@strands-agents/sdk 1.14.0 → 1.16.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.
Files changed (155) hide show
  1. package/dist/src/agent/agent-delegation.d.ts +9 -30
  2. package/dist/src/agent/agent-delegation.d.ts.map +1 -1
  3. package/dist/src/agent/agent-delegation.js +26 -98
  4. package/dist/src/agent/agent-delegation.js.map +1 -1
  5. package/dist/src/agent/agent.d.ts +26 -8
  6. package/dist/src/agent/agent.d.ts.map +1 -1
  7. package/dist/src/agent/agent.js +132 -53
  8. package/dist/src/agent/agent.js.map +1 -1
  9. package/dist/src/agent/continuation.d.ts +41 -0
  10. package/dist/src/agent/continuation.d.ts.map +1 -1
  11. package/dist/src/agent/continuation.js +41 -0
  12. package/dist/src/agent/continuation.js.map +1 -1
  13. package/dist/src/background-tasks/background-tasks.d.ts +41 -0
  14. package/dist/src/background-tasks/background-tasks.d.ts.map +1 -0
  15. package/dist/src/background-tasks/background-tasks.js +402 -0
  16. package/dist/src/background-tasks/background-tasks.js.map +1 -0
  17. package/dist/src/background-tasks/errors.d.ts +15 -0
  18. package/dist/src/background-tasks/errors.d.ts.map +1 -0
  19. package/dist/src/background-tasks/errors.js +21 -0
  20. package/dist/src/background-tasks/errors.js.map +1 -0
  21. package/dist/src/background-tasks/in-process/engine.d.ts +95 -0
  22. package/dist/src/background-tasks/in-process/engine.d.ts.map +1 -0
  23. package/dist/src/background-tasks/in-process/engine.js +306 -0
  24. package/dist/src/background-tasks/in-process/engine.js.map +1 -0
  25. package/dist/src/background-tasks/in-process/manager.d.ts +41 -0
  26. package/dist/src/background-tasks/in-process/manager.d.ts.map +1 -0
  27. package/dist/src/background-tasks/in-process/manager.js +214 -0
  28. package/dist/src/background-tasks/in-process/manager.js.map +1 -0
  29. package/dist/src/background-tasks/in-process/types.d.ts +71 -0
  30. package/dist/src/background-tasks/in-process/types.d.ts.map +1 -0
  31. package/dist/src/background-tasks/in-process/types.js +2 -0
  32. package/dist/src/background-tasks/in-process/types.js.map +1 -0
  33. package/dist/src/background-tasks/manager.d.ts +59 -0
  34. package/dist/src/background-tasks/manager.d.ts.map +1 -0
  35. package/dist/src/background-tasks/manager.js +2 -0
  36. package/dist/src/background-tasks/manager.js.map +1 -0
  37. package/dist/src/background-tasks/timer.d.ts +3 -0
  38. package/dist/src/background-tasks/timer.d.ts.map +1 -0
  39. package/dist/src/background-tasks/timer.js +11 -0
  40. package/dist/src/background-tasks/timer.js.map +1 -0
  41. package/dist/src/background-tasks/types.d.ts +60 -0
  42. package/dist/src/background-tasks/types.d.ts.map +1 -0
  43. package/dist/src/background-tasks/types.js +11 -0
  44. package/dist/src/background-tasks/types.js.map +1 -0
  45. package/dist/src/hooks/events.d.ts +6 -5
  46. package/dist/src/hooks/events.d.ts.map +1 -1
  47. package/dist/src/hooks/events.js +5 -4
  48. package/dist/src/hooks/events.js.map +1 -1
  49. package/dist/src/hooks/types.d.ts +1 -0
  50. package/dist/src/hooks/types.d.ts.map +1 -1
  51. package/dist/src/hooks/types.js +1 -0
  52. package/dist/src/hooks/types.js.map +1 -1
  53. package/dist/src/index.d.ts +3 -0
  54. package/dist/src/index.d.ts.map +1 -1
  55. package/dist/src/index.js +2 -0
  56. package/dist/src/index.js.map +1 -1
  57. package/dist/src/models/bedrock.d.ts +11 -0
  58. package/dist/src/models/bedrock.d.ts.map +1 -1
  59. package/dist/src/models/bedrock.js +61 -10
  60. package/dist/src/models/bedrock.js.map +1 -1
  61. package/dist/src/models/google/adapters.d.ts.map +1 -1
  62. package/dist/src/models/google/adapters.js +18 -4
  63. package/dist/src/models/google/adapters.js.map +1 -1
  64. package/dist/src/models/google/model.d.ts.map +1 -1
  65. package/dist/src/models/google/model.js +9 -7
  66. package/dist/src/models/google/model.js.map +1 -1
  67. package/dist/src/models/google/types.d.ts +2 -0
  68. package/dist/src/models/google/types.d.ts.map +1 -1
  69. package/dist/src/models/model.d.ts +4 -0
  70. package/dist/src/models/model.d.ts.map +1 -1
  71. package/dist/src/models/model.js.map +1 -1
  72. package/dist/src/models/openai/cache.d.ts +31 -0
  73. package/dist/src/models/openai/cache.d.ts.map +1 -0
  74. package/dist/src/models/openai/cache.js +56 -0
  75. package/dist/src/models/openai/cache.js.map +1 -0
  76. package/dist/src/models/openai/chat-adapter.d.ts.map +1 -1
  77. package/dist/src/models/openai/chat-adapter.js +2 -0
  78. package/dist/src/models/openai/chat-adapter.js.map +1 -1
  79. package/dist/src/models/openai/model.d.ts.map +1 -1
  80. package/dist/src/models/openai/model.js +9 -3
  81. package/dist/src/models/openai/model.js.map +1 -1
  82. package/dist/src/models/openai/responses-adapter.d.ts.map +1 -1
  83. package/dist/src/models/openai/responses-adapter.js +3 -1
  84. package/dist/src/models/openai/responses-adapter.js.map +1 -1
  85. package/dist/src/models/openai/types.d.ts +5 -1
  86. package/dist/src/models/openai/types.d.ts.map +1 -1
  87. package/dist/src/models/routing/fallback-strategy.d.ts +13 -0
  88. package/dist/src/models/routing/fallback-strategy.d.ts.map +1 -0
  89. package/dist/src/models/routing/fallback-strategy.js +33 -0
  90. package/dist/src/models/routing/fallback-strategy.js.map +1 -0
  91. package/dist/src/models/routing/index.d.ts +11 -0
  92. package/dist/src/models/routing/index.d.ts.map +1 -0
  93. package/dist/src/models/routing/index.js +9 -0
  94. package/dist/src/models/routing/index.js.map +1 -0
  95. package/dist/src/models/routing/router.d.ts +161 -0
  96. package/dist/src/models/routing/router.d.ts.map +1 -0
  97. package/dist/src/models/routing/router.js +474 -0
  98. package/dist/src/models/routing/router.js.map +1 -0
  99. package/dist/src/models/routing/strategy.d.ts +53 -0
  100. package/dist/src/models/routing/strategy.d.ts.map +1 -0
  101. package/dist/src/models/routing/strategy.js +2 -0
  102. package/dist/src/models/routing/strategy.js.map +1 -0
  103. package/dist/src/models/streaming.d.ts +12 -0
  104. package/dist/src/models/streaming.d.ts.map +1 -1
  105. package/dist/src/models/streaming.js +17 -0
  106. package/dist/src/models/streaming.js.map +1 -1
  107. package/dist/src/retry/default-model-retry-strategy.d.ts +3 -8
  108. package/dist/src/retry/default-model-retry-strategy.d.ts.map +1 -1
  109. package/dist/src/retry/default-model-retry-strategy.js +3 -8
  110. package/dist/src/retry/default-model-retry-strategy.js.map +1 -1
  111. package/dist/src/retry/model-retry-strategy.d.ts +6 -9
  112. package/dist/src/retry/model-retry-strategy.d.ts.map +1 -1
  113. package/dist/src/retry/model-retry-strategy.js +8 -12
  114. package/dist/src/retry/model-retry-strategy.js.map +1 -1
  115. package/dist/src/session/session-manager.d.ts +4 -0
  116. package/dist/src/session/session-manager.d.ts.map +1 -1
  117. package/dist/src/session/session-manager.js +6 -0
  118. package/dist/src/session/session-manager.js.map +1 -1
  119. package/dist/src/storage/local-file-storage.d.ts +4 -6
  120. package/dist/src/storage/local-file-storage.d.ts.map +1 -1
  121. package/dist/src/storage/local-file-storage.js +12 -10
  122. package/dist/src/storage/local-file-storage.js.map +1 -1
  123. package/dist/src/storage/search/keyword.d.ts +1 -0
  124. package/dist/src/storage/search/keyword.d.ts.map +1 -1
  125. package/dist/src/storage/search/keyword.js +124 -0
  126. package/dist/src/storage/search/keyword.js.map +1 -1
  127. package/dist/src/storage/search/qmd.d.ts +66 -0
  128. package/dist/src/storage/search/qmd.d.ts.map +1 -0
  129. package/dist/src/storage/search/qmd.js +124 -0
  130. package/dist/src/storage/search/qmd.js.map +1 -0
  131. package/dist/src/telemetry/meter.d.ts +8 -6
  132. package/dist/src/telemetry/meter.d.ts.map +1 -1
  133. package/dist/src/telemetry/meter.js +8 -7
  134. package/dist/src/telemetry/meter.js.map +1 -1
  135. package/dist/src/telemetry/tracer.d.ts.map +1 -1
  136. package/dist/src/telemetry/tracer.js +9 -2
  137. package/dist/src/telemetry/tracer.js.map +1 -1
  138. package/dist/src/tools/executors/executor.d.ts +11 -1
  139. package/dist/src/tools/executors/executor.d.ts.map +1 -1
  140. package/dist/src/tools/executors/executor.js +50 -16
  141. package/dist/src/tools/executors/executor.js.map +1 -1
  142. package/dist/src/tsconfig.tsbuildinfo +1 -1
  143. package/dist/src/types/agent.d.ts +12 -2
  144. package/dist/src/types/agent.d.ts.map +1 -1
  145. package/dist/src/types/agent.js +3 -2
  146. package/dist/src/types/agent.js.map +1 -1
  147. package/dist/src/vended-memory-stores/file-memory-store/index.d.ts +1 -1
  148. package/dist/src/vended-memory-stores/file-memory-store/index.d.ts.map +1 -1
  149. package/dist/src/vended-memory-stores/file-memory-store/store.d.ts +31 -0
  150. package/dist/src/vended-memory-stores/file-memory-store/store.d.ts.map +1 -1
  151. package/dist/src/vended-memory-stores/file-memory-store/store.js +48 -25
  152. package/dist/src/vended-memory-stores/file-memory-store/store.js.map +1 -1
  153. package/dist/src/vended-tools/file-editor/file-editor.js +35 -30
  154. package/dist/src/vended-tools/file-editor/file-editor.js.map +1 -1
  155. package/package.json +21 -4
