@dudousxd/nestjs-agent 1.31.0 → 1.32.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/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
  }
@@ -177,8 +177,9 @@ function mergeSandboxClients(clients) {
177
177
  for (const client of clients) {
178
178
  const one = client();
179
179
  merged.theme ||= one.theme;
180
- if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
181
180
  if (one.kit !== void 0) merged.kit ??= one.kit;
181
+ if (one.css !== void 0) merged.css ??= one.css;
182
+ if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
182
183
  }
183
184
  return merged;
184
185
  }
@@ -201,7 +202,7 @@ async function resolveGenui(options) {
201
202
  }, "resolveSandbox");
202
203
  const sandbox = await resolveSandbox(asked);
203
204
  const own = options.catalog?.components.find((each) => sandboxPolicyOf(each) !== void 0);
204
- const ownOptions = asked === void 0 && own?.sandboxOptions !== void 0 && (own.sandboxView?.kit === true || own.sandboxView?.tailwind === true) ? await resolveSandbox({
205
+ const ownOptions = asked === void 0 && own?.sandboxOptions !== void 0 && own.sandboxView?.kit === true ? await resolveSandbox({
205
206
  ...own.sandboxOptions,
206
207
  name: own.name
207
208
  }) : void 0;
@@ -286,7 +287,7 @@ function coreProviders(resolver) {
286
287
  },
287
288
  {
288
289
  provide: AGENT_GENUI,
289
- useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui(catalog, perRequest(resolverInstance), resolved.channels, {
290
+ useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui2(catalog, perRequest(resolverInstance), resolved.channels, {
290
291
  ...options.mode !== void 0 ? {
291
292
  mode: options.mode
292
293
  } : {},
@@ -422,7 +423,8 @@ var AgentDepsFactory2 = class {
422
423
  memory;
423
424
  uiCatalog;
424
425
  uiCatalogResolver;
425
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
426
+ genui;
427
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver, genui) {
426
428
  this.options = options;
427
429
  this.model = model;
428
430
  this.store = store;
@@ -436,6 +438,7 @@ var AgentDepsFactory2 = class {
436
438
  this.memory = memory;
437
439
  this.uiCatalog = uiCatalog;
438
440
  this.uiCatalogResolver = uiCatalogResolver;
441
+ this.genui = genui;
439
442
  if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
440
443
  }
441
444
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
@@ -537,6 +540,30 @@ var AgentDepsFactory2 = class {
537
540
  }
538
541
  return deps;
539
542
  }
543
+ /** The turn's UI catalog: the per-request resolver's, else the app's. */
544
+ resolveUiCatalog = /* @__PURE__ */ __name((scope) => {
545
+ const catalog = this.uiCatalogResolver?.resolve({
546
+ ...scope,
547
+ ...scope.actor.tenantRef !== void 0 ? {
548
+ tenant: scope.actor.tenantRef
549
+ } : {}
550
+ }) ?? this.uiCatalog;
551
+ if (!catalog) throw new Error("UI catalog unavailable");
552
+ return catalog;
553
+ }, "resolveUiCatalog");
554
+ #uiChannelGuide;
555
+ /** genui `channels`: what the model is told per channel. Built once; `undefined` without channels. */
556
+ uiChannelGuide() {
557
+ if (this.#uiChannelGuide === void 0) {
558
+ const channels = this.genui?.channels;
559
+ this.#uiChannelGuide = channels === void 0 || this.uiCatalog === void 0 && this.uiCatalogResolver === void 0 ? null : createToolUiChannelGuide({
560
+ channels,
561
+ base: this.genui?.base ?? {},
562
+ resolveCatalog: this.resolveUiCatalog
563
+ });
564
+ }
565
+ return this.#uiChannelGuide ?? void 0;
566
+ }
540
567
  forAgent(agentName) {
541
568
  const name = agentName ?? this.defaultAgentName();
542
569
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -552,6 +579,7 @@ var AgentDepsFactory2 = class {
552
579
  const retrieval = this.options.retrieval;
553
580
  const historyPolicy = this.historyPolicy(definition);
554
581
  const ask = definition?.ask ?? this.options.ask;
582
+ const uiChannelGuide = this.uiChannelGuide();
555
583
  return {
556
584
  model: this.model,
557
585
  store: this.store,
@@ -565,16 +593,10 @@ var AgentDepsFactory2 = class {
565
593
  } : {},
566
594
  registry: this.registry,
567
595
  ...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")
596
+ resolveUiCatalog: this.resolveUiCatalog
597
+ } : {},
598
+ ...uiChannelGuide !== void 0 ? {
599
+ uiChannelGuide
578
600
  } : {},
579
601
  promptContributors: this.promptContributors,
580
602
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
@@ -745,6 +767,8 @@ AgentDepsFactory2 = _ts_decorate2([
745
767
  _ts_param(11, Optional()),
746
768
  _ts_param(11, Inject2(GENUI_CATALOG)),
747
769
  _ts_param(12, Optional()),
770
+ _ts_param(13, Optional()),
771
+ _ts_param(13, Inject2(AGENT_GENUI)),
748
772
  _ts_metadata("design:type", Function),
749
773
  _ts_metadata("design:paramtypes", [
750
774
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -759,7 +783,8 @@ AgentDepsFactory2 = _ts_decorate2([
759
783
  Object,
760
784
  Object,
761
785
  typeof Catalog === "undefined" ? Object : Catalog,
762
- typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
786
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver,
787
+ typeof AgentGenui === "undefined" ? Object : AgentGenui
763
788
  ])
764
789
  ], AgentDepsFactory2);
765
790