@cuylabs/agent-core 0.7.0 → 0.8.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/dist/{builder-BRvqCcIk.d.ts → builder-UpOWQMW3.d.ts} +2 -2
- package/dist/{chunk-3HNO5SVI.js → chunk-4BDA7DQY.js} +3 -3
- package/dist/chunk-BFM2YHNM.js +222 -0
- package/dist/chunk-CAA7FHIH.js +280 -0
- package/dist/chunk-DWYX7ASF.js +26 -0
- package/dist/chunk-KUVSERLJ.js +50 -0
- package/dist/{chunk-5K7AQVOU.js → chunk-N6HWIEEA.js} +8 -204
- package/dist/{chunk-QGOGIP7T.js → chunk-RFEKJKTO.js} +131 -25
- package/dist/chunk-RZITT45F.js +202 -0
- package/dist/{chunk-ZPMACVZK.js → chunk-SQU2AJHO.js} +1 -1
- package/dist/{chunk-BNSHUWCV.js → chunk-WWYYNWEW.js} +1 -1
- package/dist/{chunk-CDTV2UYU.js → chunk-YSLSEQ6B.js} +52 -252
- package/dist/context/index.js +1 -1
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.js +16 -0
- package/dist/events-CE72w8W4.d.ts +149 -0
- package/dist/{index-C33hlD6H.d.ts → index-CWSchSql.d.ts} +36 -50
- package/dist/index.d.ts +36 -109
- package/dist/index.js +213 -396
- package/dist/inference/index.d.ts +10 -7
- package/dist/inference/index.js +7 -5
- package/dist/llm-error-D93FNNLY.d.ts +32 -0
- package/dist/middleware/index.d.ts +245 -7
- package/dist/middleware/index.js +3 -1
- package/dist/models/index.d.ts +125 -4
- package/dist/models/index.js +7 -3
- package/dist/presets/index.d.ts +53 -0
- package/dist/presets/index.js +28 -0
- package/dist/prompt/index.d.ts +10 -8
- package/dist/reasoning/index.d.ts +1 -2
- package/dist/reasoning/index.js +3 -7
- package/dist/{registry-BDLIHOQB.d.ts → registry-DwYqsQkX.d.ts} +1 -1
- package/dist/{runner-DSKaEz3z.d.ts → runner-e2YRcUoX.d.ts} +58 -151
- package/dist/runtime/index.d.ts +11 -8
- package/dist/runtime/index.js +9 -7
- package/dist/safety/index.d.ts +38 -0
- package/dist/safety/index.js +12 -0
- package/dist/scope/index.d.ts +2 -2
- package/dist/signal/index.d.ts +28 -0
- package/dist/signal/index.js +6 -0
- package/dist/skill/index.d.ts +7 -6
- package/dist/sub-agent/index.d.ts +14 -9
- package/dist/tool/index.d.ts +7 -5
- package/dist/tool/index.js +2 -2
- package/dist/tool-BHbyUAy3.d.ts +150 -0
- package/dist/{tool-HUtkiVBx.d.ts → tool-DLXAR9Ce.d.ts} +1 -1
- package/dist/tracking/index.d.ts +2 -2
- package/dist/{tool-Db1Ue-1U.d.ts → types-BfNpU8NS.d.ts} +1 -150
- package/dist/types-BnpEOYV-.d.ts +50 -0
- package/dist/{types-9jGQUjqW.d.ts → types-CQL-SvTn.d.ts} +1 -1
- package/dist/types-CWm-7rvB.d.ts +55 -0
- package/dist/{types-FRpzzg_9.d.ts → types-KKDrdU9Y.d.ts} +5 -35
- package/dist/{capability-resolver-CgRGsWVX.d.ts → types-QA4WhEfz.d.ts} +1 -117
- package/dist/{types-CqDZTh4d.d.ts → types-QKHHQLLq.d.ts} +5 -4
- package/dist/types-YuWV4ag7.d.ts +72 -0
- package/package.json +58 -3
- package/dist/index-CfBGYrpd.d.ts +0 -317
- package/dist/{chunk-IEFIQENH.js → chunk-7VKQ4WPB.js} +4 -4
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { ToolSet } from 'ai';
|
|
2
|
-
import { T as Tool } from '../tool-
|
|
2
|
+
import { T as Tool } from '../tool-BHbyUAy3.js';
|
|
3
3
|
import { T as ToolHost } from '../types-CHiPh8U2.js';
|
|
4
|
-
import { M as MiddlewareRunner } from '../runner-
|
|
5
|
-
export { S as StreamChunk } from '../runner-
|
|
6
|
-
import { d as TurnTrackerContext } from '../tool-
|
|
7
|
-
import { T as ToolExecutionMode, I as InferenceStreamInput, A as AnyInferenceResult } from '../types-
|
|
8
|
-
export { a as AnyStreamResult, C as CustomStreamProvider, b as CustomStreamResult, D as DEFAULT_MAX_OUTPUT_TOKENS, c as InferenceCustomResult, d as InferenceStepInfo, e as InferenceStreamResult, L as LLMStreamInput, f as LLMStreamResult, O as OUTPUT_TOKEN_MAX, S as StepInfo } from '../types-
|
|
4
|
+
import { M as MiddlewareRunner } from '../runner-e2YRcUoX.js';
|
|
5
|
+
export { S as StreamChunk } from '../runner-e2YRcUoX.js';
|
|
6
|
+
import { d as TurnTrackerContext } from '../tool-DLXAR9Ce.js';
|
|
7
|
+
import { T as ToolExecutionMode, I as InferenceStreamInput, A as AnyInferenceResult } from '../types-KKDrdU9Y.js';
|
|
8
|
+
export { a as AnyStreamResult, C as CustomStreamProvider, b as CustomStreamResult, D as DEFAULT_MAX_OUTPUT_TOKENS, c as InferenceCustomResult, d as InferenceStepInfo, e as InferenceStreamResult, L as LLMStreamInput, f as LLMStreamResult, O as OUTPUT_TOKEN_MAX, S as StepInfo } from '../types-KKDrdU9Y.js';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@ai-sdk/provider-utils';
|
|
11
|
+
import '../events-CE72w8W4.js';
|
|
11
12
|
import '../messages-BYWGn8TY.js';
|
|
12
|
-
import '../types-
|
|
13
|
+
import '../types-BfNpU8NS.js';
|
|
14
|
+
import '../types-CQL-SvTn.js';
|
|
13
15
|
import '../types-CQaXbRsS.js';
|
|
16
|
+
import '../llm-error-D93FNNLY.js';
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* Build a Vercel AI SDK `ToolSet` from `Tool.Info` definitions.
|
package/dist/inference/index.js
CHANGED
|
@@ -7,12 +7,14 @@ import {
|
|
|
7
7
|
stream,
|
|
8
8
|
streamOnce,
|
|
9
9
|
streamStep
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-IEFIQENH.js";
|
|
13
|
-
import "../chunk-N7P4PN3O.js";
|
|
10
|
+
} from "../chunk-N6HWIEEA.js";
|
|
11
|
+
import "../chunk-7VKQ4WPB.js";
|
|
14
12
|
import "../chunk-VEKUXUVF.js";
|
|
15
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-SQU2AJHO.js";
|
|
14
|
+
import "../chunk-N7P4PN3O.js";
|
|
15
|
+
import "../chunk-RZITT45F.js";
|
|
16
|
+
import "../chunk-RFEKJKTO.js";
|
|
17
|
+
import "../chunk-DWYX7ASF.js";
|
|
16
18
|
export {
|
|
17
19
|
DEFAULT_MAX_OUTPUT_TOKENS,
|
|
18
20
|
Inference,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type ErrorCategory = "rate_limit" | "overloaded" | "auth" | "invalid_request" | "context_overflow" | "content_filter" | "network" | "timeout" | "cancelled" | "unknown";
|
|
2
|
+
interface ResponseHeaders {
|
|
3
|
+
"retry-after"?: string;
|
|
4
|
+
"retry-after-ms"?: string;
|
|
5
|
+
"x-ratelimit-remaining"?: string;
|
|
6
|
+
"x-ratelimit-reset"?: string;
|
|
7
|
+
[key: string]: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface LLMErrorOptions {
|
|
10
|
+
message: string;
|
|
11
|
+
category?: ErrorCategory;
|
|
12
|
+
status?: number;
|
|
13
|
+
headers?: ResponseHeaders;
|
|
14
|
+
cause?: Error;
|
|
15
|
+
provider?: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare class LLMError extends Error {
|
|
20
|
+
readonly category: ErrorCategory;
|
|
21
|
+
readonly status?: number;
|
|
22
|
+
readonly headers?: ResponseHeaders;
|
|
23
|
+
readonly provider?: string;
|
|
24
|
+
readonly model?: string;
|
|
25
|
+
readonly isRetryable: boolean;
|
|
26
|
+
readonly retryDelayMs?: number;
|
|
27
|
+
constructor(options: LLMErrorOptions);
|
|
28
|
+
static from(error: unknown, context?: Partial<LLMErrorOptions>): LLMError;
|
|
29
|
+
get description(): string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { type ErrorCategory as E, LLMError as L, type ResponseHeaders as R, type LLMErrorOptions as a };
|
|
@@ -1,11 +1,249 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
import '
|
|
1
|
+
import { A as AgentMiddleware } from '../runner-e2YRcUoX.js';
|
|
2
|
+
export { f as AgentModelHooks, B as BlockedModelCall, M as MiddlewareRunner, h as ModelCallContext, e as ModelCallInput, i as ModelCallOutput, j as PluginCommand, k as PluginContext, l as PluginInit, T as ToolCallDecision } from '../runner-e2YRcUoX.js';
|
|
3
|
+
import { a as ApprovalConfig, R as RiskLevel } from '../types-CWm-7rvB.js';
|
|
4
|
+
import { TelemetrySettings } from 'ai';
|
|
4
5
|
import '@ai-sdk/provider-utils';
|
|
6
|
+
import '../events-CE72w8W4.js';
|
|
5
7
|
import '../messages-BYWGn8TY.js';
|
|
6
|
-
import '../
|
|
7
|
-
import '
|
|
8
|
-
import '../tool-
|
|
8
|
+
import '../types-BfNpU8NS.js';
|
|
9
|
+
import '../types-CQL-SvTn.js';
|
|
10
|
+
import '../tool-DLXAR9Ce.js';
|
|
9
11
|
import '../types-CHiPh8U2.js';
|
|
10
|
-
import '../
|
|
12
|
+
import '../tool-BHbyUAy3.js';
|
|
13
|
+
import 'zod';
|
|
11
14
|
import '../types-CQaXbRsS.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Approval Middleware
|
|
18
|
+
*
|
|
19
|
+
* Wraps the existing approval system as an AgentMiddleware.
|
|
20
|
+
* This is how approval finally gets wired into the tool execution
|
|
21
|
+
* pipeline — no more dead code.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { createAgent, approvalMiddleware } from "@cuylabs/agent-core";
|
|
26
|
+
*
|
|
27
|
+
* const agent = createAgent({
|
|
28
|
+
* model: anthropic("claude-sonnet-4-20250514"),
|
|
29
|
+
* tools: [read, write, bash],
|
|
30
|
+
* middleware: [
|
|
31
|
+
* approvalMiddleware({
|
|
32
|
+
* rules: [
|
|
33
|
+
* { pattern: "src/*", tool: "read_file", action: "allow" },
|
|
34
|
+
* ],
|
|
35
|
+
* onRequest: async (req) => {
|
|
36
|
+
* // Prompt user in your UI
|
|
37
|
+
* return await askUser(req);
|
|
38
|
+
* },
|
|
39
|
+
* }),
|
|
40
|
+
* ],
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for the approval middleware.
|
|
47
|
+
*
|
|
48
|
+
* Extends the existing ApprovalConfig with middleware-specific options.
|
|
49
|
+
*/
|
|
50
|
+
interface ApprovalMiddlewareConfig extends ApprovalConfig {
|
|
51
|
+
/**
|
|
52
|
+
* Custom risk classification for tools.
|
|
53
|
+
*
|
|
54
|
+
* Overrides the built-in risk map. Tools not listed here
|
|
55
|
+
* fall back to the default classification.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* customRisks: {
|
|
60
|
+
* "my_deploy_tool": "dangerous",
|
|
61
|
+
* "my_lint_tool": "safe",
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
customRisks?: Record<string, RiskLevel>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create an approval middleware from an ApprovalConfig.
|
|
69
|
+
*
|
|
70
|
+
* This bridges the existing `createApprovalHandler` into the middleware
|
|
71
|
+
* system. The `beforeToolCall` hook checks rules, classifies risk,
|
|
72
|
+
* and calls the approval handler when needed.
|
|
73
|
+
*
|
|
74
|
+
* @param config - Approval configuration (rules, handler, timeout, etc.)
|
|
75
|
+
* @returns An AgentMiddleware that gates tool execution
|
|
76
|
+
*/
|
|
77
|
+
declare function approvalMiddleware(config?: ApprovalMiddlewareConfig): AgentMiddleware;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Configuration for the OpenTelemetry middleware.
|
|
81
|
+
*/
|
|
82
|
+
interface OtelMiddlewareConfig {
|
|
83
|
+
/**
|
|
84
|
+
* Whether to record tool call arguments as span attributes.
|
|
85
|
+
* Defaults to `true`.
|
|
86
|
+
*/
|
|
87
|
+
recordInputs?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether to record tool results as span attributes.
|
|
90
|
+
* Defaults to `true`.
|
|
91
|
+
*/
|
|
92
|
+
recordOutputs?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Agent name — used in the root span name and attributes.
|
|
95
|
+
* Falls back to `"agent"`.
|
|
96
|
+
*/
|
|
97
|
+
agentName?: string;
|
|
98
|
+
/** Agent description — recorded as `gen_ai.agent.description`. */
|
|
99
|
+
agentDescription?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Whether to emit `execute_tool` spans for tool calls.
|
|
102
|
+
* Defaults to `true`.
|
|
103
|
+
*/
|
|
104
|
+
emitToolSpans?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* TTL in milliseconds for orphaned spans.
|
|
107
|
+
* Defaults to 5 minutes.
|
|
108
|
+
*/
|
|
109
|
+
spanTimeoutMs?: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Configuration for `createTelemetryConfig()`.
|
|
113
|
+
*/
|
|
114
|
+
interface TelemetryConfig {
|
|
115
|
+
/** Agent name — used in span names and `gen_ai.agent.name`. */
|
|
116
|
+
agentName: string;
|
|
117
|
+
/** Agent description — recorded as `gen_ai.agent.description`. */
|
|
118
|
+
agentDescription?: string;
|
|
119
|
+
/** Record tool arguments and LLM prompts in spans. Defaults to `true`. */
|
|
120
|
+
recordInputs?: boolean;
|
|
121
|
+
/** Record tool results and LLM responses in spans. Defaults to `true`. */
|
|
122
|
+
recordOutputs?: boolean;
|
|
123
|
+
/** Emit `execute_tool` spans from our middleware. Defaults to `true`. */
|
|
124
|
+
emitToolSpans?: boolean;
|
|
125
|
+
/** TTL in ms for orphaned spans. Defaults to 5 minutes. */
|
|
126
|
+
spanTimeoutMs?: number;
|
|
127
|
+
/**
|
|
128
|
+
* An OTel `SpanProcessor` to auto-create and register a `NodeTracerProvider`.
|
|
129
|
+
*/
|
|
130
|
+
spanProcessor?: unknown;
|
|
131
|
+
/**
|
|
132
|
+
* OTel service name for the `NodeTracerProvider` resource.
|
|
133
|
+
* Defaults to `agentName`.
|
|
134
|
+
*/
|
|
135
|
+
serviceName?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Result of `createTelemetryConfig()`.
|
|
139
|
+
*/
|
|
140
|
+
interface TelemetryConfigResult {
|
|
141
|
+
/** Agent-core middleware. */
|
|
142
|
+
middleware: AgentMiddleware;
|
|
143
|
+
/** AI SDK telemetry settings. */
|
|
144
|
+
telemetry: TelemetrySettings;
|
|
145
|
+
/**
|
|
146
|
+
* Flush and shut down the auto-created tracer provider.
|
|
147
|
+
* No-op when no provider was auto-created.
|
|
148
|
+
*/
|
|
149
|
+
shutdown: () => Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare function otelMiddleware(config?: OtelMiddlewareConfig): AgentMiddleware;
|
|
153
|
+
|
|
154
|
+
declare function createTelemetryConfig(config: TelemetryConfig): TelemetryConfigResult;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Prompt Cache Middleware — Type definitions.
|
|
158
|
+
*
|
|
159
|
+
* The middleware auto-detects the model provider and applies the right
|
|
160
|
+
* caching strategy. Currently supports Anthropic's `cache_control`
|
|
161
|
+
* with ephemeral breakpoints. Other providers pass through unchanged
|
|
162
|
+
* until their caching strategy is implemented.
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* Supported cache TTL values.
|
|
166
|
+
*
|
|
167
|
+
* - `"5m"` — 5-minute cache (default, ~90% input cost reduction on Anthropic)
|
|
168
|
+
* - `"1h"` — 1-hour cache (higher write cost, longer retention)
|
|
169
|
+
*/
|
|
170
|
+
type CacheTTL = "5m" | "1h";
|
|
171
|
+
/**
|
|
172
|
+
* Configuration for the prompt cache middleware.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // Auto-detect provider, 5-minute TTL
|
|
177
|
+
* promptCacheMiddleware()
|
|
178
|
+
*
|
|
179
|
+
* // Custom TTL
|
|
180
|
+
* promptCacheMiddleware({ ttl: "1h" })
|
|
181
|
+
*
|
|
182
|
+
* // Custom breakpoint strategy (Anthropic)
|
|
183
|
+
* promptCacheMiddleware({ messageBreakpoints: 2 })
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
interface PromptCacheConfig {
|
|
187
|
+
/**
|
|
188
|
+
* Cache TTL. Defaults to `"5m"`.
|
|
189
|
+
*
|
|
190
|
+
* - `"5m"` — 5 minutes.
|
|
191
|
+
* - `"1h"` — 1 hour.
|
|
192
|
+
*/
|
|
193
|
+
ttl?: CacheTTL;
|
|
194
|
+
/**
|
|
195
|
+
* Number of cache breakpoints to place on conversation messages.
|
|
196
|
+
*
|
|
197
|
+
* For Anthropic: max 4 breakpoints total (system always gets 1).
|
|
198
|
+
* This controls additional breakpoints on conversation messages.
|
|
199
|
+
*
|
|
200
|
+
* Defaults to `1` (system + 1 message boundary = 2 breakpoints).
|
|
201
|
+
* Set to `0` to only cache the system prompt.
|
|
202
|
+
*/
|
|
203
|
+
messageBreakpoints?: number;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Prompt Cache Middleware — provider-dispatched prompt caching.
|
|
208
|
+
*
|
|
209
|
+
* Auto-detects the model provider and applies the right caching strategy:
|
|
210
|
+
*
|
|
211
|
+
* - **Anthropic**: Sets `cache_control: { type: "ephemeral" }` breakpoints
|
|
212
|
+
* on system prompt and stable conversation messages. Up to 4 breakpoints.
|
|
213
|
+
*
|
|
214
|
+
* - **Other providers**: Pass through unchanged (strategies can be added).
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* import { promptCacheMiddleware } from "@cuylabs/agent-core/middleware";
|
|
219
|
+
*
|
|
220
|
+
* const agent = createAgent({
|
|
221
|
+
* model: anthropic("claude-sonnet-4-20250514"),
|
|
222
|
+
* middleware: [promptCacheMiddleware()],
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Create a prompt cache middleware that auto-detects the model provider
|
|
229
|
+
* and applies the right caching strategy.
|
|
230
|
+
*
|
|
231
|
+
* Currently supported:
|
|
232
|
+
* - **Anthropic** — `cache_control` breakpoints on system + messages
|
|
233
|
+
*
|
|
234
|
+
* Unsupported providers pass through unchanged.
|
|
235
|
+
*
|
|
236
|
+
* @param config - Optional TTL and breakpoint settings
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* // Works with any supported provider — auto-detects
|
|
241
|
+
* const agent = createAgent({
|
|
242
|
+
* model: anthropic("claude-sonnet-4-20250514"),
|
|
243
|
+
* middleware: [promptCacheMiddleware()],
|
|
244
|
+
* });
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
declare function promptCacheMiddleware(config?: PromptCacheConfig): AgentMiddleware;
|
|
248
|
+
|
|
249
|
+
export { AgentMiddleware, type ApprovalMiddlewareConfig, type CacheTTL, type OtelMiddlewareConfig, type PromptCacheConfig, type TelemetryConfig, type TelemetryConfigResult, approvalMiddleware, createTelemetryConfig, otelMiddleware, promptCacheMiddleware };
|
package/dist/middleware/index.js
CHANGED
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
createTelemetryConfig,
|
|
5
5
|
otelMiddleware,
|
|
6
6
|
promptCacheMiddleware
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-YSLSEQ6B.js";
|
|
8
|
+
import "../chunk-BFM2YHNM.js";
|
|
9
|
+
import "../chunk-DWYX7ASF.js";
|
|
8
10
|
export {
|
|
9
11
|
MiddlewareRunner,
|
|
10
12
|
approvalMiddleware,
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LanguageModel } from 'ai';
|
|
2
|
-
import { C as CapabilitySource, S as SourcePriority,
|
|
3
|
-
export { D as DEFAULT_RESOLVER_OPTIONS, I as InputModality,
|
|
2
|
+
import { C as CapabilitySource, S as SourcePriority, b as SourceResult, P as ProviderCompatibility, R as ResolverOptions, a as ModelEntry, M as ModelCapabilities } from '../types-QA4WhEfz.js';
|
|
3
|
+
export { D as DEFAULT_RESOLVER_OPTIONS, I as InputModality, O as OutputModality } from '../types-QA4WhEfz.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Extract a model ID string from a LanguageModel instance.
|
|
@@ -11,7 +11,7 @@ declare function getModelId(model: LanguageModel): string;
|
|
|
11
11
|
*/
|
|
12
12
|
declare function getProviderId(model: LanguageModel): string | undefined;
|
|
13
13
|
|
|
14
|
-
type AdapterKind = "openai" | "anthropic" | "google" | "openai-compatible";
|
|
14
|
+
type AdapterKind = "openai" | "anthropic" | "google" | "openai-compatible" | "openrouter" | "azure" | "bedrock" | "vertex" | "xai" | "mistral" | "groq";
|
|
15
15
|
type AdapterSettings = {
|
|
16
16
|
apiKey?: string;
|
|
17
17
|
baseUrl?: string;
|
|
@@ -47,6 +47,13 @@ declare function createResolver(directory: Directory): Resolver;
|
|
|
47
47
|
* This is the fallback layer — always works offline.
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Infer context window size (in tokens) from a model ID.
|
|
52
|
+
*
|
|
53
|
+
* Uses local pattern matching — no network calls, always fast.
|
|
54
|
+
* Returns `undefined` if the model isn't recognized.
|
|
55
|
+
*/
|
|
56
|
+
declare function inferContextWindow(modelId: string): number | undefined;
|
|
50
57
|
/**
|
|
51
58
|
* Infer provider from model ID
|
|
52
59
|
*/
|
|
@@ -106,6 +113,13 @@ declare class CacheCapabilitySource implements CapabilitySource {
|
|
|
106
113
|
isAvailable(): Promise<boolean>;
|
|
107
114
|
}
|
|
108
115
|
|
|
116
|
+
interface NetworkStatus {
|
|
117
|
+
online: boolean;
|
|
118
|
+
lastSuccess?: number;
|
|
119
|
+
lastError?: string;
|
|
120
|
+
failureCount: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
109
123
|
declare function getNetworkStatus(): NetworkStatus;
|
|
110
124
|
|
|
111
125
|
declare class RemoteCapabilityFetcher {
|
|
@@ -132,4 +146,111 @@ declare class RemoteCapabilitySource implements CapabilitySource {
|
|
|
132
146
|
refresh(): Promise<void>;
|
|
133
147
|
}
|
|
134
148
|
|
|
135
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Model Capability Resolver for @cuylabs/agent-core
|
|
151
|
+
*
|
|
152
|
+
* Main orchestrator that combines multiple capability sources:
|
|
153
|
+
* 1. User overrides (highest priority)
|
|
154
|
+
* 2. Local cache (fast, persisted)
|
|
155
|
+
* 3. Pattern matching (always available)
|
|
156
|
+
* 4. Remote API (optional, network-dependent)
|
|
157
|
+
*
|
|
158
|
+
* Designed for the Vercel AI SDK v6 ecosystem.
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Extract model ID from LanguageModel
|
|
163
|
+
*/
|
|
164
|
+
declare function extractModelId(model: LanguageModel): string;
|
|
165
|
+
/**
|
|
166
|
+
* Extract provider from LanguageModel
|
|
167
|
+
*/
|
|
168
|
+
declare function extractProvider(model: LanguageModel): string | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* Resolution result with source information
|
|
171
|
+
*/
|
|
172
|
+
interface ResolutionResult {
|
|
173
|
+
/** The resolved model entry */
|
|
174
|
+
entry: ModelEntry;
|
|
175
|
+
/** Which source provided the primary result */
|
|
176
|
+
source: SourcePriority;
|
|
177
|
+
/** Whether this is a confident match */
|
|
178
|
+
confident: boolean;
|
|
179
|
+
/** Resolution timing in ms */
|
|
180
|
+
resolveTimeMs: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Model Capability Resolver
|
|
184
|
+
*
|
|
185
|
+
* Provides a unified API for querying model capabilities with
|
|
186
|
+
* automatic fallback through multiple sources.
|
|
187
|
+
*/
|
|
188
|
+
declare class ModelCapabilityResolver {
|
|
189
|
+
private options;
|
|
190
|
+
private cache;
|
|
191
|
+
private sources;
|
|
192
|
+
private initialized;
|
|
193
|
+
private initPromise;
|
|
194
|
+
constructor(options?: Partial<ResolverOptions>);
|
|
195
|
+
/**
|
|
196
|
+
* Initialize the resolver (load cache, optionally fetch remote)
|
|
197
|
+
*/
|
|
198
|
+
initialize(): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Resolve capabilities for a model
|
|
201
|
+
*/
|
|
202
|
+
resolve(model: LanguageModel): Promise<ResolutionResult>;
|
|
203
|
+
/**
|
|
204
|
+
* Quick check if a model supports reasoning
|
|
205
|
+
* Uses cache/patterns only for speed
|
|
206
|
+
*/
|
|
207
|
+
supportsReasoning(model: LanguageModel): Promise<boolean>;
|
|
208
|
+
/**
|
|
209
|
+
* Get capabilities for a model
|
|
210
|
+
*/
|
|
211
|
+
getCapabilities(model: LanguageModel): Promise<ModelCapabilities>;
|
|
212
|
+
/**
|
|
213
|
+
* Get provider compatibility settings
|
|
214
|
+
*/
|
|
215
|
+
getCompatibility(model: LanguageModel): Promise<ProviderCompatibility | undefined>;
|
|
216
|
+
/**
|
|
217
|
+
* Force refresh from remote API
|
|
218
|
+
*/
|
|
219
|
+
refreshRemote(): Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* Get current network status
|
|
222
|
+
*/
|
|
223
|
+
getNetworkStatus(): NetworkStatus;
|
|
224
|
+
/**
|
|
225
|
+
* Get resolver statistics
|
|
226
|
+
*/
|
|
227
|
+
getStats(): {
|
|
228
|
+
cacheSize: number;
|
|
229
|
+
cacheLoaded: boolean;
|
|
230
|
+
remoteFetchEnabled: boolean;
|
|
231
|
+
networkOnline: boolean;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Clear all cached data
|
|
235
|
+
*/
|
|
236
|
+
clearCache(): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* List all available models
|
|
239
|
+
* Fetches from remote if cache is empty and remote is enabled
|
|
240
|
+
*/
|
|
241
|
+
listModels(): Promise<ModelEntry[]>;
|
|
242
|
+
/**
|
|
243
|
+
* List all available models grouped by provider
|
|
244
|
+
*/
|
|
245
|
+
listModelsByProvider(): Promise<Record<string, ModelEntry[]>>;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Get the default resolver instance
|
|
249
|
+
*/
|
|
250
|
+
declare function getDefaultResolver(): ModelCapabilityResolver;
|
|
251
|
+
/**
|
|
252
|
+
* Configure the default resolver with custom options
|
|
253
|
+
*/
|
|
254
|
+
declare function configureResolver(options: Partial<ResolverOptions>): void;
|
|
255
|
+
|
|
256
|
+
export { type AdapterSettings, CacheCapabilitySource, CapabilityCache, type CapabilityOverrides, CapabilitySource, type Directory, type EngineSpec, ModelCapabilities, ModelCapabilityResolver, ModelEntry, type ModelSpec, type NetworkStatus, PatternCapabilitySource, ProviderCompatibility, RemoteCapabilityFetcher, RemoteCapabilitySource, type ResolutionResult, type Resolver, ResolverOptions, SourcePriority, SourceResult, type SyncResolver, applyCapabilityOverride, configureResolver, createResolver, extractModelId, extractProvider, findCapabilityOverride, getDefaultResolver, getModelId, getNetworkStatus, getProviderCompatibility, getProviderId, inferContextWindow, inferProvider, likelySupportsReasoning };
|
package/dist/models/index.js
CHANGED
|
@@ -14,13 +14,16 @@ import {
|
|
|
14
14
|
extractProvider,
|
|
15
15
|
findCapabilityOverride,
|
|
16
16
|
getDefaultResolver,
|
|
17
|
-
getModelId,
|
|
18
17
|
getNetworkStatus,
|
|
19
18
|
getProviderCompatibility,
|
|
20
|
-
|
|
19
|
+
inferContextWindow,
|
|
21
20
|
inferProvider,
|
|
22
21
|
likelySupportsReasoning
|
|
23
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-RFEKJKTO.js";
|
|
23
|
+
import {
|
|
24
|
+
getModelId,
|
|
25
|
+
getProviderId
|
|
26
|
+
} from "../chunk-DWYX7ASF.js";
|
|
24
27
|
export {
|
|
25
28
|
CacheCapabilitySource,
|
|
26
29
|
CapabilityCache,
|
|
@@ -41,6 +44,7 @@ export {
|
|
|
41
44
|
getNetworkStatus,
|
|
42
45
|
getProviderCompatibility,
|
|
43
46
|
getProviderId,
|
|
47
|
+
inferContextWindow,
|
|
44
48
|
inferProvider,
|
|
45
49
|
likelySupportsReasoning
|
|
46
50
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { P as Preset, A as AppliedPreset } from '../types-BnpEOYV-.js';
|
|
2
|
+
import { T as Tool } from '../tool-BHbyUAy3.js';
|
|
3
|
+
import 'ai';
|
|
4
|
+
import '../types-CQaXbRsS.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../tool-DLXAR9Ce.js';
|
|
7
|
+
import '../types-CHiPh8U2.js';
|
|
8
|
+
import '../types-CQL-SvTn.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Filter tools using preset allow/deny patterns.
|
|
12
|
+
*
|
|
13
|
+
* Explicit allow matches win over deny matches. This lets presets define a
|
|
14
|
+
* broad deny rule like `"*"` and then carve out a safe allow-list.
|
|
15
|
+
*/
|
|
16
|
+
declare function filterTools(tools: Tool.AnyInfo[], options: {
|
|
17
|
+
allow?: string[];
|
|
18
|
+
deny?: string[];
|
|
19
|
+
}): Tool.AnyInfo[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Apply a preset to available tools and a parent system prompt.
|
|
23
|
+
*/
|
|
24
|
+
declare function applyPreset(preset: Preset, availableTools: Tool.AnyInfo[], baseSystemPrompt?: string): AppliedPreset;
|
|
25
|
+
/**
|
|
26
|
+
* Merge multiple presets. Later presets override earlier scalar values.
|
|
27
|
+
*/
|
|
28
|
+
declare function mergePresets(...presets: Preset[]): Preset;
|
|
29
|
+
/**
|
|
30
|
+
* Create a custom preset with sensible defaults.
|
|
31
|
+
*/
|
|
32
|
+
declare function createPreset(options: Partial<Preset> & {
|
|
33
|
+
name: string;
|
|
34
|
+
}): Preset;
|
|
35
|
+
|
|
36
|
+
declare const explore: Preset;
|
|
37
|
+
declare const plan: Preset;
|
|
38
|
+
declare const review: Preset;
|
|
39
|
+
declare const quick: Preset;
|
|
40
|
+
declare const careful: Preset;
|
|
41
|
+
declare const code: Preset;
|
|
42
|
+
declare const watch: Preset;
|
|
43
|
+
declare const Presets: {
|
|
44
|
+
readonly explore: Preset;
|
|
45
|
+
readonly plan: Preset;
|
|
46
|
+
readonly review: Preset;
|
|
47
|
+
readonly quick: Preset;
|
|
48
|
+
readonly careful: Preset;
|
|
49
|
+
readonly code: Preset;
|
|
50
|
+
readonly watch: Preset;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { AppliedPreset, Preset, Presets, applyPreset, careful, code, createPreset, explore, filterTools, mergePresets, plan, quick, review, watch };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Presets,
|
|
3
|
+
applyPreset,
|
|
4
|
+
careful,
|
|
5
|
+
code,
|
|
6
|
+
createPreset,
|
|
7
|
+
explore,
|
|
8
|
+
filterTools,
|
|
9
|
+
mergePresets,
|
|
10
|
+
plan,
|
|
11
|
+
quick,
|
|
12
|
+
review,
|
|
13
|
+
watch
|
|
14
|
+
} from "../chunk-CAA7FHIH.js";
|
|
15
|
+
export {
|
|
16
|
+
Presets,
|
|
17
|
+
applyPreset,
|
|
18
|
+
careful,
|
|
19
|
+
code,
|
|
20
|
+
createPreset,
|
|
21
|
+
explore,
|
|
22
|
+
filterTools,
|
|
23
|
+
mergePresets,
|
|
24
|
+
plan,
|
|
25
|
+
quick,
|
|
26
|
+
review,
|
|
27
|
+
watch
|
|
28
|
+
};
|
package/dist/prompt/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { c as ModelFamily,
|
|
2
|
-
export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-
|
|
1
|
+
import { c as ModelFamily, g as EnvironmentInfo, I as InstructionFile } from '../runner-e2YRcUoX.js';
|
|
2
|
+
export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-e2YRcUoX.js';
|
|
3
3
|
import { LanguageModel } from 'ai';
|
|
4
|
-
export { P as PromptBuilder, c as createPromptBuilder } from '../builder-
|
|
5
|
-
export { d as SkillConfig } from '../
|
|
4
|
+
export { P as PromptBuilder, c as createPromptBuilder } from '../builder-UpOWQMW3.js';
|
|
5
|
+
export { d as SkillConfig } from '../types-BfNpU8NS.js';
|
|
6
6
|
import '@ai-sdk/provider-utils';
|
|
7
|
+
import '../events-CE72w8W4.js';
|
|
7
8
|
import '../messages-BYWGn8TY.js';
|
|
8
|
-
import '../types-
|
|
9
|
-
import '../tool-
|
|
9
|
+
import '../types-CQL-SvTn.js';
|
|
10
|
+
import '../tool-DLXAR9Ce.js';
|
|
10
11
|
import '../types-CHiPh8U2.js';
|
|
11
|
-
import '../
|
|
12
|
-
import '../registry-BDLIHOQB.js';
|
|
12
|
+
import '../tool-BHbyUAy3.js';
|
|
13
13
|
import 'zod';
|
|
14
|
+
import '../types-CQaXbRsS.js';
|
|
15
|
+
import '../registry-DwYqsQkX.js';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Prompt Templates — Base system prompts per model family
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { R as ReasoningLevel, a as ReasoningConfig } from '../types-CQaXbRsS.js';
|
|
2
2
|
export { E as EXTENDED_LEVELS, F as FIXED_LEVELS, S as STANDARD_LEVELS, s as shouldIncludeReasoningSummary } from '../types-CQaXbRsS.js';
|
|
3
|
-
import { P as ProviderCompatibility } from '../
|
|
4
|
-
export { f as extractModelId, g as extractProvider } from '../capability-resolver-CgRGsWVX.js';
|
|
3
|
+
import { P as ProviderCompatibility } from '../types-QA4WhEfz.js';
|
|
5
4
|
import { LanguageModel } from 'ai';
|
|
6
5
|
import { ProviderOptions } from '@ai-sdk/provider-utils';
|
|
7
6
|
|
package/dist/reasoning/index.js
CHANGED
|
@@ -17,11 +17,9 @@ import {
|
|
|
17
17
|
shouldIncludeReasoningSummary,
|
|
18
18
|
supportsReasoning,
|
|
19
19
|
supportsReasoningSync
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
extractProvider
|
|
24
|
-
} from "../chunk-QGOGIP7T.js";
|
|
20
|
+
} from "../chunk-SQU2AJHO.js";
|
|
21
|
+
import "../chunk-RFEKJKTO.js";
|
|
22
|
+
import "../chunk-DWYX7ASF.js";
|
|
25
23
|
export {
|
|
26
24
|
EXTENDED_LEVELS,
|
|
27
25
|
FIXED_LEVELS,
|
|
@@ -35,8 +33,6 @@ export {
|
|
|
35
33
|
buildReasoningOptions,
|
|
36
34
|
buildReasoningOptionsSync,
|
|
37
35
|
buildXAIOptions,
|
|
38
|
-
extractModelId,
|
|
39
|
-
extractProvider,
|
|
40
36
|
getProviderOptionsKey,
|
|
41
37
|
getReasoningConfig,
|
|
42
38
|
getReasoningConfigSync,
|