@zuplo/runtime 7.4.7 → 7.5.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.
- package/out/esm/{chunk-XIFGUD6K.js → chunk-LVTBALLF.js} +103 -97
- package/out/esm/chunk-LVTBALLF.js.map +1 -0
- package/out/esm/index.js +1 -1
- package/out/esm/index.js.map +1 -1
- package/out/esm/mcp-gateway/index.js +1 -1
- package/out/esm/mcp-gateway/index.js.map +1 -1
- package/out/types/index.d.ts +253 -0
- package/package.json +1 -1
- package/out/esm/chunk-XIFGUD6K.js.map +0 -1
- /package/out/esm/{chunk-XIFGUD6K.js.LEGAL.txt → chunk-LVTBALLF.js.LEGAL.txt} +0 -0
package/out/types/index.d.ts
CHANGED
|
@@ -1065,6 +1065,154 @@ export declare interface AIGatewaySemanticCacheV2InboundPolicyOptions {
|
|
|
1065
1065
|
onUnknownShape?: OnUnknownShape_2;
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
+
/**
|
|
1069
|
+
* Reads and writes the Smart Router result for an AI Gateway request.
|
|
1070
|
+
*
|
|
1071
|
+
* The built-in Smart Router policy `set()`s this after a successful
|
|
1072
|
+
* classification. Custom policies can `get()` it later in the same request,
|
|
1073
|
+
* or `set()` a compatible result of their own.
|
|
1074
|
+
*
|
|
1075
|
+
* @public
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```typescript
|
|
1078
|
+
* import { AIGatewaySmartRouter } from "@zuplo/runtime";
|
|
1079
|
+
*
|
|
1080
|
+
* const result = AIGatewaySmartRouter.get(context);
|
|
1081
|
+
* if (result?.profile.intent === "code") {
|
|
1082
|
+
* // ...
|
|
1083
|
+
* }
|
|
1084
|
+
* ```
|
|
1085
|
+
*/
|
|
1086
|
+
export declare const AIGatewaySmartRouter: {
|
|
1087
|
+
set(context: ZuploContext, result: AIGatewaySmartRouterResult): void;
|
|
1088
|
+
get(context: ZuploContext): AIGatewaySmartRouterResult | undefined;
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Prompt-complexity label produced by Smart Router.
|
|
1093
|
+
*
|
|
1094
|
+
* @public
|
|
1095
|
+
*/
|
|
1096
|
+
export declare type AIGatewaySmartRouterComplexity = "low" | "medium" | "high";
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Smart Router Inbound Policy for the AI Gateway
|
|
1100
|
+
* @title Smart Router
|
|
1101
|
+
* @product ai-gateway
|
|
1102
|
+
* @requiresAI
|
|
1103
|
+
*
|
|
1104
|
+
* Classifies the last user prompt by calling a dedicated classifier AI
|
|
1105
|
+
* Gateway app, stores the result on `AIGatewaySmartRouter`, and
|
|
1106
|
+
* optionally overwrites completions routing from `modelsByComplexity`.
|
|
1107
|
+
* Classification failures, timeouts, and invalid options fail open: the
|
|
1108
|
+
* original request is forwarded.
|
|
1109
|
+
*
|
|
1110
|
+
* @param request - The ZuploRequest
|
|
1111
|
+
* @param context - The ZuploContext
|
|
1112
|
+
* @param options - The policy options set in policies.json
|
|
1113
|
+
* @param policyName - The name of the policy as set in policies.json
|
|
1114
|
+
* @returns A Request or a Response
|
|
1115
|
+
*/
|
|
1116
|
+
export declare function AIGatewaySmartRouterInboundPolicy(
|
|
1117
|
+
request: ZuploRequest,
|
|
1118
|
+
context: ZuploContext,
|
|
1119
|
+
unparsedOptions: unknown,
|
|
1120
|
+
policyName: string
|
|
1121
|
+
): Promise<ZuploRequest | Response>;
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Options for the Smart Router policy: classify the last user prompt with a dedicated classifier AI Gateway app, then optionally route by complexity.
|
|
1125
|
+
* @public
|
|
1126
|
+
*/
|
|
1127
|
+
export declare interface AIGatewaySmartRouterInboundPolicyOptions {
|
|
1128
|
+
classifierAppID: ClassifierAppID;
|
|
1129
|
+
classifierAppApiKey: ClassifierAppAPIKey;
|
|
1130
|
+
classifierModel: ClassifierModel;
|
|
1131
|
+
smartRoutingEnabled?: SmartRoutingEnabled;
|
|
1132
|
+
modelsByComplexity?: ModelsByComplexity;
|
|
1133
|
+
intents?: Intents;
|
|
1134
|
+
classifierPrompt?: ClassifierPrompt;
|
|
1135
|
+
minConfidenceForRouting?: MinimumConfidenceForRouting;
|
|
1136
|
+
classifierTimeoutMs?: ClassifierTimeoutMs;
|
|
1137
|
+
maxPromptChars?: MaxPromptCharacters;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Structured classification of the last user prompt.
|
|
1142
|
+
*
|
|
1143
|
+
* @public
|
|
1144
|
+
*/
|
|
1145
|
+
export declare interface AIGatewaySmartRouterProfile {
|
|
1146
|
+
intent: string;
|
|
1147
|
+
complexity: AIGatewaySmartRouterComplexity;
|
|
1148
|
+
confidence: number;
|
|
1149
|
+
reasons: string[];
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Where the classified text was taken from on the request.
|
|
1154
|
+
*
|
|
1155
|
+
* @public
|
|
1156
|
+
*/
|
|
1157
|
+
export declare type AIGatewaySmartRouterPromptSource = "user" | "prior-user";
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Why Smart Router did or did not change the request's model.
|
|
1161
|
+
*
|
|
1162
|
+
* @public
|
|
1163
|
+
*/
|
|
1164
|
+
export declare type AIGatewaySmartRouterReason =
|
|
1165
|
+
| "applied"
|
|
1166
|
+
| "disabled"
|
|
1167
|
+
| "low-confidence"
|
|
1168
|
+
| "no-model"
|
|
1169
|
+
| "internal-error"
|
|
1170
|
+
| "unknown-intent";
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Result produced by the Smart Router policy for the current request.
|
|
1174
|
+
* Custom inbound policies can read this after Smart Router runs.
|
|
1175
|
+
*
|
|
1176
|
+
* @public
|
|
1177
|
+
*/
|
|
1178
|
+
export declare interface AIGatewaySmartRouterResult {
|
|
1179
|
+
profile: AIGatewaySmartRouterProfile;
|
|
1180
|
+
usage: AIGatewaySmartRouterTokenUsage;
|
|
1181
|
+
classifierModel: string;
|
|
1182
|
+
routing: AIGatewaySmartRouterRoutingDecision;
|
|
1183
|
+
durationMs: number;
|
|
1184
|
+
promptSource: AIGatewaySmartRouterPromptSource;
|
|
1185
|
+
promptLength: number;
|
|
1186
|
+
promptTruncated: boolean;
|
|
1187
|
+
unknownIntent: boolean;
|
|
1188
|
+
smartRouting: {
|
|
1189
|
+
enabled: boolean;
|
|
1190
|
+
applied: boolean;
|
|
1191
|
+
reason: AIGatewaySmartRouterReason;
|
|
1192
|
+
minConfidence: number;
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* Model chosen from `modelsByComplexity` for the classified complexity, if any.
|
|
1198
|
+
*
|
|
1199
|
+
* @public
|
|
1200
|
+
*/
|
|
1201
|
+
export declare interface AIGatewaySmartRouterRoutingDecision {
|
|
1202
|
+
model?: string;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Classifier token usage reported by the classifier chat/completions call.
|
|
1207
|
+
*
|
|
1208
|
+
* @public
|
|
1209
|
+
*/
|
|
1210
|
+
export declare interface AIGatewaySmartRouterTokenUsage {
|
|
1211
|
+
promptTokens: number;
|
|
1212
|
+
completionTokens: number;
|
|
1213
|
+
totalTokens: number;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1068
1216
|
/**
|
|
1069
1217
|
* The options for this policy.
|
|
1070
1218
|
* @public
|
|
@@ -3589,6 +3737,36 @@ declare type Claim = string;
|
|
|
3589
3737
|
*/
|
|
3590
3738
|
declare type ClaimCheck = EqualsRule | InRule | StartsWithRule;
|
|
3591
3739
|
|
|
3740
|
+
/**
|
|
3741
|
+
* API key sent as `Authorization: Bearer` when invoking the classifier app.
|
|
3742
|
+
* @public
|
|
3743
|
+
*/
|
|
3744
|
+
declare type ClassifierAppAPIKey = string;
|
|
3745
|
+
|
|
3746
|
+
/**
|
|
3747
|
+
* The AI Gateway application id whose `/v1/chat/completions` route runs the classifier. The policy calls `/{classifierAppID}/v1/chat/completions` via `context.invokeRoute`.
|
|
3748
|
+
* @public
|
|
3749
|
+
*/
|
|
3750
|
+
declare type ClassifierAppID = string;
|
|
3751
|
+
|
|
3752
|
+
/**
|
|
3753
|
+
* The `providerName/model` reference the classifier chat/completions request should use.
|
|
3754
|
+
* @public
|
|
3755
|
+
*/
|
|
3756
|
+
declare type ClassifierModel = string;
|
|
3757
|
+
|
|
3758
|
+
/**
|
|
3759
|
+
* System prompt for the classifier. If it includes `{{intents}}`, that placeholder is replaced with the configured intent id/description list. A string or an array of lines (joined with newlines). Omit to use the built-in classifier prompt.
|
|
3760
|
+
* @public
|
|
3761
|
+
*/
|
|
3762
|
+
declare type ClassifierPrompt = string | [string, ...string[]];
|
|
3763
|
+
|
|
3764
|
+
/**
|
|
3765
|
+
* How long to wait for the classifier `invokeRoute` call before skipping classification and forwarding the original request.
|
|
3766
|
+
* @public
|
|
3767
|
+
*/
|
|
3768
|
+
declare type ClassifierTimeoutMs = number;
|
|
3769
|
+
|
|
3592
3770
|
/**
|
|
3593
3771
|
* Removes all headers from the incoming request except for those in the exclude list.
|
|
3594
3772
|
*
|
|
@@ -5778,6 +5956,12 @@ declare interface HeaderCredentialsConfig {
|
|
|
5778
5956
|
headerName: string;
|
|
5779
5957
|
}
|
|
5780
5958
|
|
|
5959
|
+
/**
|
|
5960
|
+
* Model used for prompts classified as high complexity.
|
|
5961
|
+
* @public
|
|
5962
|
+
*/
|
|
5963
|
+
declare type HighComplexityModel = string;
|
|
5964
|
+
|
|
5781
5965
|
/**
|
|
5782
5966
|
* Sets HTTP deprecation headers on the outgoing response following the IETF
|
|
5783
5967
|
* HTTP Deprecation Header standard. Supports the Deprecation, Sunset, and Link
|
|
@@ -7654,6 +7838,35 @@ declare interface InRule {
|
|
|
7654
7838
|
in: [string | number | boolean, ...(string | number | boolean)[]];
|
|
7655
7839
|
}
|
|
7656
7840
|
|
|
7841
|
+
/**
|
|
7842
|
+
* Short description shown to the classifier for this intent.
|
|
7843
|
+
* @public
|
|
7844
|
+
*/
|
|
7845
|
+
declare type IntentDescription = string;
|
|
7846
|
+
|
|
7847
|
+
/**
|
|
7848
|
+
* Stable intent identifier written into the classifier JSON schema enum.
|
|
7849
|
+
* @public
|
|
7850
|
+
*/
|
|
7851
|
+
declare type IntentID = string;
|
|
7852
|
+
|
|
7853
|
+
/**
|
|
7854
|
+
* Labels the classifier may assign. Used to build the JSON schema enum and injected into `classifierPrompt` at `{{intents}}`. Omit to use the built-in taxonomy (code, summarization, translation, qa, conversation, classification, creative_writing, agentic, document_qa, other).
|
|
7855
|
+
*
|
|
7856
|
+
* @minItems 1
|
|
7857
|
+
* @public
|
|
7858
|
+
*/
|
|
7859
|
+
declare type Intents = [
|
|
7860
|
+
{
|
|
7861
|
+
id: IntentID;
|
|
7862
|
+
description: IntentDescription;
|
|
7863
|
+
},
|
|
7864
|
+
...{
|
|
7865
|
+
id: IntentID;
|
|
7866
|
+
description: IntentDescription;
|
|
7867
|
+
}[],
|
|
7868
|
+
];
|
|
7869
|
+
|
|
7657
7870
|
/**
|
|
7658
7871
|
* Restricts which client IP addresses can call a route using an allow list, a
|
|
7659
7872
|
* deny list, or both. Entries are individual IP addresses or CIDR ranges, in
|
|
@@ -8298,12 +8511,24 @@ declare type LokiTransportVersion = 1 | 2;
|
|
|
8298
8511
|
|
|
8299
8512
|
/* Excluded from this release type: LookupResult */
|
|
8300
8513
|
|
|
8514
|
+
/**
|
|
8515
|
+
* Model used for prompts classified as low complexity.
|
|
8516
|
+
* @public
|
|
8517
|
+
*/
|
|
8518
|
+
declare type LowComplexityModel = string;
|
|
8519
|
+
|
|
8301
8520
|
/**
|
|
8302
8521
|
* Skip caching entirely when the conversation has more than this many messages. Unset by default (no limit). Set a bound to guard against topic drift: the cache key covers only the last recentMessageCount messages, so the deeper a conversation goes, the more likely a match on recent messages alone ignores earlier context that should change the answer.
|
|
8303
8522
|
* @public
|
|
8304
8523
|
*/
|
|
8305
8524
|
declare type MaxConversationLength = number;
|
|
8306
8525
|
|
|
8526
|
+
/**
|
|
8527
|
+
* Maximum characters of user prompt sent to the classifier. Longer prompts are truncated.
|
|
8528
|
+
* @public
|
|
8529
|
+
*/
|
|
8530
|
+
declare type MaxPromptCharacters = number;
|
|
8531
|
+
|
|
8307
8532
|
/**
|
|
8308
8533
|
* Authenticate MCP gateway requests using a gateway-issued OAuth access token,
|
|
8309
8534
|
* with browser login delegated to Auth0.
|
|
@@ -10087,6 +10312,12 @@ export declare interface McpWorkosOAuthInboundPolicyOptions {
|
|
|
10087
10312
|
};
|
|
10088
10313
|
}
|
|
10089
10314
|
|
|
10315
|
+
/**
|
|
10316
|
+
* Model used for prompts classified as medium complexity.
|
|
10317
|
+
* @public
|
|
10318
|
+
*/
|
|
10319
|
+
declare type MediumComplexityModel = string;
|
|
10320
|
+
|
|
10090
10321
|
declare interface MemoryCacheOptions {
|
|
10091
10322
|
maxSize: number;
|
|
10092
10323
|
}
|
|
@@ -10270,6 +10501,12 @@ declare interface MetricsType {
|
|
|
10270
10501
|
responseContentLength?: boolean;
|
|
10271
10502
|
}
|
|
10272
10503
|
|
|
10504
|
+
/**
|
|
10505
|
+
* Minimum confidence (0–1) required before applying model routing. Unknown intents are capped strictly below this threshold.
|
|
10506
|
+
* @public
|
|
10507
|
+
*/
|
|
10508
|
+
declare type MinimumConfidenceForRouting = number;
|
|
10509
|
+
|
|
10273
10510
|
/**
|
|
10274
10511
|
* The options for this policy.
|
|
10275
10512
|
* @public
|
|
@@ -10322,6 +10559,16 @@ declare interface Models {
|
|
|
10322
10559
|
embeddings?: EmbeddingsModels;
|
|
10323
10560
|
}
|
|
10324
10561
|
|
|
10562
|
+
/**
|
|
10563
|
+
* Optional `providerName/model` routing by classified complexity. Used only when `smartRoutingEnabled` is true.
|
|
10564
|
+
* @public
|
|
10565
|
+
*/
|
|
10566
|
+
declare interface ModelsByComplexity {
|
|
10567
|
+
low?: LowComplexityModel;
|
|
10568
|
+
medium?: MediumComplexityModel;
|
|
10569
|
+
high?: HighComplexityModel;
|
|
10570
|
+
}
|
|
10571
|
+
|
|
10325
10572
|
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
10326
10573
|
|
|
10327
10574
|
declare interface MoesifContext {
|
|
@@ -13907,6 +14154,12 @@ export declare interface SleepInboundPolicyOptions {
|
|
|
13907
14154
|
sleepInMs: number;
|
|
13908
14155
|
}
|
|
13909
14156
|
|
|
14157
|
+
/**
|
|
14158
|
+
* When true, apply model routing from `modelsByComplexity` when confidence is high enough and the intent is known. Classification still runs when false.
|
|
14159
|
+
* @public
|
|
14160
|
+
*/
|
|
14161
|
+
declare type SmartRoutingEnabled = boolean;
|
|
14162
|
+
|
|
13910
14163
|
declare interface SplunkLoggingOptions {
|
|
13911
14164
|
/**
|
|
13912
14165
|
* The URL for the Splunk HTTP Event Collector (HEC) endpoint.
|