@dudousxd/nestjs-agent 1.31.0 → 1.31.1

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/dist/index.d.cts CHANGED
@@ -1,19 +1,18 @@
1
1
  import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, d as AgentProtocolAdapter, A as AgentDepsFactory, e as AgentSkillsOptions, C as ChatQueueService } from './chat-queue.service-ZwQ9p-Ps.cjs';
3
- export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-ZwQ9p-Ps.cjs';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, d as AgentProtocolAdapter, A as AgentDepsFactory, e as AgentSkillsOptions, C as ChatQueueService } from './chat-queue.service-QIuTS-5c.cjs';
3
+ export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-QIuTS-5c.cjs';
4
4
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
5
5
  import { ActorResolver, AttachmentStagingStore, AgentApprovalPort, Actor, AgentStore, StagedAttachment, MessageAttachment, ModelCatalog, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, MessageFeedbackValue, MessageFeedback, ModelCatalogView, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunner, AgentRunInput, AgentRunStartOptions, HumanReply, ChatQueueState, TokenStreamSink, SinkWriter, ActionProposal } from '@dudousxd/nestjs-agent-core';
6
6
  export * from '@dudousxd/nestjs-agent-core';
7
7
  export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
8
8
  import { A2uiOptions } from '@dudousxd/nestjs-agent-core/a2ui';
9
9
  import { Request, Response } from 'express';
10
- import { A as AgentService, a as ActionProposalService } from './index-DoCdfNrO.cjs';
11
- export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-DoCdfNrO.cjs';
10
+ import { A as AgentService, a as ActionProposalService } from './index-DIFUEKPr.cjs';
11
+ export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-DIFUEKPr.cjs';
12
12
  import { AgentGenui } from './genui/index.cjs';
13
13
  import { StandardSchemaV1 } from '@standard-schema/spec';
14
14
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
15
15
  import '@dudousxd/nestjs-agent-core/genui';
16
- import './agent-genui.module-D0X3YnzO.cjs';
17
16
 
18
17
  declare class AgentModule {
19
18
  static forRoot(options: AgentModuleOptions): DynamicModule;
package/dist/index.d.ts CHANGED
@@ -1,19 +1,18 @@
1
1
  import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, d as AgentProtocolAdapter, A as AgentDepsFactory, e as AgentSkillsOptions, C as ChatQueueService } from './chat-queue.service-Bdz43pAC.js';
3
- export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-Bdz43pAC.js';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, d as AgentProtocolAdapter, A as AgentDepsFactory, e as AgentSkillsOptions, C as ChatQueueService } from './chat-queue.service-wNWaoUN8.js';
3
+ export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-wNWaoUN8.js';
4
4
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
5
5
  import { ActorResolver, AttachmentStagingStore, AgentApprovalPort, Actor, AgentStore, StagedAttachment, MessageAttachment, ModelCatalog, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, MessageFeedbackValue, MessageFeedback, ModelCatalogView, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunner, AgentRunInput, AgentRunStartOptions, HumanReply, ChatQueueState, TokenStreamSink, SinkWriter, ActionProposal } from '@dudousxd/nestjs-agent-core';
6
6
  export * from '@dudousxd/nestjs-agent-core';
7
7
  export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
8
8
  import { A2uiOptions } from '@dudousxd/nestjs-agent-core/a2ui';
9
9
  import { Request, Response } from 'express';
10
- import { A as AgentService, a as ActionProposalService } from './index-BGevU_Ih.js';
11
- export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-BGevU_Ih.js';
10
+ import { A as AgentService, a as ActionProposalService } from './index-DFKUTFfZ.js';
11
+ export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-DFKUTFfZ.js';
12
12
  import { AgentGenui } from './genui/index.js';
13
13
  import { StandardSchemaV1 } from '@standard-schema/spec';
14
14
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
15
15
  import '@dudousxd/nestjs-agent-core/genui';
16
- import './agent-genui.module-D0X3YnzO.js';
17
16
 
