@cuylabs/agent-core 0.4.0 → 0.6.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 (66) hide show
  1. package/README.md +81 -323
  2. package/dist/builder-BKkipazh.d.ts +34 -0
  3. package/dist/capabilities/index.d.ts +97 -0
  4. package/dist/capabilities/index.js +46 -0
  5. package/dist/chunk-3C4VKG4P.js +2149 -0
  6. package/dist/chunk-6TDTQJ4P.js +116 -0
  7. package/dist/chunk-7MUFEN4K.js +559 -0
  8. package/dist/chunk-BDBZ3SLK.js +745 -0
  9. package/dist/chunk-DWYX7ASF.js +26 -0
  10. package/dist/chunk-FG4MD5MU.js +54 -0
  11. package/dist/chunk-IVUJDISU.js +556 -0
  12. package/dist/chunk-LRHOS4ZN.js +584 -0
  13. package/dist/chunk-O2ZCFQL6.js +764 -0
  14. package/dist/chunk-P6YF7USR.js +182 -0
  15. package/dist/chunk-QAQADS4X.js +258 -0
  16. package/dist/chunk-QWFMX226.js +879 -0
  17. package/dist/{chunk-6VKLWNRE.js → chunk-SDSBEQXG.js} +1 -132
  18. package/dist/chunk-VBWWUHWI.js +724 -0
  19. package/dist/chunk-VEKUXUVF.js +41 -0
  20. package/dist/chunk-X635CM2F.js +305 -0
  21. package/dist/chunk-YUUJK53A.js +91 -0
  22. package/dist/chunk-ZXAKHMWH.js +283 -0
  23. package/dist/config-D2xeGEHK.d.ts +52 -0
  24. package/dist/context/index.d.ts +259 -0
  25. package/dist/context/index.js +26 -0
  26. package/dist/identifiers-BLUxFqV_.d.ts +12 -0
  27. package/dist/index-DZQJD_hp.d.ts +1067 -0
  28. package/dist/index-ipP3_ztp.d.ts +198 -0
  29. package/dist/index.d.ts +210 -5736
  30. package/dist/index.js +2132 -7767
  31. package/dist/mcp/index.d.ts +26 -0
  32. package/dist/mcp/index.js +14 -0
  33. package/dist/messages-BYWGn8TY.d.ts +110 -0
  34. package/dist/middleware/index.d.ts +8 -0
  35. package/dist/middleware/index.js +12 -0
  36. package/dist/models/index.d.ts +33 -0
  37. package/dist/models/index.js +12 -0
  38. package/dist/network-D76DS5ot.d.ts +5 -0
  39. package/dist/prompt/index.d.ts +225 -0
  40. package/dist/prompt/index.js +45 -0
  41. package/dist/reasoning/index.d.ts +71 -0
  42. package/dist/reasoning/index.js +47 -0
  43. package/dist/registry-CuRWWtcT.d.ts +164 -0
  44. package/dist/resolver-DOfZ-xuk.d.ts +254 -0
  45. package/dist/runner-G1wxEgac.d.ts +852 -0
  46. package/dist/runtime/index.d.ts +357 -0
  47. package/dist/runtime/index.js +64 -0
  48. package/dist/session-manager-Uawm2Le7.d.ts +274 -0
  49. package/dist/skill/index.d.ts +103 -0
  50. package/dist/skill/index.js +39 -0
  51. package/dist/storage/index.d.ts +167 -0
  52. package/dist/storage/index.js +50 -0
  53. package/dist/sub-agent/index.d.ts +14 -0
  54. package/dist/sub-agent/index.js +15 -0
  55. package/dist/tool/index.d.ts +174 -1
  56. package/dist/tool/index.js +12 -3
  57. package/dist/tool-DYp6-cC3.d.ts +239 -0
  58. package/dist/tool-pFAnJc5Y.d.ts +419 -0
  59. package/dist/tracker-DClqYqTj.d.ts +96 -0
  60. package/dist/tracking/index.d.ts +109 -0
  61. package/dist/tracking/index.js +20 -0
  62. package/dist/types-BWo810L_.d.ts +648 -0
  63. package/dist/types-CQaXbRsS.d.ts +47 -0
  64. package/dist/types-VQgymC1N.d.ts +156 -0
  65. package/package.json +89 -5
  66. package/dist/index-BlSTfS-W.d.ts +0 -470
