@dudousxd/nestjs-agent 1.30.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,18 +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-Bk7DCKGV.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-Bk7DCKGV.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-D9EM7ivO.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-D9EM7ivO.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
+ import { AgentGenui } from './genui/index.cjs';
12
13
  import { StandardSchemaV1 } from '@standard-schema/spec';
13
14
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
14
15
  import '@dudousxd/nestjs-agent-core/genui';
15
- import './genui/index.cjs';
16
16
 
17
17
  declare class AgentModule {
18
18
  static forRoot(options: AgentModuleOptions): DynamicModule;
@@ -202,7 +202,8 @@ declare class ConfigController {
202
202
  private readonly actorResolver;
203
203
  private readonly staging;
204
204
  private readonly models;
205
- constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined);
205
+ private readonly genui;
206
+ constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined, genui: AgentGenui | undefined);
206
207
  config(req: Request): Promise<AgentClientConfig>;
207
208
  }
208
209
 
package/dist/index.d.ts CHANGED
@@ -1,18 +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-B-fVOJGf.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-B-fVOJGf.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-APh8WN3z.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-APh8WN3z.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
+ import { AgentGenui } from './genui/index.js';
12
13
  import { StandardSchemaV1 } from '@standard-schema/spec';
13
14
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
14
15
  import '@dudousxd/nestjs-agent-core/genui';
15
- import './genui/index.js';
16
16
 
17
17
  declare class AgentModule {
18
18
  static forRoot(options: AgentModuleOptions): DynamicModule;
@@ -202,7 +202,8 @@ declare class ConfigController {
202
202
  private readonly actorResolver;
203
203
  private readonly staging;
204
204
  private readonly models;
205
- constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined);
205
+ private readonly genui;
206
+ constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined, genui: AgentGenui | undefined);
206
207
  config(req: Request): Promise<AgentClientConfig>;
207
208
  }
208
209
 
package/dist/index.js CHANGED
@@ -1,5 +1,63 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // src/vite/index.ts
13
+ import { SANDBOX_KIT_DEV_PREFIX, SANDBOX_KIT_MANIFEST_KEYS, SANDBOX_KIT_UPDATE_EVENT, createGenuiSandboxKitPlugin } from "@dudousxd/nestjs-agent-core/genui/kit";
14
+ var NEST_SANDBOX_KIT_DESCRIPTOR;
15
+ var init_vite = __esm({
16
+ "src/vite/index.ts"() {
17
+ "use strict";
18
+ NEST_SANDBOX_KIT_DESCRIPTOR = ".genui/sandbox-kit.json";
19
+ }
20
+ });
21
+
22
+ // src/genui/kit.ts
23
+ var kit_exports = {};
24
+ __export(kit_exports, {
25
+ NEST_SANDBOX_KIT_MANIFEST: () => NEST_SANDBOX_KIT_MANIFEST,
26
+ nestSandboxKitDiscovery: () => nestSandboxKitDiscovery
27
+ });
28
+ import { resolve } from "path";
29
+ import { sandboxKitDiscovery } from "@dudousxd/nestjs-agent-core/genui/kit";
30
+ function nestSandboxKitDiscovery(options = {}) {
31
+ const manifest = options.manifest ?? NEST_SANDBOX_KIT_MANIFEST;
32
+ return sandboxKitDiscovery({
33
+ root: resolve(options.root ?? process.cwd()),
34
+ descriptor: options.descriptor ?? NEST_SANDBOX_KIT_DESCRIPTOR,
35
+ ...manifest !== false ? {
36
+ manifest: {
37
+ file: manifest.file,
38
+ outDir: manifest.outDir
39
+ }
40
+ } : {},
41
+ ...options.kitUrl !== void 0 ? {
42
+ kitUrl: options.kitUrl
43
+ } : {},
44
+ ...options.production !== void 0 ? {
45
+ production: options.production
46
+ } : {}
47
+ });
48
+ }
49
+ var NEST_SANDBOX_KIT_MANIFEST;
50
+ var init_kit = __esm({
51
+ "src/genui/kit.ts"() {
52
+ "use strict";
53
+ init_vite();
54
+ NEST_SANDBOX_KIT_MANIFEST = Object.freeze({
55
+ file: "public/.vite/manifest.json",
56
+ outDir: "public"
57
+ });
58
+ __name(nestSandboxKitDiscovery, "nestSandboxKitDiscovery");
59
+ }
60
+ });
3
61
 
4
62
  // src/agent.module.ts
5
63
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL3, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS10, 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_STORE7, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
@@ -7,13 +65,13 @@ import { Global, Logger as Logger8, Module as Module2 } from "@nestjs/common";
7
65
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
8
66
 
