@cuylabs/agent-core 0.3.0 → 0.5.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 +216 -41
  2. package/dist/builder-RcTZuYnO.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-6TDTQJ4P.js +116 -0
  6. package/dist/chunk-7MUFEN4K.js +559 -0
  7. package/dist/chunk-BDBZ3SLK.js +745 -0
  8. package/dist/chunk-DWYX7ASF.js +26 -0
  9. package/dist/chunk-FG4MD5MU.js +54 -0
  10. package/dist/chunk-IMGQOTU2.js +2019 -0
  11. package/dist/chunk-IVUJDISU.js +556 -0
  12. package/dist/chunk-LRHOS4ZN.js +584 -0
  13. package/dist/chunk-OTUGSCED.js +691 -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-p0kOsVsE.d.ts +1067 -0
  28. package/dist/index-tmhaADz5.d.ts +198 -0
  29. package/dist/index.d.ts +185 -4316
  30. package/dist/index.js +1238 -5368
  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 +7 -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 +224 -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-C7aMP_x3.d.ts +596 -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 +173 -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-CQaXbRsS.d.ts +47 -0
  63. package/dist/types-MM1JoX5T.d.ts +810 -0
  64. package/dist/types-VQgymC1N.d.ts +156 -0
  65. package/package.json +89 -5
  66. package/dist/index-QR704uRr.d.ts +0 -472