package/README.md CHANGED
@@ -1,23 +1,40 @@
1
1
  # @cuylabs/agent-core
2
2
 
3
- Embeddable AI agent infrastructure using Vercel AI SDK. Core building blocks for streaming AI agents with session management, resilience, and model capabilities.
4
-
5
- ## Features
6
-
7
- - **Agent Framework** Create AI agents with tool support and streaming responses
8
- - **Session Management** Persistent conversation state with branching support
9
- - **LLM Streaming** — Real-time streaming with proper backpressure handling
10
- - **Error Resilience** — Automatic retry with exponential backoff
11
- - **Context Management** — Token counting and automatic context pruning
12
- - **Tool Framework** — Type-safe tool definitions with Zod schemas
13
- - **Middleware** — Composable lifecycle hooks for tool interception, prompt injection, logging, and guardrails
14
- - **Skills** Modular knowledge packs with progressive disclosure (L1 summary → L2 content → L3 resources)
15
- - **Approval System** — Configurable tool approval via middleware (rules + interactive prompts)
16
- - **Checkpoint System** Undo/restore capabilities for file operations
17
- - **Model Capabilities** Runtime model capability detection
18
- - **MCP Support** Extend agents with Model Context Protocol servers
19
- - **Sub-Agents** Fork agents with inherited config, run tasks in parallel, or let the LLM delegate via `invoke_agent`
20
- - **Presets** — Reusable agent configurations with tool filtering
3
+ Embeddable AI agent infrastructure built on the AI SDK.
4
+
5
+ `@cuylabs/agent-core` is the in-process execution layer in this workspace. It
6
+ owns the `Agent` API, tool and model execution semantics, middleware, sessions,
7
+ prompt construction, tracing, and the reusable task/turn/workflow primitives
8
+ that higher layers build on.
9
+
10
+ ## Package Boundary
11
+
12
+ Use `@cuylabs/agent-core` when you want:
13
+
14
+ - `Agent` creation and `chat()` / `send()` APIs
15
+ - tool definition and execution
16
+ - model hooks, tool hooks, and lifecycle middleware
17
+ - sessions, storage, branching, and prompt construction
18
+ - tracing, MCP, skills, presets, and sub-agents
19
+ - runtime-facing task/turn/workflow helpers from `@cuylabs/agent-core/runtime`
20
+
21
+ This package does not own outer orchestration or hosting:
22
+
23
+ - use `@cuylabs/agent-runtime` for jobs, schedules, retries, and workload dispatch
24
+ - use `@cuylabs/agent-runtime-dapr` for Dapr-backed durability and workflow hosting
25
+ - use `@cuylabs/agent-http` for an AI SDK chat-stream HTTP adapter
26
+
27
+ ## Core Capabilities
28
+
29
+ - Streaming agent execution with structured events
30
+ - Type-safe tools with Zod schemas
31
+ - Middleware for model input/output, stream chunks, tool calls, and lifecycle hooks
32
+ - Session persistence with branching support
33
+ - Prompt pipeline and dynamic prompt sections
34
+ - Skills and built-in sub-agent delegation
35
+ - OpenTelemetry tracing
36
+ - MCP integration
37
+ - Runtime-facing task, turn, and workflow primitives for durable adapters
21
38
 
22
39
  ## Installation
23
40
 
@@ -27,14 +44,14 @@ npm install @cuylabs/agent-core
27
44
  pnpm add @cuylabs/agent-core
28
45
  ```
29
46
 
30
- You'll also need at least one AI SDK provider:
47
+ You will also need at least one AI SDK provider:
31
48
 
32
49
  ```bash
