avantgate 1.1.2 → 1.2.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.
Files changed (94) hide show
  1. package/dist/agent/adapters/custom-adapter.d.ts +50 -0
  2. package/dist/agent/adapters/custom-adapter.d.ts.map +1 -0
  3. package/dist/agent/adapters/index.d.ts +6 -0
  4. package/dist/agent/adapters/index.d.ts.map +1 -0
  5. package/dist/agent/adapters/memory-adapter.d.ts +34 -0
  6. package/dist/agent/adapters/memory-adapter.d.ts.map +1 -0
  7. package/dist/agent/adapters/platform-adapter.d.ts +32 -0
  8. package/dist/agent/adapters/platform-adapter.d.ts.map +1 -0
  9. package/dist/agent/adapters/prisma-adapter.d.ts +55 -0
  10. package/dist/agent/adapters/prisma-adapter.d.ts.map +1 -0
  11. package/dist/agent/adapters/sqlite-adapter.d.ts +31 -0
  12. package/dist/agent/adapters/sqlite-adapter.d.ts.map +1 -0
  13. package/dist/agent/dto.d.ts +58 -0
  14. package/dist/agent/dto.d.ts.map +1 -0
  15. package/dist/agent/errors.d.ts +50 -0
  16. package/dist/agent/errors.d.ts.map +1 -0
  17. package/dist/agent/factory.d.ts +21 -0
  18. package/dist/agent/factory.d.ts.map +1 -0
  19. package/dist/agent/guardrails.d.ts +14 -0
  20. package/dist/agent/guardrails.d.ts.map +1 -0
  21. package/dist/agent/index.d.ts +17 -742
  22. package/dist/agent/index.d.ts.map +1 -0
  23. package/dist/agent/index.js +224 -31
  24. package/dist/agent/index.mjs +223 -31
  25. package/dist/agent/isolated-tool.d.ts +9 -0
  26. package/dist/agent/isolated-tool.d.ts.map +1 -0
  27. package/dist/agent/registry.d.ts +71 -0
  28. package/dist/agent/registry.d.ts.map +1 -0
  29. package/dist/agent/step-runner.d.ts +12 -0
  30. package/dist/agent/step-runner.d.ts.map +1 -0
  31. package/dist/agent/strategy.d.ts +37 -0
  32. package/dist/agent/strategy.d.ts.map +1 -0
  33. package/dist/agent/telemetry/http-exporter.d.ts +24 -0
  34. package/dist/agent/telemetry/http-exporter.d.ts.map +1 -0
  35. package/dist/agent/telemetry/index.d.ts +3 -0
  36. package/dist/agent/telemetry/index.d.ts.map +1 -0
  37. package/dist/agent/telemetry/types.d.ts +92 -0
  38. package/dist/agent/telemetry/types.d.ts.map +1 -0
  39. package/dist/agent/tool-invoker.d.ts +17 -0
  40. package/dist/agent/tool-invoker.d.ts.map +1 -0
  41. package/dist/agent/tool-state.d.ts +7 -0
  42. package/dist/agent/tool-state.d.ts.map +1 -0
  43. package/dist/agent/types.d.ts +243 -0
  44. package/dist/agent/types.d.ts.map +1 -0
  45. package/dist/control-layer.d.ts +49 -0
  46. package/dist/control-layer.d.ts.map +1 -0
  47. package/dist/finance/factory.d.ts +11 -0
  48. package/dist/finance/factory.d.ts.map +1 -0
  49. package/dist/finance/index.d.ts +9 -76
  50. package/dist/finance/index.d.ts.map +1 -0
  51. package/dist/finance/normalizer.d.ts +19 -0
  52. package/dist/finance/normalizer.d.ts.map +1 -0
  53. package/dist/finance/strategies/french-pcg.strategy.d.ts +10 -0
  54. package/dist/finance/strategies/french-pcg.strategy.d.ts.map +1 -0
  55. package/dist/finance/strategies/international.strategy.d.ts +10 -0
  56. package/dist/finance/strategies/international.strategy.d.ts.map +1 -0
  57. package/dist/finance/strategies/swiss-co.strategy.d.ts +10 -0
  58. package/dist/finance/strategies/swiss-co.strategy.d.ts.map +1 -0
  59. package/dist/finance/strategies/uk-ifrs.strategy.d.ts +10 -0
  60. package/dist/finance/strategies/uk-ifrs.strategy.d.ts.map +1 -0
  61. package/dist/finance/strategies/us-gaap.strategy.d.ts +10 -0
  62. package/dist/finance/strategies/us-gaap.strategy.d.ts.map +1 -0
  63. package/dist/{strategy.interface-CB4_ZAuk.d.ts → finance/strategy.interface.d.ts} +5 -6
  64. package/dist/finance/strategy.interface.d.ts.map +1 -0
  65. package/dist/index.d.ts +9 -390
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.mjs +3 -3
  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 -743
  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 {
@@ -148,6 +155,25 @@ function auditToolResult(data, options) {
148
155
  }
149
156
 
150
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
+ }
151
177
  async function dispatchClientData(rawResult, callback) {
152
178
  if (!callback) {
153
179
  return;
@@ -199,6 +225,7 @@ function createIsolatedTool(config) {
199
225
  const toolId = config.id || config.name;
200
226
  const toolAlias = config.alias;
201
227
  const clientCallback = config.clientDto;
228
+ const toolIdentifier = toolAlias || config.name;
202
229
  const tool = {
203
230
  description: config.description,
204
231
  parameters: config.parameters,
@@ -207,20 +234,41 @@ function createIsolatedTool(config) {
207
234
  _toolAlias: toolAlias,
208
235
  _isIsolated: true,
209
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,
210
242
  _lastPiiFilteredCount: 0,
243
+ _lastInvalidationTags: void 0,
211
244
  async execute(args, context) {
212
245
  const updatedContext = {
213
246
  ...context,
214
247
  callChain: context?.callChain ?? Object.freeze([toolId])
215
248
  };
249
+ await verifyDataAccessGuard(
250
+ config.dataAccessGuard,
251
+ args,
252
+ updatedContext,
253
+ toolIdentifier
254
+ );
216
255
  const rawResult = await config.execute(args, updatedContext);
256
+ const tags = await resolveInvalidationTags(
257
+ config,
258
+ args,
259
+ rawResult,
260
+ updatedContext
261
+ );
262
+ if (tags) {
263
+ tool._lastInvalidationTags = tags;
264
+ }
217
265
  await dispatchClientData(rawResult, clientCallback);
218
266
  const protection = await processLlmPayload(
219
267
  rawResult,
220
268
  args,
221
269
  updatedContext,
222
270
  config,
223
- toolAlias || config.name
271
+ toolIdentifier
224
272
  );
225
273
  tool._lastPiiFilteredCount = protection.count;
226
274
  return protection.sanitized;
@@ -230,6 +278,18 @@ function createIsolatedTool(config) {
230
278
  }
231
279
 
232
280
  // src/agent/dto.ts
281
+ function extractWhitelistedFields(data, keys) {
282
+ const result = {};
283
+ if (!data || typeof data !== "object") {
284
+ return result;
285
+ }
286
+ for (const key of keys) {
287
+ if (key in data) {
288
+ result[key] = data[key];
289
+ }
290
+ }
291
+ return result;
292
+ }
233
293
  var dto = {
234
294
  /**
235
295
  * Generates a boolean acknowledgment for mutations ({ success: true | false }).
@@ -256,20 +316,16 @@ var dto = {
256
316
  };
257
317
  },
258
318
  /**
259
- * Filters raw output by extracting only a strict whitelist of allowed fields.
319
+ * Filters raw output by extracting only a whitelist of allowed fields.
320
+ * Supports optional TSource generic parameter for auto-completion.
260
321
  */
261
- pick: (keys) => (data) => {
262
- const result = {};
263
- if (!data || typeof data !== "object") {
264
- return result;
265
- }
266
- for (const key of keys) {
267
- if (key in data) {
268
- result[key] = data[key];
269
- }
270
- }
271
- return result;
272
- }
322
+ pick: (keys) => (data) => extractWhitelistedFields(data, keys),
323
+ /**
324
+ * Compile-time guarded exhaustive projection.
325
+ * Forces developers to explicitly classify every key of TSource as either 'keep' (sent to LLM)
326
+ * or 'drop' (ignored), preventing silent schema drift when source types evolve.
327
+ */
328
+ exhaustivePick: () => (config) => (data) => extractWhitelistedFields(data, config.keep)
273
329
  };
274
330
 
275
331
  // src/agent/factory.ts
@@ -303,6 +359,65 @@ var AgentToolFactory = class _AgentToolFactory {
303
359
  };
304
360
 
305
361
  // src/agent/registry.ts
362
+ function isCoreTool(item) {
363
+ return typeof item.execute === "function" && "_toolId" in item;
364
+ }
365
+ function normalizeToolDefinition(toolDef) {
366
+ if (isCoreTool(toolDef)) {
367
+ return {
368
+ id: toolDef._toolId || toolDef._toolName,
369
+ name: toolDef._toolName,
370
+ alias: toolDef._toolAlias,
371
+ description: toolDef.description,
372
+ domain: toolDef._domain,
373
+ resource: toolDef._resource,
374
+ roles: toolDef._roles ? Array.from(toolDef._roles) : void 0,
375
+ permissions: toolDef._permissions ? Array.from(toolDef._permissions) : void 0,
376
+ requireApproval: toolDef._requireApproval,
377
+ tool: toolDef
378
+ };
379
+ }
380
+ const id = toolDef.id || toolDef.name || toolDef.tool?._toolId;
381
+ const publicName = toolDef.alias || toolDef.name || toolDef.tool?._toolAlias || toolDef.tool?._toolName;
382
+ const roles = toolDef.roles ?? (toolDef.tool?._roles ? Array.from(toolDef.tool._roles) : toolDef.requiredRoles);
383
+ const permissions = toolDef.permissions ?? (toolDef.tool?._permissions ? Array.from(toolDef.tool._permissions) : void 0);
384
+ return {
385
+ ...toolDef,
386
+ id,
387
+ name: toolDef.name || toolDef.tool?._toolName || id,
388
+ alias: publicName,
389
+ domain: toolDef.domain ?? toolDef.tool?._domain,
390
+ resource: toolDef.resource ?? toolDef.tool?._resource,
391
+ roles,
392
+ permissions,
393
+ requireApproval: toolDef.requireApproval ?? toolDef.tool?._requireApproval
394
+ };
395
+ }
396
+ function matchesRoleFilter(tool, role) {
397
+ if (!role) {
398
+ return true;
399
+ }
400
+ const roles = tool.roles ?? tool.requiredRoles;
401
+ if (!roles || roles.length === 0) {
402
+ return true;
403
+ }
404
+ return roles.includes(role);
405
+ }
406
+ function toDescriptor(tool) {
407
+ return {
408
+ id: tool.id,
409
+ name: tool.name,
410
+ alias: tool.alias,
411
+ description: tool.description,
412
+ domain: tool.domain,
413
+ resource: tool.resource,
414
+ roles: tool.roles ?? tool.requiredRoles,
415
+ permissions: tool.permissions,
416
+ requireApproval: tool.requireApproval,
417
+ cacheTTL: tool.tool._cacheTTL,
418
+ tags: tool.tags
419
+ };
420
+ }
306
421
  var ToolRegistry = class _ToolRegistry {
307
422
  toolsById = /* @__PURE__ */ new Map();
308
423
  toolsByPublicName = /* @__PURE__ */ new Map();
@@ -310,16 +425,21 @@ var ToolRegistry = class _ToolRegistry {
310
425
  * Registers a new tool in the registry.
311
426
  */
312
427
  register(toolDef) {
313
- const id = toolDef.id || toolDef.name;
314
- const publicName = toolDef.alias || toolDef.name;
315
- const normalizedDef = {
316
- ...toolDef,
317
- id
318
- };
319
- this.toolsById.set(id, normalizedDef);
428
+ const normalizedDef = normalizeToolDefinition(toolDef);
429
+ const publicName = normalizedDef.alias || normalizedDef.name;
430
+ this.toolsById.set(normalizedDef.id, normalizedDef);
320
431
  this.toolsByPublicName.set(publicName, normalizedDef);
321
432
  return this;
322
433
  }
434
+ /**
435
+ * Registers multiple tools in batch.
436
+ */
437
+ registerMany(tools) {
438
+ for (const tool of tools) {
439
+ this.register(tool);
440
+ }
441
+ return this;
442
+ }
323
443
  /**
324
444
  * Retrieves a tool by its ID or public name/alias.
325
445
  */
@@ -350,6 +470,12 @@ var ToolRegistry = class _ToolRegistry {
350
470
  getAll() {
351
471
  return Array.from(this.toolsById.values());
352
472
  }
473
+ /**
474
+ * Filters tools belonging to a specific business domain.
475
+ */
476
+ getByDomain(domain) {
477
+ return this.getAll().filter((item) => item.domain === domain);
478
+ }
353
479
  /**
354
480
  * Filters tools matching a specific workflow phase.
355
481
  */
@@ -367,12 +493,26 @@ var ToolRegistry = class _ToolRegistry {
367
493
  filterByRoles(userRoles) {
368
494
  const roleSet = new Set(userRoles);
369
495
  return this.getAll().filter((item) => {
370
- if (!item.requiredRoles || item.requiredRoles.length === 0) {
496
+ const roles = item.roles ?? item.requiredRoles;
497
+ if (!roles || roles.length === 0) {
371
498
  return true;
372
499
  }
373
- return item.requiredRoles.some((role) => roleSet.has(role));
500
+ return roles.some((role) => roleSet.has(role));
374
501
  });
375
502
  }
503
+ /**
504
+ * Exports headless technical descriptors without UI rendering coupling.
505
+ */
506
+ getDescriptors(filter) {
507
+ let list = this.getAll();
508
+ if (filter?.domain) {
509
+ list = list.filter((item) => item.domain === filter.domain);
510
+ }
511
+ if (filter?.role) {
512
+ list = list.filter((item) => matchesRoleFilter(item, filter.role));
513
+ }
514
+ return list.map(toDescriptor);
515
+ }
376
516
  /**
377
517
  * Converts instance registered tools to the record map format required by Vercel AI SDK.
378
518
  */
@@ -384,8 +524,12 @@ var ToolRegistry = class _ToolRegistry {
384
524
  * If anonymize is true, uses alias (if defined) as dictionary key instead of technical name.
385
525
  */
386
526
  static toRecord(tools, options = {}) {
527
+ let filtered = tools;
528
+ if (options.domain) {
529
+ filtered = filtered.filter((item) => item.domain === options.domain);
530
+ }
387
531
  const record = {};
388
- for (const item of tools) {
532
+ for (const item of filtered) {
389
533
  const key = options.anonymize && item.alias ? item.alias : item.name;
390
534
  record[key] = item.tool;
391
535
  }
@@ -411,17 +555,64 @@ var PhaseBasedToolStrategy = class {
411
555
  var RoleBasedToolStrategy = class {
412
556
  selectTools(tools, context) {
413
557
  if (!context.role) {
414
- return tools.filter((t) => !t.requiredRoles || t.requiredRoles.length === 0);
558
+ return tools.filter((toolCandidate) => {
559
+ const roles = toolCandidate.roles ?? toolCandidate.requiredRoles;
560
+ return !roles || roles.length === 0;
561
+ });
415
562
  }
416
563
  const currentRole = context.role;
417
564
  return tools.filter((item) => {
418
- if (!item.requiredRoles || item.requiredRoles.length === 0) {
565
+ const roles = item.roles ?? item.requiredRoles;
566
+ if (!roles || roles.length === 0) {
419
567
  return true;
420
568
  }
421
- return item.requiredRoles.includes(currentRole);
569
+ return roles.includes(currentRole);
422
570
  });
423
571
  }
424
572
  };
573
+ function matchesDomain(tool, allowedDomains) {
574
+ if (!allowedDomains) {
575
+ return true;
576
+ }
577
+ return Boolean(tool.domain && allowedDomains.has(tool.domain));
578
+ }
579
+ function matchesRoles(tool, context) {
580
+ const toolRoles = tool.roles ?? tool.requiredRoles;
581
+ if (!toolRoles || toolRoles.length === 0) {
582
+ return true;
583
+ }
584
+ const userRoles = [];
585
+ if (context.role) {
586
+ userRoles.push(context.role);
587
+ }
588
+ if (context.roles) {
589
+ userRoles.push(...context.roles);
590
+ }
591
+ if (userRoles.length === 0) {
592
+ return false;
593
+ }
594
+ return toolRoles.some((roleName) => userRoles.includes(roleName));
595
+ }
596
+ function matchesPermissions(tool, context) {
597
+ if (!tool.permissions || tool.permissions.length === 0) {
598
+ return true;
599
+ }
600
+ const userPermissions = context.permissions ?? [];
601
+ return tool.permissions.every((permissionName) => userPermissions.includes(permissionName));
602
+ }
603
+ var AccessControlToolStrategy = class {
604
+ allowedDomains;
605
+ constructor(options) {
606
+ if (options?.allowedDomains) {
607
+ this.allowedDomains = new Set(options.allowedDomains);
608
+ }
609
+ }
610
+ selectTools(tools, context) {
611
+ return tools.filter(
612
+ (tool) => matchesDomain(tool, this.allowedDomains) && matchesRoles(tool, context) && matchesPermissions(tool, context)
613
+ );
614
+ }
615
+ };
425
616
  var CompositeToolStrategy = class {
426
617
  strategies;
427
618
  constructor(strategies) {
@@ -1669,6 +1860,7 @@ var HttpTelemetryExporter = class {
1669
1860
  }
1670
1861
  };
1671
1862
  export {
1863
+ AccessControlToolStrategy,
1672
1864
  AgentToolFactory,
1673
1865
  CircularToolCallError,
1674
1866
  CompositeToolStrategy,
@@ -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,oBAAo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@@
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"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Supported telemetry event types for the avantGate observability platform.
3
+ */
4
+ export type TelemetryEventType = "STEP_START" | "STEP_COMPLETED" | "STEP_FAILED" | "STEP_APPROVAL_REQUEST" | "TOOL_EXECUTION";
5
+ /**
6
+ * Base properties shared across all telemetry events.
7
+ */
8
+ export interface BaseTelemetryEvent {
9
+ type: TelemetryEventType;
10
+ timestamp: string;
11
+ }
12
+ export interface StepStartEvent extends BaseTelemetryEvent {
13
+ type: "STEP_START";
14
+ stepName: string;
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+ export interface StepCompletedEvent extends BaseTelemetryEvent {
18
+ type: "STEP_COMPLETED";
19
+ stepName: string;
20
+ durationMs?: number;
21
+ piiDetectedCount?: number;
22
+ resultSummary?: unknown;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ export interface StepFailedEvent extends BaseTelemetryEvent {
26
+ type: "STEP_FAILED";
27
+ stepName: string;
28
+ durationMs?: number;
29
+ error: string;
30
+ }
31
+ export interface StepApprovalRequestEvent extends BaseTelemetryEvent {
32
+ type: "STEP_APPROVAL_REQUEST";
33
+ stepName: string;
34
+ actionType?: string;
35
+ payloadSummary?: unknown;
36
+ }
37
+ export interface ToolExecutionTelemetryEvent extends BaseTelemetryEvent {
38
+ type: "TOOL_EXECUTION";
39
+ toolId: string;
40
+ toolName: string;
41
+ aliasUsed?: string;
42
+ durationMs: number;
43
+ success: boolean;
44
+ parentToolId?: string;
45
+ depth?: number;
46
+ llmSummary?: unknown;
47
+ piiFilteredCount?: number;
48
+ tokenCount?: number;
49
+ tokens?: {
50
+ promptTokens?: number;
51
+ completionTokens?: number;
52
+ totalTokens?: number;
53
+ };
54
+ costUsd?: number;
55
+ cached?: boolean;
56
+ error?: string;
57
+ }
58
+ export type TelemetryEvent = StepStartEvent | StepCompletedEvent | StepFailedEvent | StepApprovalRequestEvent | ToolExecutionTelemetryEvent;
59
+ /**
60
+ * Consolidates token usage and FinOps metrics for a batch or run.
61
+ */
62
+ export interface TelemetryUsageSummary {
63
+ model?: string;
64
+ promptTokens?: number;
65
+ completionTokens?: number;
66
+ totalTokens?: number;
67
+ costUsd?: number;
68
+ }
69
+ /**
70
+ * Payload schema ingested by POST /api/v1/ingest/events according to DESIGN-005 §5.1.
71
+ */
72
+ export interface TelemetryIngestPayload {
73
+ runId: string;
74
+ agentName?: string;
75
+ timestamp: string;
76
+ events: TelemetryEvent[];
77
+ usage?: TelemetryUsageSummary;
78
+ }
79
+ /**
80
+ * Configuration options for the HTTP Telemetry Exporter.
81
+ */
82
+ export interface HttpTelemetryExporterOptions {
83
+ apiKey: string;
84
+ endpoint?: string;
85
+ agentName?: string;
86
+ batchIntervalMs?: number;
87
+ maxBatchSize?: number;
88
+ maxQueueSize?: number;
89
+ fetchFn?: typeof fetch;
90
+ onError?: (error: Error) => void;
91
+ }
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agent/telemetry/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,gBAAgB,GAChB,aAAa,GACb,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CA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,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC"}
@@ -0,0 +1,17 @@
1
+ import { ToolRegistry } from "./registry";
2
+ import type { StepStorageAdapter, ToolExecutionContext } from "./types";
3
+ export interface ToolInvokerOptions {
4
+ maxDepth?: number;
5
+ maxTotalSubCalls?: number;
6
+ workflowId?: string;
7
+ stepId?: string;
8
+ }
9
+ export interface ToolInvoker {
10
+ invokeTool<TResult = unknown>(toolId: string, args: unknown, context?: ToolExecutionContext): Promise<TResult>;
11
+ }
12
+ /**
13
+ * Creates an intelligent, concurrency-safe tool invoker with cycle detection,
14
+ * depth guard, result caching, and database execution tracing.
15
+ */
16
+ export declare function createToolInvoker(registry: ToolRegistry, storage?: StepStorageAdapter, options?: ToolInvokerOptions): ToolInvoker;
17
+ //# sourceMappingURL=tool-invoker.d.ts.map