@dudousxd/nestjs-agent 1.14.0 → 1.16.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 +21 -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 +1845 -751
- 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 +1675 -581
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +1649 -666
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -7
- package/dist/index.d.ts +152 -7
- package/dist/index.js +1459 -478
- 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,248 @@ 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);
|
|
484
1052
|
return {
|
|
485
|
-
|
|
486
|
-
|
|
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
|
+
} : {}
|
|
487
1064
|
};
|
|
488
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
|
+
/**
|
|
1116
|
+
* `POST <base>/queue/:messageId/interrupt` — run a message that is already waiting NOW: it moves
|
|
1117
|
+
* to the head of its queue marked as an interrupt, any pause is lifted, and the running turn is
|
|
1118
|
+
* cancelled (its settle starts this message — the same path a `mode: 'interrupt'` send takes).
|
|
1119
|
+
* With nothing running, the message starts at once.
|
|
1120
|
+
*
|
|
1121
|
+
* One request, and the message never leaves the queue: a client that removed it and sent it again
|
|
1122
|
+
* would lose it if the second call failed, and would run it twice if another tab's drain started
|
|
1123
|
+
* it in between. Answers the queue, plus `interrupting` (the run that was cancelled) or `runId`
|
|
1124
|
+
* (the run this message started).
|
|
1125
|
+
*/
|
|
1126
|
+
async interruptQueuedMessage(actor, messageId) {
|
|
1127
|
+
const queue = this.requireQueue();
|
|
1128
|
+
const store = queue.queueStore();
|
|
1129
|
+
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1130
|
+
const gone = /* @__PURE__ */ __name(() => new GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
1131
|
+
const marked = await store.updateQueuedMessage(messageId, {
|
|
1132
|
+
interrupt: true
|
|
1133
|
+
});
|
|
1134
|
+
if (marked === null) {
|
|
1135
|
+
throw gone();
|
|
1136
|
+
}
|
|
1137
|
+
if (marked.interrupt !== true) {
|
|
1138
|
+
throw new NotImplementedException2("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
1139
|
+
}
|
|
1140
|
+
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
1141
|
+
throw gone();
|
|
1142
|
+
}
|
|
1143
|
+
await store.setQueuePause(threadId, null);
|
|
1144
|
+
const { live } = await queue.holder(threadId, this.runner);
|
|
1145
|
+
if (live !== null && live !== messageId && await store.getQueuedMessage(messageId) !== null) {
|
|
1146
|
+
const state2 = await queue.publish(threadId);
|
|
1147
|
+
await this.runner.cancel(live);
|
|
1148
|
+
return {
|
|
1149
|
+
...state2,
|
|
1150
|
+
interrupting: live
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
if (live !== null) {
|
|
1154
|
+
return {
|
|
1155
|
+
...await queue.state(threadId),
|
|
1156
|
+
runId: messageId
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
const runId = await queue.kick(threadId, this.runner);
|
|
1160
|
+
const state = runId === void 0 ? await queue.publish(threadId) : await queue.state(threadId);
|
|
1161
|
+
return {
|
|
1162
|
+
...state,
|
|
1163
|
+
...runId !== void 0 ? {
|
|
1164
|
+
runId
|
|
1165
|
+
} : {}
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
/** `DELETE <base>/threads/:id/queue` — drop every waiting message (and any pause). */
|
|
1169
|
+
async clearQueue(actor, threadId) {
|
|
1170
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1171
|
+
const queue = this.requireQueue();
|
|
1172
|
+
await queue.queueStore().clearQueue(threadId);
|
|
1173
|
+
await queue.queueStore().setQueuePause(threadId, null);
|
|
1174
|
+
return queue.publish(threadId);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* `POST <base>/threads/:id/queue/resume` — lift a pause and start the head when nothing is
|
|
1178
|
+
* running. Answers the queue, and the run the head started under, if it did.
|
|
1179
|
+
*/
|
|
1180
|
+
async resumeQueue(actor, threadId) {
|
|
1181
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1182
|
+
const queue = this.requireQueue();
|
|
1183
|
+
await queue.queueStore().setQueuePause(threadId, null);
|
|
1184
|
+
const runId = await queue.kick(threadId, this.runner);
|
|
1185
|
+
const state = runId === void 0 ? await queue.publish(threadId) : await queue.state(threadId);
|
|
1186
|
+
return {
|
|
1187
|
+
...state,
|
|
1188
|
+
...runId !== void 0 ? {
|
|
1189
|
+
runId
|
|
1190
|
+
} : {}
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
/** The thread a queued message waits on, once the caller is shown to own it. */
|
|
1194
|
+
async assertOwnsQueuedMessage(actor, messageId) {
|
|
1195
|
+
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
1196
|
+
if (message === null) {
|
|
1197
|
+
throw new NotFoundException(`queued message ${messageId} not found`);
|
|
1198
|
+
}
|
|
1199
|
+
await this.assertOwnsThread(actor, message.threadId);
|
|
1200
|
+
return message.threadId;
|
|
1201
|
+
}
|
|
489
1202
|
/**
|
|
490
1203
|
* Rebuild this turn's attachments from the staging store, keyed by the ids the caller claimed.
|
|
491
1204
|
* The model provider fetches {@link MessageAttachment.url} verbatim, so that url is only ever
|
|
@@ -502,7 +1215,7 @@ var AgentService = class {
|
|
|
502
1215
|
}
|
|
503
1216
|
const staging = this.staging;
|
|
504
1217
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
505
|
-
throw new
|
|
1218
|
+
throw new NotImplementedException2("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
506
1219
|
}
|
|
507
1220
|
const resolved = [];
|
|
508
1221
|
for (const ref of refs) {
|
|
@@ -660,7 +1373,7 @@ var AgentService = class {
|
|
|
660
1373
|
return;
|
|
661
1374
|
}
|
|
662
1375
|
if (this.store.updateThread === void 0) {
|
|
663
|
-
throw new
|
|
1376
|
+
throw new NotImplementedException2("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
664
1377
|
}
|
|
665
1378
|
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
1379
|
await this.store.updateThread(threadId, {
|
|
@@ -725,9 +1438,13 @@ var AgentService = class {
|
|
|
725
1438
|
}
|
|
726
1439
|
async toDetailView(thread, actor) {
|
|
727
1440
|
const summary = await this.toSummaryView(thread);
|
|
1441
|
+
const queue = this.queueing();
|
|
728
1442
|
return {
|
|
729
1443
|
...summary,
|
|
730
|
-
messages: await this.freshAttachmentUrls(thread.messages, actor)
|
|
1444
|
+
messages: await this.freshAttachmentUrls(thread.messages, actor),
|
|
1445
|
+
...queue !== void 0 ? {
|
|
1446
|
+
queue: await queue.state(thread.id)
|
|
1447
|
+
} : {}
|
|
731
1448
|
};
|
|
732
1449
|
}
|
|
733
1450
|
/**
|
|
@@ -790,7 +1507,7 @@ var AgentService = class {
|
|
|
790
1507
|
throw new BadRequestException("comment must be at most 2000 characters");
|
|
791
1508
|
}
|
|
792
1509
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
793
|
-
throw new
|
|
1510
|
+
throw new NotImplementedException2("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
794
1511
|
}
|
|
795
1512
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
796
1513
|
if (threadId === null) {
|
|
@@ -842,7 +1559,7 @@ var AgentService = class {
|
|
|
842
1559
|
const list = this.attachmentInventory();
|
|
843
1560
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
844
1561
|
if (referencedMediaIds === void 0) {
|
|
845
|
-
throw new
|
|
1562
|
+
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
1563
|
}
|
|
847
1564
|
const stagedBefore = options.olderThan.toISOString();
|
|
848
1565
|
const inventory = await list({
|
|
@@ -864,7 +1581,7 @@ var AgentService = class {
|
|
|
864
1581
|
attachmentInventory() {
|
|
865
1582
|
const list = this.staging?.list?.bind(this.staging);
|
|
866
1583
|
if (list === void 0) {
|
|
867
|
-
throw new
|
|
1584
|
+
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
1585
|
}
|
|
869
1586
|
return list;
|
|
870
1587
|
}
|
|
@@ -982,34 +1699,36 @@ var AgentService = class {
|
|
|
982
1699
|
}
|
|
983
1700
|
}
|
|
984
1701
|
};
|
|
985
|
-
AgentService =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1702
|
+
AgentService = _ts_decorate3([
|
|
1703
|
+
Injectable3(),
|
|
1704
|
+
_ts_param3(0, Inject3(AGENT_RUNNER)),
|
|
1705
|
+
_ts_param3(1, Inject3(AGENT_STORE3)),
|
|
1706
|
+
_ts_param3(2, Inject3(AGENT_DEPS_FACTORY)),
|
|
1707
|
+
_ts_param3(3, Optional3()),
|
|
1708
|
+
_ts_param3(3, Inject3(AGENT_ATTACHMENT_STAGING2)),
|
|
1709
|
+
_ts_param3(4, Optional3()),
|
|
1710
|
+
_ts_param3(4, Inject3(AGENT_MODEL_CATALOG)),
|
|
1711
|
+
_ts_param3(5, Optional3()),
|
|
1712
|
+
_ts_param3(5, Inject3(AGENT_QUOTA_PROVIDER2)),
|
|
1713
|
+
_ts_param3(6, Optional3()),
|
|
1714
|
+
_ts_param3(6, Inject3(AGENT_OPTIONS3)),
|
|
1715
|
+
_ts_param3(7, Optional3()),
|
|
1716
|
+
_ts_metadata3("design:type", Function),
|
|
1717
|
+
_ts_metadata3("design:paramtypes", [
|
|
1000
1718
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1001
1719
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1002
1720
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1003
1721
|
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1004
1722
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1005
1723
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
1006
|
-
typeof Pick === "undefined" ? Object : Pick
|
|
1724
|
+
typeof Pick === "undefined" ? Object : Pick,
|
|
1725
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
1007
1726
|
])
|
|
1008
1727
|
], AgentService);
|
|
1009
1728
|
|
|
1010
1729
|
// src/approval-port.adapter.ts
|
|
1011
|
-
import { Injectable as
|
|
1012
|
-
function
|
|
1730
|
+
import { Injectable as Injectable4 } from "@nestjs/common";
|
|
1731
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1013
1732
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1014
1733
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1015
1734
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1022,13 +1741,13 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1022
1741
|
}
|
|
1023
1742
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1024
1743
|
}
|
|
1025
|
-
__name(
|
|
1026
|
-
function
|
|
1744
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
1745
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
1027
1746
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1028
1747
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1029
1748
|
}
|
|
1030
1749
|
}
|
|
1031
|
-
__name(
|
|
1750
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1032
1751
|
var AgentApprovalPortAdapter = class {
|
|
1033
1752
|
static {
|
|
1034
1753
|
__name(this, "AgentApprovalPortAdapter");
|
|
@@ -1066,18 +1785,18 @@ var AgentApprovalPortAdapter = class {
|
|
|
1066
1785
|
});
|
|
1067
1786
|
}
|
|
1068
1787
|
};
|
|
1069
|
-
AgentApprovalPortAdapter =
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1788
|
+
AgentApprovalPortAdapter = _ts_decorate4([
|
|
1789
|
+
Injectable4(),
|
|
1790
|
+
_ts_metadata4("design:type", Function),
|
|
1791
|
+
_ts_metadata4("design:paramtypes", [
|
|
1073
1792
|
typeof AgentService === "undefined" ? Object : AgentService
|
|
1074
1793
|
])
|
|
1075
1794
|
], AgentApprovalPortAdapter);
|
|
1076
1795
|
|
|
1077
1796
|
// src/controller/agents.controller.ts
|
|
1078
1797
|
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
|
|
1798
|
+
import { Controller, Get, Inject as Inject4 } from "@nestjs/common";
|
|
1799
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1081
1800
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1082
1801
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1083
1802
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1090,19 +1809,19 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
1090
1809
|
}
|
|
1091
1810
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1092
1811
|
}
|
|
1093
|
-
__name(
|
|
1094
|
-
function
|
|
1812
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1813
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
1095
1814
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1096
1815
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1097
1816
|
}
|
|
1098
1817
|
}
|
|
1099
|
-
__name(
|
|
1100
|
-
function
|
|
1818
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1819
|
+
function _ts_param4(paramIndex, decorator) {
|
|
1101
1820
|
return function(target, key) {
|
|
1102
1821
|
decorator(target, key, paramIndex);
|
|
1103
1822
|
};
|
|
1104
1823
|
}
|
|
1105
|
-
__name(
|
|
1824
|
+
__name(_ts_param4, "_ts_param");
|
|
1106
1825
|
var AgentsController = class {
|
|
1107
1826
|
static {
|
|
1108
1827
|
__name(this, "AgentsController");
|
|
@@ -1124,26 +1843,26 @@ var AgentsController = class {
|
|
|
1124
1843
|
}));
|
|
1125
1844
|
}
|
|
1126
1845
|
};
|
|
1127
|
-
|
|
1846
|
+
_ts_decorate5([
|
|
1128
1847
|
Get(),
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1848
|
+
_ts_metadata5("design:type", Function),
|
|
1849
|
+
_ts_metadata5("design:paramtypes", []),
|
|
1850
|
+
_ts_metadata5("design:returntype", Array)
|
|
1132
1851
|
], AgentsController.prototype, "list", null);
|
|
1133
|
-
AgentsController =
|
|
1852
|
+
AgentsController = _ts_decorate5([
|
|
1134
1853
|
Controller("agents"),
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1854
|
+
_ts_param4(0, Inject4(AGENT_REGISTRY2)),
|
|
1855
|
+
_ts_param4(1, Inject4(AGENT_DEPS_FACTORY2)),
|
|
1856
|
+
_ts_metadata5("design:type", Function),
|
|
1857
|
+
_ts_metadata5("design:paramtypes", [
|
|
1139
1858
|
typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
|
|
1140
1859
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
1141
1860
|
])
|
|
1142
1861
|
], AgentsController);
|
|
1143
1862
|
|
|
1144
1863
|
// 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
|
|
1864
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
|
|
1865
|
+
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
1866
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
1148
1867
|
|
|
1149
1868
|
// src/attachment-limits.ts
|
|
@@ -1172,7 +1891,7 @@ function attachmentLimits(options, staging) {
|
|
|
1172
1891
|
__name(attachmentLimits, "attachmentLimits");
|
|
1173
1892
|
|
|
1174
1893
|
// src/controller/attachments.controller.ts
|
|
1175
|
-
function
|
|
1894
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1176
1895
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1177
1896
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1178
1897
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1185,19 +1904,19 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1185
1904
|
}
|
|
1186
1905
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1187
1906
|
}
|
|
1188
|
-
__name(
|
|
1189
|
-
function
|
|
1907
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1908
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
1190
1909
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1191
1910
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1192
1911
|
}
|
|
1193
1912
|
}
|
|
1194
|
-
__name(
|
|
1195
|
-
function
|
|
1913
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1914
|
+
function _ts_param5(paramIndex, decorator) {
|
|
1196
1915
|
return function(target, key) {
|
|
1197
1916
|
decorator(target, key, paramIndex);
|
|
1198
1917
|
};
|
|
1199
1918
|
}
|
|
1200
|
-
__name(
|
|
1919
|
+
__name(_ts_param5, "_ts_param");
|
|
1201
1920
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
1202
1921
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
1203
1922
|
var AttachmentsController = class {
|
|
@@ -1231,7 +1950,7 @@ var AttachmentsController = class {
|
|
|
1231
1950
|
}
|
|
1232
1951
|
async upload(req, file) {
|
|
1233
1952
|
if (this.staging === void 0) {
|
|
1234
|
-
throw new
|
|
1953
|
+
throw new NotImplementedException3("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
1235
1954
|
}
|
|
1236
1955
|
if (file === void 0) {
|
|
1237
1956
|
throw new BadRequestException2('multipart field "file" is required');
|
|
@@ -1253,39 +1972,39 @@ var AttachmentsController = class {
|
|
|
1253
1972
|
});
|
|
1254
1973
|
}
|
|
1255
1974
|
};
|
|
1256
|
-
|
|
1975
|
+
_ts_decorate6([
|
|
1257
1976
|
Get2(),
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1977
|
+
_ts_param5(0, Req()),
|
|
1978
|
+
_ts_metadata6("design:type", Function),
|
|
1979
|
+
_ts_metadata6("design:paramtypes", [
|
|
1261
1980
|
typeof Request === "undefined" ? Object : Request
|
|
1262
1981
|
]),
|
|
1263
|
-
|
|
1982
|
+
_ts_metadata6("design:returntype", Promise)
|
|
1264
1983
|
], AttachmentsController.prototype, "list", null);
|
|
1265
|
-
|
|
1984
|
+
_ts_decorate6([
|
|
1266
1985
|
Post(),
|
|
1267
1986
|
UseInterceptors(FileInterceptor("file", {
|
|
1268
1987
|
limits: {
|
|
1269
1988
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
1270
1989
|
}
|
|
1271
1990
|
})),
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1991
|
+
_ts_param5(0, Req()),
|
|
1992
|
+
_ts_param5(1, UploadedFile()),
|
|
1993
|
+
_ts_metadata6("design:type", Function),
|
|
1994
|
+
_ts_metadata6("design:paramtypes", [
|
|
1276
1995
|
typeof Request === "undefined" ? Object : Request,
|
|
1277
1996
|
Object
|
|
1278
1997
|
]),
|
|
1279
|
-
|
|
1998
|
+
_ts_metadata6("design:returntype", Promise)
|
|
1280
1999
|
], AttachmentsController.prototype, "upload", null);
|
|
1281
|
-
AttachmentsController =
|
|
2000
|
+
AttachmentsController = _ts_decorate6([
|
|
1282
2001
|
Controller2("attachments"),
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
2002
|
+
_ts_param5(0, Inject5(AGENT_OPTIONS4)),
|
|
2003
|
+
_ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER)),
|
|
2004
|
+
_ts_param5(3, Optional4()),
|
|
2005
|
+
_ts_param5(3, Inject5(AGENT_ATTACHMENT_STAGING3)),
|
|
2006
|
+
_ts_metadata6("design:type", Function),
|
|
2007
|
+
_ts_metadata6("design:paramtypes", [
|
|
1289
2008
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
1290
2009
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1291
2010
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -1295,8 +2014,8 @@ AttachmentsController = _ts_decorate5([
|
|
|
1295
2014
|
|
|
1296
2015
|
// src/controller/chat.controller.ts
|
|
1297
2016
|
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
|
|
2017
|
+
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";
|
|
2018
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1300
2019
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1301
2020
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1302
2021
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1309,19 +2028,32 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1309
2028
|
}
|
|
1310
2029
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1311
2030
|
}
|
|
1312
|
-
__name(
|
|
1313
|
-
function
|
|
2031
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
2032
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
1314
2033
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1315
2034
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1316
2035
|
}
|
|
1317
2036
|
}
|
|
1318
|
-
__name(
|
|
1319
|
-
function
|
|
2037
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2038
|
+
function _ts_param6(paramIndex, decorator) {
|
|
1320
2039
|
return function(target, key) {
|
|
1321
2040
|
decorator(target, key, paramIndex);
|
|
1322
2041
|
};
|
|
1323
2042
|
}
|
|
1324
|
-
__name(
|
|
2043
|
+
__name(_ts_param6, "_ts_param");
|
|
2044
|
+
function sendMode(body) {
|
|
2045
|
+
if (body.interrupt === true) {
|
|
2046
|
+
return "interrupt";
|
|
2047
|
+
}
|
|
2048
|
+
if (body.mode === void 0 || body.mode === null) {
|
|
2049
|
+
return "auto";
|
|
2050
|
+
}
|
|
2051
|
+
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
2052
|
+
return body.mode;
|
|
2053
|
+
}
|
|
2054
|
+
throw new BadRequestException3("mode must be 'auto', 'queue' or 'interrupt'");
|
|
2055
|
+
}
|
|
2056
|
+
__name(sendMode, "sendMode");
|
|
1325
2057
|
function attachmentRefs(claimed) {
|
|
1326
2058
|
if (claimed === void 0) {
|
|
1327
2059
|
return [];
|
|
@@ -1359,10 +2091,17 @@ var ChatController = class {
|
|
|
1359
2091
|
this.agent = agent;
|
|
1360
2092
|
this.actorResolver = actorResolver;
|
|
1361
2093
|
}
|
|
2094
|
+
/**
|
|
2095
|
+
* Start a turn and stream it — or, when the thread already has one running, queue the message and
|
|
2096
|
+
* answer `202 { queued: true, messageId, position, queue, … }` (JSON, no stream): it runs when the
|
|
2097
|
+
* turn ahead of it settles, and the stream of the run holding the thread announces it with a
|
|
2098
|
+
* `queue` frame.
|
|
2099
|
+
*/
|
|
1362
2100
|
async chat(req, res, body) {
|
|
1363
2101
|
const actor = await this.actorResolver.resolve(req);
|
|
1364
2102
|
const attachments = attachmentRefs(body.attachments);
|
|
1365
|
-
const
|
|
2103
|
+
const mode = sendMode(body);
|
|
2104
|
+
const result = await this.agent.send({
|
|
1366
2105
|
actor,
|
|
1367
2106
|
message: body.message,
|
|
1368
2107
|
...body.threadId !== void 0 ? {
|
|
@@ -1385,8 +2124,14 @@ var ChatController = class {
|
|
|
1385
2124
|
} : {},
|
|
1386
2125
|
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
1387
2126
|
model: body.model
|
|
1388
|
-
} : {}
|
|
2127
|
+
} : {},
|
|
2128
|
+
mode
|
|
1389
2129
|
});
|
|
2130
|
+
if (result.queued === true) {
|
|
2131
|
+
res.status(202).json(result);
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const { runId, threadId } = result;
|
|
1390
2135
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
1391
2136
|
}
|
|
1392
2137
|
/**
|
|
@@ -1476,50 +2221,50 @@ data: ${JSON.stringify(payload)}
|
|
|
1476
2221
|
res.end();
|
|
1477
2222
|
}
|
|
1478
2223
|
};
|
|
1479
|
-
|
|
2224
|
+
_ts_decorate7([
|
|
1480
2225
|
Post2("chat"),
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
2226
|
+
_ts_param6(0, Req2()),
|
|
2227
|
+
_ts_param6(1, Res()),
|
|
2228
|
+
_ts_param6(2, Body()),
|
|
2229
|
+
_ts_metadata7("design:type", Function),
|
|
2230
|
+
_ts_metadata7("design:paramtypes", [
|
|
1486
2231
|
typeof Request === "undefined" ? Object : Request,
|
|
1487
2232
|
typeof Response === "undefined" ? Object : Response,
|
|
1488
2233
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
1489
2234
|
]),
|
|
1490
|
-
|
|
2235
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1491
2236
|
], ChatController.prototype, "chat", null);
|
|
1492
|
-
|
|
2237
|
+
_ts_decorate7([
|
|
1493
2238
|
Get3("chat/:runId/stream"),
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
2239
|
+
_ts_param6(0, Req2()),
|
|
2240
|
+
_ts_param6(1, Param("runId")),
|
|
2241
|
+
_ts_param6(2, Res()),
|
|
2242
|
+
_ts_param6(3, Query("after")),
|
|
2243
|
+
_ts_metadata7("design:type", Function),
|
|
2244
|
+
_ts_metadata7("design:paramtypes", [
|
|
1500
2245
|
typeof Request === "undefined" ? Object : Request,
|
|
1501
2246
|
String,
|
|
1502
2247
|
typeof Response === "undefined" ? Object : Response,
|
|
1503
2248
|
String
|
|
1504
2249
|
]),
|
|
1505
|
-
|
|
2250
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1506
2251
|
], ChatController.prototype, "stream", null);
|
|
1507
|
-
|
|
2252
|
+
_ts_decorate7([
|
|
1508
2253
|
Post2("chat/:runId/cancel"),
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
2254
|
+
_ts_param6(0, Req2()),
|
|
2255
|
+
_ts_param6(1, Param("runId")),
|
|
2256
|
+
_ts_metadata7("design:type", Function),
|
|
2257
|
+
_ts_metadata7("design:paramtypes", [
|
|
1513
2258
|
typeof Request === "undefined" ? Object : Request,
|
|
1514
2259
|
String
|
|
1515
2260
|
]),
|
|
1516
|
-
|
|
2261
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1517
2262
|
], ChatController.prototype, "cancel", null);
|
|
1518
|
-
ChatController =
|
|
2263
|
+
ChatController = _ts_decorate7([
|
|
1519
2264
|
Controller3(),
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
2265
|
+
_ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER2)),
|
|
2266
|
+
_ts_metadata7("design:type", Function),
|
|
2267
|
+
_ts_metadata7("design:paramtypes", [
|
|
1523
2268
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1524
2269
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1525
2270
|
])
|
|
@@ -1535,8 +2280,8 @@ function parseCursor(raw) {
|
|
|
1535
2280
|
__name(parseCursor, "parseCursor");
|
|
1536
2281
|
|
|
1537
2282
|
// 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
|
|
2283
|
+
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";
|
|
2284
|
+
import { Controller as Controller4, Get as Get4, Inject as Inject7, Optional as Optional5, Req as Req3 } from "@nestjs/common";
|
|
1540
2285
|
|
|
1541
2286
|
// src/resolver/anonymous-actor-resolver.ts
|
|
1542
2287
|
import { createHash, randomBytes } from "crypto";
|
|
@@ -1626,7 +2371,7 @@ var AnonymousActorResolver = class {
|
|
|
1626
2371
|
};
|
|
1627
2372
|
|
|
1628
2373
|
// src/controller/config.controller.ts
|
|
1629
|
-
function
|
|
2374
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1630
2375
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1631
2376
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1632
2377
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1639,19 +2384,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1639
2384
|
}
|
|
1640
2385
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1641
2386
|
}
|
|
1642
|
-
__name(
|
|
1643
|
-
function
|
|
2387
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2388
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
1644
2389
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1645
2390
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1646
2391
|
}
|
|
1647
2392
|
}
|
|
1648
|
-
__name(
|
|
1649
|
-
function
|
|
2393
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2394
|
+
function _ts_param7(paramIndex, decorator) {
|
|
1650
2395
|
return function(target, key) {
|
|
1651
2396
|
decorator(target, key, paramIndex);
|
|
1652
2397
|
};
|
|
1653
2398
|
}
|
|
1654
|
-
__name(
|
|
2399
|
+
__name(_ts_param7, "_ts_param");
|
|
1655
2400
|
var ConfigController = class {
|
|
1656
2401
|
static {
|
|
1657
2402
|
__name(this, "ConfigController");
|
|
@@ -1682,25 +2427,25 @@ var ConfigController = class {
|
|
|
1682
2427
|
};
|
|
1683
2428
|
}
|
|
1684
2429
|
};
|
|
1685
|
-
|
|
2430
|
+
_ts_decorate8([
|
|
1686
2431
|
Get4(),
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
2432
|
+
_ts_param7(0, Req3()),
|
|
2433
|
+
_ts_metadata8("design:type", Function),
|
|
2434
|
+
_ts_metadata8("design:paramtypes", [
|
|
1690
2435
|
typeof Request === "undefined" ? Object : Request
|
|
1691
2436
|
]),
|
|
1692
|
-
|
|
2437
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1693
2438
|
], ConfigController.prototype, "config", null);
|
|
1694
|
-
ConfigController =
|
|
2439
|
+
ConfigController = _ts_decorate8([
|
|
1695
2440
|
Controller4("config"),
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
2441
|
+
_ts_param7(0, Inject7(AGENT_OPTIONS5)),
|
|
2442
|
+
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER3)),
|
|
2443
|
+
_ts_param7(2, Optional5()),
|
|
2444
|
+
_ts_param7(2, Inject7(AGENT_ATTACHMENT_STAGING4)),
|
|
2445
|
+
_ts_param7(3, Optional5()),
|
|
2446
|
+
_ts_param7(3, Inject7(AGENT_MODEL_CATALOG2)),
|
|
2447
|
+
_ts_metadata8("design:type", Function),
|
|
2448
|
+
_ts_metadata8("design:paramtypes", [
|
|
1704
2449
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
1705
2450
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1706
2451
|
Object,
|
|
@@ -1710,8 +2455,8 @@ ConfigController = _ts_decorate7([
|
|
|
1710
2455
|
|
|
1711
2456
|
// src/controller/memories.controller.ts
|
|
1712
2457
|
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
|
|
2458
|
+
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";
|
|
2459
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1715
2460
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1716
2461
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1717
2462
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1724,19 +2469,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1724
2469
|
}
|
|
1725
2470
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1726
2471
|
}
|
|
1727
|
-
__name(
|
|
1728
|
-
function
|
|
2472
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2473
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
1729
2474
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1730
2475
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1731
2476
|
}
|
|
1732
2477
|
}
|
|
1733
|
-
__name(
|
|
1734
|
-
function
|
|
2478
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2479
|
+
function _ts_param8(paramIndex, decorator) {
|
|
1735
2480
|
return function(target, key) {
|
|
1736
2481
|
decorator(target, key, paramIndex);
|
|
1737
2482
|
};
|
|
1738
2483
|
}
|
|
1739
|
-
__name(
|
|
2484
|
+
__name(_ts_param8, "_ts_param");
|
|
1740
2485
|
var MemoriesController = class {
|
|
1741
2486
|
static {
|
|
1742
2487
|
__name(this, "MemoriesController");
|
|
@@ -1809,35 +2554,35 @@ var MemoriesController = class {
|
|
|
1809
2554
|
});
|
|
1810
2555
|
}
|
|
1811
2556
|
};
|
|
1812
|
-
|
|
2557
|
+
_ts_decorate9([
|
|
1813
2558
|
Get5(),
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
2559
|
+
_ts_param8(0, Req4()),
|
|
2560
|
+
_ts_param8(1, Query2("threadId")),
|
|
2561
|
+
_ts_metadata9("design:type", Function),
|
|
2562
|
+
_ts_metadata9("design:paramtypes", [
|
|
1818
2563
|
typeof Request === "undefined" ? Object : Request,
|
|
1819
2564
|
String
|
|
1820
2565
|
]),
|
|
1821
|
-
|
|
2566
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1822
2567
|
], MemoriesController.prototype, "list", null);
|
|
1823
|
-
|
|
2568
|
+
_ts_decorate9([
|
|
1824
2569
|
Delete(":id"),
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2570
|
+
_ts_param8(0, Req4()),
|
|
2571
|
+
_ts_param8(1, Param2("id")),
|
|
2572
|
+
_ts_metadata9("design:type", Function),
|
|
2573
|
+
_ts_metadata9("design:paramtypes", [
|
|
1829
2574
|
typeof Request === "undefined" ? Object : Request,
|
|
1830
2575
|
String
|
|
1831
2576
|
]),
|
|
1832
|
-
|
|
2577
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1833
2578
|
], MemoriesController.prototype, "forget", null);
|
|
1834
|
-
MemoriesController =
|
|
2579
|
+
MemoriesController = _ts_decorate9([
|
|
1835
2580
|
Controller5("memories"),
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
2581
|
+
_ts_param8(0, Inject8(AGENT_ACTOR_RESOLVER4)),
|
|
2582
|
+
_ts_param8(1, Optional6()),
|
|
2583
|
+
_ts_param8(1, Inject8(AGENT_MEMORY2)),
|
|
2584
|
+
_ts_metadata9("design:type", Function),
|
|
2585
|
+
_ts_metadata9("design:paramtypes", [
|
|
1841
2586
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1842
2587
|
Object
|
|
1843
2588
|
])
|
|
@@ -1845,8 +2590,8 @@ MemoriesController = _ts_decorate8([
|
|
|
1845
2590
|
|
|
1846
2591
|
// src/controller/messages.controller.ts
|
|
1847
2592
|
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
|
|
2593
|
+
import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject9, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
|
|
2594
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1850
2595
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1851
2596
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1852
2597
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1859,19 +2604,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
1859
2604
|
}
|
|
1860
2605
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1861
2606
|
}
|
|
1862
|
-
__name(
|
|
1863
|
-
function
|
|
2607
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
2608
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
1864
2609
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1865
2610
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1866
2611
|
}
|
|
1867
2612
|
}
|
|
1868
|
-
__name(
|
|
1869
|
-
function
|
|
2613
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2614
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1870
2615
|
return function(target, key) {
|
|
1871
2616
|
decorator(target, key, paramIndex);
|
|
1872
2617
|
};
|
|
1873
2618
|
}
|
|
1874
|
-
__name(
|
|
2619
|
+
__name(_ts_param9, "_ts_param");
|
|
1875
2620
|
var MessagesController = class {
|
|
1876
2621
|
static {
|
|
1877
2622
|
__name(this, "MessagesController");
|
|
@@ -1899,25 +2644,25 @@ var MessagesController = class {
|
|
|
1899
2644
|
};
|
|
1900
2645
|
}
|
|
1901
2646
|
};
|
|
1902
|
-
|
|
2647
|
+
_ts_decorate10([
|
|
1903
2648
|
Post3(":id/feedback"),
|
|
1904
2649
|
HttpCode(200),
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
2650
|
+
_ts_param9(0, Req5()),
|
|
2651
|
+
_ts_param9(1, Param3("id")),
|
|
2652
|
+
_ts_param9(2, Body2()),
|
|
2653
|
+
_ts_metadata10("design:type", Function),
|
|
2654
|
+
_ts_metadata10("design:paramtypes", [
|
|
1910
2655
|
typeof Request === "undefined" ? Object : Request,
|
|
1911
2656
|
String,
|
|
1912
2657
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
1913
2658
|
]),
|
|
1914
|
-
|
|
2659
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1915
2660
|
], MessagesController.prototype, "feedback", null);
|
|
1916
|
-
MessagesController =
|
|
2661
|
+
MessagesController = _ts_decorate10([
|
|
1917
2662
|
Controller6("messages"),
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2663
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER5)),
|
|
2664
|
+
_ts_metadata10("design:type", Function),
|
|
2665
|
+
_ts_metadata10("design:paramtypes", [
|
|
1921
2666
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1922
2667
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1923
2668
|
])
|
|
@@ -1925,8 +2670,8 @@ MessagesController = _ts_decorate9([
|
|
|
1925
2670
|
|
|
1926
2671
|
// src/controller/models.controller.ts
|
|
1927
2672
|
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
|
|
2673
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject10, Query as Query3, Req as Req6 } from "@nestjs/common";
|
|
2674
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1930
2675
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1931
2676
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1932
2677
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1939,19 +2684,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1939
2684
|
}
|
|
1940
2685
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1941
2686
|
}
|
|
1942
|
-
__name(
|
|
1943
|
-
function
|
|
2687
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2688
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
1944
2689
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1945
2690
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1946
2691
|
}
|
|
1947
2692
|
}
|
|
1948
|
-
__name(
|
|
1949
|
-
function
|
|
2693
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2694
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1950
2695
|
return function(target, key) {
|
|
1951
2696
|
decorator(target, key, paramIndex);
|
|
1952
2697
|
};
|
|
1953
2698
|
}
|
|
1954
|
-
__name(
|
|
2699
|
+
__name(_ts_param10, "_ts_param");
|
|
1955
2700
|
var ModelsController = class {
|
|
1956
2701
|
static {
|
|
1957
2702
|
__name(this, "ModelsController");
|
|
@@ -1971,31 +2716,31 @@ var ModelsController = class {
|
|
|
1971
2716
|
return this.agent.listModels(actor, agent);
|
|
1972
2717
|
}
|
|
1973
2718
|
};
|
|
1974
|
-
|
|
2719
|
+
_ts_decorate11([
|
|
1975
2720
|
Get6(),
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2721
|
+
_ts_param10(0, Req6()),
|
|
2722
|
+
_ts_param10(1, Query3("agent")),
|
|
2723
|
+
_ts_metadata11("design:type", Function),
|
|
2724
|
+
_ts_metadata11("design:paramtypes", [
|
|
1980
2725
|
typeof Request === "undefined" ? Object : Request,
|
|
1981
2726
|
String
|
|
1982
2727
|
]),
|
|
1983
|
-
|
|
2728
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1984
2729
|
], ModelsController.prototype, "list", null);
|
|
1985
|
-
ModelsController =
|
|
2730
|
+
ModelsController = _ts_decorate11([
|
|
1986
2731
|
Controller7("models"),
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2732
|
+
_ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER6)),
|
|
2733
|
+
_ts_metadata11("design:type", Function),
|
|
2734
|
+
_ts_metadata11("design:paramtypes", [
|
|
1990
2735
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1991
2736
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1992
2737
|
])
|
|
1993
2738
|
], ModelsController);
|
|
1994
2739
|
|
|
1995
|
-
// src/controller/
|
|
2740
|
+
// src/controller/queue.controller.ts
|
|
1996
2741
|
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
|
|
2742
|
+
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";
|
|
2743
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1999
2744
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2000
2745
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2001
2746
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2008,19 +2753,179 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
2008
2753
|
}
|
|
2009
2754
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2010
2755
|
}
|
|
2011
|
-
__name(
|
|
2012
|
-
function
|
|
2756
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2757
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
2013
2758
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2014
2759
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2015
2760
|
}
|
|
2016
2761
|
}
|
|
2017
|
-
__name(
|
|
2018
|
-
function
|
|
2762
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2763
|
+
function _ts_param11(paramIndex, decorator) {
|
|
2019
2764
|
return function(target, key) {
|
|
2020
2765
|
decorator(target, key, paramIndex);
|
|
2021
2766
|
};
|
|
2022
2767
|
}
|
|
2023
|
-
__name(
|
|
2768
|
+
__name(_ts_param11, "_ts_param");
|
|
2769
|
+
var QueueController = class {
|
|
2770
|
+
static {
|
|
2771
|
+
__name(this, "QueueController");
|
|
2772
|
+
}
|
|
2773
|
+
agent;
|
|
2774
|
+
actorResolver;
|
|
2775
|
+
constructor(agent, actorResolver) {
|
|
2776
|
+
this.agent = agent;
|
|
2777
|
+
this.actorResolver = actorResolver;
|
|
2778
|
+
}
|
|
2779
|
+
async list(req, id) {
|
|
2780
|
+
return this.agent.getQueue(await this.actorResolver.resolve(req), id);
|
|
2781
|
+
}
|
|
2782
|
+
async clear(req, id) {
|
|
2783
|
+
return this.agent.clearQueue(await this.actorResolver.resolve(req), id);
|
|
2784
|
+
}
|
|
2785
|
+
/** Lift a pause; the head starts when nothing is running. Carries `runId` when it started. */
|
|
2786
|
+
async resume(req, id) {
|
|
2787
|
+
return this.agent.resumeQueue(await this.actorResolver.resolve(req), id);
|
|
2788
|
+
}
|
|
2789
|
+
async update(req, messageId, body) {
|
|
2790
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2791
|
+
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
2792
|
+
throw new BadRequestException4("message must be a string");
|
|
2793
|
+
}
|
|
2794
|
+
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
2795
|
+
throw new BadRequestException4("position must be a number");
|
|
2796
|
+
}
|
|
2797
|
+
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
2798
|
+
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
2799
|
+
...body.message !== void 0 ? {
|
|
2800
|
+
message: body.message
|
|
2801
|
+
} : {},
|
|
2802
|
+
...attachments !== void 0 ? {
|
|
2803
|
+
attachments
|
|
2804
|
+
} : {},
|
|
2805
|
+
...body.position !== void 0 ? {
|
|
2806
|
+
position: body.position
|
|
2807
|
+
} : {}
|
|
2808
|
+
});
|
|
2809
|
+
}
|
|
2810
|
+
/**
|
|
2811
|
+
* Run a waiting message now: it moves to the head as an interrupt and the running turn is
|
|
2812
|
+
* cancelled for it. Carries `interrupting` (the cancelled run), or `runId` when nothing was
|
|
2813
|
+
* running and it started at once.
|
|
2814
|
+
*/
|
|
2815
|
+
async interrupt(req, messageId) {
|
|
2816
|
+
return this.agent.interruptQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
2817
|
+
}
|
|
2818
|
+
async remove(req, messageId) {
|
|
2819
|
+
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
2820
|
+
}
|
|
2821
|
+
};
|
|
2822
|
+
_ts_decorate12([
|
|
2823
|
+
Get7("threads/:id/queue"),
|
|
2824
|
+
_ts_param11(0, Req7()),
|
|
2825
|
+
_ts_param11(1, Param4("id")),
|
|
2826
|
+
_ts_metadata12("design:type", Function),
|
|
2827
|
+
_ts_metadata12("design:paramtypes", [
|
|
2828
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2829
|
+
String
|
|
2830
|
+
]),
|
|
2831
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2832
|
+
], QueueController.prototype, "list", null);
|
|
2833
|
+
_ts_decorate12([
|
|
2834
|
+
Delete2("threads/:id/queue"),
|
|
2835
|
+
_ts_param11(0, Req7()),
|
|
2836
|
+
_ts_param11(1, Param4("id")),
|
|
2837
|
+
_ts_metadata12("design:type", Function),
|
|
2838
|
+
_ts_metadata12("design:paramtypes", [
|
|
2839
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2840
|
+
String
|
|
2841
|
+
]),
|
|
2842
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2843
|
+
], QueueController.prototype, "clear", null);
|
|
2844
|
+
_ts_decorate12([
|
|
2845
|
+
Post4("threads/:id/queue/resume"),
|
|
2846
|
+
_ts_param11(0, Req7()),
|
|
2847
|
+
_ts_param11(1, Param4("id")),
|
|
2848
|
+
_ts_metadata12("design:type", Function),
|
|
2849
|
+
_ts_metadata12("design:paramtypes", [
|
|
2850
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2851
|
+
String
|
|
2852
|
+
]),
|
|
2853
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2854
|
+
], QueueController.prototype, "resume", null);
|
|
2855
|
+
_ts_decorate12([
|
|
2856
|
+
Patch("queue/:messageId"),
|
|
2857
|
+
_ts_param11(0, Req7()),
|
|
2858
|
+
_ts_param11(1, Param4("messageId")),
|
|
2859
|
+
_ts_param11(2, Body3()),
|
|
2860
|
+
_ts_metadata12("design:type", Function),
|
|
2861
|
+
_ts_metadata12("design:paramtypes", [
|
|
2862
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2863
|
+
String,
|
|
2864
|
+
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
2865
|
+
]),
|
|
2866
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2867
|
+
], QueueController.prototype, "update", null);
|
|
2868
|
+
_ts_decorate12([
|
|
2869
|
+
Post4("queue/:messageId/interrupt"),
|
|
2870
|
+
_ts_param11(0, Req7()),
|
|
2871
|
+
_ts_param11(1, Param4("messageId")),
|
|
2872
|
+
_ts_metadata12("design:type", Function),
|
|
2873
|
+
_ts_metadata12("design:paramtypes", [
|
|
2874
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2875
|
+
String
|
|
2876
|
+
]),
|
|
2877
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2878
|
+
], QueueController.prototype, "interrupt", null);
|
|
2879
|
+
_ts_decorate12([
|
|
2880
|
+
Delete2("queue/:messageId"),
|
|
2881
|
+
_ts_param11(0, Req7()),
|
|
2882
|
+
_ts_param11(1, Param4("messageId")),
|
|
2883
|
+
_ts_metadata12("design:type", Function),
|
|
2884
|
+
_ts_metadata12("design:paramtypes", [
|
|
2885
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2886
|
+
String
|
|
2887
|
+
]),
|
|
2888
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2889
|
+
], QueueController.prototype, "remove", null);
|
|
2890
|
+
QueueController = _ts_decorate12([
|
|
2891
|
+
Controller8(),
|
|
2892
|
+
_ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER7)),
|
|
2893
|
+
_ts_metadata12("design:type", Function),
|
|
2894
|
+
_ts_metadata12("design:paramtypes", [
|
|
2895
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2896
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2897
|
+
])
|
|
2898
|
+
], QueueController);
|
|
2899
|
+
|
|
2900
|
+
// src/controller/quota.controller.ts
|
|
2901
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
|
|
2902
|
+
import { Controller as Controller9, Get as Get8, Inject as Inject12, Req as Req8 } from "@nestjs/common";
|
|
2903
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2904
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2905
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2906
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2907
|
+
} else {
|
|
2908
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2909
|
+
if (d = decorators[i]) {
|
|
2910
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2915
|
+
}
|
|
2916
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2917
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
2918
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2919
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2923
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2924
|
+
return function(target, key) {
|
|
2925
|
+
decorator(target, key, paramIndex);
|
|
2926
|
+
};
|
|
2927
|
+
}
|
|
2928
|
+
__name(_ts_param12, "_ts_param");
|
|
2024
2929
|
var QuotaController = class {
|
|
2025
2930
|
static {
|
|
2026
2931
|
__name(this, "QuotaController");
|
|
@@ -2040,29 +2945,29 @@ var QuotaController = class {
|
|
|
2040
2945
|
return this.agent.quotaReport(actor);
|
|
2041
2946
|
}
|
|
2042
2947
|
};
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2948
|
+
_ts_decorate13([
|
|
2949
|
+
Get8(),
|
|
2950
|
+
_ts_param12(0, Req8()),
|
|
2951
|
+
_ts_metadata13("design:type", Function),
|
|
2952
|
+
_ts_metadata13("design:paramtypes", [
|
|
2048
2953
|
typeof Request === "undefined" ? Object : Request
|
|
2049
2954
|
]),
|
|
2050
|
-
|
|
2955
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2051
2956
|
], QuotaController.prototype, "report", null);
|
|
2052
|
-
QuotaController =
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2957
|
+
QuotaController = _ts_decorate13([
|
|
2958
|
+
Controller9("quota"),
|
|
2959
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER8)),
|
|
2960
|
+
_ts_metadata13("design:type", Function),
|
|
2961
|
+
_ts_metadata13("design:paramtypes", [
|
|
2057
2962
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2058
2963
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2059
2964
|
])
|
|
2060
2965
|
], QuotaController);
|
|
2061
2966
|
|
|
2062
2967
|
// src/controller/skills.controller.ts
|
|
2063
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2064
|
-
import { Controller as
|
|
2065
|
-
function
|
|
2968
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
2969
|
+
import { Controller as Controller10, Get as Get9, Inject as Inject13, Optional as Optional7, Query as Query4, Req as Req9 } from "@nestjs/common";
|
|
2970
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2066
2971
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2067
2972
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2068
2973
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2075,19 +2980,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2075
2980
|
}
|
|
2076
2981
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2077
2982
|
}
|
|
2078
|
-
__name(
|
|
2079
|
-
function
|
|
2983
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2984
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2080
2985
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2081
2986
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2082
2987
|
}
|
|
2083
2988
|
}
|
|
2084
|
-
__name(
|
|
2085
|
-
function
|
|
2989
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2990
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2086
2991
|
return function(target, key) {
|
|
2087
2992
|
decorator(target, key, paramIndex);
|
|
2088
2993
|
};
|
|
2089
2994
|
}
|
|
2090
|
-
__name(
|
|
2995
|
+
__name(_ts_param13, "_ts_param");
|
|
2091
2996
|
var SkillsController = class {
|
|
2092
2997
|
static {
|
|
2093
2998
|
__name(this, "SkillsController");
|
|
@@ -2110,33 +3015,33 @@ var SkillsController = class {
|
|
|
2110
3015
|
return offer.entries;
|
|
2111
3016
|
}
|
|
2112
3017
|
};
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
3018
|
+
_ts_decorate14([
|
|
3019
|
+
Get9(),
|
|
3020
|
+
_ts_param13(0, Req9()),
|
|
3021
|
+
_ts_param13(1, Query4("threadId")),
|
|
3022
|
+
_ts_metadata14("design:type", Function),
|
|
3023
|
+
_ts_metadata14("design:paramtypes", [
|
|
2119
3024
|
typeof Request === "undefined" ? Object : Request,
|
|
2120
3025
|
String
|
|
2121
3026
|
]),
|
|
2122
|
-
|
|
3027
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2123
3028
|
], SkillsController.prototype, "list", null);
|
|
2124
|
-
SkillsController =
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
3029
|
+
SkillsController = _ts_decorate14([
|
|
3030
|
+
Controller10("skills"),
|
|
3031
|
+
_ts_param13(0, Inject13(AGENT_ACTOR_RESOLVER9)),
|
|
3032
|
+
_ts_param13(1, Optional7()),
|
|
3033
|
+
_ts_param13(1, Inject13(AGENT_SKILLS2)),
|
|
3034
|
+
_ts_metadata14("design:type", Function),
|
|
3035
|
+
_ts_metadata14("design:paramtypes", [
|
|
2131
3036
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2132
3037
|
Object
|
|
2133
3038
|
])
|
|
2134
3039
|
], SkillsController);
|
|
2135
3040
|
|
|
2136
3041
|
// src/controller/threads.controller.ts
|
|
2137
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2138
|
-
import { Body as
|
|
2139
|
-
function
|
|
3042
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
|
|
3043
|
+
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";
|
|
3044
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2140
3045
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2141
3046
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2142
3047
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2149,19 +3054,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2149
3054
|
}
|
|
2150
3055
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2151
3056
|
}
|
|
2152
|
-
__name(
|
|
2153
|
-
function
|
|
3057
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3058
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2154
3059
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2155
3060
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2156
3061
|
}
|
|
2157
3062
|
}
|
|
2158
|
-
__name(
|
|
2159
|
-
function
|
|
3063
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3064
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2160
3065
|
return function(target, key) {
|
|
2161
3066
|
decorator(target, key, paramIndex);
|
|
2162
3067
|
};
|
|
2163
3068
|
}
|
|
2164
|
-
__name(
|
|
3069
|
+
__name(_ts_param14, "_ts_param");
|
|
2165
3070
|
var ThreadsController = class {
|
|
2166
3071
|
static {
|
|
2167
3072
|
__name(this, "ThreadsController");
|
|
@@ -2228,101 +3133,101 @@ var ThreadsController = class {
|
|
|
2228
3133
|
};
|
|
2229
3134
|
}
|
|
2230
3135
|
};
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
3136
|
+
_ts_decorate15([
|
|
3137
|
+
Get10(),
|
|
3138
|
+
_ts_param14(0, Req10()),
|
|
3139
|
+
_ts_metadata15("design:type", Function),
|
|
3140
|
+
_ts_metadata15("design:paramtypes", [
|
|
2236
3141
|
typeof Request === "undefined" ? Object : Request
|
|
2237
3142
|
]),
|
|
2238
|
-
|
|
3143
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2239
3144
|
], ThreadsController.prototype, "list", null);
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
3145
|
+
_ts_decorate15([
|
|
3146
|
+
Get10(":id"),
|
|
3147
|
+
_ts_param14(0, Req10()),
|
|
3148
|
+
_ts_param14(1, Param5("id")),
|
|
3149
|
+
_ts_metadata15("design:type", Function),
|
|
3150
|
+
_ts_metadata15("design:paramtypes", [
|
|
2246
3151
|
typeof Request === "undefined" ? Object : Request,
|
|
2247
3152
|
String
|
|
2248
3153
|
]),
|
|
2249
|
-
|
|
3154
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2250
3155
|
], ThreadsController.prototype, "detail", null);
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
3156
|
+
_ts_decorate15([
|
|
3157
|
+
Delete3(":id"),
|
|
3158
|
+
_ts_param14(0, Req10()),
|
|
3159
|
+
_ts_param14(1, Param5("id")),
|
|
3160
|
+
_ts_metadata15("design:type", Function),
|
|
3161
|
+
_ts_metadata15("design:paramtypes", [
|
|
2257
3162
|
typeof Request === "undefined" ? Object : Request,
|
|
2258
3163
|
String
|
|
2259
3164
|
]),
|
|
2260
|
-
|
|
3165
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2261
3166
|
], ThreadsController.prototype, "remove", null);
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
3167
|
+
_ts_decorate15([
|
|
3168
|
+
Post5(":id/fork-from/:messageId"),
|
|
3169
|
+
_ts_param14(0, Req10()),
|
|
3170
|
+
_ts_param14(1, Param5("id")),
|
|
3171
|
+
_ts_param14(2, Param5("messageId")),
|
|
3172
|
+
_ts_metadata15("design:type", Function),
|
|
3173
|
+
_ts_metadata15("design:paramtypes", [
|
|
2269
3174
|
typeof Request === "undefined" ? Object : Request,
|
|
2270
3175
|
String,
|
|
2271
3176
|
String
|
|
2272
3177
|
]),
|
|
2273
|
-
|
|
3178
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2274
3179
|
], ThreadsController.prototype, "fork", null);
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
3180
|
+
_ts_decorate15([
|
|
3181
|
+
Patch2(":id"),
|
|
3182
|
+
_ts_param14(0, Req10()),
|
|
3183
|
+
_ts_param14(1, Param5("id")),
|
|
3184
|
+
_ts_param14(2, Body4()),
|
|
3185
|
+
_ts_metadata15("design:type", Function),
|
|
3186
|
+
_ts_metadata15("design:paramtypes", [
|
|
2282
3187
|
typeof Request === "undefined" ? Object : Request,
|
|
2283
3188
|
String,
|
|
2284
3189
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2285
3190
|
]),
|
|
2286
|
-
|
|
3191
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2287
3192
|
], ThreadsController.prototype, "update", null);
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
3193
|
+
_ts_decorate15([
|
|
3194
|
+
Post5(":id/promote"),
|
|
3195
|
+
_ts_param14(0, Req10()),
|
|
3196
|
+
_ts_param14(1, Param5("id")),
|
|
3197
|
+
_ts_metadata15("design:type", Function),
|
|
3198
|
+
_ts_metadata15("design:paramtypes", [
|
|
2294
3199
|
typeof Request === "undefined" ? Object : Request,
|
|
2295
3200
|
String
|
|
2296
3201
|
]),
|
|
2297
|
-
|
|
3202
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2298
3203
|
], ThreadsController.prototype, "promote", null);
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
3204
|
+
_ts_decorate15([
|
|
3205
|
+
Delete3(":id/from/:messageId"),
|
|
3206
|
+
_ts_param14(0, Req10()),
|
|
3207
|
+
_ts_param14(1, Param5("id")),
|
|
3208
|
+
_ts_param14(2, Param5("messageId")),
|
|
3209
|
+
_ts_metadata15("design:type", Function),
|
|
3210
|
+
_ts_metadata15("design:paramtypes", [
|
|
2306
3211
|
typeof Request === "undefined" ? Object : Request,
|
|
2307
3212
|
String,
|
|
2308
3213
|
String
|
|
2309
3214
|
]),
|
|
2310
|
-
|
|
3215
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2311
3216
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2312
|
-
ThreadsController =
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
3217
|
+
ThreadsController = _ts_decorate15([
|
|
3218
|
+
Controller11("threads"),
|
|
3219
|
+
_ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER10)),
|
|
3220
|
+
_ts_metadata15("design:type", Function),
|
|
3221
|
+
_ts_metadata15("design:paramtypes", [
|
|
2317
3222
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2318
3223
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2319
3224
|
])
|
|
2320
3225
|
], ThreadsController);
|
|
2321
3226
|
|
|
2322
3227
|
// src/controller/tool-call.controller.ts
|
|
2323
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2324
|
-
import { BadRequestException as
|
|
2325
|
-
function
|
|
3228
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11 } from "@dudousxd/nestjs-agent-core";
|
|
3229
|
+
import { BadRequestException as BadRequestException5, Body as Body5, Controller as Controller12, Inject as Inject15, Post as Post6, Req as Req11 } from "@nestjs/common";
|
|
3230
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2326
3231
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2327
3232
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2328
3233
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2335,19 +3240,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2335
3240
|
}
|
|
2336
3241
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2337
3242
|
}
|
|
2338
|
-
__name(
|
|
2339
|
-
function
|
|
3243
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3244
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2340
3245
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2341
3246
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2342
3247
|
}
|
|
2343
3248
|
}
|
|
2344
|
-
__name(
|
|
2345
|
-
function
|
|
3249
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
3250
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2346
3251
|
return function(target, key) {
|
|
2347
3252
|
decorator(target, key, paramIndex);
|
|
2348
3253
|
};
|
|
2349
3254
|
}
|
|
2350
|
-
__name(
|
|
3255
|
+
__name(_ts_param15, "_ts_param");
|
|
2351
3256
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2352
3257
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2353
3258
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2356,7 +3261,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
2356
3261
|
var DEFAULT_VIA = "web";
|
|
2357
3262
|
function toolCallId(claimed) {
|
|
2358
3263
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
2359
|
-
throw new
|
|
3264
|
+
throw new BadRequestException5("toolCallId must be a non-empty string");
|
|
2360
3265
|
}
|
|
2361
3266
|
return claimed;
|
|
2362
3267
|
}
|
|
@@ -2366,10 +3271,10 @@ function rejectReason(claimed) {
|
|
|
2366
3271
|
return void 0;
|
|
2367
3272
|
}
|
|
2368
3273
|
if (typeof claimed !== "string") {
|
|
2369
|
-
throw new
|
|
3274
|
+
throw new BadRequestException5("reason must be a string");
|
|
2370
3275
|
}
|
|
2371
3276
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
2372
|
-
throw new
|
|
3277
|
+
throw new BadRequestException5(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
2373
3278
|
}
|
|
2374
3279
|
return claimed;
|
|
2375
3280
|
}
|
|
@@ -2379,7 +3284,7 @@ function remember(claimed) {
|
|
|
2379
3284
|
return false;
|
|
2380
3285
|
}
|
|
2381
3286
|
if (typeof claimed !== "boolean") {
|
|
2382
|
-
throw new
|
|
3287
|
+
throw new BadRequestException5("remember must be a boolean");
|
|
2383
3288
|
}
|
|
2384
3289
|
return claimed;
|
|
2385
3290
|
}
|
|
@@ -2389,7 +3294,7 @@ function via(claimed) {
|
|
|
2389
3294
|
return DEFAULT_VIA;
|
|
2390
3295
|
}
|
|
2391
3296
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
2392
|
-
throw new
|
|
3297
|
+
throw new BadRequestException5(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
2393
3298
|
}
|
|
2394
3299
|
return claimed;
|
|
2395
3300
|
}
|
|
@@ -2399,26 +3304,26 @@ function answers(claimed) {
|
|
|
2399
3304
|
return void 0;
|
|
2400
3305
|
}
|
|
2401
3306
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
2402
|
-
throw new
|
|
3307
|
+
throw new BadRequestException5("answers must be an object of questionId \u2192 chosen values");
|
|
2403
3308
|
}
|
|
2404
3309
|
const entries = Object.entries(claimed);
|
|
2405
3310
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
2406
|
-
throw new
|
|
3311
|
+
throw new BadRequestException5(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
2407
3312
|
}
|
|
2408
3313
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
2409
3314
|
for (const [questionId, values] of entries) {
|
|
2410
3315
|
if (!Array.isArray(values)) {
|
|
2411
|
-
throw new
|
|
3316
|
+
throw new BadRequestException5(`answers["${questionId}"] must be an array of chosen values`);
|
|
2412
3317
|
}
|
|
2413
3318
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
2414
|
-
throw new
|
|
3319
|
+
throw new BadRequestException5(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
2415
3320
|
}
|
|
2416
3321
|
for (const value of values) {
|
|
2417
3322
|
if (typeof value !== "string") {
|
|
2418
|
-
throw new
|
|
3323
|
+
throw new BadRequestException5(`answers["${questionId}"] must contain only strings`);
|
|
2419
3324
|
}
|
|
2420
3325
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
2421
|
-
throw new
|
|
3326
|
+
throw new BadRequestException5(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
2422
3327
|
}
|
|
2423
3328
|
}
|
|
2424
3329
|
validated[questionId] = values;
|
|
@@ -2480,64 +3385,64 @@ var ToolCallController = class {
|
|
|
2480
3385
|
};
|
|
2481
3386
|
}
|
|
2482
3387
|
};
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
3388
|
+
_ts_decorate16([
|
|
3389
|
+
Post6("approve"),
|
|
3390
|
+
_ts_param15(0, Req11()),
|
|
3391
|
+
_ts_param15(1, Body5()),
|
|
3392
|
+
_ts_metadata16("design:type", Function),
|
|
3393
|
+
_ts_metadata16("design:paramtypes", [
|
|
2489
3394
|
typeof Request === "undefined" ? Object : Request,
|
|
2490
3395
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2491
3396
|
]),
|
|
2492
|
-
|
|
3397
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2493
3398
|
], ToolCallController.prototype, "approve", null);
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
3399
|
+
_ts_decorate16([
|
|
3400
|
+
Post6("reject"),
|
|
3401
|
+
_ts_param15(0, Req11()),
|
|
3402
|
+
_ts_param15(1, Body5()),
|
|
3403
|
+
_ts_metadata16("design:type", Function),
|
|
3404
|
+
_ts_metadata16("design:paramtypes", [
|
|
2500
3405
|
typeof Request === "undefined" ? Object : Request,
|
|
2501
3406
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2502
3407
|
]),
|
|
2503
|
-
|
|
3408
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2504
3409
|
], ToolCallController.prototype, "reject", null);
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
3410
|
+
_ts_decorate16([
|
|
3411
|
+
Post6("answer"),
|
|
3412
|
+
_ts_param15(0, Req11()),
|
|
3413
|
+
_ts_param15(1, Body5()),
|
|
3414
|
+
_ts_metadata16("design:type", Function),
|
|
3415
|
+
_ts_metadata16("design:paramtypes", [
|
|
2511
3416
|
typeof Request === "undefined" ? Object : Request,
|
|
2512
3417
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2513
3418
|
]),
|
|
2514
|
-
|
|
3419
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2515
3420
|
], ToolCallController.prototype, "answer", null);
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
3421
|
+
_ts_decorate16([
|
|
3422
|
+
Post6("skip"),
|
|
3423
|
+
_ts_param15(0, Req11()),
|
|
3424
|
+
_ts_param15(1, Body5()),
|
|
3425
|
+
_ts_metadata16("design:type", Function),
|
|
3426
|
+
_ts_metadata16("design:paramtypes", [
|
|
2522
3427
|
typeof Request === "undefined" ? Object : Request,
|
|
2523
3428
|
Object
|
|
2524
3429
|
]),
|
|
2525
|
-
|
|
3430
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2526
3431
|
], ToolCallController.prototype, "skip", null);
|
|
2527
|
-
ToolCallController =
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
3432
|
+
ToolCallController = _ts_decorate16([
|
|
3433
|
+
Controller12("tool-call"),
|
|
3434
|
+
_ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER11)),
|
|
3435
|
+
_ts_metadata16("design:type", Function),
|
|
3436
|
+
_ts_metadata16("design:paramtypes", [
|
|
2532
3437
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2533
3438
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2534
3439
|
])
|
|
2535
3440
|
], ToolCallController);
|
|
2536
3441
|
|
|
2537
3442
|
// src/controller/tools.controller.ts
|
|
2538
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2539
|
-
import { Controller as
|
|
2540
|
-
function
|
|
3443
|
+
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";
|
|
3444
|
+
import { Controller as Controller13, Get as Get11, Inject as Inject16, NotFoundException as NotFoundException3, Query as Query5, Req as Req12 } from "@nestjs/common";
|
|
3445
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2541
3446
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2542
3447
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2543
3448
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2550,19 +3455,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2550
3455
|
}
|
|
2551
3456
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2552
3457
|
}
|
|
2553
|
-
__name(
|
|
2554
|
-
function
|
|
3458
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3459
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2555
3460
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2556
3461
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2557
3462
|
}
|
|
2558
3463
|
}
|
|
2559
|
-
__name(
|
|
2560
|
-
function
|
|
3464
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3465
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2561
3466
|
return function(target, key) {
|
|
2562
3467
|
decorator(target, key, paramIndex);
|
|
2563
3468
|
};
|
|
2564
3469
|
}
|
|
2565
|
-
__name(
|
|
3470
|
+
__name(_ts_param16, "_ts_param");
|
|
2566
3471
|
var ToolsController = class {
|
|
2567
3472
|
static {
|
|
2568
3473
|
__name(this, "ToolsController");
|
|
@@ -2606,24 +3511,24 @@ var ToolsController = class {
|
|
|
2606
3511
|
];
|
|
2607
3512
|
}
|
|
2608
3513
|
};
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
3514
|
+
_ts_decorate17([
|
|
3515
|
+
Get11(),
|
|
3516
|
+
_ts_param16(0, Req12()),
|
|
3517
|
+
_ts_param16(1, Query5("agent")),
|
|
3518
|
+
_ts_metadata17("design:type", Function),
|
|
3519
|
+
_ts_metadata17("design:paramtypes", [
|
|
2615
3520
|
typeof Request === "undefined" ? Object : Request,
|
|
2616
3521
|
String
|
|
2617
3522
|
]),
|
|
2618
|
-
|
|
3523
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2619
3524
|
], ToolsController.prototype, "list", null);
|
|
2620
|
-
ToolsController =
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
3525
|
+
ToolsController = _ts_decorate17([
|
|
3526
|
+
Controller13("tools"),
|
|
3527
|
+
_ts_param16(0, Inject16(AGENT_ACTOR_RESOLVER12)),
|
|
3528
|
+
_ts_param16(1, Inject16(AGENT_DEPS_FACTORY3)),
|
|
3529
|
+
_ts_param16(2, Inject16(AGENT_REGISTRY3)),
|
|
3530
|
+
_ts_metadata17("design:type", Function),
|
|
3531
|
+
_ts_metadata17("design:paramtypes", [
|
|
2627
3532
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2628
3533
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2629
3534
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -2632,7 +3537,7 @@ ToolsController = _ts_decorate15([
|
|
|
2632
3537
|
|
|
2633
3538
|
// src/discovery/agent-discovery.service.ts
|
|
2634
3539
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
2635
|
-
import { Inject as
|
|
3540
|
+
import { Inject as Inject17, Injectable as Injectable5, Logger as Logger2 } from "@nestjs/common";
|
|
2636
3541
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
2637
3542
|
|
|
2638
3543
|
// src/decorator/agent.decorator.ts
|
|
@@ -2667,7 +3572,7 @@ function SystemPromptContributor() {
|
|
|
2667
3572
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
2668
3573
|
|
|
2669
3574
|
// src/discovery/agent-discovery.service.ts
|
|
2670
|
-
function
|
|
3575
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2671
3576
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2672
3577
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2673
3578
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2680,19 +3585,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2680
3585
|
}
|
|
2681
3586
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2682
3587
|
}
|
|
2683
|
-
__name(
|
|
2684
|
-
function
|
|
3588
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3589
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2685
3590
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2686
3591
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2687
3592
|
}
|
|
2688
3593
|
}
|
|
2689
|
-
__name(
|
|
2690
|
-
function
|
|
3594
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3595
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2691
3596
|
return function(target, key) {
|
|
2692
3597
|
decorator(target, key, paramIndex);
|
|
2693
3598
|
};
|
|
2694
3599
|
}
|
|
2695
|
-
__name(
|
|
3600
|
+
__name(_ts_param17, "_ts_param");
|
|
2696
3601
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2697
3602
|
static {
|
|
2698
3603
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2701,7 +3606,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2701
3606
|
scanner;
|
|
2702
3607
|
registry;
|
|
2703
3608
|
contributors;
|
|
2704
|
-
logger = new
|
|
3609
|
+
logger = new Logger2(_AgentDiscoveryService.name);
|
|
2705
3610
|
constructor(discovery, scanner, registry, contributors) {
|
|
2706
3611
|
this.discovery = discovery;
|
|
2707
3612
|
this.scanner = scanner;
|
|
@@ -2819,12 +3724,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2819
3724
|
return (ctx) => candidate.call(instance, ctx);
|
|
2820
3725
|
}
|
|
2821
3726
|
};
|
|
2822
|
-
AgentDiscoveryService =
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
3727
|
+
AgentDiscoveryService = _ts_decorate18([
|
|
3728
|
+
Injectable5(),
|
|
3729
|
+
_ts_param17(2, Inject17(AGENT_REGISTRY4)),
|
|
3730
|
+
_ts_param17(3, Inject17(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
3731
|
+
_ts_metadata18("design:type", Function),
|
|
3732
|
+
_ts_metadata18("design:paramtypes", [
|
|
2828
3733
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
2829
3734
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
2830
3735
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -2833,8 +3738,8 @@ AgentDiscoveryService = _ts_decorate16([
|
|
|
2833
3738
|
], AgentDiscoveryService);
|
|
2834
3739
|
|
|
2835
3740
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2836
|
-
import { AGENT_OPTIONS as
|
|
2837
|
-
import { Inject as
|
|
3741
|
+
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";
|
|
3742
|
+
import { Inject as Inject18, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
|
|
2838
3743
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
2839
3744
|
import { z } from "zod";
|
|
2840
3745
|
|
|
@@ -2905,7 +3810,7 @@ function provideAgentTools(factory, inject) {
|
|
|
2905
3810
|
__name(provideAgentTools, "provideAgentTools");
|
|
2906
3811
|
|
|
2907
3812
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2908
|
-
function
|
|
3813
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
2909
3814
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2910
3815
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2911
3816
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2918,19 +3823,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2918
3823
|
}
|
|
2919
3824
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2920
3825
|
}
|
|
2921
|
-
__name(
|
|
2922
|
-
function
|
|
3826
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3827
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
2923
3828
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2924
3829
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2925
3830
|
}
|
|
2926
3831
|
}
|
|
2927
|
-
__name(
|
|
2928
|
-
function
|
|
3832
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3833
|
+
function _ts_param18(paramIndex, decorator) {
|
|
2929
3834
|
return function(target, key) {
|
|
2930
3835
|
decorator(target, key, paramIndex);
|
|
2931
3836
|
};
|
|
2932
3837
|
}
|
|
2933
|
-
__name(
|
|
3838
|
+
__name(_ts_param18, "_ts_param");
|
|
2934
3839
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2935
3840
|
static {
|
|
2936
3841
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2939,7 +3844,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2939
3844
|
registry;
|
|
2940
3845
|
agents;
|
|
2941
3846
|
options;
|
|
2942
|
-
logger = new
|
|
3847
|
+
logger = new Logger3(_AiToolDiscoveryService.name);
|
|
2943
3848
|
constructor(discovery, registry, agents, options) {
|
|
2944
3849
|
this.discovery = discovery;
|
|
2945
3850
|
this.registry = registry;
|
|
@@ -3074,13 +3979,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3074
3979
|
return true;
|
|
3075
3980
|
}
|
|
3076
3981
|
};
|
|
3077
|
-
AiToolDiscoveryService =
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3982
|
+
AiToolDiscoveryService = _ts_decorate19([
|
|
3983
|
+
Injectable6(),
|
|
3984
|
+
_ts_param18(1, Inject18(AGENT_TOOL_REGISTRY2)),
|
|
3985
|
+
_ts_param18(2, Inject18(AGENT_REGISTRY5)),
|
|
3986
|
+
_ts_param18(3, Inject18(AGENT_OPTIONS6)),
|
|
3987
|
+
_ts_metadata19("design:type", Function),
|
|
3988
|
+
_ts_metadata19("design:paramtypes", [
|
|
3084
3989
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
3085
3990
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3086
3991
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3090,7 +3995,7 @@ AiToolDiscoveryService = _ts_decorate17([
|
|
|
3090
3995
|
|
|
3091
3996
|
// src/discovery/skill-discovery.service.ts
|
|
3092
3997
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
3093
|
-
import { Inject as
|
|
3998
|
+
import { Inject as Inject19, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
|
|
3094
3999
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
3095
4000
|
|
|
3096
4001
|
// src/decorator/skill.decorator.ts
|
|
@@ -3113,7 +4018,7 @@ function skillScope(options) {
|
|
|
3113
4018
|
__name(skillScope, "skillScope");
|
|
3114
4019
|
|
|
3115
4020
|
// src/discovery/skill-discovery.service.ts
|
|
3116
|
-
function
|
|
4021
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3117
4022
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3118
4023
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3119
4024
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3126,26 +4031,26 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3126
4031
|
}
|
|
3127
4032
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3128
4033
|
}
|
|
3129
|
-
__name(
|
|
3130
|
-
function
|
|
4034
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4035
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3131
4036
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3132
4037
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3133
4038
|
}
|
|
3134
4039
|
}
|
|
3135
|
-
__name(
|
|
3136
|
-
function
|
|
4040
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
4041
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3137
4042
|
return function(target, key) {
|
|
3138
4043
|
decorator(target, key, paramIndex);
|
|
3139
4044
|
};
|
|
3140
4045
|
}
|
|
3141
|
-
__name(
|
|
4046
|
+
__name(_ts_param19, "_ts_param");
|
|
3142
4047
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3143
4048
|
static {
|
|
3144
4049
|
__name(this, "SkillDiscoveryService");
|
|
3145
4050
|
}
|
|
3146
4051
|
discovery;
|
|
3147
4052
|
declared;
|
|
3148
|
-
logger = new
|
|
4053
|
+
logger = new Logger4(_SkillDiscoveryService.name);
|
|
3149
4054
|
constructor(discovery, declared) {
|
|
3150
4055
|
this.discovery = discovery;
|
|
3151
4056
|
this.declared = declared;
|
|
@@ -3182,11 +4087,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3182
4087
|
return flat === void 0 ? void 0 : () => flat;
|
|
3183
4088
|
}
|
|
3184
4089
|
};
|
|
3185
|
-
SkillDiscoveryService =
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
4090
|
+
SkillDiscoveryService = _ts_decorate20([
|
|
4091
|
+
Injectable7(),
|
|
4092
|
+
_ts_param19(1, Inject19(AGENT_SKILL_SOURCES)),
|
|
4093
|
+
_ts_metadata20("design:type", Function),
|
|
4094
|
+
_ts_metadata20("design:paramtypes", [
|
|
3190
4095
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
3191
4096
|
Array
|
|
3192
4097
|
])
|
|
@@ -3323,9 +4228,9 @@ var LedgerQuotaProvider = class {
|
|
|
3323
4228
|
};
|
|
3324
4229
|
|
|
3325
4230
|
// src/runner/inline-agent-runner.ts
|
|
3326
|
-
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as
|
|
3327
|
-
import { Inject as
|
|
3328
|
-
function
|
|
4231
|
+
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";
|
|
4232
|
+
import { Inject as Inject20, Injectable as Injectable8, Logger as Logger5, Optional as Optional8 } from "@nestjs/common";
|
|
4233
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3329
4234
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3330
4235
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3331
4236
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3338,26 +4243,27 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3338
4243
|
}
|
|
3339
4244
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3340
4245
|
}
|
|
3341
|
-
__name(
|
|
3342
|
-
function
|
|
4246
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
4247
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
3343
4248
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3344
4249
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3345
4250
|
}
|
|
3346
4251
|
}
|
|
3347
|
-
__name(
|
|
3348
|
-
function
|
|
4252
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
4253
|
+
function _ts_param20(paramIndex, decorator) {
|
|
3349
4254
|
return function(target, key) {
|
|
3350
4255
|
decorator(target, key, paramIndex);
|
|
3351
4256
|
};
|
|
3352
4257
|
}
|
|
3353
|
-
__name(
|
|
4258
|
+
__name(_ts_param20, "_ts_param");
|
|
3354
4259
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3355
4260
|
static {
|
|
3356
4261
|
__name(this, "InlineAgentRunner");
|
|
3357
4262
|
}
|
|
3358
4263
|
factory;
|
|
3359
4264
|
store;
|
|
3360
|
-
|
|
4265
|
+
queue;
|
|
4266
|
+
logger = new Logger5(_InlineAgentRunner.name);
|
|
3361
4267
|
pending = /* @__PURE__ */ new Map();
|
|
3362
4268
|
/**
|
|
3363
4269
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -3365,14 +4271,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3365
4271
|
* running it. A cancelled id is dropped once the run settles, so the set tracks live runs only.
|
|
3366
4272
|
*/
|
|
3367
4273
|
cancelled = /* @__PURE__ */ new Set();
|
|
3368
|
-
|
|
4274
|
+
/** Top-level runs this process is running now — what {@link isRunActive} answers from. */
|
|
4275
|
+
live = /* @__PURE__ */ new Set();
|
|
4276
|
+
constructor(factory, store, queue) {
|
|
3369
4277
|
this.factory = factory;
|
|
3370
4278
|
this.store = store;
|
|
4279
|
+
this.queue = queue;
|
|
3371
4280
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
4281
|
+
/**
|
|
4282
|
+
* In-process, so exact: a run this process is not running is not running anywhere — the process
|
|
4283
|
+
* that was running it is gone (a restart), and a thread it still holds is a stale claim.
|
|
4284
|
+
*/
|
|
4285
|
+
async isRunActive(runId) {
|
|
4286
|
+
return this.live.has(runId);
|
|
4287
|
+
}
|
|
4288
|
+
async start(input, options = {}) {
|
|
4289
|
+
const runId = options.runId ?? crypto.randomUUID();
|
|
3374
4290
|
const day = input.day ?? utcDay();
|
|
3375
4291
|
const deps = this.factory.forAgent(input.agentName);
|
|
4292
|
+
this.live.add(runId);
|
|
3376
4293
|
const hooks = this.topLevelHooks({
|
|
3377
4294
|
runId,
|
|
3378
4295
|
deps,
|
|
@@ -3384,14 +4301,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3384
4301
|
...input.agentName !== void 0 ? [
|
|
3385
4302
|
input.agentName
|
|
3386
4303
|
] : []
|
|
3387
|
-
]
|
|
4304
|
+
],
|
|
4305
|
+
input
|
|
3388
4306
|
});
|
|
3389
4307
|
void runAgentLoop({
|
|
3390
4308
|
...deps,
|
|
3391
4309
|
day
|
|
3392
|
-
}, input, hooks).then(() => this.store
|
|
4310
|
+
}, input, hooks).then(() => releaseThreadRun(this.store, input.threadId, runId)).catch(async (error) => {
|
|
3393
4311
|
if (error instanceof RunCancelledError) {
|
|
3394
|
-
await this.settleCancelled(runId, input
|
|
4312
|
+
await this.settleCancelled(runId, input, deps);
|
|
3395
4313
|
return;
|
|
3396
4314
|
}
|
|
3397
4315
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -3408,13 +4326,17 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3408
4326
|
errorCode: code,
|
|
3409
4327
|
errorMessage: message
|
|
3410
4328
|
});
|
|
3411
|
-
await this.store.setActiveStream(input.threadId, null);
|
|
3412
4329
|
const writer = await deps.sink.open(runId);
|
|
4330
|
+
await this.settleQueue(writer, input, runId, "failed", message);
|
|
4331
|
+
await releaseThreadRun(this.store, input.threadId, runId);
|
|
3413
4332
|
await writer.fail({
|
|
3414
4333
|
code,
|
|
3415
4334
|
message
|
|
3416
4335
|
});
|
|
3417
|
-
}).finally(() =>
|
|
4336
|
+
}).finally(() => {
|
|
4337
|
+
this.cancelled.delete(runId);
|
|
4338
|
+
this.live.delete(runId);
|
|
4339
|
+
});
|
|
3418
4340
|
return {
|
|
3419
4341
|
runId
|
|
3420
4342
|
};
|
|
@@ -3457,11 +4379,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3457
4379
|
* the stream ENDED after a `cancelled` frame rather than failed, so a client that retries failed
|
|
3458
4380
|
* streams does not retry this one.
|
|
3459
4381
|
*/
|
|
3460
|
-
async settleCancelled(runId,
|
|
4382
|
+
async settleCancelled(runId, input, deps) {
|
|
3461
4383
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3462
|
-
await this.store.setActiveStream(threadId, null);
|
|
3463
4384
|
const writer = await deps.sink.open(runId);
|
|
3464
|
-
await
|
|
4385
|
+
await this.settleQueue(writer, input, runId, "cancelled");
|
|
4386
|
+
await releaseThreadRun(this.store, input.threadId, runId);
|
|
4387
|
+
await writer.write(encodeStreamEvent2({
|
|
3465
4388
|
kind: "cancelled"
|
|
3466
4389
|
}));
|
|
3467
4390
|
await writer.end();
|
|
@@ -3471,6 +4394,38 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3471
4394
|
});
|
|
3472
4395
|
}
|
|
3473
4396
|
/**
|
|
4397
|
+
* Move the thread past a settling TOP-LEVEL run — to the next queued message, which starts here,
|
|
4398
|
+
* or to a paused/empty queue — and write the resulting `queue` frame into this run's stream. A
|
|
4399
|
+
* no-op without a queue-capable store, and for a run that is not a thread's own turn.
|
|
4400
|
+
*
|
|
4401
|
+
* Never throws: the run is settling either way, and a queue that could not be advanced is picked
|
|
4402
|
+
* up by the next send or resume on the thread.
|
|
4403
|
+
*/
|
|
4404
|
+
async settleQueue(writer, input, runId, outcome, error) {
|
|
4405
|
+
const queue = this.queue;
|
|
4406
|
+
if (queue === void 0 || !queue.supported || !isThreadTurn(input)) {
|
|
4407
|
+
return;
|
|
4408
|
+
}
|
|
4409
|
+
const settled = outcome === "completed" && this.cancelled.has(runId) ? "cancelled" : outcome;
|
|
4410
|
+
try {
|
|
4411
|
+
const frame = await queue.handoff({
|
|
4412
|
+
threadId: input.threadId,
|
|
4413
|
+
runId,
|
|
4414
|
+
outcome: settled,
|
|
4415
|
+
...error !== void 0 ? {
|
|
4416
|
+
error
|
|
4417
|
+
} : {}
|
|
4418
|
+
}, (next, nextRunId) => this.start(next, {
|
|
4419
|
+
runId: nextRunId
|
|
4420
|
+
}));
|
|
4421
|
+
if (frame !== void 0) {
|
|
4422
|
+
await writer.write(encodeStreamEvent2(frame));
|
|
4423
|
+
}
|
|
4424
|
+
} catch (failure) {
|
|
4425
|
+
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
/**
|
|
3474
4429
|
* Park a run on a human, keyed by run + tool call. One map for approvals and for question-set
|
|
3475
4430
|
* answers alike: both wait on the same key, and `signal` cannot tell (or need to tell) which
|
|
3476
4431
|
* shape it is delivering — the loop asked for one and only ever gets what the caller sent. A
|
|
@@ -3515,10 +4470,23 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3515
4470
|
});
|
|
3516
4471
|
}
|
|
3517
4472
|
topLevelHooks(args) {
|
|
3518
|
-
const { runId, deps, actor, day, threadId, chainBelow } = args;
|
|
4473
|
+
const { runId, deps, actor, day, threadId, chainBelow, input } = args;
|
|
3519
4474
|
return {
|
|
3520
4475
|
runId,
|
|
3521
|
-
|
|
4476
|
+
// The loop ends the stream when the turn completes. Just before, the thread passes to the next
|
|
4477
|
+
// queued message (or is released), and the reader is told which — so by the time a client
|
|
4478
|
+
// sees the run end, the thread is already free or already running what it queued.
|
|
4479
|
+
openSink: /* @__PURE__ */ __name(async () => {
|
|
4480
|
+
const writer = await deps.sink.open(runId);
|
|
4481
|
+
return this.queue === void 0 ? writer : {
|
|
4482
|
+
write: /* @__PURE__ */ __name((chunk) => writer.write(chunk), "write"),
|
|
4483
|
+
fail: /* @__PURE__ */ __name((error) => writer.fail(error), "fail"),
|
|
4484
|
+
end: /* @__PURE__ */ __name(async () => {
|
|
4485
|
+
await this.settleQueue(writer, input, runId, "completed");
|
|
4486
|
+
await writer.end();
|
|
4487
|
+
}, "end")
|
|
4488
|
+
};
|
|
4489
|
+
}, "openSink"),
|
|
3522
4490
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3523
4491
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3524
4492
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
@@ -3731,16 +4699,22 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3731
4699
|
}
|
|
3732
4700
|
}
|
|
3733
4701
|
};
|
|
3734
|
-
InlineAgentRunner =
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
4702
|
+
InlineAgentRunner = _ts_decorate21([
|
|
4703
|
+
Injectable8(),
|
|
4704
|
+
_ts_param20(0, Inject20(AGENT_DEPS_FACTORY4)),
|
|
4705
|
+
_ts_param20(1, Inject20(AGENT_STORE4)),
|
|
4706
|
+
_ts_param20(2, Optional8()),
|
|
4707
|
+
_ts_metadata21("design:type", Function),
|
|
4708
|
+
_ts_metadata21("design:paramtypes", [
|
|
3740
4709
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3741
|
-
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
4710
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
4711
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
3742
4712
|
])
|
|
3743
4713
|
], InlineAgentRunner);
|
|
4714
|
+
function isThreadTurn(input) {
|
|
4715
|
+
return input.sinkRunId === void 0 && input.deliverTo === void 0;
|
|
4716
|
+
}
|
|
4717
|
+
__name(isThreadTurn, "isThreadTurn");
|
|
3744
4718
|
|
|
3745
4719
|
// src/skills-config.ts
|
|
3746
4720
|
import { compositeSkillProvider } from "@dudousxd/nestjs-agent-core";
|
|
@@ -3781,7 +4755,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3781
4755
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3782
4756
|
|
|
3783
4757
|
// src/agent.module.ts
|
|
3784
|
-
function
|
|
4758
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3785
4759
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3786
4760
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3787
4761
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3794,13 +4768,13 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3794
4768
|
}
|
|
3795
4769
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3796
4770
|
}
|
|
3797
|
-
__name(
|
|
4771
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3798
4772
|
var DEFAULT_PATH = "agent";
|
|
3799
|
-
var logger = new
|
|
4773
|
+
var logger = new Logger6("AgentModule");
|
|
3800
4774
|
function externalStoreWrapper(modules) {
|
|
3801
4775
|
for (const module of modules.values()) {
|
|
3802
4776
|
if (module.metatype === AgentModule) continue;
|
|
3803
|
-
const wrapper = module.providers.get(
|
|
4777
|
+
const wrapper = module.providers.get(AGENT_STORE5);
|
|
3804
4778
|
if (wrapper !== void 0) return wrapper;
|
|
3805
4779
|
}
|
|
3806
4780
|
return void 0;
|
|
@@ -3873,7 +4847,7 @@ function sharedProviders(durable) {
|
|
|
3873
4847
|
provide: AGENT_SKILLS3,
|
|
3874
4848
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3875
4849
|
inject: [
|
|
3876
|
-
|
|
4850
|
+
AGENT_OPTIONS7,
|
|
3877
4851
|
AGENT_SKILL_SOURCES2
|
|
3878
4852
|
]
|
|
3879
4853
|
},
|
|
@@ -3883,58 +4857,58 @@ function sharedProviders(durable) {
|
|
|
3883
4857
|
provide: AGENT_MEMORY3,
|
|
3884
4858
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3885
4859
|
inject: [
|
|
3886
|
-
|
|
4860
|
+
AGENT_OPTIONS7
|
|
3887
4861
|
]
|
|
3888
4862
|
},
|
|
3889
4863
|
{
|
|
3890
|
-
provide:
|
|
4864
|
+
provide: AGENT_SINK3,
|
|
3891
4865
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3892
4866
|
inject: [
|
|
3893
|
-
|
|
4867
|
+
AGENT_OPTIONS7
|
|
3894
4868
|
]
|
|
3895
4869
|
},
|
|
3896
4870
|
{
|
|
3897
4871
|
provide: AGENT_ROLES_POLICY2,
|
|
3898
4872
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3899
4873
|
inject: [
|
|
3900
|
-
|
|
4874
|
+
AGENT_OPTIONS7
|
|
3901
4875
|
]
|
|
3902
4876
|
},
|
|
3903
4877
|
{
|
|
3904
|
-
provide:
|
|
4878
|
+
provide: AGENT_ACTOR_RESOLVER13,
|
|
3905
4879
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
3906
4880
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
3907
4881
|
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.");
|
|
3908
4882
|
return new AnonymousActorResolver();
|
|
3909
4883
|
}, "useFactory"),
|
|
3910
4884
|
inject: [
|
|
3911
|
-
|
|
4885
|
+
AGENT_OPTIONS7
|
|
3912
4886
|
]
|
|
3913
4887
|
},
|
|
3914
4888
|
{
|
|
3915
4889
|
provide: AGENT_MODEL2,
|
|
3916
4890
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3917
4891
|
inject: [
|
|
3918
|
-
|
|
4892
|
+
AGENT_OPTIONS7
|
|
3919
4893
|
]
|
|
3920
4894
|
},
|
|
3921
4895
|
{
|
|
3922
4896
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
3923
4897
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
3924
|
-
provide:
|
|
4898
|
+
provide: AGENT_QUOTA_PROVIDER3,
|
|
3925
4899
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
3926
4900
|
warnAt: o.quota.warnAt
|
|
3927
4901
|
} : {}), "useFactory"),
|
|
3928
4902
|
inject: [
|
|
3929
|
-
|
|
3930
|
-
|
|
4903
|
+
AGENT_OPTIONS7,
|
|
4904
|
+
AGENT_STORE5
|
|
3931
4905
|
]
|
|
3932
4906
|
},
|
|
3933
4907
|
{
|
|
3934
4908
|
provide: AGENT_MODEL_CATALOG3,
|
|
3935
4909
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
3936
4910
|
inject: [
|
|
3937
|
-
|
|
4911
|
+
AGENT_OPTIONS7
|
|
3938
4912
|
]
|
|
3939
4913
|
},
|
|
3940
4914
|
AgentDepsFactory2,
|
|
@@ -3947,6 +4921,9 @@ function sharedProviders(durable) {
|
|
|
3947
4921
|
AgentDiscoveryService,
|
|
3948
4922
|
AiToolDiscoveryService,
|
|
3949
4923
|
SkillDiscoveryService,
|
|
4924
|
+
// The thread message queue — every surface, since both runners and the durable workflow settle
|
|
4925
|
+
// into it, and the chat routes enqueue into it.
|
|
4926
|
+
ChatQueueService,
|
|
3950
4927
|
InlineAgentRunner,
|
|
3951
4928
|
AgentService,
|
|
3952
4929
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
@@ -3958,10 +4935,10 @@ function sharedProviders(durable) {
|
|
|
3958
4935
|
}
|
|
3959
4936
|
];
|
|
3960
4937
|
providers.push({
|
|
3961
|
-
provide:
|
|
4938
|
+
provide: AGENT_STORE5,
|
|
3962
4939
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
3963
4940
|
inject: [
|
|
3964
|
-
|
|
4941
|
+
AGENT_OPTIONS7,
|
|
3965
4942
|
ModulesContainer
|
|
3966
4943
|
]
|
|
3967
4944
|
});
|
|
@@ -3992,22 +4969,23 @@ function sharedProviders(durable) {
|
|
|
3992
4969
|
__name(sharedProviders, "sharedProviders");
|
|
3993
4970
|
function exportsFor() {
|
|
3994
4971
|
return [
|
|
3995
|
-
|
|
4972
|
+
AGENT_OPTIONS7,
|
|
3996
4973
|
AGENT_TOOL_REGISTRY3,
|
|
3997
4974
|
AGENT_REGISTRY6,
|
|
3998
|
-
|
|
4975
|
+
AGENT_SINK3,
|
|
3999
4976
|
AGENT_ROLES_POLICY2,
|
|
4000
|
-
|
|
4977
|
+
AGENT_ACTOR_RESOLVER13,
|
|
4001
4978
|
AGENT_MODEL2,
|
|
4002
|
-
|
|
4979
|
+
AGENT_STORE5,
|
|
4003
4980
|
AGENT_MODEL_CATALOG3,
|
|
4004
|
-
|
|
4981
|
+
AGENT_QUOTA_PROVIDER3,
|
|
4005
4982
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
4006
4983
|
AGENT_SKILLS3,
|
|
4007
4984
|
AGENT_MEMORY3,
|
|
4008
4985
|
AGENT_DEPS_FACTORY5,
|
|
4009
4986
|
AgentDepsFactory2,
|
|
4010
4987
|
AgentService,
|
|
4988
|
+
ChatQueueService,
|
|
4011
4989
|
InlineAgentRunner,
|
|
4012
4990
|
AGENT_APPROVAL_PORT
|
|
4013
4991
|
];
|
|
@@ -4015,6 +4993,7 @@ function exportsFor() {
|
|
|
4015
4993
|
__name(exportsFor, "exportsFor");
|
|
4016
4994
|
var BASE_CONTROLLERS = [
|
|
4017
4995
|
ChatController,
|
|
4996
|
+
QueueController,
|
|
4018
4997
|
ThreadsController,
|
|
4019
4998
|
ToolCallController,
|
|
4020
4999
|
QuotaController,
|
|
@@ -4072,7 +5051,7 @@ var AgentModule = class _AgentModule {
|
|
|
4072
5051
|
controllers: controllersForSurface(options.surface),
|
|
4073
5052
|
providers: [
|
|
4074
5053
|
{
|
|
4075
|
-
provide:
|
|
5054
|
+
provide: AGENT_OPTIONS7,
|
|
4076
5055
|
useValue: options
|
|
4077
5056
|
},
|
|
4078
5057
|
...sharedProviders(options.durable ?? false),
|
|
@@ -4095,7 +5074,7 @@ var AgentModule = class _AgentModule {
|
|
|
4095
5074
|
controllers: controllersForSurface(options.surface),
|
|
4096
5075
|
providers: [
|
|
4097
5076
|
{
|
|
4098
|
-
provide:
|
|
5077
|
+
provide: AGENT_OPTIONS7,
|
|
4099
5078
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4100
5079
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4101
5080
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4116,7 +5095,7 @@ var AgentModule = class _AgentModule {
|
|
|
4116
5095
|
};
|
|
4117
5096
|
}
|
|
4118
5097
|
};
|
|
4119
|
-
AgentModule =
|
|
5098
|
+
AgentModule = _ts_decorate22([
|
|
4120
5099
|
Global(),
|
|
4121
5100
|
Module({})
|
|
4122
5101
|
], AgentModule);
|
|
@@ -4212,6 +5191,7 @@ export {
|
|
|
4212
5191
|
AiToolDiscoveryService,
|
|
4213
5192
|
AnonymousActorResolver,
|
|
4214
5193
|
AttachmentsController,
|
|
5194
|
+
ChatQueueService,
|
|
4215
5195
|
ConfigController,
|
|
4216
5196
|
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
4217
5197
|
DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
@@ -4223,6 +5203,7 @@ export {
|
|
|
4223
5203
|
MemoriesController,
|
|
4224
5204
|
MessagesController,
|
|
4225
5205
|
ModelsController,
|
|
5206
|
+
QueueController,
|
|
4226
5207
|
SKILL_METADATA,
|
|
4227
5208
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
4228
5209
|
SYSTEM_PROMPT_METADATA,
|