@dudousxd/nestjs-agent 1.5.0 → 1.6.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 +14 -0
- package/dist/durable/index.cjs +459 -313
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +363 -217
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +465 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.js +364 -217
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.cjs
CHANGED
|
@@ -818,8 +818,8 @@ AgentDurableModule = _ts_decorate4([
|
|
|
818
818
|
], AgentDurableModule);
|
|
819
819
|
|
|
820
820
|
// src/agent.module.ts
|
|
821
|
-
var
|
|
822
|
-
var
|
|
821
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
822
|
+
var import_common22 = require("@nestjs/common");
|
|
823
823
|
var import_core4 = require("@nestjs/core");
|
|
824
824
|
|
|
825
825
|
// src/agent-deps.factory.ts
|
|
@@ -1421,6 +1421,40 @@ var AgentService = class {
|
|
|
1421
1421
|
return this.store.truncateFrom(threadId, messageId);
|
|
1422
1422
|
}
|
|
1423
1423
|
/**
|
|
1424
|
+
* Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
|
|
1425
|
+
* to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
|
|
1426
|
+
* on a store without `threadOfMessage` + `setMessageFeedback`.
|
|
1427
|
+
*/
|
|
1428
|
+
async setMessageFeedback(actor, messageId, input) {
|
|
1429
|
+
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
1430
|
+
throw new import_common6.BadRequestException("value must be 'up', 'down' or null");
|
|
1431
|
+
}
|
|
1432
|
+
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
1433
|
+
throw new import_common6.BadRequestException("comment must be a string");
|
|
1434
|
+
}
|
|
1435
|
+
const comment = input.comment?.trim();
|
|
1436
|
+
if (comment !== void 0 && comment.length > 2e3) {
|
|
1437
|
+
throw new import_common6.BadRequestException("comment must be at most 2000 characters");
|
|
1438
|
+
}
|
|
1439
|
+
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
1440
|
+
throw new import_common6.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
1441
|
+
}
|
|
1442
|
+
const threadId = await this.store.threadOfMessage(messageId);
|
|
1443
|
+
if (threadId === null) {
|
|
1444
|
+
throw new import_common6.NotFoundException(`message ${messageId} not found`);
|
|
1445
|
+
}
|
|
1446
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1447
|
+
const feedback = input.value === null ? null : {
|
|
1448
|
+
value: input.value,
|
|
1449
|
+
...comment !== void 0 && comment.length > 0 ? {
|
|
1450
|
+
comment
|
|
1451
|
+
} : {},
|
|
1452
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1453
|
+
};
|
|
1454
|
+
await this.store.setMessageFeedback(messageId, feedback);
|
|
1455
|
+
return feedback;
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1424
1458
|
* Every file this actor has staged, newest first — across threads, including uploads that were
|
|
1425
1459
|
* never sent, which nothing else on this surface can see.
|
|
1426
1460
|
*
|
|
@@ -2009,9 +2043,15 @@ var ChatController = class {
|
|
|
2009
2043
|
});
|
|
2010
2044
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
2011
2045
|
}
|
|
2012
|
-
|
|
2046
|
+
/**
|
|
2047
|
+
* Attach to a run's stream: every buffered frame, then live ones. `?after=<seq>` (or the SSE
|
|
2048
|
+
* `Last-Event-ID` header a browser `EventSource` sends on its own) skips the frames a reconnecting
|
|
2049
|
+
* client already has — see {@link pipe} for how frames are numbered.
|
|
2050
|
+
*/
|
|
2051
|
+
async stream(req, runId, res, after) {
|
|
2013
2052
|
const actor = await this.actorResolver.resolve(req);
|
|
2014
|
-
|
|
2053
|
+
const cursor = parseCursor(after) ?? parseCursor(req.headers["last-event-id"]) ?? 0;
|
|
2054
|
+
await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId), void 0, cursor);
|
|
2015
2055
|
}
|
|
2016
2056
|
async cancel(req, runId) {
|
|
2017
2057
|
const actor = await this.actorResolver.resolve(req);
|
|
@@ -2020,7 +2060,15 @@ var ChatController = class {
|
|
|
2020
2060
|
aborted: true
|
|
2021
2061
|
};
|
|
2022
2062
|
}
|
|
2023
|
-
|
|
2063
|
+
/**
|
|
2064
|
+
* Every `data:` frame carries an SSE `id:` — its 1-based sequence number within the run. The
|
|
2065
|
+
* number is a pure function of the run's buffered stream (every sink replays a run from its first
|
|
2066
|
+
* chunk, in write order), so the same frame gets the same number on the POST that started the run
|
|
2067
|
+
* and on any later `GET …/stream`, whichever replica serves it. A reconnecting client passes the
|
|
2068
|
+
* last one it saw as `?after=`; frames at or below it are read off the sink but not re-sent.
|
|
2069
|
+
* `meta`, `done` and `error` carry no id: `meta` is re-sent on every attach, the terminals once.
|
|
2070
|
+
*/
|
|
2071
|
+
async pipe(res, runId, events, threadId, after = 0) {
|
|
2024
2072
|
res.setHeader("Content-Type", "text/event-stream");
|
|
2025
2073
|
res.setHeader("Cache-Control", "no-cache");
|
|
2026
2074
|
res.setHeader("Connection", "keep-alive");
|
|
@@ -2037,6 +2085,16 @@ data: ${JSON.stringify({
|
|
|
2037
2085
|
`);
|
|
2038
2086
|
const decoder = new TextDecoder();
|
|
2039
2087
|
let buffer = "";
|
|
2088
|
+
let seq = 0;
|
|
2089
|
+
const forward = /* @__PURE__ */ __name((line) => {
|
|
2090
|
+
seq += 1;
|
|
2091
|
+
if (seq > after) {
|
|
2092
|
+
res.write(`id: ${seq}
|
|
2093
|
+
data: ${line}
|
|
2094
|
+
|
|
2095
|
+
`);
|
|
2096
|
+
}
|
|
2097
|
+
}, "forward");
|
|
2040
2098
|
try {
|
|
2041
2099
|
for await (const chunk of events) {
|
|
2042
2100
|
buffer += decoder.decode(chunk, {
|
|
@@ -2047,17 +2105,13 @@ data: ${JSON.stringify({
|
|
|
2047
2105
|
const line = buffer.slice(0, newline);
|
|
2048
2106
|
buffer = buffer.slice(newline + 1);
|
|
2049
2107
|
if (line.length > 0) {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
`);
|
|
2108
|
+
forward(line);
|
|
2053
2109
|
}
|
|
2054
2110
|
newline = buffer.indexOf("\n");
|
|
2055
2111
|
}
|
|
2056
2112
|
}
|
|
2057
2113
|
if (buffer.length > 0) {
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
`);
|
|
2114
|
+
forward(buffer);
|
|
2061
2115
|
}
|
|
2062
2116
|
res.write("event: done\ndata: {}\n\n");
|
|
2063
2117
|
} catch (error) {
|
|
@@ -2094,11 +2148,13 @@ _ts_decorate10([
|
|
|
2094
2148
|
_ts_param8(0, (0, import_common10.Req)()),
|
|
2095
2149
|
_ts_param8(1, (0, import_common10.Param)("runId")),
|
|
2096
2150
|
_ts_param8(2, (0, import_common10.Res)()),
|
|
2151
|
+
_ts_param8(3, (0, import_common10.Query)("after")),
|
|
2097
2152
|
_ts_metadata9("design:type", Function),
|
|
2098
2153
|
_ts_metadata9("design:paramtypes", [
|
|
2099
2154
|
typeof Request === "undefined" ? Object : Request,
|
|
2100
2155
|
String,
|
|
2101
|
-
typeof Response === "undefined" ? Object : Response
|
|
2156
|
+
typeof Response === "undefined" ? Object : Response,
|
|
2157
|
+
String
|
|
2102
2158
|
]),
|
|
2103
2159
|
_ts_metadata9("design:returntype", Promise)
|
|
2104
2160
|
], ChatController.prototype, "stream", null);
|
|
@@ -2122,6 +2178,15 @@ ChatController = _ts_decorate10([
|
|
|
2122
2178
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2123
2179
|
])
|
|
2124
2180
|
], ChatController);
|
|
2181
|
+
function parseCursor(raw) {
|
|
2182
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
2183
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
|
|
2184
|
+
return void 0;
|
|
2185
|
+
}
|
|
2186
|
+
const parsed = Number(value.trim());
|
|
2187
|
+
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
2188
|
+
}
|
|
2189
|
+
__name(parseCursor, "parseCursor");
|
|
2125
2190
|
|
|
2126
2191
|
// src/controller/memories.controller.ts
|
|
2127
2192
|
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
@@ -2258,7 +2323,7 @@ MemoriesController = _ts_decorate11([
|
|
|
2258
2323
|
])
|
|
2259
2324
|
], MemoriesController);
|
|
2260
2325
|
|
|
2261
|
-
// src/controller/
|
|
2326
|
+
// src/controller/messages.controller.ts
|
|
2262
2327
|
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2263
2328
|
var import_common12 = require("@nestjs/common");
|
|
2264
2329
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
@@ -2287,9 +2352,9 @@ function _ts_param10(paramIndex, decorator) {
|
|
|
2287
2352
|
};
|
|
2288
2353
|
}
|
|
2289
2354
|
__name(_ts_param10, "_ts_param");
|
|
2290
|
-
var
|
|
2355
|
+
var MessagesController = class {
|
|
2291
2356
|
static {
|
|
2292
|
-
__name(this, "
|
|
2357
|
+
__name(this, "MessagesController");
|
|
2293
2358
|
}
|
|
2294
2359
|
agent;
|
|
2295
2360
|
actorResolver;
|
|
@@ -2297,31 +2362,48 @@ var QuotaController = class {
|
|
|
2297
2362
|
this.agent = agent;
|
|
2298
2363
|
this.actorResolver = actorResolver;
|
|
2299
2364
|
}
|
|
2300
|
-
|
|
2365
|
+
/**
|
|
2366
|
+
* Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
|
|
2367
|
+
* (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
|
|
2368
|
+
*/
|
|
2369
|
+
async feedback(req, id, body) {
|
|
2301
2370
|
const actor = await this.actorResolver.resolve(req);
|
|
2302
|
-
|
|
2371
|
+
const feedback = await this.agent.setMessageFeedback(actor, id, {
|
|
2372
|
+
value: body?.value ?? null,
|
|
2373
|
+
...body?.comment !== void 0 ? {
|
|
2374
|
+
comment: body.comment
|
|
2375
|
+
} : {}
|
|
2376
|
+
});
|
|
2377
|
+
return {
|
|
2378
|
+
feedback
|
|
2379
|
+
};
|
|
2303
2380
|
}
|
|
2304
2381
|
};
|
|
2305
2382
|
_ts_decorate12([
|
|
2306
|
-
(0, import_common12.
|
|
2383
|
+
(0, import_common12.Post)(":id/feedback"),
|
|
2384
|
+
(0, import_common12.HttpCode)(200),
|
|
2307
2385
|
_ts_param10(0, (0, import_common12.Req)()),
|
|
2386
|
+
_ts_param10(1, (0, import_common12.Param)("id")),
|
|
2387
|
+
_ts_param10(2, (0, import_common12.Body)()),
|
|
2308
2388
|
_ts_metadata11("design:type", Function),
|
|
2309
2389
|
_ts_metadata11("design:paramtypes", [
|
|
2310
|
-
typeof Request === "undefined" ? Object : Request
|
|
2390
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2391
|
+
String,
|
|
2392
|
+
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
2311
2393
|
]),
|
|
2312
2394
|
_ts_metadata11("design:returntype", Promise)
|
|
2313
|
-
],
|
|
2314
|
-
|
|
2315
|
-
(0, import_common12.Controller)("
|
|
2395
|
+
], MessagesController.prototype, "feedback", null);
|
|
2396
|
+
MessagesController = _ts_decorate12([
|
|
2397
|
+
(0, import_common12.Controller)("messages"),
|
|
2316
2398
|
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
2317
2399
|
_ts_metadata11("design:type", Function),
|
|
2318
2400
|
_ts_metadata11("design:paramtypes", [
|
|
2319
2401
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2320
2402
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2321
2403
|
])
|
|
2322
|
-
],
|
|
2404
|
+
], MessagesController);
|
|
2323
2405
|
|
|
2324
|
-
// src/controller/
|
|
2406
|
+
// src/controller/quota.controller.ts
|
|
2325
2407
|
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
2326
2408
|
var import_common13 = require("@nestjs/common");
|
|
2327
2409
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
@@ -2350,6 +2432,69 @@ function _ts_param11(paramIndex, decorator) {
|
|
|
2350
2432
|
};
|
|
2351
2433
|
}
|
|
2352
2434
|
__name(_ts_param11, "_ts_param");
|
|
2435
|
+
var QuotaController = class {
|
|
2436
|
+
static {
|
|
2437
|
+
__name(this, "QuotaController");
|
|
2438
|
+
}
|
|
2439
|
+
agent;
|
|
2440
|
+
actorResolver;
|
|
2441
|
+
constructor(agent, actorResolver) {
|
|
2442
|
+
this.agent = agent;
|
|
2443
|
+
this.actorResolver = actorResolver;
|
|
2444
|
+
}
|
|
2445
|
+
async today(req) {
|
|
2446
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2447
|
+
return this.agent.quotaToday(actor.id);
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
_ts_decorate13([
|
|
2451
|
+
(0, import_common13.Get)("today"),
|
|
2452
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2453
|
+
_ts_metadata12("design:type", Function),
|
|
2454
|
+
_ts_metadata12("design:paramtypes", [
|
|
2455
|
+
typeof Request === "undefined" ? Object : Request
|
|
2456
|
+
]),
|
|
2457
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2458
|
+
], QuotaController.prototype, "today", null);
|
|
2459
|
+
QuotaController = _ts_decorate13([
|
|
2460
|
+
(0, import_common13.Controller)("quota"),
|
|
2461
|
+
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
2462
|
+
_ts_metadata12("design:type", Function),
|
|
2463
|
+
_ts_metadata12("design:paramtypes", [
|
|
2464
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2465
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2466
|
+
])
|
|
2467
|
+
], QuotaController);
|
|
2468
|
+
|
|
2469
|
+
// src/controller/skills.controller.ts
|
|
2470
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2471
|
+
var import_common14 = require("@nestjs/common");
|
|
2472
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2473
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2474
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2475
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2476
|
+
} else {
|
|
2477
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2478
|
+
if (d = decorators[i]) {
|
|
2479
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2484
|
+
}
|
|
2485
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2486
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
2487
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2488
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2492
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2493
|
+
return function(target, key) {
|
|
2494
|
+
decorator(target, key, paramIndex);
|
|
2495
|
+
};
|
|
2496
|
+
}
|
|
2497
|
+
__name(_ts_param12, "_ts_param");
|
|
2353
2498
|
var SkillsController = class {
|
|
2354
2499
|
static {
|
|
2355
2500
|
__name(this, "SkillsController");
|
|
@@ -2365,40 +2510,40 @@ var SkillsController = class {
|
|
|
2365
2510
|
return [];
|
|
2366
2511
|
}
|
|
2367
2512
|
const actor = await this.actorResolver.resolve(req);
|
|
2368
|
-
const offer = await (0,
|
|
2513
|
+
const offer = await (0, import_nestjs_agent_core15.offerSkills)(this.skills, {
|
|
2369
2514
|
actor,
|
|
2370
2515
|
threadId: threadId ?? ""
|
|
2371
2516
|
});
|
|
2372
2517
|
return offer.entries;
|
|
2373
2518
|
}
|
|
2374
2519
|
};
|
|
2375
|
-
|
|
2376
|
-
(0,
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2520
|
+
_ts_decorate14([
|
|
2521
|
+
(0, import_common14.Get)(),
|
|
2522
|
+
_ts_param12(0, (0, import_common14.Req)()),
|
|
2523
|
+
_ts_param12(1, (0, import_common14.Query)("threadId")),
|
|
2524
|
+
_ts_metadata13("design:type", Function),
|
|
2525
|
+
_ts_metadata13("design:paramtypes", [
|
|
2381
2526
|
typeof Request === "undefined" ? Object : Request,
|
|
2382
2527
|
String
|
|
2383
2528
|
]),
|
|
2384
|
-
|
|
2529
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2385
2530
|
], SkillsController.prototype, "list", null);
|
|
2386
|
-
SkillsController =
|
|
2387
|
-
(0,
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2531
|
+
SkillsController = _ts_decorate14([
|
|
2532
|
+
(0, import_common14.Controller)("skills"),
|
|
2533
|
+
_ts_param12(0, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
2534
|
+
_ts_param12(1, (0, import_common14.Optional)()),
|
|
2535
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_SKILLS)),
|
|
2536
|
+
_ts_metadata13("design:type", Function),
|
|
2537
|
+
_ts_metadata13("design:paramtypes", [
|
|
2393
2538
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2394
2539
|
Object
|
|
2395
2540
|
])
|
|
2396
2541
|
], SkillsController);
|
|
2397
2542
|
|
|
2398
2543
|
// src/controller/threads.controller.ts
|
|
2399
|
-
var
|
|
2400
|
-
var
|
|
2401
|
-
function
|
|
2544
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
2545
|
+
var import_common15 = require("@nestjs/common");
|
|
2546
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2402
2547
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2403
2548
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2404
2549
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2411,19 +2556,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2411
2556
|
}
|
|
2412
2557
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2413
2558
|
}
|
|
2414
|
-
__name(
|
|
2415
|
-
function
|
|
2559
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2560
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2416
2561
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2417
2562
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2418
2563
|
}
|
|
2419
2564
|
}
|
|
2420
|
-
__name(
|
|
2421
|
-
function
|
|
2565
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2566
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2422
2567
|
return function(target, key) {
|
|
2423
2568
|
decorator(target, key, paramIndex);
|
|
2424
2569
|
};
|
|
2425
2570
|
}
|
|
2426
|
-
__name(
|
|
2571
|
+
__name(_ts_param13, "_ts_param");
|
|
2427
2572
|
var ThreadsController = class {
|
|
2428
2573
|
static {
|
|
2429
2574
|
__name(this, "ThreadsController");
|
|
@@ -2487,101 +2632,101 @@ var ThreadsController = class {
|
|
|
2487
2632
|
};
|
|
2488
2633
|
}
|
|
2489
2634
|
};
|
|
2490
|
-
|
|
2491
|
-
(0,
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2635
|
+
_ts_decorate15([
|
|
2636
|
+
(0, import_common15.Get)(),
|
|
2637
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2638
|
+
_ts_metadata14("design:type", Function),
|
|
2639
|
+
_ts_metadata14("design:paramtypes", [
|
|
2495
2640
|
typeof Request === "undefined" ? Object : Request
|
|
2496
2641
|
]),
|
|
2497
|
-
|
|
2642
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2498
2643
|
], ThreadsController.prototype, "list", null);
|
|
2499
|
-
|
|
2500
|
-
(0,
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2644
|
+
_ts_decorate15([
|
|
2645
|
+
(0, import_common15.Get)(":id"),
|
|
2646
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2647
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
2648
|
+
_ts_metadata14("design:type", Function),
|
|
2649
|
+
_ts_metadata14("design:paramtypes", [
|
|
2505
2650
|
typeof Request === "undefined" ? Object : Request,
|
|
2506
2651
|
String
|
|
2507
2652
|
]),
|
|
2508
|
-
|
|
2653
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2509
2654
|
], ThreadsController.prototype, "detail", null);
|
|
2510
|
-
|
|
2511
|
-
(0,
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2655
|
+
_ts_decorate15([
|
|
2656
|
+
(0, import_common15.Delete)(":id"),
|
|
2657
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2658
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
2659
|
+
_ts_metadata14("design:type", Function),
|
|
2660
|
+
_ts_metadata14("design:paramtypes", [
|
|
2516
2661
|
typeof Request === "undefined" ? Object : Request,
|
|
2517
2662
|
String
|
|
2518
2663
|
]),
|
|
2519
|
-
|
|
2664
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2520
2665
|
], ThreadsController.prototype, "remove", null);
|
|
2521
|
-
|
|
2522
|
-
(0,
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2666
|
+
_ts_decorate15([
|
|
2667
|
+
(0, import_common15.Post)(":id/fork-from/:messageId"),
|
|
2668
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2669
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
2670
|
+
_ts_param13(2, (0, import_common15.Param)("messageId")),
|
|
2671
|
+
_ts_metadata14("design:type", Function),
|
|
2672
|
+
_ts_metadata14("design:paramtypes", [
|
|
2528
2673
|
typeof Request === "undefined" ? Object : Request,
|
|
2529
2674
|
String,
|
|
2530
2675
|
String
|
|
2531
2676
|
]),
|
|
2532
|
-
|
|
2677
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2533
2678
|
], ThreadsController.prototype, "fork", null);
|
|
2534
|
-
|
|
2535
|
-
(0,
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2679
|
+
_ts_decorate15([
|
|
2680
|
+
(0, import_common15.Patch)(":id"),
|
|
2681
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2682
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
2683
|
+
_ts_param13(2, (0, import_common15.Body)()),
|
|
2684
|
+
_ts_metadata14("design:type", Function),
|
|
2685
|
+
_ts_metadata14("design:paramtypes", [
|
|
2541
2686
|
typeof Request === "undefined" ? Object : Request,
|
|
2542
2687
|
String,
|
|
2543
2688
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2544
2689
|
]),
|
|
2545
|
-
|
|
2690
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2546
2691
|
], ThreadsController.prototype, "update", null);
|
|
2547
|
-
|
|
2548
|
-
(0,
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2692
|
+
_ts_decorate15([
|
|
2693
|
+
(0, import_common15.Post)(":id/promote"),
|
|
2694
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2695
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
2696
|
+
_ts_metadata14("design:type", Function),
|
|
2697
|
+
_ts_metadata14("design:paramtypes", [
|
|
2553
2698
|
typeof Request === "undefined" ? Object : Request,
|
|
2554
2699
|
String
|
|
2555
2700
|
]),
|
|
2556
|
-
|
|
2701
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2557
2702
|
], ThreadsController.prototype, "promote", null);
|
|
2558
|
-
|
|
2559
|
-
(0,
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2703
|
+
_ts_decorate15([
|
|
2704
|
+
(0, import_common15.Delete)(":id/from/:messageId"),
|
|
2705
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2706
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
2707
|
+
_ts_param13(2, (0, import_common15.Param)("messageId")),
|
|
2708
|
+
_ts_metadata14("design:type", Function),
|
|
2709
|
+
_ts_metadata14("design:paramtypes", [
|
|
2565
2710
|
typeof Request === "undefined" ? Object : Request,
|
|
2566
2711
|
String,
|
|
2567
2712
|
String
|
|
2568
2713
|
]),
|
|
2569
|
-
|
|
2714
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2570
2715
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2571
|
-
ThreadsController =
|
|
2572
|
-
(0,
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2716
|
+
ThreadsController = _ts_decorate15([
|
|
2717
|
+
(0, import_common15.Controller)("threads"),
|
|
2718
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
2719
|
+
_ts_metadata14("design:type", Function),
|
|
2720
|
+
_ts_metadata14("design:paramtypes", [
|
|
2576
2721
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2577
2722
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2578
2723
|
])
|
|
2579
2724
|
], ThreadsController);
|
|
2580
2725
|
|
|
2581
2726
|
// src/controller/tool-call.controller.ts
|
|
2582
|
-
var
|
|
2583
|
-
var
|
|
2584
|
-
function
|
|
2727
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
2728
|
+
var import_common16 = require("@nestjs/common");
|
|
2729
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2585
2730
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2586
2731
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2587
2732
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2594,19 +2739,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2594
2739
|
}
|
|
2595
2740
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2596
2741
|
}
|
|
2597
|
-
__name(
|
|
2598
|
-
function
|
|
2742
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2743
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2599
2744
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2600
2745
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2601
2746
|
}
|
|
2602
2747
|
}
|
|
2603
|
-
__name(
|
|
2604
|
-
function
|
|
2748
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2749
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2605
2750
|
return function(target, key) {
|
|
2606
2751
|
decorator(target, key, paramIndex);
|
|
2607
2752
|
};
|
|
2608
2753
|
}
|
|
2609
|
-
__name(
|
|
2754
|
+
__name(_ts_param14, "_ts_param");
|
|
2610
2755
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2611
2756
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2612
2757
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2615,7 +2760,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
2615
2760
|
var DEFAULT_VIA = "web";
|
|
2616
2761
|
function toolCallId(claimed) {
|
|
2617
2762
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
2618
|
-
throw new
|
|
2763
|
+
throw new import_common16.BadRequestException("toolCallId must be a non-empty string");
|
|
2619
2764
|
}
|
|
2620
2765
|
return claimed;
|
|
2621
2766
|
}
|
|
@@ -2625,10 +2770,10 @@ function rejectReason(claimed) {
|
|
|
2625
2770
|
return void 0;
|
|
2626
2771
|
}
|
|
2627
2772
|
if (typeof claimed !== "string") {
|
|
2628
|
-
throw new
|
|
2773
|
+
throw new import_common16.BadRequestException("reason must be a string");
|
|
2629
2774
|
}
|
|
2630
2775
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
2631
|
-
throw new
|
|
2776
|
+
throw new import_common16.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
2632
2777
|
}
|
|
2633
2778
|
return claimed;
|
|
2634
2779
|
}
|
|
@@ -2638,7 +2783,7 @@ function remember(claimed) {
|
|
|
2638
2783
|
return false;
|
|
2639
2784
|
}
|
|
2640
2785
|
if (typeof claimed !== "boolean") {
|
|
2641
|
-
throw new
|
|
2786
|
+
throw new import_common16.BadRequestException("remember must be a boolean");
|
|
2642
2787
|
}
|
|
2643
2788
|
return claimed;
|
|
2644
2789
|
}
|
|
@@ -2648,7 +2793,7 @@ function via(claimed) {
|
|
|
2648
2793
|
return DEFAULT_VIA;
|
|
2649
2794
|
}
|
|
2650
2795
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
2651
|
-
throw new
|
|
2796
|
+
throw new import_common16.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
2652
2797
|
}
|
|
2653
2798
|
return claimed;
|
|
2654
2799
|
}
|
|
@@ -2658,26 +2803,26 @@ function answers(claimed) {
|
|
|
2658
2803
|
return void 0;
|
|
2659
2804
|
}
|
|
2660
2805
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
2661
|
-
throw new
|
|
2806
|
+
throw new import_common16.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
2662
2807
|
}
|
|
2663
2808
|
const entries = Object.entries(claimed);
|
|
2664
2809
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
2665
|
-
throw new
|
|
2810
|
+
throw new import_common16.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
2666
2811
|
}
|
|
2667
2812
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
2668
2813
|
for (const [questionId, values] of entries) {
|
|
2669
2814
|
if (!Array.isArray(values)) {
|
|
2670
|
-
throw new
|
|
2815
|
+
throw new import_common16.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
2671
2816
|
}
|
|
2672
2817
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
2673
|
-
throw new
|
|
2818
|
+
throw new import_common16.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
2674
2819
|
}
|
|
2675
2820
|
for (const value of values) {
|
|
2676
2821
|
if (typeof value !== "string") {
|
|
2677
|
-
throw new
|
|
2822
|
+
throw new import_common16.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
2678
2823
|
}
|
|
2679
2824
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
2680
|
-
throw new
|
|
2825
|
+
throw new import_common16.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
2681
2826
|
}
|
|
2682
2827
|
}
|
|
2683
2828
|
validated[questionId] = values;
|
|
@@ -2735,64 +2880,64 @@ var ToolCallController = class {
|
|
|
2735
2880
|
};
|
|
2736
2881
|
}
|
|
2737
2882
|
};
|
|
2738
|
-
|
|
2739
|
-
(0,
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2883
|
+
_ts_decorate16([
|
|
2884
|
+
(0, import_common16.Post)("approve"),
|
|
2885
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2886
|
+
_ts_param14(1, (0, import_common16.Body)()),
|
|
2887
|
+
_ts_metadata15("design:type", Function),
|
|
2888
|
+
_ts_metadata15("design:paramtypes", [
|
|
2744
2889
|
typeof Request === "undefined" ? Object : Request,
|
|
2745
2890
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2746
2891
|
]),
|
|
2747
|
-
|
|
2892
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2748
2893
|
], ToolCallController.prototype, "approve", null);
|
|
2749
|
-
|
|
2750
|
-
(0,
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2894
|
+
_ts_decorate16([
|
|
2895
|
+
(0, import_common16.Post)("reject"),
|
|
2896
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2897
|
+
_ts_param14(1, (0, import_common16.Body)()),
|
|
2898
|
+
_ts_metadata15("design:type", Function),
|
|
2899
|
+
_ts_metadata15("design:paramtypes", [
|
|
2755
2900
|
typeof Request === "undefined" ? Object : Request,
|
|
2756
2901
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2757
2902
|
]),
|
|
2758
|
-
|
|
2903
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2759
2904
|
], ToolCallController.prototype, "reject", null);
|
|
2760
|
-
|
|
2761
|
-
(0,
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2905
|
+
_ts_decorate16([
|
|
2906
|
+
(0, import_common16.Post)("answer"),
|
|
2907
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2908
|
+
_ts_param14(1, (0, import_common16.Body)()),
|
|
2909
|
+
_ts_metadata15("design:type", Function),
|
|
2910
|
+
_ts_metadata15("design:paramtypes", [
|
|
2766
2911
|
typeof Request === "undefined" ? Object : Request,
|
|
2767
2912
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2768
2913
|
]),
|
|
2769
|
-
|
|
2914
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2770
2915
|
], ToolCallController.prototype, "answer", null);
|
|
2771
|
-
|
|
2772
|
-
(0,
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2916
|
+
_ts_decorate16([
|
|
2917
|
+
(0, import_common16.Post)("skip"),
|
|
2918
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2919
|
+
_ts_param14(1, (0, import_common16.Body)()),
|
|
2920
|
+
_ts_metadata15("design:type", Function),
|
|
2921
|
+
_ts_metadata15("design:paramtypes", [
|
|
2777
2922
|
typeof Request === "undefined" ? Object : Request,
|
|
2778
2923
|
Object
|
|
2779
2924
|
]),
|
|
2780
|
-
|
|
2925
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2781
2926
|
], ToolCallController.prototype, "skip", null);
|
|
2782
|
-
ToolCallController =
|
|
2783
|
-
(0,
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2927
|
+
ToolCallController = _ts_decorate16([
|
|
2928
|
+
(0, import_common16.Controller)("tool-call"),
|
|
2929
|
+
_ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
2930
|
+
_ts_metadata15("design:type", Function),
|
|
2931
|
+
_ts_metadata15("design:paramtypes", [
|
|
2787
2932
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2788
2933
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2789
2934
|
])
|
|
2790
2935
|
], ToolCallController);
|
|
2791
2936
|
|
|
2792
2937
|
// src/controller/tools.controller.ts
|
|
2793
|
-
var
|
|
2794
|
-
var
|
|
2795
|
-
function
|
|
2938
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
2939
|
+
var import_common17 = require("@nestjs/common");
|
|
2940
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2796
2941
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2797
2942
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2798
2943
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2805,19 +2950,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2805
2950
|
}
|
|
2806
2951
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2807
2952
|
}
|
|
2808
|
-
__name(
|
|
2809
|
-
function
|
|
2953
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2954
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2810
2955
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2811
2956
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2812
2957
|
}
|
|
2813
2958
|
}
|
|
2814
|
-
__name(
|
|
2815
|
-
function
|
|
2959
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2960
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2816
2961
|
return function(target, key) {
|
|
2817
2962
|
decorator(target, key, paramIndex);
|
|
2818
2963
|
};
|
|
2819
2964
|
}
|
|
2820
|
-
__name(
|
|
2965
|
+
__name(_ts_param15, "_ts_param");
|
|
2821
2966
|
var ToolsController = class {
|
|
2822
2967
|
static {
|
|
2823
2968
|
__name(this, "ToolsController");
|
|
@@ -2832,7 +2977,7 @@ var ToolsController = class {
|
|
|
2832
2977
|
}
|
|
2833
2978
|
async list(req, agent) {
|
|
2834
2979
|
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
2835
|
-
throw new
|
|
2980
|
+
throw new import_common17.NotFoundException(`No agent named "${agent}"`);
|
|
2836
2981
|
}
|
|
2837
2982
|
const actor = await this.actorResolver.resolve(req);
|
|
2838
2983
|
const deps = this.depsFactory.forAgent(agent);
|
|
@@ -2846,33 +2991,33 @@ var ToolsController = class {
|
|
|
2846
2991
|
}));
|
|
2847
2992
|
}
|
|
2848
2993
|
};
|
|
2849
|
-
|
|
2850
|
-
(0,
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2994
|
+
_ts_decorate17([
|
|
2995
|
+
(0, import_common17.Get)(),
|
|
2996
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
2997
|
+
_ts_param15(1, (0, import_common17.Query)("agent")),
|
|
2998
|
+
_ts_metadata16("design:type", Function),
|
|
2999
|
+
_ts_metadata16("design:paramtypes", [
|
|
2855
3000
|
typeof Request === "undefined" ? Object : Request,
|
|
2856
3001
|
String
|
|
2857
3002
|
]),
|
|
2858
|
-
|
|
3003
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2859
3004
|
], ToolsController.prototype, "list", null);
|
|
2860
|
-
ToolsController =
|
|
2861
|
-
(0,
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
3005
|
+
ToolsController = _ts_decorate17([
|
|
3006
|
+
(0, import_common17.Controller)("tools"),
|
|
3007
|
+
_ts_param15(0, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3008
|
+
_ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_DEPS_FACTORY)),
|
|
3009
|
+
_ts_param15(2, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_REGISTRY)),
|
|
3010
|
+
_ts_metadata16("design:type", Function),
|
|
3011
|
+
_ts_metadata16("design:paramtypes", [
|
|
2867
3012
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2868
3013
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2869
|
-
typeof
|
|
3014
|
+
typeof import_nestjs_agent_core18.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core18.AgentRegistry
|
|
2870
3015
|
])
|
|
2871
3016
|
], ToolsController);
|
|
2872
3017
|
|
|
2873
3018
|
// src/discovery/agent-discovery.service.ts
|
|
2874
|
-
var
|
|
2875
|
-
var
|
|
3019
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3020
|
+
var import_common18 = require("@nestjs/common");
|
|
2876
3021
|
var import_core = require("@nestjs/core");
|
|
2877
3022
|
|
|
2878
3023
|
// src/decorator/agent.decorator.ts
|
|
@@ -2889,7 +3034,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
2889
3034
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
2890
3035
|
|
|
2891
3036
|
// src/discovery/agent-discovery.service.ts
|
|
2892
|
-
function
|
|
3037
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2893
3038
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2894
3039
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2895
3040
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2902,19 +3047,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2902
3047
|
}
|
|
2903
3048
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2904
3049
|
}
|
|
2905
|
-
__name(
|
|
2906
|
-
function
|
|
3050
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3051
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2907
3052
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2908
3053
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2909
3054
|
}
|
|
2910
3055
|
}
|
|
2911
|
-
__name(
|
|
2912
|
-
function
|
|
3056
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3057
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2913
3058
|
return function(target, key) {
|
|
2914
3059
|
decorator(target, key, paramIndex);
|
|
2915
3060
|
};
|
|
2916
3061
|
}
|
|
2917
|
-
__name(
|
|
3062
|
+
__name(_ts_param16, "_ts_param");
|
|
2918
3063
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2919
3064
|
static {
|
|
2920
3065
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2923,7 +3068,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2923
3068
|
scanner;
|
|
2924
3069
|
registry;
|
|
2925
3070
|
contributors;
|
|
2926
|
-
logger = new
|
|
3071
|
+
logger = new import_common18.Logger(_AgentDiscoveryService.name);
|
|
2927
3072
|
constructor(discovery, scanner, registry, contributors) {
|
|
2928
3073
|
this.discovery = discovery;
|
|
2929
3074
|
this.scanner = scanner;
|
|
@@ -3041,22 +3186,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3041
3186
|
return (ctx) => candidate.call(instance, ctx);
|
|
3042
3187
|
}
|
|
3043
3188
|
};
|
|
3044
|
-
AgentDiscoveryService =
|
|
3045
|
-
(0,
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3189
|
+
AgentDiscoveryService = _ts_decorate18([
|
|
3190
|
+
(0, import_common18.Injectable)(),
|
|
3191
|
+
_ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
|
|
3192
|
+
_ts_param16(3, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_PROMPT_CONTRIBUTORS)),
|
|
3193
|
+
_ts_metadata17("design:type", Function),
|
|
3194
|
+
_ts_metadata17("design:paramtypes", [
|
|
3050
3195
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
3051
3196
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
3052
|
-
typeof
|
|
3197
|
+
typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry,
|
|
3053
3198
|
Array
|
|
3054
3199
|
])
|
|
3055
3200
|
], AgentDiscoveryService);
|
|
3056
3201
|
|
|
3057
3202
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3058
|
-
var
|
|
3059
|
-
var
|
|
3203
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3204
|
+
var import_common19 = require("@nestjs/common");
|
|
3060
3205
|
var import_core2 = require("@nestjs/core");
|
|
3061
3206
|
var import_zod = require("zod");
|
|
3062
3207
|
|
|
@@ -3076,7 +3221,7 @@ function isBrandedFunctionalTool(value) {
|
|
|
3076
3221
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
3077
3222
|
|
|
3078
3223
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3079
|
-
function
|
|
3224
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3080
3225
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3081
3226
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3082
3227
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3089,19 +3234,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3089
3234
|
}
|
|
3090
3235
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3091
3236
|
}
|
|
3092
|
-
__name(
|
|
3093
|
-
function
|
|
3237
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3238
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3094
3239
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3095
3240
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3096
3241
|
}
|
|
3097
3242
|
}
|
|
3098
|
-
__name(
|
|
3099
|
-
function
|
|
3243
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3244
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3100
3245
|
return function(target, key) {
|
|
3101
3246
|
decorator(target, key, paramIndex);
|
|
3102
3247
|
};
|
|
3103
3248
|
}
|
|
3104
|
-
__name(
|
|
3249
|
+
__name(_ts_param17, "_ts_param");
|
|
3105
3250
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
3106
3251
|
static {
|
|
3107
3252
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -3110,7 +3255,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3110
3255
|
registry;
|
|
3111
3256
|
agents;
|
|
3112
3257
|
options;
|
|
3113
|
-
logger = new
|
|
3258
|
+
logger = new import_common19.Logger(_AiToolDiscoveryService.name);
|
|
3114
3259
|
constructor(discovery, registry, agents, options) {
|
|
3115
3260
|
this.discovery = discovery;
|
|
3116
3261
|
this.registry = registry;
|
|
@@ -3184,7 +3329,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3184
3329
|
let delegates = 0;
|
|
3185
3330
|
for (const definition of this.agents.list()) {
|
|
3186
3331
|
for (const edge of definition.delegatesTo ?? []) {
|
|
3187
|
-
const { agent: target, detached } = (0,
|
|
3332
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core20.normalizeDelegation)(edge);
|
|
3188
3333
|
const targetDefinition = this.agents.get(target);
|
|
3189
3334
|
if (targetDefinition === void 0) {
|
|
3190
3335
|
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.`);
|
|
@@ -3234,13 +3379,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3234
3379
|
return true;
|
|
3235
3380
|
}
|
|
3236
3381
|
};
|
|
3237
|
-
AiToolDiscoveryService =
|
|
3238
|
-
(0,
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3382
|
+
AiToolDiscoveryService = _ts_decorate19([
|
|
3383
|
+
(0, import_common19.Injectable)(),
|
|
3384
|
+
_ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_TOOL_REGISTRY)),
|
|
3385
|
+
_ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
|
|
3386
|
+
_ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
|
|
3387
|
+
_ts_metadata18("design:type", Function),
|
|
3388
|
+
_ts_metadata18("design:paramtypes", [
|
|
3244
3389
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
3245
3390
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3246
3391
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3249,25 +3394,25 @@ AiToolDiscoveryService = _ts_decorate18([
|
|
|
3249
3394
|
], AiToolDiscoveryService);
|
|
3250
3395
|
|
|
3251
3396
|
// src/discovery/skill-discovery.service.ts
|
|
3252
|
-
var
|
|
3253
|
-
var
|
|
3397
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
3398
|
+
var import_common20 = require("@nestjs/common");
|
|
3254
3399
|
var import_core3 = require("@nestjs/core");
|
|
3255
3400
|
|
|
3256
3401
|
// src/decorator/skill.decorator.ts
|
|
3257
3402
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
3258
|
-
var
|
|
3403
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
3259
3404
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
3260
3405
|
function readSkillMetadata(target) {
|
|
3261
3406
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
3262
3407
|
}
|
|
3263
3408
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
3264
3409
|
function skillScope(options) {
|
|
3265
|
-
return options.scope ??
|
|
3410
|
+
return options.scope ?? import_nestjs_agent_core21.GLOBAL_SCOPE;
|
|
3266
3411
|
}
|
|
3267
3412
|
__name(skillScope, "skillScope");
|
|
3268
3413
|
|
|
3269
3414
|
// src/discovery/skill-discovery.service.ts
|
|
3270
|
-
function
|
|
3415
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3271
3416
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3272
3417
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3273
3418
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3280,26 +3425,26 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3280
3425
|
}
|
|
3281
3426
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3282
3427
|
}
|
|
3283
|
-
__name(
|
|
3284
|
-
function
|
|
3428
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3429
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3285
3430
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3286
3431
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3287
3432
|
}
|
|
3288
3433
|
}
|
|
3289
|
-
__name(
|
|
3290
|
-
function
|
|
3434
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3435
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3291
3436
|
return function(target, key) {
|
|
3292
3437
|
decorator(target, key, paramIndex);
|
|
3293
3438
|
};
|
|
3294
3439
|
}
|
|
3295
|
-
__name(
|
|
3440
|
+
__name(_ts_param18, "_ts_param");
|
|
3296
3441
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3297
3442
|
static {
|
|
3298
3443
|
__name(this, "SkillDiscoveryService");
|
|
3299
3444
|
}
|
|
3300
3445
|
discovery;
|
|
3301
3446
|
declared;
|
|
3302
|
-
logger = new
|
|
3447
|
+
logger = new import_common20.Logger(_SkillDiscoveryService.name);
|
|
3303
3448
|
constructor(discovery, declared) {
|
|
3304
3449
|
this.discovery = discovery;
|
|
3305
3450
|
this.declared = declared;
|
|
@@ -3336,11 +3481,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3336
3481
|
return flat === void 0 ? void 0 : () => flat;
|
|
3337
3482
|
}
|
|
3338
3483
|
};
|
|
3339
|
-
SkillDiscoveryService =
|
|
3340
|
-
(0,
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3484
|
+
SkillDiscoveryService = _ts_decorate20([
|
|
3485
|
+
(0, import_common20.Injectable)(),
|
|
3486
|
+
_ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_SKILL_SOURCES)),
|
|
3487
|
+
_ts_metadata19("design:type", Function),
|
|
3488
|
+
_ts_metadata19("design:paramtypes", [
|
|
3344
3489
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
3345
3490
|
Array
|
|
3346
3491
|
])
|
|
@@ -3370,9 +3515,9 @@ var LedgerQuotaStore = class {
|
|
|
3370
3515
|
};
|
|
3371
3516
|
|
|
3372
3517
|
// src/runner/inline-agent-runner.ts
|
|
3373
|
-
var
|
|
3374
|
-
var
|
|
3375
|
-
function
|
|
3518
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
3519
|
+
var import_common21 = require("@nestjs/common");
|
|
3520
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3376
3521
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3377
3522
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3378
3523
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3385,26 +3530,26 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3385
3530
|
}
|
|
3386
3531
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3387
3532
|
}
|
|
3388
|
-
__name(
|
|
3389
|
-
function
|
|
3533
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3534
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3390
3535
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3391
3536
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3392
3537
|
}
|
|
3393
3538
|
}
|
|
3394
|
-
__name(
|
|
3395
|
-
function
|
|
3539
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3540
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3396
3541
|
return function(target, key) {
|
|
3397
3542
|
decorator(target, key, paramIndex);
|
|
3398
3543
|
};
|
|
3399
3544
|
}
|
|
3400
|
-
__name(
|
|
3545
|
+
__name(_ts_param19, "_ts_param");
|
|
3401
3546
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3402
3547
|
static {
|
|
3403
3548
|
__name(this, "InlineAgentRunner");
|
|
3404
3549
|
}
|
|
3405
3550
|
factory;
|
|
3406
3551
|
store;
|
|
3407
|
-
logger = new
|
|
3552
|
+
logger = new import_common21.Logger(_InlineAgentRunner.name);
|
|
3408
3553
|
pending = /* @__PURE__ */ new Map();
|
|
3409
3554
|
/**
|
|
3410
3555
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -3433,18 +3578,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3433
3578
|
] : []
|
|
3434
3579
|
]
|
|
3435
3580
|
});
|
|
3436
|
-
void (0,
|
|
3581
|
+
void (0, import_nestjs_agent_core23.runAgentLoop)({
|
|
3437
3582
|
...deps,
|
|
3438
3583
|
day
|
|
3439
3584
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
3440
|
-
if (error instanceof
|
|
3585
|
+
if (error instanceof import_nestjs_agent_core23.RunCancelledError) {
|
|
3441
3586
|
await this.settleCancelled(runId, input.threadId, deps);
|
|
3442
3587
|
return;
|
|
3443
3588
|
}
|
|
3444
3589
|
const message = error instanceof Error ? error.message : String(error);
|
|
3445
|
-
const code = (0,
|
|
3590
|
+
const code = (0, import_nestjs_agent_core23.agentFailureCode)(error);
|
|
3446
3591
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
3447
|
-
(0,
|
|
3592
|
+
(0, import_nestjs_agent_core23.publishAgentRunFailed)({
|
|
3448
3593
|
runId,
|
|
3449
3594
|
code,
|
|
3450
3595
|
message
|
|
@@ -3493,7 +3638,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3493
3638
|
for (const [key, waiter] of this.pending) {
|
|
3494
3639
|
if (key.startsWith(`${runId}:`)) {
|
|
3495
3640
|
this.pending.delete(key);
|
|
3496
|
-
waiter.reject(new
|
|
3641
|
+
waiter.reject(new import_nestjs_agent_core23.RunCancelledError());
|
|
3497
3642
|
}
|
|
3498
3643
|
}
|
|
3499
3644
|
await Promise.resolve();
|
|
@@ -3508,7 +3653,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3508
3653
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3509
3654
|
await this.store.setActiveStream(threadId, null);
|
|
3510
3655
|
const writer = await deps.sink.open(runId);
|
|
3511
|
-
await writer.write((0,
|
|
3656
|
+
await writer.write((0, import_nestjs_agent_core23.encodeStreamEvent)({
|
|
3512
3657
|
kind: "cancelled"
|
|
3513
3658
|
}));
|
|
3514
3659
|
await writer.end();
|
|
@@ -3569,7 +3714,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3569
3714
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3570
3715
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3571
3716
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3572
|
-
parallel:
|
|
3717
|
+
parallel: import_nestjs_agent_core23.settleAll,
|
|
3573
3718
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3574
3719
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
3575
3720
|
agentName,
|
|
@@ -3620,7 +3765,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3620
3765
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3621
3766
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3622
3767
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3623
|
-
parallel:
|
|
3768
|
+
parallel: import_nestjs_agent_core23.settleAll,
|
|
3624
3769
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3625
3770
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
3626
3771
|
agentName: childName,
|
|
@@ -3653,7 +3798,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3653
3798
|
}
|
|
3654
3799
|
}), "startAgent")
|
|
3655
3800
|
};
|
|
3656
|
-
void (0,
|
|
3801
|
+
void (0, import_nestjs_agent_core23.runAgentLoop)({
|
|
3657
3802
|
...deps,
|
|
3658
3803
|
day
|
|
3659
3804
|
}, {
|
|
@@ -3667,13 +3812,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3667
3812
|
parentRunId,
|
|
3668
3813
|
deliverTo
|
|
3669
3814
|
}, hooks).catch(async (error) => {
|
|
3670
|
-
const cancelled = error instanceof
|
|
3815
|
+
const cancelled = error instanceof import_nestjs_agent_core23.RunCancelledError;
|
|
3671
3816
|
const message = error instanceof Error ? error.message : String(error);
|
|
3672
3817
|
if (!cancelled) {
|
|
3673
3818
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
3674
|
-
(0,
|
|
3819
|
+
(0, import_nestjs_agent_core23.publishAgentRunFailed)({
|
|
3675
3820
|
runId,
|
|
3676
|
-
code: (0,
|
|
3821
|
+
code: (0, import_nestjs_agent_core23.agentFailureCode)(error),
|
|
3677
3822
|
message
|
|
3678
3823
|
});
|
|
3679
3824
|
}
|
|
@@ -3681,11 +3826,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3681
3826
|
runId,
|
|
3682
3827
|
status: cancelled ? "cancelled" : "failed",
|
|
3683
3828
|
...cancelled ? {} : {
|
|
3684
|
-
errorCode: (0,
|
|
3829
|
+
errorCode: (0, import_nestjs_agent_core23.agentFailureCode)(error),
|
|
3685
3830
|
errorMessage: message
|
|
3686
3831
|
}
|
|
3687
3832
|
});
|
|
3688
|
-
await (0,
|
|
3833
|
+
await (0, import_nestjs_agent_core23.settleUnsettledDelegation)({
|
|
3689
3834
|
store: this.store,
|
|
3690
3835
|
delivery: deliverTo,
|
|
3691
3836
|
agent: agentName,
|
|
@@ -3724,7 +3869,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3724
3869
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3725
3870
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3726
3871
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3727
|
-
parallel:
|
|
3872
|
+
parallel: import_nestjs_agent_core23.settleAll,
|
|
3728
3873
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
3729
3874
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
3730
3875
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -3759,7 +3904,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3759
3904
|
}), "startAgent")
|
|
3760
3905
|
};
|
|
3761
3906
|
try {
|
|
3762
|
-
return await (0,
|
|
3907
|
+
return await (0, import_nestjs_agent_core23.runAgentLoop)({
|
|
3763
3908
|
...deps,
|
|
3764
3909
|
day
|
|
3765
3910
|
}, {
|
|
@@ -3778,19 +3923,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3778
3923
|
}
|
|
3779
3924
|
}
|
|
3780
3925
|
};
|
|
3781
|
-
InlineAgentRunner =
|
|
3782
|
-
(0,
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3926
|
+
InlineAgentRunner = _ts_decorate21([
|
|
3927
|
+
(0, import_common21.Injectable)(),
|
|
3928
|
+
_ts_param19(0, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_DEPS_FACTORY)),
|
|
3929
|
+
_ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_STORE)),
|
|
3930
|
+
_ts_metadata20("design:type", Function),
|
|
3931
|
+
_ts_metadata20("design:paramtypes", [
|
|
3787
3932
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3788
3933
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3789
3934
|
])
|
|
3790
3935
|
], InlineAgentRunner);
|
|
3791
3936
|
|
|
3792
3937
|
// src/skills-config.ts
|
|
3793
|
-
var
|
|
3938
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
3794
3939
|
function declaredSkillProvider(declared) {
|
|
3795
3940
|
return {
|
|
3796
3941
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -3816,7 +3961,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3816
3961
|
declaredSkillProvider(declared)
|
|
3817
3962
|
];
|
|
3818
3963
|
return {
|
|
3819
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
3964
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core24.compositeSkillProvider)(providers),
|
|
3820
3965
|
...options.scopes !== void 0 ? {
|
|
3821
3966
|
scopes: options.scopes
|
|
3822
3967
|
} : {},
|
|
@@ -3828,7 +3973,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3828
3973
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3829
3974
|
|
|
3830
3975
|
// src/agent.module.ts
|
|
3831
|
-
function
|
|
3976
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3832
3977
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3833
3978
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3834
3979
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3841,92 +3986,92 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
3841
3986
|
}
|
|
3842
3987
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3843
3988
|
}
|
|
3844
|
-
__name(
|
|
3989
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3845
3990
|
var DEFAULT_PATH = "agent";
|
|
3846
3991
|
function sharedProviders(durable, includeStore) {
|
|
3847
3992
|
const providers = [
|
|
3848
3993
|
{
|
|
3849
|
-
provide:
|
|
3850
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3994
|
+
provide: import_nestjs_agent_core25.AGENT_TOOL_REGISTRY,
|
|
3995
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core25.ToolRegistry(), "useFactory")
|
|
3851
3996
|
},
|
|
3852
3997
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
3853
3998
|
{
|
|
3854
|
-
provide:
|
|
3855
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3999
|
+
provide: import_nestjs_agent_core25.AGENT_REGISTRY,
|
|
4000
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core25.AgentRegistry(), "useFactory")
|
|
3856
4001
|
},
|
|
3857
4002
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
3858
4003
|
{
|
|
3859
|
-
provide:
|
|
4004
|
+
provide: import_nestjs_agent_core25.AGENT_PROMPT_CONTRIBUTORS,
|
|
3860
4005
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3861
4006
|
},
|
|
3862
4007
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
3863
4008
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
3864
4009
|
{
|
|
3865
|
-
provide:
|
|
4010
|
+
provide: import_nestjs_agent_core25.AGENT_SKILL_SOURCES,
|
|
3866
4011
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3867
4012
|
},
|
|
3868
4013
|
{
|
|
3869
4014
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
3870
4015
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
3871
4016
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
3872
|
-
provide:
|
|
4017
|
+
provide: import_nestjs_agent_core25.AGENT_SKILLS,
|
|
3873
4018
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3874
4019
|
inject: [
|
|
3875
|
-
|
|
3876
|
-
|
|
4020
|
+
import_nestjs_agent_core25.AGENT_OPTIONS,
|
|
4021
|
+
import_nestjs_agent_core25.AGENT_SKILL_SOURCES
|
|
3877
4022
|
]
|
|
3878
4023
|
},
|
|
3879
4024
|
{
|
|
3880
4025
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
3881
4026
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
3882
|
-
provide:
|
|
4027
|
+
provide: import_nestjs_agent_core25.AGENT_MEMORY,
|
|
3883
4028
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3884
4029
|
inject: [
|
|
3885
|
-
|
|
4030
|
+
import_nestjs_agent_core25.AGENT_OPTIONS
|
|
3886
4031
|
]
|
|
3887
4032
|
},
|
|
3888
4033
|
{
|
|
3889
|
-
provide:
|
|
4034
|
+
provide: import_nestjs_agent_core25.AGENT_SINK,
|
|
3890
4035
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3891
4036
|
inject: [
|
|
3892
|
-
|
|
4037
|
+
import_nestjs_agent_core25.AGENT_OPTIONS
|
|
3893
4038
|
]
|
|
3894
4039
|
},
|
|
3895
4040
|
{
|
|
3896
|
-
provide:
|
|
3897
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
4041
|
+
provide: import_nestjs_agent_core25.AGENT_ROLES_POLICY,
|
|
4042
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core25.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3898
4043
|
inject: [
|
|
3899
|
-
|
|
4044
|
+
import_nestjs_agent_core25.AGENT_OPTIONS
|
|
3900
4045
|
]
|
|
3901
4046
|
},
|
|
3902
4047
|
{
|
|
3903
|
-
provide:
|
|
4048
|
+
provide: import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER,
|
|
3904
4049
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
3905
4050
|
inject: [
|
|
3906
|
-
|
|
4051
|
+
import_nestjs_agent_core25.AGENT_OPTIONS
|
|
3907
4052
|
]
|
|
3908
4053
|
},
|
|
3909
4054
|
{
|
|
3910
|
-
provide:
|
|
4055
|
+
provide: import_nestjs_agent_core25.AGENT_MODEL,
|
|
3911
4056
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3912
4057
|
inject: [
|
|
3913
|
-
|
|
4058
|
+
import_nestjs_agent_core25.AGENT_OPTIONS
|
|
3914
4059
|
]
|
|
3915
4060
|
},
|
|
3916
4061
|
{
|
|
3917
4062
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
3918
4063
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
3919
4064
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
3920
|
-
provide:
|
|
4065
|
+
provide: import_nestjs_agent_core25.AGENT_QUOTA_STORE,
|
|
3921
4066
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3922
4067
|
inject: [
|
|
3923
|
-
|
|
3924
|
-
|
|
4068
|
+
import_nestjs_agent_core25.AGENT_OPTIONS,
|
|
4069
|
+
import_nestjs_agent_core25.AGENT_STORE
|
|
3925
4070
|
]
|
|
3926
4071
|
},
|
|
3927
4072
|
AgentDepsFactory2,
|
|
3928
4073
|
{
|
|
3929
|
-
provide:
|
|
4074
|
+
provide: import_nestjs_agent_core25.AGENT_DEPS_FACTORY,
|
|
3930
4075
|
useExisting: AgentDepsFactory2
|
|
3931
4076
|
},
|
|
3932
4077
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -3940,22 +4085,22 @@ function sharedProviders(durable, includeStore) {
|
|
|
3940
4085
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
3941
4086
|
AgentApprovalPortAdapter,
|
|
3942
4087
|
{
|
|
3943
|
-
provide:
|
|
4088
|
+
provide: import_nestjs_agent_core25.AGENT_APPROVAL_PORT,
|
|
3944
4089
|
useExisting: AgentApprovalPortAdapter
|
|
3945
4090
|
}
|
|
3946
4091
|
];
|
|
3947
4092
|
if (includeStore) {
|
|
3948
4093
|
providers.push({
|
|
3949
|
-
provide:
|
|
4094
|
+
provide: import_nestjs_agent_core25.AGENT_STORE,
|
|
3950
4095
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
3951
4096
|
inject: [
|
|
3952
|
-
|
|
4097
|
+
import_nestjs_agent_core25.AGENT_OPTIONS
|
|
3953
4098
|
]
|
|
3954
4099
|
});
|
|
3955
4100
|
}
|
|
3956
4101
|
if (durable) {
|
|
3957
4102
|
providers.push({
|
|
3958
|
-
provide:
|
|
4103
|
+
provide: import_nestjs_agent_core25.AGENT_RUNNER,
|
|
3959
4104
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
3960
4105
|
if (durableRunner === void 0) {
|
|
3961
4106
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -3964,14 +4109,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
3964
4109
|
}, "useFactory"),
|
|
3965
4110
|
inject: [
|
|
3966
4111
|
{
|
|
3967
|
-
token:
|
|
4112
|
+
token: import_nestjs_agent_core25.AGENT_DURABLE_RUNNER,
|
|
3968
4113
|
optional: true
|
|
3969
4114
|
}
|
|
3970
4115
|
]
|
|
3971
4116
|
});
|
|
3972
4117
|
} else {
|
|
3973
4118
|
providers.push({
|
|
3974
|
-
provide:
|
|
4119
|
+
provide: import_nestjs_agent_core25.AGENT_RUNNER,
|
|
3975
4120
|
useExisting: InlineAgentRunner
|
|
3976
4121
|
});
|
|
3977
4122
|
}
|
|
@@ -3980,25 +4125,25 @@ function sharedProviders(durable, includeStore) {
|
|
|
3980
4125
|
__name(sharedProviders, "sharedProviders");
|
|
3981
4126
|
function exportsFor(includeStore) {
|
|
3982
4127
|
return [
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4128
|
+
import_nestjs_agent_core25.AGENT_OPTIONS,
|
|
4129
|
+
import_nestjs_agent_core25.AGENT_TOOL_REGISTRY,
|
|
4130
|
+
import_nestjs_agent_core25.AGENT_REGISTRY,
|
|
4131
|
+
import_nestjs_agent_core25.AGENT_SINK,
|
|
4132
|
+
import_nestjs_agent_core25.AGENT_ROLES_POLICY,
|
|
4133
|
+
import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER,
|
|
4134
|
+
import_nestjs_agent_core25.AGENT_MODEL,
|
|
3990
4135
|
...includeStore ? [
|
|
3991
|
-
|
|
4136
|
+
import_nestjs_agent_core25.AGENT_STORE
|
|
3992
4137
|
] : [],
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
4138
|
+
import_nestjs_agent_core25.AGENT_QUOTA_STORE,
|
|
4139
|
+
import_nestjs_agent_core25.AGENT_PROMPT_CONTRIBUTORS,
|
|
4140
|
+
import_nestjs_agent_core25.AGENT_SKILLS,
|
|
4141
|
+
import_nestjs_agent_core25.AGENT_MEMORY,
|
|
4142
|
+
import_nestjs_agent_core25.AGENT_DEPS_FACTORY,
|
|
3998
4143
|
AgentDepsFactory2,
|
|
3999
4144
|
AgentService,
|
|
4000
4145
|
InlineAgentRunner,
|
|
4001
|
-
|
|
4146
|
+
import_nestjs_agent_core25.AGENT_APPROVAL_PORT
|
|
4002
4147
|
];
|
|
4003
4148
|
}
|
|
4004
4149
|
__name(exportsFor, "exportsFor");
|
|
@@ -4010,7 +4155,8 @@ var BASE_CONTROLLERS = [
|
|
|
4010
4155
|
AgentsController,
|
|
4011
4156
|
SkillsController,
|
|
4012
4157
|
MemoriesController,
|
|
4013
|
-
ToolsController
|
|
4158
|
+
ToolsController,
|
|
4159
|
+
MessagesController
|
|
4014
4160
|
];
|
|
4015
4161
|
var GUARDABLE_CONTROLLERS = [
|
|
4016
4162
|
...BASE_CONTROLLERS,
|
|
@@ -4068,7 +4214,7 @@ var AgentModule = class _AgentModule {
|
|
|
4068
4214
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
4069
4215
|
providers: [
|
|
4070
4216
|
{
|
|
4071
|
-
provide:
|
|
4217
|
+
provide: import_nestjs_agent_core25.AGENT_OPTIONS,
|
|
4072
4218
|
useValue: options
|
|
4073
4219
|
},
|
|
4074
4220
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -4092,7 +4238,7 @@ var AgentModule = class _AgentModule {
|
|
|
4092
4238
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
4093
4239
|
providers: [
|
|
4094
4240
|
{
|
|
4095
|
-
provide:
|
|
4241
|
+
provide: import_nestjs_agent_core25.AGENT_OPTIONS,
|
|
4096
4242
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4097
4243
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4098
4244
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4113,9 +4259,9 @@ var AgentModule = class _AgentModule {
|
|
|
4113
4259
|
};
|
|
4114
4260
|
}
|
|
4115
4261
|
};
|
|
4116
|
-
AgentModule =
|
|
4117
|
-
(0,
|
|
4118
|
-
(0,
|
|
4262
|
+
AgentModule = _ts_decorate22([
|
|
4263
|
+
(0, import_common22.Global)(),
|
|
4264
|
+
(0, import_common22.Module)({})
|
|
4119
4265
|
], AgentModule);
|
|
4120
4266
|
|
|
4121
4267
|
// src/durable/agent-durable.ts
|