@dudousxd/nestjs-agent 1.21.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/{chat-queue.service-XG9RQCjU.d.ts → chat-queue.service-CTyX_yNr.d.ts} +33 -2
- package/dist/{chat-queue.service-CGsR40Ct.d.cts → chat-queue.service-Dx9OsjcF.d.cts} +33 -2
- package/dist/durable/index.cjs +334 -237
- 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 +122 -25
- 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 +404 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -14
- package/dist/index.d.ts +43 -14
- package/dist/index.js +185 -32
- 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);
|
|
@@ -2237,7 +2287,7 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2237
2287
|
}
|
|
2238
2288
|
async write(runId, frame) {
|
|
2239
2289
|
const writer = await this.sink.open(runId);
|
|
2240
|
-
await writer.write((0,
|
|
2290
|
+
await writer.write((0, import_nestjs_agent_core14.encodeStreamEvent)(frame));
|
|
2241
2291
|
}
|
|
2242
2292
|
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
2243
2293
|
async quotaBlock(actor) {
|
|
@@ -2245,12 +2295,14 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2245
2295
|
return null;
|
|
2246
2296
|
}
|
|
2247
2297
|
try {
|
|
2248
|
-
const
|
|
2298
|
+
const report = await this.quotaProvider.report({
|
|
2249
2299
|
actor
|
|
2250
2300
|
});
|
|
2301
|
+
const { blocked } = report;
|
|
2251
2302
|
if (blocked === void 0) {
|
|
2252
2303
|
return null;
|
|
2253
2304
|
}
|
|
2305
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
2254
2306
|
return blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`;
|
|
2255
2307
|
} catch {
|
|
2256
2308
|
return null;
|
|
@@ -2339,16 +2391,16 @@ var ChatQueueService2 = class _ChatQueueService {
|
|
|
2339
2391
|
};
|
|
2340
2392
|
ChatQueueService2 = _ts_decorate8([
|
|
2341
2393
|
(0, import_common8.Injectable)(),
|
|
2342
|
-
_ts_param6(0, (0, import_common8.Inject)(
|
|
2343
|
-
_ts_param6(1, (0, import_common8.Inject)(
|
|
2394
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_STORE)),
|
|
2395
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_SINK)),
|
|
2344
2396
|
_ts_param6(2, (0, import_common8.Optional)()),
|
|
2345
|
-
_ts_param6(2, (0, import_common8.Inject)(
|
|
2397
|
+
_ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_QUOTA_PROVIDER)),
|
|
2346
2398
|
_ts_param6(3, (0, import_common8.Optional)()),
|
|
2347
|
-
_ts_param6(3, (0, import_common8.Inject)(
|
|
2399
|
+
_ts_param6(3, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
|
|
2348
2400
|
_ts_param6(4, (0, import_common8.Optional)()),
|
|
2349
|
-
_ts_param6(4, (0, import_common8.Inject)(
|
|
2401
|
+
_ts_param6(4, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_ATTACHMENT_STAGING)),
|
|
2350
2402
|
_ts_param6(5, (0, import_common8.Optional)()),
|
|
2351
|
-
_ts_param6(5, (0, import_common8.Inject)(
|
|
2403
|
+
_ts_param6(5, (0, import_common8.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
|
|
2352
2404
|
_ts_metadata6("design:type", Function),
|
|
2353
2405
|
_ts_metadata6("design:paramtypes", [
|
|
2354
2406
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
@@ -2373,7 +2425,7 @@ function queueFrame(items, paused, started) {
|
|
|
2373
2425
|
return {
|
|
2374
2426
|
kind: "queue",
|
|
2375
2427
|
queue: {
|
|
2376
|
-
items: items.map(
|
|
2428
|
+
items: items.map(import_nestjs_agent_core14.queuedMessageView),
|
|
2377
2429
|
paused
|
|
2378
2430
|
},
|
|
2379
2431
|
...started !== void 0 ? {
|
|
@@ -2384,19 +2436,19 @@ function queueFrame(items, paused, started) {
|
|
|
2384
2436
|
__name(queueFrame, "queueFrame");
|
|
2385
2437
|
|
|
2386
2438
|
// src/run-not-active.exception.ts
|
|
2387
|
-
var
|
|
2439
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2388
2440
|
var import_common9 = require("@nestjs/common");
|
|
2389
2441
|
var RunNotActiveException = class extends import_common9.ConflictException {
|
|
2390
2442
|
static {
|
|
2391
2443
|
__name(this, "RunNotActiveException");
|
|
2392
2444
|
}
|
|
2393
2445
|
runId;
|
|
2394
|
-
code =
|
|
2446
|
+
code = import_nestjs_agent_core15.RUN_NOT_ACTIVE_CODE;
|
|
2395
2447
|
constructor(runId) {
|
|
2396
2448
|
super({
|
|
2397
2449
|
statusCode: 409,
|
|
2398
|
-
code:
|
|
2399
|
-
message:
|
|
2450
|
+
code: import_nestjs_agent_core15.RUN_NOT_ACTIVE_CODE,
|
|
2451
|
+
message: import_nestjs_agent_core15.RUN_NOT_ACTIVE_MESSAGE
|
|
2400
2452
|
}), this.runId = runId;
|
|
2401
2453
|
}
|
|
2402
2454
|
};
|
|
@@ -2452,6 +2504,21 @@ var AgentService = class {
|
|
|
2452
2504
|
this.queue = queue;
|
|
2453
2505
|
this.proposals = proposals;
|
|
2454
2506
|
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Decide one independent proposal through the scoped proposal service — what the native
|
|
2509
|
+
* `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
|
|
2510
|
+
* proposals are not on, `403`/`404` when this actor may not decide it.
|
|
2511
|
+
*/
|
|
2512
|
+
async decideActionProposal(actor, threadId, proposalId, command) {
|
|
2513
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) {
|
|
2514
|
+
throw new import_common10.NotFoundException("Proposal not found");
|
|
2515
|
+
}
|
|
2516
|
+
const result = await this.proposals.decide(threadId, proposalId, actor, command);
|
|
2517
|
+
return {
|
|
2518
|
+
proposalDecision: result,
|
|
2519
|
+
text: this.proposals.reply(result, command.decision)
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2455
2522
|
async handleTextDecision(threadId, actor, text) {
|
|
2456
2523
|
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
2457
2524
|
status: "unmatched"
|
|
@@ -2499,10 +2566,12 @@ var AgentService = class {
|
|
|
2499
2566
|
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
2500
2567
|
return;
|
|
2501
2568
|
}
|
|
2502
|
-
const
|
|
2569
|
+
const report = await this.quotaProvider.report({
|
|
2503
2570
|
actor
|
|
2504
2571
|
});
|
|
2572
|
+
const { blocked } = report;
|
|
2505
2573
|
if (blocked !== void 0) {
|
|
2574
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
2506
2575
|
throw new import_common10.HttpException({
|
|
2507
2576
|
statusCode: import_common10.HttpStatus.TOO_MANY_REQUESTS,
|
|
2508
2577
|
code: "quota_exceeded",
|
|
@@ -2538,7 +2607,7 @@ var AgentService = class {
|
|
|
2538
2607
|
if (this.models === void 0) {
|
|
2539
2608
|
throw new import_common10.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
2540
2609
|
}
|
|
2541
|
-
const entry = (0,
|
|
2610
|
+
const entry = (0, import_nestjs_agent_core16.findCatalogModel)(await this.models.list({
|
|
2542
2611
|
actor,
|
|
2543
2612
|
agent
|
|
2544
2613
|
}), model);
|
|
@@ -2692,7 +2761,7 @@ var AgentService = class {
|
|
|
2692
2761
|
const mode = params.mode ?? "auto";
|
|
2693
2762
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
2694
2763
|
if (stale !== null) {
|
|
2695
|
-
await (0,
|
|
2764
|
+
await (0, import_nestjs_agent_core16.settleDeadRun)(this.store, {
|
|
2696
2765
|
runId: stale
|
|
2697
2766
|
});
|
|
2698
2767
|
}
|
|
@@ -3081,7 +3150,7 @@ var AgentService = class {
|
|
|
3081
3150
|
if (active) {
|
|
3082
3151
|
return;
|
|
3083
3152
|
}
|
|
3084
|
-
await (0,
|
|
3153
|
+
await (0, import_nestjs_agent_core16.settleDeadRun)(this.store, {
|
|
3085
3154
|
runId
|
|
3086
3155
|
});
|
|
3087
3156
|
throw new RunNotActiveException(runId);
|
|
@@ -3449,10 +3518,10 @@ var AgentService = class {
|
|
|
3449
3518
|
if (this.store.toolCallInput === void 0) {
|
|
3450
3519
|
return;
|
|
3451
3520
|
}
|
|
3452
|
-
const questions = (0,
|
|
3521
|
+
const questions = (0, import_nestjs_agent_core16.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
3453
3522
|
for (const question of questions) {
|
|
3454
3523
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
3455
|
-
const problem = (0,
|
|
3524
|
+
const problem = (0, import_nestjs_agent_core16.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
3456
3525
|
if (problem !== null) {
|
|
3457
3526
|
throw new import_common10.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
3458
3527
|
}
|
|
@@ -3466,15 +3535,15 @@ var AgentService = class {
|
|
|
3466
3535
|
*/
|
|
3467
3536
|
async assertMayDecide(actor, toolCallId2) {
|
|
3468
3537
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
3469
|
-
const approver = approval?.approver ??
|
|
3470
|
-
if (approver ===
|
|
3538
|
+
const approver = approval?.approver ?? import_nestjs_agent_core16.REQUESTER_APPROVER;
|
|
3539
|
+
if (approver === import_nestjs_agent_core16.REQUESTER_APPROVER) {
|
|
3471
3540
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
3472
3541
|
}
|
|
3473
3542
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
3474
3543
|
if (requesterRef === null) {
|
|
3475
3544
|
throw new import_common10.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
3476
3545
|
}
|
|
3477
|
-
const allowed = await (0,
|
|
3546
|
+
const allowed = await (0, import_nestjs_agent_core16.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
3478
3547
|
toolCallId: toolCallId2,
|
|
3479
3548
|
approver,
|
|
3480
3549
|
requesterRef
|
|
@@ -3526,17 +3595,17 @@ var AgentService = class {
|
|
|
3526
3595
|
};
|
|
3527
3596
|
AgentService = _ts_decorate9([
|
|
3528
3597
|
(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)(
|
|
3598
|
+
_ts_param7(0, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_RUNNER)),
|
|
3599
|
+
_ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_STORE)),
|
|
3600
|
+
_ts_param7(2, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_DEPS_FACTORY)),
|
|
3532
3601
|
_ts_param7(3, (0, import_common10.Optional)()),
|
|
3533
|
-
_ts_param7(3, (0, import_common10.Inject)(
|
|
3602
|
+
_ts_param7(3, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_ATTACHMENT_STAGING)),
|
|
3534
3603
|
_ts_param7(4, (0, import_common10.Optional)()),
|
|
3535
|
-
_ts_param7(4, (0, import_common10.Inject)(
|
|
3604
|
+
_ts_param7(4, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_MODEL_CATALOG)),
|
|
3536
3605
|
_ts_param7(5, (0, import_common10.Optional)()),
|
|
3537
|
-
_ts_param7(5, (0, import_common10.Inject)(
|
|
3606
|
+
_ts_param7(5, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_QUOTA_PROVIDER)),
|
|
3538
3607
|
_ts_param7(6, (0, import_common10.Optional)()),
|
|
3539
|
-
_ts_param7(6, (0, import_common10.Inject)(
|
|
3608
|
+
_ts_param7(6, (0, import_common10.Inject)(import_nestjs_agent_core16.AGENT_OPTIONS)),
|
|
3540
3609
|
_ts_param7(7, (0, import_common10.Optional)()),
|
|
3541
3610
|
_ts_param7(8, (0, import_common10.Optional)()),
|
|
3542
3611
|
_ts_metadata7("design:type", Function),
|
|
@@ -3651,7 +3720,7 @@ AgentApprovalPortAdapter = _ts_decorate10([
|
|
|
3651
3720
|
], AgentApprovalPortAdapter);
|
|
3652
3721
|
|
|
3653
3722
|
// src/controller/agents.controller.ts
|
|
3654
|
-
var
|
|
3723
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3655
3724
|
var import_common12 = require("@nestjs/common");
|
|
3656
3725
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
3657
3726
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3717,17 +3786,17 @@ _ts_decorate11([
|
|
|
3717
3786
|
], AgentsController.prototype, "list", null);
|
|
3718
3787
|
AgentsController = _ts_decorate11([
|
|
3719
3788
|
(0, import_common12.Controller)("agents"),
|
|
3720
|
-
_ts_param9(0, (0, import_common12.Inject)(
|
|
3721
|
-
_ts_param9(1, (0, import_common12.Inject)(
|
|
3789
|
+
_ts_param9(0, (0, import_common12.Inject)(import_nestjs_agent_core17.AGENT_REGISTRY)),
|
|
3790
|
+
_ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core17.AGENT_DEPS_FACTORY)),
|
|
3722
3791
|
_ts_metadata9("design:type", Function),
|
|
3723
3792
|
_ts_metadata9("design:paramtypes", [
|
|
3724
|
-
typeof
|
|
3793
|
+
typeof import_nestjs_agent_core17.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core17.AgentRegistry,
|
|
3725
3794
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
3726
3795
|
])
|
|
3727
3796
|
], AgentsController);
|
|
3728
3797
|
|
|
3729
3798
|
// src/controller/attachments.controller.ts
|
|
3730
|
-
var
|
|
3799
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3731
3800
|
var import_common13 = require("@nestjs/common");
|
|
3732
3801
|
var import_platform_express = require("@nestjs/platform-express");
|
|
3733
3802
|
|
|
@@ -3865,10 +3934,10 @@ _ts_decorate12([
|
|
|
3865
3934
|
], AttachmentsController.prototype, "upload", null);
|
|
3866
3935
|
AttachmentsController = _ts_decorate12([
|
|
3867
3936
|
(0, import_common13.Controller)("attachments"),
|
|
3868
|
-
_ts_param10(0, (0, import_common13.Inject)(
|
|
3869
|
-
_ts_param10(1, (0, import_common13.Inject)(
|
|
3937
|
+
_ts_param10(0, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_OPTIONS)),
|
|
3938
|
+
_ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3870
3939
|
_ts_param10(3, (0, import_common13.Optional)()),
|
|
3871
|
-
_ts_param10(3, (0, import_common13.Inject)(
|
|
3940
|
+
_ts_param10(3, (0, import_common13.Inject)(import_nestjs_agent_core18.AGENT_ATTACHMENT_STAGING)),
|
|
3872
3941
|
_ts_metadata10("design:type", Function),
|
|
3873
3942
|
_ts_metadata10("design:paramtypes", [
|
|
3874
3943
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -3879,7 +3948,7 @@ AttachmentsController = _ts_decorate12([
|
|
|
3879
3948
|
], AttachmentsController);
|
|
3880
3949
|
|
|
3881
3950
|
// src/controller/chat.controller.ts
|
|
3882
|
-
var
|
|
3951
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3883
3952
|
var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
|
|
3884
3953
|
var import_common14 = require("@nestjs/common");
|
|
3885
3954
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
@@ -4089,10 +4158,10 @@ data: ${line}
|
|
|
4089
4158
|
}
|
|
4090
4159
|
res.write("event: done\ndata: {}\n\n");
|
|
4091
4160
|
} catch (error) {
|
|
4092
|
-
const payload = error instanceof
|
|
4161
|
+
const payload = error instanceof import_nestjs_agent_core19.AgentStreamError ? {
|
|
4093
4162
|
code: error.code,
|
|
4094
4163
|
message: error.message
|
|
4095
|
-
} : (0,
|
|
4164
|
+
} : (0, import_nestjs_agent_core19.streamFailure)(error);
|
|
4096
4165
|
res.write(`event: error
|
|
4097
4166
|
data: ${JSON.stringify(payload)}
|
|
4098
4167
|
|
|
@@ -4142,7 +4211,7 @@ _ts_decorate13([
|
|
|
4142
4211
|
], ChatController.prototype, "cancel", null);
|
|
4143
4212
|
ChatController = _ts_decorate13([
|
|
4144
4213
|
(0, import_common14.Controller)(),
|
|
4145
|
-
_ts_param11(1, (0, import_common14.Inject)(
|
|
4214
|
+
_ts_param11(1, (0, import_common14.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
4146
4215
|
_ts_metadata11("design:type", Function),
|
|
4147
4216
|
_ts_metadata11("design:paramtypes", [
|
|
4148
4217
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4160,7 +4229,7 @@ function parseCursor(raw) {
|
|
|
4160
4229
|
__name(parseCursor, "parseCursor");
|
|
4161
4230
|
|
|
4162
4231
|
// src/controller/config.controller.ts
|
|
4163
|
-
var
|
|
4232
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
4164
4233
|
var import_common15 = require("@nestjs/common");
|
|
4165
4234
|
|
|
4166
4235
|
// src/resolver/anonymous-actor-resolver.ts
|
|
@@ -4318,12 +4387,12 @@ _ts_decorate14([
|
|
|
4318
4387
|
], ConfigController.prototype, "config", null);
|
|
4319
4388
|
ConfigController = _ts_decorate14([
|
|
4320
4389
|
(0, import_common15.Controller)("config"),
|
|
4321
|
-
_ts_param12(0, (0, import_common15.Inject)(
|
|
4322
|
-
_ts_param12(1, (0, import_common15.Inject)(
|
|
4390
|
+
_ts_param12(0, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
|
|
4391
|
+
_ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4323
4392
|
_ts_param12(2, (0, import_common15.Optional)()),
|
|
4324
|
-
_ts_param12(2, (0, import_common15.Inject)(
|
|
4393
|
+
_ts_param12(2, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ATTACHMENT_STAGING)),
|
|
4325
4394
|
_ts_param12(3, (0, import_common15.Optional)()),
|
|
4326
|
-
_ts_param12(3, (0, import_common15.Inject)(
|
|
4395
|
+
_ts_param12(3, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_MODEL_CATALOG)),
|
|
4327
4396
|
_ts_metadata12("design:type", Function),
|
|
4328
4397
|
_ts_metadata12("design:paramtypes", [
|
|
4329
4398
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -4334,7 +4403,7 @@ ConfigController = _ts_decorate14([
|
|
|
4334
4403
|
], ConfigController);
|
|
4335
4404
|
|
|
4336
4405
|
// src/controller/memories.controller.ts
|
|
4337
|
-
var
|
|
4406
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4338
4407
|
var import_common16 = require("@nestjs/common");
|
|
4339
4408
|
function _ts_decorate15(decorators, target, key, desc) {
|
|
4340
4409
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4403,7 +4472,7 @@ var MemoriesController = class {
|
|
|
4403
4472
|
if (entry === void 0) {
|
|
4404
4473
|
throw new import_common16.NotFoundException(`No memory with id "${id}".`);
|
|
4405
4474
|
}
|
|
4406
|
-
const verdict = (0,
|
|
4475
|
+
const verdict = (0, import_nestjs_agent_core21.memoryForgetVerdict)({
|
|
4407
4476
|
record: entry,
|
|
4408
4477
|
actor
|
|
4409
4478
|
});
|
|
@@ -4422,7 +4491,7 @@ var MemoriesController = class {
|
|
|
4422
4491
|
}
|
|
4423
4492
|
async unbounded(threadId, actor) {
|
|
4424
4493
|
const config = this.memory;
|
|
4425
|
-
return await (0,
|
|
4494
|
+
return await (0, import_nestjs_agent_core21.offerMemories)({
|
|
4426
4495
|
config: {
|
|
4427
4496
|
...config,
|
|
4428
4497
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -4458,9 +4527,9 @@ _ts_decorate15([
|
|
|
4458
4527
|
], MemoriesController.prototype, "forget", null);
|
|
4459
4528
|
MemoriesController = _ts_decorate15([
|
|
4460
4529
|
(0, import_common16.Controller)("memories"),
|
|
4461
|
-
_ts_param13(0, (0, import_common16.Inject)(
|
|
4530
|
+
_ts_param13(0, (0, import_common16.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
|
|
4462
4531
|
_ts_param13(1, (0, import_common16.Optional)()),
|
|
4463
|
-
_ts_param13(1, (0, import_common16.Inject)(
|
|
4532
|
+
_ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core21.AGENT_MEMORY)),
|
|
4464
4533
|
_ts_metadata13("design:type", Function),
|
|
4465
4534
|
_ts_metadata13("design:paramtypes", [
|
|
4466
4535
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -4469,7 +4538,7 @@ MemoriesController = _ts_decorate15([
|
|
|
4469
4538
|
], MemoriesController);
|
|
4470
4539
|
|
|
4471
4540
|
// src/controller/messages.controller.ts
|
|
4472
|
-
var
|
|
4541
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4473
4542
|
var import_common17 = require("@nestjs/common");
|
|
4474
4543
|
function _ts_decorate16(decorators, target, key, desc) {
|
|
4475
4544
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4540,7 +4609,7 @@ _ts_decorate16([
|
|
|
4540
4609
|
], MessagesController.prototype, "feedback", null);
|
|
4541
4610
|
MessagesController = _ts_decorate16([
|
|
4542
4611
|
(0, import_common17.Controller)("messages"),
|
|
4543
|
-
_ts_param14(1, (0, import_common17.Inject)(
|
|
4612
|
+
_ts_param14(1, (0, import_common17.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
|
|
4544
4613
|
_ts_metadata14("design:type", Function),
|
|
4545
4614
|
_ts_metadata14("design:paramtypes", [
|
|
4546
4615
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4549,7 +4618,7 @@ MessagesController = _ts_decorate16([
|
|
|
4549
4618
|
], MessagesController);
|
|
4550
4619
|
|
|
4551
4620
|
// src/controller/models.controller.ts
|
|
4552
|
-
var
|
|
4621
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4553
4622
|
var import_common18 = require("@nestjs/common");
|
|
4554
4623
|
function _ts_decorate17(decorators, target, key, desc) {
|
|
4555
4624
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4609,7 +4678,7 @@ _ts_decorate17([
|
|
|
4609
4678
|
], ModelsController.prototype, "list", null);
|
|
4610
4679
|
ModelsController = _ts_decorate17([
|
|
4611
4680
|
(0, import_common18.Controller)("models"),
|
|
4612
|
-
_ts_param15(1, (0, import_common18.Inject)(
|
|
4681
|
+
_ts_param15(1, (0, import_common18.Inject)(import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER)),
|
|
4613
4682
|
_ts_metadata15("design:type", Function),
|
|
4614
4683
|
_ts_metadata15("design:paramtypes", [
|
|
4615
4684
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4618,7 +4687,7 @@ ModelsController = _ts_decorate17([
|
|
|
4618
4687
|
], ModelsController);
|
|
4619
4688
|
|
|
4620
4689
|
// src/controller/queue.controller.ts
|
|
4621
|
-
var
|
|
4690
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4622
4691
|
var import_common19 = require("@nestjs/common");
|
|
4623
4692
|
function _ts_decorate18(decorators, target, key, desc) {
|
|
4624
4693
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4769,7 +4838,7 @@ _ts_decorate18([
|
|
|
4769
4838
|
], QueueController.prototype, "remove", null);
|
|
4770
4839
|
QueueController = _ts_decorate18([
|
|
4771
4840
|
(0, import_common19.Controller)(),
|
|
4772
|
-
_ts_param16(1, (0, import_common19.Inject)(
|
|
4841
|
+
_ts_param16(1, (0, import_common19.Inject)(import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER)),
|
|
4773
4842
|
_ts_metadata16("design:type", Function),
|
|
4774
4843
|
_ts_metadata16("design:paramtypes", [
|
|
4775
4844
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4778,7 +4847,7 @@ QueueController = _ts_decorate18([
|
|
|
4778
4847
|
], QueueController);
|
|
4779
4848
|
|
|
4780
4849
|
// src/controller/quota.controller.ts
|
|
4781
|
-
var
|
|
4850
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4782
4851
|
var import_common20 = require("@nestjs/common");
|
|
4783
4852
|
function _ts_decorate19(decorators, target, key, desc) {
|
|
4784
4853
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4836,7 +4905,7 @@ _ts_decorate19([
|
|
|
4836
4905
|
], QuotaController.prototype, "report", null);
|
|
4837
4906
|
QuotaController = _ts_decorate19([
|
|
4838
4907
|
(0, import_common20.Controller)("quota"),
|
|
4839
|
-
_ts_param17(1, (0, import_common20.Inject)(
|
|
4908
|
+
_ts_param17(1, (0, import_common20.Inject)(import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER)),
|
|
4840
4909
|
_ts_metadata17("design:type", Function),
|
|
4841
4910
|
_ts_metadata17("design:paramtypes", [
|
|
4842
4911
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -4845,7 +4914,7 @@ QuotaController = _ts_decorate19([
|
|
|
4845
4914
|
], QuotaController);
|
|
4846
4915
|
|
|
4847
4916
|
// src/controller/skills.controller.ts
|
|
4848
|
-
var
|
|
4917
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4849
4918
|
var import_common21 = require("@nestjs/common");
|
|
4850
4919
|
function _ts_decorate20(decorators, target, key, desc) {
|
|
4851
4920
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4888,7 +4957,7 @@ var SkillsController = class {
|
|
|
4888
4957
|
return [];
|
|
4889
4958
|
}
|
|
4890
4959
|
const actor = await this.actorResolver.resolve(req);
|
|
4891
|
-
const offer = await (0,
|
|
4960
|
+
const offer = await (0, import_nestjs_agent_core26.offerSkills)(this.skills, {
|
|
4892
4961
|
actor,
|
|
4893
4962
|
threadId: threadId ?? ""
|
|
4894
4963
|
});
|
|
@@ -4908,9 +4977,9 @@ _ts_decorate20([
|
|
|
4908
4977
|
], SkillsController.prototype, "list", null);
|
|
4909
4978
|
SkillsController = _ts_decorate20([
|
|
4910
4979
|
(0, import_common21.Controller)("skills"),
|
|
4911
|
-
_ts_param18(0, (0, import_common21.Inject)(
|
|
4980
|
+
_ts_param18(0, (0, import_common21.Inject)(import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER)),
|
|
4912
4981
|
_ts_param18(1, (0, import_common21.Optional)()),
|
|
4913
|
-
_ts_param18(1, (0, import_common21.Inject)(
|
|
4982
|
+
_ts_param18(1, (0, import_common21.Inject)(import_nestjs_agent_core26.AGENT_SKILLS)),
|
|
4914
4983
|
_ts_metadata18("design:type", Function),
|
|
4915
4984
|
_ts_metadata18("design:paramtypes", [
|
|
4916
4985
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -4919,7 +4988,7 @@ SkillsController = _ts_decorate20([
|
|
|
4919
4988
|
], SkillsController);
|
|
4920
4989
|
|
|
4921
4990
|
// src/controller/threads.controller.ts
|
|
4922
|
-
var
|
|
4991
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
4923
4992
|
var import_common22 = require("@nestjs/common");
|
|
4924
4993
|
function _ts_decorate21(decorators, target, key, desc) {
|
|
4925
4994
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5099,7 +5168,7 @@ _ts_decorate21([
|
|
|
5099
5168
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
5100
5169
|
ThreadsController = _ts_decorate21([
|
|
5101
5170
|
(0, import_common22.Controller)("threads"),
|
|
5102
|
-
_ts_param19(1, (0, import_common22.Inject)(
|
|
5171
|
+
_ts_param19(1, (0, import_common22.Inject)(import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER)),
|
|
5103
5172
|
_ts_metadata19("design:type", Function),
|
|
5104
5173
|
_ts_metadata19("design:paramtypes", [
|
|
5105
5174
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -5108,7 +5177,7 @@ ThreadsController = _ts_decorate21([
|
|
|
5108
5177
|
], ThreadsController);
|
|
5109
5178
|
|
|
5110
5179
|
// src/controller/tool-call.controller.ts
|
|
5111
|
-
var
|
|
5180
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
5112
5181
|
var import_common23 = require("@nestjs/common");
|
|
5113
5182
|
function _ts_decorate22(decorators, target, key, desc) {
|
|
5114
5183
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5314,7 +5383,7 @@ _ts_decorate22([
|
|
|
5314
5383
|
], ToolCallController.prototype, "skip", null);
|
|
5315
5384
|
ToolCallController = _ts_decorate22([
|
|
5316
5385
|
(0, import_common23.Controller)("tool-call"),
|
|
5317
|
-
_ts_param20(1, (0, import_common23.Inject)(
|
|
5386
|
+
_ts_param20(1, (0, import_common23.Inject)(import_nestjs_agent_core28.AGENT_ACTOR_RESOLVER)),
|
|
5318
5387
|
_ts_metadata20("design:type", Function),
|
|
5319
5388
|
_ts_metadata20("design:paramtypes", [
|
|
5320
5389
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -5323,7 +5392,7 @@ ToolCallController = _ts_decorate22([
|
|
|
5323
5392
|
], ToolCallController);
|
|
5324
5393
|
|
|
5325
5394
|
// src/controller/tools.controller.ts
|
|
5326
|
-
var
|
|
5395
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5327
5396
|
var import_common24 = require("@nestjs/common");
|
|
5328
5397
|
function _ts_decorate23(decorators, target, key, desc) {
|
|
5329
5398
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -5364,11 +5433,11 @@ var ToolsController = class {
|
|
|
5364
5433
|
this.agents = agents;
|
|
5365
5434
|
}
|
|
5366
5435
|
async list(req, agent) {
|
|
5367
|
-
if (agent !== void 0 && agent !==
|
|
5436
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core29.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
5368
5437
|
throw new import_common24.NotFoundException(`No agent named "${agent}"`);
|
|
5369
5438
|
}
|
|
5370
5439
|
const actor = await this.actorResolver.resolve(req);
|
|
5371
|
-
const names = agent ===
|
|
5440
|
+
const names = agent === import_nestjs_agent_core29.ALL_AGENTS ? [
|
|
5372
5441
|
void 0,
|
|
5373
5442
|
...this.agents.list().map((definition) => definition.name)
|
|
5374
5443
|
] : [
|
|
@@ -5407,19 +5476,19 @@ _ts_decorate23([
|
|
|
5407
5476
|
], ToolsController.prototype, "list", null);
|
|
5408
5477
|
ToolsController = _ts_decorate23([
|
|
5409
5478
|
(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)(
|
|
5479
|
+
_ts_param21(0, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_ACTOR_RESOLVER)),
|
|
5480
|
+
_ts_param21(1, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
|
|
5481
|
+
_ts_param21(2, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_REGISTRY)),
|
|
5413
5482
|
_ts_metadata21("design:type", Function),
|
|
5414
5483
|
_ts_metadata21("design:paramtypes", [
|
|
5415
5484
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
5416
5485
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
5417
|
-
typeof
|
|
5486
|
+
typeof import_nestjs_agent_core29.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core29.AgentRegistry
|
|
5418
5487
|
])
|
|
5419
5488
|
], ToolsController);
|
|
5420
5489
|
|
|
5421
5490
|
// src/discovery/agent-discovery.service.ts
|
|
5422
|
-
var
|
|
5491
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5423
5492
|
var import_common25 = require("@nestjs/common");
|
|
5424
5493
|
var import_core = require("@nestjs/core");
|
|
5425
5494
|
|
|
@@ -5630,19 +5699,19 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
5630
5699
|
};
|
|
5631
5700
|
AgentDiscoveryService = _ts_decorate24([
|
|
5632
5701
|
(0, import_common25.Injectable)(),
|
|
5633
|
-
_ts_param22(2, (0, import_common25.Inject)(
|
|
5634
|
-
_ts_param22(3, (0, import_common25.Inject)(
|
|
5702
|
+
_ts_param22(2, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_REGISTRY)),
|
|
5703
|
+
_ts_param22(3, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_PROMPT_CONTRIBUTORS)),
|
|
5635
5704
|
_ts_metadata22("design:type", Function),
|
|
5636
5705
|
_ts_metadata22("design:paramtypes", [
|
|
5637
5706
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
5638
5707
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
5639
|
-
typeof
|
|
5708
|
+
typeof import_nestjs_agent_core30.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core30.AgentRegistry,
|
|
5640
5709
|
Array
|
|
5641
5710
|
])
|
|
5642
5711
|
], AgentDiscoveryService);
|
|
5643
5712
|
|
|
5644
5713
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5645
|
-
var
|
|
5714
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
5646
5715
|
var import_common26 = require("@nestjs/common");
|
|
5647
5716
|
var import_core2 = require("@nestjs/core");
|
|
5648
5717
|
var import_zod = require("zod");
|
|
@@ -5755,6 +5824,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5755
5824
|
} : {}
|
|
5756
5825
|
}, {
|
|
5757
5826
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
5827
|
+
...typeof handler.present === "function" ? {
|
|
5828
|
+
present: /* @__PURE__ */ __name((output, ctx) => instance.present(output, ctx), "present")
|
|
5829
|
+
} : {},
|
|
5758
5830
|
...typeof handler.preflight === "function" ? {
|
|
5759
5831
|
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
5760
5832
|
} : {},
|
|
@@ -5781,7 +5853,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5781
5853
|
let delegates = 0;
|
|
5782
5854
|
for (const definition of this.agents.list()) {
|
|
5783
5855
|
for (const edge of definition.delegatesTo ?? []) {
|
|
5784
|
-
const { agent: target, detached } = (0,
|
|
5856
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core31.normalizeDelegation)(edge);
|
|
5785
5857
|
const targetDefinition = this.agents.get(target);
|
|
5786
5858
|
if (targetDefinition === void 0) {
|
|
5787
5859
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -5833,9 +5905,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5833
5905
|
};
|
|
5834
5906
|
AiToolDiscoveryService = _ts_decorate25([
|
|
5835
5907
|
(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)(
|
|
5908
|
+
_ts_param23(1, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_TOOL_REGISTRY)),
|
|
5909
|
+
_ts_param23(2, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_REGISTRY)),
|
|
5910
|
+
_ts_param23(3, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_OPTIONS)),
|
|
5839
5911
|
_ts_metadata23("design:type", Function),
|
|
5840
5912
|
_ts_metadata23("design:paramtypes", [
|
|
5841
5913
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
@@ -5846,20 +5918,20 @@ AiToolDiscoveryService = _ts_decorate25([
|
|
|
5846
5918
|
], AiToolDiscoveryService);
|
|
5847
5919
|
|
|
5848
5920
|
// src/discovery/skill-discovery.service.ts
|
|
5849
|
-
var
|
|
5921
|
+
var import_nestjs_agent_core33 = require("@dudousxd/nestjs-agent-core");
|
|
5850
5922
|
var import_common27 = require("@nestjs/common");
|
|
5851
5923
|
var import_core3 = require("@nestjs/core");
|
|
5852
5924
|
|
|
5853
5925
|
// src/decorator/skill.decorator.ts
|
|
5854
5926
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
5855
|
-
var
|
|
5927
|
+
var import_nestjs_agent_core32 = require("@dudousxd/nestjs-agent-core");
|
|
5856
5928
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
5857
5929
|
function readSkillMetadata(target) {
|
|
5858
5930
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
5859
5931
|
}
|
|
5860
5932
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
5861
5933
|
function skillScope(options) {
|
|
5862
|
-
return options.scope ??
|
|
5934
|
+
return options.scope ?? import_nestjs_agent_core32.GLOBAL_SCOPE;
|
|
5863
5935
|
}
|
|
5864
5936
|
__name(skillScope, "skillScope");
|
|
5865
5937
|
|
|
@@ -5935,7 +6007,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
5935
6007
|
};
|
|
5936
6008
|
SkillDiscoveryService = _ts_decorate26([
|
|
5937
6009
|
(0, import_common27.Injectable)(),
|
|
5938
|
-
_ts_param24(1, (0, import_common27.Inject)(
|
|
6010
|
+
_ts_param24(1, (0, import_common27.Inject)(import_nestjs_agent_core33.AGENT_SKILL_SOURCES)),
|
|
5939
6011
|
_ts_metadata24("design:type", Function),
|
|
5940
6012
|
_ts_metadata24("design:paramtypes", [
|
|
5941
6013
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
@@ -5944,7 +6016,7 @@ SkillDiscoveryService = _ts_decorate26([
|
|
|
5944
6016
|
], SkillDiscoveryService);
|
|
5945
6017
|
|
|
5946
6018
|
// src/ledger-quota-provider.ts
|
|
5947
|
-
var
|
|
6019
|
+
var import_nestjs_agent_core34 = require("@dudousxd/nestjs-agent-core");
|
|
5948
6020
|
var LedgerQuotaProvider = class {
|
|
5949
6021
|
static {
|
|
5950
6022
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -5964,12 +6036,12 @@ var LedgerQuotaProvider = class {
|
|
|
5964
6036
|
await this.dayWindow(actorRef, now)
|
|
5965
6037
|
];
|
|
5966
6038
|
if (this.store.usageBetween !== void 0) {
|
|
5967
|
-
const range = (0,
|
|
6039
|
+
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("month", now);
|
|
5968
6040
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
5969
6041
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
5970
6042
|
}
|
|
5971
|
-
const blocked = (0,
|
|
5972
|
-
const warning = (0,
|
|
6043
|
+
const blocked = (0, import_nestjs_agent_core34.exhaustedWindow)(windows);
|
|
6044
|
+
const warning = (0, import_nestjs_agent_core34.quotaWarning)(windows);
|
|
5973
6045
|
return {
|
|
5974
6046
|
windows,
|
|
5975
6047
|
...blocked !== void 0 ? {
|
|
@@ -5981,7 +6053,7 @@ var LedgerQuotaProvider = class {
|
|
|
5981
6053
|
};
|
|
5982
6054
|
}
|
|
5983
6055
|
async dayWindow(actorRef, now) {
|
|
5984
|
-
const range = (0,
|
|
6056
|
+
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("day", now);
|
|
5985
6057
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
5986
6058
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
5987
6059
|
}
|
|
@@ -6007,7 +6079,7 @@ var LedgerQuotaProvider = class {
|
|
|
6007
6079
|
|
|
6008
6080
|
// src/proposals/action-proposal-worker.service.ts
|
|
6009
6081
|
var import_node_crypto3 = require("crypto");
|
|
6010
|
-
var
|
|
6082
|
+
var import_nestjs_agent_core35 = require("@dudousxd/nestjs-agent-core");
|
|
6011
6083
|
var import_common28 = require("@nestjs/common");
|
|
6012
6084
|
function _ts_decorate27(decorators, target, key, desc) {
|
|
6013
6085
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6051,15 +6123,15 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6051
6123
|
}
|
|
6052
6124
|
onModuleInit() {
|
|
6053
6125
|
if (this.options.actionApprovalMode !== "independent") return;
|
|
6054
|
-
(0,
|
|
6126
|
+
(0, import_nestjs_agent_core35.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
6055
6127
|
if (this.options.surface === "http") return;
|
|
6056
6128
|
const resolver = this.options.backgroundActorResolver;
|
|
6057
6129
|
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
6058
|
-
this.worker = new
|
|
6130
|
+
this.worker = new import_nestjs_agent_core35.ActionProposalWorker({
|
|
6059
6131
|
store: this.store,
|
|
6060
6132
|
workerId: (0, import_node_crypto3.randomUUID)(),
|
|
6061
6133
|
...this.options.actionProposalWorker,
|
|
6062
|
-
executor: new
|
|
6134
|
+
executor: new import_nestjs_agent_core35.ActionProposalExecutor({
|
|
6063
6135
|
resolver,
|
|
6064
6136
|
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
6065
6137
|
const deps = this.deps.forProposal(proposal, actor);
|
|
@@ -6085,9 +6157,9 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6085
6157
|
};
|
|
6086
6158
|
ActionProposalWorkerService = _ts_decorate27([
|
|
6087
6159
|
(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)(
|
|
6160
|
+
_ts_param25(0, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_STORE)),
|
|
6161
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_OPTIONS)),
|
|
6162
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_DEPS_FACTORY)),
|
|
6091
6163
|
_ts_metadata25("design:type", Function),
|
|
6092
6164
|
_ts_metadata25("design:paramtypes", [
|
|
6093
6165
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
@@ -6097,7 +6169,7 @@ ActionProposalWorkerService = _ts_decorate27([
|
|
|
6097
6169
|
], ActionProposalWorkerService);
|
|
6098
6170
|
|
|
6099
6171
|
// src/proposals/action-proposal.controller.ts
|
|
6100
|
-
var
|
|
6172
|
+
var import_nestjs_agent_core36 = require("@dudousxd/nestjs-agent-core");
|
|
6101
6173
|
var import_common29 = require("@nestjs/common");
|
|
6102
6174
|
function _ts_decorate28(decorators, target, key, desc) {
|
|
6103
6175
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6151,7 +6223,7 @@ var ActionProposalController = class {
|
|
|
6151
6223
|
query = {
|
|
6152
6224
|
after: JSON.parse(cursor)
|
|
6153
6225
|
};
|
|
6154
|
-
(0,
|
|
6226
|
+
(0, import_nestjs_agent_core36.validateActionProposalListQuery)(query);
|
|
6155
6227
|
} catch {
|
|
6156
6228
|
throw new import_common29.BadRequestException("Invalid action proposal cursor");
|
|
6157
6229
|
}
|
|
@@ -6232,7 +6304,7 @@ _ts_decorate28([
|
|
|
6232
6304
|
], ActionProposalController.prototype, "reject", null);
|
|
6233
6305
|
ActionProposalController = _ts_decorate28([
|
|
6234
6306
|
(0, import_common29.Controller)("threads/:threadId/action-proposals"),
|
|
6235
|
-
_ts_param26(1, (0, import_common29.Inject)(
|
|
6307
|
+
_ts_param26(1, (0, import_common29.Inject)(import_nestjs_agent_core36.AGENT_ACTOR_RESOLVER)),
|
|
6236
6308
|
_ts_metadata26("design:type", Function),
|
|
6237
6309
|
_ts_metadata26("design:paramtypes", [
|
|
6238
6310
|
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
@@ -6241,7 +6313,7 @@ ActionProposalController = _ts_decorate28([
|
|
|
6241
6313
|
], ActionProposalController);
|
|
6242
6314
|
|
|
6243
6315
|
// src/runner/inline-agent-runner.ts
|
|
6244
|
-
var
|
|
6316
|
+
var import_nestjs_agent_core37 = require("@dudousxd/nestjs-agent-core");
|
|
6245
6317
|
var import_common30 = require("@nestjs/common");
|
|
6246
6318
|
function _ts_decorate29(decorators, target, key, desc) {
|
|
6247
6319
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6325,18 +6397,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6325
6397
|
],
|
|
6326
6398
|
input
|
|
6327
6399
|
});
|
|
6328
|
-
void (0,
|
|
6400
|
+
void (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
6329
6401
|
...deps,
|
|
6330
6402
|
day
|
|
6331
|
-
}, input, hooks).then(() => (0,
|
|
6332
|
-
if (error instanceof
|
|
6403
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
6404
|
+
if (error instanceof import_nestjs_agent_core37.RunCancelledError) {
|
|
6333
6405
|
await this.settleCancelled(runId, input, deps);
|
|
6334
6406
|
return;
|
|
6335
6407
|
}
|
|
6336
6408
|
const message = error instanceof Error ? error.message : String(error);
|
|
6337
|
-
const code = (0,
|
|
6409
|
+
const code = (0, import_nestjs_agent_core37.agentFailureCode)(error);
|
|
6338
6410
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
6339
|
-
(0,
|
|
6411
|
+
(0, import_nestjs_agent_core37.publishAgentRunFailed)({
|
|
6340
6412
|
runId,
|
|
6341
6413
|
code,
|
|
6342
6414
|
message
|
|
@@ -6347,11 +6419,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6347
6419
|
errorCode: code,
|
|
6348
6420
|
errorMessage: message
|
|
6349
6421
|
});
|
|
6350
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6422
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core37.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6351
6423
|
const writer = await deps.sink.open(runId);
|
|
6352
6424
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
6353
|
-
await (0,
|
|
6354
|
-
await writer.fail((0,
|
|
6425
|
+
await (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6426
|
+
await writer.fail((0, import_nestjs_agent_core37.streamFailure)(error));
|
|
6355
6427
|
}).finally(() => {
|
|
6356
6428
|
this.cancelled.delete(runId);
|
|
6357
6429
|
this.live.delete(runId);
|
|
@@ -6387,7 +6459,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6387
6459
|
for (const [key, waiter] of this.pending) {
|
|
6388
6460
|
if (key.startsWith(`${runId}:`)) {
|
|
6389
6461
|
this.pending.delete(key);
|
|
6390
|
-
waiter.reject(new
|
|
6462
|
+
waiter.reject(new import_nestjs_agent_core37.RunCancelledError());
|
|
6391
6463
|
}
|
|
6392
6464
|
}
|
|
6393
6465
|
await Promise.resolve();
|
|
@@ -6402,8 +6474,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6402
6474
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
6403
6475
|
const writer = await deps.sink.open(runId);
|
|
6404
6476
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
6405
|
-
await (0,
|
|
6406
|
-
await writer.write((0,
|
|
6477
|
+
await (0, import_nestjs_agent_core37.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6478
|
+
await writer.write((0, import_nestjs_agent_core37.encodeStreamEvent)({
|
|
6407
6479
|
kind: "cancelled"
|
|
6408
6480
|
}));
|
|
6409
6481
|
await writer.end();
|
|
@@ -6438,7 +6510,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6438
6510
|
runId: nextRunId
|
|
6439
6511
|
}));
|
|
6440
6512
|
if (frame !== void 0) {
|
|
6441
|
-
await writer.write((0,
|
|
6513
|
+
await writer.write((0, import_nestjs_agent_core37.encodeStreamEvent)(frame));
|
|
6442
6514
|
}
|
|
6443
6515
|
} catch (failure) {
|
|
6444
6516
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -6509,7 +6581,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6509
6581
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6510
6582
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6511
6583
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6512
|
-
parallel:
|
|
6584
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
6513
6585
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
6514
6586
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
6515
6587
|
agentName,
|
|
@@ -6560,7 +6632,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6560
6632
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6561
6633
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6562
6634
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6563
|
-
parallel:
|
|
6635
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
6564
6636
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
6565
6637
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
6566
6638
|
agentName: childName,
|
|
@@ -6593,7 +6665,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6593
6665
|
}
|
|
6594
6666
|
}), "startAgent")
|
|
6595
6667
|
};
|
|
6596
|
-
void (0,
|
|
6668
|
+
void (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
6597
6669
|
...deps,
|
|
6598
6670
|
day
|
|
6599
6671
|
}, {
|
|
@@ -6607,13 +6679,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6607
6679
|
parentRunId,
|
|
6608
6680
|
deliverTo
|
|
6609
6681
|
}, hooks).catch(async (error) => {
|
|
6610
|
-
const cancelled = error instanceof
|
|
6682
|
+
const cancelled = error instanceof import_nestjs_agent_core37.RunCancelledError;
|
|
6611
6683
|
const message = error instanceof Error ? error.message : String(error);
|
|
6612
6684
|
if (!cancelled) {
|
|
6613
6685
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
6614
|
-
(0,
|
|
6686
|
+
(0, import_nestjs_agent_core37.publishAgentRunFailed)({
|
|
6615
6687
|
runId,
|
|
6616
|
-
code: (0,
|
|
6688
|
+
code: (0, import_nestjs_agent_core37.agentFailureCode)(error),
|
|
6617
6689
|
message
|
|
6618
6690
|
});
|
|
6619
6691
|
}
|
|
@@ -6621,12 +6693,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6621
6693
|
runId,
|
|
6622
6694
|
status: cancelled ? "cancelled" : "failed",
|
|
6623
6695
|
...cancelled ? {} : {
|
|
6624
|
-
errorCode: (0,
|
|
6696
|
+
errorCode: (0, import_nestjs_agent_core37.agentFailureCode)(error),
|
|
6625
6697
|
errorMessage: message
|
|
6626
6698
|
}
|
|
6627
6699
|
});
|
|
6628
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6629
|
-
await (0,
|
|
6700
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core37.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6701
|
+
await (0, import_nestjs_agent_core37.settleUnsettledDelegation)({
|
|
6630
6702
|
store: this.store,
|
|
6631
6703
|
delivery: deliverTo,
|
|
6632
6704
|
agent: agentName,
|
|
@@ -6665,7 +6737,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6665
6737
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6666
6738
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6667
6739
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6668
|
-
parallel:
|
|
6740
|
+
parallel: import_nestjs_agent_core37.settleAll,
|
|
6669
6741
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
6670
6742
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
6671
6743
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -6700,7 +6772,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6700
6772
|
}), "startAgent")
|
|
6701
6773
|
};
|
|
6702
6774
|
try {
|
|
6703
|
-
return await (0,
|
|
6775
|
+
return await (0, import_nestjs_agent_core37.runAgentLoop)({
|
|
6704
6776
|
...deps,
|
|
6705
6777
|
day
|
|
6706
6778
|
}, {
|
|
@@ -6721,8 +6793,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6721
6793
|
};
|
|
6722
6794
|
InlineAgentRunner = _ts_decorate29([
|
|
6723
6795
|
(0, import_common30.Injectable)(),
|
|
6724
|
-
_ts_param27(0, (0, import_common30.Inject)(
|
|
6725
|
-
_ts_param27(1, (0, import_common30.Inject)(
|
|
6796
|
+
_ts_param27(0, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_DEPS_FACTORY)),
|
|
6797
|
+
_ts_param27(1, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_STORE)),
|
|
6726
6798
|
_ts_param27(2, (0, import_common30.Optional)()),
|
|
6727
6799
|
_ts_metadata27("design:type", Function),
|
|
6728
6800
|
_ts_metadata27("design:paramtypes", [
|
|
@@ -6737,7 +6809,7 @@ function isThreadTurn2(input) {
|
|
|
6737
6809
|
__name(isThreadTurn2, "isThreadTurn");
|
|
6738
6810
|
|
|
6739
6811
|
// src/skills-config.ts
|
|
6740
|
-
var
|
|
6812
|
+
var import_nestjs_agent_core38 = require("@dudousxd/nestjs-agent-core");
|
|
6741
6813
|
function declaredSkillProvider(declared) {
|
|
6742
6814
|
return {
|
|
6743
6815
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -6763,7 +6835,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
6763
6835
|
declaredSkillProvider(declared)
|
|
6764
6836
|
];
|
|
6765
6837
|
return {
|
|
6766
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
6838
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core38.compositeSkillProvider)(providers),
|
|
6767
6839
|
...options.scopes !== void 0 ? {
|
|
6768
6840
|
scopes: options.scopes
|
|
6769
6841
|
} : {},
|
|
@@ -6791,15 +6863,15 @@ function _ts_decorate30(decorators, target, key, desc) {
|
|
|
6791
6863
|
__name(_ts_decorate30, "_ts_decorate");
|
|
6792
6864
|
var DEFAULT_PATH = "agent";
|
|
6793
6865
|
var logger = new import_common31.Logger("AgentModule");
|
|
6794
|
-
function
|
|
6866
|
+
function externalWrapper(modules, token) {
|
|
6795
6867
|
for (const module2 of modules.values()) {
|
|
6796
6868
|
if (module2.metatype === AgentModule) continue;
|
|
6797
|
-
const wrapper = module2.providers.get(
|
|
6869
|
+
const wrapper = module2.providers.get(token);
|
|
6798
6870
|
if (wrapper !== void 0) return wrapper;
|
|
6799
6871
|
}
|
|
6800
6872
|
return void 0;
|
|
6801
6873
|
}
|
|
6802
|
-
__name(
|
|
6874
|
+
__name(externalWrapper, "externalWrapper");
|
|
6803
6875
|
function forwardingStore(wrapper) {
|
|
6804
6876
|
const target = /* @__PURE__ */ __name(() => {
|
|
6805
6877
|
const instance = wrapper.instance;
|
|
@@ -6822,12 +6894,36 @@ function forwardingStore(wrapper) {
|
|
|
6822
6894
|
__name(forwardingStore, "forwardingStore");
|
|
6823
6895
|
function resolveStore(options, modules) {
|
|
6824
6896
|
if (options.store !== void 0) return options.store;
|
|
6825
|
-
const external =
|
|
6897
|
+
const external = externalWrapper(modules, import_nestjs_agent_core39.AGENT_STORE);
|
|
6826
6898
|
if (external !== void 0) return forwardingStore(external);
|
|
6827
6899
|
logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
|
|
6828
|
-
return new
|
|
6900
|
+
return new import_nestjs_agent_core39.InMemoryAgentStore();
|
|
6829
6901
|
}
|
|
6830
6902
|
__name(resolveStore, "resolveStore");
|
|
6903
|
+
function resolveRolesPolicy(options, modules) {
|
|
6904
|
+
const external = externalWrapper(modules, import_nestjs_agent_core39.AGENT_ROLES_POLICY);
|
|
6905
|
+
if (options.rolesPolicy !== void 0) {
|
|
6906
|
+
if (external !== void 0) {
|
|
6907
|
+
logger.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
6908
|
+
}
|
|
6909
|
+
return options.rolesPolicy;
|
|
6910
|
+
}
|
|
6911
|
+
if (external !== void 0) return forwardingPolicy(external);
|
|
6912
|
+
return options.emptyRoles === "deny" ? new import_nestjs_agent_core39.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core39.DefaultRolesPolicy(options.defaultRoles);
|
|
6913
|
+
}
|
|
6914
|
+
__name(resolveRolesPolicy, "resolveRolesPolicy");
|
|
6915
|
+
function forwardingPolicy(wrapper) {
|
|
6916
|
+
return {
|
|
6917
|
+
can(actor, tool) {
|
|
6918
|
+
const policy = wrapper.instance;
|
|
6919
|
+
if (policy === void 0 || policy === null) {
|
|
6920
|
+
throw new Error("AgentModule: the AGENT_ROLES_POLICY bound by another module is not ready yet");
|
|
6921
|
+
}
|
|
6922
|
+
return policy.can(actor, tool);
|
|
6923
|
+
}
|
|
6924
|
+
};
|
|
6925
|
+
}
|
|
6926
|
+
__name(forwardingPolicy, "forwardingPolicy");
|
|
6831
6927
|
function isQuotaProvider(quota) {
|
|
6832
6928
|
return quota !== void 0 && typeof quota.report === "function";
|
|
6833
6929
|
}
|
|
@@ -6841,99 +6937,100 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
6841
6937
|
function sharedProviders(durable) {
|
|
6842
6938
|
const providers = [
|
|
6843
6939
|
{
|
|
6844
|
-
provide:
|
|
6845
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6940
|
+
provide: import_nestjs_agent_core39.AGENT_TOOL_REGISTRY,
|
|
6941
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core39.ToolRegistry(), "useFactory")
|
|
6846
6942
|
},
|
|
6847
6943
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
6848
6944
|
{
|
|
6849
|
-
provide:
|
|
6850
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
6945
|
+
provide: import_nestjs_agent_core39.AGENT_REGISTRY,
|
|
6946
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core39.AgentRegistry(), "useFactory")
|
|
6851
6947
|
},
|
|
6852
6948
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
6853
6949
|
{
|
|
6854
|
-
provide:
|
|
6950
|
+
provide: import_nestjs_agent_core39.AGENT_PROMPT_CONTRIBUTORS,
|
|
6855
6951
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6856
6952
|
},
|
|
6857
6953
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
6858
6954
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
6859
6955
|
{
|
|
6860
|
-
provide:
|
|
6956
|
+
provide: import_nestjs_agent_core39.AGENT_SKILL_SOURCES,
|
|
6861
6957
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
6862
6958
|
},
|
|
6863
6959
|
{
|
|
6864
6960
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
6865
6961
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
6866
6962
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
6867
|
-
provide:
|
|
6963
|
+
provide: import_nestjs_agent_core39.AGENT_SKILLS,
|
|
6868
6964
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
6869
6965
|
inject: [
|
|
6870
|
-
|
|
6871
|
-
|
|
6966
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6967
|
+
import_nestjs_agent_core39.AGENT_SKILL_SOURCES
|
|
6872
6968
|
]
|
|
6873
6969
|
},
|
|
6874
6970
|
{
|
|
6875
6971
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
6876
6972
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
6877
|
-
provide:
|
|
6973
|
+
provide: import_nestjs_agent_core39.AGENT_MEMORY,
|
|
6878
6974
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
6879
6975
|
inject: [
|
|
6880
|
-
|
|
6976
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6881
6977
|
]
|
|
6882
6978
|
},
|
|
6883
6979
|
{
|
|
6884
|
-
provide:
|
|
6980
|
+
provide: import_nestjs_agent_core39.AGENT_SINK,
|
|
6885
6981
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
6886
6982
|
inject: [
|
|
6887
|
-
|
|
6983
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6888
6984
|
]
|
|
6889
6985
|
},
|
|
6890
6986
|
{
|
|
6891
|
-
provide:
|
|
6892
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
6987
|
+
provide: import_nestjs_agent_core39.AGENT_ROLES_POLICY,
|
|
6988
|
+
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
6893
6989
|
inject: [
|
|
6894
|
-
|
|
6990
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6991
|
+
import_core4.ModulesContainer
|
|
6895
6992
|
]
|
|
6896
6993
|
},
|
|
6897
6994
|
{
|
|
6898
|
-
provide:
|
|
6995
|
+
provide: import_nestjs_agent_core39.AGENT_ACTOR_RESOLVER,
|
|
6899
6996
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
6900
6997
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
6901
6998
|
logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
|
|
6902
6999
|
return new AnonymousActorResolver();
|
|
6903
7000
|
}, "useFactory"),
|
|
6904
7001
|
inject: [
|
|
6905
|
-
|
|
7002
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6906
7003
|
]
|
|
6907
7004
|
},
|
|
6908
7005
|
{
|
|
6909
|
-
provide:
|
|
7006
|
+
provide: import_nestjs_agent_core39.AGENT_MODEL,
|
|
6910
7007
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
6911
7008
|
inject: [
|
|
6912
|
-
|
|
7009
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6913
7010
|
]
|
|
6914
7011
|
},
|
|
6915
7012
|
{
|
|
6916
7013
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
6917
7014
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
6918
|
-
provide:
|
|
7015
|
+
provide: import_nestjs_agent_core39.AGENT_QUOTA_PROVIDER,
|
|
6919
7016
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
6920
7017
|
warnAt: o.quota.warnAt
|
|
6921
7018
|
} : {}), "useFactory"),
|
|
6922
7019
|
inject: [
|
|
6923
|
-
|
|
6924
|
-
|
|
7020
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7021
|
+
import_nestjs_agent_core39.AGENT_STORE
|
|
6925
7022
|
]
|
|
6926
7023
|
},
|
|
6927
7024
|
{
|
|
6928
|
-
provide:
|
|
7025
|
+
provide: import_nestjs_agent_core39.AGENT_MODEL_CATALOG,
|
|
6929
7026
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
6930
7027
|
inject: [
|
|
6931
|
-
|
|
7028
|
+
import_nestjs_agent_core39.AGENT_OPTIONS
|
|
6932
7029
|
]
|
|
6933
7030
|
},
|
|
6934
7031
|
AgentDepsFactory2,
|
|
6935
7032
|
{
|
|
6936
|
-
provide:
|
|
7033
|
+
provide: import_nestjs_agent_core39.AGENT_DEPS_FACTORY,
|
|
6937
7034
|
useExisting: AgentDepsFactory2
|
|
6938
7035
|
},
|
|
6939
7036
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -6956,21 +7053,21 @@ function sharedProviders(durable) {
|
|
|
6956
7053
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
6957
7054
|
AgentApprovalPortAdapter,
|
|
6958
7055
|
{
|
|
6959
|
-
provide:
|
|
7056
|
+
provide: import_nestjs_agent_core39.AGENT_APPROVAL_PORT,
|
|
6960
7057
|
useExisting: AgentApprovalPortAdapter
|
|
6961
7058
|
}
|
|
6962
7059
|
];
|
|
6963
7060
|
providers.push({
|
|
6964
|
-
provide:
|
|
7061
|
+
provide: import_nestjs_agent_core39.AGENT_STORE,
|
|
6965
7062
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
6966
7063
|
inject: [
|
|
6967
|
-
|
|
7064
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
6968
7065
|
import_core4.ModulesContainer
|
|
6969
7066
|
]
|
|
6970
7067
|
});
|
|
6971
7068
|
if (durable) {
|
|
6972
7069
|
providers.push({
|
|
6973
|
-
provide:
|
|
7070
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
6974
7071
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
6975
7072
|
if (durableRunner === void 0) {
|
|
6976
7073
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -6979,14 +7076,14 @@ function sharedProviders(durable) {
|
|
|
6979
7076
|
}, "useFactory"),
|
|
6980
7077
|
inject: [
|
|
6981
7078
|
{
|
|
6982
|
-
token:
|
|
7079
|
+
token: import_nestjs_agent_core39.AGENT_DURABLE_RUNNER,
|
|
6983
7080
|
optional: true
|
|
6984
7081
|
}
|
|
6985
7082
|
]
|
|
6986
7083
|
});
|
|
6987
7084
|
} else {
|
|
6988
7085
|
providers.push({
|
|
6989
|
-
provide:
|
|
7086
|
+
provide: import_nestjs_agent_core39.AGENT_RUNNER,
|
|
6990
7087
|
useExisting: InlineAgentRunner
|
|
6991
7088
|
});
|
|
6992
7089
|
}
|
|
@@ -6995,20 +7092,20 @@ function sharedProviders(durable) {
|
|
|
6995
7092
|
__name(sharedProviders, "sharedProviders");
|
|
6996
7093
|
function exportsFor() {
|
|
6997
7094
|
return [
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7095
|
+
import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7096
|
+
import_nestjs_agent_core39.AGENT_TOOL_REGISTRY,
|
|
7097
|
+
import_nestjs_agent_core39.AGENT_REGISTRY,
|
|
7098
|
+
import_nestjs_agent_core39.AGENT_SINK,
|
|
7099
|
+
import_nestjs_agent_core39.AGENT_ROLES_POLICY,
|
|
7100
|
+
import_nestjs_agent_core39.AGENT_ACTOR_RESOLVER,
|
|
7101
|
+
import_nestjs_agent_core39.AGENT_MODEL,
|
|
7102
|
+
import_nestjs_agent_core39.AGENT_STORE,
|
|
7103
|
+
import_nestjs_agent_core39.AGENT_MODEL_CATALOG,
|
|
7104
|
+
import_nestjs_agent_core39.AGENT_QUOTA_PROVIDER,
|
|
7105
|
+
import_nestjs_agent_core39.AGENT_PROMPT_CONTRIBUTORS,
|
|
7106
|
+
import_nestjs_agent_core39.AGENT_SKILLS,
|
|
7107
|
+
import_nestjs_agent_core39.AGENT_MEMORY,
|
|
7108
|
+
import_nestjs_agent_core39.AGENT_DEPS_FACTORY,
|
|
7012
7109
|
AgentDepsFactory2,
|
|
7013
7110
|
AgentService,
|
|
7014
7111
|
ActionProposalService,
|
|
@@ -7016,7 +7113,7 @@ function exportsFor() {
|
|
|
7016
7113
|
ChatQueueService2,
|
|
7017
7114
|
AGENT_CHAT_QUEUE,
|
|
7018
7115
|
InlineAgentRunner,
|
|
7019
|
-
|
|
7116
|
+
import_nestjs_agent_core39.AGENT_APPROVAL_PORT
|
|
7020
7117
|
];
|
|
7021
7118
|
}
|
|
7022
7119
|
__name(exportsFor, "exportsFor");
|
|
@@ -7094,7 +7191,7 @@ var AgentModule = class _AgentModule {
|
|
|
7094
7191
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
7095
7192
|
providers: [
|
|
7096
7193
|
{
|
|
7097
|
-
provide:
|
|
7194
|
+
provide: import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7098
7195
|
useValue: options
|
|
7099
7196
|
},
|
|
7100
7197
|
...sharedProviders(options.durable ?? false),
|
|
@@ -7118,7 +7215,7 @@ var AgentModule = class _AgentModule {
|
|
|
7118
7215
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
7119
7216
|
providers: [
|
|
7120
7217
|
{
|
|
7121
|
-
provide:
|
|
7218
|
+
provide: import_nestjs_agent_core39.AGENT_OPTIONS,
|
|
7122
7219
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
7123
7220
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
7124
7221
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|