@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,9 +1,14 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
9
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,8 +21,66 @@ var __copyProps = (to, from, except, desc) => {
16
21
  }
17
22
  return to;
18
23
  };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
19
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
33
 
34
+ // src/vite/index.ts
35
+ var import_kit, NEST_SANDBOX_KIT_DESCRIPTOR;
36
+ var init_vite = __esm({
37
+ "src/vite/index.ts"() {
38
+ "use strict";
39
+ import_kit = require("@dudousxd/nestjs-agent-core/genui/kit");
40
+ NEST_SANDBOX_KIT_DESCRIPTOR = ".genui/sandbox-kit.json";
41
+ }
42
+ });
43
+
44
+ // src/genui/kit.ts
45
+ var kit_exports = {};
46
+ __export(kit_exports, {
47
+ NEST_SANDBOX_KIT_MANIFEST: () => NEST_SANDBOX_KIT_MANIFEST,
48
+ nestSandboxKitDiscovery: () => nestSandboxKitDiscovery
49
+ });
50
+ function nestSandboxKitDiscovery(options = {}) {
51
+ const manifest = options.manifest ?? NEST_SANDBOX_KIT_MANIFEST;
52
+ return (0, import_kit2.sandboxKitDiscovery)({
53
+ root: (0, import_node_path.resolve)(options.root ?? process.cwd()),
54
+ descriptor: options.descriptor ?? NEST_SANDBOX_KIT_DESCRIPTOR,
55
+ ...manifest !== false ? {
56
+ manifest: {
57
+ file: manifest.file,
58
+ outDir: manifest.outDir
59
+ }
60
+ } : {},
61
+ ...options.kitUrl !== void 0 ? {
62
+ kitUrl: options.kitUrl
63
+ } : {},
64
+ ...options.production !== void 0 ? {
65
+ production: options.production
66
+ } : {}
67
+ });
68
+ }
69
+ var import_node_path, import_kit2, NEST_SANDBOX_KIT_MANIFEST;
70
+ var init_kit = __esm({
71
+ "src/genui/kit.ts"() {
72
+ "use strict";
73
+ import_node_path = require("path");
74
+ import_kit2 = require("@dudousxd/nestjs-agent-core/genui/kit");
75
+ init_vite();
76
+ NEST_SANDBOX_KIT_MANIFEST = Object.freeze({
77
+ file: "public/.vite/manifest.json",
78
+ outDir: "public"
79
+ });
80
+ __name(nestSandboxKitDiscovery, "nestSandboxKitDiscovery");
81
+ }
82
+ });
83
+
21
84
  // src/durable/index.ts
22
85
  var durable_exports = {};
23
86
  __export(durable_exports, {
@@ -64,6 +127,7 @@ var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-q
64
127
  var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
65
128
  var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
66
129
  var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
130
+ var import_genui = require("@dudousxd/nestjs-agent-core/genui");
67
131
  var import_nestjs_durable = require("@dudousxd/nestjs-durable");
68
132
  var import_common = require("@nestjs/common");
69
133
 
@@ -140,6 +204,7 @@ var AgentRunSteps = class {
140
204
  ...input.preflightContext?.uiCapabilities !== void 0 ? {
141
205
  uiCapabilities: input.preflightContext.uiCapabilities
142
206
  } : {},
207
+ channel: (0, import_genui.turnChannel)(input.preflightContext?.pageContext),
143
208
  ...input.agentName !== void 0 ? {
144
209
  agentName: input.agentName
145
210
  } : {}
@@ -169,7 +234,8 @@ var AgentRunSteps = class {
169
234
  } : {},
170
235
  ...input.preflightContext?.uiCapabilities !== void 0 ? {
171
236
  uiCapabilities: input.preflightContext.uiCapabilities
172
- } : {}
237
+ } : {},
238
+ channel: (0, import_genui.turnChannel)(input.preflightContext?.pageContext)
173
239
  }));