33
50
  npm install @ai-sdk/openai
34
51
  # or @ai-sdk/anthropic, @ai-sdk/google
35
52
  ```
36
53
 
37
- For OpenAI-compatible endpoints (local or hosted), add:
54
+ For OpenAI-compatible endpoints, add:
38
55
 
39
56
  ```bash
40
57
  npm install @ai-sdk/openai-compatible
@@ -47,11 +64,10 @@ import { createAgent, Tool } from "@cuylabs/agent-core";
47
64
  import { openai } from "@ai-sdk/openai";
48
65
  import { z } from "zod";
49
66
 
50
- // Define tools
51
67
  const greet = Tool.define("greet", {
52
68
  description: "Greet a user by name",
53
69
  parameters: z.object({
54
- name: z.string().describe("Name to greet"),
70
+ name: z.string(),
55
71
  }),
56
72
  execute: async ({ name }) => ({
57
73
  title: "Greeting",
@@ -60,342 +76,84 @@ const greet = Tool.define("greet", {
60
76
  }),
61
77
  });
62
78
 
63
- // Create agent
64
79
  const agent = createAgent({
80
+ name: "assistant",
65
81
  model: openai("gpt-4o"),
66
82
  tools: [greet],
67
83
  systemPrompt: "You are a helpful assistant.",
68
84
  });
69
85
 
70
- // Stream responses
71
- for await (const event of agent.chat("session-1", "Hello!")) {
86
+ for await (const event of agent.chat("session-1", "Say hi to Ada")) {
72
87
  switch (event.type) {
73
88
  case "text-delta":
74
89
  process.stdout.write(event.text);
75
90
  break;
76
91
  case "tool-start":
77
- console.log(`Calling tool: ${event.toolName}`);
92
+ console.log(`calling ${event.toolName}`);
78
93
  break;
79
94
  case "tool-result":
80
- console.log(`Tool result: ${event.result}`);
95
+ console.log(`tool result:`, event.result);
81
96
  break;
82
97
  case "complete":
83
- console.log("\nDone!");
98
+ console.log("\ndone");
84
99
  break;
85
100
  }
86
101
  }
87
102
  ```
88
103
 
89
- ## API Reference
90
-
91
- ### Local Models (Ollama Example)
92
-
93
- ```typescript
94
- import { createAgent, createModelResolver } from "@cuylabs/agent-core";
95
-
96
- const resolveModel = createModelResolver({
97
- engines: {
98
- ollama: {
99
- adapter: "openai-compatible",
100
- settings: {
101
- baseUrl: "http://localhost:11434/v1",
102
- },
103
- },
104
- },
105
- });
106
-
107
- const agent = createAgent({
108
- model: resolveModel("ollama/llama3.1"),
109
- cwd: process.cwd(),
110
- });
111
- ```
112
-
113
- ### Agent
114
-
115
- ```typescript
116
- import { createAgent, Agent } from "@cuylabs/agent-core";
117
- import { openai } from "@ai-sdk/openai";
118
-
119
- const agent = createAgent({
120
- model: openai("gpt-4o"),
121
- cwd: "/path/to/project",
122
- tools: myTools,
123
- systemPrompt: "You are a helpful assistant.",
124
- temperature: 0.7,
125
- maxSteps: 10,
126
- });
127
-
128
- // Streaming chat
129
- for await (const event of agent.chat(sessionId, message)) {
130
- // Handle events
131
- }
132
- ```
133
-
134
- ### Session Management
135
-
136
- ```typescript
137
- import {
138
- SessionManager,
139
- MemoryStorage,
140
- FileStorage
141
- } from "@cuylabs/agent-core";
142
-
143
- // In-memory storage (default)
144
- const memoryStorage = new MemoryStorage();
145
-
146
- // File-based persistent storage
147
- const fileStorage = new FileStorage({
148
- dataDir: "/path/to/data",
149
- });
150
-
151
- const sessions = new SessionManager(fileStorage);
152
- await sessions.createSession({ id: "my-session" });
153
- ```
154
-
155
- ### Tool Framework
156
-
157
- ```typescript
158
- import { Tool } from "@cuylabs/agent-core";
159
- import { z } from "zod";
160
-
161
- const calculator = Tool.define("calculator", {
162
- description: "Evaluate a math expression",
163
- parameters: z.object({
164
- expression: z.string(),
165
- }),
166
- execute: async ({ expression }, ctx) => {
167
- // ctx provides sessionID, cwd, abort signal, host, etc.
168
- return {
169
- title: "Calculator",
170
- output: String(eval(expression)), // Don't actually do this!
171
- metadata: {},
172
- };
173
- },
174
- });
175
- ```
176
-
177
- ### Middleware
178
-
179
- Composable lifecycle hooks for tool interception, prompt injection, logging, and guardrails:
180
-
181
- ```typescript
182
- import { createAgent, type AgentMiddleware, approvalMiddleware } from "@cuylabs/agent-core";
183
-
184
- // Simple logging middleware
185
- const logger: AgentMiddleware = {
186
- name: "logger",
187
- async beforeToolCall(tool, args) {
188
- console.log(`→ ${tool}`, args);
189
- return { action: "allow" };
190
- },
191
- async afterToolCall(tool, _args, result) {
192
- console.log(`← ${tool}`, result.title);
193
- return result;
194
- },
195
- async onChatStart(sessionId, message) {
196
- console.log(`Chat started: ${sessionId}`);
197
- },
198
- async onChatEnd(sessionId, { usage, error }) {
199
- console.log(`Chat ended: ${usage?.totalTokens} tokens`);
200
- },
201
- };
202
-
203
- // Guardrail middleware — block dangerous tools
204
- const guardrail: AgentMiddleware = {
205
- name: "guardrail",
206
- async beforeToolCall(tool) {
207
- if (tool === "bash") {
208
- return { action: "deny", reason: "Shell commands are disabled." };
209
- }
210
- return { action: "allow" };
211
- },
212
- };
213
-
214
- const agent = createAgent({
215
- model: openai("gpt-4o"),
216
- tools: myTools,
217
- middleware: [
218
- logger,
219
- guardrail,
220
- approvalMiddleware({
221
- rules: [{ pattern: "*", tool: "read_file", action: "allow" }],
222
- onRequest: async (req) => {
223
- // Prompt user for approval
224
- return await askUser(req);
225
- },
226
- }),
227
- ],
228
- });
229
- ```
230
-
231
- Middleware hooks: `beforeToolCall`, `afterToolCall`, `promptSections`, `onEvent`, `onChatStart`, `onChatEnd`. Sub-agents inherit middleware via `fork()`.
104
+ ## Focused Imports
232
105
 
233
- ### Skills
234
-
235
- Modular knowledge packs with three-level progressive disclosure:
106
+ The root export is available, but focused subpath imports mirror the package
107
+ structure when you want clearer boundaries:
236
108
 
237
109
  ```typescript
238
- import { createAgent, createSkillRegistry, createSkillTools } from "@cuylabs/agent-core";
239
-
240
- // Discover skills from SKILL.md files
241
- const registry = await createSkillRegistry(process.cwd(), {
242
- externalDirs: [".agents", ".claude"],
243
- });
244
-
245
- // Create skill tools (skill + skill_resource)
246
- const skillTools = createSkillTools(registry);
247
-
248
- // Inject L1 summary into system prompt, give agent skill tools
249
- const agent = createAgent({
250
- model: openai("gpt-4o"),
251
- tools: [...myTools, ...skillTools],
252
- systemPrompt: `You are a coding assistant.\n\n${registry.formatSummary()}`,
253
- });
254
- ```
255
-
256
- Skills use the `SKILL.md` format with YAML frontmatter. See [examples/skills/](examples/skills/) for samples.
257
-
258
- ### Built-in Sub-Agent Tools
259
-
260
- Let the LLM delegate work to specialized sub-agents via tool calls:
261
-
262
- ```typescript
263
- import { createAgent, createSubAgentTools, Presets } from "@cuylabs/agent-core";
264
- import type { AgentProfile } from "@cuylabs/agent-core";
265
-
266
- const profiles: AgentProfile[] = [
267
- { name: "explorer", description: "Fast code search", preset: Presets.explore },
268
- { name: "reviewer", description: "Thorough code review", preset: Presets.review },
269
- ];
270
-
271
- const parent = createAgent({ model, tools: codeTools });
272
- const subTools = createSubAgentTools(parent, { profiles, async: true });
273
-
274
- const agent = createAgent({
275
- model,
276
- tools: [...codeTools, ...subTools],
277
- });
278
- // The LLM can now call invoke_agent, wait_agent, and close_agent
279
- ```
280
-
281
- Tools: `invoke_agent` (spawn), `wait_agent` (collect results), `close_agent` (cancel). Supports sync and async modes, depth limiting, and concurrency control. See [docs/subagents.md](docs/subagents.md#built-in-sub-agent-tools-llm-callable).
282
-
283
- ### Error Handling & Retry
284
-
285
- ```typescript
286
- import {
287
- withRetry,
288
- LLMError,
289
- isRetryable,
290
- getRetryDelay
291
- } from "@cuylabs/agent-core";
292
-
293
- const result = await withRetry(
294
- async () => {
295
- // Your operation
296
- },
297
- {
298
- maxRetries: 3,
299
- initialDelay: 1000,
300
- maxDelay: 30000,
301
- }
302
- );
303
- ```
304
-
305
- ### Context Management
306
-
307
- ```typescript
308
- import {
309
- ContextManager,
310
- estimateTokens,
311
- pruneContext
312
- } from "@cuylabs/agent-core";
313
-
314
- const ctx = new ContextManager({
315
- maxInputTokens: 100000,
316
- pruneThreshold: 0.9,
317
- });
318
-
319
- const tokens = estimateTokens("Your text here");
320
- ```
321
-
322
- ### Model Capabilities
323
-
324
- ```typescript
325
- import {
326
- ModelCapabilityResolver,
327
- getDefaultResolver
328
- } from "@cuylabs/agent-core";
329
-
330
- const resolver = getDefaultResolver();
331
- const caps = await resolver.resolve("gpt-4o");
332
-
333
- console.log(caps.supportsImages);
334
- console.log(caps.supportsToolUse);
335
- console.log(caps.maxOutputTokens);
110
+ import { createAgent, Tool } from "@cuylabs/agent-core";
111
+ import type { AgentMiddleware } from "@cuylabs/agent-core/middleware";
112
+ import { createAgentTaskRunner } from "@cuylabs/agent-core/runtime";
113
+ import { createPromptBuilder } from "@cuylabs/agent-core/prompt";
114
+ import { createSkillRegistry } from "@cuylabs/agent-core/skill";
115
+ import { createSubAgentTools } from "@cuylabs/agent-core/sub-agent";
116
+ import { createMCPManager } from "@cuylabs/agent-core/mcp";
336
117
  ```
337
118
 
338
- ### MCP (Model Context Protocol)
339
-
340
- ```typescript
341
- import {
342
- createAgent,
343
- createMCPManager,
344
- stdioServer
345
- } from "@cuylabs/agent-core";
346
- import { anthropic } from "@ai-sdk/anthropic";
347
-
348
- // Create MCP manager with servers
349
- const mcp = createMCPManager({
350
- filesystem: stdioServer("npx", [
351
- "-y", "@modelcontextprotocol/server-filesystem", "/tmp"
352
- ]),
353
- });
119
+ Additional focused entrypoints are available for `tool`, `tracking`, `storage`,
120
+ `context`, `reasoning`, `capabilities`, and `models`.
354
121
 
355
- // Create agent with MCP tools
356
- const agent = createAgent({
357
- model: anthropic("claude-sonnet-4-20250514"),
358
- mcp,
359
- });
122
+ ## Relationship To The Runtime Packages
360
123
 
361
- // MCP tools are automatically available
362
- const result = await agent.send("session", "List files in /tmp");
124
+ The layering is:
363
125
 
364
- // Clean up
365
- await agent.close();
126
+ ```text
127
+ agent-core
128
+ -> agent-runtime
129
+ -> agent-runtime-dapr
366
130
  ```
367
131
 
368
- ## Event Types
369
-
370
- The `chat()` method yields these event types:
371
-
372
- | Event Type | Description |
373
- |------------|-------------|
374
- | `text-delta` | Streaming text chunk |
375
- | `text-start` / `text-end` | Text generation boundaries |
376
- | `tool-start` | Tool invocation started |
377
- | `tool-result` | Tool execution completed |
378
- | `tool-error` | Tool execution failed |
379
- | `step-start` / `step-finish` | LLM step boundaries with usage stats |
380
- | `reasoning-delta` | Model reasoning chunk (if supported) |
381
- | `status` | Agent state changes (thinking, calling-tool, etc.) |
382
- | `doom-loop` | Repeated tool call pattern detected |
383
- | `context-overflow` | Context window exceeded |
384
- | `message` | Complete user/assistant message |
385
- | `complete` | Stream finished with usage stats |
386
- | `error` | Unrecoverable error |
132
+ - `agent-core` owns live agent execution
133
+ - `agent-runtime` owns generic workload scheduling and dispatch
134
+ - `agent-runtime-dapr` adds Dapr-backed durability and host integration
387
135
 
388
- See [examples/03-streaming.ts](examples/03-streaming.ts) for a complete event handling example.
136
+ If you need durable orchestration, `agent-core` already exposes the task and
137
+ turn surfaces those packages build on:
389
138
 
390
- ## Concurrency Note
139
+ - `createAgentTaskRunner(...)`
140
+ - task execution observers and checkpoints
141
+ - turn-step helpers such as `prepareModelStep(...)` and `runToolBatch(...)`
142
+ - workflow-safe state/planning helpers
391
143
 
392
- When using `runConcurrent()` to run multiple tasks in parallel, be aware that all tasks share the same `SessionManager` instance. For independent conversations, create separate `Agent` instances or use distinct session IDs.
144
+ ## Learn More
393
145
 
394
- ## Examples
146
+ Start with the package docs:
395
147
 
396
- See [examples/](examples/) for 17 runnable examples covering every feature — from basic chat to middleware, skills, and Docker execution. The [examples README](examples/README.md) has setup instructions and run commands.
148
+ - [docs/README.md](./docs/README.md) for the learning path
149
+ - [docs/agent.md](./docs/agent.md) for the main `Agent` API
150
+ - [docs/middleware.md](./docs/middleware.md) for model/tool hooks and lifecycle middleware
151
+ - [docs/tools.md](./docs/tools.md) for tool definition and execution
152
+ - [docs/runtime-integration.md](./docs/runtime-integration.md) for task/turn/workflow runtime integration
153
+ - [docs/tracing.md](./docs/tracing.md) for tracing setup
397
154
 
398
- ## Documentation
155
+ Runnable examples live in [examples/README.md](./examples/README.md).
399
156
 
400
- See [docs/](docs/) for in-depth guides on each subsystem.
157
+ ## License
401
158
 
159
+ Apache-2.0
@@ -0,0 +1,34 @@
1
+ import { P as PromptConfig, a as PromptBuildContext, M as MiddlewareRunner, b as PromptSection, c as ModelFamily } from './runner-G1wxEgac.js';
2
+ import { S as SkillRegistry } from './registry-CuRWWtcT.js';
3
+
4
+ interface PromptSectionPreview {
5
+ id: string;
6
+ label: string;
7
+ priority: number;
8
+ size: number;
9
+ }
10
+
11
+ declare class PromptBuilder {
12
+ private readonly config;
13
+ private customSections;
14
+ private envCache?;
15
+ private instructionCache?;
16
+ private skillRegistryCache?;
17
+ constructor(config?: PromptConfig);
18
+ build(context: PromptBuildContext, middleware?: MiddlewareRunner): Promise<string>;
19
+ addSection(section: PromptSection): void;
20
+ removeSection(id: string): boolean;
21
+ toggleSection(id: string, enabled: boolean): void;
22
+ getSections(): PromptSection[];
23
+ hasSection(id: string): boolean;
24
+ clearCache(): void;
25
+ getSkillRegistry(cwd: string): Promise<SkillRegistry>;
26
+ getModelFamily(model: PromptBuildContext["model"]): ModelFamily;
27
+ getBaseTemplate(model: PromptBuildContext["model"]): string;
28
+ preview(context: PromptBuildContext, middleware?: MiddlewareRunner): Promise<PromptSectionPreview[]>;
29
+ private getEnvironment;
30
+ private getInstructions;
31
+ }
32
+ declare function createPromptBuilder(config?: PromptConfig): PromptBuilder;
33
+
34
+ export { PromptBuilder as P, createPromptBuilder as c };
@@ -0,0 +1,97 @@
1
+ import { C as CapabilitySource, S as SourcePriority, b as SourceResult, P as ProviderCompatibility, R as ResolverOptions, M as ModelEntry, c as ModelCapabilities } from '../resolver-DOfZ-xuk.js';
2
+ export { D as DEFAULT_RESOLVER_OPTIONS, I as InputModality, d as ModelCapabilityResolver, N as NetworkStatus, O as OutputModality, f as ResolutionResult, g as configureResolver, e as extractModelId, a as extractProvider, h as getDefaultResolver } from '../resolver-DOfZ-xuk.js';
3
+ export { g as getModelId, a as getProviderId } from '../identifiers-BLUxFqV_.js';
4
+ export { g as getNetworkStatus } from '../network-D76DS5ot.js';
5
+ import 'ai';
6
+
7
+ /**
8
+ * Pattern-Based Capability Detection for @cuylabs/agent-core
9
+ *
10
+ * Static pattern matching for model capabilities when no external data is available.
11
+ * This is the fallback layer - always works offline.
12
+ */
13
+
14
+ /**
15
+ * Infer provider from model ID
16
+ */
17
+ declare function inferProvider(modelId: string): string | undefined;
18
+ /**
19
+ * Pattern-based capability source
20
+ * Always available, uses heuristics to detect capabilities
21
+ */
22
+ declare class PatternCapabilitySource implements CapabilitySource {
23
+ readonly priority = SourcePriority.PatternMatch;
24
+ readonly name = "Pattern Matching";
25
+ lookup(modelId: string, providerHint?: string): Promise<SourceResult>;
26
+ isAvailable(): Promise<boolean>;
27
+ }
28
+ /**
29
+ * Quick check if a model ID likely supports reasoning
30
+ */
31
+ declare function likelySupportsReasoning(modelId: string): boolean;
32
+ /**
33
+ * Get provider compatibility for a model
34
+ */
35
+ declare function getProviderCompatibility(modelId: string, provider?: string): ProviderCompatibility | undefined;
36
+
37
+ type CapabilityOverrides = ResolverOptions["modelOverrides"];
38
+ type OverrideLookup = {
39
+ override?: Partial<ModelCapabilities>;
40
+ matchedKey?: string;
41
+ };
42
+ declare function findCapabilityOverride(overrides: CapabilityOverrides, modelId: string, provider?: string): OverrideLookup;
43
+ declare function applyCapabilityOverride(entry: ModelEntry, override?: Partial<ModelCapabilities>): ModelEntry;
44
+
45
+ declare class CapabilityCache {
46
+ private adapter;
47
+ private memoryCache;
48
+ private ttlMs;
49
+ private loaded;
50
+ constructor(options?: Partial<ResolverOptions>);
51
+ private load;
52
+ get(modelId: string, provider?: string): Promise<ModelEntry | undefined>;
53
+ set(entry: ModelEntry): Promise<void>;
54
+ setMany(entries: ModelEntry[]): Promise<void>;
55
+ persist(): Promise<void>;
56
+ clear(): Promise<void>;
57
+ stats(): {
58
+ size: number;
59
+ loaded: boolean;
60
+ };
61
+ getAll(): Promise<ModelEntry[]>;
62
+ getAllByProvider(): Promise<Record<string, ModelEntry[]>>;
63
+ }
64
+ declare class CacheCapabilitySource implements CapabilitySource {
65
+ private cache;
66
+ readonly priority = SourcePriority.LocalCache;
67
+ readonly name = "Local Cache";
68
+ constructor(cache: CapabilityCache);
69
+ lookup(modelId: string, provider?: string): Promise<SourceResult>;
70
+ isAvailable(): Promise<boolean>;
71
+ }
72
+
73
+ declare class RemoteCapabilityFetcher {
74
+ private apiUrl;
75
+ private timeoutMs;
76
+ private cache;
77
+ private lastFetchTime;
78
+ private minFetchInterval;
79
+ constructor(cache: CapabilityCache, options?: Partial<ResolverOptions>);
80
+ fetchAll(): Promise<ModelEntry[]>;
81
+ ping(): Promise<boolean>;
82
+ }
83
+
84
+ declare class RemoteCapabilitySource implements CapabilitySource {
85
+ readonly priority = SourcePriority.RemoteAPI;
86
+ readonly name = "Remote API (models.dev)";
87
+ private fetcher;
88
+ private cache;
89
+ private fetchPromise;
90
+ private enabled;
91
+ constructor(cache: CapabilityCache, options?: Partial<ResolverOptions>);
92
+ lookup(modelId: string, provider?: string): Promise<SourceResult>;
93
+ isAvailable(): Promise<boolean>;
94
+ refresh(): Promise<void>;
95
+ }
96
+
97
+ export { CacheCapabilitySource, CapabilityCache, type CapabilityOverrides, CapabilitySource, ModelCapabilities, ModelEntry, PatternCapabilitySource, ProviderCompatibility, RemoteCapabilityFetcher, RemoteCapabilitySource, ResolverOptions, SourcePriority, SourceResult, applyCapabilityOverride, findCapabilityOverride, getProviderCompatibility, inferProvider, likelySupportsReasoning };
@@ -0,0 +1,46 @@
1
+ import {
2
+ CacheCapabilitySource,
3
+ CapabilityCache,
4
+ DEFAULT_RESOLVER_OPTIONS,
5
+ ModelCapabilityResolver,
6
+ PatternCapabilitySource,
7
+ RemoteCapabilityFetcher,
8
+ RemoteCapabilitySource,
9
+ SourcePriority,
10
+ applyCapabilityOverride,
11
+ configureResolver,
12
+ extractModelId,
13
+ extractProvider,
14
+ findCapabilityOverride,
15
+ getDefaultResolver,
16
+ getNetworkStatus,
17
+ getProviderCompatibility,
18
+ inferProvider,
19
+ likelySupportsReasoning
20
+ } from "../chunk-QWFMX226.js";
21
+ import {
22
+ getModelId,
23
+ getProviderId
24
+ } from "../chunk-DWYX7ASF.js";
25
+ export {
26
+ CacheCapabilitySource,
27
+ CapabilityCache,
28
+ DEFAULT_RESOLVER_OPTIONS,
29
+ ModelCapabilityResolver,
30
+ PatternCapabilitySource,
31
+ RemoteCapabilityFetcher,
32
+ RemoteCapabilitySource,
33
+ SourcePriority,
34
+ applyCapabilityOverride,
35
+ configureResolver,
36
+ extractModelId,
37
+ extractProvider,
38
+ findCapabilityOverride,
39
+ getDefaultResolver,
40
+ getModelId,
41
+ getNetworkStatus,
42
+ getProviderCompatibility,
43
+ getProviderId,
44
+ inferProvider,
45
+ likelySupportsReasoning
46
+ };