@intutic/shared-types 2.3.0 → 2.5.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 +1 -1
- package/dist/anomaly.d.ts +0 -19
- package/dist/anomaly.d.ts.map +1 -1
- package/dist/attenuation.d.ts +4 -3
- package/dist/attenuation.d.ts.map +1 -1
- package/dist/attenuation.js +4 -3
- package/dist/attenuation.js.map +1 -1
- package/dist/auth.d.ts +106 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +17 -1
- package/dist/auth.js.map +1 -1
- package/dist/chaos.d.ts +2225 -0
- package/dist/chaos.d.ts.map +1 -0
- package/dist/chaos.js +358 -0
- package/dist/chaos.js.map +1 -0
- package/dist/chaosGate.d.ts +166 -0
- package/dist/chaosGate.d.ts.map +1 -0
- package/dist/chaosGate.js +383 -0
- package/dist/chaosGate.js.map +1 -0
- package/dist/cloudProbe.d.ts +54 -0
- package/dist/cloudProbe.d.ts.map +1 -0
- package/dist/cloudProbe.js +254 -0
- package/dist/cloudProbe.js.map +1 -0
- package/dist/enums.d.ts +48 -0
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +31 -3
- package/dist/enums.js.map +1 -1
- package/dist/finops.d.ts +38 -18
- package/dist/finops.d.ts.map +1 -1
- package/dist/guardrailIr.d.ts +4 -4
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -9
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +3 -100
- package/dist/intelligence.d.ts.map +1 -1
- package/dist/intelligence.js +3 -3
- package/dist/intelligence.js.map +1 -1
- package/dist/mcpBudgets.d.ts +32 -32
- package/dist/notifications.d.ts +17 -2
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +35 -5
- package/dist/notifications.js.map +1 -1
- package/dist/observability.d.ts +0 -31
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +0 -7
- package/dist/observability.js.map +1 -1
- package/dist/opaqueRefusal.d.ts +40 -0
- package/dist/opaqueRefusal.d.ts.map +1 -0
- package/dist/opaqueRefusal.js +53 -0
- package/dist/opaqueRefusal.js.map +1 -0
- package/dist/policyGuardrails.d.ts +5 -5
- package/dist/providerVerification.d.ts +35 -9
- package/dist/providerVerification.d.ts.map +1 -1
- package/dist/providerVerification.js +79 -19
- package/dist/providerVerification.js.map +1 -1
- package/dist/providers.d.ts +50 -13
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +131 -27
- package/dist/providers.js.map +1 -1
- package/dist/spendBudgets.d.ts +122 -0
- package/dist/spendBudgets.d.ts.map +1 -0
- package/dist/spendBudgets.js +92 -0
- package/dist/spendBudgets.js.map +1 -0
- package/dist/taskManagement.d.ts +34 -82
- package/dist/taskManagement.d.ts.map +1 -1
- package/dist/taskManagement.js +4 -4
- package/dist/toolPoison.d.ts +15 -2
- package/dist/toolPoison.d.ts.map +1 -1
- package/dist/toolPoison.js +14 -4
- package/dist/toolPoison.js.map +1 -1
- package/dist/upstreamRetry.d.ts +121 -0
- package/dist/upstreamRetry.d.ts.map +1 -0
- package/dist/upstreamRetry.js +90 -0
- package/dist/upstreamRetry.js.map +1 -0
- package/dist/wasmRuleDescriptor.d.ts +43 -0
- package/dist/wasmRuleDescriptor.d.ts.map +1 -0
- package/dist/wasmRuleDescriptor.js +65 -0
- package/dist/wasmRuleDescriptor.js.map +1 -0
- package/dist/workspaceSettings.d.ts +42 -4
- package/dist/workspaceSettings.d.ts.map +1 -1
- package/dist/workspaceSettings.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Spend budgets and key rate limits — how much LLM spend a workspace, one
|
|
4
|
+
* virtual key or one member may run up per day or per month, and how many
|
|
5
|
+
* requests and tokens a virtual key may send per minute.
|
|
6
|
+
*
|
|
7
|
+
* A budget is `hard` or `soft`. The LLM proxy refuses a request that a hard
|
|
8
|
+
* budget's remainder does not cover (`BUDGET_EXCEEDED`, 429, before the
|
|
9
|
+
* request leaves); a soft budget never refuses. Both raise the workspace's
|
|
10
|
+
* budget alerts — once at the alert threshold and once at the limit, per
|
|
11
|
+
* period — as `finops.budget.threshold` / `finops.budget.exceeded`.
|
|
12
|
+
*
|
|
13
|
+
* Periods are fixed UTC windows, like MCP call budgets (`mcpBudgets.ts`): a
|
|
14
|
+
* day starts at 00:00 UTC, a month on the 1st at 00:00 UTC. The window id is
|
|
15
|
+
* part of every per-key and per-member spend counter's Valkey key, so a new
|
|
16
|
+
* day or month starts from zero and an old counter expires on its own.
|
|
17
|
+
*
|
|
18
|
+
* Spend is what the control plane records per completed call
|
|
19
|
+
* (`finopsService.incrementSpend`), so a request's own cost lands after it
|
|
20
|
+
* finishes: the proxy checks a hard budget against the spend recorded so far
|
|
21
|
+
* plus the request's estimated cost, with the same 20% margin the workspace
|
|
22
|
+
* cap has always used.
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.KeyRateLimitSchema = exports.MAX_KEY_TPM = exports.MAX_KEY_RPM = exports.SpendBudgetListSchema = exports.SpendBudgetSchema = exports.MEMBER_BUDGET_DEFAULT = exports.MAX_SPEND_BUDGET_USD = exports.SPEND_BUDGET_SCOPES = exports.SPEND_BUDGET_PERIODS = void 0;
|
|
28
|
+
exports.spendBudgetWindow = spendBudgetWindow;
|
|
29
|
+
exports.describeSpendBudget = describeSpendBudget;
|
|
30
|
+
const zod_1 = require("zod");
|
|
31
|
+
exports.SPEND_BUDGET_PERIODS = ['day', 'month'];
|
|
32
|
+
exports.SPEND_BUDGET_SCOPES = ['workspace', 'key', 'member'];
|
|
33
|
+
exports.MAX_SPEND_BUDGET_USD = 1_000_000;
|
|
34
|
+
/**
|
|
35
|
+
* The member budget that applies to every member without one of their own,
|
|
36
|
+
* period by period. A member's own day budget replaces the default day
|
|
37
|
+
* budget; the default month budget still applies to them unless they have a
|
|
38
|
+
* month budget too.
|
|
39
|
+
*/
|
|
40
|
+
exports.MEMBER_BUDGET_DEFAULT = 'default';
|
|
41
|
+
exports.SpendBudgetSchema = zod_1.z
|
|
42
|
+
.object({
|
|
43
|
+
period: zod_1.z.enum(['day', 'month']),
|
|
44
|
+
limitUsd: zod_1.z.number().positive().max(exports.MAX_SPEND_BUDGET_USD),
|
|
45
|
+
enforcement: zod_1.z.enum(['hard', 'soft']).default('hard'),
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
48
|
+
/** One budget per period at most: a key or member has a day budget, a month budget, both or neither. */
|
|
49
|
+
exports.SpendBudgetListSchema = zod_1.z
|
|
50
|
+
.array(exports.SpendBudgetSchema)
|
|
51
|
+
.max(2)
|
|
52
|
+
.superRefine((list, ctx) => {
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
list.forEach((b, i) => {
|
|
55
|
+
if (seen.has(b.period))
|
|
56
|
+
ctx.addIssue({ code: 'custom', path: [i, 'period'], message: `two ${b.period} budgets` });
|
|
57
|
+
seen.add(b.period);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
exports.MAX_KEY_RPM = 100_000;
|
|
61
|
+
exports.MAX_KEY_TPM = 100_000_000;
|
|
62
|
+
exports.KeyRateLimitSchema = zod_1.z
|
|
63
|
+
.object({
|
|
64
|
+
rpm: zod_1.z.number().int().min(1).max(exports.MAX_KEY_RPM).nullable().optional(),
|
|
65
|
+
tpm: zod_1.z.number().int().min(1).max(exports.MAX_KEY_TPM).nullable().optional(),
|
|
66
|
+
})
|
|
67
|
+
.strict();
|
|
68
|
+
/** The UTC window a moment falls in: its id (part of the counter key), when it began and when it resets. */
|
|
69
|
+
function spendBudgetWindow(period, nowMs) {
|
|
70
|
+
const d = new Date(nowMs);
|
|
71
|
+
const y = d.getUTCFullYear();
|
|
72
|
+
const m = d.getUTCMonth();
|
|
73
|
+
if (period === 'day') {
|
|
74
|
+
const startMs = Date.UTC(y, m, d.getUTCDate());
|
|
75
|
+
return { id: new Date(startMs).toISOString().slice(0, 10), startMs, resetAtMs: startMs + 86_400_000 };
|
|
76
|
+
}
|
|
77
|
+
const startMs = Date.UTC(y, m, 1);
|
|
78
|
+
return { id: new Date(startMs).toISOString().slice(0, 7), startMs, resetAtMs: Date.UTC(y, m + 1, 1) };
|
|
79
|
+
}
|
|
80
|
+
/** A budget in words, for alerts, refusals and the dashboard. */
|
|
81
|
+
function describeSpendBudget(scope, budget, subjectLabel) {
|
|
82
|
+
const whose = scope === 'workspace'
|
|
83
|
+
? 'Workspace'
|
|
84
|
+
: scope === 'key'
|
|
85
|
+
? `Key ${subjectLabel ?? ''}`.trim()
|
|
86
|
+
: subjectLabel === exports.MEMBER_BUDGET_DEFAULT || subjectLabel === undefined
|
|
87
|
+
? 'Member'
|
|
88
|
+
: `Member ${subjectLabel}`;
|
|
89
|
+
const per = budget.period === 'day' ? 'day' : 'month';
|
|
90
|
+
return `${whose} ${budget.enforcement} budget: $${budget.limitUsd.toFixed(2)} per ${per}`;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=spendBudgets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spendBudgets.js","sourceRoot":"","sources":["../src/spendBudgets.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAoFH,8CAaC;AAGD,kDAWC;AA7GD,6BAAuB;AAsBV,QAAA,oBAAoB,GAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AACrE,QAAA,mBAAmB,GAAgC,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;AACjF,QAAA,oBAAoB,GAAG,SAAS,CAAA;AAE7C;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,SAAS,CAAA;AAEjC,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,CAAC;IACN,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,KAAK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,OAAO,YAAY,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;YACpC,CAAC,CAAC,YAAY,KAAK,6BAAqB,IAAI,YAAY,KAAK,SAAS;gBACpE,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,UAAU,YAAY,EAAE,CAAA;IAClC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IACrD,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,WAAW,aAAa,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAA;AAC3F,CAAC"}
|
package/dist/taskManagement.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Task Management Adapter —
|
|
2
|
+
* Task Management Adapter — read-only interface over external task trackers
|
|
3
|
+
* and incident tools.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* create/update tasks based on governance events.
|
|
5
|
+
* The control plane reads tickets (Jira, Linear) and incidents (PagerDuty) to
|
|
6
|
+
* attach task context to agent sessions. It does not create or update them.
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
/**
|
|
11
|
-
export type TaskProvider = 'jira' | '
|
|
10
|
+
/** Providers with a registered adapter. */
|
|
11
|
+
export type TaskProvider = 'jira' | 'pagerduty' | 'linear';
|
|
12
12
|
/** Priority levels mapped across providers. */
|
|
13
13
|
export type TaskPriority = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW';
|
|
14
14
|
/** Task status (normalized across providers). */
|
|
@@ -20,62 +20,17 @@ export interface TaskProviderCredentials {
|
|
|
20
20
|
baseUrl: string;
|
|
21
21
|
/** Authentication token or API key. */
|
|
22
22
|
authToken: string;
|
|
23
|
-
/** Project or
|
|
23
|
+
/** Project, team or routing key within the provider. */
|
|
24
24
|
projectKey: string;
|
|
25
|
+
/**
|
|
26
|
+
* Jira Cloud only: the email of the Atlassian account the API token belongs
|
|
27
|
+
* to. Jira Cloud authenticates an API token as Basic `email:token`. A
|
|
28
|
+
* connection stores it as `metadata.accountEmail`.
|
|
29
|
+
*/
|
|
30
|
+
accountEmail?: string;
|
|
25
31
|
/** Additional provider-specific config. */
|
|
26
32
|
metadata?: Record<string, unknown>;
|
|
27
33
|
}
|
|
28
|
-
/** Payload for creating a new task. */
|
|
29
|
-
export interface CreateTaskPayload {
|
|
30
|
-
/** Human-readable task title. */
|
|
31
|
-
title: string;
|
|
32
|
-
/** Markdown description of the task. */
|
|
33
|
-
description: string;
|
|
34
|
-
/** Normalized priority. */
|
|
35
|
-
priority: TaskPriority;
|
|
36
|
-
/** Intutic-specific labels for categorization. */
|
|
37
|
-
labels?: string[];
|
|
38
|
-
/** Assignee identifier (provider-specific). */
|
|
39
|
-
assigneeId?: string;
|
|
40
|
-
/** Link back to the Intutic governance event. */
|
|
41
|
-
intuticLink?: {
|
|
42
|
-
/** Type of governance event that created this task. */
|
|
43
|
-
eventType: 'INCIDENT' | 'ANOMALY' | 'SOP_REVIEW' | 'COMPLIANCE';
|
|
44
|
-
/** ID of the governance event. */
|
|
45
|
-
eventId: string;
|
|
46
|
-
/** Workspace this event belongs to. */
|
|
47
|
-
workspaceId: string;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/** Result of creating a task in the external system. */
|
|
51
|
-
export interface CreateTaskResult {
|
|
52
|
-
/** Whether the task was successfully created. */
|
|
53
|
-
success: boolean;
|
|
54
|
-
/** External task ID (e.g., Jira issue key like "PROJ-123"). */
|
|
55
|
-
externalTaskId?: string;
|
|
56
|
-
/** URL to the task in the external system. */
|
|
57
|
-
externalUrl?: string;
|
|
58
|
-
/** Error message if creation failed. */
|
|
59
|
-
error?: string;
|
|
60
|
-
}
|
|
61
|
-
/** Payload for updating an existing task. */
|
|
62
|
-
export interface UpdateTaskPayload {
|
|
63
|
-
/** External task ID to update. */
|
|
64
|
-
externalTaskId: string;
|
|
65
|
-
/** New status (optional). */
|
|
66
|
-
status?: TaskStatus;
|
|
67
|
-
/** Comment to add (optional). */
|
|
68
|
-
comment?: string;
|
|
69
|
-
/** Updated priority (optional). */
|
|
70
|
-
priority?: TaskPriority;
|
|
71
|
-
/** Additional fields (provider-specific). */
|
|
72
|
-
fields?: Record<string, unknown>;
|
|
73
|
-
}
|
|
74
|
-
/** Result of updating a task. */
|
|
75
|
-
export interface UpdateTaskResult {
|
|
76
|
-
success: boolean;
|
|
77
|
-
error?: string;
|
|
78
|
-
}
|
|
79
34
|
/** A task as retrieved from the external system. */
|
|
80
35
|
export interface ExternalTask {
|
|
81
36
|
externalTaskId: string;
|
|
@@ -90,13 +45,22 @@ export interface ExternalTask {
|
|
|
90
45
|
sprint?: string;
|
|
91
46
|
epic?: string;
|
|
92
47
|
}
|
|
48
|
+
/** Filters for `TaskManagementAdapter.searchTasks`. */
|
|
49
|
+
export interface TaskSearchFilters {
|
|
50
|
+
status?: TaskStatus;
|
|
51
|
+
priority?: TaskPriority;
|
|
52
|
+
labels?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* The provider's own id for the assignee. An adapter must apply it: a search
|
|
55
|
+
* for one person's work that comes back with everyone's is worse than none.
|
|
56
|
+
*/
|
|
57
|
+
assigneeId?: string;
|
|
58
|
+
}
|
|
93
59
|
/**
|
|
94
60
|
* Generic task management adapter interface.
|
|
95
61
|
*
|
|
96
|
-
* Implementations
|
|
97
|
-
*
|
|
98
|
-
* when governance events (incidents, anomalies, SOP reviews) require
|
|
99
|
-
* external task creation or updates.
|
|
62
|
+
* Implementations read from an external tracker so the control plane can
|
|
63
|
+
* resolve which ticket or incident an agent session is working on.
|
|
100
64
|
*/
|
|
101
65
|
export interface TaskManagementAdapter {
|
|
102
66
|
/** Provider name for this adapter. */
|
|
@@ -106,18 +70,6 @@ export interface TaskManagementAdapter {
|
|
|
106
70
|
* @returns true if the connection is healthy
|
|
107
71
|
*/
|
|
108
72
|
testConnection(): Promise<boolean>;
|
|
109
|
-
/**
|
|
110
|
-
* Create a new task in the external system.
|
|
111
|
-
* @param payload - Task creation payload
|
|
112
|
-
* @returns Result with external task ID and URL
|
|
113
|
-
*/
|
|
114
|
-
createTask(payload: CreateTaskPayload): Promise<CreateTaskResult>;
|
|
115
|
-
/**
|
|
116
|
-
* Update an existing task in the external system.
|
|
117
|
-
* @param payload - Task update payload
|
|
118
|
-
* @returns Result indicating success/failure
|
|
119
|
-
*/
|
|
120
|
-
updateTask(payload: UpdateTaskPayload): Promise<UpdateTaskResult>;
|
|
121
73
|
/**
|
|
122
74
|
* Retrieve a task by its external ID.
|
|
123
75
|
* @param externalTaskId - The external system's task identifier
|
|
@@ -125,15 +77,15 @@ export interface TaskManagementAdapter {
|
|
|
125
77
|
*/
|
|
126
78
|
getTask(externalTaskId: string): Promise<ExternalTask | null>;
|
|
127
79
|
/**
|
|
128
|
-
* Search for tasks
|
|
129
|
-
*
|
|
130
|
-
*
|
|
80
|
+
* Search for open tasks.
|
|
81
|
+
*
|
|
82
|
+
* Rejects when the provider cannot be asked (unreachable, refused, timed
|
|
83
|
+
* out), so a caller can tell "nothing open" from "could not ask".
|
|
84
|
+
*
|
|
85
|
+
* @param workspaceId - Intutic workspace ID, for logging
|
|
86
|
+
* @param filters - Optional filters (status, priority, labels, assignee)
|
|
131
87
|
* @returns List of matching external tasks
|
|
132
88
|
*/
|
|
133
|
-
searchTasks(workspaceId: string, filters?:
|
|
134
|
-
status?: TaskStatus;
|
|
135
|
-
priority?: TaskPriority;
|
|
136
|
-
labels?: string[];
|
|
137
|
-
}): Promise<ExternalTask[]>;
|
|
89
|
+
searchTasks(workspaceId: string, filters?: TaskSearchFilters): Promise<ExternalTask[]>;
|
|
138
90
|
}
|
|
139
91
|
//# sourceMappingURL=taskManagement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskManagement.d.ts","sourceRoot":"","sources":["../src/taskManagement.ts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vD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAID;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;IAE/B;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAElC;;;;OAIG;IACH,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;IAE7D;;;;;;;;;OASG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;CACvF"}
|
package/dist/taskManagement.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Task Management Adapter —
|
|
3
|
+
* Task Management Adapter — read-only interface over external task trackers
|
|
4
|
+
* and incident tools.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* create/update tasks based on governance events.
|
|
6
|
+
* The control plane reads tickets (Jira, Linear) and incidents (PagerDuty) to
|
|
7
|
+
* attach task context to agent sessions. It does not create or update them.
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
package/dist/toolPoison.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* toolPoison.ts — Tool-description poisoning patterns.
|
|
3
3
|
*
|
|
4
4
|
* Direct TypeScript port of `packages/proxy/src/tool_poison.rs`'s `scan`
|
|
5
|
-
* function and its
|
|
5
|
+
* function and its named patterns. This is a SEPARATE pattern set from
|
|
6
6
|
* the MCP proxy's `injection.ts`, on purpose: `tool_poison.rs`'s own module
|
|
7
7
|
* doc records that it tried reusing `injection::scan` for this and measured
|
|
8
8
|
* that its five patterns match ZERO of the tool-poisoning payloads — they are
|
|
@@ -21,10 +21,23 @@
|
|
|
21
21
|
* module's own `gating_never_changes_a_verdict` test), and the volume of tool
|
|
22
22
|
* descriptions scanned here is orders of magnitude below the Rust proxy's
|
|
23
23
|
* request path. The pattern SOURCE TEXT below is unchanged from the Rust
|
|
24
|
-
* `PATTERNS` array
|
|
24
|
+
* `PATTERNS` array, `/` escaped as `\/` for a regex literal;
|
|
25
|
+
* `__tests__/toolPoison.test.ts` reads the Rust file and holds the two equal.
|
|
25
26
|
*
|
|
26
27
|
@module
|
|
27
28
|
*/
|
|
29
|
+
export interface ToolPoisonPattern {
|
|
30
|
+
name: string;
|
|
31
|
+
regex: RegExp;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Ported verbatim from `tool_poison.rs`'s `PATTERNS` const. All bounded
|
|
35
|
+
* repetitions here are small fixed-width gaps (`{0,40}`, `{0,60}`, `{0,80}`)
|
|
36
|
+
* over a handful of alternations — the same "no wide bounded repetition, no
|
|
37
|
+
* RegexSet performance regression" shape the MCP proxy's `injection.ts` documents, not the
|
|
38
|
+
* `dlp.rs` shape that regressed.
|
|
39
|
+
*/
|
|
40
|
+
export declare const TOOL_POISON_PATTERNS: readonly ToolPoisonPattern[];
|
|
28
41
|
/**
|
|
29
42
|
* Pattern names matching this tool description, deduplicated, empty when it
|
|
30
43
|
* looks like ordinary prose (the overwhelmingly common case).
|
package/dist/toolPoison.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolPoison.d.ts","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"toolPoison.d.ts","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,iBAAiB,EA2C5D,CAAA;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjE"}
|
package/dist/toolPoison.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* toolPoison.ts — Tool-description poisoning patterns.
|
|
4
4
|
*
|
|
5
5
|
* Direct TypeScript port of `packages/proxy/src/tool_poison.rs`'s `scan`
|
|
6
|
-
* function and its
|
|
6
|
+
* function and its named patterns. This is a SEPARATE pattern set from
|
|
7
7
|
* the MCP proxy's `injection.ts`, on purpose: `tool_poison.rs`'s own module
|
|
8
8
|
* doc records that it tried reusing `injection::scan` for this and measured
|
|
9
9
|
* that its five patterns match ZERO of the tool-poisoning payloads — they are
|
|
@@ -22,11 +22,13 @@
|
|
|
22
22
|
* module's own `gating_never_changes_a_verdict` test), and the volume of tool
|
|
23
23
|
* descriptions scanned here is orders of magnitude below the Rust proxy's
|
|
24
24
|
* request path. The pattern SOURCE TEXT below is unchanged from the Rust
|
|
25
|
-
* `PATTERNS` array
|
|
25
|
+
* `PATTERNS` array, `/` escaped as `\/` for a regex literal;
|
|
26
|
+
* `__tests__/toolPoison.test.ts` reads the Rust file and holds the two equal.
|
|
26
27
|
*
|
|
27
28
|
@module
|
|
28
29
|
*/
|
|
29
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.TOOL_POISON_PATTERNS = void 0;
|
|
30
32
|
exports.scanToolDescription = scanToolDescription;
|
|
31
33
|
/**
|
|
32
34
|
* Ported verbatim from `tool_poison.rs`'s `PATTERNS` const. All bounded
|
|
@@ -35,7 +37,7 @@ exports.scanToolDescription = scanToolDescription;
|
|
|
35
37
|
* RegexSet performance regression" shape the MCP proxy's `injection.ts` documents, not the
|
|
36
38
|
* `dlp.rs` shape that regressed.
|
|
37
39
|
*/
|
|
38
|
-
|
|
40
|
+
exports.TOOL_POISON_PATTERNS = [
|
|
39
41
|
{
|
|
40
42
|
name: 'hidden-instruction-block',
|
|
41
43
|
regex: /<\s*(important|secret|system|hidden|instructions?)\s*>/i,
|
|
@@ -67,6 +69,14 @@ const PATTERNS = [
|
|
|
67
69
|
name: 'tool-scoped-instruction-override',
|
|
68
70
|
regex: /\b(ignore|disregard|override)\b[^.!?]{0,40}\b(other\s+tools?|previous\s+tools?|system\s+prompt)\b/i,
|
|
69
71
|
},
|
|
72
|
+
{
|
|
73
|
+
// An order to run a command that destroys the machine or its data: a
|
|
74
|
+
// recursive delete of the filesystem root or the home directory (never a
|
|
75
|
+
// path below either), formatting or raw-writing a block device, dropping a
|
|
76
|
+
// database, piping a download into a shell, a fork bomb.
|
|
77
|
+
name: 'destructive-command-instruction',
|
|
78
|
+
regex: /\b(run|execute|exec|invoke|issue|type|enter|paste)\b[^.!?]{0,40}(\brm\s+-[a-z-]*[rf][a-z-]*\s+(-\S+\s+){0,4}["'`]?(\/\*?|~\/?\*?|\$\{?home\}?\/?\*?)(["'`;&|)\s]|$)|\bmkfs\b|\bdd\s[^.!?]{0,60}\bof=\/dev\/|\bdrop\s+(database|schema)\b|\b(curl|wget)\s[^|\n]{0,120}\|\s*(sudo\s+)?(ba|z|da|k)?sh\b|:\(\)\s*\{\s*:\s*\|\s*:)/i,
|
|
79
|
+
},
|
|
70
80
|
];
|
|
71
81
|
/**
|
|
72
82
|
* Pattern names matching this tool description, deduplicated, empty when it
|
|
@@ -76,7 +86,7 @@ function scanToolDescription(description) {
|
|
|
76
86
|
if (!description)
|
|
77
87
|
return [];
|
|
78
88
|
const found = [];
|
|
79
|
-
for (const { name, regex } of
|
|
89
|
+
for (const { name, regex } of exports.TOOL_POISON_PATTERNS) {
|
|
80
90
|
if (regex.test(description))
|
|
81
91
|
found.push(name);
|
|
82
92
|
}
|
package/dist/toolPoison.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolPoison.js","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"toolPoison.js","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AA+DH,kDAOC;AA/DD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAiC;IAChE;QACE,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE,yDAAyD;KACjE;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,KAAK,EACH,kJAAkJ;KACrJ;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,KAAK,EACH,oKAAoK;KACvK;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,qEAAqE;QACrE,iEAAiE;QACjE,sDAAsD;QACtD,KAAK,EAAE,+GAA+G;KACvH;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,0GAA0G;KAClH;IACD;QACE,IAAI,EAAE,6BAA6B;QACnC,KAAK,EAAE,kHAAkH;KAC1H;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,oGAAoG;KAC5G;IACD;QACE,qEAAqE;QACrE,yEAAyE;QACzE,2EAA2E;QAC3E,yDAAyD;QACzD,IAAI,EAAE,iCAAiC;QACvC,KAAK,EACH,gUAAgU;KACnU;CACF,CAAA;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,WAAmB;IACrD,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAA;IAC3B,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,4BAAoB,EAAE,CAAC;QACnD,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace setting `upstreamRetry`: how the LLM proxy retries a provider
|
|
3
|
+
* call that failed before any response reached the client, and where it falls
|
|
4
|
+
* back when those retries run out.
|
|
5
|
+
*
|
|
6
|
+
* Every field is optional and overrides the proxy's own `config.yaml` value
|
|
7
|
+
* (`intutic_settings.routing.retry` / `.fallbacks`) field by field, so a
|
|
8
|
+
* workspace can change one knob without restating the rest. The proxy reads
|
|
9
|
+
* it from `/api/v1/auth/key-context` (`packages/proxy/src/routing/retry.rs`,
|
|
10
|
+
* `WorkspaceRetry`); `fixtures/upstream-retry-vectors.json` holds the two
|
|
11
|
+
* readings together.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/**
|
|
15
|
+
* The ceilings both the schema and the proxy enforce, so no setting can
|
|
16
|
+
* configure a retry storm. The proxy clamps `config.yaml` to the same values
|
|
17
|
+
* (`RetryConfig::bounded`); a test holds the two equal.
|
|
18
|
+
*/
|
|
19
|
+
export declare const UPSTREAM_RETRY_LIMITS: {
|
|
20
|
+
readonly maxAttempts: 5;
|
|
21
|
+
readonly maxBackoffMs: 60000;
|
|
22
|
+
readonly budgetMs: 120000;
|
|
23
|
+
readonly fallbackTargets: 5;
|
|
24
|
+
readonly fallbackModels: 50;
|
|
25
|
+
};
|
|
26
|
+
/** Retried by default: 429, 500, 502, 503, 504 and Anthropic's 529 overloaded. */
|
|
27
|
+
export declare const DEFAULT_UPSTREAM_RETRY_STATUSES: readonly [429, 500, 502, 503, 504, 529];
|
|
28
|
+
/** The defaults the proxy applies when neither config.yaml nor the workspace sets a field. */
|
|
29
|
+
export declare const DEFAULT_UPSTREAM_RETRY: {
|
|
30
|
+
readonly enabled: true;
|
|
31
|
+
readonly maxAttempts: 3;
|
|
32
|
+
readonly initialBackoffMs: 500;
|
|
33
|
+
readonly maxBackoffMs: 8000;
|
|
34
|
+
readonly budgetMs: 30000;
|
|
35
|
+
readonly onStatus: readonly [429, 500, 502, 503, 504, 529];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Providers a fallback target may name: every id the proxy resolves
|
|
39
|
+
* (`provider_from_wire_id` in packages/proxy/src/proxy.rs), the cloud
|
|
40
|
+
* providers' aliases included, so a target copied from config.yaml is valid
|
|
41
|
+
* here too. A test holds the two lists equal.
|
|
42
|
+
*/
|
|
43
|
+
export declare const UPSTREAM_PROVIDERS: readonly ["anthropic", "openai", "gemini", "mistral", "openrouter", "deepseek", "bedrock", "vertex_ai", "vertex", "azure_openai", "azure"];
|
|
44
|
+
export type UpstreamProvider = (typeof UPSTREAM_PROVIDERS)[number];
|
|
45
|
+
/**
|
|
46
|
+
* One fallback target. `model` alone switches model on the provider that
|
|
47
|
+
* model resolves to; `provider` alone sends the same model to another
|
|
48
|
+
* provider; both pin the pair.
|
|
49
|
+
*/
|
|
50
|
+
export declare const UpstreamFallbackTargetSchema: z.ZodEffects<z.ZodObject<{
|
|
51
|
+
model: z.ZodOptional<z.ZodString>;
|
|
52
|
+
provider: z.ZodOptional<z.ZodEnum<["anthropic", "openai", "gemini", "mistral", "openrouter", "deepseek", "bedrock", "vertex_ai", "vertex", "azure_openai", "azure"]>>;
|
|
53
|
+
}, "strict", z.ZodTypeAny, {
|
|
54
|
+
model?: string | undefined;
|
|
55
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
model?: string | undefined;
|
|
58
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
59
|
+
}>, {
|
|
60
|
+
model?: string | undefined;
|
|
61
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
model?: string | undefined;
|
|
64
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
export type UpstreamFallbackTarget = z.infer<typeof UpstreamFallbackTargetSchema>;
|
|
67
|
+
export declare const UpstreamRetrySettingsSchema: z.ZodObject<{
|
|
68
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
initialBackoffMs: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
maxBackoffMs: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
budgetMs: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
onStatus: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
74
|
+
/** Ordered targets, keyed by the model whose retries ran out. */
|
|
75
|
+
fallbacks: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
76
|
+
model: z.ZodOptional<z.ZodString>;
|
|
77
|
+
provider: z.ZodOptional<z.ZodEnum<["anthropic", "openai", "gemini", "mistral", "openrouter", "deepseek", "bedrock", "vertex_ai", "vertex", "azure_openai", "azure"]>>;
|
|
78
|
+
}, "strict", z.ZodTypeAny, {
|
|
79
|
+
model?: string | undefined;
|
|
80
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
model?: string | undefined;
|
|
83
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
84
|
+
}>, {
|
|
85
|
+
model?: string | undefined;
|
|
86
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
model?: string | undefined;
|
|
89
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
90
|
+
}>, "many">>, Record<string, {
|
|
91
|
+
model?: string | undefined;
|
|
92
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
93
|
+
}[]>, Record<string, {
|
|
94
|
+
model?: string | undefined;
|
|
95
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
96
|
+
}[]>>>;
|
|
97
|
+
}, "strict", z.ZodTypeAny, {
|
|
98
|
+
enabled?: boolean | undefined;
|
|
99
|
+
maxAttempts?: number | undefined;
|
|
100
|
+
initialBackoffMs?: number | undefined;
|
|
101
|
+
maxBackoffMs?: number | undefined;
|
|
102
|
+
budgetMs?: number | undefined;
|
|
103
|
+
onStatus?: number[] | undefined;
|
|
104
|
+
fallbacks?: Record<string, {
|
|
105
|
+
model?: string | undefined;
|
|
106
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
107
|
+
}[]> | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
enabled?: boolean | undefined;
|
|
110
|
+
maxAttempts?: number | undefined;
|
|
111
|
+
initialBackoffMs?: number | undefined;
|
|
112
|
+
maxBackoffMs?: number | undefined;
|
|
113
|
+
budgetMs?: number | undefined;
|
|
114
|
+
onStatus?: number[] | undefined;
|
|
115
|
+
fallbacks?: Record<string, {
|
|
116
|
+
model?: string | undefined;
|
|
117
|
+
provider?: "anthropic" | "openai" | "mistral" | "openrouter" | "deepseek" | "gemini" | "azure_openai" | "bedrock" | "vertex_ai" | "vertex" | "azure" | undefined;
|
|
118
|
+
}[]> | undefined;
|
|
119
|
+
}>;
|
|
120
|
+
export type UpstreamRetrySettings = z.infer<typeof UpstreamRetrySettingsSchema>;
|
|
121
|
+
//# sourceMappingURL=upstreamRetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstreamRetry.d.ts","sourceRoot":"","sources":["../src/upstreamRetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;CAMxB,CAAA;AAEV,kFAAkF;AAClF,eAAO,MAAM,+BAA+B,yCAA0C,CAAA;AAEtF,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB;;;;;;;CAOzB,CAAA;AAEV;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,4IAYrB,CAAA;AACV,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;EAQrC,CAAA;AACJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAEjF,eAAO,MAAM,2BAA2B;;;;;;;IAQpC,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW1D,CAAA;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpstreamRetrySettingsSchema = exports.UpstreamFallbackTargetSchema = exports.UPSTREAM_PROVIDERS = exports.DEFAULT_UPSTREAM_RETRY = exports.DEFAULT_UPSTREAM_RETRY_STATUSES = exports.UPSTREAM_RETRY_LIMITS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The workspace setting `upstreamRetry`: how the LLM proxy retries a provider
|
|
6
|
+
* call that failed before any response reached the client, and where it falls
|
|
7
|
+
* back when those retries run out.
|
|
8
|
+
*
|
|
9
|
+
* Every field is optional and overrides the proxy's own `config.yaml` value
|
|
10
|
+
* (`intutic_settings.routing.retry` / `.fallbacks`) field by field, so a
|
|
11
|
+
* workspace can change one knob without restating the rest. The proxy reads
|
|
12
|
+
* it from `/api/v1/auth/key-context` (`packages/proxy/src/routing/retry.rs`,
|
|
13
|
+
* `WorkspaceRetry`); `fixtures/upstream-retry-vectors.json` holds the two
|
|
14
|
+
* readings together.
|
|
15
|
+
*/
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
/**
|
|
18
|
+
* The ceilings both the schema and the proxy enforce, so no setting can
|
|
19
|
+
* configure a retry storm. The proxy clamps `config.yaml` to the same values
|
|
20
|
+
* (`RetryConfig::bounded`); a test holds the two equal.
|
|
21
|
+
*/
|
|
22
|
+
exports.UPSTREAM_RETRY_LIMITS = {
|
|
23
|
+
maxAttempts: 5,
|
|
24
|
+
maxBackoffMs: 60_000,
|
|
25
|
+
budgetMs: 120_000,
|
|
26
|
+
fallbackTargets: 5,
|
|
27
|
+
fallbackModels: 50,
|
|
28
|
+
};
|
|
29
|
+
/** Retried by default: 429, 500, 502, 503, 504 and Anthropic's 529 overloaded. */
|
|
30
|
+
exports.DEFAULT_UPSTREAM_RETRY_STATUSES = [429, 500, 502, 503, 504, 529];
|
|
31
|
+
/** The defaults the proxy applies when neither config.yaml nor the workspace sets a field. */
|
|
32
|
+
exports.DEFAULT_UPSTREAM_RETRY = {
|
|
33
|
+
enabled: true,
|
|
34
|
+
maxAttempts: 3,
|
|
35
|
+
initialBackoffMs: 500,
|
|
36
|
+
maxBackoffMs: 8_000,
|
|
37
|
+
budgetMs: 30_000,
|
|
38
|
+
onStatus: [...exports.DEFAULT_UPSTREAM_RETRY_STATUSES],
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Providers a fallback target may name: every id the proxy resolves
|
|
42
|
+
* (`provider_from_wire_id` in packages/proxy/src/proxy.rs), the cloud
|
|
43
|
+
* providers' aliases included, so a target copied from config.yaml is valid
|
|
44
|
+
* here too. A test holds the two lists equal.
|
|
45
|
+
*/
|
|
46
|
+
exports.UPSTREAM_PROVIDERS = [
|
|
47
|
+
'anthropic',
|
|
48
|
+
'openai',
|
|
49
|
+
'gemini',
|
|
50
|
+
'mistral',
|
|
51
|
+
'openrouter',
|
|
52
|
+
'deepseek',
|
|
53
|
+
'bedrock',
|
|
54
|
+
'vertex_ai',
|
|
55
|
+
'vertex',
|
|
56
|
+
'azure_openai',
|
|
57
|
+
'azure',
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* One fallback target. `model` alone switches model on the provider that
|
|
61
|
+
* model resolves to; `provider` alone sends the same model to another
|
|
62
|
+
* provider; both pin the pair.
|
|
63
|
+
*/
|
|
64
|
+
exports.UpstreamFallbackTargetSchema = zod_1.z
|
|
65
|
+
.object({
|
|
66
|
+
model: zod_1.z.string().trim().min(1).max(200).optional(),
|
|
67
|
+
provider: zod_1.z.enum(exports.UPSTREAM_PROVIDERS).optional(),
|
|
68
|
+
})
|
|
69
|
+
.strict()
|
|
70
|
+
.refine((t) => t.model !== undefined || t.provider !== undefined, {
|
|
71
|
+
message: 'A fallback target names a model, a provider, or both',
|
|
72
|
+
});
|
|
73
|
+
exports.UpstreamRetrySettingsSchema = zod_1.z
|
|
74
|
+
.object({
|
|
75
|
+
enabled: zod_1.z.boolean().optional(),
|
|
76
|
+
maxAttempts: zod_1.z.number().int().min(1).max(exports.UPSTREAM_RETRY_LIMITS.maxAttempts).optional(),
|
|
77
|
+
initialBackoffMs: zod_1.z.number().int().min(0).max(exports.UPSTREAM_RETRY_LIMITS.maxBackoffMs).optional(),
|
|
78
|
+
maxBackoffMs: zod_1.z.number().int().min(0).max(exports.UPSTREAM_RETRY_LIMITS.maxBackoffMs).optional(),
|
|
79
|
+
budgetMs: zod_1.z.number().int().min(0).max(exports.UPSTREAM_RETRY_LIMITS.budgetMs).optional(),
|
|
80
|
+
onStatus: zod_1.z.array(zod_1.z.number().int().min(400).max(599)).max(20).optional(),
|
|
81
|
+
/** Ordered targets, keyed by the model whose retries ran out. */
|
|
82
|
+
fallbacks: zod_1.z
|
|
83
|
+
.record(zod_1.z.string().trim().min(1).max(200), zod_1.z.array(exports.UpstreamFallbackTargetSchema).min(1).max(exports.UPSTREAM_RETRY_LIMITS.fallbackTargets))
|
|
84
|
+
.refine((f) => Object.keys(f).length <= exports.UPSTREAM_RETRY_LIMITS.fallbackModels, {
|
|
85
|
+
message: `At most ${exports.UPSTREAM_RETRY_LIMITS.fallbackModels} models may have fallbacks`,
|
|
86
|
+
})
|
|
87
|
+
.optional(),
|
|
88
|
+
})
|
|
89
|
+
.strict();
|
|
90
|
+
//# sourceMappingURL=upstreamRetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstreamRetry.js","sourceRoot":"","sources":["../src/upstreamRetry.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,6BAAuB;AAEvB;;;;GAIG;AACU,QAAA,qBAAqB,GAAG;IACnC,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,MAAM;IACpB,QAAQ,EAAE,OAAO;IACjB,eAAe,EAAE,CAAC;IAClB,cAAc,EAAE,EAAE;CACV,CAAA;AAEV,kFAAkF;AACrE,QAAA,+BAA+B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAA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