174
240
  const frames = (0, import_nestjs_agent_core3.observeTurnFrames)(previews.writer);
175
241
  const turn = (0, import_nestjs_agent_core3.withTurnFrames)(await (0, import_nestjs_agent_core3.traceLlmTurn)(input.runId, input.step, () => deps.model.runTurn({
@@ -320,6 +386,7 @@ var AgentRunSteps = class {
320
386
  }
321
387
  throw error;
322
388
  }
389
+ output = await (0, import_nestjs_agent_core3.withChannelDelivery)(deps, input.ctx, output, ui.components());
323
390
  return input.collectUi === true ? (0, import_nestjs_agent_core3.wrapToolStepOutput)(output, ui.components(), ui.text()) : output;
324
391
  }
325
392
  };
@@ -826,8 +893,8 @@ var InProcessTokenStreamSink = class {
826
893
  return buf;
827
894
  }
828
895
  wake(buf) {
829
- for (const resolve of buf.notify) {
830
- resolve();
896
+ for (const resolve2 of buf.notify) {
897
+ resolve2();
831
898
  }
832
899
  buf.notify.clear();
833
900
  }
@@ -866,7 +933,7 @@ var InProcessTokenStreamSink = class {
866
933
  }
867
934
  return;
868
935
  }
869
- await new Promise((resolve) => buf.notify.add(resolve));
936
+ await new Promise((resolve2) => buf.notify.add(resolve2));
870
937
  }
871
938
  }