@@ -0,0 +1,161 @@
1
+ import { Model } from '../model.js';
2
+ import type { Plugin } from '../../plugins/plugin.js';
3
+ import type { InvocationState, LocalAgent } from '../../types/agent.js';
4
+ import type { CandidateInput, RoutingStrategy } from './strategy.js';
5
+ /** Construction data for a {@link RoutingCandidate}. */
6
+ export interface RoutingCandidateOptions {
7
+ /** Concrete model or opaque nested router. */
8
+ readonly model: Model | ModelRouter;
9
+ /** Optional strategy-facing name. */
10
+ readonly name?: string;
11
+ /** Optional strategy-facing description. */
12
+ readonly description?: string;
13
+ }
14
+ /**
15
+ * A model or opaque model group with an optional name and description.
16
+ *
17
+ * Base instances are frozen automatically. Subclasses must freeze themselves after initializing additional fields.
18
+ */
19
+ export declare class RoutingCandidate {
20
+ /** Concrete model or opaque nested router. */
21
+ readonly model: Model | ModelRouter;
22
+ /** Optional strategy-facing name. */
23
+ readonly name?: string;
24
+ /** Optional strategy-facing description. */
25
+ readonly description?: string;
26
+ /**
27
+ * Create an immutable routing candidate.
28
+ *
29
+ * @param options - Candidate model, name, and description
30
+ */
31
+ constructor(options: RoutingCandidateOptions);
32
+ }
33
+ /** Options for constructing a {@link ModelRouter}. */
34
+ export interface ModelRouterOptions {
35
+ /** Strategy responsible for every routing decision. */
36
+ readonly strategy?: RoutingStrategy;
37
+ /** Maximum successful candidate switches per invocation. */
38
+ readonly maxSwitches?: number;
39
+ }
40
+ /**
41
+ * Routes each agent invocation among an immutable set of candidate models.
42
+ *
43
+ * The default {@link FallbackStrategy} prefers the candidate with the fewest recorded failures and
44
+ * breaks ties by declaration order. `maxSwitches` bounds successful candidate changes per invocation.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const router = new ModelRouter([
49
+ * new RoutingCandidate({ model: primary, name: 'primary' }),
50
+ * new RoutingCandidate({ model: fallback, name: 'fallback' }),
51
+ * ])
52
+ * const agent = new Agent({ model: router })
53
+ * ```
54
+ */
55
+ export declare class ModelRouter implements Plugin {
56
+ readonly name = "strands:model-router";
57
+ private readonly _candidates;
58
+ private readonly _strategy;
59
+ private readonly _maxSwitches?;
60
+ private readonly _attachedAgents;
61
+ private readonly _initializedAgents;
62
+ /**
63
+ * Create a model router.
64
+ *
65
+ * @param models - Candidate models, nested routers, or candidate wrappers
66
+ * @param options - Routing strategy and switch cap
67
+ * @throws TypeError if models or the strategy are invalid
68
+ * @throws Error if candidates are empty, duplicated, named alike, stateful, or `maxSwitches` is not a non-negative integer
69
+ */
70
+ constructor(models: readonly CandidateInput[], options?: ModelRouterOptions);
71
+ /** Normalized candidates in declaration order. */
72
+ get candidates(): readonly RoutingCandidate[];
73
+ /** First declared candidate resolved without consulting a strategy. */
74
+ get defaultModel(): Model;
75
+ /**
76
+ * Attach this router as an agent's configured model.
77
+ *
78
+ * @internal
79
+ * @param agent - Agent configured with this router
80
+ */
81
+ attachToAgent(agent: LocalAgent): void;
82
+ /**
83
+ * Register routing middleware and lifecycle hooks.
84
+ *
85
+ * @param agent - Agent using this router as its model
86
+ * @throws Error if attached as an ordinary plugin rather than as the model
87
+ */
88
+ initAgent(agent: LocalAgent): void;
89
+ /**
90
+ * Return the current routed model after hooks may have changed the selection.
91
+ *
92
+ * @internal
93
+ * @param agent - Agent making the model call
94
+ * @param invocationState - Live invocation state
95
+ * @returns Current routed model, or `undefined` before selection
96
+ */
97
+ getRoutedModel(agent: LocalAgent, invocationState: InvocationState): Model | undefined;
98
+ /** Apply the per-invocation selection to the model call, opening one on the first call. */
99
+ private _selectionMiddleware;
100
+ /** Make the opening choice and store its state in the invocation state under this pair's key. */
101
+ private _openAndCache;
102
+ /**
103
+ * Choose and resolve the candidate to start on.
104
+ *
105
+ * A decline serves the default model. A strategy that throws, and a candidate that will not resolve
106
+ * to a model, both propagate.
107
+ */
108
+ private _open;
109
+ /** Ask the strategy for a candidate and validate the answer. */
110
+ private _ask;
111
+ /** Return the candidate, throwing if the strategy broke its contract. */
112
+ private _validated;
113
+ /**
114
+ * Resolve a candidate to a concrete model, recursing into a nested router's selection.
115
+ *
116
+ * A nested router is asked with its own candidates and no attempts, so it contributes one candidate
117
+ * and never advances internally.
118
+ */
119
+ private _resolve;
120
+ /** Resolve this router's chosen candidate, or its default model if the strategy declines. */
121
+ private _selectModel;
122
+ /** Strategy class name, for logs that explain a routing decision. */
123
+ private get _strategyName();
124
+ /** Record the outcome and, after an unclaimed failure, apply the strategy's next choice. */
125
+ private _onModelResult;
126
+ /**
127
+ * Switch to the strategy's next candidate, returning whether the call should be retried.
128
+ *
129
+ * A usable new candidate is switched to. A strategy that throws, declines, or names a candidate the
130
+ * round already used leaves the model's error to surface. A candidate that will not resolve is
131
+ * unusable rather than unlucky, so it takes its slot in the round and the strategy is asked once
132
+ * more. Each pass either switches or consumes a slot, so the round stays bounded by the candidate
133
+ * count.
134
+ */
135
+ private _advance;
136
+ /**
137
+ * Build a {@link RoutingContext} over this router's candidates.
138
+ *
139
+ * Every ask goes through here, so the request a strategy sees is always a copy: the agent's messages
140
+ * and the registry's own tool specs are never handed over directly. Mirrors the copy the agent loop
141
+ * makes for each model call.
142
+ */
143
+ private _routingContext;
144
+ /** Drop this agent's routing state so it never spans invocations. */
145
+ private _clearState;
146
+ /** Return the routing state stored under this pair's key, ignoring any foreign value. */
147
+ private _getState;
148
+ /**
149
+ * Scope routing state to one agent/router pair.
150
+ *
151
+ * One invocation state can serve several agents, and one router several agents, so neither identity
152
+ * alone is a sufficient key. `agentId` cannot serve either: it is caller-supplied and defaults, so
153
+ * two agents sharing a router could collide. Object identity is unique among live agents, and the
154
+ * state is cleared at both ends of an invocation, so a recycled entry cannot match a live one.
155
+ *
156
+ * The key carries no per-invocation component, so isolation between concurrent invocations relies on
157
+ * the agent allowing only one at a time, which is its default.
158
+ */
159
+ private _stateKey;
160
+ }
161
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../src/models/routing/router.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAInC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAkC,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpG,wDAAwD;AACxD,MAAM,WAAW,uBAAuB;IACtC,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAAA;IACnC,qCAAqC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAAA;IACnC,qCAAqC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;OAIG;gBACS,OAAO,EAA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cAAc;IAsB5B;;;;;;;;OAQG;YACW,QAAQ;IAuDtB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAkBvB,qEAAqE;IACrE,OAAO,CAAC,WAAW;IAKnB,yFAAyF;IACzF,OAAO,CAAC,SAAS;IAKjB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,SAAS;CAGlB"}
@@ -0,0 +1,474 @@
1
+ /**
2
+ * Model routing primitives.
3
+ *
4
+ * A {@link ModelRouter} asks its {@link RoutingStrategy} before the first model call and after
5
+ * unclaimed failures until routing stops. Returning `undefined` from the opening selection uses the
6
+ * first candidate's concrete default model; returning it after a failure preserves the pending error.
7
+ *
8
+ * A failure round uses each candidate at most once. A successful call starts a new round with that
9
+ * candidate already counted as used. Nested routers are opaque candidates: they make one selection
10
+ * with an empty attempt history and do not perform internal failover for the outer router.
11
+ *
12
+ * `agent.model` remains the first candidate's concrete model. Opening selection runs in model input
13
+ * middleware after continuation input is incorporated, so the opening before-model hook reports that
14
+ * default while {@link AfterModelCallEvent} reports the effective routed model. Token estimation also
15
+ * uses the default model, so prefer candidates with comparable context windows and tokenizers. If a
16
+ * candidate fails after emitting part of a streamed response, consumers see that partial output
17
+ * followed by the replacement model's full response.
18
+ *
19
+ * The API is provisional and may change before it is finalized.
20
+ */
21
+ import { CancelledError, normalizeError } from '../../errors.js';
22
+ import { AfterInvocationEvent, AfterModelCallEvent, BeforeInvocationEvent } from '../../hooks/events.js';
23
+ import { HookOrder } from '../../hooks/types.js';
24
+ import { logger } from '../../logging/logger.js';
25
+ import { InvokeModelStage } from '../../middleware/stages.js';
26
+ import { Model } from '../model.js';
27
+ import { cloneSystemPrompt } from '../../types/messages.js';
28
+ import { deepCopy } from '../../types/json.js';
29
+ import { FallbackStrategy } from './fallback-strategy.js';
30
+ /**
31
+ * A model or opaque model group with an optional name and description.
32
+ *
33
+ * Base instances are frozen automatically. Subclasses must freeze themselves after initializing additional fields.
34
+ */
35
+ export class RoutingCandidate {
36
+ /** Concrete model or opaque nested router. */
37
+ model;
38
+ /** Optional strategy-facing name. */
39
+ name;
40
+ /** Optional strategy-facing description. */
41
+ description;
42
+ /**
43
+ * Create an immutable routing candidate.
44
+ *
45
+ * @param options - Candidate model, name, and description
46
+ */
47
+ constructor(options) {
48
+ this.model = options.model;
49
+ if (options.name !== undefined)
50
+ this.name = options.name;
51
+ if (options.description !== undefined)
52
+ this.description = options.description;
53
+ if (new.target === RoutingCandidate)
54
+ Object.freeze(this);
55
+ }
56
+ }
57
+ /** Per-invocation candidate, attempt history, and switch accounting. */
58
+ class RoutingState {
59
+ candidate;
60
+ model;
61
+ attempts = [];
62
+ switchedTo;
63
+ switches = 0;
64
+ constructor(candidate, model) {
65
+ this.candidate = candidate;
66
+ this.model = model;
67
+ // The opening candidate counts as used for this round.
68
+ this.switchedTo = new Set([candidate]);
69
+ }
70
+ }
71
+ const ROUTING_KEY_PREFIX = 'strands:modelRouting';
72
+ /** Lazily minted per-object identity numbers (the `id()` equivalent for state keys), weakly held. */
73
+ const OBJECT_IDS = new WeakMap();
74
+ let nextObjectId = 1;
75
+ /**
76
+ * Routes each agent invocation among an immutable set of candidate models.
77
+ *
78
+ * The default {@link FallbackStrategy} prefers the candidate with the fewest recorded failures and
79
+ * breaks ties by declaration order. `maxSwitches` bounds successful candidate changes per invocation.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const router = new ModelRouter([
84
+ * new RoutingCandidate({ model: primary, name: 'primary' }),
85
+ * new RoutingCandidate({ model: fallback, name: 'fallback' }),
86
+ * ])
87
+ * const agent = new Agent({ model: router })
88
+ * ```
89
+ */
90
+ export class ModelRouter {
91
+ name = 'strands:model-router';
92
+ _candidates;
93
+ _strategy;
94
+ _maxSwitches;
95
+ _attachedAgents = new WeakSet();
96
+ _initializedAgents = new WeakSet();
97
+ /**
98
+ * Create a model router.
99
+ *
100
+ * @param models - Candidate models, nested routers, or candidate wrappers
101
+ * @param options - Routing strategy and switch cap
102
+ * @throws TypeError if models or the strategy are invalid
103
+ * @throws Error if candidates are empty, duplicated, named alike, stateful, or `maxSwitches` is not a non-negative integer
104
+ */
105
+ constructor(models, options = {}) {
106
+ if (options.strategy !== undefined && !isRoutingStrategy(options.strategy)) {
107
+ throw new TypeError('strategy must implement RoutingStrategy: a select(context) method');
108
+ }
109
+ if (options.maxSwitches !== undefined && (!Number.isInteger(options.maxSwitches) || options.maxSwitches < 0)) {
110
+ throw new Error('maxSwitches must be a non-negative integer');
111
+ }
112
+ const candidates = normalize(models);
113
+ if (candidates.length === 0)
114
+ throw new Error('ModelRouter requires at least one candidate model');
115
+ rejectStateful(candidates);
116
+ rejectDuplicates(candidates);
117
+ this._candidates = Object.freeze(candidates);
118
+ this._strategy = options.strategy ?? new FallbackStrategy();
119
+ if (options.maxSwitches !== undefined)
120
+ this._maxSwitches = options.maxSwitches;
121
+ }
122
+ /** Normalized candidates in declaration order. */
123
+ get candidates() {
124
+ return this._candidates;
125
+ }
126
+ /** First declared candidate resolved without consulting a strategy. */
127
+ get defaultModel() {
128
+ const model = this._candidates[0].model;
129
+ return model instanceof ModelRouter ? model.defaultModel : model;
130
+ }
131
+ /**
132
+ * Attach this router as an agent's configured model.
133
+ *
134
+ * @internal
135
+ * @param agent - Agent configured with this router
136
+ */
137
+ attachToAgent(agent) {
138
+ this._attachedAgents.add(agent);
139
+ this.initAgent(agent);
140
+ }
141
+ /**
142
+ * Register routing middleware and lifecycle hooks.
143
+ *
144
+ * @param agent - Agent using this router as its model
145
+ * @throws Error if attached as an ordinary plugin rather than as the model
146
+ */
147
+ initAgent(agent) {
148
+ if (!this._attachedAgents.has(agent)) {
149
+ throw new Error('ModelRouter must be passed through Agent({ model }), not plugins');
150
+ }
151
+ if (this._initializedAgents.has(agent))
152
+ return;
153
+ this._initializedAgents.add(agent);
154
+ agent.addMiddleware(InvokeModelStage.Input, (context) => this._selectionMiddleware(context));
155
+ agent.addHook(AfterModelCallEvent, (event) => this._onModelResult(event), { order: HookOrder.MODEL_ROUTING });
156
+ agent.addHook(AfterInvocationEvent, (event) => this._clearState(event.agent, event.invocationState), {
157
+ order: HookOrder.SDK_LAST,
158
+ });
159
+ agent.addHook(BeforeInvocationEvent, (event) => this._clearState(event.agent, event.invocationState), {
160
+ order: HookOrder.SDK_FIRST,
161
+ });
162
+ }
163
+ /**
164
+ * Return the current routed model after hooks may have changed the selection.
165
+ *
166
+ * @internal
167
+ * @param agent - Agent making the model call
168
+ * @param invocationState - Live invocation state
169
+ * @returns Current routed model, or `undefined` before selection
170
+ */
171
+ getRoutedModel(agent, invocationState) {
172
+ return this._getState(agent, invocationState)?.model;
173
+ }
174
+ /** Apply the per-invocation selection to the model call, opening one on the first call. */
175
+ async _selectionMiddleware(context) {
176
+ let state = this._getState(context.agent, context.invocationState);
177
+ if (state === undefined) {
178
+ const routingContext = this._routingContext([...context.messages], context.systemPrompt, [...context.toolSpecs], context.invocationState);
179
+ state = await this._openAndCache(context.agent, context.invocationState, routingContext);
180
+ }
181
+ return { ...context, model: state.model };
182
+ }
183
+ /** Make the opening choice and store its state in the invocation state under this pair's key. */
184
+ async _openAndCache(agent, invocationState, context) {
185
+ const [candidate, model] = await this._open(context);
186
+ const state = new RoutingState(candidate, model);
187
+ invocationState[this._stateKey(agent)] = state;
188
+ return state;
189
+ }
190
+ /**
191
+ * Choose and resolve the candidate to start on.
192
+ *
193
+ * A decline serves the default model. A strategy that throws, and a candidate that will not resolve
194
+ * to a model, both propagate.
195
+ */
196
+ async _open(context) {
197
+ const candidate = await this._ask(context);
198
+ if (candidate === undefined) {
199
+ logger.info(`strategy=<${this._strategyName}> | strategy declined the opening choice, using the default model`);
200
+ return [this._candidates[0], this.defaultModel];
201
+ }
202
+ logger.info(`strategy=<${this._strategyName}>, candidate=<${candidateLabel(candidate)}> | candidate selected`);
203
+ return [candidate, await this._resolve(candidate, context)];
204
+ }
205
+ /** Ask the strategy for a candidate and validate the answer. */
206
+ async _ask(context) {
207
+ return this._validated(await this._strategy.select(context), context);
208
+ }
209
+ /** Return the candidate, throwing if the strategy broke its contract. */
210
+ _validated(candidate, context) {
211
+ if (candidate === undefined)
212
+ return undefined;
213
+ if (!(candidate instanceof RoutingCandidate)) {
214
+ throw new TypeError(`strategy.select must return a RoutingCandidate or undefined; got ${typeName(candidate)}`);
215
+ }
216
+ if (!context.candidates.some((configured) => configured === candidate)) {
217
+ throw new Error('strategy.select must return a candidate from context.candidates');
218
+ }
219
+ return candidate;
220
+ }
221
+ /**
222
+ * Resolve a candidate to a concrete model, recursing into a nested router's selection.
223
+ *
224
+ * A nested router is asked with its own candidates and no attempts, so it contributes one candidate
225
+ * and never advances internally.
226
+ */
227
+ async _resolve(candidate, context) {
228
+ if (!(candidate.model instanceof ModelRouter))
229
+ return candidate.model;
230
+ return candidate.model._selectModel(candidate.model._routingContext(context.messages, context.systemPrompt, context.toolSpecs, context.invocationState, []));
231
+ }
232
+ /** Resolve this router's chosen candidate, or its default model if the strategy declines. */
233
+ async _selectModel(context) {
234
+ const candidate = await this._ask(context);
235
+ if (candidate === undefined)
236
+ return this.defaultModel;
237
+ return this._resolve(candidate, context);
238
+ }
239
+ /** Strategy class name, for logs that explain a routing decision. */
240
+ get _strategyName() {
241
+ return this._strategy.constructor.name;
242
+ }
243
+ /** Record the outcome and, after an unclaimed failure, apply the strategy's next choice. */
244
+ async _onModelResult(event) {
245
+ const state = this._getState(event.agent, event.invocationState);
246
+ if (state === undefined)
247
+ return;
248
+ if (event.error instanceof CancelledError)
249
+ return;
250
+ if (event.stopData !== undefined) {
251
+ state.attempts.push(makeAttempt(state.candidate));
252
+ // The candidate that succeeded opens the next round, counting as used like any opening choice.
253
+ state.switchedTo = new Set([state.candidate]);
254
+ return;
255
+ }
256
+ if (event.retry || event.error === undefined)
257
+ return;
258
+ state.attempts.push(makeAttempt(state.candidate, event.error));
259
+ if (this._maxSwitches !== undefined && state.switches >= this._maxSwitches) {
260
+ logger.warn(`maxSwitches=<${this._maxSwitches}> | switch cap reached, leaving the error to surface`);
261
+ return;
262
+ }
263
+ if (await this._advance(event, state))
264
+ event.retry = true;
265
+ }
266
+ /**
267
+ * Switch to the strategy's next candidate, returning whether the call should be retried.
268
+ *
269
+ * A usable new candidate is switched to. A strategy that throws, declines, or names a candidate the
270
+ * round already used leaves the model's error to surface. A candidate that will not resolve is
271
+ * unusable rather than unlucky, so it takes its slot in the round and the strategy is asked once
272
+ * more. Each pass either switches or consumes a slot, so the round stays bounded by the candidate
273
+ * count.
274
+ */
275
+ async _advance(event, state) {
276
+ while (true) {
277
+ const context = this._routingContext(event.agent.messages, event.agent.systemPrompt, event.agent.toolRegistry.list().map((tool) => tool.toolSpec), event.invocationState, state.attempts);
278
+ let candidate;
279
+ try {
280
+ // Validated inside the try: a model error is already pending, so a broken answer must not
281
+ // replace it. The opening choice has nothing pending and lets the error surface.
282
+ candidate = this._validated(await this._strategy.select(context), context);
283
+ }
284
+ catch (error) {
285
+ logger.warn(`strategy=<${this._strategyName}>, error=<${String(error)}> | routing failed, leaving the error to surface`);
286
+ return false;
287
+ }
288
+ if (candidate === undefined)
289
+ return false;
290
+ // A round uses each candidate at most once, so a strategy that cycles cannot keep resetting
291
+ // the retry budget.
292
+ if (state.switchedTo.has(candidate)) {
293
+ logger.info(`candidate=<${candidateLabel(candidate)}> | already used this round, leaving the error to surface`);
294
+ return false;
295
+ }
296
+ let model;
297
+ try {
298
+ model = await this._resolve(candidate, context);
299
+ }
300
+ catch (error) {
301
+ const resolutionError = normalizeError(error);
302
+ logger.warn(`candidate=<${candidateLabel(candidate)}>, error=<${resolutionError}> | candidate could not be resolved, asking again`);
303
+ // Recorded so a strategy reading attempts stops offering it, and slot-burned so termination
304
+ // does not depend on the strategy doing that.
305
+ state.attempts.push(makeAttempt(candidate, resolutionError));
306
+ state.switchedTo.add(candidate);
307
+ continue;
308
+ }
309
+ logger.info(`from_candidate=<${candidateLabel(state.candidate)}>, to_candidate=<${candidateLabel(candidate)}>, error=<${event.error?.constructor.name}> | model call failed, switching candidate`);
310
+ state.candidate = candidate;
311
+ state.model = model;
312
+ state.switchedTo.add(candidate);
313
+ state.switches += 1;
314
+ return true;
315
+ }
316
+ }
317
+ /**
318
+ * Build a {@link RoutingContext} over this router's candidates.
319
+ *
320
+ * Every ask goes through here, so the request a strategy sees is always a copy: the agent's messages
321
+ * and the registry's own tool specs are never handed over directly. Mirrors the copy the agent loop
322
+ * makes for each model call.
323
+ */
324
+ _routingContext(messages, systemPrompt, toolSpecs, invocationState, attempts = []) {
325
+ const context = {
326
+ messages: messages.map((message) => message.clone()),
327
+ ...(systemPrompt !== undefined && { systemPrompt: cloneSystemPrompt(systemPrompt) }),
328
+ toolSpecs: deepCopy(toolSpecs),
329
+ candidates: this._candidates,
330
+ invocationState,
331
+ attempts: Object.freeze([...attempts]),
332
+ };
333
+ return Object.freeze(context);
334
+ }
335
+ /** Drop this agent's routing state so it never spans invocations. */
336
+ _clearState(agent, invocationState) {
337
+ const key = this._stateKey(agent);
338
+ if (this._getState(agent, invocationState) !== undefined)
339
+ delete invocationState[key];
340
+ }
341
+ /** Return the routing state stored under this pair's key, ignoring any foreign value. */
342
+ _getState(agent, invocationState) {
343
+ const value = invocationState[this._stateKey(agent)];
344
+ return value instanceof RoutingState ? value : undefined;
345
+ }
346
+ /**
347
+ * Scope routing state to one agent/router pair.
348
+ *
349
+ * One invocation state can serve several agents, and one router several agents, so neither identity
350
+ * alone is a sufficient key. `agentId` cannot serve either: it is caller-supplied and defaults, so
351
+ * two agents sharing a router could collide. Object identity is unique among live agents, and the
352
+ * state is cleared at both ends of an invocation, so a recycled entry cannot match a live one.
353
+ *
354
+ * The key carries no per-invocation component, so isolation between concurrent invocations relies on
355
+ * the agent allowing only one at a time, which is its default.
356
+ */
357
+ _stateKey(agent) {
358
+ return `${ROUTING_KEY_PREFIX}:${objectId(agent).toString(16)}:${objectId(this).toString(16)}`;
359
+ }
360
+ }
361
+ /** Freeze a routing attempt, omitting `exception` for a success. */
362
+ function makeAttempt(candidate, exception) {
363
+ return Object.freeze({ candidate, ...(exception !== undefined && { exception }) });
364
+ }
365
+ /** Return a stable identity number for the object, minting one on first use. */
366
+ function objectId(value) {
367
+ let identity = OBJECT_IDS.get(value);
368
+ if (identity === undefined) {
369
+ identity = nextObjectId;
370
+ nextObjectId += 1;
371
+ OBJECT_IDS.set(value, identity);
372
+ }
373
+ return identity;
374
+ }
375
+ /** Coerce the input array into {@link RoutingCandidate} objects, validating candidate types. */
376
+ function normalize(models) {
377
+ if (!Array.isArray(models))
378
+ throw new TypeError('models must be a sequence of candidates');
379
+ return models.map(asCandidate);
380
+ }
381
+ /** Wrap a candidate input in a {@link RoutingCandidate}, validating its model type. */
382
+ function asCandidate(item) {
383
+ const candidate = item instanceof RoutingCandidate ? item : new RoutingCandidate({ model: item });
384
+ if (!(candidate.model instanceof Model) && !(candidate.model instanceof ModelRouter)) {
385
+ throw new TypeError(`candidate must be a Model or ModelRouter; got ${typeName(candidate.model)}`);
386
+ }
387
+ return candidate;
388
+ }
389
+ /** Reject any stateful candidate model. */
390
+ function rejectStateful(candidates) {
391
+ for (const candidate of candidates) {
392
+ if (candidate.model instanceof Model && candidate.model.stateful) {
393
+ throw new Error(`candidate=<${candidateLabel(candidate)}> is stateful; routing among stateful models is not supported`);
394
+ }
395
+ }
396
+ }
397
+ /**
398
+ * Reject repeated candidates, repeated models, or colliding names.
399
+ *
400
+ * Strategies track health per candidate, so one model behind two candidates would get two failure
401
+ * budgets and never be demoted. The model check reaches through a nested router; names stay per level,
402
+ * since a strategy only chooses among the candidates it is shown.
403
+ */
404
+ function rejectDuplicates(candidates) {
405
+ const seenCandidates = new Set();
406
+ const seenModels = new Set();
407
+ const seenNames = new Set();
408
+ for (const candidate of candidates) {
409
+ if (seenCandidates.has(candidate))
410
+ throw new Error('duplicate RoutingCandidate instance');
411
+ seenCandidates.add(candidate);
412
+ for (const model of reachableModels(candidate)) {
413
+ if (seenModels.has(model)) {
414
+ throw new Error(`candidate=<${candidateLabel(candidate)}> repeats a model already routed to; construct a separate instance so each candidate has its own health`);
415
+ }
416
+ seenModels.add(model);
417
+ }
418
+ if (candidate.name === undefined)
419
+ continue;
420
+ if (seenNames.has(candidate.name))
421
+ throw new Error(`duplicate candidate name=<${candidate.name}>`);
422
+ seenNames.add(candidate.name);
423
+ }
424
+ }
425
+ /** Yield every concrete model this candidate can run, descending into a nested router. */
426
+ function* reachableModels(candidate) {
427
+ if (candidate.model instanceof ModelRouter) {
428
+ for (const nested of candidate.model.candidates)
429
+ yield* reachableModels(nested);
430
+ }
431
+ else {
432
+ yield candidate.model;
433
+ }
434
+ }
435
+ /** Return the candidate's name, or its provider and model id when it has none. */
436
+ function candidateLabel(candidate) {
437
+ if (candidate.name !== undefined && candidate.name.length > 0)
438
+ return candidate.name;
439
+ return candidate.model instanceof Model ? modelLabel(candidate.model) : candidate.model.constructor.name;
440
+ }
441
+ /**
442
+ * Label a model by provider and model id.
443
+ *
444
+ * Labels are built eagerly, as log arguments and by the construction guards, so one must never fail a
445
+ * routed call or mask a construction error.
446
+ */
447
+ function modelLabel(model) {
448
+ const provider = model.constructor.name;
449
+ try {
450
+ const modelId = model.getConfig()?.modelId;
451
+ return modelId ? `${provider}/${modelId}` : provider;
452
+ }
453
+ catch {
454
+ return provider;
455
+ }
456
+ }
457
+ /** Check whether the value structurally implements {@link RoutingStrategy}. */
458
+ function isRoutingStrategy(strategy) {
459
+ return isObject(strategy) && 'select' in strategy && typeof strategy.select === 'function';
460
+ }
461
+ function isObject(value) {
462
+ return typeof value === 'object' && value !== null;
463
+ }
464
+ /** Describe a value's type for error messages. */
465
+ function typeName(value) {
466
+ if (value === null)
467
+ return 'null';
468
+ if (value === undefined)
469
+ return 'undefined';
470
+ if (typeof value === 'object')
471
+ return value.constructor?.name ?? 'object';
472
+ return typeof value;
473
+ }
474
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../src/models/routing/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OA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