18
17
  declare class AgentModule {
19
18
  static forRoot(options: AgentModuleOptions): DynamicModule;
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ import { Global, Logger as Logger8, Module as Module2 } from "@nestjs/common";
65
65
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
66
66
 
67
67
  // src/agent-deps.factory.ts
68
- import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
68
+ import { assertIndependentActionCapabilities, createToolUiChannelGuide } from "@dudousxd/nestjs-agent-core";
69
69
  import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_SKILLS, AGENT_STORE, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, findPersona, intersectAllowLists, normalizeDelegation, personaCatalogEntry, resolvePersonaAlias, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
70
70
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
71
71
  import { BadRequestException, Inject as Inject2, Injectable, Optional } from "@nestjs/common";
@@ -116,7 +116,7 @@ var defineTool = createFunctionalTool;
116
116
 
117
117
  // src/genui/agent-genui.token.ts
118
118
  var AGENT_GENUI = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui");
119
- var AgentGenui = class {
119
+ var AgentGenui2 = class {
120
120
  static {
121
121
  __name(this, "AgentGenui");
122
122
  }
@@ -286,7 +286,7 @@ function coreProviders(resolver) {
286
286
  },
287
287
  {
288
288
  provide: AGENT_GENUI,
289
- useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui(catalog, perRequest(resolverInstance), resolved.channels, {
289
+ useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui2(catalog, perRequest(resolverInstance), resolved.channels, {
290
290
  ...options.mode !== void 0 ? {
291
291
  mode: options.mode
292
292
  } : {},
@@ -422,7 +422,8 @@ var AgentDepsFactory2 = class {
422
422
  memory;
423
423
  uiCatalog;
424
424
  uiCatalogResolver;
425
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
425
+ genui;
426
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver, genui) {
426
427
  this.options = options;
427
428
  this.model = model;
428
429
  this.store = store;
@@ -436,6 +437,7 @@ var AgentDepsFactory2 = class {
436
437
  this.memory = memory;
437
438
  this.uiCatalog = uiCatalog;
438
439
  this.uiCatalogResolver = uiCatalogResolver;
440
+ this.genui = genui;
439
441
  if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
440
442
  }
441
443
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
@@ -537,6 +539,30 @@ var AgentDepsFactory2 = class {
537
539
  }
538
540
  return deps;
539
541
  }
542
+ /** The turn's UI catalog: the per-request resolver's, else the app's. */
543
+ resolveUiCatalog = /* @__PURE__ */ __name((scope) => {
544
+ const catalog = this.uiCatalogResolver?.resolve({
545
+ ...scope,
546
+ ...scope.actor.tenantRef !== void 0 ? {
547
+ tenant: scope.actor.tenantRef
548
+ } : {}
549
+ }) ?? this.uiCatalog;
550
+ if (!catalog) throw new Error("UI catalog unavailable");
551
+ return catalog;
552
+ }, "resolveUiCatalog");
553
+ #uiChannelGuide;
554
+ /** genui `channels`: what the model is told per channel. Built once; `undefined` without channels. */
555
+ uiChannelGuide() {
556
+ if (this.#uiChannelGuide === void 0) {
557
+ const channels = this.genui?.channels;
558
+ this.#uiChannelGuide = channels === void 0 || this.uiCatalog === void 0 && this.uiCatalogResolver === void 0 ? null : createToolUiChannelGuide({
559
+ channels,
560
+ base: this.genui?.base ?? {},
561
+ resolveCatalog: this.resolveUiCatalog
562
+ });
563
+ }
564
+ return this.#uiChannelGuide ?? void 0;
565
+ }
540
566
  forAgent(agentName) {
541
567
  const name = agentName ?? this.defaultAgentName();
542
568
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -552,6 +578,7 @@ var AgentDepsFactory2 = class {
552
578
  const retrieval = this.options.retrieval;
553
579
  const historyPolicy = this.historyPolicy(definition);
554
580
  const ask = definition?.ask ?? this.options.ask;
581
+ const uiChannelGuide = this.uiChannelGuide();
555
582
  return {
556
583
  model: this.model,
557
584
  store: this.store,
@@ -565,16 +592,10 @@ var AgentDepsFactory2 = class {
565
592
  } : {},
566
593
  registry: this.registry,
567
594
  ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
568
- resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
569
- const catalog = this.uiCatalogResolver?.resolve({
570
- ...scope,
571
- ...scope.actor.tenantRef !== void 0 ? {
572
- tenant: scope.actor.tenantRef
573
- } : {}
574
- }) ?? this.uiCatalog;
575
- if (!catalog) throw new Error("UI catalog unavailable");
576
- return catalog;
577
- }, "resolveUiCatalog")
595
+ resolveUiCatalog: this.resolveUiCatalog
596
+ } : {},
597
+ ...uiChannelGuide !== void 0 ? {
598
+ uiChannelGuide
578
599
  } : {},
579
600
  promptContributors: this.promptContributors,
580
601
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
@@ -745,6 +766,8 @@ AgentDepsFactory2 = _ts_decorate2([
745
766
  _ts_param(11, Optional()),
746
767
  _ts_param(11, Inject2(GENUI_CATALOG)),
747
768
  _ts_param(12, Optional()),
769
+ _ts_param(13, Optional()),
770
+ _ts_param(13, Inject2(AGENT_GENUI)),
748
771
  _ts_metadata("design:type", Function),
749
772
  _ts_metadata("design:paramtypes", [
750
773
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -759,7 +782,8 @@ AgentDepsFactory2 = _ts_decorate2([
759
782
  Object,
760
783
  Object,
761
784
  typeof Catalog === "undefined" ? Object : Catalog,
762
- typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
785
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver,
786
+ typeof AgentGenui === "undefined" ? Object : AgentGenui
763
787
  ])
764
788
  ], AgentDepsFactory2);
765
789