@microsoft/agents-hosting 1.9.0-beta.8.gf58e66b2ee → 1.9.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/README.md +182 -4
- package/dist/package.json +3 -3
- package/dist/src/app/agentApplication.d.ts +4 -3
- package/dist/src/app/agentApplication.js +24 -21
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +9 -2
- package/dist/src/app/agentApplicationBuilder.js +9 -0
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +16 -4
- package/dist/src/app/auth/authorizationManager.d.ts +0 -8
- package/dist/src/app/auth/authorizationManager.js +104 -178
- package/dist/src/app/auth/authorizationManager.js.map +1 -1
- package/dist/src/app/auth/handlerStorage.d.ts +5 -3
- package/dist/src/app/auth/handlerStorage.js +36 -10
- package/dist/src/app/auth/handlerStorage.js.map +1 -1
- package/dist/src/app/auth/types.d.ts +2 -2
- package/dist/src/app/index.d.ts +1 -0
- package/dist/src/app/proactive/proactive.js +10 -6
- package/dist/src/app/proactive/proactive.js.map +1 -1
- package/dist/src/app/proactive/proactiveOptions.d.ts +2 -2
- package/dist/src/app/rateLimit.d.ts +315 -0
- package/dist/src/app/rateLimit.js +333 -0
- package/dist/src/app/rateLimit.js.map +1 -0
- package/dist/src/app/turnState.d.ts +6 -3
- package/dist/src/app/turnState.js +43 -4
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +10 -3
- package/dist/src/auth/authConfiguration.js +292 -259
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/settings.d.ts +8 -70
- package/dist/src/auth/settings.js +5 -67
- package/dist/src/auth/settings.js.map +1 -1
- package/dist/src/cloudAdapter.d.ts +5 -0
- package/dist/src/cloudAdapter.js +13 -103
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/configuration/botFrameworkEnvironmentCompatibility.d.ts +23 -0
- package/dist/src/configuration/botFrameworkEnvironmentCompatibility.js +183 -0
- package/dist/src/configuration/botFrameworkEnvironmentCompatibility.js.map +1 -0
- package/dist/src/configuration/configuration.d.ts +83 -0
- package/dist/src/configuration/configuration.js +836 -0
- package/dist/src/configuration/configuration.js.map +1 -0
- package/dist/src/configuration/configurationSource.d.ts +57 -0
- package/dist/src/configuration/configurationSource.js +7 -0
- package/dist/src/configuration/configurationSource.js.map +1 -0
- package/dist/src/configuration/environmentConfiguration.d.ts +14 -0
- package/dist/src/configuration/environmentConfiguration.js +271 -0
- package/dist/src/configuration/environmentConfiguration.js.map +1 -0
- package/dist/src/configuration/index.d.ts +7 -0
- package/dist/src/configuration/index.js +14 -0
- package/dist/src/configuration/index.js.map +1 -0
- package/dist/src/configuration/jsonFileConfigurationSource.d.ts +15 -0
- package/dist/src/configuration/jsonFileConfigurationSource.js +58 -0
- package/dist/src/configuration/jsonFileConfigurationSource.js.map +1 -0
- package/dist/src/createCloudAdapter.d.ts +30 -5
- package/dist/src/createCloudAdapter.js +17 -10
- package/dist/src/createCloudAdapter.js.map +1 -1
- package/dist/src/errorHelper.js +117 -5
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/observability/traces.d.ts +6 -4
- package/dist/src/observability/traces.js +10 -9
- package/dist/src/observability/traces.js.map +1 -1
- package/dist/src/outboundHostValidator.d.ts +4 -1
- package/dist/src/outboundHostValidator.js +25 -48
- package/dist/src/outboundHostValidator.js.map +1 -1
- package/dist/src/state/agentState.d.ts +8 -3
- package/dist/src/state/agentState.js +26 -8
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/state/conversationState.d.ts +2 -2
- package/dist/src/state/conversationState.js.map +1 -1
- package/dist/src/state/userState.d.ts +2 -2
- package/dist/src/state/userState.js.map +1 -1
- package/dist/src/statusCodes.d.ts +5 -0
- package/dist/src/statusCodes.js +5 -0
- package/dist/src/statusCodes.js.map +1 -1
- package/dist/src/storage/fileStorage.d.ts +83 -68
- package/dist/src/storage/fileStorage.js +279 -105
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/index.d.ts +1 -0
- package/dist/src/storage/index.js +1 -0
- package/dist/src/storage/index.js.map +1 -1
- package/dist/src/storage/memoryStorage.d.ts +85 -60
- package/dist/src/storage/memoryStorage.js +244 -87
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/storage/storage.d.ts +100 -2
- package/dist/src/storage/storage.js +25 -0
- package/dist/src/storage/storage.js.map +1 -1
- package/dist/src/storage/storageCompatibility.d.ts +17 -0
- package/dist/src/storage/storageCompatibility.js +157 -0
- package/dist/src/storage/storageCompatibility.js.map +1 -0
- package/dist/src/storage/storageExpiry.d.ts +6 -0
- package/dist/src/storage/storageExpiry.js +20 -0
- package/dist/src/storage/storageExpiry.js.map +1 -0
- package/dist/src/utils/env.d.ts +43 -0
- package/dist/src/utils/env.js +42 -6
- package/dist/src/utils/env.js.map +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.js +10 -1
- package/dist/src/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/app/agentApplication.ts +27 -14
- package/src/app/agentApplicationBuilder.ts +13 -2
- package/src/app/agentApplicationOptions.ts +18 -4
- package/src/app/auth/authorizationManager.ts +126 -204
- package/src/app/auth/handlerStorage.ts +51 -7
- package/src/app/auth/types.ts +2 -2
- package/src/app/index.ts +7 -0
- package/src/app/proactive/proactive.ts +19 -9
- package/src/app/proactive/proactiveOptions.ts +2 -2
- package/src/app/rateLimit.ts +659 -0
- package/src/app/turnState.ts +50 -7
- package/src/auth/authConfiguration.ts +415 -260
- package/src/auth/settings.ts +5 -82
- package/src/cloudAdapter.ts +38 -113
- package/src/configuration/botFrameworkEnvironmentCompatibility.ts +245 -0
- package/src/configuration/configuration.ts +1076 -0
- package/src/configuration/configurationSource.ts +76 -0
- package/src/configuration/environmentConfiguration.ts +377 -0
- package/src/configuration/index.ts +19 -0
- package/src/configuration/jsonFileConfigurationSource.ts +74 -0
- package/src/createCloudAdapter.ts +52 -9
- package/src/errorHelper.ts +143 -5
- package/src/index.ts +1 -0
- package/src/observability/traces.ts +8 -7
- package/src/outboundHostValidator.ts +37 -44
- package/src/state/agentState.ts +39 -13
- package/src/state/conversationState.ts +2 -2
- package/src/state/userState.ts +2 -2
- package/src/statusCodes.ts +6 -0
- package/src/storage/fileStorage.ts +299 -106
- package/src/storage/index.ts +1 -0
- package/src/storage/memoryStorage.ts +268 -85
- package/src/storage/storage.ts +114 -2
- package/src/storage/storageCompatibility.ts +185 -0
- package/src/storage/storageExpiry.ts +21 -0
- package/src/utils/env.ts +63 -0
- package/src/utils.ts +10 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proactive.js","sourceRoot":"","sources":["../../../../src/app/proactive/proactive.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;
|
|
1
|
+
{"version":3,"file":"proactive.js","sourceRoot":"","sources":["../../../../src/app/proactive/proactive.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AASlC,6EAK2C;AAI3C,gEAA4D;AAC5D,iDAA6C;AAC7C,kEAA0D;AAC1D,mDAA0C;AAC1C,uDAAsE;AAEtE,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,kBAAkB,CAAC,CAAA;AACxC,MAAM,kBAAkB,GAAG,0BAA0B,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH;IAUE,YAAa,GAA6B,EAAE,OAAyB;QACnE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,kCAAW,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC5E,CAAC;I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M,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;oBACpC,CAAC;oBAED,IAAI,OAAO,EAAE,CAAC;wBACZ,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAA;wBAClD,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;wBAC/C,MAAM,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;wBACzB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;oBACjD,CAAC;gBACH,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,WAAW,GAAG,GAAG,CAAA;gBACnB,CAAC;YACH,CAAC,CACF,CAAA;YAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE,aAAa,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;gBAClG,MAAM,WAAW,CAAA;YACnB,CAAC;YAED,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,2BAA2B,CAAC,CAAA;YACpF,CAAC;YACD,OAAO,YAAY,CAAA;QACrB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;;AA3fC;;GAEG;AACa,uCAA6B,GAAG,8DAA8D,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StorageProvider } from '../../storage/storage';
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for the proactive messaging subsystem.
|
|
4
4
|
*/
|
|
@@ -10,7 +10,7 @@ export interface ProactiveOptions {
|
|
|
10
10
|
* A warning is logged when the fallback is used.
|
|
11
11
|
* Throws at initialization time if neither is configured.
|
|
12
12
|
*/
|
|
13
|
-
storage?:
|
|
13
|
+
storage?: StorageProvider;
|
|
14
14
|
/**
|
|
15
15
|
* When `true` (default), `continueConversation()` throws if any requested
|
|
16
16
|
* token handler's user has not previously signed in.
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Activity, ActivityTypes } from '@microsoft/agents-activity';
|
|
6
|
+
import { StorageProvider } from '../storage';
|
|
7
|
+
import { TurnContext } from '../turnContext';
|
|
8
|
+
/**
|
|
9
|
+
* Defines how a rate limit rule groups incoming activities by scope key.
|
|
10
|
+
*
|
|
11
|
+
* The scope is the identity of the counter to increment after the rule has been
|
|
12
|
+
* selected for the turn. Use {@link RateLimitRule.appliesTo} to decide whether a
|
|
13
|
+
* rule should participate; use `scope` to decide which user, conversation,
|
|
14
|
+
* tenant, or other key should be counted.
|
|
15
|
+
*
|
|
16
|
+
* If a rule applies and the scope returns `undefined` or an empty string, the
|
|
17
|
+
* turn is throttled. This avoids silently bypassing a limit when the scope key
|
|
18
|
+
* cannot be derived.
|
|
19
|
+
*
|
|
20
|
+
* @example Per-user key:
|
|
21
|
+
* ```ts
|
|
22
|
+
* scope: (context) => context.activity.from?.id
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Per-conversation key:
|
|
26
|
+
* ```ts
|
|
27
|
+
* scope: (context) => context.activity.conversation?.id
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Per-user-per-conversation key:
|
|
31
|
+
* ```ts
|
|
32
|
+
* scope: (context) => `${context.activity.from?.id}:${context.activity.conversation?.id}`
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Per-tenant key:
|
|
36
|
+
* ```ts
|
|
37
|
+
* scope: (context) => context.activity.channelData?.tenantId
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export type RateLimitScope = (context: TurnContext) => string | undefined | Promise<string | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Defines how the application behaves when rate limit storage cannot be read or written.
|
|
43
|
+
*/
|
|
44
|
+
export type RateLimitStorageErrorBehavior = 'throttle' | 'allow' | 'throw';
|
|
45
|
+
/**
|
|
46
|
+
* Details about a rate limit decision.
|
|
47
|
+
*/
|
|
48
|
+
export interface RateLimitResult {
|
|
49
|
+
/**
|
|
50
|
+
* The index of the rule that produced the decision.
|
|
51
|
+
*/
|
|
52
|
+
ruleIndex: number;
|
|
53
|
+
/**
|
|
54
|
+
* The derived rate limit key.
|
|
55
|
+
*/
|
|
56
|
+
key?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Approximate delay before another activity would be accepted.
|
|
59
|
+
*
|
|
60
|
+
* For fixed-window limits, this is the time remaining until the current window
|
|
61
|
+
* for the scope key resets.
|
|
62
|
+
*/
|
|
63
|
+
retryAfterMs: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a message to send when a turn is throttled.
|
|
67
|
+
*
|
|
68
|
+
* The `result.retryAfterMs` value can be used to tell the user when another
|
|
69
|
+
* activity is expected to be accepted.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* message: (_context, result) => {
|
|
74
|
+
* const seconds = Math.ceil(result.retryAfterMs / 1000)
|
|
75
|
+
* return `Too many requests. Try again in ${seconds} seconds.`
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export type RateLimitMessageFactory = (context: TurnContext, result: RateLimitResult) => string | Activity | Promise<string | Activity>;
|
|
80
|
+
/**
|
|
81
|
+
* Configures one rate limit rule for incoming turns.
|
|
82
|
+
*
|
|
83
|
+
* A rule first decides whether it applies to the turn, then derives a scope key,
|
|
84
|
+
* then increments the fixed-window counter for that scope key.
|
|
85
|
+
* Multiple rules can apply to the same turn; the first rule whose counter is at
|
|
86
|
+
* the limit throttles the turn and prevents the route handler from running.
|
|
87
|
+
*
|
|
88
|
+
* The fixed window starts when the first matching activity for a scope key is
|
|
89
|
+
* accepted. It does not start when the limit is reached. For example, with
|
|
90
|
+
* `limit: 3` and `windowMs: 10_000`:
|
|
91
|
+
*
|
|
92
|
+
* - at 0s, the first matching activity is accepted and starts a window ending at 10s
|
|
93
|
+
* - at 1s and 2s, the second and third matching activities are accepted
|
|
94
|
+
* - at 3s, the fourth matching activity is throttled with `retryAfterMs` near 7000
|
|
95
|
+
* - at 10s, the window has expired and the next accepted activity starts a new window
|
|
96
|
+
*
|
|
97
|
+
* @example Limit all activities per user:
|
|
98
|
+
* ```ts
|
|
99
|
+
* {
|
|
100
|
+
* scope: (context) => context.activity.from?.id,
|
|
101
|
+
* limit: 10,
|
|
102
|
+
* windowMs: 60_000
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @example Limit only message activities per conversation:
|
|
107
|
+
* ```ts
|
|
108
|
+
* {
|
|
109
|
+
* scope: (context) => context.activity.conversation?.id,
|
|
110
|
+
* activityTypes: [ActivityTypes.Message],
|
|
111
|
+
* limit: 20,
|
|
112
|
+
* windowMs: 60_000
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @example Limit only an expensive command per user:
|
|
117
|
+
* ```ts
|
|
118
|
+
* {
|
|
119
|
+
* appliesTo: (context) => context.activity.text?.startsWith('/expensive') === true,
|
|
120
|
+
* scope: (context) => context.activity.from?.id,
|
|
121
|
+
* limit: 3,
|
|
122
|
+
* windowMs: 60_000
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export interface RateLimitRule {
|
|
127
|
+
/**
|
|
128
|
+
* Derives the scope key that will be counted when this rule applies.
|
|
129
|
+
*
|
|
130
|
+
* This property is required.
|
|
131
|
+
*
|
|
132
|
+
* This is for grouping, not filtering. Return the same key for activities that
|
|
133
|
+
* should share a quota, such as a user ID for per-user limits or a
|
|
134
|
+
* conversation ID for per-conversation limits.
|
|
135
|
+
*
|
|
136
|
+
* If this rule applies and the returned key is missing or blank, the turn is
|
|
137
|
+
* throttled instead of being allowed through without a counter.
|
|
138
|
+
*/
|
|
139
|
+
scope: RateLimitScope;
|
|
140
|
+
/**
|
|
141
|
+
* Maximum number of activities allowed for each scope key over `windowMs`.
|
|
142
|
+
*
|
|
143
|
+
* This property is required.
|
|
144
|
+
*
|
|
145
|
+
* Each accepted turn that matches the rule increments the counter for its
|
|
146
|
+
* scope key.
|
|
147
|
+
*/
|
|
148
|
+
limit: number;
|
|
149
|
+
/**
|
|
150
|
+
* Time window, in milliseconds, used for the rule's fixed-window counter.
|
|
151
|
+
*
|
|
152
|
+
* This property is required.
|
|
153
|
+
*
|
|
154
|
+
* For example, `limit: 5` and `windowMs: 60_000` allows up to five activities
|
|
155
|
+
* per minute for each scope key. The window starts when the first matching
|
|
156
|
+
* activity for the scope key is accepted, and resets after `windowMs`. If the
|
|
157
|
+
* counter reaches `limit` before the window resets, additional matching
|
|
158
|
+
* activities are throttled and `retryAfterMs` reports the remaining time in
|
|
159
|
+
* that same window.
|
|
160
|
+
*/
|
|
161
|
+
windowMs: number;
|
|
162
|
+
/**
|
|
163
|
+
* Activity types counted by this rule.
|
|
164
|
+
*
|
|
165
|
+
* When provided, the rule only applies to activities whose type is in this
|
|
166
|
+
* array.
|
|
167
|
+
*
|
|
168
|
+
* When omitted, the rule applies to all activity types, subject to `appliesTo`
|
|
169
|
+
* if that predicate is also configured.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* activityTypes: [ActivityTypes.Message]
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
activityTypes?: ActivityTypes[];
|
|
177
|
+
/**
|
|
178
|
+
* Optional predicate that decides whether this rule participates in the turn.
|
|
179
|
+
*
|
|
180
|
+
* When provided, it runs after the `activityTypes` check. If it returns
|
|
181
|
+
* `true`, the rule continues to `scope` and may increment a counter. If it
|
|
182
|
+
* returns `false`, the rule is skipped and no window state is read or written.
|
|
183
|
+
*
|
|
184
|
+
* When omitted, every activity that passed `activityTypes` is considered to
|
|
185
|
+
* match this rule.
|
|
186
|
+
*
|
|
187
|
+
* Use this for policy or feature filtering, such as limiting only a command,
|
|
188
|
+
* tenant, channel, or class of users.
|
|
189
|
+
*
|
|
190
|
+
* Keep this separate from `scope`: `appliesTo` answers "does this rule apply?",
|
|
191
|
+
* while `scope` answers "which scope key should be counted?".
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* appliesTo: (context) => context.activity.text?.startsWith('/expensive') === true
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
appliesTo?: (context: TurnContext) => boolean | Promise<boolean>;
|
|
199
|
+
/**
|
|
200
|
+
* Message sent when this rule throttles a turn.
|
|
201
|
+
*
|
|
202
|
+
* When provided, this message is used for throttled message turns. It can be a
|
|
203
|
+
* plain string, an Activity, or a factory. Use a factory when the response
|
|
204
|
+
* should include details such as `retryAfterMs`.
|
|
205
|
+
*
|
|
206
|
+
* When omitted, the default message is sent: "Too many requests. Please try
|
|
207
|
+
* again later."
|
|
208
|
+
*/
|
|
209
|
+
message?: string | Activity | RateLimitMessageFactory;
|
|
210
|
+
/**
|
|
211
|
+
* Storage used for this rule's fixed-window state.
|
|
212
|
+
*
|
|
213
|
+
* When provided, the rule reads and writes window state through this storage
|
|
214
|
+
* provider.
|
|
215
|
+
*
|
|
216
|
+
* When omitted, the rule uses the `AgentApplication` storage. If the
|
|
217
|
+
* application does not have storage configured, the limiter falls back to
|
|
218
|
+
* app-local memory storage. Provide rule-specific durable or shared storage
|
|
219
|
+
* when this rule should use a different store than the application state, or
|
|
220
|
+
* when limits must survive restarts or apply across multiple app instances.
|
|
221
|
+
*/
|
|
222
|
+
storage?: StorageProvider;
|
|
223
|
+
/**
|
|
224
|
+
* Behavior when rate limit storage fails. Defaults to `throttle`.
|
|
225
|
+
*
|
|
226
|
+
* When provided, the selected behavior is used when storage cannot be read or
|
|
227
|
+
* written. `throttle` fails closed and rejects the turn, `allow` fails open and
|
|
228
|
+
* lets the turn continue, and `throw` surfaces the storage error.
|
|
229
|
+
*
|
|
230
|
+
* When omitted, storage failures use `throttle`.
|
|
231
|
+
*/
|
|
232
|
+
storageErrorBehavior?: RateLimitStorageErrorBehavior;
|
|
233
|
+
/**
|
|
234
|
+
* Number of times to retry storage operations. Defaults to 3.
|
|
235
|
+
*
|
|
236
|
+
* When provided, failed window evaluations and writes are retried up to this many times before
|
|
237
|
+
* applying `storageErrorBehavior`.
|
|
238
|
+
*
|
|
239
|
+
* When omitted, failed window evaluations and writes are retried up to 3 times.
|
|
240
|
+
* Retries help when shared storage reports transient read or write failures.
|
|
241
|
+
*/
|
|
242
|
+
maxStorageRetries?: number;
|
|
243
|
+
}
|
|
244
|
+
interface RateLimitDecision {
|
|
245
|
+
allowed: boolean;
|
|
246
|
+
result?: RateLimitResult;
|
|
247
|
+
rule?: RateLimitRule;
|
|
248
|
+
}
|
|
249
|
+
export declare class AgentApplicationRateLimiter {
|
|
250
|
+
private readonly rules;
|
|
251
|
+
private readonly storage?;
|
|
252
|
+
private readonly fallbackStorage;
|
|
253
|
+
private readonly storageAdapters;
|
|
254
|
+
private readonly storageIds;
|
|
255
|
+
private readonly locks;
|
|
256
|
+
private nextStorageId;
|
|
257
|
+
/**
|
|
258
|
+
* Creates a limiter for the configured rules, using application storage as
|
|
259
|
+
* the shared fallback when a rule does not provide its own storage.
|
|
260
|
+
*/
|
|
261
|
+
constructor(rules: RateLimitRule[], storage?: StorageProvider | undefined);
|
|
262
|
+
/**
|
|
263
|
+
* Evaluates every applicable rule and stages window writes. The turn is
|
|
264
|
+
* allowed only when no rule is over its limit and all required writes succeed.
|
|
265
|
+
*/
|
|
266
|
+
shouldAllowTurn(context: TurnContext): Promise<RateLimitDecision>;
|
|
267
|
+
/**
|
|
268
|
+
* Reads and persists fixed-window state updates while holding key locks.
|
|
269
|
+
*
|
|
270
|
+
* The evaluation happens here so reads and writes use fresh eTags, and so
|
|
271
|
+
* concurrent first requests cannot all write wildcard-created counters.
|
|
272
|
+
*/
|
|
273
|
+
private commitPendingEvaluations;
|
|
274
|
+
/**
|
|
275
|
+
* Converts storage failures into the configured fail-open, fail-closed, or
|
|
276
|
+
* throw behavior.
|
|
277
|
+
*/
|
|
278
|
+
private handleStorageError;
|
|
279
|
+
/**
|
|
280
|
+
* Sends the throttled response through the correct channel mechanism.
|
|
281
|
+
*/
|
|
282
|
+
handleThrottledTurn(context: TurnContext, rule: RateLimitRule, result: RateLimitResult): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* Checks activity type and custom predicate filters before touching storage.
|
|
285
|
+
*/
|
|
286
|
+
private appliesToTurn;
|
|
287
|
+
/**
|
|
288
|
+
* Resolves and normalizes the storage key fragment for this rule and turn.
|
|
289
|
+
*/
|
|
290
|
+
private getScopeKey;
|
|
291
|
+
/**
|
|
292
|
+
* Reads the current window, decides whether the turn is over limit, and
|
|
293
|
+
* prepares the next window state when the turn should be counted.
|
|
294
|
+
*/
|
|
295
|
+
private evaluateRule;
|
|
296
|
+
private createPendingEvaluation;
|
|
297
|
+
private getStorageV2;
|
|
298
|
+
private withLocks;
|
|
299
|
+
private acquireLock;
|
|
300
|
+
private getLockKey;
|
|
301
|
+
private getStorageId;
|
|
302
|
+
/**
|
|
303
|
+
* Reuses the active window or starts a new one after the reset time.
|
|
304
|
+
*/
|
|
305
|
+
private getFixedWindow;
|
|
306
|
+
/**
|
|
307
|
+
* Resolves static and factory throttling messages to a sendable value.
|
|
308
|
+
*/
|
|
309
|
+
private resolveMessage;
|
|
310
|
+
/**
|
|
311
|
+
* Returns the fallback throttling text when a rule does not provide one.
|
|
312
|
+
*/
|
|
313
|
+
private getDefaultMessage;
|
|
314
|
+
}
|
|
315
|
+
export {};
|