@@ -0,0 +1,41 @@
1
+ // src/tracking/file-tracking.ts
2
+ function extractFilePathsFromArgs(args, meta) {
3
+ if (!meta.pathArgs || meta.pathArgs.length === 0) {
4
+ return [];
5
+ }
6
+ const paths = [];
7
+ for (const argName of meta.pathArgs) {
8
+ const value = args[argName];
9
+ if (typeof value === "string") {
10
+ paths.push(value);
11
+ } else if (Array.isArray(value)) {
12
+ for (const item of value) {
13
+ if (typeof item === "string") {
14
+ paths.push(item);
15
+ }
16
+ }
17
+ }
18
+ }
19
+ return paths;
20
+ }
21
+ function shouldCaptureBaseline(meta) {
22
+ return meta.operationType !== "read";
23
+ }
24
+ function withFileTracking(tracker, meta, execute) {
25
+ return (async (...args) => {
26
+ const params = args[0];
27
+ if (params && shouldCaptureBaseline(meta)) {
28
+ const paths = extractFilePathsFromArgs(params, meta);
29
+ for (const path of paths) {
30
+ await tracker.beforeWrite(path);
31
+ }
32
+ }
33
+ return await execute(...args);
34
+ });
35
+ }
36
+
37
+ export {
38
+ extractFilePathsFromArgs,
39
+ shouldCaptureBaseline,
40
+ withFileTracking
41
+ };
@@ -0,0 +1,305 @@
1
+ import {
2
+ extractModelId,
3
+ extractProvider,
4
+ getDefaultResolver,
5
+ likelySupportsReasoning
6
+ } from "./chunk-QWFMX226.js";
7
+
8
+ // src/reasoning/types.ts
9
+ var STANDARD_LEVELS = ["off", "low", "medium", "high"];
10
+ var EXTENDED_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
11
+ var FIXED_LEVELS = ["medium"];
12
+ function shouldIncludeReasoningSummary() {
13
+ if (typeof process !== "undefined" && process.env) {
14
+ return process.env.CODE_AGENT_DISABLE_REASONING_SUMMARY !== "true";
15
+ }
16
+ return true;
17
+ }
18
+
19
+ // src/reasoning/providers.ts
20
+ function buildOpenAIOptions(level, compat) {
21
+ if (level === "off") return void 0;
22
+ const options = {};
23
+ if (compat?.supportsReasoningEffort !== false) {
24
+ options.reasoningEffort = level;
25
+ }
26
+ if (shouldIncludeReasoningSummary()) {
27
+ options.reasoningSummary = "auto";
28
+ }
29
+ return options;
30
+ }
31
+ var ANTHROPIC_BUDGETS = {
32
+ off: 0,
33
+ minimal: 2e3,
34
+ low: 4e3,
35
+ medium: 8e3,
36
+ high: 16e3,
37
+ xhigh: 31999
38
+ };
39
+ function buildAnthropicOptions(level) {
40
+ if (level === "off") return void 0;
41
+ return {
42
+ thinking: {
43
+ type: "enabled",
44
+ budgetTokens: ANTHROPIC_BUDGETS[level]
45
+ }
46
+ };
47
+ }
48
+ var GOOGLE_BUDGETS = {
49
+ off: 0,
50
+ minimal: 2e3,
51
+ low: 4e3,
52
+ medium: 8e3,
53
+ high: 16e3,
54
+ xhigh: 24576
55
+ };
56
+ function buildGoogleOptions(level, modelId) {
57
+ if (level === "off") return void 0;
58
+ if (modelId?.includes("gemini-3") || modelId?.includes("gemini-4")) {
59
+ return {
60
+ thinkingConfig: {
61
+ includeThoughts: true,
62
+ thinkingLevel: level === "high" || level === "xhigh" ? "high" : "low"
63
+ }
64
+ };
65
+ }
66
+ return {
67
+ thinkingConfig: {
68
+ includeThoughts: true,
69
+ thinkingBudget: GOOGLE_BUDGETS[level]
70
+ }
71
+ };
72
+ }
73
+ function buildXAIOptions(level) {
74
+ if (level === "off") return void 0;
75
+ return { reasoningEffort: level };
76
+ }
77
+ function buildGroqOptions(level) {
78
+ if (level === "off") return void 0;
79
+ return {
80
+ includeThoughts: true,
81
+ thinkingLevel: level === "high" || level === "xhigh" ? "high" : "low"
82
+ };
83
+ }
84
+ var BEDROCK_ANTHROPIC_BUDGETS = {
85
+ off: 0,
86
+ minimal: 2e3,
87
+ low: 4e3,
88
+ medium: 8e3,
89
+ high: 16e3,
90
+ xhigh: 31999
91
+ };
92
+ function buildBedrockOptions(level, modelId) {
93
+ if (level === "off") return void 0;
94
+ if (modelId?.includes("anthropic") || modelId?.includes("claude")) {
95
+ return {
96
+ reasoningConfig: {
97
+ type: "enabled",
98
+ budgetTokens: BEDROCK_ANTHROPIC_BUDGETS[level]
99
+ }
100
+ };
101
+ }
102
+ return {
103
+ reasoningConfig: {
104
+ type: "enabled",
105
+ maxReasoningEffort: level
106
+ }
107
+ };
108
+ }
109
+ function buildOpenRouterOptions(level) {
110
+ if (level === "off") return void 0;
111
+ return {
112
+ reasoning: { effort: level }
113
+ };
114
+ }
115
+ var PROVIDER_KEY_MAP = {
116
+ "openai.chat": "openai",
117
+ "openai.responses": "openai",
118
+ "anthropic.messages": "anthropic",
119
+ "google.generative-ai": "google",
120
+ "bedrock": "bedrock",
121
+ "azure": "azure",
122
+ "xai": "xai",
123
+ "deepinfra": "deepinfra",
124
+ "togetherai": "togetherai",
125
+ "groq": "groq",
126
+ "mistral": "mistral"
127
+ };
128
+ function getProviderOptionsKey(provider) {
129
+ return PROVIDER_KEY_MAP[provider] || provider.split(".")[0] || "unknown";
130
+ }
131
+
132
+ // src/reasoning/config.ts
133
+ async function getReasoningConfig(model) {
134
+ const resolver = getDefaultResolver();
135
+ const result = await resolver.resolve(model);
136
+ const { capabilities, compatibility } = result.entry;
137
+ const provider = extractProvider(model);
138
+ const modelId = extractModelId(model).toLowerCase();
139
+ if (!capabilities.reasoning) {
140
+ return {
141
+ supportsReasoning: false,
142
+ availableLevels: ["off"],
143
+ getProviderOptions: () => void 0
144
+ };
145
+ }
146
+ if (provider?.includes("openai") || modelId.includes("gpt") || modelId.match(/^o[134]/)) {
147
+ if (modelId === "o1-mini") {
148
+ return {
149
+ supportsReasoning: true,
150
+ availableLevels: FIXED_LEVELS,
151
+ getProviderOptions: () => void 0
152
+ };
153
+ }
154
+ const isAdvanced = modelId.includes("gpt-5") || modelId.includes("o3") || modelId.includes("o4");
155
+ return {
156
+ supportsReasoning: true,
157
+ availableLevels: isAdvanced ? EXTENDED_LEVELS : STANDARD_LEVELS,
158
+ getProviderOptions: (level) => buildOpenAIOptions(level, compatibility)
159
+ };
160
+ }
161
+ if (provider?.includes("anthropic") || modelId.includes("claude")) {
162
+ return {
163
+ supportsReasoning: true,
164
+ availableLevels: ["off", "low", "medium", "high"],
165
+ getProviderOptions: buildAnthropicOptions
166
+ };
167
+ }
168
+ if (provider?.includes("google") || modelId.includes("gemini")) {
169
+ return {
170
+ supportsReasoning: true,
171
+ availableLevels: STANDARD_LEVELS,
172
+ getProviderOptions: (level) => buildGoogleOptions(level, modelId)
173
+ };
174
+ }
175
+ if (provider?.includes("xai") || modelId.includes("grok")) {
176
+ return {
177
+ supportsReasoning: true,
178
+ availableLevels: STANDARD_LEVELS,
179
+ getProviderOptions: buildXAIOptions
180
+ };
181
+ }
182
+ if (provider?.includes("bedrock")) {
183
+ return {
184
+ supportsReasoning: true,
185
+ availableLevels: STANDARD_LEVELS,
186
+ getProviderOptions: (level) => buildBedrockOptions(level, modelId)
187
+ };
188
+ }
189
+ if (provider?.includes("groq")) {
190
+ return {
191
+ supportsReasoning: true,
192
+ availableLevels: ["off", "low", "high"],
193
+ getProviderOptions: buildGroqOptions
194
+ };
195
+ }
196
+ if (provider?.includes("openrouter")) {
197
+ return {
198
+ supportsReasoning: true,
199
+ availableLevels: STANDARD_LEVELS,
200
+ getProviderOptions: buildOpenRouterOptions
201
+ };
202
+ }
203
+ if (modelId.includes("r1") || modelId.includes("deepseek")) {
204
+ return {
205
+ supportsReasoning: true,
206
+ availableLevels: FIXED_LEVELS,
207
+ getProviderOptions: () => void 0
208
+ };
209
+ }
210
+ return {
211
+ supportsReasoning: true,
212
+ availableLevels: STANDARD_LEVELS,
213
+ getProviderOptions: (level) => buildOpenAIOptions(level, compatibility)
214
+ };
215
+ }
216
+ function getReasoningConfigSync(model) {
217
+ const modelId = extractModelId(model).toLowerCase();
218
+ const provider = extractProvider(model) || "";
219
+ const supportsReasoning2 = modelId.match(/^o[134]/) !== null || modelId.includes("gpt-5") || modelId.includes("r1") || modelId.includes("thinking") || modelId.includes("reasoning") || modelId.includes("grok") && modelId.includes("mini");
220
+ if (!supportsReasoning2) {
221
+ return {
222
+ supportsReasoning: false,
223
+ availableLevels: ["off"],
224
+ getProviderOptions: () => void 0
225
+ };
226
+ }
227
+ const isOpenAI = provider.includes("openai") || !!modelId.match(/^o[134]/) || modelId.includes("gpt");
228
+ const isAnthropic = provider.includes("anthropic") || modelId.includes("claude");
229
+ const isGoogle = provider.includes("google") || modelId.includes("gemini");
230
+ const isXAI = provider.includes("xai") || modelId.includes("grok");
231
+ const isBedrock = provider.includes("bedrock");
232
+ const isGroq = provider.includes("groq");
233
+ const isOpenRouter = provider.includes("openrouter");
234
+ return {
235
+ supportsReasoning: true,
236
+ availableLevels: STANDARD_LEVELS,
237
+ getProviderOptions: (level) => {
238
+ if (level === "off") return void 0;
239
+ if (isOpenAI) {
240
+ const opts = { reasoningEffort: level };
241
+ if (shouldIncludeReasoningSummary()) opts.reasoningSummary = "auto";
242
+ return opts;
243
+ }
244
+ if (isAnthropic) return buildAnthropicOptions(level);
245
+ if (isGoogle) return buildGoogleOptions(level, modelId);
246
+ if (isXAI) return buildXAIOptions(level);
247
+ if (isBedrock) return buildBedrockOptions(level, modelId);
248
+ if (isGroq) return buildGroqOptions(level);
249
+ if (isOpenRouter) return buildOpenRouterOptions(level);
250
+ const defaultOpts = { reasoningEffort: level };
251
+ if (shouldIncludeReasoningSummary()) defaultOpts.reasoningSummary = "auto";
252
+ return defaultOpts;
253
+ }
254
+ };
255
+ }
256
+ async function buildReasoningOptions(model, level) {
257
+ if (level === "off") return void 0;
258
+ const config = await getReasoningConfig(model);
259
+ if (!config.supportsReasoning) return void 0;
260
+ const effectiveLevel = config.availableLevels.includes(level) ? level : config.availableLevels[config.availableLevels.length - 1];
261
+ const options = config.getProviderOptions(effectiveLevel);
262
+ if (!options) return void 0;
263
+ const provider = extractProvider(model) || "";
264
+ const providerKey = getProviderOptionsKey(provider);
265
+ return { [providerKey]: options };
266
+ }
267
+ function buildReasoningOptionsSync(model, level) {
268
+ if (level === "off") return void 0;
269
+ const config = getReasoningConfigSync(model);
270
+ if (!config.supportsReasoning) return void 0;
271
+ const effectiveLevel = config.availableLevels.includes(level) ? level : config.availableLevels[config.availableLevels.length - 1];
272
+ const options = config.getProviderOptions(effectiveLevel);
273
+ if (!options) return void 0;
274
+ const provider = extractProvider(model) || "";
275
+ const providerKey = getProviderOptionsKey(provider);
276
+ return { [providerKey]: options };
277
+ }
278
+ async function supportsReasoning(model) {
279
+ const resolver = getDefaultResolver();
280
+ return resolver.supportsReasoning(model);
281
+ }
282
+ function supportsReasoningSync(model) {
283
+ return likelySupportsReasoning(extractModelId(model));
284
+ }
285
+
286
+ export {
287
+ STANDARD_LEVELS,
288
+ EXTENDED_LEVELS,
289
+ FIXED_LEVELS,
290
+ shouldIncludeReasoningSummary,
291
+ buildOpenAIOptions,
292
+ buildAnthropicOptions,
293
+ buildGoogleOptions,
294
+ buildXAIOptions,
295
+ buildGroqOptions,
296
+ buildBedrockOptions,
297
+ buildOpenRouterOptions,
298
+ getProviderOptionsKey,
299
+ getReasoningConfig,
300
+ getReasoningConfigSync,
301
+ buildReasoningOptions,
302
+ buildReasoningOptionsSync,
303
+ supportsReasoning,
304
+ supportsReasoningSync
305
+ };
@@ -0,0 +1,91 @@
1
+ import {
2
+ Tool
3
+ } from "./chunk-P6YF7USR.js";
4
+
5
+ // src/skill/tools.ts
6
+ import { z } from "zod";
7
+ function createSkillTool(registry) {
8
+ return Tool.define("skill", () => {
9
+ const skills = registry.list();
10
+ const skillList = skills.length > 0 ? skills.map((s) => ` - "${s.name}": ${s.description}`).join("\n") : " (no skills available)";
11
+ return {
12
+ description: `Load a skill's full instructions to gain specialized knowledge for a task.
13
+
14
+ Available skills:
15
+ ${skillList}
16
+
17
+ Only load a skill when the current task clearly matches its description. Skills provide detailed workflows, reference material, and scripts.`,
18
+ parameters: z.object({
19
+ name: z.string().describe("The name of the skill to load (must match one of the available skills)")
20
+ }),
21
+ execute: async ({ name }) => {
22
+ const content = await registry.loadContent(name);
23
+ if (!content) {
24
+ const available = registry.names.join(", ");
25
+ return {
26
+ title: `Skill not found: ${name}`,
27
+ output: `No skill named "${name}" exists.
28
+
29
+ Available skills: ${available || "(none)"}`,
30
+ metadata: {}
31
+ };
32
+ }
33
+ const formatted = registry.formatContent(content);
34
+ let depNote = "";
35
+ if (content.dependencies && content.dependencies.length > 0) {
36
+ const unloaded = content.dependencies.filter(
37
+ (dep) => registry.has(dep) && !registry.isContentLoaded(dep)
38
+ );
39
+ if (unloaded.length > 0) {
40
+ depNote = `
41
+
42
+ Note: This skill works best with these additional skills: ${unloaded.join(", ")}. Consider loading them if relevant.`;
43
+ }
44
+ }
45
+ return {
46
+ title: `Loaded skill: ${content.name}`,
47
+ output: formatted + depNote,
48
+ metadata: {}
49
+ };
50
+ }
51
+ };
52
+ });
53
+ }
54
+ function createSkillResourceTool(registry) {
55
+ return Tool.define("skill_resource", {
56
+ description: "Read a specific file bundled with a skill (scripts, references, examples, assets). The skill must be loaded first via the `skill` tool to see available resources.",
57
+ parameters: z.object({
58
+ skill: z.string().describe("The skill name"),
59
+ path: z.string().describe("Relative path to the resource file within the skill")
60
+ }),
61
+ execute: async ({ skill, path }) => {
62
+ try {
63
+ const content = await registry.loadResource(skill, path);
64
+ return {
65
+ title: `${skill}/${path}`,
66
+ output: content,
67
+ metadata: {}
68
+ };
69
+ } catch (err) {
70
+ return {
71
+ title: `Error reading resource`,
72
+ output: err instanceof Error ? err.message : String(err),
73
+ metadata: {}
74
+ };
75
+ }
76
+ }
77
+ });
78
+ }
79
+ function createSkillTools(registry) {
80
+ if (registry.size === 0) return [];
81
+ return [
82
+ createSkillTool(registry),
83
+ createSkillResourceTool(registry)
84
+ ];
85
+ }
86
+
87
+ export {
88
+ createSkillTool,
89
+ createSkillResourceTool,
90
+ createSkillTools
91
+ };