9
67
  // src/agent-deps.factory.ts
10
- import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
68
+ import { assertIndependentActionCapabilities, createToolUiChannelGuide } from "@dudousxd/nestjs-agent-core";
11
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";
12
70
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
13
71
  import { BadRequestException, Inject as Inject2, Injectable, Optional } from "@nestjs/common";
14
72
 
15
73
  // src/genui/agent-genui.module.ts
16
- import { defineCatalog, defineSandbox, genuiTools } from "@dudousxd/nestjs-agent-core/genui";
74
+ import { assertGenuiChannels, defineCatalog, defineSandbox, genuiTools, sandboxPolicyOf } from "@dudousxd/nestjs-agent-core/genui";
17
75
  import { Inject, Module } from "@nestjs/common";
18
76
 
19
77
  // src/functional-tool.ts
@@ -56,6 +114,26 @@ function provideAgentTools(factory, inject) {
56
114
  __name(provideAgentTools, "provideAgentTools");
57
115
  var defineTool = createFunctionalTool;
58
116
 
117
+ // src/genui/agent-genui.token.ts
118
+ var AGENT_GENUI = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui");
119
+ var AgentGenui2 = class {
120
+ static {
121
+ __name(this, "AgentGenui");
122
+ }
123
+ catalog;
124
+ resolveCatalog;
125
+ channels;
126
+ base;
127
+ sandboxClient;
128
+ constructor(catalog, resolveCatalog2, channels, base = {}, sandboxClient) {
129
+ this.catalog = catalog;
130
+ this.resolveCatalog = resolveCatalog2;
131
+ this.channels = channels;
132
+ this.base = base;
133
+ this.sandboxClient = sandboxClient;
134
+ }
135
+ };
136
+
59
137
  // src/genui/agent-genui.module.ts
60
138
  function _ts_decorate(decorators, target, key, desc) {
61
139
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -73,6 +151,7 @@ function _ts_decorate(decorators, target, key, desc) {
73
151
  __name(_ts_decorate, "_ts_decorate");
74
152
  var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
75
153
  var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
154
+ var GENUI_RESOLVED = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-resolved");
76
155
  var GenuiCatalogResolver = class {
77
156
  static {
78
157
  __name(this, "GenuiCatalogResolver");
@@ -91,20 +170,99 @@ function resolverProviders(resolver) {
91
170
  ];
92
171
  }
93
172
  __name(resolverProviders, "resolverProviders");
94
- function toolOptions(options, resolver) {
95
- const { catalog: _catalog, sandbox: _sandbox, ...rest } = options;
173
+ function mergeSandboxClients(clients) {
174
+ const merged = {
175
+ theme: false
176
+ };
177
+ for (const client of clients) {
178
+ const one = client();
179
+ merged.theme ||= one.theme;
180
+ if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
181
+ if (one.kit !== void 0) merged.kit ??= one.kit;
182
+ }
183
+ return merged;
184
+ }
185
+ __name(mergeSandboxClients, "mergeSandboxClients");
186
+ async function resolveGenui(options) {
187
+ const { sandbox: asked, channels: askedChannels } = options;
188
+ assertGenuiChannels(askedChannels);
189
+ const clients = [];
190
+ let discovery;
191
+ const resolveSandbox = /* @__PURE__ */ __name(async (value) => {
192
+ if (value === void 0 || value === false) return value;
193
+ const [{ nestSandboxKitDiscovery: nestSandboxKitDiscovery2 }, { resolveSandboxServer }] = await Promise.all([
194
+ Promise.resolve().then(() => (init_kit(), kit_exports)),
195
+ import("@dudousxd/nestjs-agent-core/genui/kit")
196
+ ]);
197
+ discovery ??= nestSandboxKitDiscovery2(options.sandboxKit);
198
+ const resolved = resolveSandboxServer(value, discovery);
199
+ clients.push(resolved.client);
200
+ return resolved.define;
201
+ }, "resolveSandbox");
202
+ const sandbox = await resolveSandbox(asked);
203
+ 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
+ ...own.sandboxOptions,
206
+ name: own.name
207
+ }) : void 0;
208
+ let channels;
209
+ if (askedChannels !== void 0) {
210
+ channels = {};
211
+ for (const [name, entry] of Object.entries(askedChannels)) {
212
+ if (entry === void 0) continue;
213
+ const own2 = await resolveSandbox(entry.sandbox);
214
+ channels[name] = {
215
+ ...entry,
216
+ ...own2 !== void 0 ? {
217
+ sandbox: own2
218
+ } : {}
219
+ };
220
+ }
221
+ }
222
+ return {
223
+ ...sandbox !== void 0 ? {
224
+ sandbox
225
+ } : {},
226
+ ...typeof ownOptions === "object" ? {
227
+ catalogSandbox: ownOptions
228
+ } : {},
229
+ ...channels !== void 0 ? {
230
+ channels
231
+ } : {},
232
+ ...clients.length > 0 ? {
233
+ sandboxClient: /* @__PURE__ */ __name(() => mergeSandboxClients(clients), "sandboxClient")
234
+ } : {}
235
+ };
236
+ }
237
+ __name(resolveGenui, "resolveGenui");
238
+ function perRequest(resolver) {
239
+ return resolver === void 0 ? void 0 : (scope) => resolver.resolve(scope);
240
+ }
241
+ __name(perRequest, "perRequest");
242
+ function toolOptions(options, resolved, resolver) {
243
+ const { catalog: _catalog, sandbox: _sandbox, channels: _channels, sandboxKit: _sandboxKit, ...rest } = options;
244
+ const resolveCatalog2 = perRequest(resolver);
96
245
  return {
97
246
  ...rest,
98
- ...resolver !== void 0 ? {
99
- resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
247
+ ...resolved.channels !== void 0 ? {
248
+ channels: resolved.channels
249
+ } : {},
250
+ ...resolved.sandbox !== void 0 ? {
251
+ sandbox: resolved.sandbox
252
+ } : {},
253
+ ...resolveCatalog2 !== void 0 ? {
254
+ resolveCatalog: resolveCatalog2
100
255
  } : {}
101
256
  };
102
257
  }
103
258
  __name(toolOptions, "toolOptions");
104
- function withSandbox(options) {
259
+ function withSandbox(options, resolved) {
105
260
  const base = options.catalog ?? defineCatalog([]);
106
- const { sandbox } = options;
107
- return sandbox === void 0 || sandbox === false ? base : base.extend([
261
+ const { sandbox, catalogSandbox } = resolved;
262
+ if (sandbox === void 0 || sandbox === false) return catalogSandbox !== void 0 ? base.extend([
263
+ defineSandbox(catalogSandbox)
264
+ ]) : base;
265
+ return base.extend([
108
266
  defineSandbox(sandbox === true ? {} : sandbox)
109
267
  ]);
110
268
  }
@@ -112,18 +270,50 @@ __name(withSandbox, "withSandbox");
112
270
  function coreProviders(resolver) {
113
271
  return [
114
272
  {
115
- provide: GENUI_CATALOG,
116
- useFactory: /* @__PURE__ */ __name((options) => withSandbox(options), "useFactory"),
273
+ provide: GENUI_RESOLVED,
274
+ useFactory: /* @__PURE__ */ __name((options) => resolveGenui(options), "useFactory"),
117
275
  inject: [
118
276
  GENUI_OPTIONS
119
277
  ]
120
278
  },
279
+ {
280
+ provide: GENUI_CATALOG,
281
+ useFactory: /* @__PURE__ */ __name((options, resolved) => withSandbox(options, resolved), "useFactory"),
282
+ inject: [
283
+ GENUI_OPTIONS,
284
+ GENUI_RESOLVED
285
+ ]
286
+ },
287
+ {
288
+ provide: AGENT_GENUI,
289
+ useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui2(catalog, perRequest(resolverInstance), resolved.channels, {
290
+ ...options.mode !== void 0 ? {
291
+ mode: options.mode
292
+ } : {},
293
+ ...options.streaming !== void 0 ? {
294
+ streaming: options.streaming
295
+ } : {},
296
+ ...resolved.sandbox !== void 0 ? {
297
+ sandbox: resolved.sandbox
298
+ } : {}
299
+ }, resolved.sandboxClient), "useFactory"),
300
+ inject: [
301
+ GENUI_OPTIONS,
302
+ GENUI_CATALOG,
303
+ GENUI_RESOLVED,
304
+ {
305
+ token: GenuiCatalogResolver,
306
+ optional: true
307
+ }
308
+ ]
309
+ },
121
310
  ...resolverProviders(resolver),
122
311
  // The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
123
312
  // Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
124
- provideAgentTools((options, catalog, perRequest) => genuiTools(catalog, toolOptions(options, perRequest)), [
313
+ provideAgentTools((options, catalog, resolved, perRequestResolver) => genuiTools(catalog, toolOptions(options, resolved, perRequestResolver)), [
125
314
  GENUI_OPTIONS,
126
315
  GENUI_CATALOG,
316
+ GENUI_RESOLVED,
127
317
  {
128
318
  token: GenuiCatalogResolver,
129
319
  optional: true
@@ -134,7 +324,8 @@ function coreProviders(resolver) {
134
324
  __name(coreProviders, "coreProviders");
135
325
  var EXPORTS = [
136
326
  GENUI_CATALOG,
137
- GENUI_OPTIONS
327
+ GENUI_OPTIONS,
328
+ AGENT_GENUI
138
329
  ];
139
330
  var AgentGenuiModule = class _AgentGenuiModule {
140
331
  static {
@@ -231,7 +422,8 @@ var AgentDepsFactory2 = class {
231
422
  memory;
232
423
  uiCatalog;
233
424
  uiCatalogResolver;
234
- 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) {
235
427
  this.options = options;
236
428
  this.model = model;
237
429
  this.store = store;
@@ -245,6 +437,7 @@ var AgentDepsFactory2 = class {
245
437
  this.memory = memory;
246
438
  this.uiCatalog = uiCatalog;
247
439
  this.uiCatalogResolver = uiCatalogResolver;
440
+ this.genui = genui;
248
441
  if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
249
442
  }
250
443
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
@@ -346,6 +539,30 @@ var AgentDepsFactory2 = class {
346
539
  }
347
540
  return deps;
348
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
+ }
349
566
  forAgent(agentName) {
350
567
  const name = agentName ?? this.defaultAgentName();
351
568
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -361,6 +578,7 @@ var AgentDepsFactory2 = class {
361
578
  const retrieval = this.options.retrieval;
362
579
  const historyPolicy = this.historyPolicy(definition);
363
580
  const ask = definition?.ask ?? this.options.ask;
581
+ const uiChannelGuide = this.uiChannelGuide();
364
582
  return {
365
583
  model: this.model,
366
584
  store: this.store,
@@ -374,16 +592,10 @@ var AgentDepsFactory2 = class {
374
592
  } : {},
375
593
  registry: this.registry,
376
594
  ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
377
- resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
378
- const catalog = this.uiCatalogResolver?.resolve({
379
- ...scope,
380
- ...scope.actor.tenantRef !== void 0 ? {
381
- tenant: scope.actor.tenantRef
382
- } : {}
383
- }) ?? this.uiCatalog;
384
- if (!catalog) throw new Error("UI catalog unavailable");
385
- return catalog;
386
- }, "resolveUiCatalog")
595
+ resolveUiCatalog: this.resolveUiCatalog
596
+ } : {},
597
+ ...uiChannelGuide !== void 0 ? {
598
+ uiChannelGuide
387
599
  } : {},
388
600
  promptContributors: this.promptContributors,
389
601
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
@@ -466,7 +678,7 @@ var AgentDepsFactory2 = class {
466
678
  id: persona.id,
467
679
  label: persona.label
468
680
  };
469
- const resolve = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
681
+ const resolve2 = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
470
682
  const own = persona.systemPrompt;
471
683
  const systemPrompt = /* @__PURE__ */ __name(async (ctx) => {
472
684
  const scoped = {
@@ -474,10 +686,10 @@ var AgentDepsFactory2 = class {
474
686
  persona: ref
475
687
  };
476
688
  if (own === void 0) {
477
- return resolve(base, scoped);
689
+ return resolve2(base, scoped);
478
690
  }
479
- const basePrompt = typeof own === "function" ? await resolve(base, scoped) : void 0;
480
- return resolve(own, {
691
+ const basePrompt = typeof own === "function" ? await resolve2(base, scoped) : void 0;
692
+ return resolve2(own, {
481
693
  ...scoped,
482
694
  ...basePrompt !== void 0 ? {
483
695
  basePrompt
@@ -554,6 +766,8 @@ AgentDepsFactory2 = _ts_decorate2([
554
766
  _ts_param(11, Optional()),
555
767
  _ts_param(11, Inject2(GENUI_CATALOG)),
556
768
  _ts_param(12, Optional()),
769
+ _ts_param(13, Optional()),
770
+ _ts_param(13, Inject2(AGENT_GENUI)),
557
771
  _ts_metadata("design:type", Function),
558
772
  _ts_metadata("design:paramtypes", [
559
773
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -568,7 +782,8 @@ AgentDepsFactory2 = _ts_decorate2([
568
782
  Object,
569
783
  Object,
570
784
  typeof Catalog === "undefined" ? Object : Catalog,
571
- typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
785
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver,
786
+ typeof AgentGenui === "undefined" ? Object : AgentGenui
572
787
  ])
573
788
  ], AgentDepsFactory2);
574
789
 
@@ -1398,8 +1613,16 @@ function sendableParams(params) {
1398
1613
  message: "nothing to answer: send a non-empty message, an attachment, or regenerate"
1399
1614
  });
1400
1615
  }
1401
- return text === message ? params : {
1402
- ...params,
1616
+ const { channel, ...rest } = params;
1617
+ const stamped = channel === void 0 ? params : {
1618
+ ...rest,
1619
+ pageContext: {
1620
+ ...params.pageContext,
1621
+ channel
1622
+ }
1623
+ };
1624
+ return text === message ? stamped : {
1625
+ ...stamped,
1403
1626
  message: text
1404
1627
  };
1405
1628
  }
@@ -3321,11 +3544,13 @@ var ConfigController = class {
3321
3544
  actorResolver;
3322
3545
  staging;
3323
3546
  models;
3324
- constructor(options, actorResolver, staging, models) {
3547
+ genui;
3548
+ constructor(options, actorResolver, staging, models, genui) {
3325
3549
  this.options = options;
3326
3550
  this.actorResolver = actorResolver;
3327
3551
  this.staging = staging;
3328
3552
  this.models = models;
3553
+ this.genui = genui;
3329
3554
  }
3330
3555
  async config(req) {
3331
3556
  await this.actorResolver.resolve(req);
@@ -3339,7 +3564,12 @@ var ConfigController = class {
3339
3564
  },
3340
3565
  identity: {
3341
3566
  anonymous: this.actorResolver instanceof AnonymousActorResolver
3342
- }
3567
+ },
3568
+ ...this.genui?.sandboxClient !== void 0 ? {
3569
+ genui: {
3570
+ sandbox: this.genui.sandboxClient()
3571
+ }
3572
+ } : {}
3343
3573
  };
3344
3574
  }
3345
3575
  };
@@ -3360,11 +3590,14 @@ ConfigController = _ts_decorate10([
3360
3590
  _ts_param9(2, Inject9(AGENT_ATTACHMENT_STAGING4)),
3361
3591
  _ts_param9(3, Optional6()),
3362
3592
  _ts_param9(3, Inject9(AGENT_MODEL_CATALOG2)),
3593
+ _ts_param9(4, Optional6()),
3594
+ _ts_param9(4, Inject9(AGENT_GENUI)),
3363
3595
  _ts_metadata9("design:type", Function),
3364
3596
  _ts_metadata9("design:paramtypes", [
3365
3597
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
3366
3598
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3367
3599
  Object,
3600
+ Object,
3368
3601
  Object
3369
3602
  ])
3370
3603
  ], ConfigController);
@@ -5046,8 +5279,8 @@ var InProcessTokenStreamSink = class {
5046
5279
  return buf;
5047
5280
  }
5048
5281
  wake(buf) {
5049
- for (const resolve of buf.notify) {
5050
- resolve();
5282
+ for (const resolve2 of buf.notify) {
5283
+ resolve2();
5051
5284
  }
5052
5285
  buf.notify.clear();
5053
5286
  }
@@ -5086,7 +5319,7 @@ var InProcessTokenStreamSink = class {
5086
5319
  }
5087
5320
  return;
5088
5321
  }
5089
- await new Promise((resolve) => buf.notify.add(resolve));
5322
+ await new Promise((resolve2) => buf.notify.add(resolve2));
5090
5323
  }
5091
5324
  }
5092
5325
  close(runId) {
@@ -5763,12 +5996,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
5763
5996
  }
5764
5997
  const key = `${runId}:${toolCallId2}`;
5765
5998
  let timer;
5766
- const lapse = new Promise((resolve) => {
5999
+ const lapse = new Promise((resolve2) => {
5767
6000
  timer = setTimeout(() => {
5768
6001
  const entry = this.pending.get(key);
5769
6002
  if (entry !== void 0) {
5770
6003
  this.pending.delete(key);
5771
- resolve({
6004
+ resolve2({
5772
6005
  approved: false,
5773
6006
  expired: true
5774
6007
  });
@@ -5782,9 +6015,9 @@ var InlineAgentRunner = class _InlineAgentRunner {
5782
6015
  ]).finally(() => clearTimeout(timer));
5783
6016
  }
5784
6017
  park(runId, toolCallId2) {
5785
- return new Promise((resolve, reject) => {
6018
+ return new Promise((resolve2, reject) => {
5786
6019
  this.pending.set(`${runId}:${toolCallId2}`, {
5787
- resolve,
6020
+ resolve: resolve2,
5788
6021
  reject
5789
6022
  });
5790
6023
  });