@x12i/ai-gateway 9.1.6 → 9.3.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.
- package/README.md +45 -0
- package/dist/activity-manager.d.ts +1 -0
- package/dist/activity-manager.js +7 -0
- package/dist/ai-tools-client.d.ts +20 -0
- package/dist/ai-tools-client.js +91 -0
- package/dist/flex-md-loader.d.ts +5 -0
- package/dist/flex-md-loader.js +16 -0
- package/dist/gateway-config.d.ts +2 -0
- package/dist/gateway-config.js +2 -1
- package/dist/gateway-mode.d.ts +40 -0
- package/dist/gateway-mode.js +75 -0
- package/dist/gateway-utils.d.ts +57 -1
- package/dist/gateway-utils.js +181 -12
- package/dist/gateway.d.ts +3 -0
- package/dist/gateway.js +47 -15
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -1
- package/dist/output-contract-normalizer.d.ts +21 -0
- package/dist/output-contract-normalizer.js +121 -0
- package/dist/types.d.ts +35 -0
- package/dist-cjs/activity-manager.cjs +21 -19
- package/dist-cjs/activity-manager.d.ts +1 -0
- package/dist-cjs/ai-tools-client.cjs +91 -0
- package/dist-cjs/ai-tools-client.d.ts +20 -0
- package/dist-cjs/config/activity-tracking-config.cjs +1 -4
- package/dist-cjs/content-normalizer/content-normalizer.cjs +3 -8
- package/dist-cjs/content-normalizer/index.cjs +1 -7
- package/dist-cjs/content-normalizer/types.cjs +1 -2
- package/dist-cjs/flex-md-loader.cjs +35 -65
- package/dist-cjs/flex-md-loader.d.ts +5 -0
- package/dist-cjs/gateway-config.cjs +25 -63
- package/dist-cjs/gateway-config.d.ts +2 -0
- package/dist-cjs/gateway-conversion.cjs +10 -48
- package/dist-cjs/gateway-instructions.cjs +5 -10
- package/dist-cjs/gateway-log-meta.cjs +9 -14
- package/dist-cjs/gateway-memory.cjs +2 -6
- package/dist-cjs/gateway-messages.cjs +3 -6
- package/dist-cjs/gateway-meta.cjs +1 -4
- package/dist-cjs/gateway-mode.cjs +75 -0
- package/dist-cjs/gateway-mode.d.ts +40 -0
- package/dist-cjs/gateway-provider-auto-register.cjs +2 -38
- package/dist-cjs/gateway-provider.cjs +10 -22
- package/dist-cjs/gateway-rate-limiter-constants.cjs +2 -5
- package/dist-cjs/gateway-rate-limiter.cjs +5 -9
- package/dist-cjs/gateway-retry.cjs +6 -14
- package/dist-cjs/gateway-utils.cjs +201 -83
- package/dist-cjs/gateway-utils.d.ts +57 -1
- package/dist-cjs/gateway-validation.cjs +2 -6
- package/dist-cjs/gateway.cjs +100 -72
- package/dist-cjs/gateway.d.ts +3 -0
- package/dist-cjs/index.cjs +22 -91
- package/dist-cjs/index.d.ts +6 -1
- package/dist-cjs/instruction-errors.cjs +2 -7
- package/dist-cjs/instruction-optimizer.cjs +4 -10
- package/dist-cjs/instructions-parser.cjs +5 -10
- package/dist-cjs/logger-factory.cjs +3 -6
- package/dist-cjs/memory-path-resolution.cjs +8 -18
- package/dist-cjs/message-builder.cjs +11 -47
- package/dist-cjs/object-types-library-integration.cjs +3 -8
- package/dist-cjs/object-types-library.cjs +5 -10
- package/dist-cjs/output-auditor.cjs +1 -4
- package/dist-cjs/output-contract-normalizer.cjs +121 -0
- package/dist-cjs/output-contract-normalizer.d.ts +21 -0
- package/dist-cjs/request-report-generator.cjs +1 -4
- package/dist-cjs/response-analyzer/format-type-detector.cjs +1 -5
- package/dist-cjs/response-analyzer/index.cjs +3 -9
- package/dist-cjs/response-analyzer/object-type-detector.cjs +1 -5
- package/dist-cjs/response-analyzer/response-analyzer.cjs +6 -10
- package/dist-cjs/response-analyzer/types.cjs +1 -2
- package/dist-cjs/response-fallback-fixer.cjs +1 -4
- package/dist-cjs/runtime-objects.cjs +7 -13
- package/dist-cjs/template-parser.cjs +5 -42
- package/dist-cjs/template-render-merge.cjs +2 -6
- package/dist-cjs/troubleshooting-helper.cjs +13 -28
- package/dist-cjs/types.cjs +1 -2
- package/dist-cjs/types.d.ts +35 -0
- package/dist-cjs/usage-tracker.cjs +3 -7
- package/package.json +11 -5
package/dist-cjs/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @x12i/ai-gateway
|
|
4
3
|
*
|
|
@@ -6,110 +5,42 @@
|
|
|
6
5
|
* This package exposes all functionality from @x12i/ai-providers-router
|
|
7
6
|
* with enhanced features: context propagation, usage tier tracking, and comprehensive metadata.
|
|
8
7
|
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.getObjectTypesForAgent = exports.getObjectType = exports.OBJECT_TYPES_LIBRARY = exports.assertValidAIRequest = exports.formatDiagnostic = exports.runValidationTests = exports.createValidationTestCases = exports.createTestAIRequest = exports.supportsJSONMode = exports.diagnoseResponse = exports.diagnoseRequest = exports.validateResponse = exports.extractJSON = exports.validateJSON = exports.validateAIRequest = exports.DEFAULT_RATE_LIMIT_ENABLED = exports.DEFAULT_RATE_LIMIT_MIN_INTERVAL_MS = exports.GatewayRateLimiter = exports.runtimeObjects = exports.DebugLogAbstract = exports.createLogxer = exports.gatewayLogDebug = exports.withActivityIdentity = exports.activityIdentityToLogMeta = exports.ensureGatewayRequestIdentity = exports.ActivityManager = exports.Activix = exports.resolveGatewayMemoryPathValue = exports.prepareWorkingMemoryForTemplateRender = exports.parseLooseJsonObject = exports.mapSmartInputPathsInputsToInput = exports.extractCallerInputsBag = exports.coalesceMergedInputBucket = exports.buildMemoryResolutionRootFromWorkingMemory = exports.GATEWAY_DUAL_MEMORY_ROOTS = exports.mergeTemplateRenderOptions = exports.mergeGatewayAndRequestTemplateRenderOptions = exports.pickRequestIdsFromRouterLike = exports.tryExtractRouterLikePayloadFromErrorChain = exports.buildInvokeRejectionMetadata = exports.attachGatewayInvokeRejectionMetadata = exports.autoRegisterProviders = exports.InstructionBackendError = exports.InstructionNotFoundError = exports.AIGateway = exports.FallbackExhaustedError = exports.ProviderNotFoundError = exports.createRouterFromConfig = exports.createRouter = exports.LLMProviderRouter = void 0;
|
|
25
|
-
exports.resetObjectTypesLibrary = exports.getObjectTypesLibrary = exports.initializeObjectTypesLibrary = void 0;
|
|
26
8
|
// Re-export router class and types (base functionality)
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(exports, "LLMProviderRouter", { enumerable: true, get: function () { return ai_providers_router_1.LLMProviderRouter; } });
|
|
9
|
+
export { LLMProviderRouter } from '@x12i/ai-providers-router';
|
|
29
10
|
// Re-export factory functions
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(exports, "createRouter", { enumerable: true, get: function () { return ai_providers_router_2.createRouter; } });
|
|
32
|
-
Object.defineProperty(exports, "createRouterFromConfig", { enumerable: true, get: function () { return ai_providers_router_2.createRouterFromConfig; } });
|
|
11
|
+
export { createRouter, createRouterFromConfig } from '@x12i/ai-providers-router';
|
|
33
12
|
// Re-export error classes
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(exports, "ProviderNotFoundError", { enumerable: true, get: function () { return ai_providers_router_3.ProviderNotFoundError; } });
|
|
36
|
-
Object.defineProperty(exports, "FallbackExhaustedError", { enumerable: true, get: function () { return ai_providers_router_3.FallbackExhaustedError; } });
|
|
13
|
+
export { ProviderNotFoundError, FallbackExhaustedError } from '@x12i/ai-providers-router';
|
|
37
14
|
// Re-export all from router (includes everything it exports)
|
|
38
|
-
|
|
15
|
+
export * from '@x12i/ai-providers-router';
|
|
39
16
|
// Export enhanced gateway
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Object.defineProperty(exports, "attachGatewayInvokeRejectionMetadata", { enumerable: true, get: function () { return gateway_utils_js_1.attachGatewayInvokeRejectionMetadata; } });
|
|
49
|
-
Object.defineProperty(exports, "buildInvokeRejectionMetadata", { enumerable: true, get: function () { return gateway_utils_js_1.buildInvokeRejectionMetadata; } });
|
|
50
|
-
Object.defineProperty(exports, "tryExtractRouterLikePayloadFromErrorChain", { enumerable: true, get: function () { return gateway_utils_js_1.tryExtractRouterLikePayloadFromErrorChain; } });
|
|
51
|
-
Object.defineProperty(exports, "pickRequestIdsFromRouterLike", { enumerable: true, get: function () { return gateway_utils_js_1.pickRequestIdsFromRouterLike; } });
|
|
52
|
-
var template_render_merge_js_1 = require("./template-render-merge.cjs");
|
|
53
|
-
Object.defineProperty(exports, "mergeGatewayAndRequestTemplateRenderOptions", { enumerable: true, get: function () { return template_render_merge_js_1.mergeGatewayAndRequestTemplateRenderOptions; } });
|
|
54
|
-
Object.defineProperty(exports, "mergeTemplateRenderOptions", { enumerable: true, get: function () { return template_render_merge_js_1.mergeTemplateRenderOptions; } });
|
|
55
|
-
var memory_path_resolution_js_1 = require("./memory-path-resolution.cjs");
|
|
56
|
-
Object.defineProperty(exports, "GATEWAY_DUAL_MEMORY_ROOTS", { enumerable: true, get: function () { return memory_path_resolution_js_1.GATEWAY_DUAL_MEMORY_ROOTS; } });
|
|
57
|
-
Object.defineProperty(exports, "buildMemoryResolutionRootFromWorkingMemory", { enumerable: true, get: function () { return memory_path_resolution_js_1.buildMemoryResolutionRootFromWorkingMemory; } });
|
|
58
|
-
Object.defineProperty(exports, "coalesceMergedInputBucket", { enumerable: true, get: function () { return memory_path_resolution_js_1.coalesceMergedInputBucket; } });
|
|
59
|
-
Object.defineProperty(exports, "extractCallerInputsBag", { enumerable: true, get: function () { return memory_path_resolution_js_1.extractCallerInputsBag; } });
|
|
60
|
-
Object.defineProperty(exports, "mapSmartInputPathsInputsToInput", { enumerable: true, get: function () { return memory_path_resolution_js_1.mapSmartInputPathsInputsToInput; } });
|
|
61
|
-
Object.defineProperty(exports, "parseLooseJsonObject", { enumerable: true, get: function () { return memory_path_resolution_js_1.parseLooseJsonObject; } });
|
|
62
|
-
Object.defineProperty(exports, "prepareWorkingMemoryForTemplateRender", { enumerable: true, get: function () { return memory_path_resolution_js_1.prepareWorkingMemoryForTemplateRender; } });
|
|
63
|
-
Object.defineProperty(exports, "resolveGatewayMemoryPathValue", { enumerable: true, get: function () { return memory_path_resolution_js_1.resolveGatewayMemoryPathValue; } });
|
|
17
|
+
export { AIGateway } from './gateway.js';
|
|
18
|
+
export { InstructionNotFoundError, InstructionBackendError } from './instruction-errors.js';
|
|
19
|
+
export { autoRegisterProviders } from './gateway-provider-auto-register.js';
|
|
20
|
+
export { attachGatewayInvokeRejectionMetadata, buildInvokeRejectionMetadata, tryExtractRouterLikePayloadFromErrorChain, pickRequestIdsFromRouterLike, resolveActivityCostCompletion, resolveCostCompletionForActivity, resolveCostCompletionWithAiTools, hasNonZeroTokenUsage } from './gateway-utils.js';
|
|
21
|
+
export { getGatewayOperationalMode, isProdGatewayMode, resolveGatewayDefaultModel, parseModelProviderSpec, CODE_DEFAULT_MODEL } from './gateway-mode.js';
|
|
22
|
+
export { contractSpecToFieldKeys, enrichParsedContentForOutputContract, resolveOutputContractFieldKeys } from './output-contract-normalizer.js';
|
|
23
|
+
export { mergeGatewayAndRequestTemplateRenderOptions, mergeTemplateRenderOptions } from './template-render-merge.js';
|
|
24
|
+
export { GATEWAY_DUAL_MEMORY_ROOTS, buildMemoryResolutionRootFromWorkingMemory, coalesceMergedInputBucket, extractCallerInputsBag, mapSmartInputPathsInputsToInput, parseLooseJsonObject, prepareWorkingMemoryForTemplateRender, resolveGatewayMemoryPathValue } from './memory-path-resolution.js';
|
|
64
25
|
// Usage tracking: UsageTracker class methods are available but consumption calculation is disabled
|
|
65
26
|
// (x-models was previously used for RPM/TPM tracking but is no longer integrated)
|
|
66
27
|
// Re-export activity tracking primitives (Activix)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Object.defineProperty(exports, "ActivityManager", { enumerable: true, get: function () { return activity_manager_js_1.ActivityManager; } });
|
|
71
|
-
Object.defineProperty(exports, "ensureGatewayRequestIdentity", { enumerable: true, get: function () { return activity_manager_js_1.ensureGatewayRequestIdentity; } });
|
|
72
|
-
var gateway_log_meta_js_1 = require("./gateway-log-meta.cjs");
|
|
73
|
-
Object.defineProperty(exports, "activityIdentityToLogMeta", { enumerable: true, get: function () { return gateway_log_meta_js_1.activityIdentityToLogMeta; } });
|
|
74
|
-
Object.defineProperty(exports, "withActivityIdentity", { enumerable: true, get: function () { return gateway_log_meta_js_1.withActivityIdentity; } });
|
|
75
|
-
Object.defineProperty(exports, "gatewayLogDebug", { enumerable: true, get: function () { return gateway_log_meta_js_1.gatewayLogDebug; } });
|
|
28
|
+
export { Activix } from '@x12i/activix';
|
|
29
|
+
export { ActivityManager, ensureGatewayRequestIdentity } from './activity-manager.js';
|
|
30
|
+
export { activityIdentityToLogMeta, withActivityIdentity, gatewayLogDebug } from './gateway-log-meta.js';
|
|
76
31
|
// Re-export logging (@x12i/logxer)
|
|
77
|
-
|
|
78
|
-
Object.defineProperty(exports, "createLogxer", { enumerable: true, get: function () { return logxer_1.createLogxer; } });
|
|
79
|
-
Object.defineProperty(exports, "DebugLogAbstract", { enumerable: true, get: function () { return logxer_1.DebugLogAbstract; } });
|
|
32
|
+
export { createLogxer, DebugLogAbstract } from '@x12i/logxer';
|
|
80
33
|
// Runtime observability surface (leaf package: no downstream runtime objects)
|
|
81
|
-
|
|
82
|
-
Object.defineProperty(exports, "runtimeObjects", { enumerable: true, get: function () { return runtime_objects_js_1.runtimeObjects; } });
|
|
34
|
+
export { runtimeObjects } from './runtime-objects.js';
|
|
83
35
|
// Export rate limiter
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var gateway_rate_limiter_constants_js_1 = require("./gateway-rate-limiter-constants.cjs");
|
|
87
|
-
Object.defineProperty(exports, "DEFAULT_RATE_LIMIT_MIN_INTERVAL_MS", { enumerable: true, get: function () { return gateway_rate_limiter_constants_js_1.DEFAULT_RATE_LIMIT_MIN_INTERVAL_MS; } });
|
|
88
|
-
Object.defineProperty(exports, "DEFAULT_RATE_LIMIT_ENABLED", { enumerable: true, get: function () { return gateway_rate_limiter_constants_js_1.DEFAULT_RATE_LIMIT_ENABLED; } });
|
|
36
|
+
export { GatewayRateLimiter } from './gateway-rate-limiter.js';
|
|
37
|
+
export { DEFAULT_RATE_LIMIT_MIN_INTERVAL_MS, DEFAULT_RATE_LIMIT_ENABLED } from './gateway-rate-limiter-constants.js';
|
|
89
38
|
// Export troubleshooting helpers
|
|
90
|
-
|
|
91
|
-
Object.defineProperty(exports, "validateAIRequest", { enumerable: true, get: function () { return troubleshooting_helper_js_1.validateAIRequest; } });
|
|
92
|
-
Object.defineProperty(exports, "validateJSON", { enumerable: true, get: function () { return troubleshooting_helper_js_1.validateJSON; } });
|
|
93
|
-
Object.defineProperty(exports, "extractJSON", { enumerable: true, get: function () { return troubleshooting_helper_js_1.extractJSON; } });
|
|
94
|
-
Object.defineProperty(exports, "validateResponse", { enumerable: true, get: function () { return troubleshooting_helper_js_1.validateResponse; } });
|
|
95
|
-
Object.defineProperty(exports, "diagnoseRequest", { enumerable: true, get: function () { return troubleshooting_helper_js_1.diagnoseRequest; } });
|
|
96
|
-
Object.defineProperty(exports, "diagnoseResponse", { enumerable: true, get: function () { return troubleshooting_helper_js_1.diagnoseResponse; } });
|
|
97
|
-
Object.defineProperty(exports, "supportsJSONMode", { enumerable: true, get: function () { return troubleshooting_helper_js_1.supportsJSONMode; } });
|
|
98
|
-
Object.defineProperty(exports, "createTestAIRequest", { enumerable: true, get: function () { return troubleshooting_helper_js_1.createTestAIRequest; } });
|
|
99
|
-
Object.defineProperty(exports, "createValidationTestCases", { enumerable: true, get: function () { return troubleshooting_helper_js_1.createValidationTestCases; } });
|
|
100
|
-
Object.defineProperty(exports, "runValidationTests", { enumerable: true, get: function () { return troubleshooting_helper_js_1.runValidationTests; } });
|
|
101
|
-
Object.defineProperty(exports, "formatDiagnostic", { enumerable: true, get: function () { return troubleshooting_helper_js_1.formatDiagnostic; } });
|
|
102
|
-
Object.defineProperty(exports, "assertValidAIRequest", { enumerable: true, get: function () { return troubleshooting_helper_js_1.assertValidAIRequest; } });
|
|
39
|
+
export { validateAIRequest, validateJSON, extractJSON, validateResponse, diagnoseRequest, diagnoseResponse, supportsJSONMode, createTestAIRequest, createValidationTestCases, runValidationTests, formatDiagnostic, assertValidAIRequest } from './troubleshooting-helper.js';
|
|
103
40
|
// Export object types library
|
|
104
|
-
|
|
105
|
-
Object.defineProperty(exports, "OBJECT_TYPES_LIBRARY", { enumerable: true, get: function () { return object_types_library_js_1.OBJECT_TYPES_LIBRARY; } });
|
|
106
|
-
Object.defineProperty(exports, "getObjectType", { enumerable: true, get: function () { return object_types_library_js_1.getObjectType; } });
|
|
107
|
-
Object.defineProperty(exports, "getObjectTypesForAgent", { enumerable: true, get: function () { return object_types_library_js_1.getObjectTypesForAgent; } });
|
|
41
|
+
export { OBJECT_TYPES_LIBRARY, getObjectType, getObjectTypesForAgent } from './object-types-library.js';
|
|
108
42
|
// Re-export outputs library integration functions
|
|
109
|
-
|
|
110
|
-
Object.defineProperty(exports, "initializeObjectTypesLibrary", { enumerable: true, get: function () { return object_types_library_integration_js_1.initializeObjectTypesLibrary; } });
|
|
111
|
-
Object.defineProperty(exports, "getObjectTypesLibrary", { enumerable: true, get: function () { return object_types_library_integration_js_1.getObjectTypesLibrary; } });
|
|
112
|
-
Object.defineProperty(exports, "resetObjectTypesLibrary", { enumerable: true, get: function () { return object_types_library_integration_js_1.resetObjectTypesLibrary; } });
|
|
43
|
+
export { initializeObjectTypesLibrary, getObjectTypesLibrary, resetObjectTypesLibrary } from './object-types-library-integration.js';
|
|
113
44
|
// Re-export outputs library types and utilities for convenience
|
|
114
45
|
// Note: Since we use dynamic imports for the outputs library, these types may not be available
|
|
115
46
|
// at compile time if the package isn't installed. Users can import directly from
|
package/dist-cjs/index.d.ts
CHANGED
|
@@ -17,7 +17,12 @@ export { AIGateway } from './gateway.js';
|
|
|
17
17
|
export { InstructionNotFoundError, InstructionBackendError } from './instruction-errors.js';
|
|
18
18
|
export { autoRegisterProviders } from './gateway-provider-auto-register.js';
|
|
19
19
|
export type { GatewayConfig, ProviderModelRef, ModelConfig, RetryConfig, ChatRequest, AIInvokeRequest, AIRequest, GatewayActionType, GatewayInvokeRejectionMetadata, GatewayTraceRequestIds, GatewayTraceMergedConfig, EnhancedLLMResponse, InstructionMetadata, ValidationRule, TemplateRenderOptions, SmartInputConfig, SmartInputRenderOptions } from './types.js';
|
|
20
|
-
export { attachGatewayInvokeRejectionMetadata, buildInvokeRejectionMetadata, tryExtractRouterLikePayloadFromErrorChain, pickRequestIdsFromRouterLike } from './gateway-utils.js';
|
|
20
|
+
export { attachGatewayInvokeRejectionMetadata, buildInvokeRejectionMetadata, tryExtractRouterLikePayloadFromErrorChain, pickRequestIdsFromRouterLike, resolveActivityCostCompletion, resolveCostCompletionForActivity, resolveCostCompletionWithAiTools, hasNonZeroTokenUsage } from './gateway-utils.js';
|
|
21
|
+
export { getGatewayOperationalMode, isProdGatewayMode, resolveGatewayDefaultModel, parseModelProviderSpec, CODE_DEFAULT_MODEL } from './gateway-mode.js';
|
|
22
|
+
export type { GatewayOperationalMode, GatewayDefaultModelSource, DefaultModelSubstitutionReason, ResolvedGatewayDefault } from './gateway-mode.js';
|
|
23
|
+
export type { ActivityCostStatus, ResolvedActivityCost } from './gateway-utils.js';
|
|
24
|
+
export { contractSpecToFieldKeys, enrichParsedContentForOutputContract, resolveOutputContractFieldKeys } from './output-contract-normalizer.js';
|
|
25
|
+
export type { OutputContractSpec } from './output-contract-normalizer.js';
|
|
21
26
|
export { mergeGatewayAndRequestTemplateRenderOptions, mergeTemplateRenderOptions } from './template-render-merge.js';
|
|
22
27
|
export type { GatewayTemplateRenderRequestSlice } from './template-render-merge.js';
|
|
23
28
|
export { GATEWAY_DUAL_MEMORY_ROOTS, buildMemoryResolutionRootFromWorkingMemory, coalesceMergedInputBucket, extractCallerInputsBag, mapSmartInputPathsInputsToInput, parseLooseJsonObject, prepareWorkingMemoryForTemplateRender, resolveGatewayMemoryPathValue } from './memory-path-resolution.js';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Errors for instruction / prompt template and instructions-block resolution.
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
exports.InstructionBackendError = exports.InstructionNotFoundError = void 0;
|
|
7
|
-
class InstructionNotFoundError extends Error {
|
|
4
|
+
export class InstructionNotFoundError extends Error {
|
|
8
5
|
key;
|
|
9
6
|
backend;
|
|
10
7
|
originalKey;
|
|
@@ -16,8 +13,7 @@ class InstructionNotFoundError extends Error {
|
|
|
16
13
|
this.name = 'InstructionNotFoundError';
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
class InstructionBackendError extends Error {
|
|
16
|
+
export class InstructionBackendError extends Error {
|
|
21
17
|
key;
|
|
22
18
|
backend;
|
|
23
19
|
isRetryable;
|
|
@@ -31,4 +27,3 @@ class InstructionBackendError extends Error {
|
|
|
31
27
|
this.name = 'InstructionBackendError';
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
exports.InstructionBackendError = InstructionBackendError;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Instruction Optimizer Feature
|
|
4
3
|
*
|
|
5
4
|
* Uses AI to analyze and fix poorly-written instructions.
|
|
6
5
|
* This is a meta-feature that uses the AI Gateway (via router) to improve AI instructions.
|
|
7
6
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.optimizeInstructions = optimizeInstructions;
|
|
10
|
-
exports.getFixedInstructions = getFixedInstructions;
|
|
11
|
-
exports.getChangesSummary = getChangesSummary;
|
|
12
|
-
exports.validateTokenPreservation = validateTokenPreservation;
|
|
13
7
|
/**
|
|
14
8
|
* The meta-instructions used to fix other instructions
|
|
15
9
|
* Loaded from instructions-audit.md
|
|
@@ -111,7 +105,7 @@ If the instructions are already well-written, explain that in the analysis and m
|
|
|
111
105
|
* @param options - Optimization options
|
|
112
106
|
* @returns Optimization result with fixed instructions and analysis
|
|
113
107
|
*/
|
|
114
|
-
async function optimizeInstructions(gateway, originalInstructions, options) {
|
|
108
|
+
export async function optimizeInstructions(gateway, originalInstructions, options) {
|
|
115
109
|
// Get internal system action config (instruction optimization)
|
|
116
110
|
const internalConfig = gateway.config?.internalSystemActions?.instructionOptimization;
|
|
117
111
|
const defaultEngine = gateway.config?.defaultEngine || 'openai';
|
|
@@ -257,7 +251,7 @@ async function optimizeInstructions(gateway, originalInstructions, options) {
|
|
|
257
251
|
* @param result - Optimization result
|
|
258
252
|
* @returns Just the complete fixed instructions text
|
|
259
253
|
*/
|
|
260
|
-
function getFixedInstructions(result) {
|
|
254
|
+
export function getFixedInstructions(result) {
|
|
261
255
|
return result.fixed_instructions.complete_text;
|
|
262
256
|
}
|
|
263
257
|
/**
|
|
@@ -266,7 +260,7 @@ function getFixedInstructions(result) {
|
|
|
266
260
|
* @param result - Optimization result
|
|
267
261
|
* @returns Human-readable summary of changes
|
|
268
262
|
*/
|
|
269
|
-
function getChangesSummary(result) {
|
|
263
|
+
export function getChangesSummary(result) {
|
|
270
264
|
const summary = [
|
|
271
265
|
`Quality improved from ${result.quality_improvements.before_score}/10 to ${result.quality_improvements.after_score}/10`,
|
|
272
266
|
`\n${result.quality_improvements.summary}`,
|
|
@@ -286,7 +280,7 @@ function getChangesSummary(result) {
|
|
|
286
280
|
* @param result - Optimization result
|
|
287
281
|
* @returns Object with validation status and any missing tokens
|
|
288
282
|
*/
|
|
289
|
-
function validateTokenPreservation(originalInstructions, result) {
|
|
283
|
+
export function validateTokenPreservation(originalInstructions, result) {
|
|
290
284
|
// Extract tokens from original (matches {{anything}})
|
|
291
285
|
const tokenRegex = /\{\{([^}]+)\}\}/g;
|
|
292
286
|
const originalTokens = new Set();
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Instructions Parser Module
|
|
4
3
|
*
|
|
5
4
|
* Handles template rendering for instruction content using Rendrix (@x12i/rendrix).
|
|
6
5
|
* Separated from instruction resolution to keep concerns clean.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
exports.renderInstructionTemplate = renderInstructionTemplate;
|
|
10
|
-
exports.hasTemplateVariables = hasTemplateVariables;
|
|
11
|
-
exports.extractTemplateVariables = extractTemplateVariables;
|
|
12
|
-
const template_parser_js_1 = require("./template-parser.cjs");
|
|
7
|
+
import { parseTemplate } from './template-parser.js';
|
|
13
8
|
/**
|
|
14
9
|
* Renders instruction templates with variables using Rendrix (@x12i/rendrix)
|
|
15
10
|
*/
|
|
16
|
-
async function renderInstructionTemplate(template, variables = {}, templateRenderOptions, logger) {
|
|
11
|
+
export async function renderInstructionTemplate(template, variables = {}, templateRenderOptions, logger) {
|
|
17
12
|
const startTime = Date.now();
|
|
18
13
|
// Extract memory contexts for Rendrix
|
|
19
14
|
// parseTemplate expects: (template, workingMemory, shortTermMemory?, experienceMemory?, knowledgeMemory?)
|
|
@@ -23,7 +18,7 @@ async function renderInstructionTemplate(template, variables = {}, templateRende
|
|
|
23
18
|
const knowledgeMemory = variables.knowledgeMemory || {};
|
|
24
19
|
// Render template using Rendrix
|
|
25
20
|
// Pass memory contexts as separate parameters, not as a combined object
|
|
26
|
-
const renderedText = await
|
|
21
|
+
const renderedText = await parseTemplate(template, workingMemory, undefined, // taskConfig removed - no longer used
|
|
27
22
|
shortTermMemory, experienceMemory, knowledgeMemory, templateRenderOptions, logger);
|
|
28
23
|
// Combine all memory contexts for return value (for metadata)
|
|
29
24
|
const combinedVariables = {
|
|
@@ -43,14 +38,14 @@ async function renderInstructionTemplate(template, variables = {}, templateRende
|
|
|
43
38
|
/**
|
|
44
39
|
* Checks if a template contains variables that need rendering
|
|
45
40
|
*/
|
|
46
|
-
function hasTemplateVariables(template) {
|
|
41
|
+
export function hasTemplateVariables(template) {
|
|
47
42
|
// Check for double-brace variables like {{variable}}
|
|
48
43
|
return /\{\{[^}]+\}\}/g.test(template);
|
|
49
44
|
}
|
|
50
45
|
/**
|
|
51
46
|
* Extracts variable names from a template
|
|
52
47
|
*/
|
|
53
|
-
function extractTemplateVariables(template) {
|
|
48
|
+
export function extractTemplateVariables(template) {
|
|
54
49
|
const matches = template.match(/\{\{([^}]+)\}\}/g);
|
|
55
50
|
if (!matches)
|
|
56
51
|
return [];
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Logger Factory
|
|
4
3
|
*
|
|
5
4
|
* Creates and configures logxer instances for the gateway
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
exports.createGatewayLogger = createGatewayLogger;
|
|
9
|
-
const logxer_1 = require("@x12i/logxer");
|
|
6
|
+
import { createLogxer } from '@x12i/logxer';
|
|
10
7
|
function resolveDefaultRuntimeIdentity(packageName) {
|
|
11
8
|
const service = process.env.AI_GATEWAY_LOG_SERVICE ?? packageName ?? 'AI_GATEWAY';
|
|
12
9
|
if (!service)
|
|
@@ -23,14 +20,14 @@ function resolveDefaultRuntimeIdentity(packageName) {
|
|
|
23
20
|
* @param config - Logger configuration
|
|
24
21
|
* @returns Configured logger or no-op logger if logging is disabled
|
|
25
22
|
*/
|
|
26
|
-
function createGatewayLogger(config) {
|
|
23
|
+
export function createGatewayLogger(config) {
|
|
27
24
|
if (config.customLogger) {
|
|
28
25
|
return config.customLogger;
|
|
29
26
|
}
|
|
30
27
|
if (!config.enableLogging) {
|
|
31
28
|
return createNoOpLogger();
|
|
32
29
|
}
|
|
33
|
-
return
|
|
30
|
+
return createLogxer({
|
|
34
31
|
packageName: config.packageName || 'AI_GATEWAY',
|
|
35
32
|
envPrefix: config.packageName || 'AI_GATEWAY',
|
|
36
33
|
debugNamespace: 'ai-gateway'
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Dual memory roots `input` (merged MAIN payload) and `inputs` (caller / graph-entry bag).
|
|
4
3
|
* Aligned with @exellix/graph-engine ≥ 5.5.0 resolution rules for template / smart-input paths.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
exports.GATEWAY_DUAL_MEMORY_ROOTS = void 0;
|
|
8
|
-
exports.parseLooseJsonObject = parseLooseJsonObject;
|
|
9
|
-
exports.extractCallerInputsBag = extractCallerInputsBag;
|
|
10
|
-
exports.coalesceMergedInputBucket = coalesceMergedInputBucket;
|
|
11
|
-
exports.resolveGatewayMemoryPathValue = resolveGatewayMemoryPathValue;
|
|
12
|
-
exports.buildMemoryResolutionRootFromWorkingMemory = buildMemoryResolutionRootFromWorkingMemory;
|
|
13
|
-
exports.prepareWorkingMemoryForTemplateRender = prepareWorkingMemoryForTemplateRender;
|
|
14
|
-
exports.mapSmartInputPathsInputsToInput = mapSmartInputPathsInputsToInput;
|
|
15
|
-
exports.GATEWAY_DUAL_MEMORY_ROOTS = ['input', 'inputs'];
|
|
5
|
+
export const GATEWAY_DUAL_MEMORY_ROOTS = ['input', 'inputs'];
|
|
16
6
|
function isPlainObject(value) {
|
|
17
7
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
18
8
|
}
|
|
19
9
|
/**
|
|
20
10
|
* Parse JSON object shapes from strings (matches graph-engine `parseLooseJsonObject`).
|
|
21
11
|
*/
|
|
22
|
-
function parseLooseJsonObject(value) {
|
|
12
|
+
export function parseLooseJsonObject(value) {
|
|
23
13
|
if (isPlainObject(value))
|
|
24
14
|
return value;
|
|
25
15
|
if (typeof value !== 'string')
|
|
@@ -36,14 +26,14 @@ function parseLooseJsonObject(value) {
|
|
|
36
26
|
}
|
|
37
27
|
}
|
|
38
28
|
/** Caller / graph-entry bag from `workingMemory.inputs`. */
|
|
39
|
-
function extractCallerInputsBag(workingMemory) {
|
|
29
|
+
export function extractCallerInputsBag(workingMemory) {
|
|
40
30
|
if (!isPlainObject(workingMemory))
|
|
41
31
|
return undefined;
|
|
42
32
|
const inputs = workingMemory.inputs;
|
|
43
33
|
return isPlainObject(inputs) ? inputs : undefined;
|
|
44
34
|
}
|
|
45
35
|
/** Merged MAIN bucket from `workingMemory.input` (object or parsed JSON string). */
|
|
46
|
-
function coalesceMergedInputBucket(workingMemory) {
|
|
36
|
+
export function coalesceMergedInputBucket(workingMemory) {
|
|
47
37
|
if (!isPlainObject(workingMemory))
|
|
48
38
|
return undefined;
|
|
49
39
|
const raw = workingMemory.input;
|
|
@@ -107,7 +97,7 @@ function mergeBucketViews(primary, fallback) {
|
|
|
107
97
|
* - `input` / `input.*` → merged `input` first, then caller `inputs`
|
|
108
98
|
* - other paths → direct lookup on working memory
|
|
109
99
|
*/
|
|
110
|
-
function resolveGatewayMemoryPathValue(workingMemory, path) {
|
|
100
|
+
export function resolveGatewayMemoryPathValue(workingMemory, path) {
|
|
111
101
|
const trimmed = path.trim();
|
|
112
102
|
if (!trimmed)
|
|
113
103
|
return undefined;
|
|
@@ -146,7 +136,7 @@ function resolveGatewayMemoryPathValue(workingMemory, path) {
|
|
|
146
136
|
* Working-memory view for Rendrix / smart-input: preserves all keys but overlays
|
|
147
137
|
* `input` and `inputs` with dual-root merge views (does not rewrite authored paths).
|
|
148
138
|
*/
|
|
149
|
-
function buildMemoryResolutionRootFromWorkingMemory(workingMemory) {
|
|
139
|
+
export function buildMemoryResolutionRootFromWorkingMemory(workingMemory) {
|
|
150
140
|
if (!isPlainObject(workingMemory))
|
|
151
141
|
return {};
|
|
152
142
|
const inputsBag = extractCallerInputsBag(workingMemory);
|
|
@@ -161,7 +151,7 @@ function buildMemoryResolutionRootFromWorkingMemory(workingMemory) {
|
|
|
161
151
|
* When WM carries `input` and/or `inputs`, return a resolution root for template rendering.
|
|
162
152
|
* Otherwise returns the original reference unchanged.
|
|
163
153
|
*/
|
|
164
|
-
function prepareWorkingMemoryForTemplateRender(workingMemory) {
|
|
154
|
+
export function prepareWorkingMemoryForTemplateRender(workingMemory) {
|
|
165
155
|
if (!isPlainObject(workingMemory))
|
|
166
156
|
return workingMemory;
|
|
167
157
|
if (workingMemory.input === undefined && workingMemory.inputs === undefined) {
|
|
@@ -170,7 +160,7 @@ function prepareWorkingMemoryForTemplateRender(workingMemory) {
|
|
|
170
160
|
return buildMemoryResolutionRootFromWorkingMemory(workingMemory);
|
|
171
161
|
}
|
|
172
162
|
/** Optional migration: rewrite `inputs.*` smart-input / memory paths to `input.*`. */
|
|
173
|
-
function mapSmartInputPathsInputsToInput(paths) {
|
|
163
|
+
export function mapSmartInputPathsInputsToInput(paths) {
|
|
174
164
|
return paths.map((p) => {
|
|
175
165
|
const t = p.trim();
|
|
176
166
|
if (t === 'inputs')
|
|
@@ -1,47 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Message Builder
|
|
4
3
|
* Direct message construction without request-builder package dependency
|
|
5
4
|
* Handles flex-md format exclusively
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.buildMessages = buildMessages;
|
|
42
|
-
const template_parser_js_1 = require("./template-parser.cjs");
|
|
43
|
-
const template_render_merge_js_1 = require("./template-render-merge.cjs");
|
|
44
|
-
const gateway_instructions_js_1 = require("./gateway-instructions.cjs");
|
|
6
|
+
import { parseTemplate } from './template-parser.js';
|
|
7
|
+
import { mergeGatewayAndRequestTemplateRenderOptions } from './template-render-merge.js';
|
|
8
|
+
import { resolveNestedInstructionsBlock } from './gateway-instructions.js';
|
|
45
9
|
// Type guard
|
|
46
10
|
// AIRequest is distinguished by having primaryObjectType or objectTypes
|
|
47
11
|
// ChatRequest does not have these fields
|
|
@@ -95,7 +59,7 @@ async function buildInputRecognitionRules(request, config, options) {
|
|
|
95
59
|
}
|
|
96
60
|
// If direct access didn't work, try merged inline overrides / nested defaults
|
|
97
61
|
if (!rule) {
|
|
98
|
-
rule = await
|
|
62
|
+
rule = await resolveNestedInstructionsBlock(rulePath, request.agentId || '', request.taskTypeId, blockContext);
|
|
99
63
|
}
|
|
100
64
|
if (rule && typeof rule === 'string' && rule.trim() !== '') {
|
|
101
65
|
rules.push(rule);
|
|
@@ -157,7 +121,7 @@ async function buildReinforcementRules(request, config, options) {
|
|
|
157
121
|
}
|
|
158
122
|
// If direct access didn't work, try merged inline overrides / nested defaults
|
|
159
123
|
if (!rule) {
|
|
160
|
-
rule = await
|
|
124
|
+
rule = await resolveNestedInstructionsBlock(rulePath, request.agentId || '', request.taskTypeId, blockContext);
|
|
161
125
|
}
|
|
162
126
|
if (rule && typeof rule === 'string' && rule.trim() !== '') {
|
|
163
127
|
rules.push(rule);
|
|
@@ -238,7 +202,7 @@ async function buildUserMessage(request, config, shortTermMemory, experienceMemo
|
|
|
238
202
|
});
|
|
239
203
|
throw err;
|
|
240
204
|
}
|
|
241
|
-
const parsedPrompt = await
|
|
205
|
+
const parsedPrompt = await parseTemplate(request.prompt, request.workingMemory, undefined, shortTermMemory, experienceMemory, knowledgeMemory, templateRenderOptions, logger);
|
|
242
206
|
if (!parsedPrompt || parsedPrompt.trim() === '') {
|
|
243
207
|
const workingMemoryObj = request.workingMemory;
|
|
244
208
|
const err = new Error(`Prompt template rendered to empty string. This may indicate missing template variables or empty template content.`);
|
|
@@ -354,7 +318,7 @@ async function hasFlexMdContract(instructionsText, complianceLevel = 'L0') {
|
|
|
354
318
|
}
|
|
355
319
|
try {
|
|
356
320
|
// Try to use flex-md SDK to validate compliance
|
|
357
|
-
const { loadFlexMd } = await
|
|
321
|
+
const { loadFlexMd } = await import('./flex-md-loader.js');
|
|
358
322
|
const flexMd = await loadFlexMd();
|
|
359
323
|
// Check if validateMarkdownAgainstOfs is available
|
|
360
324
|
if (flexMd.validateMarkdownAgainstOfs && typeof flexMd.validateMarkdownAgainstOfs === 'function') {
|
|
@@ -404,7 +368,7 @@ async function hasFlexMdContract(instructionsText, complianceLevel = 'L0') {
|
|
|
404
368
|
/**
|
|
405
369
|
* Main function to build messages
|
|
406
370
|
*/
|
|
407
|
-
async function buildMessages(request, config, options = {}) {
|
|
371
|
+
export async function buildMessages(request, config, options = {}) {
|
|
408
372
|
const { useSystemContextFallback = true, includeInputRecognition = true, includeReinforcement = true, parsedSnapshot } = options;
|
|
409
373
|
const { logger } = config;
|
|
410
374
|
const messages = [];
|
|
@@ -415,7 +379,7 @@ async function buildMessages(request, config, options = {}) {
|
|
|
415
379
|
const shortTermMemory = options.shortTermMemory;
|
|
416
380
|
const experienceMemory = options.experienceMemory;
|
|
417
381
|
const knowledgeMemory = options.knowledgeMemory;
|
|
418
|
-
const templateRenderOptions =
|
|
382
|
+
const templateRenderOptions = mergeGatewayAndRequestTemplateRenderOptions(config.templateRendering, request);
|
|
419
383
|
if (request.instructions) {
|
|
420
384
|
if (typeof request.instructions === 'string') {
|
|
421
385
|
logger.info('Using instructions as template text', {
|
|
@@ -436,7 +400,7 @@ async function buildMessages(request, config, options = {}) {
|
|
|
436
400
|
// Step 2: Parse instructions template with full memory context
|
|
437
401
|
// Rendrix handles token resolution, so we just parse directly
|
|
438
402
|
if (instructionsText) {
|
|
439
|
-
instructionsText = await
|
|
403
|
+
instructionsText = await parseTemplate(instructionsText, request.workingMemory, undefined, // taskConfig removed - no longer used
|
|
440
404
|
shortTermMemory, experienceMemory, knowledgeMemory, templateRenderOptions, logger);
|
|
441
405
|
}
|
|
442
406
|
// Step 4: Add input recognition rules
|
|
@@ -485,7 +449,7 @@ async function buildMessages(request, config, options = {}) {
|
|
|
485
449
|
// Step 7: Add context (if provided) with full memory context
|
|
486
450
|
if (request.context) {
|
|
487
451
|
const contextText = typeof request.context === 'string' ? request.context : JSON.stringify(request.context);
|
|
488
|
-
const parsedContext = await
|
|
452
|
+
const parsedContext = await parseTemplate(contextText, request.workingMemory, undefined, // taskConfig removed - no longer used
|
|
489
453
|
shortTermMemory, experienceMemory, knowledgeMemory, templateRenderOptions, logger);
|
|
490
454
|
if (parsedContext && parsedContext.trim() !== '') {
|
|
491
455
|
messages.push({
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Object Types Library Integration - REMOVED
|
|
4
3
|
*
|
|
5
4
|
* The @x12i/outputs-library dependency has been removed.
|
|
6
5
|
* This file now provides stub functions for backward compatibility.
|
|
7
6
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.initializeObjectTypesLibrary = initializeObjectTypesLibrary;
|
|
10
|
-
exports.getObjectTypesLibrary = getObjectTypesLibrary;
|
|
11
|
-
exports.resetObjectTypesLibrary = resetObjectTypesLibrary;
|
|
12
7
|
/**
|
|
13
8
|
* Initialize ObjectTypesLibrary singleton - STUB
|
|
14
9
|
* Since ObjectTypesLibrary is removed, this function does nothing
|
|
15
10
|
*/
|
|
16
|
-
async function initializeObjectTypesLibrary(config, logger) {
|
|
11
|
+
export async function initializeObjectTypesLibrary(config, logger) {
|
|
17
12
|
logger.info('ObjectTypesLibrary dependency removed - using simplified object type handling');
|
|
18
13
|
return null;
|
|
19
14
|
}
|
|
@@ -21,12 +16,12 @@ async function initializeObjectTypesLibrary(config, logger) {
|
|
|
21
16
|
* Get the current ObjectTypesLibrary instance - STUB
|
|
22
17
|
* Always returns null since the library is removed
|
|
23
18
|
*/
|
|
24
|
-
function getObjectTypesLibrary() {
|
|
19
|
+
export function getObjectTypesLibrary() {
|
|
25
20
|
return null;
|
|
26
21
|
}
|
|
27
22
|
/**
|
|
28
23
|
* Reset the library instance (for testing) - STUB
|
|
29
24
|
*/
|
|
30
|
-
function resetObjectTypesLibrary() {
|
|
25
|
+
export function resetObjectTypesLibrary() {
|
|
31
26
|
// Nothing to reset since library is removed
|
|
32
27
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Object Types Library
|
|
4
3
|
*
|
|
5
4
|
* Standard object type definitions for AI Gateway structured outputs.
|
|
6
5
|
* Each agent type has corresponding object types with JSON schemas.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
exports.OBJECT_TYPES_LIBRARY = void 0;
|
|
10
|
-
exports.getObjectType = getObjectType;
|
|
11
|
-
exports.getObjectTypesForAgent = getObjectTypesForAgent;
|
|
12
|
-
exports.OBJECT_TYPES_LIBRARY = {
|
|
7
|
+
export const OBJECT_TYPES_LIBRARY = {
|
|
13
8
|
/**
|
|
14
9
|
* AI Reasoner - General reasoning and analysis
|
|
15
10
|
*/
|
|
@@ -194,13 +189,13 @@ exports.OBJECT_TYPES_LIBRARY = {
|
|
|
194
189
|
/**
|
|
195
190
|
* Get object type definition by name
|
|
196
191
|
*/
|
|
197
|
-
function getObjectType(typeName) {
|
|
198
|
-
return
|
|
192
|
+
export function getObjectType(typeName) {
|
|
193
|
+
return OBJECT_TYPES_LIBRARY[typeName];
|
|
199
194
|
}
|
|
200
195
|
/**
|
|
201
196
|
* Get all object types for a specific agent type
|
|
202
197
|
*/
|
|
203
|
-
function getObjectTypesForAgent(agentType) {
|
|
198
|
+
export function getObjectTypesForAgent(agentType) {
|
|
204
199
|
const mapping = {
|
|
205
200
|
'ai-reasoner': ['reasoning-result', 'classification', 'question-answer'],
|
|
206
201
|
'ai-auditor': ['audit-report'],
|
|
@@ -211,5 +206,5 @@ function getObjectTypesForAgent(agentType) {
|
|
|
211
206
|
'chat': [] // Chat doesn't use structured outputs
|
|
212
207
|
};
|
|
213
208
|
const typeNames = mapping[agentType] || [];
|
|
214
|
-
return typeNames.map(name =>
|
|
209
|
+
return typeNames.map(name => OBJECT_TYPES_LIBRARY[name]);
|
|
215
210
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Output Structure Auditor
|
|
4
3
|
*
|
|
5
4
|
* Audits the structure of parsed output against the expected schema.
|
|
6
5
|
* Provides detailed analysis of what fields are present, missing, or extra.
|
|
7
6
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.auditOutputStructure = auditOutputStructure;
|
|
10
7
|
/**
|
|
11
8
|
* Audits the structure of parsed output against the expected schema
|
|
12
9
|
*
|
|
@@ -14,7 +11,7 @@ exports.auditOutputStructure = auditOutputStructure;
|
|
|
14
11
|
* @param schema - The JSON schema to compare against
|
|
15
12
|
* @returns Audit result with detailed structure analysis
|
|
16
13
|
*/
|
|
17
|
-
function auditOutputStructure(parsedOutput, schema) {
|
|
14
|
+
export function auditOutputStructure(parsedOutput, schema) {
|
|
18
15
|
// Only audit if we have both parsedOutput and schema
|
|
19
16
|
if (!parsedOutput || !schema) {
|
|
20
17
|
return undefined;
|