@dudousxd/nestjs-agent 1.29.0 → 1.31.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.
Files changed (37) hide show
  1. package/dist/a2ui/index.cjs +207 -11
  2. package/dist/a2ui/index.cjs.map +1 -1
  3. package/dist/a2ui/index.d.cts +3 -3
  4. package/dist/a2ui/index.d.ts +3 -3
  5. package/dist/a2ui/index.js +203 -12
  6. package/dist/a2ui/index.js.map +1 -1
  7. package/dist/agent-genui.module-D0X3YnzO.d.cts +147 -0
  8. package/dist/agent-genui.module-D0X3YnzO.d.ts +147 -0
  9. package/dist/{chat-queue.service-B-fVOJGf.d.ts → chat-queue.service-Bdz43pAC.d.ts} +1 -1
  10. package/dist/{chat-queue.service-Bk7DCKGV.d.cts → chat-queue.service-ZwQ9p-Ps.d.cts} +1 -1
  11. package/dist/durable/index.cjs +249 -32
  12. package/dist/durable/index.cjs.map +1 -1
  13. package/dist/durable/index.d.cts +2 -2
  14. package/dist/durable/index.d.ts +2 -2
  15. package/dist/durable/index.js +240 -28
  16. package/dist/durable/index.js.map +1 -1
  17. package/dist/genui/index.cjs +211 -11
  18. package/dist/genui/index.cjs.map +1 -1
  19. package/dist/genui/index.d.cts +27 -94
  20. package/dist/genui/index.d.ts +27 -94
  21. package/dist/genui/index.js +205 -12
  22. package/dist/genui/index.js.map +1 -1
  23. package/dist/{index-APh8WN3z.d.ts → index-BGevU_Ih.d.ts} +8 -1
  24. package/dist/{index-D9EM7ivO.d.cts → index-DoCdfNrO.d.cts} +8 -1
  25. package/dist/index.cjs +240 -26
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +8 -6
  28. package/dist/index.d.ts +8 -6
  29. package/dist/index.js +236 -27
  30. package/dist/index.js.map +1 -1
  31. package/dist/vite/index.cjs +48 -0
  32. package/dist/vite/index.cjs.map +1 -0
  33. package/dist/vite/index.d.cts +32 -0
  34. package/dist/vite/index.d.ts +32 -0
  35. package/dist/vite/index.js +21 -0
  36. package/dist/vite/index.js.map +1 -0
  37. package/package.json +17 -3
package/dist/index.d.cts CHANGED
@@ -1,18 +1,19 @@
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-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';
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-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';
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
+ import './agent-genui.module-D0X3YnzO.cjs';
16
17
 
17
18
  declare class AgentModule {
18
19
  static forRoot(options: AgentModuleOptions): DynamicModule;
@@ -202,7 +203,8 @@ declare class ConfigController {
202
203
  private readonly actorResolver;
203
204
  private readonly staging;
204
205
  private readonly models;
205
- constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined);
206
+ private readonly genui;
207
+ constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined, genui: AgentGenui | undefined);
206
208
  config(req: Request): Promise<AgentClientConfig>;
207
209
  }
208
210
 
package/dist/index.d.ts CHANGED
@@ -1,18 +1,19 @@
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-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';
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-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';
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
+ import './agent-genui.module-D0X3YnzO.js';
16
17
 
17
18
  declare class AgentModule {
18
19
  static forRoot(options: AgentModuleOptions): DynamicModule;
@@ -202,7 +203,8 @@ declare class ConfigController {
202
203
  private readonly actorResolver;
203
204
  private readonly staging;
204
205
  private readonly models;
205
- constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined);
206
+ private readonly genui;
207
+ constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined, models: ModelCatalog | undefined, genui: AgentGenui | undefined);
206
208
  config(req: Request): Promise<AgentClientConfig>;
207
209
  }
