@dudousxd/nestjs-agent 1.5.0 → 1.7.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 +49 -0
- package/dist/{agent-deps.factory-CUyVPsa1.d.cts → agent-deps.factory-CiC5Va9J.d.cts} +7 -1
- package/dist/{agent-deps.factory-CUyVPsa1.d.ts → agent-deps.factory-CiC5Va9J.d.ts} +7 -1
- package/dist/durable/index.cjs +622 -319
- 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 +531 -228
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +626 -322
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -5
- package/dist/index.d.ts +67 -5
- package/dist/index.js +529 -227
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -42,6 +42,8 @@ __export(index_exports, {
|
|
|
42
42
|
InlineAgentRunner: () => InlineAgentRunner,
|
|
43
43
|
LedgerQuotaStore: () => LedgerQuotaStore,
|
|
44
44
|
MemoriesController: () => MemoriesController,
|
|
45
|
+
MessagesController: () => MessagesController,
|
|
46
|
+
ModelsController: () => ModelsController,
|
|
45
47
|
SKILL_METADATA: () => SKILL_METADATA,
|
|
46
48
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA: () => SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
47
49
|
SYSTEM_PROMPT_METADATA: () => SYSTEM_PROMPT_METADATA,
|
|
@@ -64,8 +66,8 @@ __export(index_exports, {
|
|
|
64
66
|
module.exports = __toCommonJS(index_exports);
|
|
65
67
|
|
|
66
68
|
// src/agent.module.ts
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
70
|
+
var import_common19 = require("@nestjs/common");
|
|
69
71
|
var import_core4 = require("@nestjs/core");
|
|
70
72
|
|
|
71
73
|
// src/agent-deps.factory.ts
|
|
@@ -389,15 +391,72 @@ var AgentService = class {
|
|
|
389
391
|
deps;
|
|
390
392
|
quota;
|
|
391
393
|
staging;
|
|
392
|
-
|
|
394
|
+
models;
|
|
395
|
+
constructor(runner, store, deps, quota, staging, models) {
|
|
393
396
|
this.runner = runner;
|
|
394
397
|
this.store = store;
|
|
395
398
|
this.deps = deps;
|
|
396
399
|
this.quota = quota;
|
|
397
400
|
this.staging = staging;
|
|
401
|
+
this.models = models;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
|
|
405
|
+
* bound, so a picker simply has nothing to offer.
|
|
406
|
+
*/
|
|
407
|
+
async listModels(actor, agent) {
|
|
408
|
+
if (this.models === void 0) {
|
|
409
|
+
return {
|
|
410
|
+
providers: [],
|
|
411
|
+
default: null
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return this.models.list({
|
|
415
|
+
actor,
|
|
416
|
+
...agent !== void 0 ? {
|
|
417
|
+
agent
|
|
418
|
+
} : {}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
|
|
423
|
+
* one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
|
|
424
|
+
* pinned and again at every turn that runs on it (availability can change in between).
|
|
425
|
+
*/
|
|
426
|
+
async assertModelAllowed(actor, agent, model) {
|
|
427
|
+
if (this.models === void 0) {
|
|
428
|
+
throw new import_common2.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
429
|
+
}
|
|
430
|
+
const entry = (0, import_nestjs_agent_core3.findCatalogModel)(await this.models.list({
|
|
431
|
+
actor,
|
|
432
|
+
agent
|
|
433
|
+
}), model);
|
|
434
|
+
if (entry === void 0) {
|
|
435
|
+
throw new import_common2.BadRequestException(`model "${model}" is not offered`);
|
|
436
|
+
}
|
|
437
|
+
if (!entry.available) {
|
|
438
|
+
throw new import_common2.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
439
|
+
}
|
|
440
|
+
return entry.id;
|
|
441
|
+
}
|
|
442
|
+
/** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
|
|
443
|
+
async resolveModel(actor, agent, requested, threadId) {
|
|
444
|
+
const model = requested ?? (threadId !== void 0 ? await this.threadModel(threadId) : null);
|
|
445
|
+
if (model === null || model === void 0) {
|
|
446
|
+
return void 0;
|
|
447
|
+
}
|
|
448
|
+
return this.assertModelAllowed(actor, agent, model);
|
|
449
|
+
}
|
|
450
|
+
async threadModel(threadId) {
|
|
451
|
+
const projecting = this.store;
|
|
452
|
+
if (typeof projecting.modelForThread === "function") {
|
|
453
|
+
return projecting.modelForThread(threadId);
|
|
454
|
+
}
|
|
455
|
+
return (await this.store.getThread(threadId))?.model ?? null;
|
|
398
456
|
}
|
|
399
457
|
async chat(params) {
|
|
400
458
|
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
459
|
+
const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
|
|
401
460
|
const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
|
|
402
461
|
let threadId = params.threadId;
|
|
403
462
|
if (threadId === void 0) {
|
|
@@ -428,6 +487,9 @@ var AgentService = class {
|
|
|
428
487
|
} : {},
|
|
429
488
|
...params.pageContext !== void 0 ? {
|
|
430
489
|
pageContext: params.pageContext
|
|
490
|
+
} : {},
|
|
491
|
+
...model !== void 0 ? {
|
|
492
|
+
model
|
|
431
493
|
} : {}
|
|
432
494
|
};
|
|
433
495
|
const { runId } = await this.runner.start(input);
|
|
@@ -598,20 +660,26 @@ var AgentService = class {
|
|
|
598
660
|
async updateThread(actor, threadId, patch) {
|
|
599
661
|
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
600
662
|
await this.assertOwnsThread(actor, threadId);
|
|
601
|
-
if (patch.defaultAgent === void 0) {
|
|
663
|
+
if (patch.defaultAgent === void 0 && patch.model === void 0) {
|
|
602
664
|
if (title !== void 0) {
|
|
603
665
|
await this.store.setTitle(threadId, title);
|
|
604
666
|
}
|
|
605
667
|
return;
|
|
606
668
|
}
|
|
607
669
|
if (this.store.updateThread === void 0) {
|
|
608
|
-
throw new import_common2.NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
670
|
+
throw new import_common2.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
609
671
|
}
|
|
672
|
+
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);
|
|
610
673
|
await this.store.updateThread(threadId, {
|
|
611
674
|
...title !== void 0 ? {
|
|
612
675
|
title
|
|
613
676
|
} : {},
|
|
614
|
-
|
|
677
|
+
...patch.defaultAgent !== void 0 ? {
|
|
678
|
+
defaultAgent: patch.defaultAgent
|
|
679
|
+
} : {},
|
|
680
|
+
...model !== void 0 ? {
|
|
681
|
+
model
|
|
682
|
+
} : {}
|
|
615
683
|
});
|
|
616
684
|
}
|
|
617
685
|
validateTitle(title) {
|
|
@@ -658,6 +726,7 @@ var AgentService = class {
|
|
|
658
726
|
return {
|
|
659
727
|
...thread,
|
|
660
728
|
defaultAgent: thread.defaultAgent ?? null,
|
|
729
|
+
model: thread.model ?? null,
|
|
661
730
|
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
662
731
|
};
|
|
663
732
|
}
|
|
@@ -685,6 +754,40 @@ var AgentService = class {
|
|
|
685
754
|
return this.store.truncateFrom(threadId, messageId);
|
|
686
755
|
}
|
|
687
756
|
/**
|
|
757
|
+
* Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
|
|
758
|
+
* to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
|
|
759
|
+
* on a store without `threadOfMessage` + `setMessageFeedback`.
|
|
760
|
+
*/
|
|
761
|
+
async setMessageFeedback(actor, messageId, input) {
|
|
762
|
+
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
763
|
+
throw new import_common2.BadRequestException("value must be 'up', 'down' or null");
|
|
764
|
+
}
|
|
765
|
+
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
766
|
+
throw new import_common2.BadRequestException("comment must be a string");
|
|
767
|
+
}
|
|
768
|
+
const comment = input.comment?.trim();
|
|
769
|
+
if (comment !== void 0 && comment.length > 2e3) {
|
|
770
|
+
throw new import_common2.BadRequestException("comment must be at most 2000 characters");
|
|
771
|
+
}
|
|
772
|
+
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
773
|
+
throw new import_common2.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
774
|
+
}
|
|
775
|
+
const threadId = await this.store.threadOfMessage(messageId);
|
|
776
|
+
if (threadId === null) {
|
|
777
|
+
throw new import_common2.NotFoundException(`message ${messageId} not found`);
|
|
778
|
+
}
|
|
779
|
+
await this.assertOwnsThread(actor, threadId);
|
|
780
|
+
const feedback = input.value === null ? null : {
|
|
781
|
+
value: input.value,
|
|
782
|
+
...comment !== void 0 && comment.length > 0 ? {
|
|
783
|
+
comment
|
|
784
|
+
} : {},
|
|
785
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
786
|
+
};
|
|
787
|
+
await this.store.setMessageFeedback(messageId, feedback);
|
|
788
|
+
return feedback;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
688
791
|
* Every file this actor has staged, newest first — across threads, including uploads that were
|
|
689
792
|
* never sent, which nothing else on this surface can see.
|
|
690
793
|
*
|
|
@@ -891,13 +994,16 @@ AgentService = _ts_decorate2([
|
|
|
891
994
|
_ts_param2(3, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_QUOTA_STORE)),
|
|
892
995
|
_ts_param2(4, (0, import_common2.Optional)()),
|
|
893
996
|
_ts_param2(4, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_ATTACHMENT_STAGING)),
|
|
997
|
+
_ts_param2(5, (0, import_common2.Optional)()),
|
|
998
|
+
_ts_param2(5, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_MODEL_CATALOG)),
|
|
894
999
|
_ts_metadata2("design:type", Function),
|
|
895
1000
|
_ts_metadata2("design:paramtypes", [
|
|
896
1001
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
897
1002
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
898
1003
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
899
1004
|
Object,
|
|
900
|
-
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
|
|
1005
|
+
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1006
|
+
typeof ModelCatalog === "undefined" ? Object : ModelCatalog
|
|
901
1007
|
])
|
|
902
1008
|
], AgentService);
|
|
903
1009
|
|
|
@@ -1269,13 +1375,22 @@ var ChatController = class {
|
|
|
1269
1375
|
} : {},
|
|
1270
1376
|
...body.transient === true ? {
|
|
1271
1377
|
transient: true
|
|
1378
|
+
} : {},
|
|
1379
|
+
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
1380
|
+
model: body.model
|
|
1272
1381
|
} : {}
|
|
1273
1382
|
});
|
|
1274
1383
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
1275
1384
|
}
|
|
1276
|
-
|
|
1385
|
+
/**
|
|
1386
|
+
* Attach to a run's stream: every buffered frame, then live ones. `?after=<seq>` (or the SSE
|
|
1387
|
+
* `Last-Event-ID` header a browser `EventSource` sends on its own) skips the frames a reconnecting
|
|
1388
|
+
* client already has — see {@link pipe} for how frames are numbered.
|
|
1389
|
+
*/
|
|
1390
|
+
async stream(req, runId, res, after) {
|
|
1277
1391
|
const actor = await this.actorResolver.resolve(req);
|
|
1278
|
-
|
|
1392
|
+
const cursor = parseCursor(after) ?? parseCursor(req.headers["last-event-id"]) ?? 0;
|
|
1393
|
+
await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId), void 0, cursor);
|
|
1279
1394
|
}
|
|
1280
1395
|
async cancel(req, runId) {
|
|
1281
1396
|
const actor = await this.actorResolver.resolve(req);
|
|
@@ -1284,7 +1399,15 @@ var ChatController = class {
|
|
|
1284
1399
|
aborted: true
|
|
1285
1400
|
};
|
|
1286
1401
|
}
|
|
1287
|
-
|
|
1402
|
+
/**
|
|
1403
|
+
* Every `data:` frame carries an SSE `id:` — its 1-based sequence number within the run. The
|
|
1404
|
+
* number is a pure function of the run's buffered stream (every sink replays a run from its first
|
|
1405
|
+
* chunk, in write order), so the same frame gets the same number on the POST that started the run
|
|
1406
|
+
* and on any later `GET …/stream`, whichever replica serves it. A reconnecting client passes the
|
|
1407
|
+
* last one it saw as `?after=`; frames at or below it are read off the sink but not re-sent.
|
|
1408
|
+
* `meta`, `done` and `error` carry no id: `meta` is re-sent on every attach, the terminals once.
|
|
1409
|
+
*/
|
|
1410
|
+
async pipe(res, runId, events, threadId, after = 0) {
|
|
1288
1411
|
res.setHeader("Content-Type", "text/event-stream");
|
|
1289
1412
|
res.setHeader("Cache-Control", "no-cache");
|
|
1290
1413
|
res.setHeader("Connection", "keep-alive");
|
|
@@ -1301,6 +1424,16 @@ data: ${JSON.stringify({
|
|
|
1301
1424
|
`);
|
|
1302
1425
|
const decoder = new TextDecoder();
|
|
1303
1426
|
let buffer = "";
|
|
1427
|
+
let seq = 0;
|
|
1428
|
+
const forward = /* @__PURE__ */ __name((line) => {
|
|
1429
|
+
seq += 1;
|
|
1430
|
+
if (seq > after) {
|
|
1431
|
+
res.write(`id: ${seq}
|
|
1432
|
+
data: ${line}
|
|
1433
|
+
|
|
1434
|
+
`);
|
|
1435
|
+
}
|
|
1436
|
+
}, "forward");
|
|
1304
1437
|
try {
|
|
1305
1438
|
for await (const chunk of events) {
|
|
1306
1439
|
buffer += decoder.decode(chunk, {
|
|
@@ -1311,17 +1444,13 @@ data: ${JSON.stringify({
|
|
|
1311
1444
|
const line = buffer.slice(0, newline);
|
|
1312
1445
|
buffer = buffer.slice(newline + 1);
|
|
1313
1446
|
if (line.length > 0) {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
`);
|
|
1447
|
+
forward(line);
|
|
1317
1448
|
}
|
|
1318
1449
|
newline = buffer.indexOf("\n");
|
|
1319
1450
|
}
|
|
1320
1451
|
}
|
|
1321
1452
|
if (buffer.length > 0) {
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
`);
|
|
1453
|
+
forward(buffer);
|
|
1325
1454
|
}
|
|
1326
1455
|
res.write("event: done\ndata: {}\n\n");
|
|
1327
1456
|
} catch (error) {
|
|
@@ -1358,11 +1487,13 @@ _ts_decorate6([
|
|
|
1358
1487
|
_ts_param5(0, (0, import_common6.Req)()),
|
|
1359
1488
|
_ts_param5(1, (0, import_common6.Param)("runId")),
|
|
1360
1489
|
_ts_param5(2, (0, import_common6.Res)()),
|
|
1490
|
+
_ts_param5(3, (0, import_common6.Query)("after")),
|
|
1361
1491
|
_ts_metadata6("design:type", Function),
|
|
1362
1492
|
_ts_metadata6("design:paramtypes", [
|
|
1363
1493
|
typeof Request === "undefined" ? Object : Request,
|
|
1364
1494
|
String,
|
|
1365
|
-
typeof Response === "undefined" ? Object : Response
|
|
1495
|
+
typeof Response === "undefined" ? Object : Response,
|
|
1496
|
+
String
|
|
1366
1497
|
]),
|
|
1367
1498
|
_ts_metadata6("design:returntype", Promise)
|
|
1368
1499
|
], ChatController.prototype, "stream", null);
|
|
@@ -1386,6 +1517,15 @@ ChatController = _ts_decorate6([
|
|
|
1386
1517
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1387
1518
|
])
|
|
1388
1519
|
], ChatController);
|
|
1520
|
+
function parseCursor(raw) {
|
|
1521
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
1522
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
|
|
1523
|
+
return void 0;
|
|
1524
|
+
}
|
|
1525
|
+
const parsed = Number(value.trim());
|
|
1526
|
+
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
1527
|
+
}
|
|
1528
|
+
__name(parseCursor, "parseCursor");
|
|
1389
1529
|
|
|
1390
1530
|
// src/controller/memories.controller.ts
|
|
1391
1531
|
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
@@ -1522,7 +1662,7 @@ MemoriesController = _ts_decorate7([
|
|
|
1522
1662
|
])
|
|
1523
1663
|
], MemoriesController);
|
|
1524
1664
|
|
|
1525
|
-
// src/controller/
|
|
1665
|
+
// src/controller/messages.controller.ts
|
|
1526
1666
|
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1527
1667
|
var import_common8 = require("@nestjs/common");
|
|
1528
1668
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
@@ -1551,9 +1691,9 @@ function _ts_param7(paramIndex, decorator) {
|
|
|
1551
1691
|
};
|
|
1552
1692
|
}
|
|
1553
1693
|
__name(_ts_param7, "_ts_param");
|
|
1554
|
-
var
|
|
1694
|
+
var MessagesController = class {
|
|
1555
1695
|
static {
|
|
1556
|
-
__name(this, "
|
|
1696
|
+
__name(this, "MessagesController");
|
|
1557
1697
|
}
|
|
1558
1698
|
agent;
|
|
1559
1699
|
actorResolver;
|
|
@@ -1561,31 +1701,48 @@ var QuotaController = class {
|
|
|
1561
1701
|
this.agent = agent;
|
|
1562
1702
|
this.actorResolver = actorResolver;
|
|
1563
1703
|
}
|
|
1564
|
-
|
|
1704
|
+
/**
|
|
1705
|
+
* Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
|
|
1706
|
+
* (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
|
|
1707
|
+
*/
|
|
1708
|
+
async feedback(req, id, body) {
|
|
1565
1709
|
const actor = await this.actorResolver.resolve(req);
|
|
1566
|
-
|
|
1710
|
+
const feedback = await this.agent.setMessageFeedback(actor, id, {
|
|
1711
|
+
value: body?.value ?? null,
|
|
1712
|
+
...body?.comment !== void 0 ? {
|
|
1713
|
+
comment: body.comment
|
|
1714
|
+
} : {}
|
|
1715
|
+
});
|
|
1716
|
+
return {
|
|
1717
|
+
feedback
|
|
1718
|
+
};
|
|
1567
1719
|
}
|
|
1568
1720
|
};
|
|
1569
1721
|
_ts_decorate8([
|
|
1570
|
-
(0, import_common8.
|
|
1722
|
+
(0, import_common8.Post)(":id/feedback"),
|
|
1723
|
+
(0, import_common8.HttpCode)(200),
|
|
1571
1724
|
_ts_param7(0, (0, import_common8.Req)()),
|
|
1725
|
+
_ts_param7(1, (0, import_common8.Param)("id")),
|
|
1726
|
+
_ts_param7(2, (0, import_common8.Body)()),
|
|
1572
1727
|
_ts_metadata8("design:type", Function),
|
|
1573
1728
|
_ts_metadata8("design:paramtypes", [
|
|
1574
|
-
typeof Request === "undefined" ? Object : Request
|
|
1729
|
+
typeof Request === "undefined" ? Object : Request,
|
|
1730
|
+
String,
|
|
1731
|
+
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
1575
1732
|
]),
|
|
1576
1733
|
_ts_metadata8("design:returntype", Promise)
|
|
1577
|
-
],
|
|
1578
|
-
|
|
1579
|
-
(0, import_common8.Controller)("
|
|
1734
|
+
], MessagesController.prototype, "feedback", null);
|
|
1735
|
+
MessagesController = _ts_decorate8([
|
|
1736
|
+
(0, import_common8.Controller)("messages"),
|
|
1580
1737
|
_ts_param7(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
|
|
1581
1738
|
_ts_metadata8("design:type", Function),
|
|
1582
1739
|
_ts_metadata8("design:paramtypes", [
|
|
1583
1740
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1584
1741
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1585
1742
|
])
|
|
1586
|
-
],
|
|
1743
|
+
], MessagesController);
|
|
1587
1744
|
|
|
1588
|
-
// src/controller/
|
|
1745
|
+
// src/controller/models.controller.ts
|
|
1589
1746
|
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
1590
1747
|
var import_common9 = require("@nestjs/common");
|
|
1591
1748
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
@@ -1614,6 +1771,138 @@ function _ts_param8(paramIndex, decorator) {
|
|
|
1614
1771
|
};
|
|
1615
1772
|
}
|
|
1616
1773
|
__name(_ts_param8, "_ts_param");
|
|
1774
|
+
var ModelsController = class {
|
|
1775
|
+
static {
|
|
1776
|
+
__name(this, "ModelsController");
|
|
1777
|
+
}
|
|
1778
|
+
agent;
|
|
1779
|
+
actorResolver;
|
|
1780
|
+
constructor(agent, actorResolver) {
|
|
1781
|
+
this.agent = agent;
|
|
1782
|
+
this.actorResolver = actorResolver;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* The models the caller may pick for `agent` (the default agent when omitted), grouped by
|
|
1786
|
+
* provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
|
|
1787
|
+
*/
|
|
1788
|
+
async list(req, agent) {
|
|
1789
|
+
const actor = await this.actorResolver.resolve(req);
|
|
1790
|
+
return this.agent.listModels(actor, agent);
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
_ts_decorate9([
|
|
1794
|
+
(0, import_common9.Get)(),
|
|
1795
|
+
_ts_param8(0, (0, import_common9.Req)()),
|
|
1796
|
+
_ts_param8(1, (0, import_common9.Query)("agent")),
|
|
1797
|
+
_ts_metadata9("design:type", Function),
|
|
1798
|
+
_ts_metadata9("design:paramtypes", [
|
|
1799
|
+
typeof Request === "undefined" ? Object : Request,
|
|
1800
|
+
String
|
|
1801
|
+
]),
|
|
1802
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1803
|
+
], ModelsController.prototype, "list", null);
|
|
1804
|
+
ModelsController = _ts_decorate9([
|
|
1805
|
+
(0, import_common9.Controller)("models"),
|
|
1806
|
+
_ts_param8(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
|
|
1807
|
+
_ts_metadata9("design:type", Function),
|
|
1808
|
+
_ts_metadata9("design:paramtypes", [
|
|
1809
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1810
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1811
|
+
])
|
|
1812
|
+
], ModelsController);
|
|
1813
|
+
|
|
1814
|
+
// src/controller/quota.controller.ts
|
|
1815
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1816
|
+
var import_common10 = require("@nestjs/common");
|
|
1817
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1818
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1819
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1820
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1821
|
+
} else {
|
|
1822
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1823
|
+
if (d = decorators[i]) {
|
|
1824
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1829
|
+
}
|
|
1830
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1831
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
1832
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1833
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1837
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1838
|
+
return function(target, key) {
|
|
1839
|
+
decorator(target, key, paramIndex);
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
__name(_ts_param9, "_ts_param");
|
|
1843
|
+
var QuotaController = class {
|
|
1844
|
+
static {
|
|
1845
|
+
__name(this, "QuotaController");
|
|
1846
|
+
}
|
|
1847
|
+
agent;
|
|
1848
|
+
actorResolver;
|
|
1849
|
+
constructor(agent, actorResolver) {
|
|
1850
|
+
this.agent = agent;
|
|
1851
|
+
this.actorResolver = actorResolver;
|
|
1852
|
+
}
|
|
1853
|
+
async today(req) {
|
|
1854
|
+
const actor = await this.actorResolver.resolve(req);
|
|
1855
|
+
return this.agent.quotaToday(actor.id);
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
_ts_decorate10([
|
|
1859
|
+
(0, import_common10.Get)("today"),
|
|
1860
|
+
_ts_param9(0, (0, import_common10.Req)()),
|
|
1861
|
+
_ts_metadata10("design:type", Function),
|
|
1862
|
+
_ts_metadata10("design:paramtypes", [
|
|
1863
|
+
typeof Request === "undefined" ? Object : Request
|
|
1864
|
+
]),
|
|
1865
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1866
|
+
], QuotaController.prototype, "today", null);
|
|
1867
|
+
QuotaController = _ts_decorate10([
|
|
1868
|
+
(0, import_common10.Controller)("quota"),
|
|
1869
|
+
_ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
1870
|
+
_ts_metadata10("design:type", Function),
|
|
1871
|
+
_ts_metadata10("design:paramtypes", [
|
|
1872
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1873
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1874
|
+
])
|
|
1875
|
+
], QuotaController);
|
|
1876
|
+
|
|
1877
|
+
// src/controller/skills.controller.ts
|
|
1878
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1879
|
+
var import_common11 = require("@nestjs/common");
|
|
1880
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1881
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1882
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1883
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1884
|
+
} else {
|
|
1885
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1886
|
+
if (d = decorators[i]) {
|
|
1887
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1892
|
+
}
|
|
1893
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1894
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
1895
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1896
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1900
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1901
|
+
return function(target, key) {
|
|
1902
|
+
decorator(target, key, paramIndex);
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
__name(_ts_param10, "_ts_param");
|
|
1617
1906
|
var SkillsController = class {
|
|
1618
1907
|
static {
|
|
1619
1908
|
__name(this, "SkillsController");
|
|
@@ -1629,40 +1918,40 @@ var SkillsController = class {
|
|
|
1629
1918
|
return [];
|
|
1630
1919
|
}
|
|
1631
1920
|
const actor = await this.actorResolver.resolve(req);
|
|
1632
|
-
const offer = await (0,
|
|
1921
|
+
const offer = await (0, import_nestjs_agent_core11.offerSkills)(this.skills, {
|
|
1633
1922
|
actor,
|
|
1634
1923
|
threadId: threadId ?? ""
|
|
1635
1924
|
});
|
|
1636
1925
|
return offer.entries;
|
|
1637
1926
|
}
|
|
1638
1927
|
};
|
|
1639
|
-
|
|
1640
|
-
(0,
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1928
|
+
_ts_decorate11([
|
|
1929
|
+
(0, import_common11.Get)(),
|
|
1930
|
+
_ts_param10(0, (0, import_common11.Req)()),
|
|
1931
|
+
_ts_param10(1, (0, import_common11.Query)("threadId")),
|
|
1932
|
+
_ts_metadata11("design:type", Function),
|
|
1933
|
+
_ts_metadata11("design:paramtypes", [
|
|
1645
1934
|
typeof Request === "undefined" ? Object : Request,
|
|
1646
1935
|
String
|
|
1647
1936
|
]),
|
|
1648
|
-
|
|
1937
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1649
1938
|
], SkillsController.prototype, "list", null);
|
|
1650
|
-
SkillsController =
|
|
1651
|
-
(0,
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1939
|
+
SkillsController = _ts_decorate11([
|
|
1940
|
+
(0, import_common11.Controller)("skills"),
|
|
1941
|
+
_ts_param10(0, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
|
|
1942
|
+
_ts_param10(1, (0, import_common11.Optional)()),
|
|
1943
|
+
_ts_param10(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_SKILLS)),
|
|
1944
|
+
_ts_metadata11("design:type", Function),
|
|
1945
|
+
_ts_metadata11("design:paramtypes", [
|
|
1657
1946
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1658
1947
|
Object
|
|
1659
1948
|
])
|
|
1660
1949
|
], SkillsController);
|
|
1661
1950
|
|
|
1662
1951
|
// src/controller/threads.controller.ts
|
|
1663
|
-
var
|
|
1664
|
-
var
|
|
1665
|
-
function
|
|
1952
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1953
|
+
var import_common12 = require("@nestjs/common");
|
|
1954
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1666
1955
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1667
1956
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1668
1957
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1675,19 +1964,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1675
1964
|
}
|
|
1676
1965
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1677
1966
|
}
|
|
1678
|
-
__name(
|
|
1679
|
-
function
|
|
1967
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1968
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
1680
1969
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1681
1970
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1682
1971
|
}
|
|
1683
1972
|
}
|
|
1684
|
-
__name(
|
|
1685
|
-
function
|
|
1973
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1974
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1686
1975
|
return function(target, key) {
|
|
1687
1976
|
decorator(target, key, paramIndex);
|
|
1688
1977
|
};
|
|
1689
1978
|
}
|
|
1690
|
-
__name(
|
|
1979
|
+
__name(_ts_param11, "_ts_param");
|
|
1691
1980
|
var ThreadsController = class {
|
|
1692
1981
|
static {
|
|
1693
1982
|
__name(this, "ThreadsController");
|
|
@@ -1730,6 +2019,9 @@ var ThreadsController = class {
|
|
|
1730
2019
|
} : {},
|
|
1731
2020
|
..."defaultAgent" in body ? {
|
|
1732
2021
|
defaultAgent: body.defaultAgent ?? null
|
|
2022
|
+
} : {},
|
|
2023
|
+
..."model" in body ? {
|
|
2024
|
+
model: body.model ?? null
|
|
1733
2025
|
} : {}
|
|
1734
2026
|
});
|
|
1735
2027
|
return {
|
|
@@ -1751,101 +2043,101 @@ var ThreadsController = class {
|
|
|
1751
2043
|
};
|
|
1752
2044
|
}
|
|
1753
2045
|
};
|
|
1754
|
-
|
|
1755
|
-
(0,
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
2046
|
+
_ts_decorate12([
|
|
2047
|
+
(0, import_common12.Get)(),
|
|
2048
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2049
|
+
_ts_metadata12("design:type", Function),
|
|
2050
|
+
_ts_metadata12("design:paramtypes", [
|
|
1759
2051
|
typeof Request === "undefined" ? Object : Request
|
|
1760
2052
|
]),
|
|
1761
|
-
|
|
2053
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1762
2054
|
], ThreadsController.prototype, "list", null);
|
|
1763
|
-
|
|
1764
|
-
(0,
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2055
|
+
_ts_decorate12([
|
|
2056
|
+
(0, import_common12.Get)(":id"),
|
|
2057
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2058
|
+
_ts_param11(1, (0, import_common12.Param)("id")),
|
|
2059
|
+
_ts_metadata12("design:type", Function),
|
|
2060
|
+
_ts_metadata12("design:paramtypes", [
|
|
1769
2061
|
typeof Request === "undefined" ? Object : Request,
|
|
1770
2062
|
String
|
|
1771
2063
|
]),
|
|
1772
|
-
|
|
2064
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1773
2065
|
], ThreadsController.prototype, "detail", null);
|
|
1774
|
-
|
|
1775
|
-
(0,
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
2066
|
+
_ts_decorate12([
|
|
2067
|
+
(0, import_common12.Delete)(":id"),
|
|
2068
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2069
|
+
_ts_param11(1, (0, import_common12.Param)("id")),
|
|
2070
|
+
_ts_metadata12("design:type", Function),
|
|
2071
|
+
_ts_metadata12("design:paramtypes", [
|
|
1780
2072
|
typeof Request === "undefined" ? Object : Request,
|
|
1781
2073
|
String
|
|
1782
2074
|
]),
|
|
1783
|
-
|
|
2075
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1784
2076
|
], ThreadsController.prototype, "remove", null);
|
|
1785
|
-
|
|
1786
|
-
(0,
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2077
|
+
_ts_decorate12([
|
|
2078
|
+
(0, import_common12.Post)(":id/fork-from/:messageId"),
|
|
2079
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2080
|
+
_ts_param11(1, (0, import_common12.Param)("id")),
|
|
2081
|
+
_ts_param11(2, (0, import_common12.Param)("messageId")),
|
|
2082
|
+
_ts_metadata12("design:type", Function),
|
|
2083
|
+
_ts_metadata12("design:paramtypes", [
|
|
1792
2084
|
typeof Request === "undefined" ? Object : Request,
|
|
1793
2085
|
String,
|
|
1794
2086
|
String
|
|
1795
2087
|
]),
|
|
1796
|
-
|
|
2088
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1797
2089
|
], ThreadsController.prototype, "fork", null);
|
|
1798
|
-
|
|
1799
|
-
(0,
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2090
|
+
_ts_decorate12([
|
|
2091
|
+
(0, import_common12.Patch)(":id"),
|
|
2092
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2093
|
+
_ts_param11(1, (0, import_common12.Param)("id")),
|
|
2094
|
+
_ts_param11(2, (0, import_common12.Body)()),
|
|
2095
|
+
_ts_metadata12("design:type", Function),
|
|
2096
|
+
_ts_metadata12("design:paramtypes", [
|
|
1805
2097
|
typeof Request === "undefined" ? Object : Request,
|
|
1806
2098
|
String,
|
|
1807
2099
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
1808
2100
|
]),
|
|
1809
|
-
|
|
2101
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1810
2102
|
], ThreadsController.prototype, "update", null);
|
|
1811
|
-
|
|
1812
|
-
(0,
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
2103
|
+
_ts_decorate12([
|
|
2104
|
+
(0, import_common12.Post)(":id/promote"),
|
|
2105
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2106
|
+
_ts_param11(1, (0, import_common12.Param)("id")),
|
|
2107
|
+
_ts_metadata12("design:type", Function),
|
|
2108
|
+
_ts_metadata12("design:paramtypes", [
|
|
1817
2109
|
typeof Request === "undefined" ? Object : Request,
|
|
1818
2110
|
String
|
|
1819
2111
|
]),
|
|
1820
|
-
|
|
2112
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1821
2113
|
], ThreadsController.prototype, "promote", null);
|
|
1822
|
-
|
|
1823
|
-
(0,
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2114
|
+
_ts_decorate12([
|
|
2115
|
+
(0, import_common12.Delete)(":id/from/:messageId"),
|
|
2116
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2117
|
+
_ts_param11(1, (0, import_common12.Param)("id")),
|
|
2118
|
+
_ts_param11(2, (0, import_common12.Param)("messageId")),
|
|
2119
|
+
_ts_metadata12("design:type", Function),
|
|
2120
|
+
_ts_metadata12("design:paramtypes", [
|
|
1829
2121
|
typeof Request === "undefined" ? Object : Request,
|
|
1830
2122
|
String,
|
|
1831
2123
|
String
|
|
1832
2124
|
]),
|
|
1833
|
-
|
|
2125
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1834
2126
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
1835
|
-
ThreadsController =
|
|
1836
|
-
(0,
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
2127
|
+
ThreadsController = _ts_decorate12([
|
|
2128
|
+
(0, import_common12.Controller)("threads"),
|
|
2129
|
+
_ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
2130
|
+
_ts_metadata12("design:type", Function),
|
|
2131
|
+
_ts_metadata12("design:paramtypes", [
|
|
1840
2132
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1841
2133
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1842
2134
|
])
|
|
1843
2135
|
], ThreadsController);
|
|
1844
2136
|
|
|
1845
2137
|
// src/controller/tool-call.controller.ts
|
|
1846
|
-
var
|
|
1847
|
-
var
|
|
1848
|
-
function
|
|
2138
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2139
|
+
var import_common13 = require("@nestjs/common");
|
|
2140
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1849
2141
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1850
2142
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1851
2143
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1858,19 +2150,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
1858
2150
|
}
|
|
1859
2151
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1860
2152
|
}
|
|
1861
|
-
__name(
|
|
1862
|
-
function
|
|
2153
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2154
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
1863
2155
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1864
2156
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1865
2157
|
}
|
|
1866
2158
|
}
|
|
1867
|
-
__name(
|
|
1868
|
-
function
|
|
2159
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2160
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1869
2161
|
return function(target, key) {
|
|
1870
2162
|
decorator(target, key, paramIndex);
|
|
1871
2163
|
};
|
|
1872
2164
|
}
|
|
1873
|
-
__name(
|
|
2165
|
+
__name(_ts_param12, "_ts_param");
|
|
1874
2166
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
1875
2167
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
1876
2168
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -1879,7 +2171,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
1879
2171
|
var DEFAULT_VIA = "web";
|
|
1880
2172
|
function toolCallId(claimed) {
|
|
1881
2173
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
1882
|
-
throw new
|
|
2174
|
+
throw new import_common13.BadRequestException("toolCallId must be a non-empty string");
|
|
1883
2175
|
}
|
|
1884
2176
|
return claimed;
|
|
1885
2177
|
}
|
|
@@ -1889,10 +2181,10 @@ function rejectReason(claimed) {
|
|
|
1889
2181
|
return void 0;
|
|
1890
2182
|
}
|
|
1891
2183
|
if (typeof claimed !== "string") {
|
|
1892
|
-
throw new
|
|
2184
|
+
throw new import_common13.BadRequestException("reason must be a string");
|
|
1893
2185
|
}
|
|
1894
2186
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
1895
|
-
throw new
|
|
2187
|
+
throw new import_common13.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
1896
2188
|
}
|
|
1897
2189
|
return claimed;
|
|
1898
2190
|
}
|
|
@@ -1902,7 +2194,7 @@ function remember(claimed) {
|
|
|
1902
2194
|
return false;
|
|
1903
2195
|
}
|
|
1904
2196
|
if (typeof claimed !== "boolean") {
|
|
1905
|
-
throw new
|
|
2197
|
+
throw new import_common13.BadRequestException("remember must be a boolean");
|
|
1906
2198
|
}
|
|
1907
2199
|
return claimed;
|
|
1908
2200
|
}
|
|
@@ -1912,7 +2204,7 @@ function via(claimed) {
|
|
|
1912
2204
|
return DEFAULT_VIA;
|
|
1913
2205
|
}
|
|
1914
2206
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
1915
|
-
throw new
|
|
2207
|
+
throw new import_common13.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
1916
2208
|
}
|
|
1917
2209
|
return claimed;
|
|
1918
2210
|
}
|
|
@@ -1922,26 +2214,26 @@ function answers(claimed) {
|
|
|
1922
2214
|
return void 0;
|
|
1923
2215
|
}
|
|
1924
2216
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
1925
|
-
throw new
|
|
2217
|
+
throw new import_common13.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
1926
2218
|
}
|
|
1927
2219
|
const entries = Object.entries(claimed);
|
|
1928
2220
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
1929
|
-
throw new
|
|
2221
|
+
throw new import_common13.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
1930
2222
|
}
|
|
1931
2223
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
1932
2224
|
for (const [questionId, values] of entries) {
|
|
1933
2225
|
if (!Array.isArray(values)) {
|
|
1934
|
-
throw new
|
|
2226
|
+
throw new import_common13.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
1935
2227
|
}
|
|
1936
2228
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
1937
|
-
throw new
|
|
2229
|
+
throw new import_common13.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
1938
2230
|
}
|
|
1939
2231
|
for (const value of values) {
|
|
1940
2232
|
if (typeof value !== "string") {
|
|
1941
|
-
throw new
|
|
2233
|
+
throw new import_common13.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
1942
2234
|
}
|
|
1943
2235
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
1944
|
-
throw new
|
|
2236
|
+
throw new import_common13.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
1945
2237
|
}
|
|
1946
2238
|
}
|
|
1947
2239
|
validated[questionId] = values;
|
|
@@ -1999,64 +2291,64 @@ var ToolCallController = class {
|
|
|
1999
2291
|
};
|
|
2000
2292
|
}
|
|
2001
2293
|
};
|
|
2002
|
-
|
|
2003
|
-
(0,
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2294
|
+
_ts_decorate13([
|
|
2295
|
+
(0, import_common13.Post)("approve"),
|
|
2296
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2297
|
+
_ts_param12(1, (0, import_common13.Body)()),
|
|
2298
|
+
_ts_metadata13("design:type", Function),
|
|
2299
|
+
_ts_metadata13("design:paramtypes", [
|
|
2008
2300
|
typeof Request === "undefined" ? Object : Request,
|
|
2009
2301
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2010
2302
|
]),
|
|
2011
|
-
|
|
2303
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2012
2304
|
], ToolCallController.prototype, "approve", null);
|
|
2013
|
-
|
|
2014
|
-
(0,
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2305
|
+
_ts_decorate13([
|
|
2306
|
+
(0, import_common13.Post)("reject"),
|
|
2307
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2308
|
+
_ts_param12(1, (0, import_common13.Body)()),
|
|
2309
|
+
_ts_metadata13("design:type", Function),
|
|
2310
|
+
_ts_metadata13("design:paramtypes", [
|
|
2019
2311
|
typeof Request === "undefined" ? Object : Request,
|
|
2020
2312
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2021
2313
|
]),
|
|
2022
|
-
|
|
2314
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2023
2315
|
], ToolCallController.prototype, "reject", null);
|
|
2024
|
-
|
|
2025
|
-
(0,
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2316
|
+
_ts_decorate13([
|
|
2317
|
+
(0, import_common13.Post)("answer"),
|
|
2318
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2319
|
+
_ts_param12(1, (0, import_common13.Body)()),
|
|
2320
|
+
_ts_metadata13("design:type", Function),
|
|
2321
|
+
_ts_metadata13("design:paramtypes", [
|
|
2030
2322
|
typeof Request === "undefined" ? Object : Request,
|
|
2031
2323
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2032
2324
|
]),
|
|
2033
|
-
|
|
2325
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2034
2326
|
], ToolCallController.prototype, "answer", null);
|
|
2035
|
-
|
|
2036
|
-
(0,
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2327
|
+
_ts_decorate13([
|
|
2328
|
+
(0, import_common13.Post)("skip"),
|
|
2329
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2330
|
+
_ts_param12(1, (0, import_common13.Body)()),
|
|
2331
|
+
_ts_metadata13("design:type", Function),
|
|
2332
|
+
_ts_metadata13("design:paramtypes", [
|
|
2041
2333
|
typeof Request === "undefined" ? Object : Request,
|
|
2042
2334
|
Object
|
|
2043
2335
|
]),
|
|
2044
|
-
|
|
2336
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2045
2337
|
], ToolCallController.prototype, "skip", null);
|
|
2046
|
-
ToolCallController =
|
|
2047
|
-
(0,
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2338
|
+
ToolCallController = _ts_decorate13([
|
|
2339
|
+
(0, import_common13.Controller)("tool-call"),
|
|
2340
|
+
_ts_param12(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
2341
|
+
_ts_metadata13("design:type", Function),
|
|
2342
|
+
_ts_metadata13("design:paramtypes", [
|
|
2051
2343
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2052
2344
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2053
2345
|
])
|
|
2054
2346
|
], ToolCallController);
|
|
2055
2347
|
|
|
2056
2348
|
// src/controller/tools.controller.ts
|
|
2057
|
-
var
|
|
2058
|
-
var
|
|
2059
|
-
function
|
|
2349
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
2350
|
+
var import_common14 = require("@nestjs/common");
|
|
2351
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2060
2352
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2061
2353
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2062
2354
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2069,19 +2361,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2069
2361
|
}
|
|
2070
2362
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2071
2363
|
}
|
|
2072
|
-
__name(
|
|
2073
|
-
function
|
|
2364
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2365
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2074
2366
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2075
2367
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2076
2368
|
}
|
|
2077
2369
|
}
|
|
2078
|
-
__name(
|
|
2079
|
-
function
|
|
2370
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2371
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2080
2372
|
return function(target, key) {
|
|
2081
2373
|
decorator(target, key, paramIndex);
|
|
2082
2374
|
};
|
|
2083
2375
|
}
|
|
2084
|
-
__name(
|
|
2376
|
+
__name(_ts_param13, "_ts_param");
|
|
2085
2377
|
var ToolsController = class {
|
|
2086
2378
|
static {
|
|
2087
2379
|
__name(this, "ToolsController");
|
|
@@ -2096,7 +2388,7 @@ var ToolsController = class {
|
|
|
2096
2388
|
}
|
|
2097
2389
|
async list(req, agent) {
|
|
2098
2390
|
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
2099
|
-
throw new
|
|
2391
|
+
throw new import_common14.NotFoundException(`No agent named "${agent}"`);
|
|
2100
2392
|
}
|
|
2101
2393
|
const actor = await this.actorResolver.resolve(req);
|
|
2102
2394
|
const deps = this.depsFactory.forAgent(agent);
|
|
@@ -2110,33 +2402,33 @@ var ToolsController = class {
|
|
|
2110
2402
|
}));
|
|
2111
2403
|
}
|
|
2112
2404
|
};
|
|
2113
|
-
|
|
2114
|
-
(0,
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2405
|
+
_ts_decorate14([
|
|
2406
|
+
(0, import_common14.Get)(),
|
|
2407
|
+
_ts_param13(0, (0, import_common14.Req)()),
|
|
2408
|
+
_ts_param13(1, (0, import_common14.Query)("agent")),
|
|
2409
|
+
_ts_metadata14("design:type", Function),
|
|
2410
|
+
_ts_metadata14("design:paramtypes", [
|
|
2119
2411
|
typeof Request === "undefined" ? Object : Request,
|
|
2120
2412
|
String
|
|
2121
2413
|
]),
|
|
2122
|
-
|
|
2414
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2123
2415
|
], ToolsController.prototype, "list", null);
|
|
2124
|
-
ToolsController =
|
|
2125
|
-
(0,
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2416
|
+
ToolsController = _ts_decorate14([
|
|
2417
|
+
(0, import_common14.Controller)("tools"),
|
|
2418
|
+
_ts_param13(0, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
2419
|
+
_ts_param13(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
|
|
2420
|
+
_ts_param13(2, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
|
|
2421
|
+
_ts_metadata14("design:type", Function),
|
|
2422
|
+
_ts_metadata14("design:paramtypes", [
|
|
2131
2423
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2132
2424
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2133
|
-
typeof
|
|
2425
|
+
typeof import_nestjs_agent_core14.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core14.AgentRegistry
|
|
2134
2426
|
])
|
|
2135
2427
|
], ToolsController);
|
|
2136
2428
|
|
|
2137
2429
|
// src/discovery/agent-discovery.service.ts
|
|
2138
|
-
var
|
|
2139
|
-
var
|
|
2430
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2431
|
+
var import_common15 = require("@nestjs/common");
|
|
2140
2432
|
var import_core = require("@nestjs/core");
|
|
2141
2433
|
|
|
2142
2434
|
// src/decorator/agent.decorator.ts
|
|
@@ -2171,7 +2463,7 @@ function SystemPromptContributor() {
|
|
|
2171
2463
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
2172
2464
|
|
|
2173
2465
|
// src/discovery/agent-discovery.service.ts
|
|
2174
|
-
function
|
|
2466
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2175
2467
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2176
2468
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2177
2469
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2184,19 +2476,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2184
2476
|
}
|
|
2185
2477
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2186
2478
|
}
|
|
2187
|
-
__name(
|
|
2188
|
-
function
|
|
2479
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2480
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2189
2481
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2190
2482
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2191
2483
|
}
|
|
2192
2484
|
}
|
|
2193
|
-
__name(
|
|
2194
|
-
function
|
|
2485
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2486
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2195
2487
|
return function(target, key) {
|
|
2196
2488
|
decorator(target, key, paramIndex);
|
|
2197
2489
|
};
|
|
2198
2490
|
}
|
|
2199
|
-
__name(
|
|
2491
|
+
__name(_ts_param14, "_ts_param");
|
|
2200
2492
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2201
2493
|
static {
|
|
2202
2494
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2205,7 +2497,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2205
2497
|
scanner;
|
|
2206
2498
|
registry;
|
|
2207
2499
|
contributors;
|
|
2208
|
-
logger = new
|
|
2500
|
+
logger = new import_common15.Logger(_AgentDiscoveryService.name);
|
|
2209
2501
|
constructor(discovery, scanner, registry, contributors) {
|
|
2210
2502
|
this.discovery = discovery;
|
|
2211
2503
|
this.scanner = scanner;
|
|
@@ -2323,22 +2615,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2323
2615
|
return (ctx) => candidate.call(instance, ctx);
|
|
2324
2616
|
}
|
|
2325
2617
|
};
|
|
2326
|
-
AgentDiscoveryService =
|
|
2327
|
-
(0,
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2618
|
+
AgentDiscoveryService = _ts_decorate15([
|
|
2619
|
+
(0, import_common15.Injectable)(),
|
|
2620
|
+
_ts_param14(2, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
|
|
2621
|
+
_ts_param14(3, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_PROMPT_CONTRIBUTORS)),
|
|
2622
|
+
_ts_metadata15("design:type", Function),
|
|
2623
|
+
_ts_metadata15("design:paramtypes", [
|
|
2332
2624
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
2333
2625
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
2334
|
-
typeof
|
|
2626
|
+
typeof import_nestjs_agent_core15.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core15.AgentRegistry,
|
|
2335
2627
|
Array
|
|
2336
2628
|
])
|
|
2337
2629
|
], AgentDiscoveryService);
|
|
2338
2630
|
|
|
2339
2631
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2340
|
-
var
|
|
2341
|
-
var
|
|
2632
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
2633
|
+
var import_common16 = require("@nestjs/common");
|
|
2342
2634
|
var import_core2 = require("@nestjs/core");
|
|
2343
2635
|
var import_zod = require("zod");
|
|
2344
2636
|
|
|
@@ -2387,7 +2679,7 @@ function provideAgentTool(factoryOrTool, inject) {
|
|
|
2387
2679
|
__name(provideAgentTool, "provideAgentTool");
|
|
2388
2680
|
|
|
2389
2681
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2390
|
-
function
|
|
2682
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2391
2683
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2392
2684
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2393
2685
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2400,19 +2692,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2400
2692
|
}
|
|
2401
2693
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2402
2694
|
}
|
|
2403
|
-
__name(
|
|
2404
|
-
function
|
|
2695
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2696
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2405
2697
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2406
2698
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2407
2699
|
}
|
|
2408
2700
|
}
|
|
2409
|
-
__name(
|
|
2410
|
-
function
|
|
2701
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2702
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2411
2703
|
return function(target, key) {
|
|
2412
2704
|
decorator(target, key, paramIndex);
|
|
2413
2705
|
};
|
|
2414
2706
|
}
|
|
2415
|
-
__name(
|
|
2707
|
+
__name(_ts_param15, "_ts_param");
|
|
2416
2708
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2417
2709
|
static {
|
|
2418
2710
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2421,7 +2713,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2421
2713
|
registry;
|
|
2422
2714
|
agents;
|
|
2423
2715
|
options;
|
|
2424
|
-
logger = new
|
|
2716
|
+
logger = new import_common16.Logger(_AiToolDiscoveryService.name);
|
|
2425
2717
|
constructor(discovery, registry, agents, options) {
|
|
2426
2718
|
this.discovery = discovery;
|
|
2427
2719
|
this.registry = registry;
|
|
@@ -2495,7 +2787,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2495
2787
|
let delegates = 0;
|
|
2496
2788
|
for (const definition of this.agents.list()) {
|
|
2497
2789
|
for (const edge of definition.delegatesTo ?? []) {
|
|
2498
|
-
const { agent: target, detached } = (0,
|
|
2790
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core16.normalizeDelegation)(edge);
|
|
2499
2791
|
const targetDefinition = this.agents.get(target);
|
|
2500
2792
|
if (targetDefinition === void 0) {
|
|
2501
2793
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -2545,13 +2837,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2545
2837
|
return true;
|
|
2546
2838
|
}
|
|
2547
2839
|
};
|
|
2548
|
-
AiToolDiscoveryService =
|
|
2549
|
-
(0,
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2840
|
+
AiToolDiscoveryService = _ts_decorate16([
|
|
2841
|
+
(0, import_common16.Injectable)(),
|
|
2842
|
+
_ts_param15(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_TOOL_REGISTRY)),
|
|
2843
|
+
_ts_param15(2, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_REGISTRY)),
|
|
2844
|
+
_ts_param15(3, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_OPTIONS)),
|
|
2845
|
+
_ts_metadata16("design:type", Function),
|
|
2846
|
+
_ts_metadata16("design:paramtypes", [
|
|
2555
2847
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
2556
2848
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
2557
2849
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -2560,13 +2852,13 @@ AiToolDiscoveryService = _ts_decorate14([
|
|
|
2560
2852
|
], AiToolDiscoveryService);
|
|
2561
2853
|
|
|
2562
2854
|
// src/discovery/skill-discovery.service.ts
|
|
2563
|
-
var
|
|
2564
|
-
var
|
|
2855
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
2856
|
+
var import_common17 = require("@nestjs/common");
|
|
2565
2857
|
var import_core3 = require("@nestjs/core");
|
|
2566
2858
|
|
|
2567
2859
|
// src/decorator/skill.decorator.ts
|
|
2568
2860
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
2569
|
-
var
|
|
2861
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
2570
2862
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
2571
2863
|
function Skill(options) {
|
|
2572
2864
|
return (target) => {
|
|
@@ -2579,12 +2871,12 @@ function readSkillMetadata(target) {
|
|
|
2579
2871
|
}
|
|
2580
2872
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
2581
2873
|
function skillScope(options) {
|
|
2582
|
-
return options.scope ??
|
|
2874
|
+
return options.scope ?? import_nestjs_agent_core17.GLOBAL_SCOPE;
|
|
2583
2875
|
}
|
|
2584
2876
|
__name(skillScope, "skillScope");
|
|
2585
2877
|
|
|
2586
2878
|
// src/discovery/skill-discovery.service.ts
|
|
2587
|
-
function
|
|
2879
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2588
2880
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2589
2881
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2590
2882
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2597,26 +2889,26 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2597
2889
|
}
|
|
2598
2890
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2599
2891
|
}
|
|
2600
|
-
__name(
|
|
2601
|
-
function
|
|
2892
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2893
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2602
2894
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2603
2895
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2604
2896
|
}
|
|
2605
2897
|
}
|
|
2606
|
-
__name(
|
|
2607
|
-
function
|
|
2898
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
2899
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2608
2900
|
return function(target, key) {
|
|
2609
2901
|
decorator(target, key, paramIndex);
|
|
2610
2902
|
};
|
|
2611
2903
|
}
|
|
2612
|
-
__name(
|
|
2904
|
+
__name(_ts_param16, "_ts_param");
|
|
2613
2905
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
2614
2906
|
static {
|
|
2615
2907
|
__name(this, "SkillDiscoveryService");
|
|
2616
2908
|
}
|
|
2617
2909
|
discovery;
|
|
2618
2910
|
declared;
|
|
2619
|
-
logger = new
|
|
2911
|
+
logger = new import_common17.Logger(_SkillDiscoveryService.name);
|
|
2620
2912
|
constructor(discovery, declared) {
|
|
2621
2913
|
this.discovery = discovery;
|
|
2622
2914
|
this.declared = declared;
|
|
@@ -2653,18 +2945,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
2653
2945
|
return flat === void 0 ? void 0 : () => flat;
|
|
2654
2946
|
}
|
|
2655
2947
|
};
|
|
2656
|
-
SkillDiscoveryService =
|
|
2657
|
-
(0,
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2948
|
+
SkillDiscoveryService = _ts_decorate17([
|
|
2949
|
+
(0, import_common17.Injectable)(),
|
|
2950
|
+
_ts_param16(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_SKILL_SOURCES)),
|
|
2951
|
+
_ts_metadata17("design:type", Function),
|
|
2952
|
+
_ts_metadata17("design:paramtypes", [
|
|
2661
2953
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
2662
2954
|
Array
|
|
2663
2955
|
])
|
|
2664
2956
|
], SkillDiscoveryService);
|
|
2665
2957
|
|
|
2666
2958
|
// src/in-process-sink.ts
|
|
2667
|
-
var
|
|
2959
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
2668
2960
|
var InProcessTokenStreamSink = class {
|
|
2669
2961
|
static {
|
|
2670
2962
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -2719,7 +3011,7 @@ var InProcessTokenStreamSink = class {
|
|
|
2719
3011
|
}
|
|
2720
3012
|
if (buf.ended) {
|
|
2721
3013
|
if (buf.failure !== void 0) {
|
|
2722
|
-
throw new
|
|
3014
|
+
throw new import_nestjs_agent_core19.AgentStreamError(buf.failure);
|
|
2723
3015
|
}
|
|
2724
3016
|
return;
|
|
2725
3017
|
}
|
|
@@ -2755,9 +3047,9 @@ var LedgerQuotaStore = class {
|
|
|
2755
3047
|
};
|
|
2756
3048
|
|
|
2757
3049
|
// src/runner/inline-agent-runner.ts
|
|
2758
|
-
var
|
|
2759
|
-
var
|
|
2760
|
-
function
|
|
3050
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3051
|
+
var import_common18 = require("@nestjs/common");
|
|
3052
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2761
3053
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2762
3054
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2763
3055
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2770,26 +3062,26 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2770
3062
|
}
|
|
2771
3063
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2772
3064
|
}
|
|
2773
|
-
__name(
|
|
2774
|
-
function
|
|
3065
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3066
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2775
3067
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2776
3068
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2777
3069
|
}
|
|
2778
3070
|
}
|
|
2779
|
-
__name(
|
|
2780
|
-
function
|
|
3071
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3072
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2781
3073
|
return function(target, key) {
|
|
2782
3074
|
decorator(target, key, paramIndex);
|
|
2783
3075
|
};
|
|
2784
3076
|
}
|
|
2785
|
-
__name(
|
|
3077
|
+
__name(_ts_param17, "_ts_param");
|
|
2786
3078
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
2787
3079
|
static {
|
|
2788
3080
|
__name(this, "InlineAgentRunner");
|
|
2789
3081
|
}
|
|
2790
3082
|
factory;
|
|
2791
3083
|
store;
|
|
2792
|
-
logger = new
|
|
3084
|
+
logger = new import_common18.Logger(_InlineAgentRunner.name);
|
|
2793
3085
|
pending = /* @__PURE__ */ new Map();
|
|
2794
3086
|
/**
|
|
2795
3087
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -2818,18 +3110,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2818
3110
|
] : []
|
|
2819
3111
|
]
|
|
2820
3112
|
});
|
|
2821
|
-
void (0,
|
|
3113
|
+
void (0, import_nestjs_agent_core20.runAgentLoop)({
|
|
2822
3114
|
...deps,
|
|
2823
3115
|
day
|
|
2824
3116
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
2825
|
-
if (error instanceof
|
|
3117
|
+
if (error instanceof import_nestjs_agent_core20.RunCancelledError) {
|
|
2826
3118
|
await this.settleCancelled(runId, input.threadId, deps);
|
|
2827
3119
|
return;
|
|
2828
3120
|
}
|
|
2829
3121
|
const message = error instanceof Error ? error.message : String(error);
|
|
2830
|
-
const code = (0,
|
|
3122
|
+
const code = (0, import_nestjs_agent_core20.agentFailureCode)(error);
|
|
2831
3123
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
2832
|
-
(0,
|
|
3124
|
+
(0, import_nestjs_agent_core20.publishAgentRunFailed)({
|
|
2833
3125
|
runId,
|
|
2834
3126
|
code,
|
|
2835
3127
|
message
|
|
@@ -2878,7 +3170,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2878
3170
|
for (const [key, waiter] of this.pending) {
|
|
2879
3171
|
if (key.startsWith(`${runId}:`)) {
|
|
2880
3172
|
this.pending.delete(key);
|
|
2881
|
-
waiter.reject(new
|
|
3173
|
+
waiter.reject(new import_nestjs_agent_core20.RunCancelledError());
|
|
2882
3174
|
}
|
|
2883
3175
|
}
|
|
2884
3176
|
await Promise.resolve();
|
|
@@ -2893,7 +3185,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2893
3185
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
2894
3186
|
await this.store.setActiveStream(threadId, null);
|
|
2895
3187
|
const writer = await deps.sink.open(runId);
|
|
2896
|
-
await writer.write((0,
|
|
3188
|
+
await writer.write((0, import_nestjs_agent_core20.encodeStreamEvent)({
|
|
2897
3189
|
kind: "cancelled"
|
|
2898
3190
|
}));
|
|
2899
3191
|
await writer.end();
|
|
@@ -2954,7 +3246,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2954
3246
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
2955
3247
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
2956
3248
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
2957
|
-
parallel:
|
|
3249
|
+
parallel: import_nestjs_agent_core20.settleAll,
|
|
2958
3250
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
2959
3251
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
2960
3252
|
agentName,
|
|
@@ -3005,7 +3297,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3005
3297
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3006
3298
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3007
3299
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3008
|
-
parallel:
|
|
3300
|
+
parallel: import_nestjs_agent_core20.settleAll,
|
|
3009
3301
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3010
3302
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
3011
3303
|
agentName: childName,
|
|
@@ -3038,7 +3330,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3038
3330
|
}
|
|
3039
3331
|
}), "startAgent")
|
|
3040
3332
|
};
|
|
3041
|
-
void (0,
|
|
3333
|
+
void (0, import_nestjs_agent_core20.runAgentLoop)({
|
|
3042
3334
|
...deps,
|
|
3043
3335
|
day
|
|
3044
3336
|
}, {
|
|
@@ -3052,13 +3344,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3052
3344
|
parentRunId,
|
|
3053
3345
|
deliverTo
|
|
3054
3346
|
}, hooks).catch(async (error) => {
|
|
3055
|
-
const cancelled = error instanceof
|
|
3347
|
+
const cancelled = error instanceof import_nestjs_agent_core20.RunCancelledError;
|
|
3056
3348
|
const message = error instanceof Error ? error.message : String(error);
|
|
3057
3349
|
if (!cancelled) {
|
|
3058
3350
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
3059
|
-
(0,
|
|
3351
|
+
(0, import_nestjs_agent_core20.publishAgentRunFailed)({
|
|
3060
3352
|
runId,
|
|
3061
|
-
code: (0,
|
|
3353
|
+
code: (0, import_nestjs_agent_core20.agentFailureCode)(error),
|
|
3062
3354
|
message
|
|
3063
3355
|
});
|
|
3064
3356
|
}
|
|
@@ -3066,11 +3358,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3066
3358
|
runId,
|
|
3067
3359
|
status: cancelled ? "cancelled" : "failed",
|
|
3068
3360
|
...cancelled ? {} : {
|
|
3069
|
-
errorCode: (0,
|
|
3361
|
+
errorCode: (0, import_nestjs_agent_core20.agentFailureCode)(error),
|
|
3070
3362
|
errorMessage: message
|
|
3071
3363
|
}
|
|
3072
3364
|
});
|
|
3073
|
-
await (0,
|
|
3365
|
+
await (0, import_nestjs_agent_core20.settleUnsettledDelegation)({
|
|
3074
3366
|
store: this.store,
|
|
3075
3367
|
delivery: deliverTo,
|
|
3076
3368
|
agent: agentName,
|
|
@@ -3109,7 +3401,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3109
3401
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3110
3402
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3111
3403
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3112
|
-
parallel:
|
|
3404
|
+
parallel: import_nestjs_agent_core20.settleAll,
|
|
3113
3405
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
3114
3406
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
3115
3407
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -3144,7 +3436,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3144
3436
|
}), "startAgent")
|
|
3145
3437
|
};
|
|
3146
3438
|
try {
|
|
3147
|
-
return await (0,
|
|
3439
|
+
return await (0, import_nestjs_agent_core20.runAgentLoop)({
|
|
3148
3440
|
...deps,
|
|
3149
3441
|
day
|
|
3150
3442
|
}, {
|
|
@@ -3163,19 +3455,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3163
3455
|
}
|
|
3164
3456
|
}
|
|
3165
3457
|
};
|
|
3166
|
-
InlineAgentRunner =
|
|
3167
|
-
(0,
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3458
|
+
InlineAgentRunner = _ts_decorate18([
|
|
3459
|
+
(0, import_common18.Injectable)(),
|
|
3460
|
+
_ts_param17(0, (0, import_common18.Inject)(import_nestjs_agent_core20.AGENT_DEPS_FACTORY)),
|
|
3461
|
+
_ts_param17(1, (0, import_common18.Inject)(import_nestjs_agent_core20.AGENT_STORE)),
|
|
3462
|
+
_ts_metadata18("design:type", Function),
|
|
3463
|
+
_ts_metadata18("design:paramtypes", [
|
|
3172
3464
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3173
3465
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3174
3466
|
])
|
|
3175
3467
|
], InlineAgentRunner);
|
|
3176
3468
|
|
|
3177
3469
|
// src/skills-config.ts
|
|
3178
|
-
var
|
|
3470
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
3179
3471
|
function declaredSkillProvider(declared) {
|
|
3180
3472
|
return {
|
|
3181
3473
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -3201,7 +3493,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3201
3493
|
declaredSkillProvider(declared)
|
|
3202
3494
|
];
|
|
3203
3495
|
return {
|
|
3204
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
3496
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core21.compositeSkillProvider)(providers),
|
|
3205
3497
|
...options.scopes !== void 0 ? {
|
|
3206
3498
|
scopes: options.scopes
|
|
3207
3499
|
} : {},
|
|
@@ -3213,7 +3505,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3213
3505
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3214
3506
|
|
|
3215
3507
|
// src/agent.module.ts
|
|
3216
|
-
function
|
|
3508
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3217
3509
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3218
3510
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3219
3511
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3226,92 +3518,99 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
3226
3518
|
}
|
|
3227
3519
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3228
3520
|
}
|
|
3229
|
-
__name(
|
|
3521
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3230
3522
|
var DEFAULT_PATH = "agent";
|
|
3231
3523
|
function sharedProviders(durable, includeStore) {
|
|
3232
3524
|
const providers = [
|
|
3233
3525
|
{
|
|
3234
|
-
provide:
|
|
3235
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3526
|
+
provide: import_nestjs_agent_core22.AGENT_TOOL_REGISTRY,
|
|
3527
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core22.ToolRegistry(), "useFactory")
|
|
3236
3528
|
},
|
|
3237
3529
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
3238
3530
|
{
|
|
3239
|
-
provide:
|
|
3240
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3531
|
+
provide: import_nestjs_agent_core22.AGENT_REGISTRY,
|
|
3532
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core22.AgentRegistry(), "useFactory")
|
|
3241
3533
|
},
|
|
3242
3534
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
3243
3535
|
{
|
|
3244
|
-
provide:
|
|
3536
|
+
provide: import_nestjs_agent_core22.AGENT_PROMPT_CONTRIBUTORS,
|
|
3245
3537
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3246
3538
|
},
|
|
3247
3539
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
3248
3540
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
3249
3541
|
{
|
|
3250
|
-
provide:
|
|
3542
|
+
provide: import_nestjs_agent_core22.AGENT_SKILL_SOURCES,
|
|
3251
3543
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3252
3544
|
},
|
|
3253
3545
|
{
|
|
3254
3546
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
3255
3547
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
3256
3548
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
3257
|
-
provide:
|
|
3549
|
+
provide: import_nestjs_agent_core22.AGENT_SKILLS,
|
|
3258
3550
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3259
3551
|
inject: [
|
|
3260
|
-
|
|
3261
|
-
|
|
3552
|
+
import_nestjs_agent_core22.AGENT_OPTIONS,
|
|
3553
|
+
import_nestjs_agent_core22.AGENT_SKILL_SOURCES
|
|
3262
3554
|
]
|
|
3263
3555
|
},
|
|
3264
3556
|
{
|
|
3265
3557
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
3266
3558
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
3267
|
-
provide:
|
|
3559
|
+
provide: import_nestjs_agent_core22.AGENT_MEMORY,
|
|
3268
3560
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3269
3561
|
inject: [
|
|
3270
|
-
|
|
3562
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3271
3563
|
]
|
|
3272
3564
|
},
|
|
3273
3565
|
{
|
|
3274
|
-
provide:
|
|
3566
|
+
provide: import_nestjs_agent_core22.AGENT_SINK,
|
|
3275
3567
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3276
3568
|
inject: [
|
|
3277
|
-
|
|
3569
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3278
3570
|
]
|
|
3279
3571
|
},
|
|
3280
3572
|
{
|
|
3281
|
-
provide:
|
|
3282
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
3573
|
+
provide: import_nestjs_agent_core22.AGENT_ROLES_POLICY,
|
|
3574
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core22.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3283
3575
|
inject: [
|
|
3284
|
-
|
|
3576
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3285
3577
|
]
|
|
3286
3578
|
},
|
|
3287
3579
|
{
|
|
3288
|
-
provide:
|
|
3580
|
+
provide: import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER,
|
|
3289
3581
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
3290
3582
|
inject: [
|
|
3291
|
-
|
|
3583
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3292
3584
|
]
|
|
3293
3585
|
},
|
|
3294
3586
|
{
|
|
3295
|
-
provide:
|
|
3587
|
+
provide: import_nestjs_agent_core22.AGENT_MODEL,
|
|
3296
3588
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3297
3589
|
inject: [
|
|
3298
|
-
|
|
3590
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3299
3591
|
]
|
|
3300
3592
|
},
|
|
3301
3593
|
{
|
|
3302
3594
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
3303
3595
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
3304
3596
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
3305
|
-
provide:
|
|
3597
|
+
provide: import_nestjs_agent_core22.AGENT_QUOTA_STORE,
|
|
3306
3598
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3307
3599
|
inject: [
|
|
3308
|
-
|
|
3309
|
-
|
|
3600
|
+
import_nestjs_agent_core22.AGENT_OPTIONS,
|
|
3601
|
+
import_nestjs_agent_core22.AGENT_STORE
|
|
3602
|
+
]
|
|
3603
|
+
},
|
|
3604
|
+
{
|
|
3605
|
+
provide: import_nestjs_agent_core22.AGENT_MODEL_CATALOG,
|
|
3606
|
+
useFactory: /* @__PURE__ */ __name((o) => o.models, "useFactory"),
|
|
3607
|
+
inject: [
|
|
3608
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3310
3609
|
]
|
|
3311
3610
|
},
|
|
3312
3611
|
AgentDepsFactory2,
|
|
3313
3612
|
{
|
|
3314
|
-
provide:
|
|
3613
|
+
provide: import_nestjs_agent_core22.AGENT_DEPS_FACTORY,
|
|
3315
3614
|
useExisting: AgentDepsFactory2
|
|
3316
3615
|
},
|
|
3317
3616
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -3325,22 +3624,22 @@ function sharedProviders(durable, includeStore) {
|
|
|
3325
3624
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
3326
3625
|
AgentApprovalPortAdapter,
|
|
3327
3626
|
{
|
|
3328
|
-
provide:
|
|
3627
|
+
provide: import_nestjs_agent_core22.AGENT_APPROVAL_PORT,
|
|
3329
3628
|
useExisting: AgentApprovalPortAdapter
|
|
3330
3629
|
}
|
|
3331
3630
|
];
|
|
3332
3631
|
if (includeStore) {
|
|
3333
3632
|
providers.push({
|
|
3334
|
-
provide:
|
|
3633
|
+
provide: import_nestjs_agent_core22.AGENT_STORE,
|
|
3335
3634
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
3336
3635
|
inject: [
|
|
3337
|
-
|
|
3636
|
+
import_nestjs_agent_core22.AGENT_OPTIONS
|
|
3338
3637
|
]
|
|
3339
3638
|
});
|
|
3340
3639
|
}
|
|
3341
3640
|
if (durable) {
|
|
3342
3641
|
providers.push({
|
|
3343
|
-
provide:
|
|
3642
|
+
provide: import_nestjs_agent_core22.AGENT_RUNNER,
|
|
3344
3643
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
3345
3644
|
if (durableRunner === void 0) {
|
|
3346
3645
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -3349,14 +3648,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
3349
3648
|
}, "useFactory"),
|
|
3350
3649
|
inject: [
|
|
3351
3650
|
{
|
|
3352
|
-
token:
|
|
3651
|
+
token: import_nestjs_agent_core22.AGENT_DURABLE_RUNNER,
|
|
3353
3652
|
optional: true
|
|
3354
3653
|
}
|
|
3355
3654
|
]
|
|
3356
3655
|
});
|
|
3357
3656
|
} else {
|
|
3358
3657
|
providers.push({
|
|
3359
|
-
provide:
|
|
3658
|
+
provide: import_nestjs_agent_core22.AGENT_RUNNER,
|
|
3360
3659
|
useExisting: InlineAgentRunner
|
|
3361
3660
|
});
|
|
3362
3661
|
}
|
|
@@ -3365,25 +3664,26 @@ function sharedProviders(durable, includeStore) {
|
|
|
3365
3664
|
__name(sharedProviders, "sharedProviders");
|
|
3366
3665
|
function exportsFor(includeStore) {
|
|
3367
3666
|
return [
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3667
|
+
import_nestjs_agent_core22.AGENT_OPTIONS,
|
|
3668
|
+
import_nestjs_agent_core22.AGENT_TOOL_REGISTRY,
|
|
3669
|
+
import_nestjs_agent_core22.AGENT_REGISTRY,
|
|
3670
|
+
import_nestjs_agent_core22.AGENT_SINK,
|
|
3671
|
+
import_nestjs_agent_core22.AGENT_ROLES_POLICY,
|
|
3672
|
+
import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER,
|
|
3673
|
+
import_nestjs_agent_core22.AGENT_MODEL,
|
|
3375
3674
|
...includeStore ? [
|
|
3376
|
-
|
|
3675
|
+
import_nestjs_agent_core22.AGENT_STORE
|
|
3377
3676
|
] : [],
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3677
|
+
import_nestjs_agent_core22.AGENT_QUOTA_STORE,
|
|
3678
|
+
import_nestjs_agent_core22.AGENT_MODEL_CATALOG,
|
|
3679
|
+
import_nestjs_agent_core22.AGENT_PROMPT_CONTRIBUTORS,
|
|
3680
|
+
import_nestjs_agent_core22.AGENT_SKILLS,
|
|
3681
|
+
import_nestjs_agent_core22.AGENT_MEMORY,
|
|
3682
|
+
import_nestjs_agent_core22.AGENT_DEPS_FACTORY,
|
|
3383
3683
|
AgentDepsFactory2,
|
|
3384
3684
|
AgentService,
|
|
3385
3685
|
InlineAgentRunner,
|
|
3386
|
-
|
|
3686
|
+
import_nestjs_agent_core22.AGENT_APPROVAL_PORT
|
|
3387
3687
|
];
|
|
3388
3688
|
}
|
|
3389
3689
|
__name(exportsFor, "exportsFor");
|
|
@@ -3395,7 +3695,9 @@ var BASE_CONTROLLERS = [
|
|
|
3395
3695
|
AgentsController,
|
|
3396
3696
|
SkillsController,
|
|
3397
3697
|
MemoriesController,
|
|
3398
|
-
ToolsController
|
|
3698
|
+
ToolsController,
|
|
3699
|
+
MessagesController,
|
|
3700
|
+
ModelsController
|
|
3399
3701
|
];
|
|
3400
3702
|
var GUARDABLE_CONTROLLERS = [
|
|
3401
3703
|
...BASE_CONTROLLERS,
|
|
@@ -3453,7 +3755,7 @@ var AgentModule = class _AgentModule {
|
|
|
3453
3755
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
3454
3756
|
providers: [
|
|
3455
3757
|
{
|
|
3456
|
-
provide:
|
|
3758
|
+
provide: import_nestjs_agent_core22.AGENT_OPTIONS,
|
|
3457
3759
|
useValue: options
|
|
3458
3760
|
},
|
|
3459
3761
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -3477,7 +3779,7 @@ var AgentModule = class _AgentModule {
|
|
|
3477
3779
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
3478
3780
|
providers: [
|
|
3479
3781
|
{
|
|
3480
|
-
provide:
|
|
3782
|
+
provide: import_nestjs_agent_core22.AGENT_OPTIONS,
|
|
3481
3783
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
3482
3784
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
3483
3785
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -3498,13 +3800,13 @@ var AgentModule = class _AgentModule {
|
|
|
3498
3800
|
};
|
|
3499
3801
|
}
|
|
3500
3802
|
};
|
|
3501
|
-
AgentModule =
|
|
3502
|
-
(0,
|
|
3503
|
-
(0,
|
|
3803
|
+
AgentModule = _ts_decorate19([
|
|
3804
|
+
(0, import_common19.Global)(),
|
|
3805
|
+
(0, import_common19.Module)({})
|
|
3504
3806
|
], AgentModule);
|
|
3505
3807
|
|
|
3506
3808
|
// src/resolver/header-actor-resolver.ts
|
|
3507
|
-
var
|
|
3809
|
+
var import_common20 = require("@nestjs/common");
|
|
3508
3810
|
function readHeader(req, name) {
|
|
3509
3811
|
if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
|
|
3510
3812
|
const { headers } = req;
|
|
@@ -3520,7 +3822,7 @@ var HeaderActorResolver = class {
|
|
|
3520
3822
|
resolve(req) {
|
|
3521
3823
|
const id = readHeader(req, "x-actor-id");
|
|
3522
3824
|
if (id === void 0 || id.length === 0) {
|
|
3523
|
-
throw new
|
|
3825
|
+
throw new import_common20.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
|
|
3524
3826
|
}
|
|
3525
3827
|
const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
|
|
3526
3828
|
const tenantRef = readHeader(req, "x-tenant-ref");
|
|
@@ -3558,6 +3860,8 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
3558
3860
|
InlineAgentRunner,
|
|
3559
3861
|
LedgerQuotaStore,
|
|
3560
3862
|
MemoriesController,
|
|
3863
|
+
MessagesController,
|
|
3864
|
+
ModelsController,
|
|
3561
3865
|
SKILL_METADATA,
|
|
3562
3866
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
3563
3867
|
SYSTEM_PROMPT_METADATA,
|