@x12i/ai-gateway 9.0.9 → 9.1.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 (38) hide show
  1. package/README.md +897 -998
  2. package/dist/activity-manager.js +46 -6
  3. package/dist/config/activity-tracking-config.d.ts +2 -1
  4. package/dist/config/activity-tracking-config.js +3 -2
  5. package/dist/gateway-memory.d.ts +1 -2
  6. package/dist/gateway-memory.js +1 -15
  7. package/dist/gateway-meta.js +3 -0
  8. package/dist/gateway-utils.d.ts +9 -1
  9. package/dist/gateway-utils.js +79 -18
  10. package/dist/gateway-validation.d.ts +3 -3
  11. package/dist/gateway-validation.js +10 -1
  12. package/dist/gateway.d.ts +2 -2
  13. package/dist/gateway.js +20 -3
  14. package/dist/index.d.ts +2 -2
  15. package/dist/instruction-optimizer.js +3 -0
  16. package/dist/runtime-objects.d.ts +2 -13
  17. package/dist/troubleshooting-helper.d.ts +0 -3
  18. package/dist/troubleshooting-helper.js +99 -20
  19. package/dist/types.d.ts +39 -89
  20. package/dist-cjs/activity-manager.cjs +45 -5
  21. package/dist-cjs/config/activity-tracking-config.cjs +3 -2
  22. package/dist-cjs/config/activity-tracking-config.d.ts +2 -1
  23. package/dist-cjs/gateway-memory.cjs +1 -15
  24. package/dist-cjs/gateway-memory.d.ts +1 -2
  25. package/dist-cjs/gateway-meta.cjs +3 -0
  26. package/dist-cjs/gateway-utils.cjs +81 -18
  27. package/dist-cjs/gateway-utils.d.ts +9 -1
  28. package/dist-cjs/gateway-validation.cjs +10 -1
  29. package/dist-cjs/gateway-validation.d.ts +3 -3
  30. package/dist-cjs/gateway.cjs +19 -2
  31. package/dist-cjs/gateway.d.ts +2 -2
  32. package/dist-cjs/index.d.ts +2 -2
  33. package/dist-cjs/instruction-optimizer.cjs +3 -0
  34. package/dist-cjs/runtime-objects.d.ts +2 -13
  35. package/dist-cjs/troubleshooting-helper.cjs +99 -20
  36. package/dist-cjs/troubleshooting-helper.d.ts +0 -3
  37. package/dist-cjs/types.d.ts +39 -89
  38. package/package.json +2 -2
@@ -22,7 +22,22 @@ export interface DiagnosticsOptions {
22
22
  * Implementations must size-cap any raw payload included.
23
23
  */
24
24
  includeRawProviderPayload?: boolean;
25
+ /**
26
+ * When false, Activix activity completion omits `response.content.fullResponse` (large provider blob).
27
+ * When true or omitted, the full payload is stored (subject to `activityFullResponseMaxChars`).
28
+ */
29
+ includeFullProviderResponseInActivity?: boolean;
30
+ /**
31
+ * Max serialized length for `fullResponse` on activity records when included (JSON string length).
32
+ * Default applied in gateway when omitted.
33
+ */
34
+ activityFullResponseMaxChars?: number;
25
35
  }
