@cuylabs/agent-core 0.7.0 → 0.9.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-BgZ_j4Vs.d.ts} +3 -2
- package/dist/chunk-4QFNWPIF.js +202 -0
- package/dist/chunk-5ARZJWD2.js +259 -0
- package/dist/chunk-DXFBQMXP.js +53 -0
- package/dist/chunk-EKR6PKXU.js +180 -0
- package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
- package/dist/{chunk-IEFIQENH.js → chunk-H3FUYU52.js} +15 -7
- package/dist/chunk-I6PKJ7XQ.js +292 -0
- package/dist/chunk-IYWQOJMQ.js +102 -0
- package/dist/{chunk-3HNO5SVI.js → chunk-J4QDGZIA.js} +20 -4
- package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
- package/dist/{chunk-CDTV2UYU.js → chunk-MAZ5DY5B.js} +64 -276
- package/dist/{chunk-P6YF7USR.js → chunk-MHKK374K.js} +12 -11
- package/dist/{chunk-VBWWUHWI.js → chunk-OFDKHNCX.js} +4 -1
- package/dist/{chunk-YUUJK53A.js → chunk-RKEW5WXI.js} +1 -1
- package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
- package/dist/{chunk-QGOGIP7T.js → chunk-UDCZ673N.js} +385 -233
- package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
- package/dist/chunk-WGZAPU6N.js +929 -0
- package/dist/{chunk-5K7AQVOU.js → chunk-WKHDSSXG.js} +130 -209
- package/dist/{chunk-BNSHUWCV.js → chunk-WWYYNWEW.js} +1 -1
- package/dist/context/index.js +1 -1
- package/dist/events-CE72w8W4.d.ts +149 -0
- package/dist/index-BCqEGzBj.d.ts +251 -0
- package/dist/{index-C33hlD6H.d.ts → index-DQuTZ8xL.d.ts} +319 -56
- package/dist/index.d.ts +42 -121
- package/dist/index.js +951 -848
- package/dist/inference/errors/index.d.ts +11 -0
- package/dist/inference/errors/index.js +16 -0
- package/dist/inference/index.d.ts +12 -8
- package/dist/inference/index.js +35 -7
- package/dist/llm-error-D93FNNLY.d.ts +32 -0
- package/dist/middleware/index.d.ts +246 -7
- package/dist/middleware/index.js +3 -1
- package/dist/models/index.d.ts +132 -9
- package/dist/models/index.js +48 -8
- package/dist/models/reasoning/index.d.ts +4 -0
- package/dist/{reasoning → models/reasoning}/index.js +2 -7
- package/dist/plugin/index.d.ts +414 -0
- package/dist/plugin/index.js +32 -0
- package/dist/presets/index.d.ts +53 -0
- package/dist/presets/index.js +30 -0
- package/dist/prompt/index.d.ts +11 -8
- package/dist/prompt/index.js +3 -2
- package/dist/{registry-BDLIHOQB.d.ts → registry-DwYqsQkX.d.ts} +1 -1
- package/dist/runner-CI-XeR16.d.ts +91 -0
- package/dist/runtime/index.d.ts +12 -8
- package/dist/runtime/index.js +8 -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/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
- 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/skill/index.js +3 -3
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/sub-agent/index.d.ts +16 -10
- package/dist/sub-agent/index.js +21 -4
- package/dist/tool/index.d.ts +22 -6
- package/dist/tool/index.js +3 -3
- package/dist/tool-CZWN3KbO.d.ts +141 -0
- package/dist/{tool-HUtkiVBx.d.ts → tool-DkhSCV2Y.d.ts} +2 -2
- package/dist/tracking/index.d.ts +2 -2
- package/dist/tracking/index.js +1 -1
- package/dist/{tool-Db1Ue-1U.d.ts → types-BfNpU8NS.d.ts} +1 -150
- package/dist/{types-FRpzzg_9.d.ts → types-BlOKk-Bb.d.ts} +10 -35
- package/dist/types-BlZwmnuW.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/{runner-DSKaEz3z.d.ts → types-DTSkxakL.d.ts} +7 -235
- package/dist/{types-CqDZTh4d.d.ts → types-DmDwi2zI.d.ts} +8 -4
- package/dist/types-YuWV4ag7.d.ts +72 -0
- package/package.json +67 -6
- package/dist/capability-resolver-CgRGsWVX.d.ts +0 -254
- package/dist/chunk-ZPMACVZK.js +0 -305
- package/dist/index-CfBGYrpd.d.ts +0 -317
- package/dist/reasoning/index.d.ts +0 -117
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { A as AgentEvent } from './events-CE72w8W4.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Agent Signal — typed event dispatch interface.
|
|
5
|
+
*
|
|
6
|
+
* Defines how consumers subscribe to {@link AgentEvent}s without being
|
|
7
|
+
* part of the middleware stack. Each Agent owns a signal; events are
|
|
8
|
+
* scoped to that agent instance.
|
|
9
|
+
*
|
|
10
|
+
* The default implementation (`LocalSignal`) dispatches in-process via
|
|
11
|
+
* plain function calls. A distributed runtime can supply its own
|
|
12
|
+
* implementation that bridges to external infrastructure.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extract a single variant from the AgentEvent union by its `type` tag.
|
|
17
|
+
*/
|
|
18
|
+
type EventOf<T extends AgentEvent["type"]> = Extract<AgentEvent, {
|
|
19
|
+
type: T;
|
|
20
|
+
}>;
|
|
21
|
+
/** Handler for a specific event type. */
|
|
22
|
+
type TypedHandler<T extends AgentEvent["type"]> = (event: EventOf<T>) => void;
|
|
23
|
+
/** Handler that receives every event regardless of type. */
|
|
24
|
+
type WildcardHandler = (event: AgentEvent) => void;
|
|
25
|
+
/** Call to remove a previously registered handler. */
|
|
26
|
+
type Unsubscribe = () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Typed, multi-consumer event dispatch.
|
|
29
|
+
*
|
|
30
|
+
* Subscribe to agent events from anywhere — SSE routes, TUI renderers,
|
|
31
|
+
* plugins, tests. The interface is deliberately minimal so that backend
|
|
32
|
+
* implementations (in-process, Dapr, Redis, …) have a small contract to
|
|
33
|
+
* fulfil.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // Subscribe to a specific event
|
|
38
|
+
* const off = agent.signal.on("text-delta", (e) => process.stdout.write(e.text));
|
|
39
|
+
*
|
|
40
|
+
* // Subscribe to everything
|
|
41
|
+
* const off2 = agent.signal.onAny((e) => logger.info(e.type));
|
|
42
|
+
*
|
|
43
|
+
* // Clean up
|
|
44
|
+
* off();
|
|
45
|
+
* off2();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
interface AgentSignal {
|
|
49
|
+
/**
|
|
50
|
+
* Subscribe to a specific event type.
|
|
51
|
+
*
|
|
52
|
+
* @returns An unsubscribe function.
|
|
53
|
+
*/
|
|
54
|
+
on<T extends AgentEvent["type"]>(type: T, handler: TypedHandler<T>): Unsubscribe;
|
|
55
|
+
/**
|
|
56
|
+
* Subscribe to all events.
|
|
57
|
+
*
|
|
58
|
+
* @returns An unsubscribe function.
|
|
59
|
+
*/
|
|
60
|
+
onAny(handler: WildcardHandler): Unsubscribe;
|
|
61
|
+
/**
|
|
62
|
+
* Dispatch an event to every matching handler.
|
|
63
|
+
*
|
|
64
|
+
* Called internally by the Agent — but nothing prevents external code
|
|
65
|
+
* from injecting a synthetic event (useful for testing or bridging).
|
|
66
|
+
*/
|
|
67
|
+
emit(event: AgentEvent): void;
|
|
68
|
+
/** Remove all handlers. Called during agent disposal. */
|
|
69
|
+
clear(): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type { AgentSignal as A, EventOf as E, TypedHandler as T, Unsubscribe as U, WildcardHandler as W };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuylabs/agent-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Embeddable AI agent infrastructure — execution, sessions, tools, skills, sub-agents, tracing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"default": "./dist/context/index.js"
|
|
63
63
|
},
|
|
64
64
|
"./reasoning": {
|
|
65
|
-
"types": "./dist/reasoning/index.d.ts",
|
|
66
|
-
"import": "./dist/reasoning/index.js",
|
|
67
|
-
"default": "./dist/reasoning/index.js"
|
|
65
|
+
"types": "./dist/models/reasoning/index.d.ts",
|
|
66
|
+
"import": "./dist/models/reasoning/index.js",
|
|
67
|
+
"default": "./dist/models/reasoning/index.js"
|
|
68
68
|
},
|
|
69
69
|
"./models": {
|
|
70
70
|
"types": "./dist/models/index.d.ts",
|
|
@@ -85,6 +85,31 @@
|
|
|
85
85
|
"types": "./dist/scope/index.d.ts",
|
|
86
86
|
"import": "./dist/scope/index.js",
|
|
87
87
|
"default": "./dist/scope/index.js"
|
|
88
|
+
},
|
|
89
|
+
"./signal": {
|
|
90
|
+
"types": "./dist/signal/index.d.ts",
|
|
91
|
+
"import": "./dist/signal/index.js",
|
|
92
|
+
"default": "./dist/signal/index.js"
|
|
93
|
+
},
|
|
94
|
+
"./errors": {
|
|
95
|
+
"types": "./dist/inference/errors/index.d.ts",
|
|
96
|
+
"import": "./dist/inference/errors/index.js",
|
|
97
|
+
"default": "./dist/inference/errors/index.js"
|
|
98
|
+
},
|
|
99
|
+
"./presets": {
|
|
100
|
+
"types": "./dist/presets/index.d.ts",
|
|
101
|
+
"import": "./dist/presets/index.js",
|
|
102
|
+
"default": "./dist/presets/index.js"
|
|
103
|
+
},
|
|
104
|
+
"./safety": {
|
|
105
|
+
"types": "./dist/safety/index.d.ts",
|
|
106
|
+
"import": "./dist/safety/index.js",
|
|
107
|
+
"default": "./dist/safety/index.js"
|
|
108
|
+
},
|
|
109
|
+
"./plugin": {
|
|
110
|
+
"types": "./dist/plugin/index.d.ts",
|
|
111
|
+
"import": "./dist/plugin/index.js",
|
|
112
|
+
"default": "./dist/plugin/index.js"
|
|
88
113
|
}
|
|
89
114
|
},
|
|
90
115
|
"files": [
|
|
@@ -94,15 +119,23 @@
|
|
|
94
119
|
"dependencies": {
|
|
95
120
|
"@ai-sdk/provider": "^3.0.7",
|
|
96
121
|
"ai": "^6.0.67",
|
|
122
|
+
"jiti": "^2.6.1",
|
|
97
123
|
"zod": "^3.25.76 || ^4.1.8"
|
|
98
124
|
},
|
|
99
125
|
"peerDependencies": {
|
|
126
|
+
"@ai-sdk/amazon-bedrock": "^4.0.0",
|
|
100
127
|
"@ai-sdk/anthropic": "^3.0.0",
|
|
128
|
+
"@ai-sdk/azure": "^3.0.0",
|
|
101
129
|
"@ai-sdk/google": "^3.0.0",
|
|
130
|
+
"@ai-sdk/google-vertex": "^4.0.0",
|
|
131
|
+
"@ai-sdk/groq": "^3.0.0",
|
|
102
132
|
"@ai-sdk/mcp": "^1.0.0",
|
|
133
|
+
"@ai-sdk/mistral": "^3.0.0",
|
|
103
134
|
"@ai-sdk/openai": "^3.0.0",
|
|
104
135
|
"@ai-sdk/openai-compatible": "^2.0.0",
|
|
136
|
+
"@ai-sdk/xai": "^3.0.0",
|
|
105
137
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
138
|
+
"@openrouter/ai-sdk-provider": "^1.0.0",
|
|
106
139
|
"@opentelemetry/api": "^1.9.0",
|
|
107
140
|
"@opentelemetry/resources": "^2.0.0",
|
|
108
141
|
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
@@ -110,9 +143,15 @@
|
|
|
110
143
|
"dockerode": "^4.0.9"
|
|
111
144
|
},
|
|
112
145
|
"peerDependenciesMeta": {
|
|
146
|
+
"@ai-sdk/amazon-bedrock": {
|
|
147
|
+
"optional": true
|
|
148
|
+
},
|
|
113
149
|
"@ai-sdk/anthropic": {
|
|
114
150
|
"optional": true
|
|
115
151
|
},
|
|
152
|
+
"@ai-sdk/azure": {
|
|
153
|
+
"optional": true
|
|
154
|
+
},
|
|
116
155
|
"@ai-sdk/openai": {
|
|
117
156
|
"optional": true
|
|
118
157
|
},
|
|
@@ -122,12 +161,27 @@
|
|
|
122
161
|
"@ai-sdk/google": {
|
|
123
162
|
"optional": true
|
|
124
163
|
},
|
|
164
|
+
"@ai-sdk/google-vertex": {
|
|
165
|
+
"optional": true
|
|
166
|
+
},
|
|
167
|
+
"@ai-sdk/groq": {
|
|
168
|
+
"optional": true
|
|
169
|
+
},
|
|
125
170
|
"@ai-sdk/mcp": {
|
|
126
171
|
"optional": true
|
|
127
172
|
},
|
|
173
|
+
"@ai-sdk/mistral": {
|
|
174
|
+
"optional": true
|
|
175
|
+
},
|
|
176
|
+
"@ai-sdk/xai": {
|
|
177
|
+
"optional": true
|
|
178
|
+
},
|
|
128
179
|
"@modelcontextprotocol/sdk": {
|
|
129
180
|
"optional": true
|
|
130
181
|
},
|
|
182
|
+
"@openrouter/ai-sdk-provider": {
|
|
183
|
+
"optional": true
|
|
184
|
+
},
|
|
131
185
|
"dockerode": {
|
|
132
186
|
"optional": true
|
|
133
187
|
},
|
|
@@ -145,14 +199,21 @@
|
|
|
145
199
|
}
|
|
146
200
|
},
|
|
147
201
|
"devDependencies": {
|
|
202
|
+
"@ai-sdk/amazon-bedrock": "^4.0.77",
|
|
148
203
|
"@ai-sdk/anthropic": "^3.0.35",
|
|
204
|
+
"@ai-sdk/azure": "^3.0.42",
|
|
149
205
|
"@ai-sdk/google": "^3.0.30",
|
|
206
|
+
"@ai-sdk/google-vertex": "^4.0.80",
|
|
207
|
+
"@ai-sdk/groq": "^3.0.29",
|
|
150
208
|
"@ai-sdk/mcp": "^1.0.19",
|
|
209
|
+
"@ai-sdk/mistral": "^3.0.24",
|
|
151
210
|
"@ai-sdk/openai": "^3.0.25",
|
|
152
211
|
"@ai-sdk/openai-compatible": "^2.0.30",
|
|
153
212
|
"@ai-sdk/provider-utils": "^4.0.15",
|
|
213
|
+
"@ai-sdk/xai": "^3.0.67",
|
|
154
214
|
"@arizeai/openinference-vercel": "^2.7.1",
|
|
155
215
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
216
|
+
"@openrouter/ai-sdk-provider": "^1.0.0",
|
|
156
217
|
"@opentelemetry/api": "^1.9.0",
|
|
157
218
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.213.0",
|
|
158
219
|
"@opentelemetry/exporter-trace-otlp-http": "^0.213.0",
|
|
@@ -189,8 +250,8 @@
|
|
|
189
250
|
"access": "public"
|
|
190
251
|
},
|
|
191
252
|
"scripts": {
|
|
192
|
-
"build": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/
|
|
193
|
-
"dev": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/
|
|
253
|
+
"build": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/inference/errors/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/host/index.ts src/scope/index.ts src/signal/index.ts src/presets/index.ts src/safety/index.ts src/plugin/index.ts --format esm --dts --clean",
|
|
254
|
+
"dev": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/inference/errors/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/host/index.ts src/scope/index.ts src/signal/index.ts src/presets/index.ts src/safety/index.ts src/plugin/index.ts --format esm --dts --watch",
|
|
194
255
|
"test": "vitest run",
|
|
195
256
|
"test:watch": "vitest",
|
|
196
257
|
"lint": "eslint src/",
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { LanguageModel } from 'ai';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Model Capability Types for @cuylabs/agent-core
|
|
5
|
-
*
|
|
6
|
-
* Defines the structure for model capabilities that can be sourced from
|
|
7
|
-
* static patterns, local cache, or remote APIs.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Input modalities a model can accept
|
|
11
|
-
*/
|
|
12
|
-
type InputModality = "text" | "image" | "audio" | "video" | "pdf";
|
|
13
|
-
/**
|
|
14
|
-
* Output modalities a model can produce
|
|
15
|
-
*/
|
|
16
|
-
type OutputModality = "text" | "image" | "audio" | "video";
|
|
17
|
-
/**
|
|
18
|
-
* Comprehensive model capabilities
|
|
19
|
-
*/
|
|
20
|
-
interface ModelCapabilities {
|
|
21
|
-
/** Model supports extended reasoning/thinking */
|
|
22
|
-
reasoning: boolean;
|
|
23
|
-
/** Model supports function/tool calling */
|
|
24
|
-
toolCalling: boolean;
|
|
25
|
-
/** Model supports temperature adjustment */
|
|
26
|
-
temperature: boolean;
|
|
27
|
-
/** Model supports file attachments */
|
|
28
|
-
attachments: boolean;
|
|
29
|
-
/** Model supports streaming responses */
|
|
30
|
-
streaming: boolean;
|
|
31
|
-
/** Supported input modalities */
|
|
32
|
-
inputModalities: InputModality[];
|
|
33
|
-
/** Supported output modalities */
|
|
34
|
-
outputModalities: OutputModality[];
|
|
35
|
-
/** Maximum context window in tokens */
|
|
36
|
-
contextWindow?: number;
|
|
37
|
-
/** Maximum output tokens */
|
|
38
|
-
maxOutput?: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Provider-specific compatibility flags
|
|
42
|
-
* These handle quirks in different provider implementations
|
|
43
|
-
*/
|
|
44
|
-
interface ProviderCompatibility {
|
|
45
|
-
/** Supports OpenAI-style reasoning_effort parameter */
|
|
46
|
-
supportsReasoningEffort?: boolean;
|
|
47
|
-
/** Supports developer/system role distinction */
|
|
48
|
-
supportsDeveloperRole?: boolean;
|
|
49
|
-
/** Field name for max tokens (varies by provider) */
|
|
50
|
-
maxTokensField?: "max_tokens" | "max_completion_tokens";
|
|
51
|
-
/** Requires thinking as text tags vs structured */
|
|
52
|
-
requiresThinkingTags?: boolean;
|
|
53
|
-
/** Provider-specific thinking format */
|
|
54
|
-
thinkingFormat?: "openai" | "anthropic" | "google" | "zai";
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Complete model entry with metadata
|
|
58
|
-
*/
|
|
59
|
-
interface ModelEntry {
|
|
60
|
-
/** Model identifier (e.g., "gpt-4o", "claude-sonnet-4") */
|
|
61
|
-
id: string;
|
|
62
|
-
/** Human-readable model name */
|
|
63
|
-
name: string;
|
|
64
|
-
/** Provider identifier (e.g., "openai", "anthropic") */
|
|
65
|
-
provider: string;
|
|
66
|
-
/** Model capabilities */
|
|
67
|
-
capabilities: ModelCapabilities;
|
|
68
|
-
/** Provider-specific compatibility settings */
|
|
69
|
-
compatibility?: ProviderCompatibility;
|
|
70
|
-
/** Cost per million tokens (input) */
|
|
71
|
-
costInput?: number;
|
|
72
|
-
/** Cost per million tokens (output) */
|
|
73
|
-
costOutput?: number;
|
|
74
|
-
/** When this entry was last updated */
|
|
75
|
-
updatedAt?: string;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Priority levels for capability sources
|
|
79
|
-
*/
|
|
80
|
-
declare enum SourcePriority {
|
|
81
|
-
/** User configuration overrides everything */
|
|
82
|
-
UserConfig = 0,
|
|
83
|
-
/** Local cache from previous fetch */
|
|
84
|
-
LocalCache = 1,
|
|
85
|
-
/** Bundled static data (build-time) */
|
|
86
|
-
BundledData = 2,
|
|
87
|
-
/** Pattern-based inference (fallback) */
|
|
88
|
-
PatternMatch = 3,
|
|
89
|
-
/** Remote API (if network available) */
|
|
90
|
-
RemoteAPI = 4
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Result from a capability source lookup
|
|
94
|
-
*/
|
|
95
|
-
interface SourceResult {
|
|
96
|
-
/** The model entry if found */
|
|
97
|
-
entry?: ModelEntry;
|
|
98
|
-
/** Which source provided this result */
|
|
99
|
-
source: SourcePriority;
|
|
100
|
-
/** Whether this is a confident match */
|
|
101
|
-
confident: boolean;
|
|
102
|
-
/** Error message if lookup failed */
|
|
103
|
-
error?: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Capability source interface
|
|
107
|
-
*/
|
|
108
|
-
interface CapabilitySource {
|
|
109
|
-
/** Source priority (lower = higher priority) */
|
|
110
|
-
priority: SourcePriority;
|
|
111
|
-
/** Human-readable source name */
|
|
112
|
-
name: string;
|
|
113
|
-
/** Look up capabilities for a model */
|
|
114
|
-
lookup(modelId: string, provider?: string): Promise<SourceResult>;
|
|
115
|
-
/** Check if this source is available */
|
|
116
|
-
isAvailable(): Promise<boolean>;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Options for the capability resolver
|
|
120
|
-
*/
|
|
121
|
-
interface ResolverOptions {
|
|
122
|
-
/** Enable remote API fetching (default: false) */
|
|
123
|
-
enableRemoteFetch?: boolean;
|
|
124
|
-
/** Remote API URL (default: https://models.dev) */
|
|
125
|
-
remoteApiUrl?: string;
|
|
126
|
-
/** Cache directory path */
|
|
127
|
-
cachePath?: string;
|
|
128
|
-
/** Cache TTL in milliseconds (default: 1 hour) */
|
|
129
|
-
cacheTtlMs?: number;
|
|
130
|
-
/** Network timeout in milliseconds (default: 10 seconds) */
|
|
131
|
-
networkTimeoutMs?: number;
|
|
132
|
-
/** Custom user overrides for specific models */
|
|
133
|
-
modelOverrides?: Record<string, Partial<ModelCapabilities>>;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Default resolver options
|
|
137
|
-
*/
|
|
138
|
-
declare const DEFAULT_RESOLVER_OPTIONS: Required<ResolverOptions>;
|
|
139
|
-
|
|
140
|
-
interface NetworkStatus {
|
|
141
|
-
online: boolean;
|
|
142
|
-
lastSuccess?: number;
|
|
143
|
-
lastError?: string;
|
|
144
|
-
failureCount: number;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Model Capability Resolver for @cuylabs/agent-core
|
|
149
|
-
*
|
|
150
|
-
* Main orchestrator that combines multiple capability sources:
|
|
151
|
-
* 1. User overrides (highest priority)
|
|
152
|
-
* 2. Local cache (fast, persisted)
|
|
153
|
-
* 3. Pattern matching (always available)
|
|
154
|
-
* 4. Remote API (optional, network-dependent)
|
|
155
|
-
*
|
|
156
|
-
* Designed for the Vercel AI SDK v6 ecosystem.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Extract model ID from LanguageModel
|
|
161
|
-
*/
|
|
162
|
-
declare function extractModelId(model: LanguageModel): string;
|
|
163
|
-
/**
|
|
164
|
-
* Extract provider from LanguageModel
|
|
165
|
-
*/
|
|
166
|
-
declare function extractProvider(model: LanguageModel): string | undefined;
|
|
167
|
-
/**
|
|
168
|
-
* Resolution result with source information
|
|
169
|
-
*/
|
|
170
|
-
interface ResolutionResult {
|
|
171
|
-
/** The resolved model entry */
|
|
172
|
-
entry: ModelEntry;
|
|
173
|
-
/** Which source provided the primary result */
|
|
174
|
-
source: SourcePriority;
|
|
175
|
-
/** Whether this is a confident match */
|
|
176
|
-
confident: boolean;
|
|
177
|
-
/** Resolution timing in ms */
|
|
178
|
-
resolveTimeMs: number;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Model Capability Resolver
|
|
182
|
-
*
|
|
183
|
-
* Provides a unified API for querying model capabilities with
|
|
184
|
-
* automatic fallback through multiple sources.
|
|
185
|
-
*/
|
|
186
|
-
declare class ModelCapabilityResolver {
|
|
187
|
-
private options;
|
|
188
|
-
private cache;
|
|
189
|
-
private sources;
|
|
190
|
-
private initialized;
|
|
191
|
-
private initPromise;
|
|
192
|
-
constructor(options?: Partial<ResolverOptions>);
|
|
193
|
-
/**
|
|
194
|
-
* Initialize the resolver (load cache, optionally fetch remote)
|
|
195
|
-
*/
|
|
196
|
-
initialize(): Promise<void>;
|
|
197
|
-
/**
|
|
198
|
-
* Resolve capabilities for a model
|
|
199
|
-
*/
|
|
200
|
-
resolve(model: LanguageModel): Promise<ResolutionResult>;
|
|
201
|
-
/**
|
|
202
|
-
* Quick check if a model supports reasoning
|
|
203
|
-
* Uses cache/patterns only for speed
|
|
204
|
-
*/
|
|
205
|
-
supportsReasoning(model: LanguageModel): Promise<boolean>;
|
|
206
|
-
/**
|
|
207
|
-
* Get capabilities for a model
|
|
208
|
-
*/
|
|
209
|
-
getCapabilities(model: LanguageModel): Promise<ModelCapabilities>;
|
|
210
|
-
/**
|
|
211
|
-
* Get provider compatibility settings
|
|
212
|
-
*/
|
|
213
|
-
getCompatibility(model: LanguageModel): Promise<ProviderCompatibility | undefined>;
|
|
214
|
-
/**
|
|
215
|
-
* Force refresh from remote API
|
|
216
|
-
*/
|
|
217
|
-
refreshRemote(): Promise<void>;
|
|
218
|
-
/**
|
|
219
|
-
* Get current network status
|
|
220
|
-
*/
|
|
221
|
-
getNetworkStatus(): NetworkStatus;
|
|
222
|
-
/**
|
|
223
|
-
* Get resolver statistics
|
|
224
|
-
*/
|
|
225
|
-
getStats(): {
|
|
226
|
-
cacheSize: number;
|
|
227
|
-
cacheLoaded: boolean;
|
|
228
|
-
remoteFetchEnabled: boolean;
|
|
229
|
-
networkOnline: boolean;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Clear all cached data
|
|
233
|
-
*/
|
|
234
|
-
clearCache(): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* List all available models
|
|
237
|
-
* Fetches from remote if cache is empty and remote is enabled
|
|
238
|
-
*/
|
|
239
|
-
listModels(): Promise<ModelEntry[]>;
|
|
240
|
-
/**
|
|
241
|
-
* List all available models grouped by provider
|
|
242
|
-
*/
|
|
243
|
-
listModelsByProvider(): Promise<Record<string, ModelEntry[]>>;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get the default resolver instance
|
|
247
|
-
*/
|
|
248
|
-
declare function getDefaultResolver(): ModelCapabilityResolver;
|
|
249
|
-
/**
|
|
250
|
-
* Configure the default resolver with custom options
|
|
251
|
-
*/
|
|
252
|
-
declare function configureResolver(options: Partial<ResolverOptions>): void;
|
|
253
|
-
|
|
254
|
-
export { type CapabilitySource as C, DEFAULT_RESOLVER_OPTIONS as D, type InputModality as I, type ModelCapabilities as M, type NetworkStatus as N, type OutputModality as O, type ProviderCompatibility as P, type ResolutionResult as R, SourcePriority as S, ModelCapabilityResolver as a, type ModelEntry as b, type ResolverOptions as c, type SourceResult as d, configureResolver as e, extractModelId as f, extractProvider as g, getDefaultResolver as h };
|