@dudousxd/nestjs-agent 1.13.0 → 1.15.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 +19 -0
- package/dist/{agent-deps.factory-DkWvoWbD.d.cts → chat-queue.service-Bqq00NN1.d.cts} +131 -2
- package/dist/{agent-deps.factory-DkWvoWbD.d.ts → chat-queue.service-Bqq00NN1.d.ts} +131 -2
- package/dist/durable/index.cjs +1796 -759
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +26 -7
- package/dist/durable/index.d.ts +26 -7
- package/dist/durable/index.js +1628 -591
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +1598 -672
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -8
- package/dist/index.d.ts +133 -8
- package/dist/index.js +1412 -488
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/agent.module.ts
|
|
5
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
6
|
-
import { Global, Logger as
|
|
5
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS7, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
6
|
+
import { Global, Logger as Logger6, Module } from "@nestjs/common";
|
|
7
7
|
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
8
8
|
|
|
9
9
|
// src/agent-deps.factory.ts
|
|
@@ -265,8 +265,8 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
265
265
|
], AgentDepsFactory2);
|
|
266
266
|
|
|
267
267
|
// src/agent.service.ts
|
|
268
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_MODEL_CATALOG, AGENT_OPTIONS as
|
|
269
|
-
import { BadRequestException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as
|
|
268
|
+
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE3, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
269
|
+
import { BadRequestException, ConflictException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject3, Injectable as Injectable3, NotFoundException, NotImplementedException as NotImplementedException2, Optional as Optional3 } from "@nestjs/common";
|
|
270
270
|
|
|
271
271
|
// src/agent-deps.ts
|
|
272
272
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -284,7 +284,9 @@ function childSinkWriter(writer) {
|
|
|
284
284
|
}
|
|
285
285
|
__name(childSinkWriter, "childSinkWriter");
|
|
286
286
|
|
|
287
|
-
// src/
|
|
287
|
+
// src/queue/chat-queue.service.ts
|
|
288
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE2, encodeStreamEvent, isChatQueueStore, queuedMessageView } from "@dudousxd/nestjs-agent-core";
|
|
289
|
+
import { Inject as Inject2, Injectable as Injectable2, Logger, NotImplementedException, Optional as Optional2 } from "@nestjs/common";
|
|
288
290
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
289
291
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
290
292
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -311,6 +313,431 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
311
313
|
};
|
|
312
314
|
}
|
|
313
315
|
__name(_ts_param2, "_ts_param");
|
|
316
|
+
var MAX_DRAIN_ATTEMPTS = 8;
|
|
317
|
+
var ChatQueueService = class _ChatQueueService {
|
|
318
|
+
static {
|
|
319
|
+
__name(this, "ChatQueueService");
|
|
320
|
+
}
|
|
321
|
+
store;
|
|
322
|
+
sink;
|
|
323
|
+
quotaProvider;
|
|
324
|
+
options;
|
|
325
|
+
staging;
|
|
326
|
+
logger = new Logger(_ChatQueueService.name);
|
|
327
|
+
/**
|
|
328
|
+
* Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
|
|
329
|
+
* alive whatever the runner says — it simply has not registered the run yet.
|
|
330
|
+
*/
|
|
331
|
+
starting = /* @__PURE__ */ new Set();
|
|
332
|
+
constructor(store, sink, quotaProvider, options, staging) {
|
|
333
|
+
this.store = store;
|
|
334
|
+
this.sink = sink;
|
|
335
|
+
this.quotaProvider = quotaProvider;
|
|
336
|
+
this.options = options;
|
|
337
|
+
this.staging = staging;
|
|
338
|
+
}
|
|
339
|
+
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
340
|
+
get supported() {
|
|
341
|
+
return isChatQueueStore(this.store);
|
|
342
|
+
}
|
|
343
|
+
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
344
|
+
queueStore() {
|
|
345
|
+
if (!isChatQueueStore(this.store)) {
|
|
346
|
+
throw new NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
347
|
+
}
|
|
348
|
+
return this.store;
|
|
349
|
+
}
|
|
350
|
+
async state(threadId) {
|
|
351
|
+
const store = this.queueStore();
|
|
352
|
+
const [items, paused] = await Promise.all([
|
|
353
|
+
store.listQueue(threadId),
|
|
354
|
+
store.queuePause(threadId)
|
|
355
|
+
]);
|
|
356
|
+
return {
|
|
357
|
+
items: items.map(queuedMessageView),
|
|
358
|
+
paused
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Whether `holder` is still running. A run this process is about to start is; otherwise the
|
|
363
|
+
* runner decides, and a runner that cannot tell says yes.
|
|
364
|
+
*/
|
|
365
|
+
async isAlive(holder, runner) {
|
|
366
|
+
if (this.starting.has(holder)) {
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
if (typeof runner.isRunActive !== "function") {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
try {
|
|
373
|
+
return await runner.isRunActive(holder);
|
|
374
|
+
} catch {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* The run holding `threadId`, or `null` when it is free — a holder the runner reports dead counts
|
|
380
|
+
* as free, and is returned as `stale` so the caller can claim over it.
|
|
381
|
+
*/
|
|
382
|
+
async holder(threadId, runner) {
|
|
383
|
+
const holder = await this.queueStore().activeRunForThread(threadId);
|
|
384
|
+
if (holder === null) {
|
|
385
|
+
return {
|
|
386
|
+
live: null,
|
|
387
|
+
stale: null
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return await this.isAlive(holder, runner) ? {
|
|
391
|
+
live: holder,
|
|
392
|
+
stale: null
|
|
393
|
+
} : {
|
|
394
|
+
live: null,
|
|
395
|
+
stale: holder
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Decide what follows a TOP-LEVEL run that is settling on `threadId`, and move the thread there:
|
|
400
|
+
* hand it to the next queued message (claimed and popped here, started by the caller), or pause
|
|
401
|
+
* the queue, or release the thread. Call it BEFORE the run's terminal frame, so a client reading
|
|
402
|
+
* the stream learns what comes next from the `queue` frame, and so the thread is already free
|
|
403
|
+
* when the client sees the run end.
|
|
404
|
+
*
|
|
405
|
+
* A no-op returning `{}` on a store without a queue.
|
|
406
|
+
*/
|
|
407
|
+
async plan(args) {
|
|
408
|
+
if (!isChatQueueStore(this.store)) {
|
|
409
|
+
return {};
|
|
410
|
+
}
|
|
411
|
+
const store = this.store;
|
|
412
|
+
const { threadId, outcome } = args;
|
|
413
|
+
if (await store.activeRunForThread(threadId) !== args.runId) {
|
|
414
|
+
return {};
|
|
415
|
+
}
|
|
416
|
+
let holding = args.runId;
|
|
417
|
+
for (let attempt = 0; attempt < MAX_DRAIN_ATTEMPTS; attempt += 1) {
|
|
418
|
+
const items = await store.listQueue(threadId);
|
|
419
|
+
const head = items[0];
|
|
420
|
+
if (head === void 0) {
|
|
421
|
+
if (holding !== null) {
|
|
422
|
+
await store.releaseActiveStream(threadId, holding);
|
|
423
|
+
holding = null;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
return {};
|
|
427
|
+
}
|
|
428
|
+
let pause = await store.queuePause(threadId);
|
|
429
|
+
if (pause === null) {
|
|
430
|
+
const reason = pauseReasonFor(outcome, head);
|
|
431
|
+
if (reason !== null) {
|
|
432
|
+
pause = {
|
|
433
|
+
reason,
|
|
434
|
+
...outcome === "failed" && args.error !== void 0 ? {
|
|
435
|
+
message: args.error
|
|
436
|
+
} : {},
|
|
437
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
438
|
+
};
|
|
439
|
+
await store.setQueuePause(threadId, pause);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (pause === null) {
|
|
443
|
+
const blocked = await this.quotaBlock(head.actor);
|
|
444
|
+
if (blocked !== null) {
|
|
445
|
+
pause = {
|
|
446
|
+
reason: "quota_exceeded",
|
|
447
|
+
message: blocked,
|
|
448
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
449
|
+
};
|
|
450
|
+
await store.setQueuePause(threadId, pause);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (pause !== null) {
|
|
454
|
+
if (holding !== null) {
|
|
455
|
+
await store.releaseActiveStream(threadId, holding);
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
frame: queueFrame(items, pause)
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
const claimed = await store.claimActiveStream(threadId, head.id, holding !== null ? {
|
|
462
|
+
replacing: holding
|
|
463
|
+
} : {});
|
|
464
|
+
if (!claimed) {
|
|
465
|
+
return {};
|
|
466
|
+
}
|
|
467
|
+
holding = head.id;
|
|
468
|
+
if (!await store.removeQueuedMessage(head.id)) {
|
|
469
|
+
await store.releaseActiveStream(threadId, head.id);
|
|
470
|
+
holding = null;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
const next = {
|
|
474
|
+
runId: head.id,
|
|
475
|
+
messageId: head.id,
|
|
476
|
+
input: await this.inputFor(head)
|
|
477
|
+
};
|
|
478
|
+
return {
|
|
479
|
+
next,
|
|
480
|
+
frame: queueFrame(items.slice(1), null, {
|
|
481
|
+
messageId: head.id,
|
|
482
|
+
runId: head.id
|
|
483
|
+
})
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
if (holding !== null) {
|
|
487
|
+
await store.releaseActiveStream(threadId, holding);
|
|
488
|
+
}
|
|
489
|
+
return {};
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* {@link plan}, then start what it picked with `start`. What an in-process settle (the inline
|
|
493
|
+
* runner, a durable cancel issued outside a workflow) calls; answers the frame to write.
|
|
494
|
+
*/
|
|
495
|
+
async handoff(args, start) {
|
|
496
|
+
const plan = await this.plan(args);
|
|
497
|
+
if (plan.next === void 0) {
|
|
498
|
+
return plan.frame;
|
|
499
|
+
}
|
|
500
|
+
return await this.launch(args.threadId, plan.next, start) ? plan.frame : this.pausedFrame(args.threadId);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Start the head of an IDLE thread's queue — after a send queued behind a run that turned out to
|
|
504
|
+
* be gone, after a resume, after a stale holder. Does nothing while a live run holds the thread
|
|
505
|
+
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
506
|
+
*/
|
|
507
|
+
async kick(threadId, runner) {
|
|
508
|
+
if (!isChatQueueStore(this.store)) {
|
|
509
|
+
return void 0;
|
|
510
|
+
}
|
|
511
|
+
const { live, stale } = await this.holder(threadId, runner);
|
|
512
|
+
if (live !== null) {
|
|
513
|
+
return void 0;
|
|
514
|
+
}
|
|
515
|
+
if (stale !== null) {
|
|
516
|
+
this.logger.warn(`thread ${threadId} was held by run ${stale}, which is no longer running`);
|
|
517
|
+
}
|
|
518
|
+
const plan = await this.plan({
|
|
519
|
+
threadId,
|
|
520
|
+
runId: stale,
|
|
521
|
+
outcome: "completed"
|
|
522
|
+
});
|
|
523
|
+
if (plan.next === void 0) {
|
|
524
|
+
return void 0;
|
|
525
|
+
}
|
|
526
|
+
const started = await this.launch(threadId, plan.next, (input, runId) => runner.start(input, {
|
|
527
|
+
runId
|
|
528
|
+
}));
|
|
529
|
+
if (started && plan.frame !== void 0) {
|
|
530
|
+
await this.write(plan.next.runId, plan.frame);
|
|
531
|
+
}
|
|
532
|
+
return started ? plan.next.runId : void 0;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Start a turn the thread is already claimed for. On failure the message goes back to the head of
|
|
536
|
+
* the queue, the queue pauses (`start_failed`), and the claim is released — nothing is lost and
|
|
537
|
+
* nothing is left holding the thread.
|
|
538
|
+
*/
|
|
539
|
+
async launch(threadId, next, start) {
|
|
540
|
+
this.starting.add(next.runId);
|
|
541
|
+
try {
|
|
542
|
+
await start(next.input, next.runId);
|
|
543
|
+
return true;
|
|
544
|
+
} catch (error) {
|
|
545
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
546
|
+
this.logger.error(`queued message ${next.messageId} could not start: ${message}`);
|
|
547
|
+
await this.restore(threadId, next, "start_failed", message);
|
|
548
|
+
return false;
|
|
549
|
+
} finally {
|
|
550
|
+
this.starting.delete(next.runId);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/** Put a turn that never started back at the head of its queue, paused, and free the thread. */
|
|
554
|
+
async restore(threadId, next, reason, message) {
|
|
555
|
+
const store = this.queueStore();
|
|
556
|
+
const { input } = next;
|
|
557
|
+
await store.enqueueMessage({
|
|
558
|
+
threadId,
|
|
559
|
+
actor: input.actor,
|
|
560
|
+
content: input.userText,
|
|
561
|
+
at: "head",
|
|
562
|
+
...input.attachments !== void 0 ? {
|
|
563
|
+
attachments: input.attachments
|
|
564
|
+
} : {},
|
|
565
|
+
...input.agentName !== void 0 ? {
|
|
566
|
+
agentName: input.agentName
|
|
567
|
+
} : {},
|
|
568
|
+
...input.model !== void 0 ? {
|
|
569
|
+
model: input.model
|
|
570
|
+
} : {},
|
|
571
|
+
...input.pageContext !== void 0 ? {
|
|
572
|
+
pageContext: input.pageContext
|
|
573
|
+
} : {}
|
|
574
|
+
});
|
|
575
|
+
await store.setQueuePause(threadId, {
|
|
576
|
+
reason,
|
|
577
|
+
message,
|
|
578
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
579
|
+
});
|
|
580
|
+
await store.releaseActiveStream(threadId, next.runId);
|
|
581
|
+
}
|
|
582
|
+
/** A `queue` frame with the thread's current state. */
|
|
583
|
+
async pausedFrame(threadId) {
|
|
584
|
+
return {
|
|
585
|
+
kind: "queue",
|
|
586
|
+
queue: await this.state(threadId)
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Tell whoever is watching the thread that its queue changed: a `queue` frame into the stream of
|
|
591
|
+
* the run holding it. Best-effort — a thread nobody is streaming has no one to tell, and the next
|
|
592
|
+
* read of the thread carries the queue anyway.
|
|
593
|
+
*/
|
|
594
|
+
async publish(threadId) {
|
|
595
|
+
const state = await this.state(threadId);
|
|
596
|
+
const holder = await this.queueStore().activeRunForThread(threadId);
|
|
597
|
+
if (holder !== null) {
|
|
598
|
+
await this.write(holder, {
|
|
599
|
+
kind: "queue",
|
|
600
|
+
queue: state
|
|
601
|
+
}).catch((error) => {
|
|
602
|
+
this.logger.warn(`could not publish the queue of thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
return state;
|
|
606
|
+
}
|
|
607
|
+
async write(runId, frame) {
|
|
608
|
+
const writer = await this.sink.open(runId);
|
|
609
|
+
await writer.write(encodeStreamEvent(frame));
|
|
610
|
+
}
|
|
611
|
+
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
612
|
+
async quotaBlock(actor) {
|
|
613
|
+
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
try {
|
|
617
|
+
const { blocked } = await this.quotaProvider.report({
|
|
618
|
+
actor
|
|
619
|
+
});
|
|
620
|
+
if (blocked === void 0) {
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
return blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`;
|
|
624
|
+
} catch {
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* The turn a queued message starts: everything it was queued with, today's date, and its
|
|
630
|
+
* attachments' urls minted afresh — the ones stored at enqueue time may have expired while it
|
|
631
|
+
* waited. An attachment the staging store no longer resolves keeps its stored url.
|
|
632
|
+
*/
|
|
633
|
+
async inputFor(message) {
|
|
634
|
+
const attachments = await this.freshAttachments(message.actor, message.attachments ?? []);
|
|
635
|
+
return {
|
|
636
|
+
threadId: message.threadId,
|
|
637
|
+
actor: message.actor,
|
|
638
|
+
userText: message.content,
|
|
639
|
+
day: utcDay(),
|
|
640
|
+
...message.agentName !== void 0 ? {
|
|
641
|
+
agentName: message.agentName
|
|
642
|
+
} : {},
|
|
643
|
+
...attachments.length > 0 ? {
|
|
644
|
+
attachments
|
|
645
|
+
} : {},
|
|
646
|
+
...message.pageContext !== void 0 ? {
|
|
647
|
+
pageContext: message.pageContext
|
|
648
|
+
} : {},
|
|
649
|
+
...message.model !== void 0 ? {
|
|
650
|
+
model: message.model
|
|
651
|
+
} : {}
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
async freshAttachments(actor, attachments) {
|
|
655
|
+
const staging = this.staging;
|
|
656
|
+
if (attachments.length === 0 || staging === void 0 || typeof staging.resolve !== "function") {
|
|
657
|
+
return attachments;
|
|
658
|
+
}
|
|
659
|
+
return Promise.all(attachments.map(async (attachment) => {
|
|
660
|
+
try {
|
|
661
|
+
return await staging.resolve({
|
|
662
|
+
mediaId: attachment.mediaId,
|
|
663
|
+
actor
|
|
664
|
+
}) ?? attachment;
|
|
665
|
+
} catch {
|
|
666
|
+
return attachment;
|
|
667
|
+
}
|
|
668
|
+
}));
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
ChatQueueService = _ts_decorate2([
|
|
672
|
+
Injectable2(),
|
|
673
|
+
_ts_param2(0, Inject2(AGENT_STORE2)),
|
|
674
|
+
_ts_param2(1, Inject2(AGENT_SINK2)),
|
|
675
|
+
_ts_param2(2, Optional2()),
|
|
676
|
+
_ts_param2(2, Inject2(AGENT_QUOTA_PROVIDER)),
|
|
677
|
+
_ts_param2(3, Optional2()),
|
|
678
|
+
_ts_param2(3, Inject2(AGENT_OPTIONS2)),
|
|
679
|
+
_ts_param2(4, Optional2()),
|
|
680
|
+
_ts_param2(4, Inject2(AGENT_ATTACHMENT_STAGING)),
|
|
681
|
+
_ts_metadata2("design:type", Function),
|
|
682
|
+
_ts_metadata2("design:paramtypes", [
|
|
683
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
684
|
+
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
685
|
+
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
686
|
+
typeof Pick === "undefined" ? Object : Pick,
|
|
687
|
+
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
|
|
688
|
+
])
|
|
689
|
+
], ChatQueueService);
|
|
690
|
+
function pauseReasonFor(outcome, head) {
|
|
691
|
+
if (outcome === "failed") {
|
|
692
|
+
return "run_failed";
|
|
693
|
+
}
|
|
694
|
+
if (outcome === "cancelled" && head.interrupt !== true) {
|
|
695
|
+
return "cancelled";
|
|
696
|
+
}
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
__name(pauseReasonFor, "pauseReasonFor");
|
|
700
|
+
function queueFrame(items, paused, started) {
|
|
701
|
+
return {
|
|
702
|
+
kind: "queue",
|
|
703
|
+
queue: {
|
|
704
|
+
items: items.map(queuedMessageView),
|
|
705
|
+
paused
|
|
706
|
+
},
|
|
707
|
+
...started !== void 0 ? {
|
|
708
|
+
started
|
|
709
|
+
} : {}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
__name(queueFrame, "queueFrame");
|
|
713
|
+
|
|
714
|
+
// src/agent.service.ts
|
|
715
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
716
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
717
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
718
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
719
|
+
} else {
|
|
720
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
721
|
+
if (d = decorators[i]) {
|
|
722
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
727
|
+
}
|
|
728
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
729
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
730
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
731
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
735
|
+
function _ts_param3(paramIndex, decorator) {
|
|
736
|
+
return function(target, key) {
|
|
737
|
+
decorator(target, key, paramIndex);
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
__name(_ts_param3, "_ts_param");
|
|
314
741
|
var AgentService = class {
|
|
315
742
|
static {
|
|
316
743
|
__name(this, "AgentService");
|
|
@@ -322,7 +749,8 @@ var AgentService = class {
|
|
|
322
749
|
models;
|
|
323
750
|
quotaProvider;
|
|
324
751
|
options;
|
|
325
|
-
|
|
752
|
+
queue;
|
|
753
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options, queue) {
|
|
326
754
|
this.runner = runner;
|
|
327
755
|
this.store = store;
|
|
328
756
|
this.deps = deps;
|
|
@@ -330,6 +758,19 @@ var AgentService = class {
|
|
|
330
758
|
this.models = models;
|
|
331
759
|
this.quotaProvider = quotaProvider;
|
|
332
760
|
this.options = options;
|
|
761
|
+
this.queue = queue;
|
|
762
|
+
}
|
|
763
|
+
/** The queue service when the bound store can hold a queue, else `undefined`. */
|
|
764
|
+
queueing() {
|
|
765
|
+
return this.queue?.supported === true ? this.queue : void 0;
|
|
766
|
+
}
|
|
767
|
+
/** The queue service, or a 501 naming what is missing. */
|
|
768
|
+
requireQueue() {
|
|
769
|
+
const queue = this.queueing();
|
|
770
|
+
if (queue === void 0) {
|
|
771
|
+
throw new NotImplementedException2("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
772
|
+
}
|
|
773
|
+
return queue;
|
|
333
774
|
}
|
|
334
775
|
/**
|
|
335
776
|
* The actor's budget across windows (`GET <base>/quota`) — the bound {@link QuotaProvider}'s
|
|
@@ -440,7 +881,44 @@ var AgentService = class {
|
|
|
440
881
|
}
|
|
441
882
|
return (await this.store.getThread(threadId))?.model ?? null;
|
|
442
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Start a turn — for in-process callers that need a run id back. A send that would have to wait
|
|
886
|
+
* (its thread already has a turn running) is refused with `409` instead; {@link send} is the form
|
|
887
|
+
* that queues it.
|
|
888
|
+
*/
|
|
443
889
|
async chat(params) {
|
|
890
|
+
const result = await this.send({
|
|
891
|
+
...params,
|
|
892
|
+
mode: "auto"
|
|
893
|
+
});
|
|
894
|
+
if (result.queued !== true) {
|
|
895
|
+
return result;
|
|
896
|
+
}
|
|
897
|
+
if (result.runId !== void 0) {
|
|
898
|
+
return {
|
|
899
|
+
runId: result.runId,
|
|
900
|
+
threadId: result.threadId
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
const store = this.requireQueue().queueStore();
|
|
904
|
+
if (!await store.removeQueuedMessage(result.messageId)) {
|
|
905
|
+
return {
|
|
906
|
+
runId: result.messageId,
|
|
907
|
+
threadId: result.threadId
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
await this.requireQueue().publish(result.threadId);
|
|
911
|
+
throw new ConflictException({
|
|
912
|
+
statusCode: 409,
|
|
913
|
+
code: "run_active",
|
|
914
|
+
message: `thread ${result.threadId} already has a turn running`
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
919
|
+
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
920
|
+
*/
|
|
921
|
+
async send(params) {
|
|
444
922
|
await this.assertWithinQuota(params.actor);
|
|
445
923
|
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
446
924
|
const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
|
|
@@ -457,7 +935,7 @@ var AgentService = class {
|
|
|
457
935
|
} : {}
|
|
458
936
|
});
|
|
459
937
|
threadId = created.id;
|
|
460
|
-
} else
|
|
938
|
+
} else {
|
|
461
939
|
await this.assertOwnsThread(params.actor, threadId);
|
|
462
940
|
}
|
|
463
941
|
const input = {
|
|
@@ -479,13 +957,195 @@ var AgentService = class {
|
|
|
479
957
|
model
|
|
480
958
|
} : {}
|
|
481
959
|
};
|
|
482
|
-
const
|
|
483
|
-
|
|
960
|
+
const queue = this.queueing();
|
|
961
|
+
if (queue === void 0) {
|
|
962
|
+
const { runId } = await this.runner.start(input);
|
|
963
|
+
await this.store.setActiveStream(threadId, runId);
|
|
964
|
+
return {
|
|
965
|
+
runId,
|
|
966
|
+
threadId
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
const mode = params.mode ?? "auto";
|
|
970
|
+
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
971
|
+
if (live === null && mode !== "queue") {
|
|
972
|
+
const runId = crypto.randomUUID();
|
|
973
|
+
if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
|
|
974
|
+
replacing: stale
|
|
975
|
+
} : {})) {
|
|
976
|
+
return {
|
|
977
|
+
runId: await this.startClaimed(input, runId),
|
|
978
|
+
threadId
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
if (params.regenerate === true) {
|
|
983
|
+
throw new ConflictException({
|
|
984
|
+
statusCode: 409,
|
|
985
|
+
code: "run_active",
|
|
986
|
+
message: "cannot regenerate while a turn is running on this thread"
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
return this.enqueue(queue, input, mode, live);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Start a turn the thread is already claimed for, under the claimed id. A runner that minted an
|
|
993
|
+
* id of its own anyway gets the thread re-pointed at it; one that fails to start frees the thread.
|
|
994
|
+
*/
|
|
995
|
+
async startClaimed(input, runId) {
|
|
996
|
+
const store = this.requireQueue().queueStore();
|
|
997
|
+
let started;
|
|
998
|
+
try {
|
|
999
|
+
started = (await this.runner.start(input, {
|
|
1000
|
+
runId
|
|
1001
|
+
})).runId;
|
|
1002
|
+
} catch (error) {
|
|
1003
|
+
await store.releaseActiveStream(input.threadId, runId);
|
|
1004
|
+
throw error;
|
|
1005
|
+
}
|
|
1006
|
+
if (started !== runId) {
|
|
1007
|
+
await store.claimActiveStream(input.threadId, started, {
|
|
1008
|
+
replacing: runId
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
return started;
|
|
1012
|
+
}
|
|
1013
|
+
/** Put a send in its thread's queue, then drain it if the thread turned out to be free. */
|
|
1014
|
+
async enqueue(queue, input, mode, live) {
|
|
1015
|
+
const store = queue.queueStore();
|
|
1016
|
+
const threadId = input.threadId;
|
|
1017
|
+
const interrupting = mode === "interrupt" && live !== null ? live : void 0;
|
|
1018
|
+
const queued = await store.enqueueMessage({
|
|
1019
|
+
threadId,
|
|
1020
|
+
actor: input.actor,
|
|
1021
|
+
content: input.userText,
|
|
1022
|
+
...input.attachments !== void 0 ? {
|
|
1023
|
+
attachments: input.attachments
|
|
1024
|
+
} : {},
|
|
1025
|
+
...input.agentName !== void 0 ? {
|
|
1026
|
+
agentName: input.agentName
|
|
1027
|
+
} : {},
|
|
1028
|
+
...input.model !== void 0 ? {
|
|
1029
|
+
model: input.model
|
|
1030
|
+
} : {},
|
|
1031
|
+
...input.pageContext !== void 0 ? {
|
|
1032
|
+
pageContext: input.pageContext
|
|
1033
|
+
} : {},
|
|
1034
|
+
...interrupting !== void 0 ? {
|
|
1035
|
+
interrupt: true,
|
|
1036
|
+
at: "head"
|
|
1037
|
+
} : {}
|
|
1038
|
+
});
|
|
1039
|
+
let runId;
|
|
1040
|
+
if (interrupting !== void 0) {
|
|
1041
|
+
await store.setQueuePause(threadId, null);
|
|
1042
|
+
await queue.publish(threadId);
|
|
1043
|
+
await this.runner.cancel(interrupting);
|
|
1044
|
+
} else {
|
|
1045
|
+
runId = await queue.kick(threadId, this.runner);
|
|
1046
|
+
if (runId === void 0) {
|
|
1047
|
+
await queue.publish(threadId);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
const state = await queue.state(threadId);
|
|
1051
|
+
const position = state.items.findIndex((item) => item.id === queued.id);
|
|
1052
|
+
return {
|
|
1053
|
+
threadId,
|
|
1054
|
+
queued: true,
|
|
1055
|
+
messageId: queued.id,
|
|
1056
|
+
position: position === -1 ? 0 : position,
|
|
1057
|
+
queue: state,
|
|
1058
|
+
...runId !== void 0 && runId === queued.id ? {
|
|
1059
|
+
runId
|
|
1060
|
+
} : {},
|
|
1061
|
+
...interrupting !== void 0 ? {
|
|
1062
|
+
interrupting
|
|
1063
|
+
} : {}
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
/** `GET <base>/threads/:id/queue` — the thread's waiting messages and whether it drains. */
|
|
1067
|
+
async getQueue(actor, threadId) {
|
|
1068
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1069
|
+
return this.requireQueue().state(threadId);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* `PATCH <base>/queue/:messageId` — change a waiting message's text and/or attachments, and/or move
|
|
1073
|
+
* it to `position` in the queue. Answers the thread's queue.
|
|
1074
|
+
*/
|
|
1075
|
+
async updateQueuedMessage(actor, messageId, patch) {
|
|
1076
|
+
const queue = this.requireQueue();
|
|
1077
|
+
const store = queue.queueStore();
|
|
1078
|
+
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1079
|
+
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
1080
|
+
throw new BadRequestException("message must not be empty");
|
|
1081
|
+
}
|
|
1082
|
+
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
1083
|
+
if (patch.message !== void 0 || attachments !== void 0) {
|
|
1084
|
+
const updated = await store.updateQueuedMessage(messageId, {
|
|
1085
|
+
...patch.message !== void 0 ? {
|
|
1086
|
+
content: patch.message
|
|
1087
|
+
} : {},
|
|
1088
|
+
...attachments !== void 0 ? {
|
|
1089
|
+
attachments
|
|
1090
|
+
} : {}
|
|
1091
|
+
});
|
|
1092
|
+
if (updated === null) {
|
|
1093
|
+
throw new GoneException(`queued message ${messageId} already started or was removed`);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (patch.position !== void 0) {
|
|
1097
|
+
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
1098
|
+
throw new BadRequestException("position must be a non-negative integer");
|
|
1099
|
+
}
|
|
1100
|
+
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
1101
|
+
throw new GoneException(`queued message ${messageId} already started or was removed`);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
return queue.publish(threadId);
|
|
1105
|
+
}
|
|
1106
|
+
/** `DELETE <base>/queue/:messageId` — drop a waiting message. Answers the thread's queue. */
|
|
1107
|
+
async removeQueuedMessage(actor, messageId) {
|
|
1108
|
+
const queue = this.requireQueue();
|
|
1109
|
+
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1110
|
+
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
1111
|
+
throw new GoneException(`queued message ${messageId} already started or was removed`);
|
|
1112
|
+
}
|
|
1113
|
+
return queue.publish(threadId);
|
|
1114
|
+
}
|
|
1115
|
+
/** `DELETE <base>/threads/:id/queue` — drop every waiting message (and any pause). */
|
|
1116
|
+
async clearQueue(actor, threadId) {
|
|
1117
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1118
|
+
const queue = this.requireQueue();
|
|
1119
|
+
await queue.queueStore().clearQueue(threadId);
|
|
1120
|
+
await queue.queueStore().setQueuePause(threadId, null);
|
|
1121
|
+
return queue.publish(threadId);
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* `POST <base>/threads/:id/queue/resume` — lift a pause and start the head when nothing is
|
|
1125
|
+
* running. Answers the queue, and the run the head started under, if it did.
|
|
1126
|
+
*/
|
|
1127
|
+
async resumeQueue(actor, threadId) {
|
|
1128
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1129
|
+
const queue = this.requireQueue();
|
|
1130
|
+
await queue.queueStore().setQueuePause(threadId, null);
|
|
1131
|
+
const runId = await queue.kick(threadId, this.runner);
|
|
1132
|
+
const state = runId === void 0 ? await queue.publish(threadId) : await queue.state(threadId);
|
|
484
1133
|
return {
|
|
485
|
-
|
|
486
|
-
|
|
1134
|
+
...state,
|
|
1135
|
+
...runId !== void 0 ? {
|
|
1136
|
+
runId
|
|
1137
|
+
} : {}
|
|
487
1138
|
};
|
|
488
1139
|
}
|
|
1140
|
+
/** The thread a queued message waits on, once the caller is shown to own it. */
|
|
1141
|
+
async assertOwnsQueuedMessage(actor, messageId) {
|
|
1142
|
+
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
1143
|
+
if (message === null) {
|
|
1144
|
+
throw new NotFoundException(`queued message ${messageId} not found`);
|
|
1145
|
+
}
|
|
1146
|
+
await this.assertOwnsThread(actor, message.threadId);
|
|
1147
|
+
return message.threadId;
|
|
1148
|
+
}
|
|
489
1149
|
/**
|
|
490
1150
|
* Rebuild this turn's attachments from the staging store, keyed by the ids the caller claimed.
|
|
491
1151
|
* The model provider fetches {@link MessageAttachment.url} verbatim, so that url is only ever
|
|
@@ -502,7 +1162,7 @@ var AgentService = class {
|
|
|
502
1162
|
}
|
|
503
1163
|
const staging = this.staging;
|
|
504
1164
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
505
|
-
throw new
|
|
1165
|
+
throw new NotImplementedException2("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
506
1166
|
}
|
|
507
1167
|
const resolved = [];
|
|
508
1168
|
for (const ref of refs) {
|
|
@@ -660,7 +1320,7 @@ var AgentService = class {
|
|
|
660
1320
|
return;
|
|
661
1321
|
}
|
|
662
1322
|
if (this.store.updateThread === void 0) {
|
|
663
|
-
throw new
|
|
1323
|
+
throw new NotImplementedException2("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
664
1324
|
}
|
|
665
1325
|
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);
|
|
666
1326
|
await this.store.updateThread(threadId, {
|
|
@@ -725,9 +1385,13 @@ var AgentService = class {
|
|
|
725
1385
|
}
|
|
726
1386
|
async toDetailView(thread, actor) {
|
|
727
1387
|
const summary = await this.toSummaryView(thread);
|
|
1388
|
+
const queue = this.queueing();
|
|
728
1389
|
return {
|
|
729
1390
|
...summary,
|
|
730
|
-
messages: await this.freshAttachmentUrls(thread.messages, actor)
|
|
1391
|
+
messages: await this.freshAttachmentUrls(thread.messages, actor),
|
|
1392
|
+
...queue !== void 0 ? {
|
|
1393
|
+
queue: await queue.state(thread.id)
|
|
1394
|
+
} : {}
|
|
731
1395
|
};
|
|
732
1396
|
}
|
|
733
1397
|
/**
|
|
@@ -790,7 +1454,7 @@ var AgentService = class {
|
|
|
790
1454
|
throw new BadRequestException("comment must be at most 2000 characters");
|
|
791
1455
|
}
|
|
792
1456
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
793
|
-
throw new
|
|
1457
|
+
throw new NotImplementedException2("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
794
1458
|
}
|
|
795
1459
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
796
1460
|
if (threadId === null) {
|
|
@@ -842,7 +1506,7 @@ var AgentService = class {
|
|
|
842
1506
|
const list = this.attachmentInventory();
|
|
843
1507
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
844
1508
|
if (referencedMediaIds === void 0) {
|
|
845
|
-
throw new
|
|
1509
|
+
throw new NotImplementedException2("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
|
|
846
1510
|
}
|
|
847
1511
|
const stagedBefore = options.olderThan.toISOString();
|
|
848
1512
|
const inventory = await list({
|
|
@@ -864,7 +1528,7 @@ var AgentService = class {
|
|
|
864
1528
|
attachmentInventory() {
|
|
865
1529
|
const list = this.staging?.list?.bind(this.staging);
|
|
866
1530
|
if (list === void 0) {
|
|
867
|
-
throw new
|
|
1531
|
+
throw new NotImplementedException2("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
|
|
868
1532
|
}
|
|
869
1533
|
return list;
|
|
870
1534
|
}
|
|
@@ -982,34 +1646,36 @@ var AgentService = class {
|
|
|
982
1646
|
}
|
|
983
1647
|
}
|
|
984
1648
|
};
|
|
985
|
-
AgentService =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1649
|
+
AgentService = _ts_decorate3([
|
|
1650
|
+
Injectable3(),
|
|
1651
|
+
_ts_param3(0, Inject3(AGENT_RUNNER)),
|
|
1652
|
+
_ts_param3(1, Inject3(AGENT_STORE3)),
|
|
1653
|
+
_ts_param3(2, Inject3(AGENT_DEPS_FACTORY)),
|
|
1654
|
+
_ts_param3(3, Optional3()),
|
|
1655
|
+
_ts_param3(3, Inject3(AGENT_ATTACHMENT_STAGING2)),
|
|
1656
|
+
_ts_param3(4, Optional3()),
|
|
1657
|
+
_ts_param3(4, Inject3(AGENT_MODEL_CATALOG)),
|
|
1658
|
+
_ts_param3(5, Optional3()),
|
|
1659
|
+
_ts_param3(5, Inject3(AGENT_QUOTA_PROVIDER2)),
|
|
1660
|
+
_ts_param3(6, Optional3()),
|
|
1661
|
+
_ts_param3(6, Inject3(AGENT_OPTIONS3)),
|
|
1662
|
+
_ts_param3(7, Optional3()),
|
|
1663
|
+
_ts_metadata3("design:type", Function),
|
|
1664
|
+
_ts_metadata3("design:paramtypes", [
|
|
1000
1665
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1001
1666
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1002
1667
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1003
1668
|
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1004
1669
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1005
1670
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
1006
|
-
typeof Pick === "undefined" ? Object : Pick
|
|
1671
|
+
typeof Pick === "undefined" ? Object : Pick,
|
|
1672
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
1007
1673
|
])
|
|
1008
1674
|
], AgentService);
|
|
1009
1675
|
|
|
1010
1676
|
// src/approval-port.adapter.ts
|
|
1011
|
-
import { Injectable as
|
|
1012
|
-
function
|
|
1677
|
+
import { Injectable as Injectable4 } from "@nestjs/common";
|
|
1678
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1013
1679
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1014
1680
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1015
1681
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1022,13 +1688,13 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1022
1688
|
}
|
|
1023
1689
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1024
1690
|
}
|
|
1025
|
-
__name(
|
|
1026
|
-
function
|
|
1691
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
1692
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
1027
1693
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1028
1694
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1029
1695
|
}
|
|
1030
1696
|
}
|
|
1031
|
-
__name(
|
|
1697
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1032
1698
|
var AgentApprovalPortAdapter = class {
|
|
1033
1699
|
static {
|
|
1034
1700
|
__name(this, "AgentApprovalPortAdapter");
|
|
@@ -1066,18 +1732,18 @@ var AgentApprovalPortAdapter = class {
|
|
|
1066
1732
|
});
|
|
1067
1733
|
}
|
|
1068
1734
|
};
|
|
1069
|
-
AgentApprovalPortAdapter =
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1735
|
+
AgentApprovalPortAdapter = _ts_decorate4([
|
|
1736
|
+
Injectable4(),
|
|
1737
|
+
_ts_metadata4("design:type", Function),
|
|
1738
|
+
_ts_metadata4("design:paramtypes", [
|
|
1073
1739
|
typeof AgentService === "undefined" ? Object : AgentService
|
|
1074
1740
|
])
|
|
1075
1741
|
], AgentApprovalPortAdapter);
|
|
1076
1742
|
|
|
1077
1743
|
// src/controller/agents.controller.ts
|
|
1078
1744
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
1079
|
-
import { Controller, Get, Inject as
|
|
1080
|
-
function
|
|
1745
|
+
import { Controller, Get, Inject as Inject4 } from "@nestjs/common";
|
|
1746
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1081
1747
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1082
1748
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1083
1749
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1090,19 +1756,19 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
1090
1756
|
}
|
|
1091
1757
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1092
1758
|
}
|
|
1093
|
-
__name(
|
|
1094
|
-
function
|
|
1759
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1760
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
1095
1761
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1096
1762
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1097
1763
|
}
|
|
1098
1764
|
}
|
|
1099
|
-
__name(
|
|
1100
|
-
function
|
|
1765
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1766
|
+
function _ts_param4(paramIndex, decorator) {
|
|
1101
1767
|
return function(target, key) {
|
|
1102
1768
|
decorator(target, key, paramIndex);
|
|
1103
1769
|
};
|
|
1104
1770
|
}
|
|
1105
|
-
__name(
|
|
1771
|
+
__name(_ts_param4, "_ts_param");
|
|
1106
1772
|
var AgentsController = class {
|
|
1107
1773
|
static {
|
|
1108
1774
|
__name(this, "AgentsController");
|
|
@@ -1124,26 +1790,26 @@ var AgentsController = class {
|
|
|
1124
1790
|
}));
|
|
1125
1791
|
}
|
|
1126
1792
|
};
|
|
1127
|
-
|
|
1793
|
+
_ts_decorate5([
|
|
1128
1794
|
Get(),
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1795
|
+
_ts_metadata5("design:type", Function),
|
|
1796
|
+
_ts_metadata5("design:paramtypes", []),
|
|
1797
|
+
_ts_metadata5("design:returntype", Array)
|
|
1132
1798
|
], AgentsController.prototype, "list", null);
|
|
1133
|
-
AgentsController =
|
|
1799
|
+
AgentsController = _ts_decorate5([
|
|
1134
1800
|
Controller("agents"),
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1801
|
+
_ts_param4(0, Inject4(AGENT_REGISTRY2)),
|
|
1802
|
+
_ts_param4(1, Inject4(AGENT_DEPS_FACTORY2)),
|
|
1803
|
+
_ts_metadata5("design:type", Function),
|
|
1804
|
+
_ts_metadata5("design:paramtypes", [
|
|
1139
1805
|
typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
|
|
1140
1806
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
1141
1807
|
])
|
|
1142
1808
|
], AgentsController);
|
|
1143
1809
|
|
|
1144
1810
|
// src/controller/attachments.controller.ts
|
|
1145
|
-
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as
|
|
1146
|
-
import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as
|
|
1811
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
|
|
1812
|
+
import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as Inject5, NotImplementedException as NotImplementedException3, Optional as Optional4, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
1147
1813
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
1148
1814
|
|
|
1149
1815
|
// src/attachment-limits.ts
|
|
@@ -1172,7 +1838,7 @@ function attachmentLimits(options, staging) {
|
|
|
1172
1838
|
__name(attachmentLimits, "attachmentLimits");
|
|
1173
1839
|
|
|
1174
1840
|
// src/controller/attachments.controller.ts
|
|
1175
|
-
function
|
|
1841
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1176
1842
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1177
1843
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1178
1844
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1185,19 +1851,19 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1185
1851
|
}
|
|
1186
1852
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1187
1853
|
}
|
|
1188
|
-
__name(
|
|
1189
|
-
function
|
|
1854
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1855
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
1190
1856
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1191
1857
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1192
1858
|
}
|
|
1193
1859
|
}
|
|
1194
|
-
__name(
|
|
1195
|
-
function
|
|
1860
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1861
|
+
function _ts_param5(paramIndex, decorator) {
|
|
1196
1862
|
return function(target, key) {
|
|
1197
1863
|
decorator(target, key, paramIndex);
|
|
1198
1864
|
};
|
|
1199
1865
|
}
|
|
1200
|
-
__name(
|
|
1866
|
+
__name(_ts_param5, "_ts_param");
|
|
1201
1867
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
1202
1868
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
1203
1869
|
var AttachmentsController = class {
|
|
@@ -1231,7 +1897,7 @@ var AttachmentsController = class {
|
|
|
1231
1897
|
}
|
|
1232
1898
|
async upload(req, file) {
|
|
1233
1899
|
if (this.staging === void 0) {
|
|
1234
|
-
throw new
|
|
1900
|
+
throw new NotImplementedException3("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
1235
1901
|
}
|
|
1236
1902
|
if (file === void 0) {
|
|
1237
1903
|
throw new BadRequestException2('multipart field "file" is required');
|
|
@@ -1253,39 +1919,39 @@ var AttachmentsController = class {
|
|
|
1253
1919
|
});
|
|
1254
1920
|
}
|
|
1255
1921
|
};
|
|
1256
|
-
|
|
1922
|
+
_ts_decorate6([
|
|
1257
1923
|
Get2(),
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1924
|
+
_ts_param5(0, Req()),
|
|
1925
|
+
_ts_metadata6("design:type", Function),
|
|
1926
|
+
_ts_metadata6("design:paramtypes", [
|
|
1261
1927
|
typeof Request === "undefined" ? Object : Request
|
|
1262
1928
|
]),
|
|
1263
|
-
|
|
1929
|
+
_ts_metadata6("design:returntype", Promise)
|
|
1264
1930
|
], AttachmentsController.prototype, "list", null);
|
|
1265
|
-
|
|
1931
|
+
_ts_decorate6([
|
|
1266
1932
|
Post(),
|
|
1267
1933
|
UseInterceptors(FileInterceptor("file", {
|
|
1268
1934
|
limits: {
|
|
1269
1935
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
1270
1936
|
}
|
|
1271
1937
|
})),
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1938
|
+
_ts_param5(0, Req()),
|
|
1939
|
+
_ts_param5(1, UploadedFile()),
|
|
1940
|
+
_ts_metadata6("design:type", Function),
|
|
1941
|
+
_ts_metadata6("design:paramtypes", [
|
|
1276
1942
|
typeof Request === "undefined" ? Object : Request,
|
|
1277
1943
|
Object
|
|
1278
1944
|
]),
|
|
1279
|
-
|
|
1945
|
+
_ts_metadata6("design:returntype", Promise)
|
|
1280
1946
|
], AttachmentsController.prototype, "upload", null);
|
|
1281
|
-
AttachmentsController =
|
|
1947
|
+
AttachmentsController = _ts_decorate6([
|
|
1282
1948
|
Controller2("attachments"),
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1949
|
+
_ts_param5(0, Inject5(AGENT_OPTIONS4)),
|
|
1950
|
+
_ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER)),
|
|
1951
|
+
_ts_param5(3, Optional4()),
|
|
1952
|
+
_ts_param5(3, Inject5(AGENT_ATTACHMENT_STAGING3)),
|
|
1953
|
+
_ts_metadata6("design:type", Function),
|
|
1954
|
+
_ts_metadata6("design:paramtypes", [
|
|
1289
1955
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
1290
1956
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1291
1957
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -1295,8 +1961,8 @@ AttachmentsController = _ts_decorate5([
|
|
|
1295
1961
|
|
|
1296
1962
|
// src/controller/chat.controller.ts
|
|
1297
1963
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError } from "@dudousxd/nestjs-agent-core";
|
|
1298
|
-
import { BadRequestException as BadRequestException3, Body, Controller as Controller3, Get as Get3, Inject as
|
|
1299
|
-
function
|
|
1964
|
+
import { BadRequestException as BadRequestException3, Body, Controller as Controller3, Get as Get3, Inject as Inject6, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
|
|
1965
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1300
1966
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1301
1967
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1302
1968
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1309,19 +1975,32 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1309
1975
|
}
|
|
1310
1976
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1311
1977
|
}
|
|
1312
|
-
__name(
|
|
1313
|
-
function
|
|
1978
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1979
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
1314
1980
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1315
1981
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1316
1982
|
}
|
|
1317
1983
|
}
|
|
1318
|
-
__name(
|
|
1319
|
-
function
|
|
1984
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1985
|
+
function _ts_param6(paramIndex, decorator) {
|
|
1320
1986
|
return function(target, key) {
|
|
1321
1987
|
decorator(target, key, paramIndex);
|
|
1322
1988
|
};
|
|
1323
1989
|
}
|
|
1324
|
-
__name(
|
|
1990
|
+
__name(_ts_param6, "_ts_param");
|
|
1991
|
+
function sendMode(body) {
|
|
1992
|
+
if (body.interrupt === true) {
|
|
1993
|
+
return "interrupt";
|
|
1994
|
+
}
|
|
1995
|
+
if (body.mode === void 0 || body.mode === null) {
|
|
1996
|
+
return "auto";
|
|
1997
|
+
}
|
|
1998
|
+
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
1999
|
+
return body.mode;
|
|
2000
|
+
}
|
|
2001
|
+
throw new BadRequestException3("mode must be 'auto', 'queue' or 'interrupt'");
|
|
2002
|
+
}
|
|
2003
|
+
__name(sendMode, "sendMode");
|
|
1325
2004
|
function attachmentRefs(claimed) {
|
|
1326
2005
|
if (claimed === void 0) {
|
|
1327
2006
|
return [];
|
|
@@ -1359,10 +2038,17 @@ var ChatController = class {
|
|
|
1359
2038
|
this.agent = agent;
|
|
1360
2039
|
this.actorResolver = actorResolver;
|
|
1361
2040
|
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Start a turn and stream it — or, when the thread already has one running, queue the message and
|
|
2043
|
+
* answer `202 { queued: true, messageId, position, queue, … }` (JSON, no stream): it runs when the
|
|
2044
|
+
* turn ahead of it settles, and the stream of the run holding the thread announces it with a
|
|
2045
|
+
* `queue` frame.
|
|
2046
|
+
*/
|
|
1362
2047
|
async chat(req, res, body) {
|
|
1363
2048
|
const actor = await this.actorResolver.resolve(req);
|
|
1364
2049
|
const attachments = attachmentRefs(body.attachments);
|
|
1365
|
-
const
|
|
2050
|
+
const mode = sendMode(body);
|
|
2051
|
+
const result = await this.agent.send({
|
|
1366
2052
|
actor,
|
|
1367
2053
|
message: body.message,
|
|
1368
2054
|
...body.threadId !== void 0 ? {
|
|
@@ -1385,8 +2071,14 @@ var ChatController = class {
|
|
|
1385
2071
|
} : {},
|
|
1386
2072
|
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
1387
2073
|
model: body.model
|
|
1388
|
-
} : {}
|
|
2074
|
+
} : {},
|
|
2075
|
+
mode
|
|
1389
2076
|
});
|
|
2077
|
+
if (result.queued === true) {
|
|
2078
|
+
res.status(202).json(result);
|
|
2079
|
+
return;
|
|
2080
|
+
}
|
|
2081
|
+
const { runId, threadId } = result;
|
|
1390
2082
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
1391
2083
|
}
|
|
1392
2084
|
/**
|
|
@@ -1476,50 +2168,50 @@ data: ${JSON.stringify(payload)}
|
|
|
1476
2168
|
res.end();
|
|
1477
2169
|
}
|
|
1478
2170
|
};
|
|
1479
|
-
|
|
2171
|
+
_ts_decorate7([
|
|
1480
2172
|
Post2("chat"),
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
2173
|
+
_ts_param6(0, Req2()),
|
|
2174
|
+
_ts_param6(1, Res()),
|
|
2175
|
+
_ts_param6(2, Body()),
|
|
2176
|
+
_ts_metadata7("design:type", Function),
|
|
2177
|
+
_ts_metadata7("design:paramtypes", [
|
|
1486
2178
|
typeof Request === "undefined" ? Object : Request,
|
|
1487
2179
|
typeof Response === "undefined" ? Object : Response,
|
|
1488
2180
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
1489
2181
|
]),
|
|
1490
|
-
|
|
2182
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1491
2183
|
], ChatController.prototype, "chat", null);
|
|
1492
|
-
|
|
2184
|
+
_ts_decorate7([
|
|
1493
2185
|
Get3("chat/:runId/stream"),
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
2186
|
+
_ts_param6(0, Req2()),
|
|
2187
|
+
_ts_param6(1, Param("runId")),
|
|
2188
|
+
_ts_param6(2, Res()),
|
|
2189
|
+
_ts_param6(3, Query("after")),
|
|
2190
|
+
_ts_metadata7("design:type", Function),
|
|
2191
|
+
_ts_metadata7("design:paramtypes", [
|
|
1500
2192
|
typeof Request === "undefined" ? Object : Request,
|
|
1501
2193
|
String,
|
|
1502
2194
|
typeof Response === "undefined" ? Object : Response,
|
|
1503
2195
|
String
|
|
1504
2196
|
]),
|
|
1505
|
-
|
|
2197
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1506
2198
|
], ChatController.prototype, "stream", null);
|
|
1507
|
-
|
|
2199
|
+
_ts_decorate7([
|
|
1508
2200
|
Post2("chat/:runId/cancel"),
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
2201
|
+
_ts_param6(0, Req2()),
|
|
2202
|
+
_ts_param6(1, Param("runId")),
|
|
2203
|
+
_ts_metadata7("design:type", Function),
|
|
2204
|
+
_ts_metadata7("design:paramtypes", [
|
|
1513
2205
|
typeof Request === "undefined" ? Object : Request,
|
|
1514
2206
|
String
|
|
1515
2207
|
]),
|
|
1516
|
-
|
|
2208
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1517
2209
|
], ChatController.prototype, "cancel", null);
|
|
1518
|
-
ChatController =
|
|
2210
|
+
ChatController = _ts_decorate7([
|
|
1519
2211
|
Controller3(),
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
2212
|
+
_ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER2)),
|
|
2213
|
+
_ts_metadata7("design:type", Function),
|
|
2214
|
+
_ts_metadata7("design:paramtypes", [
|
|
1523
2215
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1524
2216
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1525
2217
|
])
|
|
@@ -1535,8 +2227,8 @@ function parseCursor(raw) {
|
|
|
1535
2227
|
__name(parseCursor, "parseCursor");
|
|
1536
2228
|
|
|
1537
2229
|
// src/controller/config.controller.ts
|
|
1538
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as
|
|
1539
|
-
import { Controller as Controller4, Get as Get4, Inject as
|
|
2230
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING4, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS5 } from "@dudousxd/nestjs-agent-core";
|
|
2231
|
+
import { Controller as Controller4, Get as Get4, Inject as Inject7, Optional as Optional5, Req as Req3 } from "@nestjs/common";
|
|
1540
2232
|
|
|
1541
2233
|
// src/resolver/anonymous-actor-resolver.ts
|
|
1542
2234
|
import { createHash, randomBytes } from "crypto";
|
|
@@ -1626,7 +2318,7 @@ var AnonymousActorResolver = class {
|
|
|
1626
2318
|
};
|
|
1627
2319
|
|
|
1628
2320
|
// src/controller/config.controller.ts
|
|
1629
|
-
function
|
|
2321
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1630
2322
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1631
2323
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1632
2324
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1639,19 +2331,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1639
2331
|
}
|
|
1640
2332
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1641
2333
|
}
|
|
1642
|
-
__name(
|
|
1643
|
-
function
|
|
2334
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2335
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
1644
2336
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1645
2337
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1646
2338
|
}
|
|
1647
2339
|
}
|
|
1648
|
-
__name(
|
|
1649
|
-
function
|
|
2340
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2341
|
+
function _ts_param7(paramIndex, decorator) {
|
|
1650
2342
|
return function(target, key) {
|
|
1651
2343
|
decorator(target, key, paramIndex);
|
|
1652
2344
|
};
|
|
1653
2345
|
}
|
|
1654
|
-
__name(
|
|
2346
|
+
__name(_ts_param7, "_ts_param");
|
|
1655
2347
|
var ConfigController = class {
|
|
1656
2348
|
static {
|
|
1657
2349
|
__name(this, "ConfigController");
|
|
@@ -1682,25 +2374,25 @@ var ConfigController = class {
|
|
|
1682
2374
|
};
|
|
1683
2375
|
}
|
|
1684
2376
|
};
|
|
1685
|
-
|
|
2377
|
+
_ts_decorate8([
|
|
1686
2378
|
Get4(),
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
2379
|
+
_ts_param7(0, Req3()),
|
|
2380
|
+
_ts_metadata8("design:type", Function),
|
|
2381
|
+
_ts_metadata8("design:paramtypes", [
|
|
1690
2382
|
typeof Request === "undefined" ? Object : Request
|
|
1691
2383
|
]),
|
|
1692
|
-
|
|
2384
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1693
2385
|
], ConfigController.prototype, "config", null);
|
|
1694
|
-
ConfigController =
|
|
2386
|
+
ConfigController = _ts_decorate8([
|
|
1695
2387
|
Controller4("config"),
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
2388
|
+
_ts_param7(0, Inject7(AGENT_OPTIONS5)),
|
|
2389
|
+
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER3)),
|
|
2390
|
+
_ts_param7(2, Optional5()),
|
|
2391
|
+
_ts_param7(2, Inject7(AGENT_ATTACHMENT_STAGING4)),
|
|
2392
|
+
_ts_param7(3, Optional5()),
|
|
2393
|
+
_ts_param7(3, Inject7(AGENT_MODEL_CATALOG2)),
|
|
2394
|
+
_ts_metadata8("design:type", Function),
|
|
2395
|
+
_ts_metadata8("design:paramtypes", [
|
|
1704
2396
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
1705
2397
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1706
2398
|
Object,
|
|
@@ -1710,8 +2402,8 @@ ConfigController = _ts_decorate7([
|
|
|
1710
2402
|
|
|
1711
2403
|
// src/controller/memories.controller.ts
|
|
1712
2404
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
|
|
1713
|
-
import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException2, Get as Get5, Inject as
|
|
1714
|
-
function
|
|
2405
|
+
import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException2, Get as Get5, Inject as Inject8, NotFoundException as NotFoundException2, Optional as Optional6, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
|
|
2406
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1715
2407
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1716
2408
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1717
2409
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1724,19 +2416,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1724
2416
|
}
|
|
1725
2417
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1726
2418
|
}
|
|
1727
|
-
__name(
|
|
1728
|
-
function
|
|
2419
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2420
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
1729
2421
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1730
2422
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1731
2423
|
}
|
|
1732
2424
|
}
|
|
1733
|
-
__name(
|
|
1734
|
-
function
|
|
2425
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2426
|
+
function _ts_param8(paramIndex, decorator) {
|
|
1735
2427
|
return function(target, key) {
|
|
1736
2428
|
decorator(target, key, paramIndex);
|
|
1737
2429
|
};
|
|
1738
2430
|
}
|
|
1739
|
-
__name(
|
|
2431
|
+
__name(_ts_param8, "_ts_param");
|
|
1740
2432
|
var MemoriesController = class {
|
|
1741
2433
|
static {
|
|
1742
2434
|
__name(this, "MemoriesController");
|
|
@@ -1809,35 +2501,35 @@ var MemoriesController = class {
|
|
|
1809
2501
|
});
|
|
1810
2502
|
}
|
|
1811
2503
|
};
|
|
1812
|
-
|
|
2504
|
+
_ts_decorate9([
|
|
1813
2505
|
Get5(),
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
2506
|
+
_ts_param8(0, Req4()),
|
|
2507
|
+
_ts_param8(1, Query2("threadId")),
|
|
2508
|
+
_ts_metadata9("design:type", Function),
|
|
2509
|
+
_ts_metadata9("design:paramtypes", [
|
|
1818
2510
|
typeof Request === "undefined" ? Object : Request,
|
|
1819
2511
|
String
|
|
1820
2512
|
]),
|
|
1821
|
-
|
|
2513
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1822
2514
|
], MemoriesController.prototype, "list", null);
|
|
1823
|
-
|
|
2515
|
+
_ts_decorate9([
|
|
1824
2516
|
Delete(":id"),
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2517
|
+
_ts_param8(0, Req4()),
|
|
2518
|
+
_ts_param8(1, Param2("id")),
|
|
2519
|
+
_ts_metadata9("design:type", Function),
|
|
2520
|
+
_ts_metadata9("design:paramtypes", [
|
|
1829
2521
|
typeof Request === "undefined" ? Object : Request,
|
|
1830
2522
|
String
|
|
1831
2523
|
]),
|
|
1832
|
-
|
|
2524
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1833
2525
|
], MemoriesController.prototype, "forget", null);
|
|
1834
|
-
MemoriesController =
|
|
2526
|
+
MemoriesController = _ts_decorate9([
|
|
1835
2527
|
Controller5("memories"),
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
2528
|
+
_ts_param8(0, Inject8(AGENT_ACTOR_RESOLVER4)),
|
|
2529
|
+
_ts_param8(1, Optional6()),
|
|
2530
|
+
_ts_param8(1, Inject8(AGENT_MEMORY2)),
|
|
2531
|
+
_ts_metadata9("design:type", Function),
|
|
2532
|
+
_ts_metadata9("design:paramtypes", [
|
|
1841
2533
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1842
2534
|
Object
|
|
1843
2535
|
])
|
|
@@ -1845,8 +2537,8 @@ MemoriesController = _ts_decorate8([
|
|
|
1845
2537
|
|
|
1846
2538
|
// src/controller/messages.controller.ts
|
|
1847
2539
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
1848
|
-
import { Body as Body2, Controller as Controller6, HttpCode, Inject as
|
|
1849
|
-
function
|
|
2540
|
+
import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject9, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
|
|
2541
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1850
2542
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1851
2543
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1852
2544
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1859,19 +2551,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
1859
2551
|
}
|
|
1860
2552
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1861
2553
|
}
|
|
1862
|
-
__name(
|
|
1863
|
-
function
|
|
2554
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
2555
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
1864
2556
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1865
2557
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1866
2558
|
}
|
|
1867
2559
|
}
|
|
1868
|
-
__name(
|
|
1869
|
-
function
|
|
2560
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2561
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1870
2562
|
return function(target, key) {
|
|
1871
2563
|
decorator(target, key, paramIndex);
|
|
1872
2564
|
};
|
|
1873
2565
|
}
|
|
1874
|
-
__name(
|
|
2566
|
+
__name(_ts_param9, "_ts_param");
|
|
1875
2567
|
var MessagesController = class {
|
|
1876
2568
|
static {
|
|
1877
2569
|
__name(this, "MessagesController");
|
|
@@ -1899,25 +2591,25 @@ var MessagesController = class {
|
|
|
1899
2591
|
};
|
|
1900
2592
|
}
|
|
1901
2593
|
};
|
|
1902
|
-
|
|
2594
|
+
_ts_decorate10([
|
|
1903
2595
|
Post3(":id/feedback"),
|
|
1904
2596
|
HttpCode(200),
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
2597
|
+
_ts_param9(0, Req5()),
|
|
2598
|
+
_ts_param9(1, Param3("id")),
|
|
2599
|
+
_ts_param9(2, Body2()),
|
|
2600
|
+
_ts_metadata10("design:type", Function),
|
|
2601
|
+
_ts_metadata10("design:paramtypes", [
|
|
1910
2602
|
typeof Request === "undefined" ? Object : Request,
|
|
1911
2603
|
String,
|
|
1912
2604
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
1913
2605
|
]),
|
|
1914
|
-
|
|
2606
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1915
2607
|
], MessagesController.prototype, "feedback", null);
|
|
1916
|
-
MessagesController =
|
|
2608
|
+
MessagesController = _ts_decorate10([
|
|
1917
2609
|
Controller6("messages"),
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2610
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER5)),
|
|
2611
|
+
_ts_metadata10("design:type", Function),
|
|
2612
|
+
_ts_metadata10("design:paramtypes", [
|
|
1921
2613
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1922
2614
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1923
2615
|
])
|
|
@@ -1925,8 +2617,8 @@ MessagesController = _ts_decorate9([
|
|
|
1925
2617
|
|
|
1926
2618
|
// src/controller/models.controller.ts
|
|
1927
2619
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
|
|
1928
|
-
import { Controller as Controller7, Get as Get6, Inject as
|
|
1929
|
-
function
|
|
2620
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject10, Query as Query3, Req as Req6 } from "@nestjs/common";
|
|
2621
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1930
2622
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1931
2623
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1932
2624
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1939,19 +2631,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1939
2631
|
}
|
|
1940
2632
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1941
2633
|
}
|
|
1942
|
-
__name(
|
|
1943
|
-
function
|
|
2634
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2635
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
1944
2636
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1945
2637
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1946
2638
|
}
|
|
1947
2639
|
}
|
|
1948
|
-
__name(
|
|
1949
|
-
function
|
|
2640
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2641
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1950
2642
|
return function(target, key) {
|
|
1951
2643
|
decorator(target, key, paramIndex);
|
|
1952
2644
|
};
|
|
1953
2645
|
}
|
|
1954
|
-
__name(
|
|
2646
|
+
__name(_ts_param10, "_ts_param");
|
|
1955
2647
|
var ModelsController = class {
|
|
1956
2648
|
static {
|
|
1957
2649
|
__name(this, "ModelsController");
|
|
@@ -1971,31 +2663,31 @@ var ModelsController = class {
|
|
|
1971
2663
|
return this.agent.listModels(actor, agent);
|
|
1972
2664
|
}
|
|
1973
2665
|
};
|
|
1974
|
-
|
|
2666
|
+
_ts_decorate11([
|
|
1975
2667
|
Get6(),
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2668
|
+
_ts_param10(0, Req6()),
|
|
2669
|
+
_ts_param10(1, Query3("agent")),
|
|
2670
|
+
_ts_metadata11("design:type", Function),
|
|
2671
|
+
_ts_metadata11("design:paramtypes", [
|
|
1980
2672
|
typeof Request === "undefined" ? Object : Request,
|
|
1981
2673
|
String
|
|
1982
2674
|
]),
|
|
1983
|
-
|
|
2675
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1984
2676
|
], ModelsController.prototype, "list", null);
|
|
1985
|
-
ModelsController =
|
|
2677
|
+
ModelsController = _ts_decorate11([
|
|
1986
2678
|
Controller7("models"),
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2679
|
+
_ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER6)),
|
|
2680
|
+
_ts_metadata11("design:type", Function),
|
|
2681
|
+
_ts_metadata11("design:paramtypes", [
|
|
1990
2682
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1991
2683
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1992
2684
|
])
|
|
1993
2685
|
], ModelsController);
|
|
1994
2686
|
|
|
1995
|
-
// src/controller/
|
|
2687
|
+
// src/controller/queue.controller.ts
|
|
1996
2688
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
|
|
1997
|
-
import { Controller as Controller8, Get as Get7, Inject as
|
|
1998
|
-
function
|
|
2689
|
+
import { BadRequestException as BadRequestException4, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as Inject11, Param as Param4, Patch, Post as Post4, Req as Req7 } from "@nestjs/common";
|
|
2690
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1999
2691
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2000
2692
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2001
2693
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2008,19 +2700,160 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
2008
2700
|
}
|
|
2009
2701
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2010
2702
|
}
|
|
2011
|
-
__name(
|
|
2012
|
-
function
|
|
2703
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2704
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
2013
2705
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2014
2706
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2015
2707
|
}
|
|
2016
2708
|
}
|
|
2017
|
-
__name(
|
|
2018
|
-
function
|
|
2709
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2710
|
+
function _ts_param11(paramIndex, decorator) {
|
|
2019
2711
|
return function(target, key) {
|
|
2020
2712
|
decorator(target, key, paramIndex);
|
|
2021
2713
|
};
|
|
2022
2714
|
}
|
|
2023
|
-
__name(
|
|
2715
|
+
__name(_ts_param11, "_ts_param");
|
|
2716
|
+
var QueueController = class {
|
|
2717
|
+
static {
|
|
2718
|
+
__name(this, "QueueController");
|
|
2719
|
+
}
|
|
2720
|
+
agent;
|
|
2721
|
+
actorResolver;
|
|
2722
|
+
constructor(agent, actorResolver) {
|
|
2723
|
+
this.agent = agent;
|
|
2724
|
+
this.actorResolver = actorResolver;
|
|
2725
|
+
}
|
|
2726
|
+
async list(req, id) {
|
|
2727
|
+
return this.agent.getQueue(await this.actorResolver.resolve(req), id);
|
|
2728
|
+
}
|
|
2729
|
+
async clear(req, id) {
|
|
2730
|
+
return this.agent.clearQueue(await this.actorResolver.resolve(req), id);
|
|
2731
|
+
}
|
|
2732
|
+
/** Lift a pause; the head starts when nothing is running. Carries `runId` when it started. */
|
|
2733
|
+
async resume(req, id) {
|
|
2734
|
+
return this.agent.resumeQueue(await this.actorResolver.resolve(req), id);
|
|
2735
|
+
}
|
|
2736
|
+
async update(req, messageId, body) {
|
|
2737
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2738
|
+
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
2739
|
+
throw new BadRequestException4("message must be a string");
|
|
2740
|
+
}
|
|
2741
|
+
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
2742
|
+
throw new BadRequestException4("position must be a number");
|
|
2743
|
+
}
|
|
2744
|
+
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
2745
|
+
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
2746
|
+
...body.message !== void 0 ? {
|
|
2747
|
+
message: body.message
|
|
2748
|
+
} : {},
|
|
2749
|
+
...attachments !== void 0 ? {
|
|
2750
|
+
attachments
|
|
2751
|
+
} : {},
|
|
2752
|
+
...body.position !== void 0 ? {
|
|
2753
|
+
position: body.position
|
|
2754
|
+
} : {}
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
async remove(req, messageId) {
|
|
2758
|
+
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
_ts_decorate12([
|
|
2762
|
+
Get7("threads/:id/queue"),
|
|
2763
|
+
_ts_param11(0, Req7()),
|
|
2764
|
+
_ts_param11(1, Param4("id")),
|
|
2765
|
+
_ts_metadata12("design:type", Function),
|
|
2766
|
+
_ts_metadata12("design:paramtypes", [
|
|
2767
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2768
|
+
String
|
|
2769
|
+
]),
|
|
2770
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2771
|
+
], QueueController.prototype, "list", null);
|
|
2772
|
+
_ts_decorate12([
|
|
2773
|
+
Delete2("threads/:id/queue"),
|
|
2774
|
+
_ts_param11(0, Req7()),
|
|
2775
|
+
_ts_param11(1, Param4("id")),
|
|
2776
|
+
_ts_metadata12("design:type", Function),
|
|
2777
|
+
_ts_metadata12("design:paramtypes", [
|
|
2778
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2779
|
+
String
|
|
2780
|
+
]),
|
|
2781
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2782
|
+
], QueueController.prototype, "clear", null);
|
|
2783
|
+
_ts_decorate12([
|
|
2784
|
+
Post4("threads/:id/queue/resume"),
|
|
2785
|
+
_ts_param11(0, Req7()),
|
|
2786
|
+
_ts_param11(1, Param4("id")),
|
|
2787
|
+
_ts_metadata12("design:type", Function),
|
|
2788
|
+
_ts_metadata12("design:paramtypes", [
|
|
2789
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2790
|
+
String
|
|
2791
|
+
]),
|
|
2792
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2793
|
+
], QueueController.prototype, "resume", null);
|
|
2794
|
+
_ts_decorate12([
|
|
2795
|
+
Patch("queue/:messageId"),
|
|
2796
|
+
_ts_param11(0, Req7()),
|
|
2797
|
+
_ts_param11(1, Param4("messageId")),
|
|
2798
|
+
_ts_param11(2, Body3()),
|
|
2799
|
+
_ts_metadata12("design:type", Function),
|
|
2800
|
+
_ts_metadata12("design:paramtypes", [
|
|
2801
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2802
|
+
String,
|
|
2803
|
+
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
2804
|
+
]),
|
|
2805
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2806
|
+
], QueueController.prototype, "update", null);
|
|
2807
|
+
_ts_decorate12([
|
|
2808
|
+
Delete2("queue/:messageId"),
|
|
2809
|
+
_ts_param11(0, Req7()),
|
|
2810
|
+
_ts_param11(1, Param4("messageId")),
|
|
2811
|
+
_ts_metadata12("design:type", Function),
|
|
2812
|
+
_ts_metadata12("design:paramtypes", [
|
|
2813
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2814
|
+
String
|
|
2815
|
+
]),
|
|
2816
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2817
|
+
], QueueController.prototype, "remove", null);
|
|
2818
|
+
QueueController = _ts_decorate12([
|
|
2819
|
+
Controller8(),
|
|
2820
|
+
_ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER7)),
|
|
2821
|
+
_ts_metadata12("design:type", Function),
|
|
2822
|
+
_ts_metadata12("design:paramtypes", [
|
|
2823
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2824
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2825
|
+
])
|
|
2826
|
+
], QueueController);
|
|
2827
|
+
|
|
2828
|
+
// src/controller/quota.controller.ts
|
|
2829
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
|
|
2830
|
+
import { Controller as Controller9, Get as Get8, Inject as Inject12, Req as Req8 } from "@nestjs/common";
|
|
2831
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2832
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2833
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2834
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2835
|
+
} else {
|
|
2836
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2837
|
+
if (d = decorators[i]) {
|
|
2838
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2843
|
+
}
|
|
2844
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2845
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
2846
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2847
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2851
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2852
|
+
return function(target, key) {
|
|
2853
|
+
decorator(target, key, paramIndex);
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
__name(_ts_param12, "_ts_param");
|
|
2024
2857
|
var QuotaController = class {
|
|
2025
2858
|
static {
|
|
2026
2859
|
__name(this, "QuotaController");
|
|
@@ -2040,29 +2873,29 @@ var QuotaController = class {
|
|
|
2040
2873
|
return this.agent.quotaReport(actor);
|
|
2041
2874
|
}
|
|
2042
2875
|
};
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2876
|
+
_ts_decorate13([
|
|
2877
|
+
Get8(),
|
|
2878
|
+
_ts_param12(0, Req8()),
|
|
2879
|
+
_ts_metadata13("design:type", Function),
|
|
2880
|
+
_ts_metadata13("design:paramtypes", [
|
|
2048
2881
|
typeof Request === "undefined" ? Object : Request
|
|
2049
2882
|
]),
|
|
2050
|
-
|
|
2883
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2051
2884
|
], QuotaController.prototype, "report", null);
|
|
2052
|
-
QuotaController =
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2885
|
+
QuotaController = _ts_decorate13([
|
|
2886
|
+
Controller9("quota"),
|
|
2887
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER8)),
|
|
2888
|
+
_ts_metadata13("design:type", Function),
|
|
2889
|
+
_ts_metadata13("design:paramtypes", [
|
|
2057
2890
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2058
2891
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2059
2892
|
])
|
|
2060
2893
|
], QuotaController);
|
|
2061
2894
|
|
|
2062
2895
|
// src/controller/skills.controller.ts
|
|
2063
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2064
|
-
import { Controller as
|
|
2065
|
-
function
|
|
2896
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
2897
|
+
import { Controller as Controller10, Get as Get9, Inject as Inject13, Optional as Optional7, Query as Query4, Req as Req9 } from "@nestjs/common";
|
|
2898
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2066
2899
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2067
2900
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2068
2901
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2075,19 +2908,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2075
2908
|
}
|
|
2076
2909
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2077
2910
|
}
|
|
2078
|
-
__name(
|
|
2079
|
-
function
|
|
2911
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2912
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2080
2913
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2081
2914
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2082
2915
|
}
|
|
2083
2916
|
}
|
|
2084
|
-
__name(
|
|
2085
|
-
function
|
|
2917
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2918
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2086
2919
|
return function(target, key) {
|
|
2087
2920
|
decorator(target, key, paramIndex);
|
|
2088
2921
|
};
|
|
2089
2922
|
}
|
|
2090
|
-
__name(
|
|
2923
|
+
__name(_ts_param13, "_ts_param");
|
|
2091
2924
|
var SkillsController = class {
|
|
2092
2925
|
static {
|
|
2093
2926
|
__name(this, "SkillsController");
|
|
@@ -2110,33 +2943,33 @@ var SkillsController = class {
|
|
|
2110
2943
|
return offer.entries;
|
|
2111
2944
|
}
|
|
2112
2945
|
};
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2946
|
+
_ts_decorate14([
|
|
2947
|
+
Get9(),
|
|
2948
|
+
_ts_param13(0, Req9()),
|
|
2949
|
+
_ts_param13(1, Query4("threadId")),
|
|
2950
|
+
_ts_metadata14("design:type", Function),
|
|
2951
|
+
_ts_metadata14("design:paramtypes", [
|
|
2119
2952
|
typeof Request === "undefined" ? Object : Request,
|
|
2120
2953
|
String
|
|
2121
2954
|
]),
|
|
2122
|
-
|
|
2955
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2123
2956
|
], SkillsController.prototype, "list", null);
|
|
2124
|
-
SkillsController =
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2957
|
+
SkillsController = _ts_decorate14([
|
|
2958
|
+
Controller10("skills"),
|
|
2959
|
+
_ts_param13(0, Inject13(AGENT_ACTOR_RESOLVER9)),
|
|
2960
|
+
_ts_param13(1, Optional7()),
|
|
2961
|
+
_ts_param13(1, Inject13(AGENT_SKILLS2)),
|
|
2962
|
+
_ts_metadata14("design:type", Function),
|
|
2963
|
+
_ts_metadata14("design:paramtypes", [
|
|
2131
2964
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2132
2965
|
Object
|
|
2133
2966
|
])
|
|
2134
2967
|
], SkillsController);
|
|
2135
2968
|
|
|
2136
2969
|
// src/controller/threads.controller.ts
|
|
2137
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2138
|
-
import { Body as
|
|
2139
|
-
function
|
|
2970
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
|
|
2971
|
+
import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as Inject14, Param as Param5, Patch as Patch2, Post as Post5, Req as Req10 } from "@nestjs/common";
|
|
2972
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2140
2973
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2141
2974
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2142
2975
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2149,19 +2982,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2149
2982
|
}
|
|
2150
2983
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2151
2984
|
}
|
|
2152
|
-
__name(
|
|
2153
|
-
function
|
|
2985
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2986
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2154
2987
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2155
2988
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2156
2989
|
}
|
|
2157
2990
|
}
|
|
2158
|
-
__name(
|
|
2159
|
-
function
|
|
2991
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2992
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2160
2993
|
return function(target, key) {
|
|
2161
2994
|
decorator(target, key, paramIndex);
|
|
2162
2995
|
};
|
|
2163
2996
|
}
|
|
2164
|
-
__name(
|
|
2997
|
+
__name(_ts_param14, "_ts_param");
|
|
2165
2998
|
var ThreadsController = class {
|
|
2166
2999
|
static {
|
|
2167
3000
|
__name(this, "ThreadsController");
|
|
@@ -2228,101 +3061,101 @@ var ThreadsController = class {
|
|
|
2228
3061
|
};
|
|
2229
3062
|
}
|
|
2230
3063
|
};
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
3064
|
+
_ts_decorate15([
|
|
3065
|
+
Get10(),
|
|
3066
|
+
_ts_param14(0, Req10()),
|
|
3067
|
+
_ts_metadata15("design:type", Function),
|
|
3068
|
+
_ts_metadata15("design:paramtypes", [
|
|
2236
3069
|
typeof Request === "undefined" ? Object : Request
|
|
2237
3070
|
]),
|
|
2238
|
-
|
|
3071
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2239
3072
|
], ThreadsController.prototype, "list", null);
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
3073
|
+
_ts_decorate15([
|
|
3074
|
+
Get10(":id"),
|
|
3075
|
+
_ts_param14(0, Req10()),
|
|
3076
|
+
_ts_param14(1, Param5("id")),
|
|
3077
|
+
_ts_metadata15("design:type", Function),
|
|
3078
|
+
_ts_metadata15("design:paramtypes", [
|
|
2246
3079
|
typeof Request === "undefined" ? Object : Request,
|
|
2247
3080
|
String
|
|
2248
3081
|
]),
|
|
2249
|
-
|
|
3082
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2250
3083
|
], ThreadsController.prototype, "detail", null);
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
3084
|
+
_ts_decorate15([
|
|
3085
|
+
Delete3(":id"),
|
|
3086
|
+
_ts_param14(0, Req10()),
|
|
3087
|
+
_ts_param14(1, Param5("id")),
|
|
3088
|
+
_ts_metadata15("design:type", Function),
|
|
3089
|
+
_ts_metadata15("design:paramtypes", [
|
|
2257
3090
|
typeof Request === "undefined" ? Object : Request,
|
|
2258
3091
|
String
|
|
2259
3092
|
]),
|
|
2260
|
-
|
|
3093
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2261
3094
|
], ThreadsController.prototype, "remove", null);
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
3095
|
+
_ts_decorate15([
|
|
3096
|
+
Post5(":id/fork-from/:messageId"),
|
|
3097
|
+
_ts_param14(0, Req10()),
|
|
3098
|
+
_ts_param14(1, Param5("id")),
|
|
3099
|
+
_ts_param14(2, Param5("messageId")),
|
|
3100
|
+
_ts_metadata15("design:type", Function),
|
|
3101
|
+
_ts_metadata15("design:paramtypes", [
|
|
2269
3102
|
typeof Request === "undefined" ? Object : Request,
|
|
2270
3103
|
String,
|
|
2271
3104
|
String
|
|
2272
3105
|
]),
|
|
2273
|
-
|
|
3106
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2274
3107
|
], ThreadsController.prototype, "fork", null);
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
3108
|
+
_ts_decorate15([
|
|
3109
|
+
Patch2(":id"),
|
|
3110
|
+
_ts_param14(0, Req10()),
|
|
3111
|
+
_ts_param14(1, Param5("id")),
|
|
3112
|
+
_ts_param14(2, Body4()),
|
|
3113
|
+
_ts_metadata15("design:type", Function),
|
|
3114
|
+
_ts_metadata15("design:paramtypes", [
|
|
2282
3115
|
typeof Request === "undefined" ? Object : Request,
|
|
2283
3116
|
String,
|
|
2284
3117
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2285
3118
|
]),
|
|
2286
|
-
|
|
3119
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2287
3120
|
], ThreadsController.prototype, "update", null);
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
3121
|
+
_ts_decorate15([
|
|
3122
|
+
Post5(":id/promote"),
|
|
3123
|
+
_ts_param14(0, Req10()),
|
|
3124
|
+
_ts_param14(1, Param5("id")),
|
|
3125
|
+
_ts_metadata15("design:type", Function),
|
|
3126
|
+
_ts_metadata15("design:paramtypes", [
|
|
2294
3127
|
typeof Request === "undefined" ? Object : Request,
|
|
2295
3128
|
String
|
|
2296
3129
|
]),
|
|
2297
|
-
|
|
3130
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2298
3131
|
], ThreadsController.prototype, "promote", null);
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
3132
|
+
_ts_decorate15([
|
|
3133
|
+
Delete3(":id/from/:messageId"),
|
|
3134
|
+
_ts_param14(0, Req10()),
|
|
3135
|
+
_ts_param14(1, Param5("id")),
|
|
3136
|
+
_ts_param14(2, Param5("messageId")),
|
|
3137
|
+
_ts_metadata15("design:type", Function),
|
|
3138
|
+
_ts_metadata15("design:paramtypes", [
|
|
2306
3139
|
typeof Request === "undefined" ? Object : Request,
|
|
2307
3140
|
String,
|
|
2308
3141
|
String
|
|
2309
3142
|
]),
|
|
2310
|
-
|
|
3143
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2311
3144
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2312
|
-
ThreadsController =
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
3145
|
+
ThreadsController = _ts_decorate15([
|
|
3146
|
+
Controller11("threads"),
|
|
3147
|
+
_ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER10)),
|
|
3148
|
+
_ts_metadata15("design:type", Function),
|
|
3149
|
+
_ts_metadata15("design:paramtypes", [
|
|
2317
3150
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2318
3151
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2319
3152
|
])
|
|
2320
3153
|
], ThreadsController);
|
|
2321
3154
|
|
|
2322
3155
|
// src/controller/tool-call.controller.ts
|
|
2323
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2324
|
-
import { BadRequestException as
|
|
2325
|
-
function
|
|
3156
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11 } from "@dudousxd/nestjs-agent-core";
|
|
3157
|
+
import { BadRequestException as BadRequestException5, Body as Body5, Controller as Controller12, Inject as Inject15, Post as Post6, Req as Req11 } from "@nestjs/common";
|
|
3158
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2326
3159
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2327
3160
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2328
3161
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2335,19 +3168,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2335
3168
|
}
|
|
2336
3169
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2337
3170
|
}
|
|
2338
|
-
__name(
|
|
2339
|
-
function
|
|
3171
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3172
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2340
3173
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2341
3174
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2342
3175
|
}
|
|
2343
3176
|
}
|
|
2344
|
-
__name(
|
|
2345
|
-
function
|
|
3177
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
3178
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2346
3179
|
return function(target, key) {
|
|
2347
3180
|
decorator(target, key, paramIndex);
|
|
2348
3181
|
};
|
|
2349
3182
|
}
|
|
2350
|
-
__name(
|
|
3183
|
+
__name(_ts_param15, "_ts_param");
|
|
2351
3184
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2352
3185
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2353
3186
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2356,7 +3189,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
2356
3189
|
var DEFAULT_VIA = "web";
|
|
2357
3190
|
function toolCallId(claimed) {
|
|
2358
3191
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
2359
|
-
throw new
|
|
3192
|
+
throw new BadRequestException5("toolCallId must be a non-empty string");
|
|
2360
3193
|
}
|
|
2361
3194
|
return claimed;
|
|
2362
3195
|
}
|
|
@@ -2366,10 +3199,10 @@ function rejectReason(claimed) {
|
|
|
2366
3199
|
return void 0;
|
|
2367
3200
|
}
|
|
2368
3201
|
if (typeof claimed !== "string") {
|
|
2369
|
-
throw new
|
|
3202
|
+
throw new BadRequestException5("reason must be a string");
|
|
2370
3203
|
}
|
|
2371
3204
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
2372
|
-
throw new
|
|
3205
|
+
throw new BadRequestException5(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
2373
3206
|
}
|
|
2374
3207
|
return claimed;
|
|
2375
3208
|
}
|
|
@@ -2379,7 +3212,7 @@ function remember(claimed) {
|
|
|
2379
3212
|
return false;
|
|
2380
3213
|
}
|
|
2381
3214
|
if (typeof claimed !== "boolean") {
|
|
2382
|
-
throw new
|
|
3215
|
+
throw new BadRequestException5("remember must be a boolean");
|
|
2383
3216
|
}
|
|
2384
3217
|
return claimed;
|
|
2385
3218
|
}
|
|
@@ -2389,7 +3222,7 @@ function via(claimed) {
|
|
|
2389
3222
|
return DEFAULT_VIA;
|
|
2390
3223
|
}
|
|
2391
3224
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
2392
|
-
throw new
|
|
3225
|
+
throw new BadRequestException5(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
2393
3226
|
}
|
|
2394
3227
|
return claimed;
|
|
2395
3228
|
}
|
|
@@ -2399,26 +3232,26 @@ function answers(claimed) {
|
|
|
2399
3232
|
return void 0;
|
|
2400
3233
|
}
|
|
2401
3234
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
2402
|
-
throw new
|
|
3235
|
+
throw new BadRequestException5("answers must be an object of questionId \u2192 chosen values");
|
|
2403
3236
|
}
|
|
2404
3237
|
const entries = Object.entries(claimed);
|
|
2405
3238
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
2406
|
-
throw new
|
|
3239
|
+
throw new BadRequestException5(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
2407
3240
|
}
|
|
2408
3241
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
2409
3242
|
for (const [questionId, values] of entries) {
|
|
2410
3243
|
if (!Array.isArray(values)) {
|
|
2411
|
-
throw new
|
|
3244
|
+
throw new BadRequestException5(`answers["${questionId}"] must be an array of chosen values`);
|
|
2412
3245
|
}
|
|
2413
3246
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
2414
|
-
throw new
|
|
3247
|
+
throw new BadRequestException5(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
2415
3248
|
}
|
|
2416
3249
|
for (const value of values) {
|
|
2417
3250
|
if (typeof value !== "string") {
|
|
2418
|
-
throw new
|
|
3251
|
+
throw new BadRequestException5(`answers["${questionId}"] must contain only strings`);
|
|
2419
3252
|
}
|
|
2420
3253
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
2421
|
-
throw new
|
|
3254
|
+
throw new BadRequestException5(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
2422
3255
|
}
|
|
2423
3256
|
}
|
|
2424
3257
|
validated[questionId] = values;
|
|
@@ -2480,64 +3313,64 @@ var ToolCallController = class {
|
|
|
2480
3313
|
};
|
|
2481
3314
|
}
|
|
2482
3315
|
};
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
3316
|
+
_ts_decorate16([
|
|
3317
|
+
Post6("approve"),
|
|
3318
|
+
_ts_param15(0, Req11()),
|
|
3319
|
+
_ts_param15(1, Body5()),
|
|
3320
|
+
_ts_metadata16("design:type", Function),
|
|
3321
|
+
_ts_metadata16("design:paramtypes", [
|
|
2489
3322
|
typeof Request === "undefined" ? Object : Request,
|
|
2490
3323
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2491
3324
|
]),
|
|
2492
|
-
|
|
3325
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2493
3326
|
], ToolCallController.prototype, "approve", null);
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
3327
|
+
_ts_decorate16([
|
|
3328
|
+
Post6("reject"),
|
|
3329
|
+
_ts_param15(0, Req11()),
|
|
3330
|
+
_ts_param15(1, Body5()),
|
|
3331
|
+
_ts_metadata16("design:type", Function),
|
|
3332
|
+
_ts_metadata16("design:paramtypes", [
|
|
2500
3333
|
typeof Request === "undefined" ? Object : Request,
|
|
2501
3334
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2502
3335
|
]),
|
|
2503
|
-
|
|
3336
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2504
3337
|
], ToolCallController.prototype, "reject", null);
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
3338
|
+
_ts_decorate16([
|
|
3339
|
+
Post6("answer"),
|
|
3340
|
+
_ts_param15(0, Req11()),
|
|
3341
|
+
_ts_param15(1, Body5()),
|
|
3342
|
+
_ts_metadata16("design:type", Function),
|
|
3343
|
+
_ts_metadata16("design:paramtypes", [
|
|
2511
3344
|
typeof Request === "undefined" ? Object : Request,
|
|
2512
3345
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2513
3346
|
]),
|
|
2514
|
-
|
|
3347
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2515
3348
|
], ToolCallController.prototype, "answer", null);
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
3349
|
+
_ts_decorate16([
|
|
3350
|
+
Post6("skip"),
|
|
3351
|
+
_ts_param15(0, Req11()),
|
|
3352
|
+
_ts_param15(1, Body5()),
|
|
3353
|
+
_ts_metadata16("design:type", Function),
|
|
3354
|
+
_ts_metadata16("design:paramtypes", [
|
|
2522
3355
|
typeof Request === "undefined" ? Object : Request,
|
|
2523
3356
|
Object
|
|
2524
3357
|
]),
|
|
2525
|
-
|
|
3358
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2526
3359
|
], ToolCallController.prototype, "skip", null);
|
|
2527
|
-
ToolCallController =
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
3360
|
+
ToolCallController = _ts_decorate16([
|
|
3361
|
+
Controller12("tool-call"),
|
|
3362
|
+
_ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER11)),
|
|
3363
|
+
_ts_metadata16("design:type", Function),
|
|
3364
|
+
_ts_metadata16("design:paramtypes", [
|
|
2532
3365
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2533
3366
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2534
3367
|
])
|
|
2535
3368
|
], ToolCallController);
|
|
2536
3369
|
|
|
2537
3370
|
// src/controller/tools.controller.ts
|
|
2538
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2539
|
-
import { Controller as
|
|
2540
|
-
function
|
|
3371
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_REGISTRY as AGENT_REGISTRY3, ALL_AGENTS, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
3372
|
+
import { Controller as Controller13, Get as Get11, Inject as Inject16, NotFoundException as NotFoundException3, Query as Query5, Req as Req12 } from "@nestjs/common";
|
|
3373
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2541
3374
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2542
3375
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2543
3376
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2550,19 +3383,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2550
3383
|
}
|
|
2551
3384
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2552
3385
|
}
|
|
2553
|
-
__name(
|
|
2554
|
-
function
|
|
3386
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3387
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2555
3388
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2556
3389
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2557
3390
|
}
|
|
2558
3391
|
}
|
|
2559
|
-
__name(
|
|
2560
|
-
function
|
|
3392
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3393
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2561
3394
|
return function(target, key) {
|
|
2562
3395
|
decorator(target, key, paramIndex);
|
|
2563
3396
|
};
|
|
2564
3397
|
}
|
|
2565
|
-
__name(
|
|
3398
|
+
__name(_ts_param16, "_ts_param");
|
|
2566
3399
|
var ToolsController = class {
|
|
2567
3400
|
static {
|
|
2568
3401
|
__name(this, "ToolsController");
|
|
@@ -2576,39 +3409,54 @@ var ToolsController = class {
|
|
|
2576
3409
|
this.agents = agents;
|
|
2577
3410
|
}
|
|
2578
3411
|
async list(req, agent) {
|
|
2579
|
-
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
3412
|
+
if (agent !== void 0 && agent !== ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
2580
3413
|
throw new NotFoundException3(`No agent named "${agent}"`);
|
|
2581
3414
|
}
|
|
2582
3415
|
const actor = await this.actorResolver.resolve(req);
|
|
2583
|
-
const
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
3416
|
+
const names = agent === ALL_AGENTS ? [
|
|
3417
|
+
void 0,
|
|
3418
|
+
...this.agents.list().map((definition) => definition.name)
|
|
3419
|
+
] : [
|
|
3420
|
+
agent
|
|
3421
|
+
];
|
|
3422
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3423
|
+
for (const name of names) {
|
|
3424
|
+
const deps = this.depsFactory.forAgent(name);
|
|
3425
|
+
const specs = await deps.registry.visibleSpecs(actor, deps.rolesPolicy, deps.toolAllowList);
|
|
3426
|
+
for (const spec of specs) {
|
|
3427
|
+
if (entries.has(spec.name)) continue;
|
|
3428
|
+
entries.set(spec.name, {
|
|
3429
|
+
name: spec.name,
|
|
3430
|
+
kind: spec.kind,
|
|
3431
|
+
...spec.presentation !== void 0 ? {
|
|
3432
|
+
presentation: spec.presentation
|
|
3433
|
+
} : {}
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3437
|
+
return [
|
|
3438
|
+
...entries.values()
|
|
3439
|
+
];
|
|
2592
3440
|
}
|
|
2593
3441
|
};
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
3442
|
+
_ts_decorate17([
|
|
3443
|
+
Get11(),
|
|
3444
|
+
_ts_param16(0, Req12()),
|
|
3445
|
+
_ts_param16(1, Query5("agent")),
|
|
3446
|
+
_ts_metadata17("design:type", Function),
|
|
3447
|
+
_ts_metadata17("design:paramtypes", [
|
|
2600
3448
|
typeof Request === "undefined" ? Object : Request,
|
|
2601
3449
|
String
|
|
2602
3450
|
]),
|
|
2603
|
-
|
|
3451
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2604
3452
|
], ToolsController.prototype, "list", null);
|
|
2605
|
-
ToolsController =
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
3453
|
+
ToolsController = _ts_decorate17([
|
|
3454
|
+
Controller13("tools"),
|
|
3455
|
+
_ts_param16(0, Inject16(AGENT_ACTOR_RESOLVER12)),
|
|
3456
|
+
_ts_param16(1, Inject16(AGENT_DEPS_FACTORY3)),
|
|
3457
|
+
_ts_param16(2, Inject16(AGENT_REGISTRY3)),
|
|
3458
|
+
_ts_metadata17("design:type", Function),
|
|
3459
|
+
_ts_metadata17("design:paramtypes", [
|
|
2612
3460
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2613
3461
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2614
3462
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -2617,7 +3465,7 @@ ToolsController = _ts_decorate15([
|
|
|
2617
3465
|
|
|
2618
3466
|
// src/discovery/agent-discovery.service.ts
|
|
2619
3467
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
2620
|
-
import { Inject as
|
|
3468
|
+
import { Inject as Inject17, Injectable as Injectable5, Logger as Logger2 } from "@nestjs/common";
|
|
2621
3469
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
2622
3470
|
|
|
2623
3471
|
// src/decorator/agent.decorator.ts
|
|
@@ -2652,7 +3500,7 @@ function SystemPromptContributor() {
|
|
|
2652
3500
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
2653
3501
|
|
|
2654
3502
|
// src/discovery/agent-discovery.service.ts
|
|
2655
|
-
function
|
|
3503
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2656
3504
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2657
3505
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2658
3506
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2665,19 +3513,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2665
3513
|
}
|
|
2666
3514
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2667
3515
|
}
|
|
2668
|
-
__name(
|
|
2669
|
-
function
|
|
3516
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3517
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2670
3518
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2671
3519
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2672
3520
|
}
|
|
2673
3521
|
}
|
|
2674
|
-
__name(
|
|
2675
|
-
function
|
|
3522
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3523
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2676
3524
|
return function(target, key) {
|
|
2677
3525
|
decorator(target, key, paramIndex);
|
|
2678
3526
|
};
|
|
2679
3527
|
}
|
|
2680
|
-
__name(
|
|
3528
|
+
__name(_ts_param17, "_ts_param");
|
|
2681
3529
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2682
3530
|
static {
|
|
2683
3531
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2686,7 +3534,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2686
3534
|
scanner;
|
|
2687
3535
|
registry;
|
|
2688
3536
|
contributors;
|
|
2689
|
-
logger = new
|
|
3537
|
+
logger = new Logger2(_AgentDiscoveryService.name);
|
|
2690
3538
|
constructor(discovery, scanner, registry, contributors) {
|
|
2691
3539
|
this.discovery = discovery;
|
|
2692
3540
|
this.scanner = scanner;
|
|
@@ -2804,12 +3652,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2804
3652
|
return (ctx) => candidate.call(instance, ctx);
|
|
2805
3653
|
}
|
|
2806
3654
|
};
|
|
2807
|
-
AgentDiscoveryService =
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
3655
|
+
AgentDiscoveryService = _ts_decorate18([
|
|
3656
|
+
Injectable5(),
|
|
3657
|
+
_ts_param17(2, Inject17(AGENT_REGISTRY4)),
|
|
3658
|
+
_ts_param17(3, Inject17(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
3659
|
+
_ts_metadata18("design:type", Function),
|
|
3660
|
+
_ts_metadata18("design:paramtypes", [
|
|
2813
3661
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
2814
3662
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
2815
3663
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -2818,8 +3666,8 @@ AgentDiscoveryService = _ts_decorate16([
|
|
|
2818
3666
|
], AgentDiscoveryService);
|
|
2819
3667
|
|
|
2820
3668
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2821
|
-
import { AGENT_OPTIONS as
|
|
2822
|
-
import { Inject as
|
|
3669
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS6, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
3670
|
+
import { Inject as Inject18, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
|
|
2823
3671
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
2824
3672
|
import { z } from "zod";
|
|
2825
3673
|
|
|
@@ -2890,7 +3738,7 @@ function provideAgentTools(factory, inject) {
|
|
|
2890
3738
|
__name(provideAgentTools, "provideAgentTools");
|
|
2891
3739
|
|
|
2892
3740
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2893
|
-
function
|
|
3741
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
2894
3742
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2895
3743
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2896
3744
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2903,19 +3751,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2903
3751
|
}
|
|
2904
3752
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2905
3753
|
}
|
|
2906
|
-
__name(
|
|
2907
|
-
function
|
|
3754
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3755
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
2908
3756
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2909
3757
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2910
3758
|
}
|
|
2911
3759
|
}
|
|
2912
|
-
__name(
|
|
2913
|
-
function
|
|
3760
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3761
|
+
function _ts_param18(paramIndex, decorator) {
|
|
2914
3762
|
return function(target, key) {
|
|
2915
3763
|
decorator(target, key, paramIndex);
|
|
2916
3764
|
};
|
|
2917
3765
|
}
|
|
2918
|
-
__name(
|
|
3766
|
+
__name(_ts_param18, "_ts_param");
|
|
2919
3767
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2920
3768
|
static {
|
|
2921
3769
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2924,7 +3772,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2924
3772
|
registry;
|
|
2925
3773
|
agents;
|
|
2926
3774
|
options;
|
|
2927
|
-
logger = new
|
|
3775
|
+
logger = new Logger3(_AiToolDiscoveryService.name);
|
|
2928
3776
|
constructor(discovery, registry, agents, options) {
|
|
2929
3777
|
this.discovery = discovery;
|
|
2930
3778
|
this.registry = registry;
|
|
@@ -3059,13 +3907,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3059
3907
|
return true;
|
|
3060
3908
|
}
|
|
3061
3909
|
};
|
|
3062
|
-
AiToolDiscoveryService =
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3910
|
+
AiToolDiscoveryService = _ts_decorate19([
|
|
3911
|
+
Injectable6(),
|
|
3912
|
+
_ts_param18(1, Inject18(AGENT_TOOL_REGISTRY2)),
|
|
3913
|
+
_ts_param18(2, Inject18(AGENT_REGISTRY5)),
|
|
3914
|
+
_ts_param18(3, Inject18(AGENT_OPTIONS6)),
|
|
3915
|
+
_ts_metadata19("design:type", Function),
|
|
3916
|
+
_ts_metadata19("design:paramtypes", [
|
|
3069
3917
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
3070
3918
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3071
3919
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3075,7 +3923,7 @@ AiToolDiscoveryService = _ts_decorate17([
|
|
|
3075
3923
|
|
|
3076
3924
|
// src/discovery/skill-discovery.service.ts
|
|
3077
3925
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
3078
|
-
import { Inject as
|
|
3926
|
+
import { Inject as Inject19, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
|
|
3079
3927
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
3080
3928
|
|
|
3081
3929
|
// src/decorator/skill.decorator.ts
|
|
@@ -3098,7 +3946,7 @@ function skillScope(options) {
|
|
|
3098
3946
|
__name(skillScope, "skillScope");
|
|
3099
3947
|
|
|
3100
3948
|
// src/discovery/skill-discovery.service.ts
|
|
3101
|
-
function
|
|
3949
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3102
3950
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3103
3951
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3104
3952
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3111,26 +3959,26 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3111
3959
|
}
|
|
3112
3960
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3113
3961
|
}
|
|
3114
|
-
__name(
|
|
3115
|
-
function
|
|
3962
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3963
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3116
3964
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3117
3965
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3118
3966
|
}
|
|
3119
3967
|
}
|
|
3120
|
-
__name(
|
|
3121
|
-
function
|
|
3968
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3969
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3122
3970
|
return function(target, key) {
|
|
3123
3971
|
decorator(target, key, paramIndex);
|
|
3124
3972
|
};
|
|
3125
3973
|
}
|
|
3126
|
-
__name(
|
|
3974
|
+
__name(_ts_param19, "_ts_param");
|
|
3127
3975
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3128
3976
|
static {
|
|
3129
3977
|
__name(this, "SkillDiscoveryService");
|
|
3130
3978
|
}
|
|
3131
3979
|
discovery;
|
|
3132
3980
|
declared;
|
|
3133
|
-
logger = new
|
|
3981
|
+
logger = new Logger4(_SkillDiscoveryService.name);
|
|
3134
3982
|
constructor(discovery, declared) {
|
|
3135
3983
|
this.discovery = discovery;
|
|
3136
3984
|
this.declared = declared;
|
|
@@ -3167,11 +4015,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3167
4015
|
return flat === void 0 ? void 0 : () => flat;
|
|
3168
4016
|
}
|
|
3169
4017
|
};
|
|
3170
|
-
SkillDiscoveryService =
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
4018
|
+
SkillDiscoveryService = _ts_decorate20([
|
|
4019
|
+
Injectable7(),
|
|
4020
|
+
_ts_param19(1, Inject19(AGENT_SKILL_SOURCES)),
|
|
4021
|
+
_ts_metadata20("design:type", Function),
|
|
4022
|
+
_ts_metadata20("design:paramtypes", [
|
|
3175
4023
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
3176
4024
|
Array
|
|
3177
4025
|
])
|
|
@@ -3308,9 +4156,9 @@ var LedgerQuotaProvider = class {
|
|
|
3308
4156
|
};
|
|
3309
4157
|
|
|
3310
4158
|
// src/runner/inline-agent-runner.ts
|
|
3311
|
-
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as
|
|
3312
|
-
import { Inject as
|
|
3313
|
-
function
|
|
4159
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as AGENT_STORE4, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleUnsettledDelegation } from "@dudousxd/nestjs-agent-core";
|
|
4160
|
+
import { Inject as Inject20, Injectable as Injectable8, Logger as Logger5, Optional as Optional8 } from "@nestjs/common";
|
|
4161
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3314
4162
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3315
4163
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3316
4164
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3323,26 +4171,27 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3323
4171
|
}
|
|
3324
4172
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3325
4173
|
}
|
|
3326
|
-
__name(
|
|
3327
|
-
function
|
|
4174
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
4175
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
3328
4176
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3329
4177
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3330
4178
|
}
|
|
3331
4179
|
}
|
|
3332
|
-
__name(
|
|
3333
|
-
function
|
|
4180
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
4181
|
+
function _ts_param20(paramIndex, decorator) {
|
|
3334
4182
|
return function(target, key) {
|
|
3335
4183
|
decorator(target, key, paramIndex);
|
|
3336
4184
|
};
|
|
3337
4185
|
}
|
|
3338
|
-
__name(
|
|
4186
|
+
__name(_ts_param20, "_ts_param");
|
|
3339
4187
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3340
4188
|
static {
|
|
3341
4189
|
__name(this, "InlineAgentRunner");
|
|
3342
4190
|
}
|
|
3343
4191
|
factory;
|
|
3344
4192
|
store;
|
|
3345
|
-
|
|
4193
|
+
queue;
|
|
4194
|
+
logger = new Logger5(_InlineAgentRunner.name);
|
|
3346
4195
|
pending = /* @__PURE__ */ new Map();
|
|
3347
4196
|
/**
|
|
3348
4197
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -3350,14 +4199,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3350
4199
|
* running it. A cancelled id is dropped once the run settles, so the set tracks live runs only.
|
|
3351
4200
|
*/
|
|
3352
4201
|
cancelled = /* @__PURE__ */ new Set();
|
|
3353
|
-
|
|
4202
|
+
/** Top-level runs this process is running now — what {@link isRunActive} answers from. */
|
|
4203
|
+
live = /* @__PURE__ */ new Set();
|
|
4204
|
+
constructor(factory, store, queue) {
|
|
3354
4205
|
this.factory = factory;
|
|
3355
4206
|
this.store = store;
|
|
4207
|
+
this.queue = queue;
|
|
3356
4208
|
}
|
|
3357
|
-
|
|
3358
|
-
|
|
4209
|
+
/**
|
|
4210
|
+
* In-process, so exact: a run this process is not running is not running anywhere — the process
|
|
4211
|
+
* that was running it is gone (a restart), and a thread it still holds is a stale claim.
|
|
4212
|
+
*/
|
|
4213
|
+
async isRunActive(runId) {
|
|
4214
|
+
return this.live.has(runId);
|
|
4215
|
+
}
|
|
4216
|
+
async start(input, options = {}) {
|
|
4217
|
+
const runId = options.runId ?? crypto.randomUUID();
|
|
3359
4218
|
const day = input.day ?? utcDay();
|
|
3360
4219
|
const deps = this.factory.forAgent(input.agentName);
|
|
4220
|
+
this.live.add(runId);
|
|
3361
4221
|
const hooks = this.topLevelHooks({
|
|
3362
4222
|
runId,
|
|
3363
4223
|
deps,
|
|
@@ -3369,14 +4229,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3369
4229
|
...input.agentName !== void 0 ? [
|
|
3370
4230
|
input.agentName
|
|
3371
4231
|
] : []
|
|
3372
|
-
]
|
|
4232
|
+
],
|
|
4233
|
+
input
|
|
3373
4234
|
});
|
|
3374
4235
|
void runAgentLoop({
|
|
3375
4236
|
...deps,
|
|
3376
4237
|
day
|
|
3377
|
-
}, input, hooks).then(() => this.store
|
|
4238
|
+
}, input, hooks).then(() => releaseThreadRun(this.store, input.threadId, runId)).catch(async (error) => {
|
|
3378
4239
|
if (error instanceof RunCancelledError) {
|
|
3379
|
-
await this.settleCancelled(runId, input
|
|
4240
|
+
await this.settleCancelled(runId, input, deps);
|
|
3380
4241
|
return;
|
|
3381
4242
|
}
|
|
3382
4243
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -3393,13 +4254,17 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3393
4254
|
errorCode: code,
|
|
3394
4255
|
errorMessage: message
|
|
3395
4256
|
});
|
|
3396
|
-
await this.store.setActiveStream(input.threadId, null);
|
|
3397
4257
|
const writer = await deps.sink.open(runId);
|
|
4258
|
+
await this.settleQueue(writer, input, runId, "failed", message);
|
|
4259
|
+
await releaseThreadRun(this.store, input.threadId, runId);
|
|
3398
4260
|
await writer.fail({
|
|
3399
4261
|
code,
|
|
3400
4262
|
message
|
|
3401
4263
|
});
|
|
3402
|
-
}).finally(() =>
|
|
4264
|
+
}).finally(() => {
|
|
4265
|
+
this.cancelled.delete(runId);
|
|
4266
|
+
this.live.delete(runId);
|
|
4267
|
+
});
|
|
3403
4268
|
return {
|
|
3404
4269
|
runId
|
|
3405
4270
|
};
|
|
@@ -3442,11 +4307,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3442
4307
|
* the stream ENDED after a `cancelled` frame rather than failed, so a client that retries failed
|
|
3443
4308
|
* streams does not retry this one.
|
|
3444
4309
|
*/
|
|
3445
|
-
async settleCancelled(runId,
|
|
4310
|
+
async settleCancelled(runId, input, deps) {
|
|
3446
4311
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3447
|
-
await this.store.setActiveStream(threadId, null);
|
|
3448
4312
|
const writer = await deps.sink.open(runId);
|
|
3449
|
-
await
|
|
4313
|
+
await this.settleQueue(writer, input, runId, "cancelled");
|
|
4314
|
+
await releaseThreadRun(this.store, input.threadId, runId);
|
|
4315
|
+
await writer.write(encodeStreamEvent2({
|
|
3450
4316
|
kind: "cancelled"
|
|
3451
4317
|
}));
|
|
3452
4318
|
await writer.end();
|
|
@@ -3456,6 +4322,38 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3456
4322
|
});
|
|
3457
4323
|
}
|
|
3458
4324
|
/**
|
|
4325
|
+
* Move the thread past a settling TOP-LEVEL run — to the next queued message, which starts here,
|
|
4326
|
+
* or to a paused/empty queue — and write the resulting `queue` frame into this run's stream. A
|
|
4327
|
+
* no-op without a queue-capable store, and for a run that is not a thread's own turn.
|
|
4328
|
+
*
|
|
4329
|
+
* Never throws: the run is settling either way, and a queue that could not be advanced is picked
|
|
4330
|
+
* up by the next send or resume on the thread.
|
|
4331
|
+
*/
|
|
4332
|
+
async settleQueue(writer, input, runId, outcome, error) {
|
|
4333
|
+
const queue = this.queue;
|
|
4334
|
+
if (queue === void 0 || !queue.supported || !isThreadTurn(input)) {
|
|
4335
|
+
return;
|
|
4336
|
+
}
|
|
4337
|
+
const settled = outcome === "completed" && this.cancelled.has(runId) ? "cancelled" : outcome;
|
|
4338
|
+
try {
|
|
4339
|
+
const frame = await queue.handoff({
|
|
4340
|
+
threadId: input.threadId,
|
|
4341
|
+
runId,
|
|
4342
|
+
outcome: settled,
|
|
4343
|
+
...error !== void 0 ? {
|
|
4344
|
+
error
|
|
4345
|
+
} : {}
|
|
4346
|
+
}, (next, nextRunId) => this.start(next, {
|
|
4347
|
+
runId: nextRunId
|
|
4348
|
+
}));
|
|
4349
|
+
if (frame !== void 0) {
|
|
4350
|
+
await writer.write(encodeStreamEvent2(frame));
|
|
4351
|
+
}
|
|
4352
|
+
} catch (failure) {
|
|
4353
|
+
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
3459
4357
|
* Park a run on a human, keyed by run + tool call. One map for approvals and for question-set
|
|
3460
4358
|
* answers alike: both wait on the same key, and `signal` cannot tell (or need to tell) which
|
|
3461
4359
|
* shape it is delivering — the loop asked for one and only ever gets what the caller sent. A
|
|
@@ -3500,10 +4398,23 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3500
4398
|
});
|
|
3501
4399
|
}
|
|
3502
4400
|
topLevelHooks(args) {
|
|
3503
|
-
const { runId, deps, actor, day, threadId, chainBelow } = args;
|
|
4401
|
+
const { runId, deps, actor, day, threadId, chainBelow, input } = args;
|
|
3504
4402
|
return {
|
|
3505
4403
|
runId,
|
|
3506
|
-
|
|
4404
|
+
// The loop ends the stream when the turn completes. Just before, the thread passes to the next
|
|
4405
|
+
// queued message (or is released), and the reader is told which — so by the time a client
|
|
4406
|
+
// sees the run end, the thread is already free or already running what it queued.
|
|
4407
|
+
openSink: /* @__PURE__ */ __name(async () => {
|
|
4408
|
+
const writer = await deps.sink.open(runId);
|
|
4409
|
+
return this.queue === void 0 ? writer : {
|
|
4410
|
+
write: /* @__PURE__ */ __name((chunk) => writer.write(chunk), "write"),
|
|
4411
|
+
fail: /* @__PURE__ */ __name((error) => writer.fail(error), "fail"),
|
|
4412
|
+
end: /* @__PURE__ */ __name(async () => {
|
|
4413
|
+
await this.settleQueue(writer, input, runId, "completed");
|
|
4414
|
+
await writer.end();
|
|
4415
|
+
}, "end")
|
|
4416
|
+
};
|
|
4417
|
+
}, "openSink"),
|
|
3507
4418
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3508
4419
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3509
4420
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
@@ -3716,16 +4627,22 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3716
4627
|
}
|
|
3717
4628
|
}
|
|
3718
4629
|
};
|
|
3719
|
-
InlineAgentRunner =
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
4630
|
+
InlineAgentRunner = _ts_decorate21([
|
|
4631
|
+
Injectable8(),
|
|
4632
|
+
_ts_param20(0, Inject20(AGENT_DEPS_FACTORY4)),
|
|
4633
|
+
_ts_param20(1, Inject20(AGENT_STORE4)),
|
|
4634
|
+
_ts_param20(2, Optional8()),
|
|
4635
|
+
_ts_metadata21("design:type", Function),
|
|
4636
|
+
_ts_metadata21("design:paramtypes", [
|
|
3725
4637
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3726
|
-
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
4638
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
4639
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
3727
4640
|
])
|
|
3728
4641
|
], InlineAgentRunner);
|
|
4642
|
+
function isThreadTurn(input) {
|
|
4643
|
+
return input.sinkRunId === void 0 && input.deliverTo === void 0;
|
|
4644
|
+
}
|
|
4645
|
+
__name(isThreadTurn, "isThreadTurn");
|
|
3729
4646
|
|
|
3730
4647
|
// src/skills-config.ts
|
|
3731
4648
|
import { compositeSkillProvider } from "@dudousxd/nestjs-agent-core";
|
|
@@ -3766,7 +4683,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3766
4683
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3767
4684
|
|
|
3768
4685
|
// src/agent.module.ts
|
|
3769
|
-
function
|
|
4686
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3770
4687
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3771
4688
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3772
4689
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3779,13 +4696,13 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3779
4696
|
}
|
|
3780
4697
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3781
4698
|
}
|
|
3782
|
-
__name(
|
|
4699
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3783
4700
|
var DEFAULT_PATH = "agent";
|
|
3784
|
-
var logger = new
|
|
4701
|
+
var logger = new Logger6("AgentModule");
|
|
3785
4702
|
function externalStoreWrapper(modules) {
|
|
3786
4703
|
for (const module of modules.values()) {
|
|
3787
4704
|
if (module.metatype === AgentModule) continue;
|
|
3788
|
-
const wrapper = module.providers.get(
|
|
4705
|
+
const wrapper = module.providers.get(AGENT_STORE5);
|
|
3789
4706
|
if (wrapper !== void 0) return wrapper;
|
|
3790
4707
|
}
|
|
3791
4708
|
return void 0;
|
|
@@ -3858,7 +4775,7 @@ function sharedProviders(durable) {
|
|
|
3858
4775
|
provide: AGENT_SKILLS3,
|
|
3859
4776
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3860
4777
|
inject: [
|
|
3861
|
-
|
|
4778
|
+
AGENT_OPTIONS7,
|
|
3862
4779
|
AGENT_SKILL_SOURCES2
|
|
3863
4780
|
]
|
|
3864
4781
|
},
|
|
@@ -3868,58 +4785,58 @@ function sharedProviders(durable) {
|
|
|
3868
4785
|
provide: AGENT_MEMORY3,
|
|
3869
4786
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3870
4787
|
inject: [
|
|
3871
|
-
|
|
4788
|
+
AGENT_OPTIONS7
|
|
3872
4789
|
]
|
|
3873
4790
|
},
|
|
3874
4791
|
{
|
|
3875
|
-
provide:
|
|
4792
|
+
provide: AGENT_SINK3,
|
|
3876
4793
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3877
4794
|
inject: [
|
|
3878
|
-
|
|
4795
|
+
AGENT_OPTIONS7
|
|
3879
4796
|
]
|
|
3880
4797
|
},
|
|
3881
4798
|
{
|
|
3882
4799
|
provide: AGENT_ROLES_POLICY2,
|
|
3883
4800
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3884
4801
|
inject: [
|
|
3885
|
-
|
|
4802
|
+
AGENT_OPTIONS7
|
|
3886
4803
|
]
|
|
3887
4804
|
},
|
|
3888
4805
|
{
|
|
3889
|
-
provide:
|
|
4806
|
+
provide: AGENT_ACTOR_RESOLVER13,
|
|
3890
4807
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
3891
4808
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
3892
4809
|
logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
|
|
3893
4810
|
return new AnonymousActorResolver();
|
|
3894
4811
|
}, "useFactory"),
|
|
3895
4812
|
inject: [
|
|
3896
|
-
|
|
4813
|
+
AGENT_OPTIONS7
|
|
3897
4814
|
]
|
|
3898
4815
|
},
|
|
3899
4816
|
{
|
|
3900
4817
|
provide: AGENT_MODEL2,
|
|
3901
4818
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3902
4819
|
inject: [
|
|
3903
|
-
|
|
4820
|
+
AGENT_OPTIONS7
|
|
3904
4821
|
]
|
|
3905
4822
|
},
|
|
3906
4823
|
{
|
|
3907
4824
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
3908
4825
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
3909
|
-
provide:
|
|
4826
|
+
provide: AGENT_QUOTA_PROVIDER3,
|
|
3910
4827
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
3911
4828
|
warnAt: o.quota.warnAt
|
|
3912
4829
|
} : {}), "useFactory"),
|
|
3913
4830
|
inject: [
|
|
3914
|
-
|
|
3915
|
-
|
|
4831
|
+
AGENT_OPTIONS7,
|
|
4832
|
+
AGENT_STORE5
|
|
3916
4833
|
]
|
|
3917
4834
|
},
|
|
3918
4835
|
{
|
|
3919
4836
|
provide: AGENT_MODEL_CATALOG3,
|
|
3920
4837
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
3921
4838
|
inject: [
|
|
3922
|
-
|
|
4839
|
+
AGENT_OPTIONS7
|
|
3923
4840
|
]
|
|
3924
4841
|
},
|
|
3925
4842
|
AgentDepsFactory2,
|
|
@@ -3932,6 +4849,9 @@ function sharedProviders(durable) {
|
|
|
3932
4849
|
AgentDiscoveryService,
|
|
3933
4850
|
AiToolDiscoveryService,
|
|
3934
4851
|
SkillDiscoveryService,
|
|
4852
|
+
// The thread message queue — every surface, since both runners and the durable workflow settle
|
|
4853
|
+
// into it, and the chat routes enqueue into it.
|
|
4854
|
+
ChatQueueService,
|
|
3935
4855
|
InlineAgentRunner,
|
|
3936
4856
|
AgentService,
|
|
3937
4857
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
@@ -3943,10 +4863,10 @@ function sharedProviders(durable) {
|
|
|
3943
4863
|
}
|
|
3944
4864
|
];
|
|
3945
4865
|
providers.push({
|
|
3946
|
-
provide:
|
|
4866
|
+
provide: AGENT_STORE5,
|
|
3947
4867
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
3948
4868
|
inject: [
|
|
3949
|
-
|
|
4869
|
+
AGENT_OPTIONS7,
|
|
3950
4870
|
ModulesContainer
|
|
3951
4871
|
]
|
|
3952
4872
|
});
|
|
@@ -3977,22 +4897,23 @@ function sharedProviders(durable) {
|
|
|
3977
4897
|
__name(sharedProviders, "sharedProviders");
|
|
3978
4898
|
function exportsFor() {
|
|
3979
4899
|
return [
|
|
3980
|
-
|
|
4900
|
+
AGENT_OPTIONS7,
|
|
3981
4901
|
AGENT_TOOL_REGISTRY3,
|
|
3982
4902
|
AGENT_REGISTRY6,
|
|
3983
|
-
|
|
4903
|
+
AGENT_SINK3,
|
|
3984
4904
|
AGENT_ROLES_POLICY2,
|
|
3985
|
-
|
|
4905
|
+
AGENT_ACTOR_RESOLVER13,
|
|
3986
4906
|
AGENT_MODEL2,
|
|
3987
|
-
|
|
4907
|
+
AGENT_STORE5,
|
|
3988
4908
|
AGENT_MODEL_CATALOG3,
|
|
3989
|
-
|
|
4909
|
+
AGENT_QUOTA_PROVIDER3,
|
|
3990
4910
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
3991
4911
|
AGENT_SKILLS3,
|
|
3992
4912
|
AGENT_MEMORY3,
|
|
3993
4913
|
AGENT_DEPS_FACTORY5,
|
|
3994
4914
|
AgentDepsFactory2,
|
|
3995
4915
|
AgentService,
|
|
4916
|
+
ChatQueueService,
|
|
3996
4917
|
InlineAgentRunner,
|
|
3997
4918
|
AGENT_APPROVAL_PORT
|
|
3998
4919
|
];
|
|
@@ -4000,6 +4921,7 @@ function exportsFor() {
|
|
|
4000
4921
|
__name(exportsFor, "exportsFor");
|
|
4001
4922
|
var BASE_CONTROLLERS = [
|
|
4002
4923
|
ChatController,
|
|
4924
|
+
QueueController,
|
|
4003
4925
|
ThreadsController,
|
|
4004
4926
|
ToolCallController,
|
|
4005
4927
|
QuotaController,
|
|
@@ -4057,7 +4979,7 @@ var AgentModule = class _AgentModule {
|
|
|
4057
4979
|
controllers: controllersForSurface(options.surface),
|
|
4058
4980
|
providers: [
|
|
4059
4981
|
{
|
|
4060
|
-
provide:
|
|
4982
|
+
provide: AGENT_OPTIONS7,
|
|
4061
4983
|
useValue: options
|
|
4062
4984
|
},
|
|
4063
4985
|
...sharedProviders(options.durable ?? false),
|
|
@@ -4080,7 +5002,7 @@ var AgentModule = class _AgentModule {
|
|
|
4080
5002
|
controllers: controllersForSurface(options.surface),
|
|
4081
5003
|
providers: [
|
|
4082
5004
|
{
|
|
4083
|
-
provide:
|
|
5005
|
+
provide: AGENT_OPTIONS7,
|
|
4084
5006
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4085
5007
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4086
5008
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4101,7 +5023,7 @@ var AgentModule = class _AgentModule {
|
|
|
4101
5023
|
};
|
|
4102
5024
|
}
|
|
4103
5025
|
};
|
|
4104
|
-
AgentModule =
|
|
5026
|
+
AgentModule = _ts_decorate22([
|
|
4105
5027
|
Global(),
|
|
4106
5028
|
Module({})
|
|
4107
5029
|
], AgentModule);
|
|
@@ -4197,6 +5119,7 @@ export {
|
|
|
4197
5119
|
AiToolDiscoveryService,
|
|
4198
5120
|
AnonymousActorResolver,
|
|
4199
5121
|
AttachmentsController,
|
|
5122
|
+
ChatQueueService,
|
|
4200
5123
|
ConfigController,
|
|
4201
5124
|
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
4202
5125
|
DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
@@ -4208,6 +5131,7 @@ export {
|
|
|
4208
5131
|
MemoriesController,
|
|
4209
5132
|
MessagesController,
|
|
4210
5133
|
ModelsController,
|
|
5134
|
+
QueueController,
|
|
4211
5135
|
SKILL_METADATA,
|
|
4212
5136
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
4213
5137
|
SYSTEM_PROMPT_METADATA,
|