36
+ /**
37
+ * Classifies the gateway invocation for tracing and Activix (`runContext`).
38
+ * Mandatory on {@link AIInvokeRequest} (`AIGateway.invoke`).
39
+ */
40
+ export type GatewayActionType = 'skill' | 'preSkill' | 'postSkill';
26
41
  export type GatewayTraceRequestIds = {
27
42
  /** Stable alias of gateway aiRequestId (always set when trace enabled). */
28
43
  gatewayAiRequestId: string;
@@ -111,6 +126,14 @@ export type ActivityIdentity = {
111
126
  coreSkillId?: string;
112
127
  masterSkillId?: string;
113
128
  masterSkillActivityId?: string;
129
+ /**
130
+ * From {@link AIInvokeRequest.actionType} when present (gateway.invoke); copied into runContext for Activix.
131
+ */
132
+ actionType?: GatewayActionType;
133
+ /**
134
+ * From {@link AIInvokeRequest.actionRef} when present; copied into runContext for Activix.
135
+ */
136
+ actionRef?: string;
114
137
  };
115
138
  /** Re-export parser template options for gateway consumers (MUST/optional protocol, subPathSearch, etc.). */
116
139
  export type { TemplateRenderOptions } from '@x12i/rendrix';
@@ -566,14 +589,6 @@ interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input' | 'reques
566
589
  * Added as system message between instructions and prompt
567
590
  */
568
591
  context?: string;
569
- /**
570
- * Task configuration (optional) - Control template behavior and conditional rendering
571
- * @deprecated taskConfig is no longer used by Rendrix 3.0.0+
572
- * Kept for backward compatibility only - will be ignored
573
- */
574
- taskConfig?: {
575
- includeThoughts?: boolean;
576
- };
577
592
  /**
578
593
  * Working memory (optional) - Affects all template parsing
579
594
  * Passed to Rendrix (v4+) for template variable substitution.
@@ -587,16 +602,6 @@ interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input' | 'reques
587
602
  * the full list or only set `enabled` and inherit `roots` from the gateway default merge.
588
603
  */
589
604
  templateRenderOptions?: TemplateRenderOptions;
590
- /**
591
- * Template tokens (optional) - Tier 1 (highest priority) token values
592
- * These tokens are passed directly as arguments and override all other memory sources
593
- * Common tokens: taskDescription, input (from workingMemory.input), role
594
- * Example: { taskDescription: "Extract emails", input: "user@example.com", role: "user" }
595
- * Note: The `input` field has been removed. Use workingMemory.input instead.
596
- */
597
- templateTokens?: {
598
- [key: string]: string | number | boolean | object | object[];
599
- };
600
605
  /**
601
606
  * Messages array - Optional, can be used instead of instructions/prompt
602
607
  * If provided, will be appended as-is after built messages; instructions template text is still parsed for the system message when present
@@ -643,28 +648,6 @@ interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input' | 'reques
643
648
  * Can be a single type (string) or multiple types (array)
644
649
  */
645
650
  inferenceType?: string | string[];
646
- /**
647
- * Enable output schema validation (optional)
648
- * When true, validates parsed output against schema from instruction metadata or outputs library
649
- * @default false
650
- */
651
- validateOutputSchema?: boolean;
652
- /**
653
- * Enable strict validation mode (optional)
654
- * When true, validation errors will throw exceptions instead of warnings
655
- * @default false
656
- */
657
- strictValidation?: boolean;
658
- /**
659
- * Response transformation hooks (optional)
660
- * Allows transforming responses at different stages of processing
661
- */
662
- transformations?: ResponseTransformationConfig;
663
- /**
664
- * Parse options for outputs library (optional)
665
- * Used when inferenceType is provided for parsing inference outputs
666
- */
667
- parseOptions?: Record<string, unknown>;
668
651
  /**
669
652
  * Optional diagnostics controls. When omitted or mode != 'trace', the gateway must not
670
653
  * attach heavy diagnostic objects or raw provider payloads.
@@ -682,7 +665,7 @@ interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input' | 'reques
682
665
  * Minimum: instructions + prompt (prompt is required for user message)
683
666
  *
684
667
  * Note: objectTypes is NOT supported in ChatRequest.
685
- * Use AIRequest with invoke() method for structured output requests.
668
+ * Use {@link AIInvokeRequest} with invoke() for structured output requests.
686
669
  */
687
670
  export interface ChatRequest extends BaseLLMRequest {
688
671
  /**
@@ -714,18 +697,19 @@ export interface StructuredTextSpec {
714
697
  formatHint?: string;
715
698
  }
716
699
  /**
717
- * AI request for structured output requests
718
- * Used exclusively with invoke() method for requests requiring structured output
700
+ * Payload for {@link AIGateway.invoke}: structured / skill flows with mandatory action classification.
719
701
  *
720
- * Mandatory:
721
- * - aiRequestId: Required for activity tracking
722
- * - agentId: Required to identify the agent
723
- * - instructions: Required (template text)
724
- * - primaryObjectType OR flexMdFormat: Required for structured output
725
- * * primaryObjectType: Standard/custom object type (requires outputs library)
726
- * * flexMdFormat: Direct flex-md format specification (no outputs library needed)
702
+ * Recorded on {@link ActivityIdentity} (`runContext`) and activity roots for Activix.
727
703
  */
728
- export interface AIRequest extends BaseLLMRequest {
704
+ export interface AIInvokeRequest extends BaseLLMRequest {
705
+ /**
706
+ * Invocation kind: main skill vs pre/post hooks around skill execution.
707
+ */
708
+ actionType: GatewayActionType;
709
+ /**
710
+ * Stable reference for the action (e.g. `skills/my-skill`).
711
+ */
712
+ actionRef: string;
729
713
  /**
730
714
  * Encrypted reasoning items for conversation continuity
731
715
  * Only include reasoning.encrypted items from previous responses
@@ -739,10 +723,6 @@ export interface AIRequest extends BaseLLMRequest {
739
723
  data?: string;
740
724
  summary?: any[];
741
725
  }>;
742
- /**
743
- * Skill execution tracking fields
744
- * Used when executing skills (instruction keys starting with 'skills/')
745
- */
746
726
  /**
747
727
  * Master skill activity ID - The parent skill activity's ID (when a skill calls another skill)
748
728
  * When a skill executes and calls another skill, the parent skill's activityId becomes
@@ -761,6 +741,10 @@ export interface AIRequest extends BaseLLMRequest {
761
741
  */
762
742
  masterSkillId?: string;
763
743
  }
744
+ /**
745
+ * @deprecated Prefer {@link AIInvokeRequest}; alias kept for existing imports.
746
+ */
747
+ export type AIRequest = AIInvokeRequest;
764
748
  /**
765
749
  * Enhanced response with comprehensive metadata and generic type support
766
750
  *
@@ -1241,38 +1225,4 @@ export interface ValidationRule {
1241
1225
  */
1242
1226
  message?: string;
1243
1227
  }
1244
- /**
1245
- * Response transformation hooks configuration
1246
- * Allows transforming responses at different stages of processing
1247
- */
1248
- export interface ResponseTransformationConfig {
1249
- /**
1250
- * Transform raw text before parsing
1251
- * @param rawText - Raw text from LLM response
1252
- * @param metadata - Request metadata (jobId, agentId, etc.)
1253
- * @returns Transformed raw text
1254
- */
1255
- preParse?: (rawText: string, metadata: any) => string;
1256
- /**
1257
- * Transform parsed content after parsing
1258
- * @param parsed - Parsed content (object/array)
1259
- * @param metadata - Request metadata
1260
- * @returns Transformed parsed content
1261
- */
1262
- postParse?: (parsed: any, metadata: any) => any;
1263
- /**
1264
- * Transform parsed content before validation
1265
- * @param parsed - Parsed content
1266
- * @param schema - JSON schema (if available)
1267
- * @returns Transformed parsed content
1268
- */
1269
- preValidate?: (parsed: any, schema: any) => any;
1270
- /**
1271
- * Transform validated content after validation
1272
- * @param validated - Validated content
1273
- * @param metadata - Request metadata
1274
- * @returns Transformed validated content
1275
- */
1276
- postValidate?: (validated: any, metadata: any) => any;
1277
- }
1278
1228
  export type { LLMRequest, LLMResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x12i/ai-gateway",
3
- "version": "9.0.9",
3
+ "version": "9.1.0",
4
4
  "description": "AI Gateway - Unified interface for LLM provider routing and management",
5
5
  "type": "module",
6
6
  "exports": {
@@ -65,7 +65,7 @@
65
65
  "@aws-sdk/s3-request-presigner": "^3.953.0",
66
66
  "@x12i/env": "^4.0.1",
67
67
  "@x12i/logxer": "^4.3.5",
68
- "@x12i/activix": "^6.7.0",
68
+ "@x12i/activix": "^7.1.0",
69
69
  "@x12i/flex-md": "^4.8.0"
70
70
  },
71
71
  "devDependencies": {