@dudousxd/nestjs-agent 1.6.0 → 1.8.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 +54 -0
- package/dist/{agent-deps.factory-CUyVPsa1.d.cts → agent-deps.factory-Cus_RqwJ.d.cts} +49 -2
- package/dist/{agent-deps.factory-CUyVPsa1.d.ts → agent-deps.factory-Cus_RqwJ.d.ts} +49 -2
- package/dist/durable/index.cjs +618 -309
- 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 +533 -224
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +622 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.js +531 -223
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/agent.module.ts
|
|
5
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
5
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK2, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
6
6
|
import { Global, Module } from "@nestjs/common";
|
|
7
7
|
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
8
8
|
|
|
@@ -272,8 +272,8 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
272
272
|
], AgentDepsFactory2);
|
|
273
273
|
|
|
274
274
|
// src/agent.service.ts
|
|
275
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE2, REQUESTER_APPROVER, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
276
|
-
import { BadRequestException, ForbiddenException, GoneException, Inject as Inject2, Injectable as Injectable2, NotFoundException, NotImplementedException, Optional as Optional2 } from "@nestjs/common";
|
|
275
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE2, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
276
|
+
import { BadRequestException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject2, Injectable as Injectable2, NotFoundException, NotImplementedException, Optional as Optional2 } from "@nestjs/common";
|
|
277
277
|
|
|
278
278
|
// src/agent-deps.ts
|
|
279
279
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -327,15 +327,128 @@ var AgentService = class {
|
|
|
327
327
|
deps;
|
|
328
328
|
quota;
|
|
329
329
|
staging;
|
|
330
|
-
|
|
330
|
+
models;
|
|
331
|
+
quotaProvider;
|
|
332
|
+
options;
|
|
333
|
+
constructor(runner, store, deps, quota, staging, models, quotaProvider, options) {
|
|
331
334
|
this.runner = runner;
|
|
332
335
|
this.store = store;
|
|
333
336
|
this.deps = deps;
|
|
334
337
|
this.quota = quota;
|
|
335
338
|
this.staging = staging;
|
|
339
|
+
this.models = models;
|
|
340
|
+
this.quotaProvider = quotaProvider;
|
|
341
|
+
this.options = options;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The actor's budget across windows (`GET <base>/quota`) — the bound {@link QuotaProvider}'s
|
|
345
|
+
* report. Without one (a service built outside the module), a day window from the ledger.
|
|
346
|
+
*/
|
|
347
|
+
async quotaReport(actor) {
|
|
348
|
+
if (this.quotaProvider !== void 0) {
|
|
349
|
+
return this.quotaProvider.report({
|
|
350
|
+
actor
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const today = await this.quotaToday(actor.id);
|
|
354
|
+
return {
|
|
355
|
+
windows: [
|
|
356
|
+
{
|
|
357
|
+
period: "day",
|
|
358
|
+
usedTokens: today.usedTokens,
|
|
359
|
+
...today.limitTokens !== null ? {
|
|
360
|
+
limitTokens: today.limitTokens
|
|
361
|
+
} : {},
|
|
362
|
+
usedUsd: today.costUsd
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
...today.withinLimit ? {} : {
|
|
366
|
+
blocked: {
|
|
367
|
+
period: "day"
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Refuse a turn the actor's budget no longer covers — only when the host configured one
|
|
374
|
+
* (`quotaProvider` or `quotaLimits`): the default report is informational, and the daily token
|
|
375
|
+
* quota the loop enforces keeps working as it always has.
|
|
376
|
+
*/
|
|
377
|
+
async assertWithinQuota(actor) {
|
|
378
|
+
const gated = this.options?.quotaProvider !== void 0 || this.options?.quotaLimits !== void 0;
|
|
379
|
+
if (!gated || this.quotaProvider === void 0) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const { blocked } = await this.quotaProvider.report({
|
|
383
|
+
actor
|
|
384
|
+
});
|
|
385
|
+
if (blocked !== void 0) {
|
|
386
|
+
throw new HttpException({
|
|
387
|
+
statusCode: HttpStatus.TOO_MANY_REQUESTS,
|
|
388
|
+
code: "quota_exceeded",
|
|
389
|
+
period: blocked.period,
|
|
390
|
+
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
391
|
+
}, HttpStatus.TOO_MANY_REQUESTS);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
|
|
396
|
+
* bound, so a picker simply has nothing to offer.
|
|
397
|
+
*/
|
|
398
|
+
async listModels(actor, agent) {
|
|
399
|
+
if (this.models === void 0) {
|
|
400
|
+
return {
|
|
401
|
+
providers: [],
|
|
402
|
+
default: null
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
return this.models.list({
|
|
406
|
+
actor,
|
|
407
|
+
...agent !== void 0 ? {
|
|
408
|
+
agent
|
|
409
|
+
} : {}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
|
|
414
|
+
* one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
|
|
415
|
+
* pinned and again at every turn that runs on it (availability can change in between).
|
|
416
|
+
*/
|
|
417
|
+
async assertModelAllowed(actor, agent, model) {
|
|
418
|
+
if (this.models === void 0) {
|
|
419
|
+
throw new BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
420
|
+
}
|
|
421
|
+
const entry = findCatalogModel(await this.models.list({
|
|
422
|
+
actor,
|
|
423
|
+
agent
|
|
424
|
+
}), model);
|
|
425
|
+
if (entry === void 0) {
|
|
426
|
+
throw new BadRequestException(`model "${model}" is not offered`);
|
|
427
|
+
}
|
|
428
|
+
if (!entry.available) {
|
|
429
|
+
throw new BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
430
|
+
}
|
|
431
|
+
return entry.id;
|
|
432
|
+
}
|
|
433
|
+
/** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
|
|
434
|
+
async resolveModel(actor, agent, requested, threadId) {
|
|
435
|
+
const model = requested ?? (threadId !== void 0 ? await this.threadModel(threadId) : null);
|
|
436
|
+
if (model === null || model === void 0) {
|
|
437
|
+
return void 0;
|
|
438
|
+
}
|
|
439
|
+
return this.assertModelAllowed(actor, agent, model);
|
|
440
|
+
}
|
|
441
|
+
async threadModel(threadId) {
|
|
442
|
+
const projecting = this.store;
|
|
443
|
+
if (typeof projecting.modelForThread === "function") {
|
|
444
|
+
return projecting.modelForThread(threadId);
|
|
445
|
+
}
|
|
446
|
+
return (await this.store.getThread(threadId))?.model ?? null;
|
|
336
447
|
}
|
|
337
448
|
async chat(params) {
|
|
449
|
+
await this.assertWithinQuota(params.actor);
|
|
338
450
|
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
451
|
+
const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
|
|
339
452
|
const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
|
|
340
453
|
let threadId = params.threadId;
|
|
341
454
|
if (threadId === void 0) {
|
|
@@ -366,6 +479,9 @@ var AgentService = class {
|
|
|
366
479
|
} : {},
|
|
367
480
|
...params.pageContext !== void 0 ? {
|
|
368
481
|
pageContext: params.pageContext
|
|
482
|
+
} : {},
|
|
483
|
+
...model !== void 0 ? {
|
|
484
|
+
model
|
|
369
485
|
} : {}
|
|
370
486
|
};
|
|
371
487
|
const { runId } = await this.runner.start(input);
|
|
@@ -536,20 +652,26 @@ var AgentService = class {
|
|
|
536
652
|
async updateThread(actor, threadId, patch) {
|
|
537
653
|
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
538
654
|
await this.assertOwnsThread(actor, threadId);
|
|
539
|
-
if (patch.defaultAgent === void 0) {
|
|
655
|
+
if (patch.defaultAgent === void 0 && patch.model === void 0) {
|
|
540
656
|
if (title !== void 0) {
|
|
541
657
|
await this.store.setTitle(threadId, title);
|
|
542
658
|
}
|
|
543
659
|
return;
|
|
544
660
|
}
|
|
545
661
|
if (this.store.updateThread === void 0) {
|
|
546
|
-
throw new NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
662
|
+
throw new NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
547
663
|
}
|
|
664
|
+
const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
|
|
548
665
|
await this.store.updateThread(threadId, {
|
|
549
666
|
...title !== void 0 ? {
|
|
550
667
|
title
|
|
551
668
|
} : {},
|
|
552
|
-
|
|
669
|
+
...patch.defaultAgent !== void 0 ? {
|
|
670
|
+
defaultAgent: patch.defaultAgent
|
|
671
|
+
} : {},
|
|
672
|
+
...model !== void 0 ? {
|
|
673
|
+
model
|
|
674
|
+
} : {}
|
|
553
675
|
});
|
|
554
676
|
}
|
|
555
677
|
validateTitle(title) {
|
|
@@ -596,6 +718,7 @@ var AgentService = class {
|
|
|
596
718
|
return {
|
|
597
719
|
...thread,
|
|
598
720
|
defaultAgent: thread.defaultAgent ?? null,
|
|
721
|
+
model: thread.model ?? null,
|
|
599
722
|
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
600
723
|
};
|
|
601
724
|
}
|
|
@@ -863,13 +986,22 @@ AgentService = _ts_decorate2([
|
|
|
863
986
|
_ts_param2(3, Inject2(AGENT_QUOTA_STORE2)),
|
|
864
987
|
_ts_param2(4, Optional2()),
|
|
865
988
|
_ts_param2(4, Inject2(AGENT_ATTACHMENT_STAGING)),
|
|
989
|
+
_ts_param2(5, Optional2()),
|
|
990
|
+
_ts_param2(5, Inject2(AGENT_MODEL_CATALOG)),
|
|
991
|
+
_ts_param2(6, Optional2()),
|
|
992
|
+
_ts_param2(6, Inject2(AGENT_QUOTA_PROVIDER)),
|
|
993
|
+
_ts_param2(7, Optional2()),
|
|
994
|
+
_ts_param2(7, Inject2(AGENT_OPTIONS2)),
|
|
866
995
|
_ts_metadata2("design:type", Function),
|
|
867
996
|
_ts_metadata2("design:paramtypes", [
|
|
868
997
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
869
998
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
870
999
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
871
1000
|
Object,
|
|
872
|
-
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
|
|
1001
|
+
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1002
|
+
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1003
|
+
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
1004
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
873
1005
|
])
|
|
874
1006
|
], AgentService);
|
|
875
1007
|
|
|
@@ -1008,7 +1140,7 @@ AgentsController = _ts_decorate4([
|
|
|
1008
1140
|
], AgentsController);
|
|
1009
1141
|
|
|
1010
1142
|
// src/controller/attachments.controller.ts
|
|
1011
|
-
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as
|
|
1143
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
|
|
1012
1144
|
import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as Inject4, NotImplementedException as NotImplementedException2, Optional as Optional3, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
1013
1145
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
1014
1146
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
@@ -1141,7 +1273,7 @@ _ts_decorate5([
|
|
|
1141
1273
|
], AttachmentsController.prototype, "upload", null);
|
|
1142
1274
|
AttachmentsController = _ts_decorate5([
|
|
1143
1275
|
Controller2("attachments"),
|
|
1144
|
-
_ts_param4(0, Inject4(
|
|
1276
|
+
_ts_param4(0, Inject4(AGENT_OPTIONS3)),
|
|
1145
1277
|
_ts_param4(1, Inject4(AGENT_ACTOR_RESOLVER)),
|
|
1146
1278
|
_ts_param4(3, Optional3()),
|
|
1147
1279
|
_ts_param4(3, Inject4(AGENT_ATTACHMENT_STAGING2)),
|
|
@@ -1241,6 +1373,9 @@ var ChatController = class {
|
|
|
1241
1373
|
} : {},
|
|
1242
1374
|
...body.transient === true ? {
|
|
1243
1375
|
transient: true
|
|
1376
|
+
} : {},
|
|
1377
|
+
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
1378
|
+
model: body.model
|
|
1244
1379
|
} : {}
|
|
1245
1380
|
});
|
|
1246
1381
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
@@ -1605,9 +1740,9 @@ MessagesController = _ts_decorate8([
|
|
|
1605
1740
|
])
|
|
1606
1741
|
], MessagesController);
|
|
1607
1742
|
|
|
1608
|
-
// src/controller/
|
|
1743
|
+
// src/controller/models.controller.ts
|
|
1609
1744
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
1610
|
-
import { Controller as Controller6, Get as Get5, Inject as Inject8, Req as Req5 } from "@nestjs/common";
|
|
1745
|
+
import { Controller as Controller6, Get as Get5, Inject as Inject8, Query as Query3, Req as Req5 } from "@nestjs/common";
|
|
1611
1746
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
1612
1747
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1613
1748
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1634,9 +1769,9 @@ function _ts_param8(paramIndex, decorator) {
|
|
|
1634
1769
|
};
|
|
1635
1770
|
}
|
|
1636
1771
|
__name(_ts_param8, "_ts_param");
|
|
1637
|
-
var
|
|
1772
|
+
var ModelsController = class {
|
|
1638
1773
|
static {
|
|
1639
|
-
__name(this, "
|
|
1774
|
+
__name(this, "ModelsController");
|
|
1640
1775
|
}
|
|
1641
1776
|
agent;
|
|
1642
1777
|
actorResolver;
|
|
@@ -1644,33 +1779,39 @@ var QuotaController = class {
|
|
|
1644
1779
|
this.agent = agent;
|
|
1645
1780
|
this.actorResolver = actorResolver;
|
|
1646
1781
|
}
|
|
1647
|
-
|
|
1782
|
+
/**
|
|
1783
|
+
* The models the caller may pick for `agent` (the default agent when omitted), grouped by
|
|
1784
|
+
* provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
|
|
1785
|
+
*/
|
|
1786
|
+
async list(req, agent) {
|
|
1648
1787
|
const actor = await this.actorResolver.resolve(req);
|
|
1649
|
-
return this.agent.
|
|
1788
|
+
return this.agent.listModels(actor, agent);
|
|
1650
1789
|
}
|
|
1651
1790
|
};
|
|
1652
1791
|
_ts_decorate9([
|
|
1653
|
-
Get5(
|
|
1792
|
+
Get5(),
|
|
1654
1793
|
_ts_param8(0, Req5()),
|
|
1794
|
+
_ts_param8(1, Query3("agent")),
|
|
1655
1795
|
_ts_metadata9("design:type", Function),
|
|
1656
1796
|
_ts_metadata9("design:paramtypes", [
|
|
1657
|
-
typeof Request === "undefined" ? Object : Request
|
|
1797
|
+
typeof Request === "undefined" ? Object : Request,
|
|
1798
|
+
String
|
|
1658
1799
|
]),
|
|
1659
1800
|
_ts_metadata9("design:returntype", Promise)
|
|
1660
|
-
],
|
|
1661
|
-
|
|
1662
|
-
Controller6("
|
|
1801
|
+
], ModelsController.prototype, "list", null);
|
|
1802
|
+
ModelsController = _ts_decorate9([
|
|
1803
|
+
Controller6("models"),
|
|
1663
1804
|
_ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER5)),
|
|
1664
1805
|
_ts_metadata9("design:type", Function),
|
|
1665
1806
|
_ts_metadata9("design:paramtypes", [
|
|
1666
1807
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1667
1808
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1668
1809
|
])
|
|
1669
|
-
],
|
|
1810
|
+
], ModelsController);
|
|
1670
1811
|
|
|
1671
|
-
// src/controller/
|
|
1672
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6
|
|
1673
|
-
import { Controller as Controller7, Get as Get6, Inject as Inject9,
|
|
1812
|
+
// src/controller/quota.controller.ts
|
|
1813
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
|
|
1814
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject9, Req as Req6 } from "@nestjs/common";
|
|
1674
1815
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
1675
1816
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1676
1817
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1697,6 +1838,86 @@ function _ts_param9(paramIndex, decorator) {
|
|
|
1697
1838
|
};
|
|
1698
1839
|
}
|
|
1699
1840
|
__name(_ts_param9, "_ts_param");
|
|
1841
|
+
var QuotaController = class {
|
|
1842
|
+
static {
|
|
1843
|
+
__name(this, "QuotaController");
|
|
1844
|
+
}
|
|
1845
|
+
agent;
|
|
1846
|
+
actorResolver;
|
|
1847
|
+
constructor(agent, actorResolver) {
|
|
1848
|
+
this.agent = agent;
|
|
1849
|
+
this.actorResolver = actorResolver;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* The caller's budget across windows — `{ windows: [{ period, usedTokens, limitTokens?, usedUsd,
|
|
1853
|
+
* limitUsd?, resetsAt? }], blocked?: { period, reason? } }` — from the bound `QuotaProvider`.
|
|
1854
|
+
*/
|
|
1855
|
+
async report(req) {
|
|
1856
|
+
const actor = await this.actorResolver.resolve(req);
|
|
1857
|
+
return this.agent.quotaReport(actor);
|
|
1858
|
+
}
|
|
1859
|
+
async today(req) {
|
|
1860
|
+
const actor = await this.actorResolver.resolve(req);
|
|
1861
|
+
return this.agent.quotaToday(actor.id);
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
_ts_decorate10([
|
|
1865
|
+
Get6(),
|
|
1866
|
+
_ts_param9(0, Req6()),
|
|
1867
|
+
_ts_metadata10("design:type", Function),
|
|
1868
|
+
_ts_metadata10("design:paramtypes", [
|
|
1869
|
+
typeof Request === "undefined" ? Object : Request
|
|
1870
|
+
]),
|
|
1871
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1872
|
+
], QuotaController.prototype, "report", null);
|
|
1873
|
+
_ts_decorate10([
|
|
1874
|
+
Get6("today"),
|
|
1875
|
+
_ts_param9(0, Req6()),
|
|
1876
|
+
_ts_metadata10("design:type", Function),
|
|
1877
|
+
_ts_metadata10("design:paramtypes", [
|
|
1878
|
+
typeof Request === "undefined" ? Object : Request
|
|
1879
|
+
]),
|
|
1880
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1881
|
+
], QuotaController.prototype, "today", null);
|
|
1882
|
+
QuotaController = _ts_decorate10([
|
|
1883
|
+
Controller7("quota"),
|
|
1884
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER6)),
|
|
1885
|
+
_ts_metadata10("design:type", Function),
|
|
1886
|
+
_ts_metadata10("design:paramtypes", [
|
|
1887
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1888
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1889
|
+
])
|
|
1890
|
+
], QuotaController);
|
|
1891
|
+
|
|
1892
|
+
// src/controller/skills.controller.ts
|
|
1893
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
1894
|
+
import { Controller as Controller8, Get as Get7, Inject as Inject10, Optional as Optional5, Query as Query4, Req as Req7 } from "@nestjs/common";
|
|
1895
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1896
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1897
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1898
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1899
|
+
} else {
|
|
1900
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1901
|
+
if (d = decorators[i]) {
|
|
1902
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1907
|
+
}
|
|
1908
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1909
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
1910
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1911
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1915
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1916
|
+
return function(target, key) {
|
|
1917
|
+
decorator(target, key, paramIndex);
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
__name(_ts_param10, "_ts_param");
|
|
1700
1921
|
var SkillsController = class {
|
|
1701
1922
|
static {
|
|
1702
1923
|
__name(this, "SkillsController");
|
|
@@ -1719,33 +1940,33 @@ var SkillsController = class {
|
|
|
1719
1940
|
return offer.entries;
|
|
1720
1941
|
}
|
|
1721
1942
|
};
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1943
|
+
_ts_decorate11([
|
|
1944
|
+
Get7(),
|
|
1945
|
+
_ts_param10(0, Req7()),
|
|
1946
|
+
_ts_param10(1, Query4("threadId")),
|
|
1947
|
+
_ts_metadata11("design:type", Function),
|
|
1948
|
+
_ts_metadata11("design:paramtypes", [
|
|
1728
1949
|
typeof Request === "undefined" ? Object : Request,
|
|
1729
1950
|
String
|
|
1730
1951
|
]),
|
|
1731
|
-
|
|
1952
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1732
1953
|
], SkillsController.prototype, "list", null);
|
|
1733
|
-
SkillsController =
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1954
|
+
SkillsController = _ts_decorate11([
|
|
1955
|
+
Controller8("skills"),
|
|
1956
|
+
_ts_param10(0, Inject10(AGENT_ACTOR_RESOLVER7)),
|
|
1957
|
+
_ts_param10(1, Optional5()),
|
|
1958
|
+
_ts_param10(1, Inject10(AGENT_SKILLS2)),
|
|
1959
|
+
_ts_metadata11("design:type", Function),
|
|
1960
|
+
_ts_metadata11("design:paramtypes", [
|
|
1740
1961
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1741
1962
|
Object
|
|
1742
1963
|
])
|
|
1743
1964
|
], SkillsController);
|
|
1744
1965
|
|
|
1745
1966
|
// src/controller/threads.controller.ts
|
|
1746
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1747
|
-
import { Body as Body3, Controller as
|
|
1748
|
-
function
|
|
1967
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
|
|
1968
|
+
import { Body as Body3, Controller as Controller9, Delete as Delete2, Get as Get8, Inject as Inject11, Param as Param4, Patch, Post as Post4, Req as Req8 } from "@nestjs/common";
|
|
1969
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1749
1970
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1750
1971
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1751
1972
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1758,19 +1979,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
1758
1979
|
}
|
|
1759
1980
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1760
1981
|
}
|
|
1761
|
-
__name(
|
|
1762
|
-
function
|
|
1982
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1983
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
1763
1984
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1764
1985
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1765
1986
|
}
|
|
1766
1987
|
}
|
|
1767
|
-
__name(
|
|
1768
|
-
function
|
|
1988
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1989
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1769
1990
|
return function(target, key) {
|
|
1770
1991
|
decorator(target, key, paramIndex);
|
|
1771
1992
|
};
|
|
1772
1993
|
}
|
|
1773
|
-
__name(
|
|
1994
|
+
__name(_ts_param11, "_ts_param");
|
|
1774
1995
|
var ThreadsController = class {
|
|
1775
1996
|
static {
|
|
1776
1997
|
__name(this, "ThreadsController");
|
|
@@ -1813,6 +2034,9 @@ var ThreadsController = class {
|
|
|
1813
2034
|
} : {},
|
|
1814
2035
|
..."defaultAgent" in body ? {
|
|
1815
2036
|
defaultAgent: body.defaultAgent ?? null
|
|
2037
|
+
} : {},
|
|
2038
|
+
..."model" in body ? {
|
|
2039
|
+
model: body.model ?? null
|
|
1816
2040
|
} : {}
|
|
1817
2041
|
});
|
|
1818
2042
|
return {
|
|
@@ -1834,101 +2058,101 @@ var ThreadsController = class {
|
|
|
1834
2058
|
};
|
|
1835
2059
|
}
|
|
1836
2060
|
};
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
2061
|
+
_ts_decorate12([
|
|
2062
|
+
Get8(),
|
|
2063
|
+
_ts_param11(0, Req8()),
|
|
2064
|
+
_ts_metadata12("design:type", Function),
|
|
2065
|
+
_ts_metadata12("design:paramtypes", [
|
|
1842
2066
|
typeof Request === "undefined" ? Object : Request
|
|
1843
2067
|
]),
|
|
1844
|
-
|
|
2068
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1845
2069
|
], ThreadsController.prototype, "list", null);
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
2070
|
+
_ts_decorate12([
|
|
2071
|
+
Get8(":id"),
|
|
2072
|
+
_ts_param11(0, Req8()),
|
|
2073
|
+
_ts_param11(1, Param4("id")),
|
|
2074
|
+
_ts_metadata12("design:type", Function),
|
|
2075
|
+
_ts_metadata12("design:paramtypes", [
|
|
1852
2076
|
typeof Request === "undefined" ? Object : Request,
|
|
1853
2077
|
String
|
|
1854
2078
|
]),
|
|
1855
|
-
|
|
2079
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1856
2080
|
], ThreadsController.prototype, "detail", null);
|
|
1857
|
-
|
|
2081
|
+
_ts_decorate12([
|
|
1858
2082
|
Delete2(":id"),
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
2083
|
+
_ts_param11(0, Req8()),
|
|
2084
|
+
_ts_param11(1, Param4("id")),
|
|
2085
|
+
_ts_metadata12("design:type", Function),
|
|
2086
|
+
_ts_metadata12("design:paramtypes", [
|
|
1863
2087
|
typeof Request === "undefined" ? Object : Request,
|
|
1864
2088
|
String
|
|
1865
2089
|
]),
|
|
1866
|
-
|
|
2090
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1867
2091
|
], ThreadsController.prototype, "remove", null);
|
|
1868
|
-
|
|
2092
|
+
_ts_decorate12([
|
|
1869
2093
|
Post4(":id/fork-from/:messageId"),
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
2094
|
+
_ts_param11(0, Req8()),
|
|
2095
|
+
_ts_param11(1, Param4("id")),
|
|
2096
|
+
_ts_param11(2, Param4("messageId")),
|
|
2097
|
+
_ts_metadata12("design:type", Function),
|
|
2098
|
+
_ts_metadata12("design:paramtypes", [
|
|
1875
2099
|
typeof Request === "undefined" ? Object : Request,
|
|
1876
2100
|
String,
|
|
1877
2101
|
String
|
|
1878
2102
|
]),
|
|
1879
|
-
|
|
2103
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1880
2104
|
], ThreadsController.prototype, "fork", null);
|
|
1881
|
-
|
|
2105
|
+
_ts_decorate12([
|
|
1882
2106
|
Patch(":id"),
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
2107
|
+
_ts_param11(0, Req8()),
|
|
2108
|
+
_ts_param11(1, Param4("id")),
|
|
2109
|
+
_ts_param11(2, Body3()),
|
|
2110
|
+
_ts_metadata12("design:type", Function),
|
|
2111
|
+
_ts_metadata12("design:paramtypes", [
|
|
1888
2112
|
typeof Request === "undefined" ? Object : Request,
|
|
1889
2113
|
String,
|
|
1890
2114
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
1891
2115
|
]),
|
|
1892
|
-
|
|
2116
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1893
2117
|
], ThreadsController.prototype, "update", null);
|
|
1894
|
-
|
|
2118
|
+
_ts_decorate12([
|
|
1895
2119
|
Post4(":id/promote"),
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
2120
|
+
_ts_param11(0, Req8()),
|
|
2121
|
+
_ts_param11(1, Param4("id")),
|
|
2122
|
+
_ts_metadata12("design:type", Function),
|
|
2123
|
+
_ts_metadata12("design:paramtypes", [
|
|
1900
2124
|
typeof Request === "undefined" ? Object : Request,
|
|
1901
2125
|
String
|
|
1902
2126
|
]),
|
|
1903
|
-
|
|
2127
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1904
2128
|
], ThreadsController.prototype, "promote", null);
|
|
1905
|
-
|
|
2129
|
+
_ts_decorate12([
|
|
1906
2130
|
Delete2(":id/from/:messageId"),
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
2131
|
+
_ts_param11(0, Req8()),
|
|
2132
|
+
_ts_param11(1, Param4("id")),
|
|
2133
|
+
_ts_param11(2, Param4("messageId")),
|
|
2134
|
+
_ts_metadata12("design:type", Function),
|
|
2135
|
+
_ts_metadata12("design:paramtypes", [
|
|
1912
2136
|
typeof Request === "undefined" ? Object : Request,
|
|
1913
2137
|
String,
|
|
1914
2138
|
String
|
|
1915
2139
|
]),
|
|
1916
|
-
|
|
2140
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1917
2141
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
1918
|
-
ThreadsController =
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
2142
|
+
ThreadsController = _ts_decorate12([
|
|
2143
|
+
Controller9("threads"),
|
|
2144
|
+
_ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER8)),
|
|
2145
|
+
_ts_metadata12("design:type", Function),
|
|
2146
|
+
_ts_metadata12("design:paramtypes", [
|
|
1923
2147
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1924
2148
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1925
2149
|
])
|
|
1926
2150
|
], ThreadsController);
|
|
1927
2151
|
|
|
1928
2152
|
// src/controller/tool-call.controller.ts
|
|
1929
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1930
|
-
import { BadRequestException as BadRequestException4, Body as Body4, Controller as
|
|
1931
|
-
function
|
|
2153
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9 } from "@dudousxd/nestjs-agent-core";
|
|
2154
|
+
import { BadRequestException as BadRequestException4, Body as Body4, Controller as Controller10, Inject as Inject12, Post as Post5, Req as Req9 } from "@nestjs/common";
|
|
2155
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1932
2156
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1933
2157
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1934
2158
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1941,19 +2165,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
1941
2165
|
}
|
|
1942
2166
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1943
2167
|
}
|
|
1944
|
-
__name(
|
|
1945
|
-
function
|
|
2168
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2169
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
1946
2170
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1947
2171
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1948
2172
|
}
|
|
1949
2173
|
}
|
|
1950
|
-
__name(
|
|
1951
|
-
function
|
|
2174
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2175
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1952
2176
|
return function(target, key) {
|
|
1953
2177
|
decorator(target, key, paramIndex);
|
|
1954
2178
|
};
|
|
1955
2179
|
}
|
|
1956
|
-
__name(
|
|
2180
|
+
__name(_ts_param12, "_ts_param");
|
|
1957
2181
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
1958
2182
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
1959
2183
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2082,64 +2306,64 @@ var ToolCallController = class {
|
|
|
2082
2306
|
};
|
|
2083
2307
|
}
|
|
2084
2308
|
};
|
|
2085
|
-
|
|
2309
|
+
_ts_decorate13([
|
|
2086
2310
|
Post5("approve"),
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2311
|
+
_ts_param12(0, Req9()),
|
|
2312
|
+
_ts_param12(1, Body4()),
|
|
2313
|
+
_ts_metadata13("design:type", Function),
|
|
2314
|
+
_ts_metadata13("design:paramtypes", [
|
|
2091
2315
|
typeof Request === "undefined" ? Object : Request,
|
|
2092
2316
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2093
2317
|
]),
|
|
2094
|
-
|
|
2318
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2095
2319
|
], ToolCallController.prototype, "approve", null);
|
|
2096
|
-
|
|
2320
|
+
_ts_decorate13([
|
|
2097
2321
|
Post5("reject"),
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2322
|
+
_ts_param12(0, Req9()),
|
|
2323
|
+
_ts_param12(1, Body4()),
|
|
2324
|
+
_ts_metadata13("design:type", Function),
|
|
2325
|
+
_ts_metadata13("design:paramtypes", [
|
|
2102
2326
|
typeof Request === "undefined" ? Object : Request,
|
|
2103
2327
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2104
2328
|
]),
|
|
2105
|
-
|
|
2329
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2106
2330
|
], ToolCallController.prototype, "reject", null);
|
|
2107
|
-
|
|
2331
|
+
_ts_decorate13([
|
|
2108
2332
|
Post5("answer"),
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2333
|
+
_ts_param12(0, Req9()),
|
|
2334
|
+
_ts_param12(1, Body4()),
|
|
2335
|
+
_ts_metadata13("design:type", Function),
|
|
2336
|
+
_ts_metadata13("design:paramtypes", [
|
|
2113
2337
|
typeof Request === "undefined" ? Object : Request,
|
|
2114
2338
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2115
2339
|
]),
|
|
2116
|
-
|
|
2340
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2117
2341
|
], ToolCallController.prototype, "answer", null);
|
|
2118
|
-
|
|
2342
|
+
_ts_decorate13([
|
|
2119
2343
|
Post5("skip"),
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2344
|
+
_ts_param12(0, Req9()),
|
|
2345
|
+
_ts_param12(1, Body4()),
|
|
2346
|
+
_ts_metadata13("design:type", Function),
|
|
2347
|
+
_ts_metadata13("design:paramtypes", [
|
|
2124
2348
|
typeof Request === "undefined" ? Object : Request,
|
|
2125
2349
|
Object
|
|
2126
2350
|
]),
|
|
2127
|
-
|
|
2351
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2128
2352
|
], ToolCallController.prototype, "skip", null);
|
|
2129
|
-
ToolCallController =
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2353
|
+
ToolCallController = _ts_decorate13([
|
|
2354
|
+
Controller10("tool-call"),
|
|
2355
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER9)),
|
|
2356
|
+
_ts_metadata13("design:type", Function),
|
|
2357
|
+
_ts_metadata13("design:paramtypes", [
|
|
2134
2358
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2135
2359
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2136
2360
|
])
|
|
2137
2361
|
], ToolCallController);
|
|
2138
2362
|
|
|
2139
2363
|
// src/controller/tools.controller.ts
|
|
2140
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2141
|
-
import { Controller as
|
|
2142
|
-
function
|
|
2364
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
2365
|
+
import { Controller as Controller11, Get as Get9, Inject as Inject13, NotFoundException as NotFoundException3, Query as Query5, Req as Req10 } from "@nestjs/common";
|
|
2366
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2143
2367
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2144
2368
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2145
2369
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2152,19 +2376,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2152
2376
|
}
|
|
2153
2377
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2154
2378
|
}
|
|
2155
|
-
__name(
|
|
2156
|
-
function
|
|
2379
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2380
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2157
2381
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2158
2382
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2159
2383
|
}
|
|
2160
2384
|
}
|
|
2161
|
-
__name(
|
|
2162
|
-
function
|
|
2385
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2386
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2163
2387
|
return function(target, key) {
|
|
2164
2388
|
decorator(target, key, paramIndex);
|
|
2165
2389
|
};
|
|
2166
2390
|
}
|
|
2167
|
-
__name(
|
|
2391
|
+
__name(_ts_param13, "_ts_param");
|
|
2168
2392
|
var ToolsController = class {
|
|
2169
2393
|
static {
|
|
2170
2394
|
__name(this, "ToolsController");
|
|
@@ -2193,24 +2417,24 @@ var ToolsController = class {
|
|
|
2193
2417
|
}));
|
|
2194
2418
|
}
|
|
2195
2419
|
};
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2420
|
+
_ts_decorate14([
|
|
2421
|
+
Get9(),
|
|
2422
|
+
_ts_param13(0, Req10()),
|
|
2423
|
+
_ts_param13(1, Query5("agent")),
|
|
2424
|
+
_ts_metadata14("design:type", Function),
|
|
2425
|
+
_ts_metadata14("design:paramtypes", [
|
|
2202
2426
|
typeof Request === "undefined" ? Object : Request,
|
|
2203
2427
|
String
|
|
2204
2428
|
]),
|
|
2205
|
-
|
|
2429
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2206
2430
|
], ToolsController.prototype, "list", null);
|
|
2207
|
-
ToolsController =
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2431
|
+
ToolsController = _ts_decorate14([
|
|
2432
|
+
Controller11("tools"),
|
|
2433
|
+
_ts_param13(0, Inject13(AGENT_ACTOR_RESOLVER10)),
|
|
2434
|
+
_ts_param13(1, Inject13(AGENT_DEPS_FACTORY3)),
|
|
2435
|
+
_ts_param13(2, Inject13(AGENT_REGISTRY3)),
|
|
2436
|
+
_ts_metadata14("design:type", Function),
|
|
2437
|
+
_ts_metadata14("design:paramtypes", [
|
|
2214
2438
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2215
2439
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2216
2440
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -2219,7 +2443,7 @@ ToolsController = _ts_decorate13([
|
|
|
2219
2443
|
|
|
2220
2444
|
// src/discovery/agent-discovery.service.ts
|
|
2221
2445
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
2222
|
-
import { Inject as
|
|
2446
|
+
import { Inject as Inject14, Injectable as Injectable4, Logger } from "@nestjs/common";
|
|
2223
2447
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
2224
2448
|
|
|
2225
2449
|
// src/decorator/agent.decorator.ts
|
|
@@ -2254,7 +2478,7 @@ function SystemPromptContributor() {
|
|
|
2254
2478
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
2255
2479
|
|
|
2256
2480
|
// src/discovery/agent-discovery.service.ts
|
|
2257
|
-
function
|
|
2481
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2258
2482
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2259
2483
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2260
2484
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2267,19 +2491,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2267
2491
|
}
|
|
2268
2492
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2269
2493
|
}
|
|
2270
|
-
__name(
|
|
2271
|
-
function
|
|
2494
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2495
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2272
2496
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2273
2497
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2274
2498
|
}
|
|
2275
2499
|
}
|
|
2276
|
-
__name(
|
|
2277
|
-
function
|
|
2500
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2501
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2278
2502
|
return function(target, key) {
|
|
2279
2503
|
decorator(target, key, paramIndex);
|
|
2280
2504
|
};
|
|
2281
2505
|
}
|
|
2282
|
-
__name(
|
|
2506
|
+
__name(_ts_param14, "_ts_param");
|
|
2283
2507
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2284
2508
|
static {
|
|
2285
2509
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2406,12 +2630,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2406
2630
|
return (ctx) => candidate.call(instance, ctx);
|
|
2407
2631
|
}
|
|
2408
2632
|
};
|
|
2409
|
-
AgentDiscoveryService =
|
|
2633
|
+
AgentDiscoveryService = _ts_decorate15([
|
|
2410
2634
|
Injectable4(),
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2635
|
+
_ts_param14(2, Inject14(AGENT_REGISTRY4)),
|
|
2636
|
+
_ts_param14(3, Inject14(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
2637
|
+
_ts_metadata15("design:type", Function),
|
|
2638
|
+
_ts_metadata15("design:paramtypes", [
|
|
2415
2639
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
2416
2640
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
2417
2641
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -2420,8 +2644,8 @@ AgentDiscoveryService = _ts_decorate14([
|
|
|
2420
2644
|
], AgentDiscoveryService);
|
|
2421
2645
|
|
|
2422
2646
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2423
|
-
import { AGENT_OPTIONS as
|
|
2424
|
-
import { Inject as
|
|
2647
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
2648
|
+
import { Inject as Inject15, Injectable as Injectable5, Logger as Logger2 } from "@nestjs/common";
|
|
2425
2649
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
2426
2650
|
import { z } from "zod";
|
|
2427
2651
|
|
|
@@ -2470,7 +2694,7 @@ function provideAgentTool(factoryOrTool, inject) {
|
|
|
2470
2694
|
__name(provideAgentTool, "provideAgentTool");
|
|
2471
2695
|
|
|
2472
2696
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2473
|
-
function
|
|
2697
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2474
2698
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2475
2699
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2476
2700
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2483,19 +2707,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2483
2707
|
}
|
|
2484
2708
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2485
2709
|
}
|
|
2486
|
-
__name(
|
|
2487
|
-
function
|
|
2710
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2711
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2488
2712
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2489
2713
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2490
2714
|
}
|
|
2491
2715
|
}
|
|
2492
|
-
__name(
|
|
2493
|
-
function
|
|
2716
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2717
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2494
2718
|
return function(target, key) {
|
|
2495
2719
|
decorator(target, key, paramIndex);
|
|
2496
2720
|
};
|
|
2497
2721
|
}
|
|
2498
|
-
__name(
|
|
2722
|
+
__name(_ts_param15, "_ts_param");
|
|
2499
2723
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2500
2724
|
static {
|
|
2501
2725
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2628,13 +2852,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2628
2852
|
return true;
|
|
2629
2853
|
}
|
|
2630
2854
|
};
|
|
2631
|
-
AiToolDiscoveryService =
|
|
2855
|
+
AiToolDiscoveryService = _ts_decorate16([
|
|
2632
2856
|
Injectable5(),
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2857
|
+
_ts_param15(1, Inject15(AGENT_TOOL_REGISTRY2)),
|
|
2858
|
+
_ts_param15(2, Inject15(AGENT_REGISTRY5)),
|
|
2859
|
+
_ts_param15(3, Inject15(AGENT_OPTIONS4)),
|
|
2860
|
+
_ts_metadata16("design:type", Function),
|
|
2861
|
+
_ts_metadata16("design:paramtypes", [
|
|
2638
2862
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
2639
2863
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
2640
2864
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -2644,7 +2868,7 @@ AiToolDiscoveryService = _ts_decorate15([
|
|
|
2644
2868
|
|
|
2645
2869
|
// src/discovery/skill-discovery.service.ts
|
|
2646
2870
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
2647
|
-
import { Inject as
|
|
2871
|
+
import { Inject as Inject16, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
|
|
2648
2872
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
2649
2873
|
|
|
2650
2874
|
// src/decorator/skill.decorator.ts
|
|
@@ -2667,7 +2891,7 @@ function skillScope(options) {
|
|
|
2667
2891
|
__name(skillScope, "skillScope");
|
|
2668
2892
|
|
|
2669
2893
|
// src/discovery/skill-discovery.service.ts
|
|
2670
|
-
function
|
|
2894
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2671
2895
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2672
2896
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2673
2897
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2680,19 +2904,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2680
2904
|
}
|
|
2681
2905
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2682
2906
|
}
|
|
2683
|
-
__name(
|
|
2684
|
-
function
|
|
2907
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2908
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2685
2909
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2686
2910
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2687
2911
|
}
|
|
2688
2912
|
}
|
|
2689
|
-
__name(
|
|
2690
|
-
function
|
|
2913
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
2914
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2691
2915
|
return function(target, key) {
|
|
2692
2916
|
decorator(target, key, paramIndex);
|
|
2693
2917
|
};
|
|
2694
2918
|
}
|
|
2695
|
-
__name(
|
|
2919
|
+
__name(_ts_param16, "_ts_param");
|
|
2696
2920
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
2697
2921
|
static {
|
|
2698
2922
|
__name(this, "SkillDiscoveryService");
|
|
@@ -2736,11 +2960,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
2736
2960
|
return flat === void 0 ? void 0 : () => flat;
|
|
2737
2961
|
}
|
|
2738
2962
|
};
|
|
2739
|
-
SkillDiscoveryService =
|
|
2963
|
+
SkillDiscoveryService = _ts_decorate17([
|
|
2740
2964
|
Injectable6(),
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2965
|
+
_ts_param16(1, Inject16(AGENT_SKILL_SOURCES)),
|
|
2966
|
+
_ts_metadata17("design:type", Function),
|
|
2967
|
+
_ts_metadata17("design:paramtypes", [
|
|
2744
2968
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
2745
2969
|
Array
|
|
2746
2970
|
])
|
|
@@ -2814,6 +3038,69 @@ var InProcessTokenStreamSink = class {
|
|
|
2814
3038
|
}
|
|
2815
3039
|
};
|
|
2816
3040
|
|
|
3041
|
+
// src/ledger-quota-provider.ts
|
|
3042
|
+
import { exhaustedWindow, quotaPeriodRange } from "@dudousxd/nestjs-agent-core";
|
|
3043
|
+
var LedgerQuotaProvider = class {
|
|
3044
|
+
static {
|
|
3045
|
+
__name(this, "LedgerQuotaProvider");
|
|
3046
|
+
}
|
|
3047
|
+
store;
|
|
3048
|
+
quota;
|
|
3049
|
+
limits;
|
|
3050
|
+
constructor(store, quota, limits = {}) {
|
|
3051
|
+
this.store = store;
|
|
3052
|
+
this.quota = quota;
|
|
3053
|
+
this.limits = limits;
|
|
3054
|
+
}
|
|
3055
|
+
async report(query) {
|
|
3056
|
+
const now = query.now ?? /* @__PURE__ */ new Date();
|
|
3057
|
+
const actorRef = query.actor.id;
|
|
3058
|
+
const windows = [
|
|
3059
|
+
await this.dayWindow(actorRef, now)
|
|
3060
|
+
];
|
|
3061
|
+
if (this.store.usageBetween !== void 0) {
|
|
3062
|
+
const range = quotaPeriodRange("month", now);
|
|
3063
|
+
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
3064
|
+
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
3065
|
+
}
|
|
3066
|
+
const blocked = exhaustedWindow(windows);
|
|
3067
|
+
return {
|
|
3068
|
+
windows,
|
|
3069
|
+
...blocked !== void 0 ? {
|
|
3070
|
+
blocked
|
|
3071
|
+
} : {}
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
async dayWindow(actorRef, now) {
|
|
3075
|
+
const range = quotaPeriodRange("day", now);
|
|
3076
|
+
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
3077
|
+
if (this.quota === void 0) {
|
|
3078
|
+
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3079
|
+
}
|
|
3080
|
+
const state = await this.quota.check(actorRef, range.fromDay);
|
|
3081
|
+
const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
|
|
3082
|
+
if (window.limitTokens === void 0) {
|
|
3083
|
+
window.limitTokens = state.limitTokens;
|
|
3084
|
+
}
|
|
3085
|
+
return window;
|
|
3086
|
+
}
|
|
3087
|
+
window(period, usedTokens, usedUsd, resetsAt) {
|
|
3088
|
+
const limits = this.limits[period] ?? {};
|
|
3089
|
+
return {
|
|
3090
|
+
period,
|
|
3091
|
+
usedTokens,
|
|
3092
|
+
...limits.tokens !== void 0 ? {
|
|
3093
|
+
limitTokens: limits.tokens
|
|
3094
|
+
} : {},
|
|
3095
|
+
usedUsd,
|
|
3096
|
+
...limits.usd !== void 0 ? {
|
|
3097
|
+
limitUsd: limits.usd
|
|
3098
|
+
} : {},
|
|
3099
|
+
resetsAt
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
|
|
2817
3104
|
// src/ledger-quota-store.ts
|
|
2818
3105
|
var LedgerQuotaStore = class {
|
|
2819
3106
|
static {
|
|
@@ -2839,8 +3126,8 @@ var LedgerQuotaStore = class {
|
|
|
2839
3126
|
|
|
2840
3127
|
// src/runner/inline-agent-runner.ts
|
|
2841
3128
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as AGENT_STORE3, RunCancelledError, agentFailureCode, encodeStreamEvent, publishAgentRunFailed, runAgentLoop, settleAll, settleUnsettledDelegation } from "@dudousxd/nestjs-agent-core";
|
|
2842
|
-
import { Inject as
|
|
2843
|
-
function
|
|
3129
|
+
import { Inject as Inject17, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
|
|
3130
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2844
3131
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2845
3132
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2846
3133
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2853,19 +3140,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2853
3140
|
}
|
|
2854
3141
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2855
3142
|
}
|
|
2856
|
-
__name(
|
|
2857
|
-
function
|
|
3143
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3144
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2858
3145
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2859
3146
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2860
3147
|
}
|
|
2861
3148
|
}
|
|
2862
|
-
__name(
|
|
2863
|
-
function
|
|
3149
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3150
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2864
3151
|
return function(target, key) {
|
|
2865
3152
|
decorator(target, key, paramIndex);
|
|
2866
3153
|
};
|
|
2867
3154
|
}
|
|
2868
|
-
__name(
|
|
3155
|
+
__name(_ts_param17, "_ts_param");
|
|
2869
3156
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
2870
3157
|
static {
|
|
2871
3158
|
__name(this, "InlineAgentRunner");
|
|
@@ -3246,12 +3533,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3246
3533
|
}
|
|
3247
3534
|
}
|
|
3248
3535
|
};
|
|
3249
|
-
InlineAgentRunner =
|
|
3536
|
+
InlineAgentRunner = _ts_decorate18([
|
|
3250
3537
|
Injectable7(),
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3538
|
+
_ts_param17(0, Inject17(AGENT_DEPS_FACTORY4)),
|
|
3539
|
+
_ts_param17(1, Inject17(AGENT_STORE3)),
|
|
3540
|
+
_ts_metadata18("design:type", Function),
|
|
3541
|
+
_ts_metadata18("design:paramtypes", [
|
|
3255
3542
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3256
3543
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3257
3544
|
])
|
|
@@ -3296,7 +3583,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3296
3583
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3297
3584
|
|
|
3298
3585
|
// src/agent.module.ts
|
|
3299
|
-
function
|
|
3586
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3300
3587
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3301
3588
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3302
3589
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3309,7 +3596,7 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3309
3596
|
}
|
|
3310
3597
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3311
3598
|
}
|
|
3312
|
-
__name(
|
|
3599
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3313
3600
|
var DEFAULT_PATH = "agent";
|
|
3314
3601
|
function sharedProviders(durable, includeStore) {
|
|
3315
3602
|
const providers = [
|
|
@@ -3340,7 +3627,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
3340
3627
|
provide: AGENT_SKILLS3,
|
|
3341
3628
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3342
3629
|
inject: [
|
|
3343
|
-
|
|
3630
|
+
AGENT_OPTIONS5,
|
|
3344
3631
|
AGENT_SKILL_SOURCES2
|
|
3345
3632
|
]
|
|
3346
3633
|
},
|
|
@@ -3350,35 +3637,35 @@ function sharedProviders(durable, includeStore) {
|
|
|
3350
3637
|
provide: AGENT_MEMORY3,
|
|
3351
3638
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3352
3639
|
inject: [
|
|
3353
|
-
|
|
3640
|
+
AGENT_OPTIONS5
|
|
3354
3641
|
]
|
|
3355
3642
|
},
|
|
3356
3643
|
{
|
|
3357
3644
|
provide: AGENT_SINK2,
|
|
3358
3645
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3359
3646
|
inject: [
|
|
3360
|
-
|
|
3647
|
+
AGENT_OPTIONS5
|
|
3361
3648
|
]
|
|
3362
3649
|
},
|
|
3363
3650
|
{
|
|
3364
3651
|
provide: AGENT_ROLES_POLICY2,
|
|
3365
3652
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3366
3653
|
inject: [
|
|
3367
|
-
|
|
3654
|
+
AGENT_OPTIONS5
|
|
3368
3655
|
]
|
|
3369
3656
|
},
|
|
3370
3657
|
{
|
|
3371
|
-
provide:
|
|
3658
|
+
provide: AGENT_ACTOR_RESOLVER11,
|
|
3372
3659
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
3373
3660
|
inject: [
|
|
3374
|
-
|
|
3661
|
+
AGENT_OPTIONS5
|
|
3375
3662
|
]
|
|
3376
3663
|
},
|
|
3377
3664
|
{
|
|
3378
3665
|
provide: AGENT_MODEL2,
|
|
3379
3666
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3380
3667
|
inject: [
|
|
3381
|
-
|
|
3668
|
+
AGENT_OPTIONS5
|
|
3382
3669
|
]
|
|
3383
3670
|
},
|
|
3384
3671
|
{
|
|
@@ -3388,10 +3675,26 @@ function sharedProviders(durable, includeStore) {
|
|
|
3388
3675
|
provide: AGENT_QUOTA_STORE3,
|
|
3389
3676
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3390
3677
|
inject: [
|
|
3391
|
-
|
|
3678
|
+
AGENT_OPTIONS5,
|
|
3392
3679
|
AGENT_STORE4
|
|
3393
3680
|
]
|
|
3394
3681
|
},
|
|
3682
|
+
{
|
|
3683
|
+
provide: AGENT_QUOTA_PROVIDER2,
|
|
3684
|
+
useFactory: /* @__PURE__ */ __name((o, store, quota) => o.quotaProvider ?? new LedgerQuotaProvider(store, quota, o.quotaLimits), "useFactory"),
|
|
3685
|
+
inject: [
|
|
3686
|
+
AGENT_OPTIONS5,
|
|
3687
|
+
AGENT_STORE4,
|
|
3688
|
+
AGENT_QUOTA_STORE3
|
|
3689
|
+
]
|
|
3690
|
+
},
|
|
3691
|
+
{
|
|
3692
|
+
provide: AGENT_MODEL_CATALOG2,
|
|
3693
|
+
useFactory: /* @__PURE__ */ __name((o) => o.models, "useFactory"),
|
|
3694
|
+
inject: [
|
|
3695
|
+
AGENT_OPTIONS5
|
|
3696
|
+
]
|
|
3697
|
+
},
|
|
3395
3698
|
AgentDepsFactory2,
|
|
3396
3699
|
{
|
|
3397
3700
|
provide: AGENT_DEPS_FACTORY5,
|
|
@@ -3417,7 +3720,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
3417
3720
|
provide: AGENT_STORE4,
|
|
3418
3721
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
3419
3722
|
inject: [
|
|
3420
|
-
|
|
3723
|
+
AGENT_OPTIONS5
|
|
3421
3724
|
]
|
|
3422
3725
|
});
|
|
3423
3726
|
}
|
|
@@ -3448,17 +3751,19 @@ function sharedProviders(durable, includeStore) {
|
|
|
3448
3751
|
__name(sharedProviders, "sharedProviders");
|
|
3449
3752
|
function exportsFor(includeStore) {
|
|
3450
3753
|
return [
|
|
3451
|
-
|
|
3754
|
+
AGENT_OPTIONS5,
|
|
3452
3755
|
AGENT_TOOL_REGISTRY3,
|
|
3453
3756
|
AGENT_REGISTRY6,
|
|
3454
3757
|
AGENT_SINK2,
|
|
3455
3758
|
AGENT_ROLES_POLICY2,
|
|
3456
|
-
|
|
3759
|
+
AGENT_ACTOR_RESOLVER11,
|
|
3457
3760
|
AGENT_MODEL2,
|
|
3458
3761
|
...includeStore ? [
|
|
3459
3762
|
AGENT_STORE4
|
|
3460
3763
|
] : [],
|
|
3461
3764
|
AGENT_QUOTA_STORE3,
|
|
3765
|
+
AGENT_MODEL_CATALOG2,
|
|
3766
|
+
AGENT_QUOTA_PROVIDER2,
|
|
3462
3767
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
3463
3768
|
AGENT_SKILLS3,
|
|
3464
3769
|
AGENT_MEMORY3,
|
|
@@ -3479,7 +3784,8 @@ var BASE_CONTROLLERS = [
|
|
|
3479
3784
|
SkillsController,
|
|
3480
3785
|
MemoriesController,
|
|
3481
3786
|
ToolsController,
|
|
3482
|
-
MessagesController
|
|
3787
|
+
MessagesController,
|
|
3788
|
+
ModelsController
|
|
3483
3789
|
];
|
|
3484
3790
|
var GUARDABLE_CONTROLLERS = [
|
|
3485
3791
|
...BASE_CONTROLLERS,
|
|
@@ -3537,7 +3843,7 @@ var AgentModule = class _AgentModule {
|
|
|
3537
3843
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
3538
3844
|
providers: [
|
|
3539
3845
|
{
|
|
3540
|
-
provide:
|
|
3846
|
+
provide: AGENT_OPTIONS5,
|
|
3541
3847
|
useValue: options
|
|
3542
3848
|
},
|
|
3543
3849
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -3561,7 +3867,7 @@ var AgentModule = class _AgentModule {
|
|
|
3561
3867
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
3562
3868
|
providers: [
|
|
3563
3869
|
{
|
|
3564
|
-
provide:
|
|
3870
|
+
provide: AGENT_OPTIONS5,
|
|
3565
3871
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
3566
3872
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
3567
3873
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -3582,7 +3888,7 @@ var AgentModule = class _AgentModule {
|
|
|
3582
3888
|
};
|
|
3583
3889
|
}
|
|
3584
3890
|
};
|
|
3585
|
-
AgentModule =
|
|
3891
|
+
AgentModule = _ts_decorate19([
|
|
3586
3892
|
Global(),
|
|
3587
3893
|
Module({})
|
|
3588
3894
|
], AgentModule);
|
|
@@ -3639,9 +3945,11 @@ export {
|
|
|
3639
3945
|
HeaderActorResolver,
|
|
3640
3946
|
InProcessTokenStreamSink,
|
|
3641
3947
|
InlineAgentRunner,
|
|
3948
|
+
LedgerQuotaProvider,
|
|
3642
3949
|
LedgerQuotaStore,
|
|
3643
3950
|
MemoriesController,
|
|
3644
3951
|
MessagesController,
|
|
3952
|
+
ModelsController,
|
|
3645
3953
|
SKILL_METADATA,
|
|
3646
3954
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
3647
3955
|
SYSTEM_PROMPT_METADATA,
|