208
210
 
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";
@@ -13,7 +71,7 @@ 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 AgentGenui = 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 AgentGenui(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 {
@@ -466,7 +657,7 @@ var AgentDepsFactory2 = class {
466
657
  id: persona.id,
467
658
  label: persona.label
468
659
  };
469
- const resolve = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
660
+ const resolve2 = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
470
661
  const own = persona.systemPrompt;
471
662
  const systemPrompt = /* @__PURE__ */ __name(async (ctx) => {
472
663
  const scoped = {
@@ -474,10 +665,10 @@ var AgentDepsFactory2 = class {
474
665
  persona: ref
475
666
  };
476
667
  if (own === void 0) {
477
- return resolve(base, scoped);
668
+ return resolve2(base, scoped);
478
669
  }
479
- const basePrompt = typeof own === "function" ? await resolve(base, scoped) : void 0;
480
- return resolve(own, {
670
+ const basePrompt = typeof own === "function" ? await resolve2(base, scoped) : void 0;
671
+ return resolve2(own, {
481
672
  ...scoped,
482
673
  ...basePrompt !== void 0 ? {
483
674
  basePrompt
@@ -1398,8 +1589,16 @@ function sendableParams(params) {
1398
1589
  message: "nothing to answer: send a non-empty message, an attachment, or regenerate"
1399
1590
  });
1400
1591
  }
1401
- return text === message ? params : {
1402
- ...params,
1592
+ const { channel, ...rest } = params;
1593
+ const stamped = channel === void 0 ? params : {
1594
+ ...rest,
1595
+ pageContext: {
1596
+ ...params.pageContext,
1597
+ channel
1598
+ }
1599
+ };
1600
+ return text === message ? stamped : {
1601
+ ...stamped,
1403
1602
  message: text
1404
1603
  };
1405
1604
  }
@@ -3321,11 +3520,13 @@ var ConfigController = class {
3321
3520
  actorResolver;
3322
3521
  staging;
3323
3522
  models;
3324
- constructor(options, actorResolver, staging, models) {
3523
+ genui;
3524
+ constructor(options, actorResolver, staging, models, genui) {
3325
3525
  this.options = options;
3326
3526
  this.actorResolver = actorResolver;
3327
3527
  this.staging = staging;
3328
3528
  this.models = models;
3529
+ this.genui = genui;
3329
3530
  }
3330
3531
  async config(req) {
3331
3532
  await this.actorResolver.resolve(req);
@@ -3339,7 +3540,12 @@ var ConfigController = class {
3339
3540
  },
3340
3541
  identity: {
3341
3542
  anonymous: this.actorResolver instanceof AnonymousActorResolver
3342
- }
3543
+ },
3544
+ ...this.genui?.sandboxClient !== void 0 ? {
3545
+ genui: {
3546
+ sandbox: this.genui.sandboxClient()
3547
+ }
3548
+ } : {}
3343
3549
  };
3344
3550
  }
3345
3551
  };
@@ -3360,11 +3566,14 @@ ConfigController = _ts_decorate10([
3360
3566
  _ts_param9(2, Inject9(AGENT_ATTACHMENT_STAGING4)),
3361
3567
  _ts_param9(3, Optional6()),
3362
3568
  _ts_param9(3, Inject9(AGENT_MODEL_CATALOG2)),
3569
+ _ts_param9(4, Optional6()),
3570
+ _ts_param9(4, Inject9(AGENT_GENUI)),
3363
3571
  _ts_metadata9("design:type", Function),
3364
3572
  _ts_metadata9("design:paramtypes", [
3365
3573
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
3366
3574
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3367
3575
  Object,
3576
+ Object,
3368
3577
  Object
3369
3578
  ])
3370
3579
  ], ConfigController);
@@ -5046,8 +5255,8 @@ var InProcessTokenStreamSink = class {
5046
5255
  return buf;
5047
5256
  }
5048
5257
  wake(buf) {
5049
- for (const resolve of buf.notify) {
5050
- resolve();
5258
+ for (const resolve2 of buf.notify) {
5259
+ resolve2();
5051
5260
  }
5052
5261
  buf.notify.clear();
5053
5262
  }
@@ -5086,7 +5295,7 @@ var InProcessTokenStreamSink = class {
5086
5295
  }
5087
5296
  return;
5088
5297
  }
5089
- await new Promise((resolve) => buf.notify.add(resolve));
5298
+ await new Promise((resolve2) => buf.notify.add(resolve2));
5090
5299
  }
5091
5300
  }
5092
5301
  close(runId) {
@@ -5763,12 +5972,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
5763
5972
  }
5764
5973
  const key = `${runId}:${toolCallId2}`;
5765
5974
  let timer;
5766
- const lapse = new Promise((resolve) => {
5975
+ const lapse = new Promise((resolve2) => {
5767
5976
  timer = setTimeout(() => {
5768
5977
  const entry = this.pending.get(key);
5769
5978
  if (entry !== void 0) {
5770
5979
  this.pending.delete(key);
5771
- resolve({
5980
+ resolve2({
5772
5981
  approved: false,
5773
5982
  expired: true
5774
5983
  });
@@ -5782,9 +5991,9 @@ var InlineAgentRunner = class _InlineAgentRunner {
5782
5991
  ]).finally(() => clearTimeout(timer));
5783
5992
  }
5784
5993
  park(runId, toolCallId2) {
5785
- return new Promise((resolve, reject) => {
5994
+ return new Promise((resolve2, reject) => {
5786
5995
  this.pending.set(`${runId}:${toolCallId2}`, {
5787
- resolve,
5996
+ resolve: resolve2,
5788
5997
  reject
5789
5998
  });
5790
5999
  });