@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.
@@ -1,7 +1,7 @@
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-Bk7DCKGV.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';
@@ -1,7 +1,7 @@
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-B-fVOJGf.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';
@@ -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/durable/agent-run.workflow.ts
5
63
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, isReplayIntegrityError as isReplayIntegrityError2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleDeadRun, settleUnsettledDelegation, streamFailure } from "@dudousxd/nestjs-agent-core";
@@ -35,7 +93,8 @@ var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-q
35
93
  // src/durable/agent-run.steps.ts
36
94
  import { createNegotiatedUiCollector } from "@dudousxd/nestjs-agent-core";
37
95
  import { prepareActionProposal, resolveActionProposalApproval } from "@dudousxd/nestjs-agent-core";
38
- 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
+ import { turnChannel } from "@dudousxd/nestjs-agent-core/genui";
39
98
  import { Step } from "@dudousxd/nestjs-durable";
40
99
  import { Inject, Injectable } from "@nestjs/common";
41
100
 
@@ -112,6 +171,7 @@ var AgentRunSteps = class {
112
171
  ...input.preflightContext?.uiCapabilities !== void 0 ? {
113
172
  uiCapabilities: input.preflightContext.uiCapabilities
114
173
  } : {},
174
+ channel: turnChannel(input.preflightContext?.pageContext),
115
175
  ...input.agentName !== void 0 ? {
116
176
  agentName: input.agentName
117
177
  } : {}
@@ -141,7 +201,8 @@ var AgentRunSteps = class {
141
201
  } : {},
142
202
  ...input.preflightContext?.uiCapabilities !== void 0 ? {
143
203
  uiCapabilities: input.preflightContext.uiCapabilities
144
- } : {}
204
+ } : {},
205
+ channel: turnChannel(input.preflightContext?.pageContext)
145
206
  }));
146
207
  const frames = observeTurnFrames(previews.writer);
147
208
  const turn = withTurnFrames(await traceLlmTurn(input.runId, input.step, () => deps.model.runTurn({
@@ -292,6 +353,7 @@ var AgentRunSteps = class {
292
353
  }
293
354
  throw error;
294
355
  }
356
+ output = await withChannelDelivery(deps, input.ctx, output, ui.components());
295
357
  return input.collectUi === true ? wrapToolStepOutput(output, ui.components(), ui.text()) : output;
296
358
  }
297
359
  };
@@ -798,8 +860,8 @@ var InProcessTokenStreamSink = class {
798
860
  return buf;
799
861
  }
800
862
  wake(buf) {
801
- for (const resolve of buf.notify) {
802
- resolve();
863
+ for (const resolve2 of buf.notify) {
864
+ resolve2();
803
865
  }
804
866
  buf.notify.clear();
805
867
  }
@@ -838,7 +900,7 @@ var InProcessTokenStreamSink = class {
838
900
  }
839
901
  return;
840
902
  }
841
- await new Promise((resolve) => buf.notify.add(resolve));
903
+ await new Promise((resolve2) => buf.notify.add(resolve2));
842
904
  }
843
905
  }
