@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.
@@ -1,11 +1,11 @@
1
1
  import { AgentStore, AgentRunInput, AgentLoopResult, LlmStepEnvelope, BufferedModelTurnResult, ToolStepEnvelope, AgentRunner, TokenStreamSink, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
2
2
  import { WorkflowService } from '@dudousxd/nestjs-durable';
3
3
  import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
4
- import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-ZwQ9p-Ps.cjs';
4
+ import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-QIuTS-5c.cjs';
5
5
  import { DynamicModule } from '@nestjs/common';
6
6
  import '@dudousxd/nestjs-agent-core/genui';
7
7
  import '@standard-schema/spec';
8
- import '../agent-genui.module-D0X3YnzO.cjs';
8
+ import '../genui/index.cjs';
9
9
 
10
10
  /**
11
11
  * The agent turn AS a durable workflow. Persist/stream checkpoints are `ctx.localStep`s — the
@@ -1,11 +1,11 @@
1
1
  import { AgentStore, AgentRunInput, AgentLoopResult, LlmStepEnvelope, BufferedModelTurnResult, ToolStepEnvelope, AgentRunner, TokenStreamSink, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
2
2
  import { WorkflowService } from '@dudousxd/nestjs-durable';
3
3
  import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
4
- import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-Bdz43pAC.js';
4
+ import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-wNWaoUN8.js';
5
5
  import { DynamicModule } from '@nestjs/common';
6
6
  import '@dudousxd/nestjs-agent-core/genui';
7
7
  import '@standard-schema/spec';
8
- import '../agent-genui.module-D0X3YnzO.js';
8
+ import '../genui/index.js';
9
9
 
10
10
  /**
11
11
  * The agent turn AS a durable workflow. Persist/stream checkpoints are `ctx.localStep`s — the
@@ -93,7 +93,7 @@ var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-q
93
93
  // src/durable/agent-run.steps.ts
94
94
  import { createNegotiatedUiCollector } from "@dudousxd/nestjs-agent-core";
95
95
  import { prepareActionProposal, resolveActionProposalApproval } from "@dudousxd/nestjs-agent-core";
96
- import { AGENT_DEPS_FACTORY, createFrameBuffer, createNoopEmitUi, encodeStreamEvent, intersectAllowLists, invokeWithTransientRetry, isControlFlowSignal, isReplayIntegrityError, observeTurnFrames, previewToolInputs, publishAgentToolRetry, registryInputPreviews, stampToolKinds, toolCallContext, traceLlmTurn, traceToolExecution, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolPreflightDenied, wrapToolStepOutput } from "@dudousxd/nestjs-agent-core";
96
+ import { AGENT_DEPS_FACTORY, createFrameBuffer, createNoopEmitUi, encodeStreamEvent, intersectAllowLists, invokeWithTransientRetry, isControlFlowSignal, isReplayIntegrityError, observeTurnFrames, previewToolInputs, publishAgentToolRetry, registryInputPreviews, stampToolKinds, toolCallContext, traceLlmTurn, traceToolExecution, withAskTool, withChannelDelivery, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolPreflightDenied, wrapToolStepOutput } from "@dudousxd/nestjs-agent-core";
97
97
  import { turnChannel } from "@dudousxd/nestjs-agent-core/genui";
98
98
  import { Step } from "@dudousxd/nestjs-durable";
99
99
  import { Inject, Injectable } from "@nestjs/common";
@@ -353,6 +353,7 @@ var AgentRunSteps = class {
353
353
  }
354
354
  throw error;
355
355
  }
356
+ output = await withChannelDelivery(deps, input.ctx, output, ui.components());
356
357
  return input.collectUi === true ? wrapToolStepOutput(output, ui.components(), ui.text()) : output;
357
358
  }
358
359
  };
@@ -1254,7 +1255,7 @@ import { Global as Global2, Logger as Logger10, Module as Module3 } from "@nestj
1254
1255
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
1255
1256
 
1256
1257
  // src/agent-deps.factory.ts
1257
- import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
1258
+ import { assertIndependentActionCapabilities, createToolUiChannelGuide } from "@dudousxd/nestjs-agent-core";
1258
1259
  import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK2, AGENT_SKILLS, AGENT_STORE as AGENT_STORE3, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, findPersona, intersectAllowLists as intersectAllowLists2, normalizeDelegation, personaCatalogEntry, resolvePersonaAlias, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
1259
1260
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
1260
1261
  import { BadRequestException, Inject as Inject5, Injectable as Injectable4, Optional as Optional3 } from "@nestjs/common";
@@ -1289,7 +1290,7 @@ __name(provideAgentTools, "provideAgentTools");
1289
1290
 
1290
1291
  // src/genui/agent-genui.token.ts
1291
1292
  var AGENT_GENUI = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui");
1292
- var AgentGenui = class {
1293
+ var AgentGenui2 = class {
1293
1294
  static {
1294
1295
  __name(this, "AgentGenui");
1295
1296
  }
@@ -1350,8 +1351,9 @@ function mergeSandboxClients(clients) {
1350
1351
  for (const client of clients) {
1351
1352
  const one = client();
1352
1353
  merged.theme ||= one.theme;
1353
- if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
1354
1354
  if (one.kit !== void 0) merged.kit ??= one.kit;
1355
+ if (one.css !== void 0) merged.css ??= one.css;
1356
+ if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
1355
1357
  }
1356
1358
  return merged;
1357
1359
  }
@@ -1374,7 +1376,7 @@ async function resolveGenui(options) {
1374
1376
  }, "resolveSandbox");
1375
1377
  const sandbox = await resolveSandbox(asked);
1376
1378
  const own = options.catalog?.components.find((each) => sandboxPolicyOf(each) !== void 0);
1377
- const ownOptions = asked === void 0 && own?.sandboxOptions !== void 0 && (own.sandboxView?.kit === true || own.sandboxView?.tailwind === true) ? await resolveSandbox({
1379
+ const ownOptions = asked === void 0 && own?.sandboxOptions !== void 0 && own.sandboxView?.kit === true ? await resolveSandbox({
1378
1380
  ...own.sandboxOptions,
1379
1381
  name: own.name
1380
1382
  }) : void 0;
@@ -1459,7 +1461,7 @@ function coreProviders(resolver) {
1459
1461
  },
1460
1462
  {
1461
1463
  provide: AGENT_GENUI,
1462
- useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui(catalog, perRequest(resolverInstance), resolved.channels, {
1464
+ useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui2(catalog, perRequest(resolverInstance), resolved.channels, {
1463
1465
  ...options.mode !== void 0 ? {
1464
1466
  mode: options.mode
1465
1467
  } : {},
@@ -1595,7 +1597,8 @@ var AgentDepsFactory2 = class {
1595
1597
  memory;
1596
1598
  uiCatalog;
1597
1599
  uiCatalogResolver;
1598
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
1600
+ genui;
1601
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver, genui) {
1599
1602
  this.options = options;
1600
1603
  this.model = model;
1601
1604
  this.store = store;
@@ -1609,6 +1612,7 @@ var AgentDepsFactory2 = class {
1609
1612
  this.memory = memory;
1610
1613
  this.uiCatalog = uiCatalog;
1611
1614
  this.uiCatalogResolver = uiCatalogResolver;
1615
+ this.genui = genui;
1612
1616
  if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
1613
1617
  }
1614
1618
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
@@ -1710,6 +1714,30 @@ var AgentDepsFactory2 = class {
1710
1714
  }
1711
1715
  return deps;
1712
1716
  }
1717
+ /** The turn's UI catalog: the per-request resolver's, else the app's. */
1718
+ resolveUiCatalog = /* @__PURE__ */ __name((scope) => {
1719
+ const catalog = this.uiCatalogResolver?.resolve({
1720
+ ...scope,
1721
+ ...scope.actor.tenantRef !== void 0 ? {
1722
+ tenant: scope.actor.tenantRef
1723
+ } : {}
1724
+ }) ?? this.uiCatalog;
1725
+ if (!catalog) throw new Error("UI catalog unavailable");
1726
+ return catalog;
1727
+ }, "resolveUiCatalog");
1728
+ #uiChannelGuide;
1729
+ /** genui `channels`: what the model is told per channel. Built once; `undefined` without channels. */
1730
+ uiChannelGuide() {
1731
+ if (this.#uiChannelGuide === void 0) {
1732
+ const channels = this.genui?.channels;
1733
+ this.#uiChannelGuide = channels === void 0 || this.uiCatalog === void 0 && this.uiCatalogResolver === void 0 ? null : createToolUiChannelGuide({
1734
+ channels,
1735
+ base: this.genui?.base ?? {},
1736
+ resolveCatalog: this.resolveUiCatalog
1737
+ });
1738
+ }
1739
+ return this.#uiChannelGuide ?? void 0;
1740
+ }
1713
1741
  forAgent(agentName) {
1714
1742
  const name = agentName ?? this.defaultAgentName();
1715
1743
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -1725,6 +1753,7 @@ var AgentDepsFactory2 = class {
1725
1753
  const retrieval = this.options.retrieval;
1726
1754
  const historyPolicy = this.historyPolicy(definition);
1727
1755
  const ask = definition?.ask ?? this.options.ask;
1756
+ const uiChannelGuide = this.uiChannelGuide();
1728
1757
  return {
1729
1758
  model: this.model,
1730
1759
  store: this.store,
@@ -1738,16 +1767,10 @@ var AgentDepsFactory2 = class {
1738
1767
  } : {},
1739
1768
  registry: this.registry,
1740
1769
  ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
1741
- resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
1742
- const catalog = this.uiCatalogResolver?.resolve({
1743
- ...scope,
1744
- ...scope.actor.tenantRef !== void 0 ? {
1745
- tenant: scope.actor.tenantRef
1746
- } : {}
1747
- }) ?? this.uiCatalog;
1748
- if (!catalog) throw new Error("UI catalog unavailable");
1749
- return catalog;
1750
- }, "resolveUiCatalog")
1770
+ resolveUiCatalog: this.resolveUiCatalog
1771
+ } : {},
1772
+ ...uiChannelGuide !== void 0 ? {
1773
+ uiChannelGuide
1751
1774
  } : {},
1752
1775
  promptContributors: this.promptContributors,
1753
1776
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
@@ -1918,6 +1941,8 @@ AgentDepsFactory2 = _ts_decorate6([
1918
1941
  _ts_param4(11, Optional3()),
1919
1942
  _ts_param4(11, Inject5(GENUI_CATALOG)),
1920
1943
  _ts_param4(12, Optional3()),
1944
+ _ts_param4(13, Optional3()),
1945
+ _ts_param4(13, Inject5(AGENT_GENUI)),
1921
1946
  _ts_metadata4("design:type", Function),
1922
1947
  _ts_metadata4("design:paramtypes", [
1923
1948
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -1932,7 +1957,8 @@ AgentDepsFactory2 = _ts_decorate6([
1932
1957
  Object,
1933
1958
  Object,
1934
1959
  typeof Catalog === "undefined" ? Object : Catalog,
1935
- typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
1960
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver,
1961
+ typeof AgentGenui === "undefined" ? Object : AgentGenui
1936
1962
  ])
1937
1963
  ], AgentDepsFactory2);
1938
1964