872
939
  close(runId) {
@@ -1227,7 +1294,7 @@ var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
1227
1294
  var import_common6 = require("@nestjs/common");
1228
1295
 
1229
1296
  // src/genui/agent-genui.module.ts
1230
- var import_genui = require("@dudousxd/nestjs-agent-core/genui");
1297
+ var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
1231
1298
  var import_common5 = require("@nestjs/common");
1232
1299
 
1233
1300
  // src/functional-tool.ts
@@ -1254,6 +1321,26 @@ function provideAgentTools(factory, inject) {
1254
1321
  }
1255
1322
  __name(provideAgentTools, "provideAgentTools");
1256
1323
 
1324
+ // src/genui/agent-genui.token.ts
1325
+ var AGENT_GENUI = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui");
1326
+ var AgentGenui2 = class {
1327
+ static {
1328
+ __name(this, "AgentGenui");
1329
+ }
1330
+ catalog;
1331
+ resolveCatalog;
1332
+ channels;
1333
+ base;
1334
+ sandboxClient;
1335
+ constructor(catalog, resolveCatalog2, channels, base = {}, sandboxClient) {
1336
+ this.catalog = catalog;
1337
+ this.resolveCatalog = resolveCatalog2;
1338
+ this.channels = channels;
1339
+ this.base = base;
1340
+ this.sandboxClient = sandboxClient;
1341
+ }
1342
+ };
1343
+
1257
1344
  // src/genui/agent-genui.module.ts
1258
1345
  function _ts_decorate5(decorators, target, key, desc) {
1259
1346
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1271,6 +1358,7 @@ function _ts_decorate5(decorators, target, key, desc) {
1271
1358
  __name(_ts_decorate5, "_ts_decorate");
1272
1359
  var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
1273
1360
  var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
1361
+ var GENUI_RESOLVED = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-resolved");
1274
1362
  var GenuiCatalogResolver = class {
1275
1363
  static {
1276
1364
  __name(this, "GenuiCatalogResolver");
@@ -1289,39 +1377,150 @@ function resolverProviders(resolver) {
1289
1377
  ];
1290
1378
  }
1291
1379
  __name(resolverProviders, "resolverProviders");
1292
- function toolOptions(options, resolver) {
1293
- const { catalog: _catalog, sandbox: _sandbox, ...rest } = options;
1380
+ function mergeSandboxClients(clients) {
1381
+ const merged = {
1382
+ theme: false
1383
+ };
1384
+ for (const client of clients) {
1385
+ const one = client();
1386
+ merged.theme ||= one.theme;
1387
+ if (one.tailwind !== void 0) merged.tailwind ??= one.tailwind;
1388
+ if (one.kit !== void 0) merged.kit ??= one.kit;
1389
+ }
1390
+ return merged;
1391
+ }
1392
+ __name(mergeSandboxClients, "mergeSandboxClients");
1393
+ async function resolveGenui(options) {
1394
+ const { sandbox: asked, channels: askedChannels } = options;
1395
+ (0, import_genui2.assertGenuiChannels)(askedChannels);
1396
+ const clients = [];
1397
+ let discovery;
1398
+ const resolveSandbox = /* @__PURE__ */ __name(async (value) => {
1399
+ if (value === void 0 || value === false) return value;
1400
+ const [{ nestSandboxKitDiscovery: nestSandboxKitDiscovery2 }, { resolveSandboxServer }] = await Promise.all([
1401
+ Promise.resolve().then(() => (init_kit(), kit_exports)),
1402
+ import("@dudousxd/nestjs-agent-core/genui/kit")
1403
+ ]);
1404
+ discovery ??= nestSandboxKitDiscovery2(options.sandboxKit);
1405
+ const resolved = resolveSandboxServer(value, discovery);
1406
+ clients.push(resolved.client);
1407
+ return resolved.define;
1408
+ }, "resolveSandbox");
1409
+ const sandbox = await resolveSandbox(asked);
1410
+ const own = options.catalog?.components.find((each) => (0, import_genui2.sandboxPolicyOf)(each) !== void 0);
1411
+ const ownOptions = asked === void 0 && own?.sandboxOptions !== void 0 && (own.sandboxView?.kit === true || own.sandboxView?.tailwind === true) ? await resolveSandbox({
1412
+ ...own.sandboxOptions,
1413
+ name: own.name
1414
+ }) : void 0;
1415
+ let channels;
1416
+ if (askedChannels !== void 0) {
1417
+ channels = {};
1418
+ for (const [name, entry] of Object.entries(askedChannels)) {
1419
+ if (entry === void 0) continue;
1420
+ const own2 = await resolveSandbox(entry.sandbox);
1421
+ channels[name] = {
1422
+ ...entry,
1423
+ ...own2 !== void 0 ? {
1424
+ sandbox: own2
1425
+ } : {}
1426
+ };
1427
+ }
1428
+ }
1429
+ return {
1430
+ ...sandbox !== void 0 ? {
1431
+ sandbox
1432
+ } : {},
1433
+ ...typeof ownOptions === "object" ? {
1434
+ catalogSandbox: ownOptions
1435
+ } : {},
1436
+ ...channels !== void 0 ? {
1437
+ channels
1438
+ } : {},
1439
+ ...clients.length > 0 ? {
1440
+ sandboxClient: /* @__PURE__ */ __name(() => mergeSandboxClients(clients), "sandboxClient")
1441
+ } : {}
1442
+ };
1443
+ }
1444
+ __name(resolveGenui, "resolveGenui");
1445
+ function perRequest(resolver) {
1446
+ return resolver === void 0 ? void 0 : (scope) => resolver.resolve(scope);
1447
+ }
1448
+ __name(perRequest, "perRequest");
1449
+ function toolOptions(options, resolved, resolver) {
1450
+ const { catalog: _catalog, sandbox: _sandbox, channels: _channels, sandboxKit: _sandboxKit, ...rest } = options;
1451
+ const resolveCatalog2 = perRequest(resolver);
1294
1452
  return {
1295
1453
  ...rest,
1296
- ...resolver !== void 0 ? {
1297
- resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
1454
+ ...resolved.channels !== void 0 ? {
1455
+ channels: resolved.channels
1456
+ } : {},
1457
+ ...resolved.sandbox !== void 0 ? {
1458
+ sandbox: resolved.sandbox
1459
+ } : {},
1460
+ ...resolveCatalog2 !== void 0 ? {
1461
+ resolveCatalog: resolveCatalog2
1298
1462
  } : {}
1299
1463
  };
1300
1464
  }
1301
1465
  __name(toolOptions, "toolOptions");
1302
- function withSandbox(options) {
1303
- const base = options.catalog ?? (0, import_genui.defineCatalog)([]);
1304
- const { sandbox } = options;
1305
- return sandbox === void 0 || sandbox === false ? base : base.extend([
1306
- (0, import_genui.defineSandbox)(sandbox === true ? {} : sandbox)
1466
+ function withSandbox(options, resolved) {
1467
+ const base = options.catalog ?? (0, import_genui2.defineCatalog)([]);
1468
+ const { sandbox, catalogSandbox } = resolved;
1469
+ if (sandbox === void 0 || sandbox === false) return catalogSandbox !== void 0 ? base.extend([
1470
+ (0, import_genui2.defineSandbox)(catalogSandbox)
1471
+ ]) : base;
1472
+ return base.extend([
1473
+ (0, import_genui2.defineSandbox)(sandbox === true ? {} : sandbox)
1307
1474
  ]);
1308
1475
  }
1309
1476
  __name(withSandbox, "withSandbox");
1310
1477
  function coreProviders(resolver) {
1311
1478
  return [
1312
1479
  {
1313
- provide: GENUI_CATALOG,
1314
- useFactory: /* @__PURE__ */ __name((options) => withSandbox(options), "useFactory"),
1480
+ provide: GENUI_RESOLVED,
1481
+ useFactory: /* @__PURE__ */ __name((options) => resolveGenui(options), "useFactory"),
1315
1482
  inject: [
1316
1483
  GENUI_OPTIONS
1317
1484
  ]
1318
1485
  },
1486
+ {
1487
+ provide: GENUI_CATALOG,
1488
+ useFactory: /* @__PURE__ */ __name((options, resolved) => withSandbox(options, resolved), "useFactory"),
1489
+ inject: [
1490
+ GENUI_OPTIONS,
1491
+ GENUI_RESOLVED
1492
+ ]
1493
+ },
1494
+ {
1495
+ provide: AGENT_GENUI,
1496
+ useFactory: /* @__PURE__ */ __name((options, catalog, resolved, resolverInstance) => new AgentGenui2(catalog, perRequest(resolverInstance), resolved.channels, {
1497
+ ...options.mode !== void 0 ? {
1498
+ mode: options.mode
1499
+ } : {},
1500
+ ...options.streaming !== void 0 ? {
1501
+ streaming: options.streaming
1502
+ } : {},
1503
+ ...resolved.sandbox !== void 0 ? {
1504
+ sandbox: resolved.sandbox
1505
+ } : {}
1506
+ }, resolved.sandboxClient), "useFactory"),
1507
+ inject: [
1508
+ GENUI_OPTIONS,
1509
+ GENUI_CATALOG,
1510
+ GENUI_RESOLVED,
1511
+ {
1512
+ token: GenuiCatalogResolver,
1513
+ optional: true
1514
+ }
1515
+ ]
1516
+ },
1319
1517
  ...resolverProviders(resolver),
1320
1518
  // The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
1321
1519
  // Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
1322
- provideAgentTools((options, catalog, perRequest) => (0, import_genui.genuiTools)(catalog, toolOptions(options, perRequest)), [
1520
+ provideAgentTools((options, catalog, resolved, perRequestResolver) => (0, import_genui2.genuiTools)(catalog, toolOptions(options, resolved, perRequestResolver)), [
1323
1521
  GENUI_OPTIONS,
1324
1522
  GENUI_CATALOG,
1523
+ GENUI_RESOLVED,
1325
1524
  {
1326
1525
  token: GenuiCatalogResolver,
1327
1526
  optional: true
@@ -1332,7 +1531,8 @@ function coreProviders(resolver) {
1332
1531
  __name(coreProviders, "coreProviders");
1333
1532
  var EXPORTS = [
1334
1533
  GENUI_CATALOG,
1335
- GENUI_OPTIONS
1534
+ GENUI_OPTIONS,
1535
+ AGENT_GENUI
1336
1536
  ];
1337
1537
  var AgentGenuiModule = class _AgentGenuiModule {
1338
1538
  static {
@@ -1429,7 +1629,8 @@ var AgentDepsFactory2 = class {
1429
1629
  memory;
1430
1630
  uiCatalog;
1431
1631
  uiCatalogResolver;
1432
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
1632
+ genui;
1633
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver, genui) {
1433
1634
  this.options = options;
1434
1635
  this.model = model;
1435
1636
  this.store = store;
@@ -1443,6 +1644,7 @@ var AgentDepsFactory2 = class {
1443
1644
  this.memory = memory;
1444
1645
  this.uiCatalog = uiCatalog;
1445
1646
  this.uiCatalogResolver = uiCatalogResolver;
1647
+ this.genui = genui;
1446
1648
  if (options.actionApprovalMode === "independent") (0, import_nestjs_agent_core9.assertIndependentActionCapabilities)(store, options.backgroundActorResolver);
1447
1649
  }
1448
1650
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
@@ -1544,6 +1746,30 @@ var AgentDepsFactory2 = class {
1544
1746
  }
1545
1747
  return deps;
1546
1748
  }
1749
+ /** The turn's UI catalog: the per-request resolver's, else the app's. */
1750
+ resolveUiCatalog = /* @__PURE__ */ __name((scope) => {
1751
+ const catalog = this.uiCatalogResolver?.resolve({
1752
+ ...scope,
1753
+ ...scope.actor.tenantRef !== void 0 ? {
1754
+ tenant: scope.actor.tenantRef
1755
+ } : {}
1756
+ }) ?? this.uiCatalog;
1757
+ if (!catalog) throw new Error("UI catalog unavailable");
1758
+ return catalog;
1759
+ }, "resolveUiCatalog");
1760
+ #uiChannelGuide;
1761
+ /** genui `channels`: what the model is told per channel. Built once; `undefined` without channels. */
1762
+ uiChannelGuide() {
1763
+ if (this.#uiChannelGuide === void 0) {
1764
+ const channels = this.genui?.channels;
1765
+ this.#uiChannelGuide = channels === void 0 || this.uiCatalog === void 0 && this.uiCatalogResolver === void 0 ? null : (0, import_nestjs_agent_core9.createToolUiChannelGuide)({
1766
+ channels,
1767
+ base: this.genui?.base ?? {},
1768
+ resolveCatalog: this.resolveUiCatalog
1769
+ });
1770
+ }
1771
+ return this.#uiChannelGuide ?? void 0;
1772
+ }
1547
1773
  forAgent(agentName) {
1548
1774
  const name = agentName ?? this.defaultAgentName();
1549
1775
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -1559,6 +1785,7 @@ var AgentDepsFactory2 = class {
1559
1785
  const retrieval = this.options.retrieval;
1560
1786
  const historyPolicy = this.historyPolicy(definition);
1561
1787
  const ask = definition?.ask ?? this.options.ask;
1788
+ const uiChannelGuide = this.uiChannelGuide();
1562
1789
  return {
1563
1790
  model: this.model,
1564
1791
  store: this.store,
@@ -1572,16 +1799,10 @@ var AgentDepsFactory2 = class {
1572
1799
  } : {},
1573
1800
  registry: this.registry,
1574
1801
  ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
1575
- resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
1576
- const catalog = this.uiCatalogResolver?.resolve({
1577
- ...scope,
1578
- ...scope.actor.tenantRef !== void 0 ? {
1579
- tenant: scope.actor.tenantRef
1580
- } : {}
1581
- }) ?? this.uiCatalog;
1582
- if (!catalog) throw new Error("UI catalog unavailable");
1583
- return catalog;
1584
- }, "resolveUiCatalog")
1802
+ resolveUiCatalog: this.resolveUiCatalog
1803
+ } : {},
1804
+ ...uiChannelGuide !== void 0 ? {
1805
+ uiChannelGuide
1585
1806
  } : {},
1586
1807
  promptContributors: this.promptContributors,
1587
1808
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
@@ -1664,7 +1885,7 @@ var AgentDepsFactory2 = class {
1664
1885
  id: persona.id,
1665
1886
  label: persona.label
1666
1887
  };
1667
- const resolve = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
1888
+ const resolve2 = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
1668
1889
  const own = persona.systemPrompt;
1669
1890
  const systemPrompt = /* @__PURE__ */ __name(async (ctx) => {
1670
1891
  const scoped = {
@@ -1672,10 +1893,10 @@ var AgentDepsFactory2 = class {
1672
1893
  persona: ref
1673
1894
  };
1674
1895
  if (own === void 0) {
1675
- return resolve(base, scoped);
1896
+ return resolve2(base, scoped);
1676
1897
  }
1677
- const basePrompt = typeof own === "function" ? await resolve(base, scoped) : void 0;
1678
- return resolve(own, {
1898
+ const basePrompt = typeof own === "function" ? await resolve2(base, scoped) : void 0;
1899
+ return resolve2(own, {
1679
1900
  ...scoped,
1680
1901
  ...basePrompt !== void 0 ? {
1681
1902
  basePrompt
@@ -1752,6 +1973,8 @@ AgentDepsFactory2 = _ts_decorate6([
1752
1973
  _ts_param4(11, (0, import_common6.Optional)()),
1753
1974
  _ts_param4(11, (0, import_common6.Inject)(GENUI_CATALOG)),
1754
1975
  _ts_param4(12, (0, import_common6.Optional)()),
1976
+ _ts_param4(13, (0, import_common6.Optional)()),
1977
+ _ts_param4(13, (0, import_common6.Inject)(AGENT_GENUI)),
1755
1978
  _ts_metadata4("design:type", Function),
1756
1979
  _ts_metadata4("design:paramtypes", [
1757
1980
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -1766,7 +1989,8 @@ AgentDepsFactory2 = _ts_decorate6([
1766
1989
  Object,
1767
1990
  Object,
1768
1991
  typeof Catalog === "undefined" ? Object : Catalog,
1769
- typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
1992
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver,
1993
+ typeof AgentGenui === "undefined" ? Object : AgentGenui
1770
1994
  ])
1771
1995
  ], AgentDepsFactory2);
1772
1996
 
@@ -2574,8 +2798,16 @@ function sendableParams(params) {
2574
2798
  message: "nothing to answer: send a non-empty message, an attachment, or regenerate"
2575
2799
  });
2576
2800
  }
2577
- return text === message ? params : {
2578
- ...params,
2801
+ const { channel, ...rest } = params;
2802
+ const stamped = channel === void 0 ? params : {
2803
+ ...rest,
2804
+ pageContext: {
2805
+ ...params.pageContext,
2806
+ channel
2807
+ }
2808
+ };
2809
+ return text === message ? stamped : {
2810
+ ...stamped,
2579
2811
  message: text
2580
2812
  };
2581
2813
  }
@@ -4092,7 +4324,7 @@ AttachmentsController = _ts_decorate12([
4092
4324
 
4093
4325
  // src/controller/chat.controller.ts
4094
4326
  var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
4095
- var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
4327
+ var import_genui3 = require("@dudousxd/nestjs-agent-core/genui");
4096
4328
  var import_common14 = require("@nestjs/common");
4097
4329
  function _ts_decorate13(decorators, target, key, desc) {
4098
4330
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4182,7 +4414,7 @@ var ChatController = class {
4182
4414
  const mode = sendMode(body);
4183
4415
  let uiCapabilities;
4184
4416
  try {
4185
- uiCapabilities = body.uiCapabilities === void 0 ? void 0 : (0, import_genui2.validateUiCapabilities)(body.uiCapabilities);
4417
+ uiCapabilities = body.uiCapabilities === void 0 ? void 0 : (0, import_genui3.validateUiCapabilities)(body.uiCapabilities);
4186
4418
  } catch {
4187
4419
  throw new import_common14.BadRequestException("Invalid UI capabilities");
4188
4420
  }
@@ -4497,11 +4729,13 @@ var ConfigController = class {
4497
4729
  actorResolver;
4498
4730
  staging;
4499
4731
  models;
4500
- constructor(options, actorResolver, staging, models) {
4732
+ genui;
4733
+ constructor(options, actorResolver, staging, models, genui) {
4501
4734
  this.options = options;
4502
4735
  this.actorResolver = actorResolver;
4503
4736
  this.staging = staging;
4504
4737
  this.models = models;
4738
+ this.genui = genui;
4505
4739
  }
4506
4740
  async config(req) {
4507
4741
  await this.actorResolver.resolve(req);
@@ -4515,7 +4749,12 @@ var ConfigController = class {
4515
4749
  },
4516
4750
  identity: {
4517
4751
  anonymous: this.actorResolver instanceof AnonymousActorResolver
4518
- }
4752
+ },
4753
+ ...this.genui?.sandboxClient !== void 0 ? {
4754
+ genui: {
4755
+ sandbox: this.genui.sandboxClient()
4756
+ }
4757
+ } : {}
4519
4758
  };
4520
4759
  }
4521
4760
  };
@@ -4536,11 +4775,14 @@ ConfigController = _ts_decorate14([
4536
4775
  _ts_param12(2, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_ATTACHMENT_STAGING)),
4537
4776
  _ts_param12(3, (0, import_common15.Optional)()),
4538
4777
  _ts_param12(3, (0, import_common15.Inject)(import_nestjs_agent_core20.AGENT_MODEL_CATALOG)),
4778
+ _ts_param12(4, (0, import_common15.Optional)()),
4779
+ _ts_param12(4, (0, import_common15.Inject)(AGENT_GENUI)),
4539
4780
  _ts_metadata12("design:type", Function),
4540
4781
  _ts_metadata12("design:paramtypes", [
4541
4782
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
4542
4783
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4543
4784
  Object,
4785
+ Object,
4544
4786
  Object
4545
4787
  ])
4546
4788
  ], ConfigController);
@@ -6824,12 +7066,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
6824
7066
  }
6825
7067
  const key = `${runId}:${toolCallId2}`;
6826
7068
  let timer;
6827
- const lapse = new Promise((resolve) => {
7069
+ const lapse = new Promise((resolve2) => {
6828
7070
  timer = setTimeout(() => {
6829
7071
  const entry = this.pending.get(key);
6830
7072
  if (entry !== void 0) {
6831
7073
  this.pending.delete(key);
6832
- resolve({
7074
+ resolve2({
6833
7075
  approved: false,
6834
7076
  expired: true
6835
7077
  });
@@ -6843,9 +7085,9 @@ var InlineAgentRunner = class _InlineAgentRunner {
6843
7085
  ]).finally(() => clearTimeout(timer));
6844
7086
  }
6845
7087
  park(runId, toolCallId2) {
6846
- return new Promise((resolve, reject) => {
7088
+ return new Promise((resolve2, reject) => {
6847
7089
  this.pending.set(`${runId}:${toolCallId2}`, {
6848
- resolve,
7090
+ resolve: resolve2,
6849
7091
  reject
6850
7092
  });
6851
7093
  });