avantgate 1.1.1 → 1.2.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 (94) hide show
  1. package/README.md +15 -398
  2. package/dist/agent/adapters/custom-adapter.d.ts +50 -0
  3. package/dist/agent/adapters/custom-adapter.d.ts.map +1 -0
  4. package/dist/agent/adapters/index.d.ts +6 -0
  5. package/dist/agent/adapters/index.d.ts.map +1 -0
  6. package/dist/agent/adapters/memory-adapter.d.ts +34 -0
  7. package/dist/agent/adapters/memory-adapter.d.ts.map +1 -0
  8. package/dist/agent/adapters/platform-adapter.d.ts +32 -0
  9. package/dist/agent/adapters/platform-adapter.d.ts.map +1 -0
  10. package/dist/agent/adapters/prisma-adapter.d.ts +55 -0
  11. package/dist/agent/adapters/prisma-adapter.d.ts.map +1 -0
  12. package/dist/agent/adapters/sqlite-adapter.d.ts +31 -0
  13. package/dist/agent/adapters/sqlite-adapter.d.ts.map +1 -0
  14. package/dist/agent/dto.d.ts +32 -0
  15. package/dist/agent/dto.d.ts.map +1 -0
  16. package/dist/agent/errors.d.ts +50 -0
  17. package/dist/agent/errors.d.ts.map +1 -0
  18. package/dist/agent/factory.d.ts +21 -0
  19. package/dist/agent/factory.d.ts.map +1 -0
  20. package/dist/agent/guardrails.d.ts +14 -0
  21. package/dist/agent/guardrails.d.ts.map +1 -0
  22. package/dist/agent/index.d.ts +17 -703
  23. package/dist/agent/index.d.ts.map +1 -0
  24. package/dist/agent/index.js +294 -30
  25. package/dist/agent/index.mjs +290 -29
  26. package/dist/agent/isolated-tool.d.ts +9 -0
  27. package/dist/agent/isolated-tool.d.ts.map +1 -0
  28. package/dist/agent/registry.d.ts +71 -0
  29. package/dist/agent/registry.d.ts.map +1 -0
  30. package/dist/agent/step-runner.d.ts +12 -0
  31. package/dist/agent/step-runner.d.ts.map +1 -0
  32. package/dist/agent/strategy.d.ts +37 -0
  33. package/dist/agent/strategy.d.ts.map +1 -0
  34. package/dist/agent/telemetry/http-exporter.d.ts +24 -0
  35. package/dist/agent/telemetry/http-exporter.d.ts.map +1 -0
  36. package/dist/agent/telemetry/index.d.ts +3 -0
  37. package/dist/agent/telemetry/index.d.ts.map +1 -0
  38. package/dist/agent/telemetry/types.d.ts +92 -0
  39. package/dist/agent/telemetry/types.d.ts.map +1 -0
  40. package/dist/agent/tool-invoker.d.ts +17 -0
  41. package/dist/agent/tool-invoker.d.ts.map +1 -0
  42. package/dist/agent/tool-state.d.ts +7 -0
  43. package/dist/agent/tool-state.d.ts.map +1 -0
  44. package/dist/agent/types.d.ts +243 -0
  45. package/dist/agent/types.d.ts.map +1 -0
  46. package/dist/control-layer.d.ts +49 -0
  47. package/dist/control-layer.d.ts.map +1 -0
  48. package/dist/finance/factory.d.ts +11 -0
  49. package/dist/finance/factory.d.ts.map +1 -0
  50. package/dist/finance/index.d.ts +9 -76
  51. package/dist/finance/index.d.ts.map +1 -0
  52. package/dist/finance/normalizer.d.ts +19 -0
  53. package/dist/finance/normalizer.d.ts.map +1 -0
  54. package/dist/finance/strategies/french-pcg.strategy.d.ts +10 -0
  55. package/dist/finance/strategies/french-pcg.strategy.d.ts.map +1 -0
  56. package/dist/finance/strategies/international.strategy.d.ts +10 -0
  57. package/dist/finance/strategies/international.strategy.d.ts.map +1 -0
  58. package/dist/finance/strategies/swiss-co.strategy.d.ts +10 -0
  59. package/dist/finance/strategies/swiss-co.strategy.d.ts.map +1 -0
  60. package/dist/finance/strategies/uk-ifrs.strategy.d.ts +10 -0
  61. package/dist/finance/strategies/uk-ifrs.strategy.d.ts.map +1 -0
  62. package/dist/finance/strategies/us-gaap.strategy.d.ts +10 -0
  63. package/dist/finance/strategies/us-gaap.strategy.d.ts.map +1 -0
  64. package/dist/{strategy.interface-CB4_ZAuk.d.ts → finance/strategy.interface.d.ts} +5 -6
  65. package/dist/finance/strategy.interface.d.ts.map +1 -0
  66. package/dist/index.d.ts +9 -390
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/input-guard.d.ts +13 -0
  69. package/dist/input-guard.d.ts.map +1 -0
  70. package/dist/pricing.d.ts +49 -0
  71. package/dist/pricing.d.ts.map +1 -0
  72. package/dist/prompts/index.d.ts +5 -0
  73. package/dist/prompts/index.d.ts.map +1 -0
  74. package/dist/prompts/prompt-builder.d.ts +31 -0
  75. package/dist/prompts/prompt-builder.d.ts.map +1 -0
  76. package/dist/prompts/prompt-registry.d.ts +13 -0
  77. package/dist/prompts/prompt-registry.d.ts.map +1 -0
  78. package/dist/prompts/prompt-template.d.ts +17 -0
  79. package/dist/prompts/prompt-template.d.ts.map +1 -0
  80. package/dist/prompts/types.d.ts +39 -0
  81. package/dist/prompts/types.d.ts.map +1 -0
  82. package/dist/providers/http-client.d.ts +18 -0
  83. package/dist/providers/http-client.d.ts.map +1 -0
  84. package/dist/response-validator.d.ts +18 -0
  85. package/dist/response-validator.d.ts.map +1 -0
  86. package/dist/sanitizer.d.ts +11 -0
  87. package/dist/sanitizer.d.ts.map +1 -0
  88. package/dist/types.d.ts +146 -0
  89. package/dist/types.d.ts.map +1 -0
  90. package/package.json +3 -3
  91. package/dist/agent/index.d.mts +0 -704
  92. package/dist/finance/index.d.mts +0 -76
  93. package/dist/index.d.mts +0 -390
  94. package/dist/strategy.interface-CB4_ZAuk.d.mts +0 -16
