@dudousxd/nestjs-agent 1.10.0 → 1.12.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 +75 -48
- package/dist/{agent-deps.factory-DuTy1UyU.d.cts → agent-deps.factory-pqv_qTmJ.d.cts} +47 -71
- package/dist/{agent-deps.factory-DuTy1UyU.d.ts → agent-deps.factory-pqv_qTmJ.d.ts} +47 -71
- package/dist/durable/index.cjs +729 -584
- 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 +634 -489
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +805 -591
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -55
- package/dist/index.d.ts +137 -55
- package/dist/index.js +699 -491
- package/dist/index.js.map +1 -1
- package/dist/media/index.cjs +11 -2
- package/dist/media/index.cjs.map +1 -1
- package/dist/media/index.d.cts +5 -1
- package/dist/media/index.d.ts +5 -1
- package/dist/media/index.js +11 -2
- package/dist/media/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.js
CHANGED
|
@@ -800,12 +800,12 @@ AgentDurableModule = _ts_decorate4([
|
|
|
800
800
|
], AgentDurableModule);
|
|
801
801
|
|
|
802
802
|
// src/agent.module.ts
|
|
803
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
804
|
-
import { Global as Global2, Module as Module2 } from "@nestjs/common";
|
|
805
|
-
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
803
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS6, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE6, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
804
|
+
import { Global as Global2, Logger as Logger6, Module as Module2 } from "@nestjs/common";
|
|
805
|
+
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
806
806
|
|
|
807
807
|
// src/agent-deps.factory.ts
|
|
808
|
-
import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS,
|
|
808
|
+
import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK2, AGENT_SKILLS, AGENT_STORE as AGENT_STORE3, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, normalizeDelegation, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
|
|
809
809
|
import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
|
|
810
810
|
import { Inject as Inject4, Injectable as Injectable4, Optional as Optional2 } from "@nestjs/common";
|
|
811
811
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
@@ -851,11 +851,10 @@ var AgentDepsFactory2 = class {
|
|
|
851
851
|
registry;
|
|
852
852
|
agents;
|
|
853
853
|
promptContributors;
|
|
854
|
-
quota;
|
|
855
854
|
pricingStore;
|
|
856
855
|
skills;
|
|
857
856
|
memory;
|
|
858
|
-
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors,
|
|
857
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory) {
|
|
859
858
|
this.options = options;
|
|
860
859
|
this.model = model;
|
|
861
860
|
this.store = store;
|
|
@@ -864,7 +863,6 @@ var AgentDepsFactory2 = class {
|
|
|
864
863
|
this.registry = registry;
|
|
865
864
|
this.agents = agents;
|
|
866
865
|
this.promptContributors = promptContributors;
|
|
867
|
-
this.quota = quota;
|
|
868
866
|
this.pricingStore = pricingStore;
|
|
869
867
|
this.skills = skills;
|
|
870
868
|
this.memory = memory;
|
|
@@ -925,7 +923,7 @@ var AgentDepsFactory2 = class {
|
|
|
925
923
|
} : {},
|
|
926
924
|
registry: this.registry,
|
|
927
925
|
promptContributors: this.promptContributors,
|
|
928
|
-
systemPrompt: definition?.systemPrompt ?? "You are a helpful assistant.",
|
|
926
|
+
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
929
927
|
maxSteps: definition?.maxSteps ?? 8,
|
|
930
928
|
...definition?.maxDelegationDepth !== void 0 ? {
|
|
931
929
|
maxDelegationDepth: definition.maxDelegationDepth
|
|
@@ -936,9 +934,6 @@ var AgentDepsFactory2 = class {
|
|
|
936
934
|
...definition?.modelId !== void 0 ? {
|
|
937
935
|
modelId: definition.modelId
|
|
938
936
|
} : {},
|
|
939
|
-
...this.quota !== void 0 ? {
|
|
940
|
-
quota: this.quota
|
|
941
|
-
} : {},
|
|
942
937
|
...this.pricingStore !== void 0 ? {
|
|
943
938
|
pricingStore: this.pricingStore
|
|
944
939
|
} : {},
|
|
@@ -1045,13 +1040,12 @@ AgentDepsFactory2 = _ts_decorate5([
|
|
|
1045
1040
|
_ts_param4(5, Inject4(AGENT_TOOL_REGISTRY)),
|
|
1046
1041
|
_ts_param4(6, Inject4(AGENT_REGISTRY)),
|
|
1047
1042
|
_ts_param4(7, Inject4(AGENT_PROMPT_CONTRIBUTORS)),
|
|
1048
|
-
_ts_param4(8,
|
|
1043
|
+
_ts_param4(8, Optional2()),
|
|
1044
|
+
_ts_param4(8, Inject4(AGENT_PRICING_STORE)),
|
|
1049
1045
|
_ts_param4(9, Optional2()),
|
|
1050
|
-
_ts_param4(9, Inject4(
|
|
1046
|
+
_ts_param4(9, Inject4(AGENT_SKILLS)),
|
|
1051
1047
|
_ts_param4(10, Optional2()),
|
|
1052
|
-
_ts_param4(10, Inject4(
|
|
1053
|
-
_ts_param4(11, Optional2()),
|
|
1054
|
-
_ts_param4(11, Inject4(AGENT_MEMORY)),
|
|
1048
|
+
_ts_param4(10, Inject4(AGENT_MEMORY)),
|
|
1055
1049
|
_ts_metadata4("design:type", Function),
|
|
1056
1050
|
_ts_metadata4("design:paramtypes", [
|
|
1057
1051
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -1064,13 +1058,12 @@ AgentDepsFactory2 = _ts_decorate5([
|
|
|
1064
1058
|
Array,
|
|
1065
1059
|
Object,
|
|
1066
1060
|
Object,
|
|
1067
|
-
Object,
|
|
1068
1061
|
Object
|
|
1069
1062
|
])
|
|
1070
1063
|
], AgentDepsFactory2);
|
|
1071
1064
|
|
|
1072
1065
|
// src/agent.service.ts
|
|
1073
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER,
|
|
1066
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
1074
1067
|
import { BadRequestException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject5, Injectable as Injectable5, NotFoundException, NotImplementedException, Optional as Optional3 } from "@nestjs/common";
|
|
1075
1068
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1076
1069
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1105,16 +1098,14 @@ var AgentService = class {
|
|
|
1105
1098
|
runner;
|
|
1106
1099
|
store;
|
|
1107
1100
|
deps;
|
|
1108
|
-
quota;
|
|
1109
1101
|
staging;
|
|
1110
1102
|
models;
|
|
1111
1103
|
quotaProvider;
|
|
1112
1104
|
options;
|
|
1113
|
-
constructor(runner, store, deps,
|
|
1105
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options) {
|
|
1114
1106
|
this.runner = runner;
|
|
1115
1107
|
this.store = store;
|
|
1116
1108
|
this.deps = deps;
|
|
1117
|
-
this.quota = quota;
|
|
1118
1109
|
this.staging = staging;
|
|
1119
1110
|
this.models = models;
|
|
1120
1111
|
this.quotaProvider = quotaProvider;
|
|
@@ -1130,33 +1121,23 @@ var AgentService = class {
|
|
|
1130
1121
|
actor
|
|
1131
1122
|
});
|
|
1132
1123
|
}
|
|
1133
|
-
const
|
|
1124
|
+
const { usedTokens, costUsd } = await this.store.quotaToday(actor.id, utcDay());
|
|
1134
1125
|
return {
|
|
1135
1126
|
windows: [
|
|
1136
1127
|
{
|
|
1137
1128
|
period: "day",
|
|
1138
|
-
usedTokens
|
|
1139
|
-
|
|
1140
|
-
limitTokens: today.limitTokens
|
|
1141
|
-
} : {},
|
|
1142
|
-
usedUsd: today.costUsd
|
|
1143
|
-
}
|
|
1144
|
-
],
|
|
1145
|
-
...today.withinLimit ? {} : {
|
|
1146
|
-
blocked: {
|
|
1147
|
-
period: "day"
|
|
1129
|
+
usedTokens,
|
|
1130
|
+
usedUsd: costUsd
|
|
1148
1131
|
}
|
|
1149
|
-
|
|
1132
|
+
]
|
|
1150
1133
|
};
|
|
1151
1134
|
}
|
|
1152
1135
|
/**
|
|
1153
1136
|
* Refuse a turn the actor's budget no longer covers — only when the host configured one
|
|
1154
|
-
* (`
|
|
1155
|
-
* quota the loop enforces keeps working as it always has.
|
|
1137
|
+
* (`quota`): the default report is informational.
|
|
1156
1138
|
*/
|
|
1157
1139
|
async assertWithinQuota(actor) {
|
|
1158
|
-
|
|
1159
|
-
if (!gated || this.quotaProvider === void 0) {
|
|
1140
|
+
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
1160
1141
|
return;
|
|
1161
1142
|
}
|
|
1162
1143
|
const { blocked } = await this.quotaProvider.report({
|
|
@@ -1407,7 +1388,7 @@ var AgentService = class {
|
|
|
1407
1388
|
async getThread(actor, threadId) {
|
|
1408
1389
|
await this.assertOwnsThread(actor, threadId);
|
|
1409
1390
|
const thread = await this.store.getThread(threadId);
|
|
1410
|
-
return thread === null ? null : this.toDetailView(thread);
|
|
1391
|
+
return thread === null ? null : this.toDetailView(thread, actor);
|
|
1411
1392
|
}
|
|
1412
1393
|
async deleteThread(actor, threadId) {
|
|
1413
1394
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -1499,19 +1480,46 @@ var AgentService = class {
|
|
|
1499
1480
|
...thread,
|
|
1500
1481
|
defaultAgent: thread.defaultAgent ?? null,
|
|
1501
1482
|
model: thread.model ?? null,
|
|
1502
|
-
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
1483
|
+
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? thread.activeRunId ?? null
|
|
1503
1484
|
};
|
|
1504
1485
|
}
|
|
1505
|
-
async toDetailView(thread) {
|
|
1486
|
+
async toDetailView(thread, actor) {
|
|
1506
1487
|
const summary = await this.toSummaryView(thread);
|
|
1507
1488
|
return {
|
|
1508
1489
|
...summary,
|
|
1509
|
-
messages: thread.messages,
|
|
1510
|
-
...thread.activeStreamId !== void 0 ? {
|
|
1511
|
-
activeStreamId: thread.activeStreamId
|
|
1512
|
-
} : {}
|
|
1490
|
+
messages: await this.freshAttachmentUrls(thread.messages, actor)
|
|
1513
1491
|
};
|
|
1514
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Re-mint each replayed attachment's url from the staging store, by `mediaId`: the url persisted
|
|
1495
|
+
* with the message was minted for THAT turn (a presigned url with an expiry), so an old turn would
|
|
1496
|
+
* otherwise show a dead link. The store's own access check applies — an attachment it will not
|
|
1497
|
+
* resolve for this actor keeps the url it was stored with.
|
|
1498
|
+
*/
|
|
1499
|
+
async freshAttachmentUrls(messages, actor) {
|
|
1500
|
+
const staging = this.staging;
|
|
1501
|
+
if (staging === void 0 || !messages.some((message) => message.attachments?.length)) {
|
|
1502
|
+
return messages;
|
|
1503
|
+
}
|
|
1504
|
+
return Promise.all(messages.map(async (message) => {
|
|
1505
|
+
if (message.attachments === void 0 || message.attachments.length === 0) return message;
|
|
1506
|
+
const attachments = await Promise.all(message.attachments.map(async (attachment) => {
|
|
1507
|
+
try {
|
|
1508
|
+
const fresh = await staging.resolve({
|
|
1509
|
+
mediaId: attachment.mediaId,
|
|
1510
|
+
actor
|
|
1511
|
+
});
|
|
1512
|
+
return fresh ?? attachment;
|
|
1513
|
+
} catch {
|
|
1514
|
+
return attachment;
|
|
1515
|
+
}
|
|
1516
|
+
}));
|
|
1517
|
+
return {
|
|
1518
|
+
...message,
|
|
1519
|
+
attachments
|
|
1520
|
+
};
|
|
1521
|
+
}));
|
|
1522
|
+
}
|
|
1515
1523
|
async promoteThread(actor, threadId) {
|
|
1516
1524
|
await this.assertOwnsThread(actor, threadId);
|
|
1517
1525
|
return this.store.promoteThread(threadId);
|
|
@@ -1621,30 +1629,6 @@ var AgentService = class {
|
|
|
1621
1629
|
return list;
|
|
1622
1630
|
}
|
|
1623
1631
|
/**
|
|
1624
|
-
* The day's usage for the badge: tokens + summed USD cost from the store, and the configured
|
|
1625
|
-
* limit from the quota store (null → unlimited). `withinLimit` comes from the quota store so it
|
|
1626
|
-
* can never drift from what enforcement uses.
|
|
1627
|
-
*/
|
|
1628
|
-
async quotaToday(actorRef) {
|
|
1629
|
-
const day = utcDay();
|
|
1630
|
-
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, day);
|
|
1631
|
-
if (this.quota === void 0) {
|
|
1632
|
-
return {
|
|
1633
|
-
usedTokens,
|
|
1634
|
-
costUsd,
|
|
1635
|
-
limitTokens: null,
|
|
1636
|
-
withinLimit: true
|
|
1637
|
-
};
|
|
1638
|
-
}
|
|
1639
|
-
const state = await this.quota.check(actorRef, day);
|
|
1640
|
-
return {
|
|
1641
|
-
usedTokens: state.usedTokens,
|
|
1642
|
-
costUsd,
|
|
1643
|
-
limitTokens: state.limitTokens,
|
|
1644
|
-
withinLimit: state.withinLimit
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
/**
|
|
1648
1632
|
* Authorization seam for thread-scoped endpoints: the caller must own the thread. A missing
|
|
1649
1633
|
* thread is a 404; someone else's thread is a 403 — one actor never touches another's thread.
|
|
1650
1634
|
*/
|
|
@@ -1763,21 +1747,19 @@ AgentService = _ts_decorate6([
|
|
|
1763
1747
|
_ts_param5(0, Inject5(AGENT_RUNNER)),
|
|
1764
1748
|
_ts_param5(1, Inject5(AGENT_STORE4)),
|
|
1765
1749
|
_ts_param5(2, Inject5(AGENT_DEPS_FACTORY3)),
|
|
1766
|
-
_ts_param5(3,
|
|
1750
|
+
_ts_param5(3, Optional3()),
|
|
1751
|
+
_ts_param5(3, Inject5(AGENT_ATTACHMENT_STAGING)),
|
|
1767
1752
|
_ts_param5(4, Optional3()),
|
|
1768
|
-
_ts_param5(4, Inject5(
|
|
1753
|
+
_ts_param5(4, Inject5(AGENT_MODEL_CATALOG)),
|
|
1769
1754
|
_ts_param5(5, Optional3()),
|
|
1770
|
-
_ts_param5(5, Inject5(
|
|
1755
|
+
_ts_param5(5, Inject5(AGENT_QUOTA_PROVIDER)),
|
|
1771
1756
|
_ts_param5(6, Optional3()),
|
|
1772
|
-
_ts_param5(6, Inject5(
|
|
1773
|
-
_ts_param5(7, Optional3()),
|
|
1774
|
-
_ts_param5(7, Inject5(AGENT_OPTIONS2)),
|
|
1757
|
+
_ts_param5(6, Inject5(AGENT_OPTIONS2)),
|
|
1775
1758
|
_ts_metadata5("design:type", Function),
|
|
1776
1759
|
_ts_metadata5("design:paramtypes", [
|
|
1777
1760
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1778
1761
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1779
1762
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1780
|
-
Object,
|
|
1781
1763
|
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1782
1764
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1783
1765
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -1923,6 +1905,33 @@ AgentsController = _ts_decorate8([
|
|
|
1923
1905
|
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
|
|
1924
1906
|
import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as Inject7, NotImplementedException as NotImplementedException2, Optional as Optional4, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
1925
1907
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
1908
|
+
|
|
1909
|
+
// src/attachment-limits.ts
|
|
1910
|
+
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
1911
|
+
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
1912
|
+
"image/png",
|
|
1913
|
+
"image/jpeg",
|
|
1914
|
+
"image/gif",
|
|
1915
|
+
"image/webp",
|
|
1916
|
+
"application/pdf",
|
|
1917
|
+
"text/plain",
|
|
1918
|
+
"text/csv"
|
|
1919
|
+
];
|
|
1920
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
1921
|
+
function attachmentLimits(options, staging) {
|
|
1922
|
+
const declared = staging?.describe?.();
|
|
1923
|
+
const own = options?.attachments;
|
|
1924
|
+
return {
|
|
1925
|
+
enabled: staging !== void 0,
|
|
1926
|
+
upload: staging === void 0 ? null : declared?.upload ?? "multipart",
|
|
1927
|
+
maxBytes: declared?.maxBytes ?? own?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
1928
|
+
allowedContentTypes: declared?.allowedContentTypes ?? own?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
1929
|
+
maxPerMessage: MAX_ATTACHMENTS_PER_MESSAGE
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
__name(attachmentLimits, "attachmentLimits");
|
|
1933
|
+
|
|
1934
|
+
// src/controller/attachments.controller.ts
|
|
1926
1935
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
1927
1936
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1928
1937
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1949,18 +1958,8 @@ function _ts_param7(paramIndex, decorator) {
|
|
|
1949
1958
|
};
|
|
1950
1959
|
}
|
|
1951
1960
|
__name(_ts_param7, "_ts_param");
|
|
1952
|
-
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
1953
1961
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
1954
1962
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
1955
|
-
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
1956
|
-
"image/png",
|
|
1957
|
-
"image/jpeg",
|
|
1958
|
-
"image/gif",
|
|
1959
|
-
"image/webp",
|
|
1960
|
-
"application/pdf",
|
|
1961
|
-
"text/plain",
|
|
1962
|
-
"text/csv"
|
|
1963
|
-
];
|
|
1964
1963
|
var AttachmentsController = class {
|
|
1965
1964
|
static {
|
|
1966
1965
|
__name(this, "AttachmentsController");
|
|
@@ -1976,17 +1975,6 @@ var AttachmentsController = class {
|
|
|
1976
1975
|
this.staging = staging;
|
|
1977
1976
|
}
|
|
1978
1977
|
/**
|
|
1979
|
-
* `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
|
|
1980
|
-
* the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
|
|
1981
|
-
* than mounting a controller that would 501 on every single request because nobody bound
|
|
1982
|
-
* `AGENT_ATTACHMENT_STAGING`.
|
|
1983
|
-
*/
|
|
1984
|
-
onModuleInit() {
|
|
1985
|
-
if (this.options.attachments?.upload === true && this.staging === void 0) {
|
|
1986
|
-
throw new Error("AgentModule: attachments.upload is true but no AGENT_ATTACHMENT_STAGING provider is bound. Bind one (e.g. `{ provide: AGENT_ATTACHMENT_STAGING, useClass: MyStagingStore }`) in a module imported alongside AgentModule, or set attachments.upload to false.");
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
/**
|
|
1990
1978
|
* The caller's own staged files, newest first — the one question `GET /agent/threads/:id` cannot
|
|
1991
1979
|
* answer, since an upload that was never sent belongs to no thread.
|
|
1992
1980
|
*
|
|
@@ -2003,16 +1991,15 @@ var AttachmentsController = class {
|
|
|
2003
1991
|
}
|
|
2004
1992
|
async upload(req, file) {
|
|
2005
1993
|
if (this.staging === void 0) {
|
|
2006
|
-
throw new NotImplementedException2("Attachment upload is not configured on this server.");
|
|
1994
|
+
throw new NotImplementedException2("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
2007
1995
|
}
|
|
2008
1996
|
if (file === void 0) {
|
|
2009
1997
|
throw new BadRequestException2('multipart field "file" is required');
|
|
2010
1998
|
}
|
|
2011
|
-
const allowedContentTypes = this.options.
|
|
1999
|
+
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
2012
2000
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
2013
2001
|
throw new UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
2014
2002
|
}
|
|
2015
|
-
const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
|
|
2016
2003
|
if (file.size > maxBytes) {
|
|
2017
2004
|
throw new PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
2018
2005
|
}
|
|
@@ -2095,7 +2082,6 @@ function _ts_param8(paramIndex, decorator) {
|
|
|
2095
2082
|
};
|
|
2096
2083
|
}
|
|
2097
2084
|
__name(_ts_param8, "_ts_param");
|
|
2098
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
2099
2085
|
function attachmentRefs(claimed) {
|
|
2100
2086
|
if (claimed === void 0) {
|
|
2101
2087
|
return [];
|
|
@@ -2110,6 +2096,9 @@ function attachmentRefs(claimed) {
|
|
|
2110
2096
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
2111
2097
|
throw new BadRequestException3("each attachment must be an object with a mediaId");
|
|
2112
2098
|
}
|
|
2099
|
+
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
2100
|
+
throw new BadRequestException3("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
2101
|
+
}
|
|
2113
2102
|
const { mediaId } = entry;
|
|
2114
2103
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
2115
2104
|
throw new BadRequestException3("each attachment must carry a non-empty string mediaId");
|
|
@@ -2305,9 +2294,98 @@ function parseCursor(raw) {
|
|
|
2305
2294
|
}
|
|
2306
2295
|
__name(parseCursor, "parseCursor");
|
|
2307
2296
|
|
|
2308
|
-
// src/controller/
|
|
2309
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3,
|
|
2310
|
-
import { Controller as Controller4,
|
|
2297
|
+
// src/controller/config.controller.ts
|
|
2298
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
|
|
2299
|
+
import { Controller as Controller4, Get as Get4, Inject as Inject9, Optional as Optional5, Req as Req3 } from "@nestjs/common";
|
|
2300
|
+
|
|
2301
|
+
// src/resolver/anonymous-actor-resolver.ts
|
|
2302
|
+
import { createHash, randomBytes } from "crypto";
|
|
2303
|
+
var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
2304
|
+
var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
|
|
2305
|
+
function readCookie(req, name) {
|
|
2306
|
+
const header = req.headers?.cookie;
|
|
2307
|
+
const raw = Array.isArray(header) ? header.join("; ") : header;
|
|
2308
|
+
if (raw === void 0) return void 0;
|
|
2309
|
+
for (const pair of raw.split(";")) {
|
|
2310
|
+
const index = pair.indexOf("=");
|
|
2311
|
+
if (index === -1) continue;
|
|
2312
|
+
if (pair.slice(0, index).trim() === name) {
|
|
2313
|
+
try {
|
|
2314
|
+
return decodeURIComponent(pair.slice(index + 1).trim());
|
|
2315
|
+
} catch {
|
|
2316
|
+
return void 0;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
return void 0;
|
|
2321
|
+
}
|
|
2322
|
+
__name(readCookie, "readCookie");
|
|
2323
|
+
function isHttps(req) {
|
|
2324
|
+
if (req.secure === true) return true;
|
|
2325
|
+
const forwarded = req.headers?.["x-forwarded-proto"];
|
|
2326
|
+
const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
2327
|
+
return proto?.split(",")[0]?.trim() === "https";
|
|
2328
|
+
}
|
|
2329
|
+
__name(isHttps, "isHttps");
|
|
2330
|
+
var AnonymousActorResolver = class {
|
|
2331
|
+
static {
|
|
2332
|
+
__name(this, "AnonymousActorResolver");
|
|
2333
|
+
}
|
|
2334
|
+
options;
|
|
2335
|
+
cookieName;
|
|
2336
|
+
roles;
|
|
2337
|
+
constructor(options = {}) {
|
|
2338
|
+
this.options = options;
|
|
2339
|
+
this.cookieName = options.cookieName ?? "agent_anon";
|
|
2340
|
+
this.roles = options.roles ?? [
|
|
2341
|
+
"anonymous"
|
|
2342
|
+
];
|
|
2343
|
+
}
|
|
2344
|
+
resolve(request) {
|
|
2345
|
+
const req = typeof request === "object" && request !== null ? request : {};
|
|
2346
|
+
let token = req[MINTED] ?? readCookie(req, this.cookieName);
|
|
2347
|
+
if (token === void 0 || !TOKEN_PATTERN.test(token)) {
|
|
2348
|
+
token = randomBytes(32).toString("base64url");
|
|
2349
|
+
req[MINTED] = token;
|
|
2350
|
+
this.setCookie(req, token);
|
|
2351
|
+
}
|
|
2352
|
+
const digest = createHash("sha256").update(token).digest("base64url").slice(0, 32);
|
|
2353
|
+
return {
|
|
2354
|
+
id: `anon:${digest}`,
|
|
2355
|
+
roles: [
|
|
2356
|
+
...this.roles
|
|
2357
|
+
]
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2360
|
+
setCookie(req, token) {
|
|
2361
|
+
const res = req.res;
|
|
2362
|
+
if (res?.setHeader === void 0 || res.headersSent === true) return;
|
|
2363
|
+
const sameSite = this.options.sameSite ?? "lax";
|
|
2364
|
+
const secureOption = this.options.secure ?? "auto";
|
|
2365
|
+
const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
|
|
2366
|
+
const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
|
|
2367
|
+
const cookie = [
|
|
2368
|
+
`${this.cookieName}=${token}`,
|
|
2369
|
+
`Path=${this.options.path ?? "/"}`,
|
|
2370
|
+
`Max-Age=${maxAge}`,
|
|
2371
|
+
"HttpOnly",
|
|
2372
|
+
`SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
|
|
2373
|
+
...secure ? [
|
|
2374
|
+
"Secure"
|
|
2375
|
+
] : []
|
|
2376
|
+
].join("; ");
|
|
2377
|
+
const existing = res.getHeader?.("Set-Cookie");
|
|
2378
|
+
const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
|
|
2379
|
+
String(existing)
|
|
2380
|
+
] : [];
|
|
2381
|
+
res.setHeader("Set-Cookie", [
|
|
2382
|
+
...list,
|
|
2383
|
+
cookie
|
|
2384
|
+
]);
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
// src/controller/config.controller.ts
|
|
2311
2389
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
2312
2390
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2313
2391
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2334,6 +2412,91 @@ function _ts_param9(paramIndex, decorator) {
|
|
|
2334
2412
|
};
|
|
2335
2413
|
}
|
|
2336
2414
|
__name(_ts_param9, "_ts_param");
|
|
2415
|
+
var ConfigController = class {
|
|
2416
|
+
static {
|
|
2417
|
+
__name(this, "ConfigController");
|
|
2418
|
+
}
|
|
2419
|
+
options;
|
|
2420
|
+
actorResolver;
|
|
2421
|
+
staging;
|
|
2422
|
+
models;
|
|
2423
|
+
constructor(options, actorResolver, staging, models) {
|
|
2424
|
+
this.options = options;
|
|
2425
|
+
this.actorResolver = actorResolver;
|
|
2426
|
+
this.staging = staging;
|
|
2427
|
+
this.models = models;
|
|
2428
|
+
}
|
|
2429
|
+
async config(req) {
|
|
2430
|
+
await this.actorResolver.resolve(req);
|
|
2431
|
+
return {
|
|
2432
|
+
attachments: attachmentLimits(this.options, this.staging),
|
|
2433
|
+
models: {
|
|
2434
|
+
enabled: this.models !== void 0
|
|
2435
|
+
},
|
|
2436
|
+
quota: {
|
|
2437
|
+
enforced: this.options.quota !== void 0
|
|
2438
|
+
},
|
|
2439
|
+
identity: {
|
|
2440
|
+
anonymous: this.actorResolver instanceof AnonymousActorResolver
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
_ts_decorate11([
|
|
2446
|
+
Get4(),
|
|
2447
|
+
_ts_param9(0, Req3()),
|
|
2448
|
+
_ts_metadata10("design:type", Function),
|
|
2449
|
+
_ts_metadata10("design:paramtypes", [
|
|
2450
|
+
typeof Request === "undefined" ? Object : Request
|
|
2451
|
+
]),
|
|
2452
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2453
|
+
], ConfigController.prototype, "config", null);
|
|
2454
|
+
ConfigController = _ts_decorate11([
|
|
2455
|
+
Controller4("config"),
|
|
2456
|
+
_ts_param9(0, Inject9(AGENT_OPTIONS4)),
|
|
2457
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER3)),
|
|
2458
|
+
_ts_param9(2, Optional5()),
|
|
2459
|
+
_ts_param9(2, Inject9(AGENT_ATTACHMENT_STAGING3)),
|
|
2460
|
+
_ts_param9(3, Optional5()),
|
|
2461
|
+
_ts_param9(3, Inject9(AGENT_MODEL_CATALOG2)),
|
|
2462
|
+
_ts_metadata10("design:type", Function),
|
|
2463
|
+
_ts_metadata10("design:paramtypes", [
|
|
2464
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2465
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2466
|
+
Object,
|
|
2467
|
+
Object
|
|
2468
|
+
])
|
|
2469
|
+
], ConfigController);
|
|
2470
|
+
|
|
2471
|
+
// src/controller/memories.controller.ts
|
|
2472
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
|
|
2473
|
+
import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException2, Get as Get5, Inject as Inject10, NotFoundException as NotFoundException2, Optional as Optional6, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
|
|
2474
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2475
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2476
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2477
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2478
|
+
} else {
|
|
2479
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2480
|
+
if (d = decorators[i]) {
|
|
2481
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2486
|
+
}
|
|
2487
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2488
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2489
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2490
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2494
|
+
function _ts_param10(paramIndex, decorator) {
|
|
2495
|
+
return function(target, key) {
|
|
2496
|
+
decorator(target, key, paramIndex);
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
__name(_ts_param10, "_ts_param");
|
|
2337
2500
|
var MemoriesController = class {
|
|
2338
2501
|
static {
|
|
2339
2502
|
__name(this, "MemoriesController");
|
|
@@ -2406,44 +2569,44 @@ var MemoriesController = class {
|
|
|
2406
2569
|
});
|
|
2407
2570
|
}
|
|
2408
2571
|
};
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2572
|
+
_ts_decorate12([
|
|
2573
|
+
Get5(),
|
|
2574
|
+
_ts_param10(0, Req4()),
|
|
2575
|
+
_ts_param10(1, Query2("threadId")),
|
|
2576
|
+
_ts_metadata11("design:type", Function),
|
|
2577
|
+
_ts_metadata11("design:paramtypes", [
|
|
2415
2578
|
typeof Request === "undefined" ? Object : Request,
|
|
2416
2579
|
String
|
|
2417
2580
|
]),
|
|
2418
|
-
|
|
2581
|
+
_ts_metadata11("design:returntype", Promise)
|
|
2419
2582
|
], MemoriesController.prototype, "list", null);
|
|
2420
|
-
|
|
2583
|
+
_ts_decorate12([
|
|
2421
2584
|
Delete(":id"),
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2585
|
+
_ts_param10(0, Req4()),
|
|
2586
|
+
_ts_param10(1, Param2("id")),
|
|
2587
|
+
_ts_metadata11("design:type", Function),
|
|
2588
|
+
_ts_metadata11("design:paramtypes", [
|
|
2426
2589
|
typeof Request === "undefined" ? Object : Request,
|
|
2427
2590
|
String
|
|
2428
2591
|
]),
|
|
2429
|
-
|
|
2592
|
+
_ts_metadata11("design:returntype", Promise)
|
|
2430
2593
|
], MemoriesController.prototype, "forget", null);
|
|
2431
|
-
MemoriesController =
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2594
|
+
MemoriesController = _ts_decorate12([
|
|
2595
|
+
Controller5("memories"),
|
|
2596
|
+
_ts_param10(0, Inject10(AGENT_ACTOR_RESOLVER4)),
|
|
2597
|
+
_ts_param10(1, Optional6()),
|
|
2598
|
+
_ts_param10(1, Inject10(AGENT_MEMORY2)),
|
|
2599
|
+
_ts_metadata11("design:type", Function),
|
|
2600
|
+
_ts_metadata11("design:paramtypes", [
|
|
2438
2601
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2439
2602
|
Object
|
|
2440
2603
|
])
|
|
2441
2604
|
], MemoriesController);
|
|
2442
2605
|
|
|
2443
2606
|
// src/controller/messages.controller.ts
|
|
2444
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2445
|
-
import { Body as Body2, Controller as
|
|
2446
|
-
function
|
|
2607
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
2608
|
+
import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject11, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
|
|
2609
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2447
2610
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2448
2611
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2449
2612
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2456,19 +2619,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2456
2619
|
}
|
|
2457
2620
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2458
2621
|
}
|
|
2459
|
-
__name(
|
|
2460
|
-
function
|
|
2622
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2623
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
2461
2624
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2462
2625
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2463
2626
|
}
|
|
2464
2627
|
}
|
|
2465
|
-
__name(
|
|
2466
|
-
function
|
|
2628
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2629
|
+
function _ts_param11(paramIndex, decorator) {
|
|
2467
2630
|
return function(target, key) {
|
|
2468
2631
|
decorator(target, key, paramIndex);
|
|
2469
2632
|
};
|
|
2470
2633
|
}
|
|
2471
|
-
__name(
|
|
2634
|
+
__name(_ts_param11, "_ts_param");
|
|
2472
2635
|
var MessagesController = class {
|
|
2473
2636
|
static {
|
|
2474
2637
|
__name(this, "MessagesController");
|
|
@@ -2496,34 +2659,34 @@ var MessagesController = class {
|
|
|
2496
2659
|
};
|
|
2497
2660
|
}
|
|
2498
2661
|
};
|
|
2499
|
-
|
|
2662
|
+
_ts_decorate13([
|
|
2500
2663
|
Post3(":id/feedback"),
|
|
2501
2664
|
HttpCode(200),
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2665
|
+
_ts_param11(0, Req5()),
|
|
2666
|
+
_ts_param11(1, Param3("id")),
|
|
2667
|
+
_ts_param11(2, Body2()),
|
|
2668
|
+
_ts_metadata12("design:type", Function),
|
|
2669
|
+
_ts_metadata12("design:paramtypes", [
|
|
2507
2670
|
typeof Request === "undefined" ? Object : Request,
|
|
2508
2671
|
String,
|
|
2509
2672
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
2510
2673
|
]),
|
|
2511
|
-
|
|
2674
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2512
2675
|
], MessagesController.prototype, "feedback", null);
|
|
2513
|
-
MessagesController =
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2676
|
+
MessagesController = _ts_decorate13([
|
|
2677
|
+
Controller6("messages"),
|
|
2678
|
+
_ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER5)),
|
|
2679
|
+
_ts_metadata12("design:type", Function),
|
|
2680
|
+
_ts_metadata12("design:paramtypes", [
|
|
2518
2681
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2519
2682
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2520
2683
|
])
|
|
2521
2684
|
], MessagesController);
|
|
2522
2685
|
|
|
2523
2686
|
// src/controller/models.controller.ts
|
|
2524
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2525
|
-
import { Controller as
|
|
2526
|
-
function
|
|
2687
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
|
|
2688
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject12, Query as Query3, Req as Req6 } from "@nestjs/common";
|
|
2689
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2527
2690
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2528
2691
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2529
2692
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2536,19 +2699,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2536
2699
|
}
|
|
2537
2700
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2538
2701
|
}
|
|
2539
|
-
__name(
|
|
2540
|
-
function
|
|
2702
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2703
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
2541
2704
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2542
2705
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2543
2706
|
}
|
|
2544
2707
|
}
|
|
2545
|
-
__name(
|
|
2546
|
-
function
|
|
2708
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2709
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2547
2710
|
return function(target, key) {
|
|
2548
2711
|
decorator(target, key, paramIndex);
|
|
2549
2712
|
};
|
|
2550
2713
|
}
|
|
2551
|
-
__name(
|
|
2714
|
+
__name(_ts_param12, "_ts_param");
|
|
2552
2715
|
var ModelsController = class {
|
|
2553
2716
|
static {
|
|
2554
2717
|
__name(this, "ModelsController");
|
|
@@ -2568,31 +2731,31 @@ var ModelsController = class {
|
|
|
2568
2731
|
return this.agent.listModels(actor, agent);
|
|
2569
2732
|
}
|
|
2570
2733
|
};
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2734
|
+
_ts_decorate14([
|
|
2735
|
+
Get6(),
|
|
2736
|
+
_ts_param12(0, Req6()),
|
|
2737
|
+
_ts_param12(1, Query3("agent")),
|
|
2738
|
+
_ts_metadata13("design:type", Function),
|
|
2739
|
+
_ts_metadata13("design:paramtypes", [
|
|
2577
2740
|
typeof Request === "undefined" ? Object : Request,
|
|
2578
2741
|
String
|
|
2579
2742
|
]),
|
|
2580
|
-
|
|
2743
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2581
2744
|
], ModelsController.prototype, "list", null);
|
|
2582
|
-
ModelsController =
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2745
|
+
ModelsController = _ts_decorate14([
|
|
2746
|
+
Controller7("models"),
|
|
2747
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER6)),
|
|
2748
|
+
_ts_metadata13("design:type", Function),
|
|
2749
|
+
_ts_metadata13("design:paramtypes", [
|
|
2587
2750
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2588
2751
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2589
2752
|
])
|
|
2590
2753
|
], ModelsController);
|
|
2591
2754
|
|
|
2592
2755
|
// src/controller/quota.controller.ts
|
|
2593
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2594
|
-
import { Controller as
|
|
2595
|
-
function
|
|
2756
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
|
|
2757
|
+
import { Controller as Controller8, Get as Get7, Inject as Inject13, Req as Req7 } from "@nestjs/common";
|
|
2758
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2596
2759
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2597
2760
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2598
2761
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2605,19 +2768,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2605
2768
|
}
|
|
2606
2769
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2607
2770
|
}
|
|
2608
|
-
__name(
|
|
2609
|
-
function
|
|
2771
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2772
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2610
2773
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2611
2774
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2612
2775
|
}
|
|
2613
2776
|
}
|
|
2614
|
-
__name(
|
|
2615
|
-
function
|
|
2777
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2778
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2616
2779
|
return function(target, key) {
|
|
2617
2780
|
decorator(target, key, paramIndex);
|
|
2618
2781
|
};
|
|
2619
2782
|
}
|
|
2620
|
-
__name(
|
|
2783
|
+
__name(_ts_param13, "_ts_param");
|
|
2621
2784
|
var QuotaController = class {
|
|
2622
2785
|
static {
|
|
2623
2786
|
__name(this, "QuotaController");
|
|
@@ -2636,43 +2799,30 @@ var QuotaController = class {
|
|
|
2636
2799
|
const actor = await this.actorResolver.resolve(req);
|
|
2637
2800
|
return this.agent.quotaReport(actor);
|
|
2638
2801
|
}
|
|
2639
|
-
async today(req) {
|
|
2640
|
-
const actor = await this.actorResolver.resolve(req);
|
|
2641
|
-
return this.agent.quotaToday(actor.id);
|
|
2642
|
-
}
|
|
2643
2802
|
};
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2803
|
+
_ts_decorate15([
|
|
2804
|
+
Get7(),
|
|
2805
|
+
_ts_param13(0, Req7()),
|
|
2806
|
+
_ts_metadata14("design:type", Function),
|
|
2807
|
+
_ts_metadata14("design:paramtypes", [
|
|
2649
2808
|
typeof Request === "undefined" ? Object : Request
|
|
2650
2809
|
]),
|
|
2651
|
-
|
|
2810
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2652
2811
|
], QuotaController.prototype, "report", null);
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
typeof Request === "undefined" ? Object : Request
|
|
2659
|
-
]),
|
|
2660
|
-
_ts_metadata13("design:returntype", Promise)
|
|
2661
|
-
], QuotaController.prototype, "today", null);
|
|
2662
|
-
QuotaController = _ts_decorate14([
|
|
2663
|
-
Controller7("quota"),
|
|
2664
|
-
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER6)),
|
|
2665
|
-
_ts_metadata13("design:type", Function),
|
|
2666
|
-
_ts_metadata13("design:paramtypes", [
|
|
2812
|
+
QuotaController = _ts_decorate15([
|
|
2813
|
+
Controller8("quota"),
|
|
2814
|
+
_ts_param13(1, Inject13(AGENT_ACTOR_RESOLVER7)),
|
|
2815
|
+
_ts_metadata14("design:type", Function),
|
|
2816
|
+
_ts_metadata14("design:paramtypes", [
|
|
2667
2817
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2668
2818
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2669
2819
|
])
|
|
2670
2820
|
], QuotaController);
|
|
2671
2821
|
|
|
2672
2822
|
// src/controller/skills.controller.ts
|
|
2673
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2674
|
-
import { Controller as
|
|
2675
|
-
function
|
|
2823
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
2824
|
+
import { Controller as Controller9, Get as Get8, Inject as Inject14, Optional as Optional7, Query as Query4, Req as Req8 } from "@nestjs/common";
|
|
2825
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2676
2826
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2677
2827
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2678
2828
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2685,19 +2835,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2685
2835
|
}
|
|
2686
2836
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2687
2837
|
}
|
|
2688
|
-
__name(
|
|
2689
|
-
function
|
|
2838
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2839
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2690
2840
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2691
2841
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2692
2842
|
}
|
|
2693
2843
|
}
|
|
2694
|
-
__name(
|
|
2695
|
-
function
|
|
2844
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2845
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2696
2846
|
return function(target, key) {
|
|
2697
2847
|
decorator(target, key, paramIndex);
|
|
2698
2848
|
};
|
|
2699
2849
|
}
|
|
2700
|
-
__name(
|
|
2850
|
+
__name(_ts_param14, "_ts_param");
|
|
2701
2851
|
var SkillsController = class {
|
|
2702
2852
|
static {
|
|
2703
2853
|
__name(this, "SkillsController");
|
|
@@ -2720,33 +2870,33 @@ var SkillsController = class {
|
|
|
2720
2870
|
return offer.entries;
|
|
2721
2871
|
}
|
|
2722
2872
|
};
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2873
|
+
_ts_decorate16([
|
|
2874
|
+
Get8(),
|
|
2875
|
+
_ts_param14(0, Req8()),
|
|
2876
|
+
_ts_param14(1, Query4("threadId")),
|
|
2877
|
+
_ts_metadata15("design:type", Function),
|
|
2878
|
+
_ts_metadata15("design:paramtypes", [
|
|
2729
2879
|
typeof Request === "undefined" ? Object : Request,
|
|
2730
2880
|
String
|
|
2731
2881
|
]),
|
|
2732
|
-
|
|
2882
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2733
2883
|
], SkillsController.prototype, "list", null);
|
|
2734
|
-
SkillsController =
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2884
|
+
SkillsController = _ts_decorate16([
|
|
2885
|
+
Controller9("skills"),
|
|
2886
|
+
_ts_param14(0, Inject14(AGENT_ACTOR_RESOLVER8)),
|
|
2887
|
+
_ts_param14(1, Optional7()),
|
|
2888
|
+
_ts_param14(1, Inject14(AGENT_SKILLS2)),
|
|
2889
|
+
_ts_metadata15("design:type", Function),
|
|
2890
|
+
_ts_metadata15("design:paramtypes", [
|
|
2741
2891
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2742
2892
|
Object
|
|
2743
2893
|
])
|
|
2744
2894
|
], SkillsController);
|
|
2745
2895
|
|
|
2746
2896
|
// src/controller/threads.controller.ts
|
|
2747
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2748
|
-
import { Body as Body3, Controller as
|
|
2749
|
-
function
|
|
2897
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9 } from "@dudousxd/nestjs-agent-core";
|
|
2898
|
+
import { Body as Body3, Controller as Controller10, Delete as Delete2, Get as Get9, Inject as Inject15, Param as Param4, Patch, Post as Post4, Req as Req9 } from "@nestjs/common";
|
|
2899
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2750
2900
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2751
2901
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2752
2902
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2759,19 +2909,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2759
2909
|
}
|
|
2760
2910
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2761
2911
|
}
|
|
2762
|
-
__name(
|
|
2763
|
-
function
|
|
2912
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2913
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2764
2914
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2765
2915
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2766
2916
|
}
|
|
2767
2917
|
}
|
|
2768
|
-
__name(
|
|
2769
|
-
function
|
|
2918
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2919
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2770
2920
|
return function(target, key) {
|
|
2771
2921
|
decorator(target, key, paramIndex);
|
|
2772
2922
|
};
|
|
2773
2923
|
}
|
|
2774
|
-
__name(
|
|
2924
|
+
__name(_ts_param15, "_ts_param");
|
|
2775
2925
|
var ThreadsController = class {
|
|
2776
2926
|
static {
|
|
2777
2927
|
__name(this, "ThreadsController");
|
|
@@ -2838,101 +2988,101 @@ var ThreadsController = class {
|
|
|
2838
2988
|
};
|
|
2839
2989
|
}
|
|
2840
2990
|
};
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2991
|
+
_ts_decorate17([
|
|
2992
|
+
Get9(),
|
|
2993
|
+
_ts_param15(0, Req9()),
|
|
2994
|
+
_ts_metadata16("design:type", Function),
|
|
2995
|
+
_ts_metadata16("design:paramtypes", [
|
|
2846
2996
|
typeof Request === "undefined" ? Object : Request
|
|
2847
2997
|
]),
|
|
2848
|
-
|
|
2998
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2849
2999
|
], ThreadsController.prototype, "list", null);
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
3000
|
+
_ts_decorate17([
|
|
3001
|
+
Get9(":id"),
|
|
3002
|
+
_ts_param15(0, Req9()),
|
|
3003
|
+
_ts_param15(1, Param4("id")),
|
|
3004
|
+
_ts_metadata16("design:type", Function),
|
|
3005
|
+
_ts_metadata16("design:paramtypes", [
|
|
2856
3006
|
typeof Request === "undefined" ? Object : Request,
|
|
2857
3007
|
String
|
|
2858
3008
|
]),
|
|
2859
|
-
|
|
3009
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2860
3010
|
], ThreadsController.prototype, "detail", null);
|
|
2861
|
-
|
|
3011
|
+
_ts_decorate17([
|
|
2862
3012
|
Delete2(":id"),
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
3013
|
+
_ts_param15(0, Req9()),
|
|
3014
|
+
_ts_param15(1, Param4("id")),
|
|
3015
|
+
_ts_metadata16("design:type", Function),
|
|
3016
|
+
_ts_metadata16("design:paramtypes", [
|
|
2867
3017
|
typeof Request === "undefined" ? Object : Request,
|
|
2868
3018
|
String
|
|
2869
3019
|
]),
|
|
2870
|
-
|
|
3020
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2871
3021
|
], ThreadsController.prototype, "remove", null);
|
|
2872
|
-
|
|
3022
|
+
_ts_decorate17([
|
|
2873
3023
|
Post4(":id/fork-from/:messageId"),
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
3024
|
+
_ts_param15(0, Req9()),
|
|
3025
|
+
_ts_param15(1, Param4("id")),
|
|
3026
|
+
_ts_param15(2, Param4("messageId")),
|
|
3027
|
+
_ts_metadata16("design:type", Function),
|
|
3028
|
+
_ts_metadata16("design:paramtypes", [
|
|
2879
3029
|
typeof Request === "undefined" ? Object : Request,
|
|
2880
3030
|
String,
|
|
2881
3031
|
String
|
|
2882
3032
|
]),
|
|
2883
|
-
|
|
3033
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2884
3034
|
], ThreadsController.prototype, "fork", null);
|
|
2885
|
-
|
|
3035
|
+
_ts_decorate17([
|
|
2886
3036
|
Patch(":id"),
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
3037
|
+
_ts_param15(0, Req9()),
|
|
3038
|
+
_ts_param15(1, Param4("id")),
|
|
3039
|
+
_ts_param15(2, Body3()),
|
|
3040
|
+
_ts_metadata16("design:type", Function),
|
|
3041
|
+
_ts_metadata16("design:paramtypes", [
|
|
2892
3042
|
typeof Request === "undefined" ? Object : Request,
|
|
2893
3043
|
String,
|
|
2894
3044
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2895
3045
|
]),
|
|
2896
|
-
|
|
3046
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2897
3047
|
], ThreadsController.prototype, "update", null);
|
|
2898
|
-
|
|
3048
|
+
_ts_decorate17([
|
|
2899
3049
|
Post4(":id/promote"),
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
3050
|
+
_ts_param15(0, Req9()),
|
|
3051
|
+
_ts_param15(1, Param4("id")),
|
|
3052
|
+
_ts_metadata16("design:type", Function),
|
|
3053
|
+
_ts_metadata16("design:paramtypes", [
|
|
2904
3054
|
typeof Request === "undefined" ? Object : Request,
|
|
2905
3055
|
String
|
|
2906
3056
|
]),
|
|
2907
|
-
|
|
3057
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2908
3058
|
], ThreadsController.prototype, "promote", null);
|
|
2909
|
-
|
|
3059
|
+
_ts_decorate17([
|
|
2910
3060
|
Delete2(":id/from/:messageId"),
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
3061
|
+
_ts_param15(0, Req9()),
|
|
3062
|
+
_ts_param15(1, Param4("id")),
|
|
3063
|
+
_ts_param15(2, Param4("messageId")),
|
|
3064
|
+
_ts_metadata16("design:type", Function),
|
|
3065
|
+
_ts_metadata16("design:paramtypes", [
|
|
2916
3066
|
typeof Request === "undefined" ? Object : Request,
|
|
2917
3067
|
String,
|
|
2918
3068
|
String
|
|
2919
3069
|
]),
|
|
2920
|
-
|
|
3070
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2921
3071
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2922
|
-
ThreadsController =
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3072
|
+
ThreadsController = _ts_decorate17([
|
|
3073
|
+
Controller10("threads"),
|
|
3074
|
+
_ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER9)),
|
|
3075
|
+
_ts_metadata16("design:type", Function),
|
|
3076
|
+
_ts_metadata16("design:paramtypes", [
|
|
2927
3077
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2928
3078
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2929
3079
|
])
|
|
2930
3080
|
], ThreadsController);
|
|
2931
3081
|
|
|
2932
3082
|
// src/controller/tool-call.controller.ts
|
|
2933
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2934
|
-
import { BadRequestException as BadRequestException4, Body as Body4, Controller as
|
|
2935
|
-
function
|
|
3083
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
|
|
3084
|
+
import { BadRequestException as BadRequestException4, Body as Body4, Controller as Controller11, Inject as Inject16, Post as Post5, Req as Req10 } from "@nestjs/common";
|
|
3085
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2936
3086
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2937
3087
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2938
3088
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2945,19 +3095,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2945
3095
|
}
|
|
2946
3096
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2947
3097
|
}
|
|
2948
|
-
__name(
|
|
2949
|
-
function
|
|
3098
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3099
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2950
3100
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2951
3101
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2952
3102
|
}
|
|
2953
3103
|
}
|
|
2954
|
-
__name(
|
|
2955
|
-
function
|
|
3104
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3105
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2956
3106
|
return function(target, key) {
|
|
2957
3107
|
decorator(target, key, paramIndex);
|
|
2958
3108
|
};
|
|
2959
3109
|
}
|
|
2960
|
-
__name(
|
|
3110
|
+
__name(_ts_param16, "_ts_param");
|
|
2961
3111
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2962
3112
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2963
3113
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -3086,64 +3236,64 @@ var ToolCallController = class {
|
|
|
3086
3236
|
};
|
|
3087
3237
|
}
|
|
3088
3238
|
};
|
|
3089
|
-
|
|
3239
|
+
_ts_decorate18([
|
|
3090
3240
|
Post5("approve"),
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3241
|
+
_ts_param16(0, Req10()),
|
|
3242
|
+
_ts_param16(1, Body4()),
|
|
3243
|
+
_ts_metadata17("design:type", Function),
|
|
3244
|
+
_ts_metadata17("design:paramtypes", [
|
|
3095
3245
|
typeof Request === "undefined" ? Object : Request,
|
|
3096
3246
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
3097
3247
|
]),
|
|
3098
|
-
|
|
3248
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3099
3249
|
], ToolCallController.prototype, "approve", null);
|
|
3100
|
-
|
|
3250
|
+
_ts_decorate18([
|
|
3101
3251
|
Post5("reject"),
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3252
|
+
_ts_param16(0, Req10()),
|
|
3253
|
+
_ts_param16(1, Body4()),
|
|
3254
|
+
_ts_metadata17("design:type", Function),
|
|
3255
|
+
_ts_metadata17("design:paramtypes", [
|
|
3106
3256
|
typeof Request === "undefined" ? Object : Request,
|
|
3107
3257
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
3108
3258
|
]),
|
|
3109
|
-
|
|
3259
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3110
3260
|
], ToolCallController.prototype, "reject", null);
|
|
3111
|
-
|
|
3261
|
+
_ts_decorate18([
|
|
3112
3262
|
Post5("answer"),
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3263
|
+
_ts_param16(0, Req10()),
|
|
3264
|
+
_ts_param16(1, Body4()),
|
|
3265
|
+
_ts_metadata17("design:type", Function),
|
|
3266
|
+
_ts_metadata17("design:paramtypes", [
|
|
3117
3267
|
typeof Request === "undefined" ? Object : Request,
|
|
3118
3268
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
3119
3269
|
]),
|
|
3120
|
-
|
|
3270
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3121
3271
|
], ToolCallController.prototype, "answer", null);
|
|
3122
|
-
|
|
3272
|
+
_ts_decorate18([
|
|
3123
3273
|
Post5("skip"),
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3274
|
+
_ts_param16(0, Req10()),
|
|
3275
|
+
_ts_param16(1, Body4()),
|
|
3276
|
+
_ts_metadata17("design:type", Function),
|
|
3277
|
+
_ts_metadata17("design:paramtypes", [
|
|
3128
3278
|
typeof Request === "undefined" ? Object : Request,
|
|
3129
3279
|
Object
|
|
3130
3280
|
]),
|
|
3131
|
-
|
|
3281
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3132
3282
|
], ToolCallController.prototype, "skip", null);
|
|
3133
|
-
ToolCallController =
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3283
|
+
ToolCallController = _ts_decorate18([
|
|
3284
|
+
Controller11("tool-call"),
|
|
3285
|
+
_ts_param16(1, Inject16(AGENT_ACTOR_RESOLVER10)),
|
|
3286
|
+
_ts_metadata17("design:type", Function),
|
|
3287
|
+
_ts_metadata17("design:paramtypes", [
|
|
3138
3288
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3139
3289
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3140
3290
|
])
|
|
3141
3291
|
], ToolCallController);
|
|
3142
3292
|
|
|
3143
3293
|
// src/controller/tools.controller.ts
|
|
3144
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
3145
|
-
import { Controller as
|
|
3146
|
-
function
|
|
3294
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
3295
|
+
import { Controller as Controller12, Get as Get10, Inject as Inject17, NotFoundException as NotFoundException3, Query as Query5, Req as Req11 } from "@nestjs/common";
|
|
3296
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3147
3297
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3148
3298
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3149
3299
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3156,19 +3306,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3156
3306
|
}
|
|
3157
3307
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3158
3308
|
}
|
|
3159
|
-
__name(
|
|
3160
|
-
function
|
|
3309
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3310
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3161
3311
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3162
3312
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3163
3313
|
}
|
|
3164
3314
|
}
|
|
3165
|
-
__name(
|
|
3166
|
-
function
|
|
3315
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3316
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3167
3317
|
return function(target, key) {
|
|
3168
3318
|
decorator(target, key, paramIndex);
|
|
3169
3319
|
};
|
|
3170
3320
|
}
|
|
3171
|
-
__name(
|
|
3321
|
+
__name(_ts_param17, "_ts_param");
|
|
3172
3322
|
var ToolsController = class {
|
|
3173
3323
|
static {
|
|
3174
3324
|
__name(this, "ToolsController");
|
|
@@ -3197,24 +3347,24 @@ var ToolsController = class {
|
|
|
3197
3347
|
}));
|
|
3198
3348
|
}
|
|
3199
3349
|
};
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3350
|
+
_ts_decorate19([
|
|
3351
|
+
Get10(),
|
|
3352
|
+
_ts_param17(0, Req11()),
|
|
3353
|
+
_ts_param17(1, Query5("agent")),
|
|
3354
|
+
_ts_metadata18("design:type", Function),
|
|
3355
|
+
_ts_metadata18("design:paramtypes", [
|
|
3206
3356
|
typeof Request === "undefined" ? Object : Request,
|
|
3207
3357
|
String
|
|
3208
3358
|
]),
|
|
3209
|
-
|
|
3359
|
+
_ts_metadata18("design:returntype", Promise)
|
|
3210
3360
|
], ToolsController.prototype, "list", null);
|
|
3211
|
-
ToolsController =
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3361
|
+
ToolsController = _ts_decorate19([
|
|
3362
|
+
Controller12("tools"),
|
|
3363
|
+
_ts_param17(0, Inject17(AGENT_ACTOR_RESOLVER11)),
|
|
3364
|
+
_ts_param17(1, Inject17(AGENT_DEPS_FACTORY5)),
|
|
3365
|
+
_ts_param17(2, Inject17(AGENT_REGISTRY3)),
|
|
3366
|
+
_ts_metadata18("design:type", Function),
|
|
3367
|
+
_ts_metadata18("design:paramtypes", [
|
|
3218
3368
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3219
3369
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3220
3370
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -3223,7 +3373,7 @@ ToolsController = _ts_decorate18([
|
|
|
3223
3373
|
|
|
3224
3374
|
// src/discovery/agent-discovery.service.ts
|
|
3225
3375
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
3226
|
-
import { Inject as
|
|
3376
|
+
import { Inject as Inject18, Injectable as Injectable7, Logger as Logger2 } from "@nestjs/common";
|
|
3227
3377
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
3228
3378
|
|
|
3229
3379
|
// src/decorator/agent.decorator.ts
|
|
@@ -3240,7 +3390,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
3240
3390
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
3241
3391
|
|
|
3242
3392
|
// src/discovery/agent-discovery.service.ts
|
|
3243
|
-
function
|
|
3393
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3244
3394
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3245
3395
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3246
3396
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3253,19 +3403,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3253
3403
|
}
|
|
3254
3404
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3255
3405
|
}
|
|
3256
|
-
__name(
|
|
3257
|
-
function
|
|
3406
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3407
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3258
3408
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3259
3409
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3260
3410
|
}
|
|
3261
3411
|
}
|
|
3262
|
-
__name(
|
|
3263
|
-
function
|
|
3412
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3413
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3264
3414
|
return function(target, key) {
|
|
3265
3415
|
decorator(target, key, paramIndex);
|
|
3266
3416
|
};
|
|
3267
3417
|
}
|
|
3268
|
-
__name(
|
|
3418
|
+
__name(_ts_param18, "_ts_param");
|
|
3269
3419
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
3270
3420
|
static {
|
|
3271
3421
|
__name(this, "AgentDiscoveryService");
|
|
@@ -3392,12 +3542,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3392
3542
|
return (ctx) => candidate.call(instance, ctx);
|
|
3393
3543
|
}
|
|
3394
3544
|
};
|
|
3395
|
-
AgentDiscoveryService =
|
|
3545
|
+
AgentDiscoveryService = _ts_decorate20([
|
|
3396
3546
|
Injectable7(),
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3547
|
+
_ts_param18(2, Inject18(AGENT_REGISTRY4)),
|
|
3548
|
+
_ts_param18(3, Inject18(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
3549
|
+
_ts_metadata19("design:type", Function),
|
|
3550
|
+
_ts_metadata19("design:paramtypes", [
|
|
3401
3551
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
3402
3552
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
3403
3553
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -3406,8 +3556,8 @@ AgentDiscoveryService = _ts_decorate19([
|
|
|
3406
3556
|
], AgentDiscoveryService);
|
|
3407
3557
|
|
|
3408
3558
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3409
|
-
import { AGENT_OPTIONS as
|
|
3410
|
-
import { Inject as
|
|
3559
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
3560
|
+
import { Inject as Inject19, Injectable as Injectable8, Logger as Logger3 } from "@nestjs/common";
|
|
3411
3561
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
3412
3562
|
import { z } from "zod";
|
|
3413
3563
|
|
|
@@ -3427,7 +3577,7 @@ function isBrandedFunctionalTool(value) {
|
|
|
3427
3577
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
3428
3578
|
|
|
3429
3579
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3430
|
-
function
|
|
3580
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3431
3581
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3432
3582
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3433
3583
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3440,19 +3590,19 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3440
3590
|
}
|
|
3441
3591
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3442
3592
|
}
|
|
3443
|
-
__name(
|
|
3444
|
-
function
|
|
3593
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3594
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3445
3595
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3446
3596
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3447
3597
|
}
|
|
3448
3598
|
}
|
|
3449
|
-
__name(
|
|
3450
|
-
function
|
|
3599
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3600
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3451
3601
|
return function(target, key) {
|
|
3452
3602
|
decorator(target, key, paramIndex);
|
|
3453
3603
|
};
|
|
3454
3604
|
}
|
|
3455
|
-
__name(
|
|
3605
|
+
__name(_ts_param19, "_ts_param");
|
|
3456
3606
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
3457
3607
|
static {
|
|
3458
3608
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -3596,13 +3746,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3596
3746
|
return true;
|
|
3597
3747
|
}
|
|
3598
3748
|
};
|
|
3599
|
-
AiToolDiscoveryService =
|
|
3749
|
+
AiToolDiscoveryService = _ts_decorate21([
|
|
3600
3750
|
Injectable8(),
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3751
|
+
_ts_param19(1, Inject19(AGENT_TOOL_REGISTRY2)),
|
|
3752
|
+
_ts_param19(2, Inject19(AGENT_REGISTRY5)),
|
|
3753
|
+
_ts_param19(3, Inject19(AGENT_OPTIONS5)),
|
|
3754
|
+
_ts_metadata20("design:type", Function),
|
|
3755
|
+
_ts_metadata20("design:paramtypes", [
|
|
3606
3756
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
3607
3757
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3608
3758
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3612,7 +3762,7 @@ AiToolDiscoveryService = _ts_decorate20([
|
|
|
3612
3762
|
|
|
3613
3763
|
// src/discovery/skill-discovery.service.ts
|
|
3614
3764
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
3615
|
-
import { Inject as
|
|
3765
|
+
import { Inject as Inject20, Injectable as Injectable9, Logger as Logger4 } from "@nestjs/common";
|
|
3616
3766
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
3617
3767
|
|
|
3618
3768
|
// src/decorator/skill.decorator.ts
|
|
@@ -3629,7 +3779,7 @@ function skillScope(options) {
|
|
|
3629
3779
|
__name(skillScope, "skillScope");
|
|
3630
3780
|
|
|
3631
3781
|
// src/discovery/skill-discovery.service.ts
|
|
3632
|
-
function
|
|
3782
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3633
3783
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3634
3784
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3635
3785
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3642,19 +3792,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
3642
3792
|
}
|
|
3643
3793
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3644
3794
|
}
|
|
3645
|
-
__name(
|
|
3646
|
-
function
|
|
3795
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3796
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
3647
3797
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3648
3798
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3649
3799
|
}
|
|
3650
3800
|
}
|
|
3651
|
-
__name(
|
|
3652
|
-
function
|
|
3801
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
3802
|
+
function _ts_param20(paramIndex, decorator) {
|
|
3653
3803
|
return function(target, key) {
|
|
3654
3804
|
decorator(target, key, paramIndex);
|
|
3655
3805
|
};
|
|
3656
3806
|
}
|
|
3657
|
-
__name(
|
|
3807
|
+
__name(_ts_param20, "_ts_param");
|
|
3658
3808
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3659
3809
|
static {
|
|
3660
3810
|
__name(this, "SkillDiscoveryService");
|
|
@@ -3698,11 +3848,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3698
3848
|
return flat === void 0 ? void 0 : () => flat;
|
|
3699
3849
|
}
|
|
3700
3850
|
};
|
|
3701
|
-
SkillDiscoveryService =
|
|
3851
|
+
SkillDiscoveryService = _ts_decorate22([
|
|
3702
3852
|
Injectable9(),
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3853
|
+
_ts_param20(1, Inject20(AGENT_SKILL_SOURCES)),
|
|
3854
|
+
_ts_metadata21("design:type", Function),
|
|
3855
|
+
_ts_metadata21("design:paramtypes", [
|
|
3706
3856
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
3707
3857
|
Array
|
|
3708
3858
|
])
|
|
@@ -3715,11 +3865,9 @@ var LedgerQuotaProvider = class {
|
|
|
3715
3865
|
__name(this, "LedgerQuotaProvider");
|
|
3716
3866
|
}
|
|
3717
3867
|
store;
|
|
3718
|
-
quota;
|
|
3719
3868
|
limits;
|
|
3720
|
-
constructor(store,
|
|
3869
|
+
constructor(store, limits = {}) {
|
|
3721
3870
|
this.store = store;
|
|
3722
|
-
this.quota = quota;
|
|
3723
3871
|
this.limits = limits;
|
|
3724
3872
|
}
|
|
3725
3873
|
async report(query) {
|
|
@@ -3744,15 +3892,7 @@ var LedgerQuotaProvider = class {
|
|
|
3744
3892
|
async dayWindow(actorRef, now) {
|
|
3745
3893
|
const range = quotaPeriodRange("day", now);
|
|
3746
3894
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
3747
|
-
|
|
3748
|
-
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3749
|
-
}
|
|
3750
|
-
const state = await this.quota.check(actorRef, range.fromDay);
|
|
3751
|
-
const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
|
|
3752
|
-
if (window.limitTokens === void 0) {
|
|
3753
|
-
window.limitTokens = state.limitTokens;
|
|
3754
|
-
}
|
|
3755
|
-
return window;
|
|
3895
|
+
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3756
3896
|
}
|
|
3757
3897
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
3758
3898
|
const limits = this.limits[period] ?? {};
|
|
@@ -3771,33 +3911,10 @@ var LedgerQuotaProvider = class {
|
|
|
3771
3911
|
}
|
|
3772
3912
|
};
|
|
3773
3913
|
|
|
3774
|
-
// src/ledger-quota-store.ts
|
|
3775
|
-
var LedgerQuotaStore = class {
|
|
3776
|
-
static {
|
|
3777
|
-
__name(this, "LedgerQuotaStore");
|
|
3778
|
-
}
|
|
3779
|
-
store;
|
|
3780
|
-
limitTokens;
|
|
3781
|
-
constructor(store, limitTokens) {
|
|
3782
|
-
this.store = store;
|
|
3783
|
-
this.limitTokens = limitTokens;
|
|
3784
|
-
}
|
|
3785
|
-
async check(actorRef, day) {
|
|
3786
|
-
const { usedTokens } = await this.store.quotaToday(actorRef, day);
|
|
3787
|
-
return {
|
|
3788
|
-
usedTokens,
|
|
3789
|
-
limitTokens: this.limitTokens,
|
|
3790
|
-
withinLimit: usedTokens < this.limitTokens
|
|
3791
|
-
};
|
|
3792
|
-
}
|
|
3793
|
-
async bump(_actorRef, _day, _tokens) {
|
|
3794
|
-
}
|
|
3795
|
-
};
|
|
3796
|
-
|
|
3797
3914
|
// src/runner/inline-agent-runner.ts
|
|
3798
3915
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE5, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent3, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
3799
|
-
import { Inject as
|
|
3800
|
-
function
|
|
3916
|
+
import { Inject as Inject21, Injectable as Injectable10, Logger as Logger5 } from "@nestjs/common";
|
|
3917
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
3801
3918
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3802
3919
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3803
3920
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3810,19 +3927,19 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
3810
3927
|
}
|
|
3811
3928
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3812
3929
|
}
|
|
3813
|
-
__name(
|
|
3814
|
-
function
|
|
3930
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3931
|
+
function _ts_metadata22(metadataKey, metadataValue) {
|
|
3815
3932
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3816
3933
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3817
3934
|
}
|
|
3818
3935
|
}
|
|
3819
|
-
__name(
|
|
3820
|
-
function
|
|
3936
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
3937
|
+
function _ts_param21(paramIndex, decorator) {
|
|
3821
3938
|
return function(target, key) {
|
|
3822
3939
|
decorator(target, key, paramIndex);
|
|
3823
3940
|
};
|
|
3824
3941
|
}
|
|
3825
|
-
__name(
|
|
3942
|
+
__name(_ts_param21, "_ts_param");
|
|
3826
3943
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3827
3944
|
static {
|
|
3828
3945
|
__name(this, "InlineAgentRunner");
|
|
@@ -4203,12 +4320,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4203
4320
|
}
|
|
4204
4321
|
}
|
|
4205
4322
|
};
|
|
4206
|
-
InlineAgentRunner =
|
|
4323
|
+
InlineAgentRunner = _ts_decorate23([
|
|
4207
4324
|
Injectable10(),
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4325
|
+
_ts_param21(0, Inject21(AGENT_DEPS_FACTORY6)),
|
|
4326
|
+
_ts_param21(1, Inject21(AGENT_STORE5)),
|
|
4327
|
+
_ts_metadata22("design:type", Function),
|
|
4328
|
+
_ts_metadata22("design:paramtypes", [
|
|
4212
4329
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
4213
4330
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
4214
4331
|
])
|
|
@@ -4253,7 +4370,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
4253
4370
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
4254
4371
|
|
|
4255
4372
|
// src/agent.module.ts
|
|
4256
|
-
function
|
|
4373
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4257
4374
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4258
4375
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4259
4376
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4266,9 +4383,57 @@ function _ts_decorate23(decorators, target, key, desc) {
|
|
|
4266
4383
|
}
|
|
4267
4384
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4268
4385
|
}
|
|
4269
|
-
__name(
|
|
4386
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4270
4387
|
var DEFAULT_PATH = "agent";
|
|
4271
|
-
|
|
4388
|
+
var logger = new Logger6("AgentModule");
|
|
4389
|
+
function externalStoreWrapper(modules) {
|
|
4390
|
+
for (const module of modules.values()) {
|
|
4391
|
+
if (module.metatype === AgentModule) continue;
|
|
4392
|
+
const wrapper = module.providers.get(AGENT_STORE6);
|
|
4393
|
+
if (wrapper !== void 0) return wrapper;
|
|
4394
|
+
}
|
|
4395
|
+
return void 0;
|
|
4396
|
+
}
|
|
4397
|
+
__name(externalStoreWrapper, "externalStoreWrapper");
|
|
4398
|
+
function forwardingStore(wrapper) {
|
|
4399
|
+
const target = /* @__PURE__ */ __name(() => {
|
|
4400
|
+
const instance = wrapper.instance;
|
|
4401
|
+
if (instance === void 0 || instance === null) {
|
|
4402
|
+
throw new Error("AgentModule: the AGENT_STORE bound by another module is not ready yet");
|
|
4403
|
+
}
|
|
4404
|
+
return instance;
|
|
4405
|
+
}, "target");
|
|
4406
|
+
return new Proxy({}, {
|
|
4407
|
+
get(_, property) {
|
|
4408
|
+
const store = target();
|
|
4409
|
+
const value = store[property];
|
|
4410
|
+
return typeof value === "function" ? value.bind(store) : value;
|
|
4411
|
+
},
|
|
4412
|
+
has(_, property) {
|
|
4413
|
+
return property in target();
|
|
4414
|
+
}
|
|
4415
|
+
});
|
|
4416
|
+
}
|
|
4417
|
+
__name(forwardingStore, "forwardingStore");
|
|
4418
|
+
function resolveStore(options, modules) {
|
|
4419
|
+
if (options.store !== void 0) return options.store;
|
|
4420
|
+
const external = externalStoreWrapper(modules);
|
|
4421
|
+
if (external !== void 0) return forwardingStore(external);
|
|
4422
|
+
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()).");
|
|
4423
|
+
return new InMemoryAgentStore();
|
|
4424
|
+
}
|
|
4425
|
+
__name(resolveStore, "resolveStore");
|
|
4426
|
+
function isQuotaProvider(quota) {
|
|
4427
|
+
return quota !== void 0 && typeof quota.report === "function";
|
|
4428
|
+
}
|
|
4429
|
+
__name(isQuotaProvider, "isQuotaProvider");
|
|
4430
|
+
function resolveCatalog(options) {
|
|
4431
|
+
if (options.models !== void 0) return options.models;
|
|
4432
|
+
const carried = options.model.catalog;
|
|
4433
|
+
return carried !== void 0 && typeof carried.list === "function" ? carried : void 0;
|
|
4434
|
+
}
|
|
4435
|
+
__name(resolveCatalog, "resolveCatalog");
|
|
4436
|
+
function sharedProviders(durable) {
|
|
4272
4437
|
const providers = [
|
|
4273
4438
|
{
|
|
4274
4439
|
provide: AGENT_TOOL_REGISTRY3,
|
|
@@ -4297,7 +4462,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
4297
4462
|
provide: AGENT_SKILLS3,
|
|
4298
4463
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
4299
4464
|
inject: [
|
|
4300
|
-
|
|
4465
|
+
AGENT_OPTIONS6,
|
|
4301
4466
|
AGENT_SKILL_SOURCES2
|
|
4302
4467
|
]
|
|
4303
4468
|
},
|
|
@@ -4307,62 +4472,56 @@ function sharedProviders(durable, includeStore) {
|
|
|
4307
4472
|
provide: AGENT_MEMORY3,
|
|
4308
4473
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
4309
4474
|
inject: [
|
|
4310
|
-
|
|
4475
|
+
AGENT_OPTIONS6
|
|
4311
4476
|
]
|
|
4312
4477
|
},
|
|
4313
4478
|
{
|
|
4314
4479
|
provide: AGENT_SINK3,
|
|
4315
4480
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
4316
4481
|
inject: [
|
|
4317
|
-
|
|
4482
|
+
AGENT_OPTIONS6
|
|
4318
4483
|
]
|
|
4319
4484
|
},
|
|
4320
4485
|
{
|
|
4321
4486
|
provide: AGENT_ROLES_POLICY2,
|
|
4322
4487
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
4323
4488
|
inject: [
|
|
4324
|
-
|
|
4489
|
+
AGENT_OPTIONS6
|
|
4325
4490
|
]
|
|
4326
4491
|
},
|
|
4327
4492
|
{
|
|
4328
|
-
provide:
|
|
4329
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
4493
|
+
provide: AGENT_ACTOR_RESOLVER12,
|
|
4494
|
+
useFactory: /* @__PURE__ */ __name((options) => {
|
|
4495
|
+
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
4496
|
+
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.");
|
|
4497
|
+
return new AnonymousActorResolver();
|
|
4498
|
+
}, "useFactory"),
|
|
4330
4499
|
inject: [
|
|
4331
|
-
|
|
4500
|
+
AGENT_OPTIONS6
|
|
4332
4501
|
]
|
|
4333
4502
|
},
|
|
4334
4503
|
{
|
|
4335
4504
|
provide: AGENT_MODEL2,
|
|
4336
4505
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
4337
4506
|
inject: [
|
|
4338
|
-
|
|
4339
|
-
]
|
|
4340
|
-
},
|
|
4341
|
-
{
|
|
4342
|
-
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
4343
|
-
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
4344
|
-
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
4345
|
-
provide: AGENT_QUOTA_STORE3,
|
|
4346
|
-
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
4347
|
-
inject: [
|
|
4348
|
-
AGENT_OPTIONS5,
|
|
4349
|
-
AGENT_STORE6
|
|
4507
|
+
AGENT_OPTIONS6
|
|
4350
4508
|
]
|
|
4351
4509
|
},
|
|
4352
4510
|
{
|
|
4511
|
+
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
4512
|
+
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
4353
4513
|
provide: AGENT_QUOTA_PROVIDER2,
|
|
4354
|
-
useFactory: /* @__PURE__ */ __name((o, store
|
|
4514
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits), "useFactory"),
|
|
4355
4515
|
inject: [
|
|
4356
|
-
|
|
4357
|
-
AGENT_STORE6
|
|
4358
|
-
AGENT_QUOTA_STORE3
|
|
4516
|
+
AGENT_OPTIONS6,
|
|
4517
|
+
AGENT_STORE6
|
|
4359
4518
|
]
|
|
4360
4519
|
},
|
|
4361
4520
|
{
|
|
4362
|
-
provide:
|
|
4363
|
-
useFactory: /* @__PURE__ */ __name((o) => o
|
|
4521
|
+
provide: AGENT_MODEL_CATALOG3,
|
|
4522
|
+
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
4364
4523
|
inject: [
|
|
4365
|
-
|
|
4524
|
+
AGENT_OPTIONS6
|
|
4366
4525
|
]
|
|
4367
4526
|
},
|
|
4368
4527
|
AgentDepsFactory2,
|
|
@@ -4385,15 +4544,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
4385
4544
|
useExisting: AgentApprovalPortAdapter
|
|
4386
4545
|
}
|
|
4387
4546
|
];
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
}
|
|
4547
|
+
providers.push({
|
|
4548
|
+
provide: AGENT_STORE6,
|
|
4549
|
+
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
4550
|
+
inject: [
|
|
4551
|
+
AGENT_OPTIONS6,
|
|
4552
|
+
ModulesContainer
|
|
4553
|
+
]
|
|
4554
|
+
});
|
|
4397
4555
|
if (durable) {
|
|
4398
4556
|
providers.push({
|
|
4399
4557
|
provide: AGENT_RUNNER2,
|
|
@@ -4419,20 +4577,17 @@ function sharedProviders(durable, includeStore) {
|
|
|
4419
4577
|
return providers;
|
|
4420
4578
|
}
|
|
4421
4579
|
__name(sharedProviders, "sharedProviders");
|
|
4422
|
-
function exportsFor(
|
|
4580
|
+
function exportsFor() {
|
|
4423
4581
|
return [
|
|
4424
|
-
|
|
4582
|
+
AGENT_OPTIONS6,
|
|
4425
4583
|
AGENT_TOOL_REGISTRY3,
|
|
4426
4584
|
AGENT_REGISTRY6,
|
|
4427
4585
|
AGENT_SINK3,
|
|
4428
4586
|
AGENT_ROLES_POLICY2,
|
|
4429
|
-
|
|
4587
|
+
AGENT_ACTOR_RESOLVER12,
|
|
4430
4588
|
AGENT_MODEL2,
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
] : [],
|
|
4434
|
-
AGENT_QUOTA_STORE3,
|
|
4435
|
-
AGENT_MODEL_CATALOG2,
|
|
4589
|
+
AGENT_STORE6,
|
|
4590
|
+
AGENT_MODEL_CATALOG3,
|
|
4436
4591
|
AGENT_QUOTA_PROVIDER2,
|
|
4437
4592
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
4438
4593
|
AGENT_SKILLS3,
|
|
@@ -4455,21 +4610,13 @@ var BASE_CONTROLLERS = [
|
|
|
4455
4610
|
MemoriesController,
|
|
4456
4611
|
ToolsController,
|
|
4457
4612
|
MessagesController,
|
|
4458
|
-
ModelsController
|
|
4459
|
-
|
|
4460
|
-
var GUARDABLE_CONTROLLERS = [
|
|
4461
|
-
...BASE_CONTROLLERS,
|
|
4613
|
+
ModelsController,
|
|
4614
|
+
ConfigController,
|
|
4462
4615
|
AttachmentsController
|
|
4463
4616
|
];
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
AttachmentsController
|
|
4468
|
-
] : BASE_CONTROLLERS;
|
|
4469
|
-
}
|
|
4470
|
-
__name(controllersFor, "controllersFor");
|
|
4471
|
-
function controllersForSurface(surface, mountAttachments) {
|
|
4472
|
-
return surface === "engine" ? [] : controllersFor(mountAttachments);
|
|
4617
|
+
var GUARDABLE_CONTROLLERS = BASE_CONTROLLERS;
|
|
4618
|
+
function controllersForSurface(surface) {
|
|
4619
|
+
return surface === "engine" ? [] : BASE_CONTROLLERS;
|
|
4473
4620
|
}
|
|
4474
4621
|
__name(controllersForSurface, "controllersForSurface");
|
|
4475
4622
|
var GUARDS_METADATA = "__guards__";
|
|
@@ -4501,7 +4648,6 @@ var AgentModule = class _AgentModule {
|
|
|
4501
4648
|
}
|
|
4502
4649
|
static forRoot(options) {
|
|
4503
4650
|
const path = options.path ?? DEFAULT_PATH;
|
|
4504
|
-
const includeStore = options.store !== void 0;
|
|
4505
4651
|
applyGuards(options.guards);
|
|
4506
4652
|
return {
|
|
4507
4653
|
module: _AgentModule,
|
|
@@ -4510,21 +4656,20 @@ var AgentModule = class _AgentModule {
|
|
|
4510
4656
|
DiscoveryModule,
|
|
4511
4657
|
routerFor(path)
|
|
4512
4658
|
],
|
|
4513
|
-
controllers: controllersForSurface(options.surface
|
|
4659
|
+
controllers: controllersForSurface(options.surface),
|
|
4514
4660
|
providers: [
|
|
4515
4661
|
{
|
|
4516
|
-
provide:
|
|
4662
|
+
provide: AGENT_OPTIONS6,
|
|
4517
4663
|
useValue: options
|
|
4518
4664
|
},
|
|
4519
|
-
...sharedProviders(options.durable ?? false
|
|
4665
|
+
...sharedProviders(options.durable ?? false),
|
|
4520
4666
|
...guardProviders(options.guards)
|
|
4521
4667
|
],
|
|
4522
|
-
exports: exportsFor(
|
|
4668
|
+
exports: exportsFor()
|
|
4523
4669
|
};
|
|
4524
4670
|
}
|
|
4525
4671
|
static forRootAsync(options) {
|
|
4526
4672
|
const path = options.path ?? DEFAULT_PATH;
|
|
4527
|
-
const includeStore = options.externalStore !== true;
|
|
4528
4673
|
applyGuards(options.guards);
|
|
4529
4674
|
return {
|
|
4530
4675
|
module: _AgentModule,
|
|
@@ -4534,10 +4679,10 @@ var AgentModule = class _AgentModule {
|
|
|
4534
4679
|
routerFor(path),
|
|
4535
4680
|
...options.imports ?? []
|
|
4536
4681
|
],
|
|
4537
|
-
controllers: controllersForSurface(options.surface
|
|
4682
|
+
controllers: controllersForSurface(options.surface),
|
|
4538
4683
|
providers: [
|
|
4539
4684
|
{
|
|
4540
|
-
provide:
|
|
4685
|
+
provide: AGENT_OPTIONS6,
|
|
4541
4686
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4542
4687
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4543
4688
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4551,14 +4696,14 @@ var AgentModule = class _AgentModule {
|
|
|
4551
4696
|
}), "useFactory"),
|
|
4552
4697
|
inject: options.inject ?? []
|
|
4553
4698
|
},
|
|
4554
|
-
...sharedProviders(options.durable ?? false
|
|
4699
|
+
...sharedProviders(options.durable ?? false),
|
|
4555
4700
|
...guardProviders(options.guards)
|
|
4556
4701
|
],
|
|
4557
|
-
exports: exportsFor(
|
|
4702
|
+
exports: exportsFor()
|
|
4558
4703
|
};
|
|
4559
4704
|
}
|
|
4560
4705
|
};
|
|
4561
|
-
AgentModule =
|
|
4706
|
+
AgentModule = _ts_decorate24([
|
|
4562
4707
|
Global2(),
|
|
4563
4708
|
Module2({})
|
|
4564
4709
|
], AgentModule);
|