@x12i/ai-gateway 7.9.1 → 9.0.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 +107 -94
- package/dist/activity-manager.d.ts +3 -1
- package/dist/activity-manager.js +48 -17
- package/dist/content-normalizer/content-normalizer.d.ts +2 -1
- package/dist/content-normalizer/content-normalizer.js +5 -5
- package/dist/flex-md-loader.d.ts +2 -1
- package/dist/flex-md-loader.js +18 -15
- package/dist/gateway-config.d.ts +4 -4
- package/dist/gateway-config.js +21 -25
- package/dist/gateway-conversion.js +2 -2
- package/dist/gateway-log-meta.d.ts +15 -0
- package/dist/gateway-log-meta.js +36 -0
- package/dist/gateway-memory.js +6 -6
- package/dist/gateway-messages.js +4 -4
- package/dist/gateway-meta.d.ts +3 -1
- package/dist/gateway-meta.js +9 -2
- package/dist/gateway-utils.js +9 -9
- package/dist/gateway-validation.js +9 -0
- package/dist/gateway.js +32 -33
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/instruction-optimizer.d.ts +6 -1
- package/dist/instruction-optimizer.js +10 -3
- package/dist/instructions-parser.d.ts +2 -1
- package/dist/instructions-parser.js +2 -2
- package/dist/logger-factory.js +12 -1
- package/dist/message-builder.js +19 -19
- package/dist/request-report-generator.js +1 -1
- package/dist/template-parser.d.ts +3 -1
- package/dist/template-parser.js +3 -2
- package/dist/troubleshooting-helper.d.ts +1 -1
- package/dist/troubleshooting-helper.js +2 -2
- package/dist/types.d.ts +16 -10
- package/dist-cjs/activity-manager.cjs +48 -17
- package/dist-cjs/activity-manager.d.ts +3 -1
- package/dist-cjs/content-normalizer/content-normalizer.cjs +5 -5
- package/dist-cjs/content-normalizer/content-normalizer.d.ts +2 -1
- package/dist-cjs/flex-md-loader.cjs +18 -15
- package/dist-cjs/flex-md-loader.d.ts +2 -1
- package/dist-cjs/gateway-config.cjs +21 -25
- package/dist-cjs/gateway-config.d.ts +4 -4
- package/dist-cjs/gateway-conversion.cjs +2 -2
- package/dist-cjs/gateway-log-meta.cjs +41 -0
- package/dist-cjs/gateway-log-meta.d.ts +15 -0
- package/dist-cjs/gateway-memory.cjs +6 -6
- package/dist-cjs/gateway-messages.cjs +4 -4
- package/dist-cjs/gateway-meta.cjs +9 -2
- package/dist-cjs/gateway-meta.d.ts +3 -1
- package/dist-cjs/gateway-utils.cjs +9 -9
- package/dist-cjs/gateway-validation.cjs +9 -0
- package/dist-cjs/gateway.cjs +31 -32
- package/dist-cjs/index.cjs +6 -1
- package/dist-cjs/index.d.ts +3 -2
- package/dist-cjs/instruction-optimizer.cjs +10 -3
- package/dist-cjs/instruction-optimizer.d.ts +6 -1
- package/dist-cjs/instructions-parser.cjs +2 -2
- package/dist-cjs/instructions-parser.d.ts +2 -1
- package/dist-cjs/logger-factory.cjs +12 -1
- package/dist-cjs/message-builder.cjs +19 -19
- package/dist-cjs/request-report-generator.cjs +1 -1
- package/dist-cjs/template-parser.cjs +3 -2
- package/dist-cjs/template-parser.d.ts +3 -1
- package/dist-cjs/troubleshooting-helper.cjs +2 -2
- package/dist-cjs/troubleshooting-helper.d.ts +1 -1
- package/dist-cjs/types.d.ts +16 -10
- package/package.json +3 -3
|
@@ -600,12 +600,12 @@ function formatDiagnostic(diagnostic) {
|
|
|
600
600
|
/**
|
|
601
601
|
* Quick validation helper - throws if invalid
|
|
602
602
|
*/
|
|
603
|
-
function assertValidAIRequest(request) {
|
|
603
|
+
function assertValidAIRequest(request, logger) {
|
|
604
604
|
const validation = validateAIRequest(request);
|
|
605
605
|
if (!validation.valid) {
|
|
606
606
|
throw new Error(`AIRequest validation failed:\n${validation.errors.join('\n')}`);
|
|
607
607
|
}
|
|
608
608
|
if (validation.warnings.length > 0) {
|
|
609
|
-
|
|
609
|
+
logger?.warn('AIRequest validation warnings', { warnings: validation.warnings });
|
|
610
610
|
}
|
|
611
611
|
}
|
|
@@ -120,4 +120,4 @@ export declare function formatDiagnostic(diagnostic: DiagnosticInfo): string;
|
|
|
120
120
|
/**
|
|
121
121
|
* Quick validation helper - throws if invalid
|
|
122
122
|
*/
|
|
123
|
-
export declare function assertValidAIRequest(request: Partial<AIRequest
|
|
123
|
+
export declare function assertValidAIRequest(request: Partial<AIRequest>, logger?: import('@x12i/logxer').Logxer): void;
|
package/dist-cjs/types.d.ts
CHANGED
|
@@ -32,11 +32,18 @@ export type ActivityIdentity = {
|
|
|
32
32
|
};
|
|
33
33
|
/** Gateway-level request correlation ID. */
|
|
34
34
|
aiRequestId: string;
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Upstream job identifier — must be supplied on `request.identity` only.
|
|
37
|
+
* The gateway copies this value as-is; it never generates or mutates it.
|
|
38
|
+
*/
|
|
39
|
+
jobId: string;
|
|
37
40
|
jobTypeId?: string;
|
|
38
41
|
agentId: string;
|
|
39
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Upstream task identifier — must be supplied on `request.identity` only.
|
|
44
|
+
* The gateway copies this value as-is; it never generates or mutates it.
|
|
45
|
+
*/
|
|
46
|
+
taskId: string;
|
|
40
47
|
taskTypeId?: string;
|
|
41
48
|
/** Graph/node linkage (optional, used by activity identity grouping). */
|
|
42
49
|
graphId?: string;
|
|
@@ -413,7 +420,7 @@ export interface GatewayConfig extends Omit<RouterConfig, 'defaultEngine' | 'log
|
|
|
413
420
|
* Extends LLMRequest but omits 'messages' and 'input' to allow custom message handling
|
|
414
421
|
* and make input optional (router may require it, but gateway allows it to be optional)
|
|
415
422
|
*/
|
|
416
|
-
interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input'> {
|
|
423
|
+
interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input' | 'request' | 'mode'> {
|
|
417
424
|
/**
|
|
418
425
|
* AI request ID - Required for all invocations and activity tracking
|
|
419
426
|
*/
|
|
@@ -422,15 +429,14 @@ interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input'> {
|
|
|
422
429
|
jobId?: string;
|
|
423
430
|
/**
|
|
424
431
|
* Optional top-level run/session id for Activix. Prefer `identity.sessionId`; if both are set they must match.
|
|
425
|
-
* When omitted, `ActivityManager` resolves session from `identity.sessionId`, then `jobId`, then `aiRequestId`.
|
|
432
|
+
* When omitted, `ActivityManager` resolves session from `identity.sessionId`, then `identity.jobId`, then `aiRequestId`.
|
|
426
433
|
*/
|
|
427
434
|
sessionId?: string;
|
|
428
435
|
/**
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* the gateway normalizes and attaches a full envelope (`ensureGatewayRequestIdentity` / activity tracking).
|
|
436
|
+
* Mandatory runtime identity from the upstream client (job/task correlation, Activix `runContext`).
|
|
437
|
+
* Must include at least `jobId` and `taskId` as non-empty strings; the gateway never invents these.
|
|
432
438
|
*/
|
|
433
|
-
identity
|
|
439
|
+
identity: ActivityIdentity & Record<string, unknown>;
|
|
434
440
|
/**
|
|
435
441
|
* Job type ID (optional) - Short ID or hash to identify recurring job types
|
|
436
442
|
* Best practice: Use MD5 hash of the job type string for consistent job identification
|
|
@@ -459,7 +465,7 @@ interface BaseLLMRequest extends Omit<LLMRequest, 'messages' | 'input'> {
|
|
|
459
465
|
*/
|
|
460
466
|
instructions: string;
|
|
461
467
|
/**
|
|
462
|
-
*
|
|
468
|
+
* @deprecated Prefer `identity.taskId`. The gateway does not copy this into `identity`.
|
|
463
469
|
*/
|
|
464
470
|
taskId?: string;
|
|
465
471
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x12i/ai-gateway",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "AI Gateway - Unified interface for LLM provider routing and management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@x12i/rendrix": "^4.2.0",
|
|
65
65
|
"@aws-sdk/s3-request-presigner": "^3.953.0",
|
|
66
66
|
"@x12i/env": "^4.0.1",
|
|
67
|
-
"@x12i/logxer": "^4.
|
|
68
|
-
"@x12i/activix": "^6.
|
|
67
|
+
"@x12i/logxer": "^4.2.1",
|
|
68
|
+
"@x12i/activix": "^6.5.1",
|
|
69
69
|
"@x12i/flex-md": "^4.8.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|