@@ -40,12 +40,19 @@ var StepExecutionError = class extends Error {
40
40
  var ToolAccessDeniedError = class extends Error {
41
41
  toolName;
42
42
  requiredRole;
43
- constructor(toolName, requiredRole) {
44
- const roleMsg = requiredRole ? ` (requires role "${requiredRole}")` : "";
45
- super(`Access denied for tool "${toolName}"${roleMsg}.`);
43
+ reason;
44
+ constructor(toolName, reasonOrRole) {
45
+ const isRole = Boolean(reasonOrRole && !reasonOrRole.includes(" "));
46
+ const roleMsg = isRole ? ` (requires role "${reasonOrRole}")` : "";
47
+ const reasonMsg = reasonOrRole && !isRole ? `: ${reasonOrRole}` : "";
48
+ super(`Access denied for tool "${toolName}"${roleMsg}${reasonMsg}.`);
46
49
  this.name = "ToolAccessDeniedError";
47
50
  this.toolName = toolName;
48
- this.requiredRole = requiredRole;
51
+ if (isRole) {
52
+ this.requiredRole = reasonOrRole;
53
+ } else {
54
+ this.reason = reasonOrRole;
55
+ }
49
56
  }
50
57
  };
51
58
  var CircularToolCallError = class extends Error {
@@ -84,6 +91,16 @@ var ToolNotFoundError = class extends Error {
84
91
  this.toolId = toolId;
85
92
  }
86
93
  };
94
+ var DtoValidationError = class extends Error {
95
+ toolName;
96
+ issues;
97
+ constructor(toolName, message, issues = []) {
98
+ super(`LLM DTO validation failed for tool "${toolName}": ${message}`);
99
+ this.name = "DtoValidationError";
100
+ this.toolName = toolName;
101
+ this.issues = issues;
102
+ }
103
+ };
87
104
 
88
105
  // src/agent/guardrails.ts
89
106
  function sanitizeString(value) {
@@ -138,18 +155,50 @@ function auditToolResult(data, options) {
138
155
  }
139
156
 
140
157
  // src/agent/isolated-tool.ts
158
+ async function verifyDataAccessGuard(guard, args, context, toolIdentifier) {
159
+ if (!guard) {
160
+ return;
161
+ }
162
+ const isAllowed = await guard(args, context);
163
+ if (!isAllowed) {
164
+ throw new ToolAccessDeniedError(toolIdentifier, "Access denied by data access guard");
165
+ }
166
+ }
167
+ async function resolveInvalidationTags(config, args, rawResult, context) {
168
+ if (!config.invalidationTags) {
169
+ return void 0;
170
+ }
171
+ const tags = typeof config.invalidationTags === "function" ? await config.invalidationTags(args, rawResult) : config.invalidationTags;
172
+ if (tags && tags.length > 0 && context?.onInvalidationTags) {
173
+ await context.onInvalidationTags(tags);
174
+ }
175
+ return tags;
176
+ }
141
177
  async function dispatchClientData(rawResult, callback) {
142
178
  if (!callback) {
143
179
  return;
144
180
  }
145
181
  await callback(rawResult);
146
182
  }
147
- function produceLlmPayload(rawResult, args, transformer) {
183
+ async function produceLlmPayload(rawResult, args, context, transformer) {
148
184
  if (transformer) {
149
- return transformer(rawResult, args);
185
+ return await transformer(rawResult, args, context);
150
186
  }
151
187
  return rawResult;
152
188
  }
189
+ function validateLlmDto(payload, schema, toolIdentifier) {
190
+ const parseResult = schema.safeParse(payload);
191
+ if (!parseResult.success) {
192
+ const issues = parseResult.error.issues ?? [];
193
+ const errorMessages = issues.map((issue) => `${issue.path.join(".") || "root"}: ${issue.message}`).join(", ");
194
+ throw new DtoValidationError(
195
+ toolIdentifier,
196
+ errorMessages,
197
+ issues
198
+ );
199
+ }
200
+ return parseResult.data;
201
+ }
153
202
  function protectLlmPayload(payload, toolIdentifier, sanitizePii = true, throwOnPii = false) {
154
203
  if (!sanitizePii) {
155
204
  return { sanitized: payload, count: 0 };
@@ -160,9 +209,23 @@ function protectLlmPayload(payload, toolIdentifier, sanitizePii = true, throwOnP
160
209
  });
161
210
  return { sanitized: sanitizedData, count: maskedCount };
162
211
  }
212
+ async function processLlmPayload(rawResult, args, context, config, toolIdentifier) {
213
+ let payload = await produceLlmPayload(rawResult, args, context, config.llmDto);
214
+ if (config.llmDtoSchema) {
215
+ payload = validateLlmDto(payload, config.llmDtoSchema, toolIdentifier);
216
+ }
217
+ return protectLlmPayload(
218
+ payload,
219
+ toolIdentifier,
220
+ config.sanitizePii !== false,
221
+ config.throwOnPii === true
222
+ );
223
+ }
163
224
  function createIsolatedTool(config) {
164
225
  const toolId = config.id || config.name;
165
226
  const toolAlias = config.alias;
227
+ const clientCallback = config.clientDto;
228
+ const toolIdentifier = toolAlias || config.name;
166
229
  const tool = {
167
230
  description: config.description,
168
231
  parameters: config.parameters,
@@ -171,24 +234,41 @@ function createIsolatedTool(config) {
171
234
  _toolAlias: toolAlias,
172
235
  _isIsolated: true,
173
236
  _cacheTTL: config.cacheTTL,
237
+ _domain: config.domain,
238
+ _resource: config.resource,
239
+ _roles: config.roles ? Object.freeze([...config.roles]) : void 0,
240
+ _permissions: config.permissions ? Object.freeze([...config.permissions]) : void 0,
241
+ _requireApproval: config.requireApproval ?? false,
174
242
  _lastPiiFilteredCount: 0,
243
+ _lastInvalidationTags: void 0,
175
244
  async execute(args, context) {
176
245
  const updatedContext = {
177
246
  ...context,
178
247
  callChain: context?.callChain ?? Object.freeze([toolId])
179
248
  };
249
+ await verifyDataAccessGuard(
250
+ config.dataAccessGuard,
251
+ args,
252
+ updatedContext,
253
+ toolIdentifier
254
+ );
180
255
  const rawResult = await config.execute(args, updatedContext);
181
- await dispatchClientData(rawResult, config.toClientData);
182
- const llmPayload = produceLlmPayload(
183
- rawResult,
256
+ const tags = await resolveInvalidationTags(
257
+ config,
184
258
  args,
185
- config.toLLMSummary
259
+ rawResult,
260
+ updatedContext
186
261
  );
187
- const protection = protectLlmPayload(
188
- llmPayload,
189
- toolAlias || config.name,
190
- config.sanitizePii !== false,
191
- config.throwOnPii === true
262
+ if (tags) {
263
+ tool._lastInvalidationTags = tags;
264
+ }
265
+ await dispatchClientData(rawResult, clientCallback);
266
+ const protection = await processLlmPayload(
267
+ rawResult,
268
+ args,
269
+ updatedContext,
270
+ config,
271
+ toolIdentifier
192
272
  );
193
273
  tool._lastPiiFilteredCount = protection.count;
194
274
  return protection.sanitized;
@@ -197,6 +277,49 @@ function createIsolatedTool(config) {
197
277
  return tool;
198
278
  }
199
279
 
280
+ // src/agent/dto.ts
281
+ var dto = {
282
+ /**
283
+ * Generates a boolean acknowledgment for mutations ({ success: true | false }).
284
+ * If rawResult contains a boolean `success` property, it is preserved; otherwise defaults to true.
285
+ */
286
+ boolean: () => (data) => ({
287
+ success: typeof data?.success === "boolean" ? data.success : true
288
+ }),
289
+ /**
290
+ * Generates a boolean acknowledgment preserving an opaque technical identifier for tool chaining.
291
+ */
292
+ booleanWithId: (idKey = "id") => (data) => ({
293
+ success: typeof data?.success === "boolean" ? data.success : true,
294
+ [idKey]: data?.[idKey]
295
+ }),
296
+ /**
297
+ * Extracts a numeric count from a list or nested array property without exposing items to the LLM.
298
+ */
299
+ count: (arrayKey) => (data) => {
300
+ const list = arrayKey ? data?.[arrayKey] : data;
301
+ return {
302
+ success: true,
303
+ count: Array.isArray(list) ? list.length : 0
304
+ };
305
+ },
306
+ /**
307
+ * Filters raw output by extracting only a strict whitelist of allowed fields.
308
+ */
309
+ pick: (keys) => (data) => {
310
+ const result = {};
311
+ if (!data || typeof data !== "object") {
312
+ return result;
313
+ }
314
+ for (const key of keys) {
315
+ if (key in data) {
316
+ result[key] = data[key];
317
+ }
318
+ }
319
+ return result;
320
+ }
321
+ };
322
+
200
323
  // src/agent/factory.ts
201
324
  var AgentToolFactory = class _AgentToolFactory {
202
325
  context;
@@ -228,6 +351,65 @@ var AgentToolFactory = class _AgentToolFactory {
228
351
  };
229
352
 
230
353
  // src/agent/registry.ts
354
+ function isCoreTool(item) {
355
+ return typeof item.execute === "function" && "_toolId" in item;
356
+ }
357
+ function normalizeToolDefinition(toolDef) {
358
+ if (isCoreTool(toolDef)) {
359
+ return {
360
+ id: toolDef._toolId || toolDef._toolName,
361
+ name: toolDef._toolName,
362
+ alias: toolDef._toolAlias,
363
+ description: toolDef.description,
364
+ domain: toolDef._domain,
365
+ resource: toolDef._resource,
366
+ roles: toolDef._roles ? Array.from(toolDef._roles) : void 0,
367
+ permissions: toolDef._permissions ? Array.from(toolDef._permissions) : void 0,
368
+ requireApproval: toolDef._requireApproval,
369
+ tool: toolDef
370
+ };
371
+ }
372
+ const id = toolDef.id || toolDef.name || toolDef.tool?._toolId;
373
+ const publicName = toolDef.alias || toolDef.name || toolDef.tool?._toolAlias || toolDef.tool?._toolName;
374
+ const roles = toolDef.roles ?? (toolDef.tool?._roles ? Array.from(toolDef.tool._roles) : toolDef.requiredRoles);
375
+ const permissions = toolDef.permissions ?? (toolDef.tool?._permissions ? Array.from(toolDef.tool._permissions) : void 0);
376
+ return {
377
+ ...toolDef,
378
+ id,
379
+ name: toolDef.name || toolDef.tool?._toolName || id,
380
+ alias: publicName,
381
+ domain: toolDef.domain ?? toolDef.tool?._domain,
382
+ resource: toolDef.resource ?? toolDef.tool?._resource,
383
+ roles,
384
+ permissions,
385
+ requireApproval: toolDef.requireApproval ?? toolDef.tool?._requireApproval
386
+ };
387
+ }
388
+ function matchesRoleFilter(tool, role) {
389
+ if (!role) {
390
+ return true;
391
+ }
392
+ const roles = tool.roles ?? tool.requiredRoles;
393
+ if (!roles || roles.length === 0) {
394
+ return true;
395
+ }
396
+ return roles.includes(role);
397
+ }
398
+ function toDescriptor(tool) {
399
+ return {
400
+ id: tool.id,
401
+ name: tool.name,
402
+ alias: tool.alias,
403
+ description: tool.description,
404
+ domain: tool.domain,
405
+ resource: tool.resource,
406
+ roles: tool.roles ?? tool.requiredRoles,
407
+ permissions: tool.permissions,
408
+ requireApproval: tool.requireApproval,
409
+ cacheTTL: tool.tool._cacheTTL,
410
+ tags: tool.tags
411
+ };
412
+ }
231
413
  var ToolRegistry = class _ToolRegistry {
232
414
  toolsById = /* @__PURE__ */ new Map();
233
415
  toolsByPublicName = /* @__PURE__ */ new Map();
@@ -235,16 +417,21 @@ var ToolRegistry = class _ToolRegistry {
235
417
  * Registers a new tool in the registry.
236
418
  */
237
419
  register(toolDef) {
238
- const id = toolDef.id || toolDef.name;
239
- const publicName = toolDef.alias || toolDef.name;
240
- const normalizedDef = {
241
- ...toolDef,
242
- id
243
- };
244
- this.toolsById.set(id, normalizedDef);
420
+ const normalizedDef = normalizeToolDefinition(toolDef);
421
+ const publicName = normalizedDef.alias || normalizedDef.name;
422
+ this.toolsById.set(normalizedDef.id, normalizedDef);
245
423
  this.toolsByPublicName.set(publicName, normalizedDef);
246
424
  return this;
247
425
  }
426
+ /**
427
+ * Registers multiple tools in batch.
428
+ */
429
+ registerMany(tools) {
430
+ for (const tool of tools) {
431
+ this.register(tool);
432
+ }
433
+ return this;
434
+ }
248
435
  /**
249
436
  * Retrieves a tool by its ID or public name/alias.
250
437
  */
@@ -275,6 +462,12 @@ var ToolRegistry = class _ToolRegistry {
275
462
  getAll() {
276
463
  return Array.from(this.toolsById.values());
277
464
  }
465
+ /**
466
+ * Filters tools belonging to a specific business domain.
467
+ */
468
+ getByDomain(domain) {
469
+ return this.getAll().filter((item) => item.domain === domain);
470
+ }
278
471
  /**
279
472
  * Filters tools matching a specific workflow phase.
280
473
  */
@@ -292,12 +485,26 @@ var ToolRegistry = class _ToolRegistry {
292
485
  filterByRoles(userRoles) {
293
486
  const roleSet = new Set(userRoles);
294
487
  return this.getAll().filter((item) => {
295
- if (!item.requiredRoles || item.requiredRoles.length === 0) {
488
+ const roles = item.roles ?? item.requiredRoles;
489
+ if (!roles || roles.length === 0) {
296
490
  return true;
297
491
  }
298
- return item.requiredRoles.some((role) => roleSet.has(role));
492
+ return roles.some((role) => roleSet.has(role));
299
493
  });
300
494
  }
495
+ /**
496
+ * Exports headless technical descriptors without UI rendering coupling.
497
+ */
498
+ getDescriptors(filter) {
499
+ let list = this.getAll();
500
+ if (filter?.domain) {
501
+ list = list.filter((item) => item.domain === filter.domain);
502
+ }
503
+ if (filter?.role) {
504
+ list = list.filter((item) => matchesRoleFilter(item, filter.role));
505
+ }
506
+ return list.map(toDescriptor);
507
+ }
301
508
  /**
302
509
  * Converts instance registered tools to the record map format required by Vercel AI SDK.
303
510
  */
@@ -309,8 +516,12 @@ var ToolRegistry = class _ToolRegistry {
309
516
  * If anonymize is true, uses alias (if defined) as dictionary key instead of technical name.
310
517
  */
311
518
  static toRecord(tools, options = {}) {
519
+ let filtered = tools;
520
+ if (options.domain) {
521
+ filtered = filtered.filter((item) => item.domain === options.domain);
522
+ }
312
523
  const record = {};
313
- for (const item of tools) {
524
+ for (const item of filtered) {
314
525
  const key = options.anonymize && item.alias ? item.alias : item.name;
315
526
  record[key] = item.tool;
316
527
  }
@@ -336,17 +547,64 @@ var PhaseBasedToolStrategy = class {
336
547
  var RoleBasedToolStrategy = class {
337
548
  selectTools(tools, context) {
338
549
  if (!context.role) {
339
- return tools.filter((t) => !t.requiredRoles || t.requiredRoles.length === 0);
550
+ return tools.filter((toolCandidate) => {
551
+ const roles = toolCandidate.roles ?? toolCandidate.requiredRoles;
552
+ return !roles || roles.length === 0;
553
+ });
340
554
  }
341
555
  const currentRole = context.role;
342
556
  return tools.filter((item) => {
343
- if (!item.requiredRoles || item.requiredRoles.length === 0) {
557
+ const roles = item.roles ?? item.requiredRoles;
558
+ if (!roles || roles.length === 0) {
344
559
  return true;
345
560
  }
346
- return item.requiredRoles.includes(currentRole);
561
+ return roles.includes(currentRole);
347
562
  });
348
563
  }
349
564
  };
565
+ function matchesDomain(tool, allowedDomains) {
566
+ if (!allowedDomains) {
567
+ return true;
568
+ }
569
+ return Boolean(tool.domain && allowedDomains.has(tool.domain));
570
+ }
571
+ function matchesRoles(tool, context) {
572
+ const toolRoles = tool.roles ?? tool.requiredRoles;
573
+ if (!toolRoles || toolRoles.length === 0) {
574
+ return true;
575
+ }
576
+ const userRoles = [];
577
+ if (context.role) {
578
+ userRoles.push(context.role);
579
+ }
580
+ if (context.roles) {
581
+ userRoles.push(...context.roles);
582
+ }
583
+ if (userRoles.length === 0) {
584
+ return false;
585
+ }
586
+ return toolRoles.some((roleName) => userRoles.includes(roleName));
587
+ }
588
+ function matchesPermissions(tool, context) {
589
+ if (!tool.permissions || tool.permissions.length === 0) {
590
+ return true;
591
+ }
592
+ const userPermissions = context.permissions ?? [];
593
+ return tool.permissions.every((permissionName) => userPermissions.includes(permissionName));
594
+ }
595
+ var AccessControlToolStrategy = class {
596
+ allowedDomains;
597
+ constructor(options) {
598
+ if (options?.allowedDomains) {
599
+ this.allowedDomains = new Set(options.allowedDomains);
600
+ }
601
+ }
602
+ selectTools(tools, context) {
603
+ return tools.filter(
604
+ (tool) => matchesDomain(tool, this.allowedDomains) && matchesRoles(tool, context) && matchesPermissions(tool, context)
605
+ );
606
+ }
607
+ };
350
608
  var CompositeToolStrategy = class {
351
609
  strategies;
352
610
  constructor(strategies) {
@@ -1594,9 +1852,11 @@ var HttpTelemetryExporter = class {
1594
1852
  }
1595
1853
  };
1596
1854
  export {
1855
+ AccessControlToolStrategy,
1597
1856
  AgentToolFactory,
1598
1857
  CircularToolCallError,
1599
1858
  CompositeToolStrategy,
1859
+ DtoValidationError,
1600
1860
  HttpTelemetryExporter,
1601
1861
  KeyValueStorageAdapter,
1602
1862
  MemoryStorageAdapter,
@@ -1619,5 +1879,6 @@ export {
1619
1879
  createIsolatedTool,
1620
1880
  createStepRunner,
1621
1881
  createToolInvoker,
1622
- createToolSharedState
1882
+ createToolSharedState,
1883
+ dto
1623
1884
  };
@@ -0,0 +1,9 @@
1
+ import type { IsolatedToolConfig, VercelAiCoreTool } from "./types";
2
+ /**
3
+ * Creates an isolated tool compatible with Vercel AI SDK (ai) tool contract.
4
+ * Features dual-channel separation (client data vs minimal LLM DTO),
5
+ * access governance (domain, resource, roles, dataAccessGuard, invalidationTags),
6
+ * stable ID, aliasing, caching, Zod DTO contract validation, and automatic in-flight PII redaction.
7
+ */
8
+ export declare function createIsolatedTool<TArgs = any, TResult = any, TLLMDto = unknown, TClientDto = TResult>(config: IsolatedToolConfig<TArgs, TResult, TLLMDto, TClientDto>): VercelAiCoreTool<TArgs, TResult>;
9
+ //# sourceMappingURL=isolated-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isolated-tool.d.ts","sourceRoot":"","sources":["../../src/agent/isolated-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAElB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAoHjB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,GAAG,GAAG,EACX,OAAO,GAAG,GAAG,EACb,OAAO,GAAG,OAAO,EACjB,UAAU,GAAG,OAAO,EAEpB,MAAM,EAAE,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,GAC9D,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CA8DlC"}
@@ -0,0 +1,71 @@
1
+ import type { RegisteredTool, ToolDescriptor, VercelAiCoreTool } from "./types";
2
+ export interface ToRecordOptions {
3
+ anonymize?: boolean;
4
+ domain?: string;
5
+ }
6
+ export interface ToolDescriptorFilter {
7
+ domain?: string;
8
+ role?: string;
9
+ }
10
+ /**
11
+ * Centralized catalog for managing and filtering tools with permissions, domains and metadata.
12
+ * Supports O(1) Key-Value lookup by technical ID and by public alias.
13
+ */
14
+ export declare class ToolRegistry {
15
+ private readonly toolsById;
16
+ private readonly toolsByPublicName;
17
+ /**
18
+ * Registers a new tool in the registry.
19
+ */
20
+ register(toolDef: RegisteredTool | VercelAiCoreTool): this;
21
+ /**
22
+ * Registers multiple tools in batch.
23
+ */
24
+ registerMany(tools: (RegisteredTool | VercelAiCoreTool)[]): this;
25
+ /**
26
+ * Retrieves a tool by its ID or public name/alias.
27
+ */
28
+ get(idOrName: string): RegisteredTool | undefined;
29
+ /**
30
+ * Retrieves a tool strictly by its immutable technical ID (O(1)).
31
+ */
32
+ getById(id: string): RegisteredTool | undefined;
33
+ /**
34
+ * Retrieves a tool by its public alias seen by the LLM (O(1)).
35
+ */
36
+ getByPublicName(publicName: string): RegisteredTool | undefined;
37
+ /**
38
+ * Checks if a tool is registered by ID or public name.
39
+ */
40
+ has(idOrName: string): boolean;
41
+ /**
42
+ * Returns all registered tools without duplicates.
43
+ */
44
+ getAll(): RegisteredTool[];
45
+ /**
46
+ * Filters tools belonging to a specific business domain.
47
+ */
48
+ getByDomain(domain: string): RegisteredTool[];
49
+ /**
50
+ * Filters tools matching a specific workflow phase.
51
+ */
52
+ getByPhase(phase: string): RegisteredTool[];
53
+ /**
54
+ * Filters tools matching the user's roles (RBAC).
55
+ */
56
+ filterByRoles(userRoles: string[]): RegisteredTool[];
57
+ /**
58
+ * Exports headless technical descriptors without UI rendering coupling.
59
+ */
60
+ getDescriptors(filter?: ToolDescriptorFilter): ToolDescriptor[];
61
+ /**
62
+ * Converts instance registered tools to the record map format required by Vercel AI SDK.
63
+ */
64
+ toRecord(options?: ToRecordOptions): Record<string, VercelAiCoreTool>;
65
+ /**
66
+ * Converts a list of registered tools to the record map format required by Vercel AI SDK.
67
+ * If anonymize is true, uses alias (if defined) as dictionary key instead of technical name.
68
+ */
69
+ static toRecord(tools: RegisteredTool[], options?: ToRecordOptions): Record<string, VercelAiCoreTool>;
70
+ }
71
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/agent/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAoED;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqC;IAC/D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqC;IAEvE;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,GAAG,IAAI;IASjE;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,CAAC,cAAc,GAAG,gBAAgB,CAAC,EAAE,GAAG,IAAI;IAOvE;;OAEG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIxD;;OAEG;IACI,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAItD;;OAEG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAItE;;OAEG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACI,MAAM,IAAI,cAAc,EAAE;IAIjC;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE;IAIpD;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE;IASlD;;OAEG;IACI,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE;IAW3D;;OAEG;IACI,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,cAAc,EAAE;IAWtE;;OAEG;IACI,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAIhF;;;OAGG;WACW,QAAQ,CACpB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;CAYpC"}
@@ -0,0 +1,12 @@
1
+ import type { StepRunnerConfig, StepRunnerContext, StepStorageAdapter } from "./types";
2
+ export interface StepRunnerInstance extends StepRunnerContext {
3
+ storage: StepStorageAdapter;
4
+ approveStep<T = unknown>(stepId: string, approvalData?: T): Promise<void>;
5
+ rejectStep(stepId: string, reason?: string): Promise<void>;
6
+ }
7
+ /**
8
+ * Creates a serverless durable step runner for stateful multi-step agent execution
9
+ * with automatic idempotence and Human-in-the-Loop approval capability.
10
+ */
11
+ export declare function createStepRunner(config: StepRunnerConfig): StepRunnerInstance;
12
+ //# sourceMappingURL=step-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-runner.d.ts","sourceRoot":"","sources":["../../src/agent/step-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;AAkGD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,kBAAkB,CA0B7E"}
@@ -0,0 +1,37 @@
1
+ import type { RegisteredTool, ToolContext, ToolSelectionStrategy, VercelAiCoreTool } from "./types";
2
+ /**
3
+ * Strategy selecting tools that match the current workflow phase.
4
+ */
5
+ export declare class PhaseBasedToolStrategy implements ToolSelectionStrategy {
6
+ selectTools(tools: RegisteredTool[], context: ToolContext): RegisteredTool[];
7
+ }
8
+ /**
9
+ * Strategy selecting tools permitted for the user's role (RBAC).
10
+ */
11
+ export declare class RoleBasedToolStrategy implements ToolSelectionStrategy {
12
+ selectTools(tools: RegisteredTool[], context: ToolContext): RegisteredTool[];
13
+ }
14
+ export interface AccessControlToolStrategyOptions {
15
+ allowedDomains?: string[];
16
+ }
17
+ /**
18
+ * Unified strategy evaluating role, permissions and allowed business domains in a single pass.
19
+ */
20
+ export declare class AccessControlToolStrategy implements ToolSelectionStrategy {
21
+ private readonly allowedDomains?;
22
+ constructor(options?: AccessControlToolStrategyOptions);
23
+ selectTools(tools: RegisteredTool[], context: ToolContext): RegisteredTool[];
24
+ }
25
+ /**
26
+ * Composite strategy applying multiple selection strategies sequentially (intersection).
27
+ */
28
+ export declare class CompositeToolStrategy implements ToolSelectionStrategy {
29
+ private readonly strategies;
30
+ constructor(strategies: ToolSelectionStrategy[]);
31
+ selectTools(tools: RegisteredTool[], context: ToolContext): Promise<RegisteredTool[]>;
32
+ }
33
+ /**
34
+ * Convenience helper to execute a strategy and convert selected tools to Vercel AI SDK format.
35
+ */
36
+ export declare function applyToolStrategy(tools: RegisteredTool[], strategy: ToolSelectionStrategy, context: ToolContext): Promise<Record<string, VercelAiCoreTool>>;
37
+ //# sourceMappingURL=strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../src/agent/strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,sBAAuB,YAAW,qBAAqB;IAC3D,WAAW,CAChB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,cAAc,EAAE;CAYpB;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,qBAAqB;IAC1D,WAAW,CAChB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,cAAc,EAAE;CAgBpB;AAED,MAAM,WAAW,gCAAgC;IAC/C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAmCD;;GAEG;AACH,qBAAa,yBAA0B,YAAW,qBAAqB;IACrE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAc;gBAElC,OAAO,CAAC,EAAE,gCAAgC;IAM/C,WAAW,CAChB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,cAAc,EAAE;CAQpB;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,qBAAqB;IACjE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0B;gBAEzC,UAAU,EAAE,qBAAqB,EAAE;IAIlC,WAAW,CACtB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC;CAO7B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,cAAc,EAAE,EACvB,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAG3C"}
@@ -0,0 +1,24 @@
1
+ import type { HttpTelemetryExporterOptions, TelemetryEvent, TelemetryUsageSummary } from "./types";
2
+ /**
3
+ * Asynchronous, zero-dependency HTTP Telemetry Exporter for the avantGate platform.
4
+ * Batches events in memory and sends them in background without blocking agent execution.
5
+ */
6
+ export declare class HttpTelemetryExporter {
7
+ private readonly apiKey;
8
+ private readonly endpoint;
9
+ private readonly agentName?;
10
+ private readonly batchIntervalMs;
11
+ private readonly maxBatchSize;
12
+ private readonly maxQueueSize;
13
+ private readonly fetchFn;
14
+ private readonly onError?;
15
+ private queue;
16
+ private timer;
17
+ private isFlushing;
18
+ constructor(options: HttpTelemetryExporterOptions);
19
+ private startTimer;
20
+ enqueue(runId: string, event: TelemetryEvent, usage?: TelemetryUsageSummary): void;
21
+ flush(): Promise<void>;
22
+ shutdown(): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=http-exporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-exporter.d.ts","sourceRoot":"","sources":["../../../src/agent/telemetry/http-exporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,cAAc,EAEd,qBAAqB,EACtB,MAAM,SAAS,CAAC;AA6EjB;;;GAGG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAyB;IAElD,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,4BAA4B;IAajD,OAAO,CAAC,UAAU;IAWX,OAAO,CACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,EACrB,KAAK,CAAC,EAAE,qBAAqB,GAC5B,IAAI;IAWM,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAOvC"}
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export * from "./http-exporter";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/telemetry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}