844
906
  close(runId) {
@@ -1193,13 +1255,13 @@ import { Global as Global2, Logger as Logger10, Module as Module3 } from "@nestj
1193
1255
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
1194
1256
 
1195
1257
  // src/agent-deps.factory.ts
1196
- import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
1258
+ import { assertIndependentActionCapabilities, createToolUiChannelGuide } from "@dudousxd/nestjs-agent-core";
1197
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";
1198
1260
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
1199
1261
  import { BadRequestException, Inject as Inject5, Injectable as Injectable4, Optional as Optional3 } from "@nestjs/common";
1200
1262
 
1201
1263
  // src/genui/agent-genui.module.ts
1202
- import { defineCatalog, defineSandbox, genuiTools } from "@dudousxd/nestjs-agent-core/genui";
1264
+ import { assertGenuiChannels, defineCatalog, defineSandbox, genuiTools, sandboxPolicyOf } from "@dudousxd/nestjs-agent-core/genui";
1203
1265
  import { Inject as Inject4, Module as Module2 } from "@nestjs/common";
1204
1266
 
1205
1267
  // src/functional-tool.ts
@@ -1226,6 +1288,26 @@ function provideAgentTools(factory, inject) {
1226
1288
  }
1227
1289
  __name(provideAgentTools, "provideAgentTools");
1228
1290
 
1291
+ // src/genui/agent-genui.token.ts
1292
+ var AGENT_GENUI = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui");
1293
+ var AgentGenui2 = class {
1294
+ static {
1295
+ __name(this, "AgentGenui");
1296
+ }
1297
+ catalog;
1298
+ resolveCatalog;
1299
+ channels;
1300
+ base;
1301
+ sandboxClient;
1302
+ constructor(catalog, resolveCatalog2, channels, base = {}, sandboxClient) {
1303
+ this.catalog = catalog;
1304
+ this.resolveCatalog = resolveCatalog2;
1305
+ this.channels = channels;
1306
+ this.base = base;
1307
+ this.sandboxClient = sandboxClient;
1308
+ }
1309
+ };
1310
+
1229
1311
  // src/genui/agent-genui.module.ts
1230
1312
  function _ts_decorate5(decorators, target, key, desc) {
1231
1313
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1243,6 +1325,7 @@ function _ts_decorate5(decorators, target, key, desc) {
1243
1325
  __name(_ts_decorate5, "_ts_decorate");
1244
1326
  var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
1245
1327
  var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
1328
+ var GENUI_RESOLVED = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-resolved");
1246
1329
  var GenuiCatalogResolver = class {
1247
1330
  static {
1248
1331
  __name(this, "GenuiCatalogResolver");
@@ -1261,20 +1344,99 @@ function resolverProviders(resolver) {
1261
1344
  ];
1262
1345
  }
1263
1346
  __name(resolverProviders, "resolverProviders");
1264
- function toolOptions(options, resolver) {
1265
- const { catalog: _catalog, sandbox: _sandbox, ...rest } = options;
1347
+ function mergeSandboxClients(clients) {
1348
+ const merged = {
1349
+ theme: false
1350
+ };
1351
+ for (const client of clients) {
1352
+ const one = client();
1353
+ merged.theme ||= one.theme;
1354
+ if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
1355
+ if (one.kit !== void 0) merged.kit ??= one.kit;
1356
+ }
1357
+ return merged;
1358
+ }
1359
+ __name(mergeSandboxClients, "mergeSandboxClients");
1360
+ async function resolveGenui(options) {
1361
+ const { sandbox: asked, channels: askedChannels } = options;
1362
+ assertGenuiChannels(askedChannels);
1363
+ const clients = [];
1364
+ let discovery;
1365
+ const resolveSandbox = /* @__PURE__ */ __name(async (value) => {
1366
+ if (value === void 0 || value === false) return value;
1367
+ const [{ nestSandboxKitDiscovery: nestSandboxKitDiscovery2 }, { resolveSandboxServer }] = await Promise.all([
1368
+ Promise.resolve().then(() => (init_kit(), kit_exports)),
1369
+ import("@dudousxd/nestjs-agent-core/genui/kit")
1370
+ ]);
1371
+ discovery ??= nestSandboxKitDiscovery2(options.sandboxKit);
1372
+ const resolved = resolveSandboxServer(value, discovery);
1373
+ clients.push(resolved.client);
1374
+ return resolved.define;
1375
+ }, "resolveSandbox");
1376
+ const sandbox = await resolveSandbox(asked);
1377
+ const own = options.catalog?.components.find((each) => sandboxPolicyOf(each) !== void 0);
1378
+ const ownOptions = asked === void 0 && own?.sandboxOptions !== void 0 && (own.sandboxView?.kit === true || own.sandboxView?.tailwind === true) ? await resolveSandbox({
1379
+ ...own.sandboxOptions,
1380
+ name: own.name
1381
+ }) : void 0;
1382
+ let channels;
1383
+ if (askedChannels !== void 0) {
1384
+ channels = {};
1385
+ for (const [name, entry] of Object.entries(askedChannels)) {
1386
+ if (entry === void 0) continue;
1387
+ const own2 = await resolveSandbox(entry.sandbox);
1388
+ channels[name] = {
1389
+ ...entry,
1390
+ ...own2 !== void 0 ? {
1391
+ sandbox: own2
1392
+ } : {}
1393
+ };
1394
+ }
1395
+ }
1396
+ return {
1397
+ ...sandbox !== void 0 ? {
1398
+ sandbox
1399
+ } : {},
1400
+ ...typeof ownOptions === "object" ? {
1401
+ catalogSandbox: ownOptions
1402
+ } : {},
1403
+ ...channels !== void 0 ? {
1404
+ channels
1405
+ } : {},
1406
+ ...clients.length > 0 ? {
1407
+ sandboxClient: /* @__PURE__ */ __name(() => mergeSandboxClients(clients), "sandboxClient")
1408
+ } : {}
1409
+ };
1410
+ }
1411
+ __name(resolveGenui, "resolveGenui");
1412
+ function perRequest(resolver) {
1413
+ return resolver === void 0 ? void 0 : (scope) => resolver.resolve(scope);
1414
+ }
1415
+ __name(perRequest, "perRequest");
1416
+ function toolOptions(options, resolved, resolver) {
1417
+ const { catalog: _catalog, sandbox: _sandbox, channels: _channels, sandboxKit: _sandboxKit, ...rest } = options;
1418
+ const resolveCatalog2 = perRequest(resolver);
1266
1419
  return {
1267
1420
  ...rest,
1268
- ...resolver !== void 0 ? {
1269
- resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
1421
+ ...resolved.channels !== void 0 ? {
1422
+ channels: resolved.channels
1423
+ } : {},
1424
+ ...resolved.sandbox !== void 0 ? {
1425
+ sandbox: resolved.sandbox
1426
+ } : {},
1427
+ ...resolveCatalog2 !== void 0 ? {
1428
+ resolveCatalog: resolveCatalog2
1270
1429
  } : {}
1271
1430
  };
1272
1431
  }
1273
1432
  __name(toolOptions, "toolOptions");
1274
- function withSandbox(options) {
1433
+ function withSandbox(options, resolved) {
1275
1434
  const base = options.catalog ?? defineCatalog([]);
1276
- const { sandbox } = options;
1277
- return sandbox === void 0 || sandbox === false ? base : base.extend([
1435
+ const { sandbox, catalogSandbox } = resolved;
1436
+ if (sandbox === void 0 || sandbox === false) return catalogSandbox !== void 0 ? base.extend([
1437
+ defineSandbox(catalogSandbox)
1438
+ ]) : base;
1439
+ return base.extend([
1278
1440
  defineSandbox(sandbox === true ? {} : sandbox)
1279
1441
  ]);
1280
1442
  }
@@ -1282,18 +1444,50 @@ __name(withSandbox, "withSandbox");
1282
1444
  function coreProviders(resolver) {
1283
1445
  return [
1284
1446
  {
1285
- provide: GENUI_CATALOG,
1286
- useFactory: /* @__PURE__ */ __name((options) => withSandbox(options), "useFactory"),
1447
+ provide: GENUI_RESOLVED,
1448
+ useFactory: /* @__PURE__ */ __name((options) => resolveGenui(options), "useFactory"),
1287
1449
  inject: [
1288
1450
  GENUI_OPTIONS
1289
1451
  ]
1290
1452
  },
1453
+ {
1454
+ provide: GENUI_CATALOG,
1455
+ useFactory: /* @__PURE__ */ __name((options, resolved) => withSandbox(options, resolved), "useFactory"),
1456
+ inject: [
1457
+ GENUI_OPTIONS,
1458
+ GENUI_RESOLVED
1459
+ ]
1460
+ },
1461
+ {
1462
+ provide: AGENT_GENUI,
1463
+ useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui2(catalog, perRequest(resolverInstance), resolved.channels, {
1464
+ ...options.mode !== void 0 ? {
1465
+ mode: options.mode
1466
+ } : {},
1467
+ ...options.streaming !== void 0 ? {
1468
+ streaming: options.streaming
1469
+ } : {},
1470
+ ...resolved.sandbox !== void 0 ? {
1471
+ sandbox: resolved.sandbox
1472
+ } : {}
1473
+ }, resolved.sandboxClient), "useFactory"),
1474
+ inject: [
1475
+ GENUI_OPTIONS,
1476
+ GENUI_CATALOG,
1477
+ GENUI_RESOLVED,
1478
+ {
1479
+ token: GenuiCatalogResolver,
1480
+ optional: true
1481
+ }
1482
+ ]
1483
+ },
1291
1484
  ...resolverProviders(resolver),
1292
1485
  // The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
1293
1486
  // Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
1294
- provideAgentTools((options, catalog, perRequest) => genuiTools(catalog, toolOptions(options, perRequest)), [
1487
+ provideAgentTools((options, catalog, resolved, perRequestResolver) => genuiTools(catalog, toolOptions(options, resolved, perRequestResolver)), [
1295
1488
  GENUI_OPTIONS,
1296
1489
  GENUI_CATALOG,
1490
+ GENUI_RESOLVED,
1297
1491
  {
1298
1492
  token: GenuiCatalogResolver,
1299
1493
  optional: true
@@ -1304,7 +1498,8 @@ function coreProviders(resolver) {
1304
1498
  __name(coreProviders, "coreProviders");
1305
1499
  var EXPORTS = [
1306
1500
  GENUI_CATALOG,
1307
- GENUI_OPTIONS
1501
+ GENUI_OPTIONS,
1502
+ AGENT_GENUI
1308
1503
  ];
1309
1504
  var AgentGenuiModule = class _AgentGenuiModule {
1310
1505
  static {
@@ -1401,7 +1596,8 @@ var AgentDepsFactory2 = class {
1401
1596
  memory;
1402
1597
  uiCatalog;
1403
1598
  uiCatalogResolver;
1404
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
1599
+ genui;
1600
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver, genui) {
1405
1601
  this.options = options;
1406
1602
  this.model = model;
1407
1603
  this.store = store;
@@ -1415,6 +1611,7 @@ var AgentDepsFactory2 = class {
1415
1611
  this.memory = memory;
1416
1612
  this.uiCatalog = uiCatalog;
1417
1613
  this.uiCatalogResolver = uiCatalogResolver;
1614
+ this.genui = genui;
1418
1615
  if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
1419
1616
  }
1420
1617
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
@@ -1516,6 +1713,30 @@ var AgentDepsFactory2 = class {
1516
1713
  }
1517
1714
  return deps;
1518
1715
  }
1716
+ /** The turn's UI catalog: the per-request resolver's, else the app's. */
1717
+ resolveUiCatalog = /* @__PURE__ */ __name((scope) => {
1718
+ const catalog = this.uiCatalogResolver?.resolve({
1719
+ ...scope,
1720
+ ...scope.actor.tenantRef !== void 0 ? {
1721
+ tenant: scope.actor.tenantRef
1722
+ } : {}
1723
+ }) ?? this.uiCatalog;
1724
+ if (!catalog) throw new Error("UI catalog unavailable");
1725
+ return catalog;
1726
+ }, "resolveUiCatalog");
1727
+ #uiChannelGuide;
1728
+ /** genui `channels`: what the model is told per channel. Built once; `undefined` without channels. */
1729
+ uiChannelGuide() {
1730
+ if (this.#uiChannelGuide === void 0) {
1731
+ const channels = this.genui?.channels;
1732
+ this.#uiChannelGuide = channels === void 0 || this.uiCatalog === void 0 && this.uiCatalogResolver === void 0 ? null : createToolUiChannelGuide({
1733
+ channels,
1734
+ base: this.genui?.base ?? {},
1735
+ resolveCatalog: this.resolveUiCatalog
1736
+ });
1737
+ }
1738
+ return this.#uiChannelGuide ?? void 0;
1739
+ }
1519
1740
  forAgent(agentName) {
1520
1741
  const name = agentName ?? this.defaultAgentName();
1521
1742
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -1531,6 +1752,7 @@ var AgentDepsFactory2 = class {
1531
1752
  const retrieval = this.options.retrieval;
1532
1753
  const historyPolicy = this.historyPolicy(definition);
1533
1754
  const ask = definition?.ask ?? this.options.ask;
1755
+ const uiChannelGuide = this.uiChannelGuide();
1534
1756
  return {
1535
1757
  model: this.model,
1536
1758
  store: this.store,
@@ -1544,16 +1766,10 @@ var AgentDepsFactory2 = class {
1544
1766
  } : {},
1545
1767
  registry: this.registry,
1546
1768
  ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
1547
- resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
1548
- const catalog = this.uiCatalogResolver?.resolve({
1549
- ...scope,
1550
- ...scope.actor.tenantRef !== void 0 ? {
1551
- tenant: scope.actor.tenantRef
1552
- } : {}
1553
- }) ?? this.uiCatalog;
1554
- if (!catalog) throw new Error("UI catalog unavailable");
1555
- return catalog;
1556
- }, "resolveUiCatalog")
1769
+ resolveUiCatalog: this.resolveUiCatalog
1770
+ } : {},
1771
+ ...uiChannelGuide !== void 0 ? {
1772
+ uiChannelGuide
1557
1773
  } : {},
1558
1774
  promptContributors: this.promptContributors,
1559
1775
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
@@ -1636,7 +1852,7 @@ var AgentDepsFactory2 = class {
1636
1852
  id: persona.id,
1637
1853
  label: persona.label
1638
1854
  };
1639
- const resolve = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
1855
+ const resolve2 = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
1640
1856
  const own = persona.systemPrompt;
1641
1857
  const systemPrompt = /* @__PURE__ */ __name(async (ctx) => {
1642
1858
  const scoped = {
@@ -1644,10 +1860,10 @@ var AgentDepsFactory2 = class {
1644
1860
  persona: ref
1645
1861
  };
1646
1862
  if (own === void 0) {
1647
- return resolve(base, scoped);
1863
+ return resolve2(base, scoped);
1648
1864
  }
1649
- const basePrompt = typeof own === "function" ? await resolve(base, scoped) : void 0;
1650
- return resolve(own, {
1865
+ const basePrompt = typeof own === "function" ? await resolve2(base, scoped) : void 0;
1866
+ return resolve2(own, {
1651
1867
  ...scoped,
1652
1868
  ...basePrompt !== void 0 ? {
1653
1869
  basePrompt
@@ -1724,6 +1940,8 @@ AgentDepsFactory2 = _ts_decorate6([
1724
1940
  _ts_param4(11, Optional3()),
1725
1941
  _ts_param4(11, Inject5(GENUI_CATALOG)),
1726
1942
  _ts_param4(12, Optional3()),
1943
+ _ts_param4(13, Optional3()),
1944
+ _ts_param4(13, Inject5(AGENT_GENUI)),
1727
1945
  _ts_metadata4("design:type", Function),
1728
1946
  _ts_metadata4("design:paramtypes", [
1729
1947
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -1738,7 +1956,8 @@ AgentDepsFactory2 = _ts_decorate6([
1738
1956
  Object,
1739
1957
  Object,
1740
1958
  typeof Catalog === "undefined" ? Object : Catalog,
1741
- typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
1959
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver,
1960
+ typeof AgentGenui === "undefined" ? Object : AgentGenui
1742
1961
  ])
1743
1962
  ], AgentDepsFactory2);
1744
1963
 
@@ -2546,8 +2765,16 @@ function sendableParams(params) {
2546
2765
  message: "nothing to answer: send a non-empty message, an attachment, or regenerate"
2547
2766
  });
2548
2767
  }
2549
- return text === message ? params : {
2550
- ...params,
2768
+ const { channel, ...rest } = params;
2769
+ const stamped = channel === void 0 ? params : {
2770
+ ...rest,
2771
+ pageContext: {
2772
+ ...params.pageContext,
2773
+ channel
2774
+ }
2775
+ };
2776
+ return text === message ? stamped : {
2777
+ ...stamped,
2551
2778
  message: text
2552
2779
  };
2553
2780
  }
@@ -4469,11 +4696,13 @@ var ConfigController = class {
4469
4696
  actorResolver;
4470
4697
  staging;
4471
4698
  models;
4472
- constructor(options, actorResolver, staging, models) {
4699
+ genui;
4700
+ constructor(options, actorResolver, staging, models, genui) {
4473
4701
  this.options = options;
4474
4702
  this.actorResolver = actorResolver;
4475
4703
  this.staging = staging;
4476
4704
  this.models = models;
4705
+ this.genui = genui;
4477
4706
  }
4478
4707
  async config(req) {
4479
4708
  await this.actorResolver.resolve(req);
@@ -4487,7 +4716,12 @@ var ConfigController = class {
4487
4716
  },
4488
4717
  identity: {
4489
4718
  anonymous: this.actorResolver instanceof AnonymousActorResolver
4490
- }
4719
+ },
4720
+ ...this.genui?.sandboxClient !== void 0 ? {
4721
+ genui: {
4722
+ sandbox: this.genui.sandboxClient()
4723
+ }
4724
+ } : {}
4491
4725
  };
4492
4726
  }
4493
4727
  };
@@ -4508,11 +4742,14 @@ ConfigController = _ts_decorate14([
4508
4742
  _ts_param12(2, Inject12(AGENT_ATTACHMENT_STAGING4)),
4509
4743
  _ts_param12(3, Optional8()),
4510
4744
  _ts_param12(3, Inject12(AGENT_MODEL_CATALOG2)),
4745
+ _ts_param12(4, Optional8()),
4746
+ _ts_param12(4, Inject12(AGENT_GENUI)),
4511
4747
  _ts_metadata12("design:type", Function),
4512
4748
  _ts_metadata12("design:paramtypes", [
4513
4749
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
4514
4750
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4515
4751
  Object,
4752
+ Object,
4516
4753
  Object
4517
4754
  ])
4518
4755
  ], ConfigController);
@@ -6796,12 +7033,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
6796
7033
  }
6797
7034
  const key = `${runId}:${toolCallId2}`;
6798
7035
  let timer;
6799
- const lapse = new Promise((resolve) => {
7036
+ const lapse = new Promise((resolve2) => {
6800
7037
  timer = setTimeout(() => {
6801
7038
  const entry = this.pending.get(key);
6802
7039
  if (entry !== void 0) {
6803
7040
  this.pending.delete(key);
6804
- resolve({
7041
+ resolve2({
6805
7042
  approved: false,
6806
7043
  expired: true
6807
7044
  });
@@ -6815,9 +7052,9 @@ var InlineAgentRunner = class _InlineAgentRunner {
6815
7052
  ]).finally(() => clearTimeout(timer));
6816
7053
  }
6817
7054
  park(runId, toolCallId2) {
6818
- return new Promise((resolve, reject) => {
7055
+ return new Promise((resolve2, reject) => {
6819
7056
  this.pending.set(`${runId}:${toolCallId2}`, {
6820
- resolve,
7057
+ resolve: resolve2,
6821
7058
  reject
6822
7059
  });
6823
7060
  });