@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
@@ -0,0 +1,164 @@
1
+ import { S as SkillDiscoveryResult, a as SkillMetadata, b as SkillContent, c as SkillResource, d as SkillConfig } from './tool-pFAnJc5Y.js';
2
+
3
+ /**
4
+ * Skill Registry — in-memory store for discovered skills
5
+ *
6
+ * The registry is the central coordination point for the skill system.
7
+ * It holds discovered metadata (L1), handles on-demand content loading
8
+ * (L2/L3), provides the prompt summary for injection, and manages
9
+ * the lifecycle of skill state.
10
+ *
11
+ * ```
12
+ * discoverSkills() → SkillRegistry → promptSummary (L1 → system prompt)
13
+ * → loadSkill() (L2 → tool response)
14
+ * → loadResource (L3 → tool response)
15
+ * ```
16
+ *
17
+ * The registry is designed to be created once per agent and shared
18
+ * across the agent's lifetime, including across forked sub-agents.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const registry = await createSkillRegistry("/path/to/project", {
23
+ * externalDirs: [".agents", ".claude"],
24
+ * });
25
+ *
26
+ * // L1: summary goes into system prompt
27
+ * const summary = registry.formatSummary();
28
+ *
29
+ * // L2: agent calls skill tool → full content loaded
30
+ * const content = await registry.loadContent("testing");
31
+ *
32
+ * // L3: agent reads a bundled reference
33
+ * const ref = await registry.loadResource("testing", "references/patterns.md");
34
+ * ```
35
+ */
36
+
37
+ /**
38
+ * In-memory registry of discovered skills with lazy content loading.
39
+ *
40
+ * Holds L1 metadata for all skills. Content (L2) and resources (L3)
41
+ * are loaded on demand and cached for the registry's lifetime.
42
+ */
43
+ declare class SkillRegistry {
44
+ /** All discovered skill metadata indexed by name */
45
+ private readonly skills;
46
+ /** Cached full content for skills that have been loaded */
47
+ private readonly contentCache;
48
+ /** Discovery metadata */
49
+ readonly discoveryResult: SkillDiscoveryResult;
50
+ constructor(discoveryResult: SkillDiscoveryResult);
51
+ /** Get a skill's metadata by name. Returns undefined if not found. */
52
+ get(name: string): SkillMetadata | undefined;
53
+ /** Check if a skill exists by name. */
54
+ has(name: string): boolean;
55
+ /** Get all skill metadata entries. */
56
+ list(): SkillMetadata[];
57
+ /** Number of registered skills. */
58
+ get size(): number;
59
+ /** Skill names as an array. */
60
+ get names(): string[];
61
+ /**
62
+ * Load a skill's full content (L2: body + resource listing).
63
+ *
64
+ * Results are cached — subsequent calls return the cached content
65
+ * without re-reading the filesystem.
66
+ *
67
+ * @param name Skill name
68
+ * @returns Full skill content, or null if the skill doesn't exist
69
+ */
70
+ loadContent(name: string): Promise<SkillContent | null>;
71
+ /**
72
+ * Load a specific bundled resource from a skill (L3).
73
+ *
74
+ * The skill's content must be loaded first (via `loadContent`)
75
+ * so the resource listing is available.
76
+ *
77
+ * @param skillName Skill name
78
+ * @param relativePath Relative path to the resource within the skill dir
79
+ * @returns Resource file content as UTF-8 string
80
+ * @throws If the skill or resource doesn't exist
81
+ */
82
+ loadResource(skillName: string, relativePath: string): Promise<string>;
83
+ /**
84
+ * Get the list of resources for a loaded skill.
85
+ *
86
+ * @param name Skill name
87
+ * @returns Resource list, or empty array if skill isn't loaded yet
88
+ */
89
+ getResources(name: string): SkillResource[];
90
+ /**
91
+ * Format a summary of all available skills for injection into the system prompt.
92
+ *
93
+ * This is the L1 layer — the agent sees names and descriptions of all
94
+ * available skills, enabling it to decide which to activate via tool calls.
95
+ *
96
+ * The output format uses XML tags (consistent with the instruction format
97
+ * in `formatInstructions`) for clear delineation in the prompt.
98
+ *
99
+ * Returns empty string if no skills are available.
100
+ *
101
+ * @example Output:
102
+ * ```xml
103
+ * <available-skills>
104
+ *
105
+ * You have access to the following skills. To activate a skill and load its
106
+ * full instructions, call the `skill` tool with the skill's name.
107
+ *
108
+ * <skill name="testing" scope="project">
109
+ * Write comprehensive test suites with vitest, covering unit, integration,
110
+ * and snapshot testing patterns.
111
+ * </skill>
112
+ *
113
+ * <skill name="frontend-design" scope="user">
114
+ * Create distinctive, production-grade frontend interfaces with high design quality.
115
+ * </skill>
116
+ *
117
+ * </available-skills>
118
+ * ```
119
+ */
120
+ formatSummary(): string;
121
+ /**
122
+ * Format the full content of a loaded skill for a tool response.
123
+ *
124
+ * Wraps the skill body in XML with metadata, and lists bundled resources
125
+ * so the agent knows what's available at L3.
126
+ *
127
+ * @param content Previously loaded skill content
128
+ * @returns Formatted string for tool response
129
+ */
130
+ formatContent(content: SkillContent): string;
131
+ /** Clear the content cache, forcing reloads on next access. */
132
+ clearContentCache(): void;
133
+ /** Check if a skill's content has been loaded and cached. */
134
+ isContentLoaded(name: string): boolean;
135
+ }
136
+ /**
137
+ * Create a skill registry by discovering all available skills.
138
+ *
139
+ * This is the recommended way to initialize the skill system.
140
+ * It runs discovery, deduplicates by scope priority, and returns
141
+ * a ready-to-use registry.
142
+ *
143
+ * @param cwd Current working directory
144
+ * @param config Skill configuration
145
+ * @returns A populated SkillRegistry
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const registry = await createSkillRegistry("/path/to/project", {
150
+ * externalDirs: [".agents", ".claude"],
151
+ * roots: ["./company-skills"],
152
+ * });
153
+ *
154
+ * console.log(`Found ${registry.size} skills`);
155
+ * console.log(registry.formatSummary());
156
+ * ```
157
+ */
158
+ declare function createSkillRegistry(cwd: string, config?: SkillConfig): Promise<SkillRegistry>;
159
+ /**
160
+ * Create an empty skill registry (for agents that don't use skills).
161
+ */
162
+ declare function emptySkillRegistry(): SkillRegistry;
163
+
164
+ export { SkillRegistry as S, createSkillRegistry as c, emptySkillRegistry as e };
@@ -0,0 +1,254 @@
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 ModelEntry as M, type NetworkStatus as N, type OutputModality as O, type ProviderCompatibility as P, type ResolverOptions as R, SourcePriority as S, extractProvider as a, type SourceResult as b, type ModelCapabilities as c, ModelCapabilityResolver as d, extractModelId as e, type ResolutionResult as f, configureResolver as g, getDefaultResolver as h };