@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,103 @@
1
+ import { h as SkillScope, i as SkillSource, a as SkillMetadata, g as SkillResourceType, c as SkillResource, b as SkillContent, d as SkillConfig, S as SkillDiscoveryResult, T as Tool } from '../tool-pFAnJc5Y.js';
2
+ export { R as RemoteSkillEntry, e as RemoteSkillIndex, f as SkillDiscoveryError, j as SkillSourceType } from '../tool-pFAnJc5Y.js';
3
+ import { S as SkillRegistry } from '../registry-CuRWWtcT.js';
4
+ export { c as createSkillRegistry, e as emptySkillRegistry } from '../registry-CuRWWtcT.js';
5
+ import 'zod';
6
+ import '../tool-DYp6-cC3.js';
7
+
8
+ declare const SKILL_FILENAME = "SKILL.md";
9
+ declare const DEFAULT_SKILL_MAX_SIZE = 102400;
10
+
11
+ declare function parseFrontmatter(raw: string): {
12
+ data: Record<string, unknown>;
13
+ body: string;
14
+ };
15
+
16
+ declare function loadSkillMetadata(filePath: string, scope: SkillScope, source: SkillSource, maxSize: number): Promise<SkillMetadata | null>;
17
+
18
+ declare function loadSkillContent(metadata: SkillMetadata): Promise<SkillContent>;
19
+ declare function loadResourceContent(resource: SkillResource): Promise<string>;
20
+ declare function inferResourceType(filePath: string): SkillResourceType;
21
+
22
+ declare const DEFAULT_EXTERNAL_DIRS: string[];
23
+ declare const DEFAULT_MAX_SCAN_DEPTH = 4;
24
+
25
+ declare function discoverSkills(cwd: string, config?: SkillConfig): Promise<SkillDiscoveryResult>;
26
+
27
+ /**
28
+ * Skill Tools — built-in tools for agent-initiated skill loading
29
+ *
30
+ * Provides two tools that enable the agent to activate skills on demand:
31
+ *
32
+ * 1. **`skill`** — Load a skill's full instructions (L2).
33
+ * The agent calls this when it recognizes a task matching a skill's
34
+ * description. Returns the complete skill body with resource listings.
35
+ *
36
+ * 2. **`skill_resource`** — Read a specific bundled resource (L3).
37
+ * After loading a skill, the agent can read scripts, references,
38
+ * examples, or assets bundled with it.
39
+ *
40
+ * These tools expose skills as regular tools the agent can call,
41
+ * using progressive disclosure so context is used efficiently.
42
+ *
43
+ * The tool descriptions are dynamic — they list all available skill names
44
+ * and descriptions so the agent knows what's available without needing
45
+ * a separate discovery step.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * import { createSkillTools, createSkillRegistry } from "@cuylabs/agent-core";
50
+ *
51
+ * const registry = await createSkillRegistry(cwd, skillConfig);
52
+ * const tools = createSkillTools(registry);
53
+ *
54
+ * const agent = createAgent({
55
+ * model: anthropic("claude-sonnet-4-20250514"),
56
+ * tools: [...myTools, ...tools],
57
+ * });
58
+ * ```
59
+ */
60
+
61
+ /**
62
+ * Create the built-in `skill` tool that lets the agent load skill instructions.
63
+ *
64
+ * The tool's description is dynamically generated to include all available
65
+ * skill names and summaries, so the agent knows exactly what's available.
66
+ *
67
+ * @param registry The skill registry to load from
68
+ * @returns A Tool.Info for the `skill` tool
69
+ */
70
+ declare function createSkillTool(registry: SkillRegistry): Tool.AnyInfo;
71
+ /**
72
+ * Create the built-in `skill_resource` tool for reading bundled files.
73
+ *
74
+ * This is the L3 layer — the agent calls this to read specific scripts,
75
+ * references, examples, or assets bundled with a skill.
76
+ *
77
+ * @param registry The skill registry to load from
78
+ * @returns A Tool.Info for the `skill_resource` tool
79
+ */
80
+ declare function createSkillResourceTool(registry: SkillRegistry): Tool.AnyInfo;
81
+ /**
82
+ * Create both skill tools (skill + skill_resource) for an agent.
83
+ *
84
+ * Returns an empty array if the registry has no skills, so the tools
85
+ * don't clutter the agent's tool list when skills aren't in use.
86
+ *
87
+ * @param registry The skill registry
88
+ * @returns Array of Tool.AnyInfo (0 or 2 tools)
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const registry = await createSkillRegistry(cwd, config);
93
+ * const skillTools = createSkillTools(registry);
94
+ *
95
+ * const agent = createAgent({
96
+ * model: myModel,
97
+ * tools: [...codeTools, ...skillTools],
98
+ * });
99
+ * ```
100
+ */
101
+ declare function createSkillTools(registry: SkillRegistry): Tool.AnyInfo[];
102
+
103
+ export { DEFAULT_EXTERNAL_DIRS, DEFAULT_MAX_SCAN_DEPTH, DEFAULT_SKILL_MAX_SIZE, SKILL_FILENAME, SkillConfig, SkillContent, SkillDiscoveryResult, SkillMetadata, SkillRegistry, SkillResource, SkillResourceType, SkillScope, SkillSource, createSkillResourceTool, createSkillTool, createSkillTools, discoverSkills, inferResourceType, loadResourceContent, loadSkillContent, loadSkillMetadata, parseFrontmatter };
@@ -0,0 +1,39 @@
1
+ import {
2
+ createSkillResourceTool,
3
+ createSkillTool,
4
+ createSkillTools
5
+ } from "../chunk-YUUJK53A.js";
6
+ import "../chunk-P6YF7USR.js";
7
+ import {
8
+ DEFAULT_EXTERNAL_DIRS,
9
+ DEFAULT_MAX_SCAN_DEPTH,
10
+ DEFAULT_SKILL_MAX_SIZE,
11
+ SKILL_FILENAME,
12
+ SkillRegistry,
13
+ createSkillRegistry,
14
+ discoverSkills,
15
+ emptySkillRegistry,
16
+ inferResourceType,
17
+ loadResourceContent,
18
+ loadSkillContent,
19
+ loadSkillMetadata,
20
+ parseFrontmatter
21
+ } from "../chunk-LRHOS4ZN.js";
22
+ export {
23
+ DEFAULT_EXTERNAL_DIRS,
24
+ DEFAULT_MAX_SCAN_DEPTH,
25
+ DEFAULT_SKILL_MAX_SIZE,
26
+ SKILL_FILENAME,
27
+ SkillRegistry,
28
+ createSkillRegistry,
29
+ createSkillResourceTool,
30
+ createSkillTool,
31
+ createSkillTools,
32
+ discoverSkills,
33
+ emptySkillRegistry,
34
+ inferResourceType,
35
+ loadResourceContent,
36
+ loadSkillContent,
37
+ loadSkillMetadata,
38
+ parseFrontmatter
39
+ };
@@ -0,0 +1,167 @@
1
+ import { F as FileEntry, i as SerializedMessage, d as SessionEntry, M as MessageEntry, b as MetadataEntry, f as SessionInfo, h as SessionStorage, e as SessionHeader, g as SessionManager } from '../session-manager-Uawm2Le7.js';
2
+ export { B as BranchEntry, C as CompactionEntry, j as ConfigChangeEntry, a as CreateSessionOptions, E as EntryBase, S as STORAGE_VERSION, c as SessionContext } from '../session-manager-Uawm2Le7.js';
3
+ import { M as Message } from '../messages-BYWGn8TY.js';
4
+
5
+ /**
6
+ * Storage Utilities
7
+ *
8
+ * Helper functions for session storage operations.
9
+ */
10
+
11
+ /**
12
+ * Generate a unique 8-character hex ID
13
+ * Collision-checked against existing IDs
14
+ */
15
+ declare function generateEntryId(existingIds?: Set<string>): string;
16
+ /**
17
+ * Parse JSONL content into entries
18
+ * Handles malformed lines gracefully
19
+ */
20
+ declare function parseJSONL<T>(content: string): T[];
21
+ /**
22
+ * Serialize entry to JSONL line
23
+ */
24
+ declare function toJSONL(entry: FileEntry): string;
25
+ /**
26
+ * Serialize multiple entries to JSONL
27
+ */
28
+ declare function toJSONLBatch(entries: FileEntry[]): string;
29
+ /**
30
+ * Serialize a Message to storage format
31
+ */
32
+ declare function serializeMessage(message: Message): SerializedMessage;
33
+ /**
34
+ * Deserialize a stored message back to Message
35
+ */
36
+ declare function deserializeMessage(serialized: SerializedMessage): Message;
37
+ /**
38
+ * Create a message entry from a Message
39
+ */
40
+ declare function createMessageEntry(message: Message, parentId: string | null, existingIds?: Set<string>): MessageEntry;
41
+ /**
42
+ * Create a metadata entry
43
+ */
44
+ declare function createMetadataEntry(updates: {
45
+ title?: string;
46
+ name?: string;
47
+ }, parentId: string | null, existingIds?: Set<string>): MetadataEntry;
48
+ /**
49
+ * Extract SessionInfo from entries (for listing)
50
+ */
51
+ declare function extractSessionInfo(entries: FileEntry[], path: string): SessionInfo | null;
52
+ /**
53
+ * Get leaf entry ID (last entry in the chain)
54
+ */
55
+ declare function getLeafId(entries: FileEntry[]): string | null;
56
+ /**
57
+ * Build path from root to a specific entry
58
+ */
59
+ declare function buildEntryPath(entries: FileEntry[], targetId: string): SessionEntry[];
60
+ /**
61
+ * Build messages array from entries for a specific leaf
62
+ * Handles compaction summaries
63
+ */
64
+ declare function buildMessagesFromEntries(entries: FileEntry[], leafId?: string): Message[];
65
+
66
+ /**
67
+ * Memory Session Storage
68
+ *
69
+ * In-memory implementation of SessionStorage.
70
+ * Useful for testing and ephemeral sessions.
71
+ */
72
+
73
+ /**
74
+ * In-memory session storage
75
+ */
76
+ declare class MemoryStorage implements SessionStorage {
77
+ private sessions;
78
+ create(header: SessionHeader): Promise<void>;
79
+ append(sessionId: string, entry: SessionEntry): Promise<void>;
80
+ appendBatch(sessionId: string, entries: SessionEntry[]): Promise<void>;
81
+ read(sessionId: string): Promise<FileEntry[]>;
82
+ delete(sessionId: string): Promise<boolean>;
83
+ exists(sessionId: string): Promise<boolean>;
84
+ list(): Promise<SessionInfo[]>;
85
+ clear(): Promise<void>;
86
+ }
87
+
88
+ interface FileStorageOptions {
89
+ directory: string;
90
+ extension?: string;
91
+ cache?: boolean;
92
+ }
93
+
94
+ declare class FileStorage implements SessionStorage {
95
+ private readonly directory;
96
+ private readonly extension;
97
+ private readonly useCache;
98
+ private cache;
99
+ private initialized;
100
+ constructor(options: FileStorageOptions);
101
+ private ensureDir;
102
+ private getPath;
103
+ private getEntries;
104
+ create(header: SessionHeader): Promise<void>;
105
+ append(sessionId: string, entry: SessionEntry): Promise<void>;
106
+ appendBatch(sessionId: string, entries: SessionEntry[]): Promise<void>;
107
+ read(sessionId: string): Promise<FileEntry[]>;
108
+ delete(sessionId: string): Promise<boolean>;
109
+ exists(sessionId: string): Promise<boolean>;
110
+ list(): Promise<SessionInfo[]>;
111
+ clear(): Promise<void>;
112
+ flushCache(): void;
113
+ reload(sessionId: string): Promise<FileEntry[]>;
114
+ listIds(): Promise<string[]>;
115
+ getStats(sessionId: string): Promise<{
116
+ size: number;
117
+ mtime: Date;
118
+ } | null>;
119
+ }
120
+
121
+ /**
122
+ * Default paths for storage
123
+ *
124
+ * Follows platform conventions:
125
+ * - macOS: ~/.cuylabs/
126
+ * - Linux: $XDG_DATA_HOME/cuylabs/ or ~/.local/share/cuylabs/
127
+ * - Windows: %APPDATA%/cuylabs/
128
+ *
129
+ * Project identification:
130
+ * - Uses git root commit hash for git repos
131
+ * - Falls back to encoded path for non-git directories
132
+ */
133
+ /**
134
+ * Get the default data directory for cuylabs
135
+ */
136
+ declare function getDataDir(appName?: string): string;
137
+ /**
138
+ * Get the default sessions directory
139
+ */
140
+ declare function getSessionsDir(appName?: string): string;
141
+ /**
142
+ * Get the git root commit hash for a directory.
143
+ * This is stable across machines and identifies the project uniquely.
144
+ * Returns null if not a git repo.
145
+ */
146
+ declare function getGitRootHash(cwd: string): string | null;
147
+ /**
148
+ * Get a short project ID for a directory.
149
+ * - For git repos: uses first 12 chars of root commit hash
150
+ * - For non-git: uses encoded path
151
+ */
152
+ declare function getProjectId(cwd: string): string;
153
+ /**
154
+ * Get sessions directory for a specific project/cwd
155
+ */
156
+ declare function getProjectSessionsDir(cwd: string, appName?: string): string;
157
+
158
+ /**
159
+ * Get the default session-manager instance.
160
+ */
161
+ declare function getDefaultSessionManager(): SessionManager;
162
+ /**
163
+ * Replace the default session-manager instance with one backed by custom storage.
164
+ */
165
+ declare function configureDefaultSessionManager(storage: SessionStorage): SessionManager;
166
+
167
+ export { FileEntry, FileStorage, type FileStorageOptions, MemoryStorage, MessageEntry, MetadataEntry, SerializedMessage, SessionEntry, SessionHeader, SessionInfo, SessionManager, SessionStorage, buildEntryPath, buildMessagesFromEntries, configureDefaultSessionManager, createMessageEntry, createMetadataEntry, deserializeMessage, extractSessionInfo, generateEntryId, getDataDir, getDefaultSessionManager, getGitRootHash, getLeafId, getProjectId, getProjectSessionsDir, getSessionsDir, parseJSONL, serializeMessage, toJSONL, toJSONLBatch };
@@ -0,0 +1,50 @@
1
+ import {
2
+ FileStorage,
3
+ MemoryStorage,
4
+ STORAGE_VERSION,
5
+ SessionManager,
6
+ buildEntryPath,
7
+ buildMessagesFromEntries,
8
+ configureDefaultSessionManager,
9
+ createMessageEntry,
10
+ createMetadataEntry,
11
+ deserializeMessage,
12
+ extractSessionInfo,
13
+ generateEntryId,
14
+ getDataDir,
15
+ getDefaultSessionManager,
16
+ getGitRootHash,
17
+ getLeafId,
18
+ getProjectId,
19
+ getProjectSessionsDir,
20
+ getSessionsDir,
21
+ parseJSONL,
22
+ serializeMessage,
23
+ toJSONL,
24
+ toJSONLBatch
25
+ } from "../chunk-BDBZ3SLK.js";
26
+ export {
27
+ FileStorage,
28
+ MemoryStorage,
29
+ STORAGE_VERSION,
30
+ SessionManager,
31
+ buildEntryPath,
32
+ buildMessagesFromEntries,
33
+ configureDefaultSessionManager,
34
+ createMessageEntry,
35
+ createMetadataEntry,
36
+ deserializeMessage,
37
+ extractSessionInfo,
38
+ generateEntryId,
39
+ getDataDir,
40
+ getDefaultSessionManager,
41
+ getGitRootHash,
42
+ getLeafId,
43
+ getProjectId,
44
+ getProjectSessionsDir,
45
+ getSessionsDir,
46
+ parseJSONL,
47
+ serializeMessage,
48
+ toJSONL,
49
+ toJSONLBatch
50
+ };
@@ -0,0 +1,14 @@
1
+ export { c as AgentProfile, D as DEFAULT_MAX_CONCURRENT, d as DEFAULT_MAX_SPAWN_DEPTH, e as DEFAULT_SESSION_TITLE_PREFIX, S as SubAgentCompletedResult, f as SubAgentHandle, g as SubAgentStatus, h as SubAgentToolConfig, i as SubAgentTracker, j as SubAgentUsage, l as createSubAgentTools } from '../index-p0kOsVsE.js';
2
+ import 'ai';
3
+ import '../types-CQaXbRsS.js';
4
+ import '../tool-pFAnJc5Y.js';
5
+ import 'zod';
6
+ import '../tool-DYp6-cC3.js';
7
+ import '../runner-C7aMP_x3.js';
8
+ import '../messages-BYWGn8TY.js';
9
+ import '../session-manager-Uawm2Le7.js';
10
+ import '../types-VQgymC1N.js';
11
+ import '../tracker-DClqYqTj.js';
12
+ import '../builder-RcTZuYnO.js';
13
+ import '../registry-CuRWWtcT.js';
14
+ import '../types-MM1JoX5T.js';
@@ -0,0 +1,15 @@
1
+ import {
2
+ DEFAULT_MAX_CONCURRENT,
3
+ DEFAULT_MAX_SPAWN_DEPTH,
4
+ DEFAULT_SESSION_TITLE_PREFIX,
5
+ SubAgentTracker,
6
+ createSubAgentTools
7
+ } from "../chunk-7MUFEN4K.js";
8
+ import "../chunk-P6YF7USR.js";
9
+ export {
10
+ DEFAULT_MAX_CONCURRENT,
11
+ DEFAULT_MAX_SPAWN_DEPTH,
12
+ DEFAULT_SESSION_TITLE_PREFIX,
13
+ SubAgentTracker,
14
+ createSubAgentTools
15
+ };
@@ -1,2 +1,174 @@
1
- export { C as CompatibleSchema, I as InferSchemaOutput, M as MAX_BYTES, e as MAX_LINES, f as TRUNCATE_DIR, g as TRUNCATE_GLOB, a as Tool, j as ToolRegistry, l as ToolSpec, m as TruncateResult, n as defaultRegistry, o as defineTool, p as formatSize, t as truncateOutput } from '../index-QR704uRr.js';
1
+ import { T as Tool } from '../tool-pFAnJc5Y.js';
2
+ export { C as CompatibleSchema, I as InferSchemaOutput, k as defineTool } from '../tool-pFAnJc5Y.js';
3
+ import { a as ToolReplayPolicy, F as FileOperationMeta, N as NormalizedToolReplayPolicy, d as ToolHost, e as TurnTrackerContext } from '../tool-DYp6-cC3.js';
4
+ import { M as MiddlewareRunner } from '../runner-C7aMP_x3.js';
2
5
  import 'zod';
6
+ import 'ai';
7
+ import '../messages-BYWGn8TY.js';
8
+
9
+ /**
10
+ * Normalize a tool replay policy into explicit, infrastructure-agnostic
11
+ * recovery semantics.
12
+ *
13
+ * The defaults are intentionally conservative:
14
+ * - read-only tools default to `replay`
15
+ * - mutating or unknown tools default to `manual`
16
+ */
17
+ declare function normalizeToolReplayPolicy(policy?: ToolReplayPolicy, fileOps?: FileOperationMeta): NormalizedToolReplayPolicy;
18
+
19
+ /**
20
+ * Tool registry for @cuylabs/agent-core
21
+ *
22
+ * Manages available tools, named groups, and resolution from specs.
23
+ */
24
+
25
+ /**
26
+ * A tool spec that can be resolved to an array of tools.
27
+ *
28
+ * - `string` — group name (`"read-only"`), single tool ID (`"bash"`),
29
+ * or comma-separated list (`"read,grep,glob"`).
30
+ * Prefix with `-` to exclude: `"all,-bash"`.
31
+ * - `string[]` — array of tool IDs and/or group names.
32
+ * - `Tool.AnyInfo[]` — pass-through (already resolved).
33
+ * - `true` — all registered tools.
34
+ * - `false` — no tools.
35
+ */
36
+ type ToolSpec = string | string[] | Tool.AnyInfo[] | boolean;
37
+ /**
38
+ * Tool registry — manages available tools and named groups.
39
+ *
40
+ * Tools are registered individually. Groups are named collections of tool IDs
41
+ * that resolve against the registry at lookup time.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const reg = new ToolRegistry();
46
+ * reg.registerAll([readTool, grepTool, bashTool]);
47
+ * reg.registerGroup("read-only", ["read", "grep", "glob"]);
48
+ *
49
+ * // Resolve a spec to a tool array
50
+ * reg.resolve("read-only"); // → [readTool, grepTool]
51
+ * reg.resolve("all,-bash"); // → [readTool, grepTool]
52
+ * reg.resolve(["read", "grep"]); // → [readTool, grepTool]
53
+ * reg.resolve(true); // → all tools
54
+ * ```
55
+ */
56
+ declare class ToolRegistry {
57
+ private tools;
58
+ private groups;
59
+ /**
60
+ * Register a tool. Throws if a tool with the same ID is already registered.
61
+ * Use `set()` for upsert semantics.
62
+ */
63
+ register(tool: Tool.AnyInfo): void;
64
+ /** Register multiple tools (throws on duplicates). */
65
+ registerAll(tools: Tool.AnyInfo[]): void;
66
+ /** Register or replace a tool (upsert). */
67
+ set(tool: Tool.AnyInfo): void;
68
+ /** Unregister a tool by ID. Returns `true` if it existed. */
69
+ unregister(id: string): boolean;
70
+ /** Get a tool by ID. */
71
+ get(id: string): Tool.AnyInfo | undefined;
72
+ /** Check if a tool is registered. */
73
+ has(id: string): boolean;
74
+ /** Get all tool IDs. */
75
+ ids(): string[];
76
+ /** Get all tools. */
77
+ all(): Tool.AnyInfo[];
78
+ /** Clear all tools and groups. */
79
+ clear(): void;
80
+ /** Number of registered tools. */
81
+ get size(): number;
82
+ /**
83
+ * Register a named group of tool IDs.
84
+ * The group name can be used in `resolve()` specs.
85
+ * Tool IDs don't need to be registered yet — resolution is lazy.
86
+ */
87
+ registerGroup(name: string, toolIds: string[]): void;
88
+ /** Get tools in a group (only returns registered tools). */
89
+ getGroup(name: string): Tool.AnyInfo[] | undefined;
90
+ /** Check if a group is registered. */
91
+ hasGroup(name: string): boolean;
92
+ /** List all group names. */
93
+ listGroups(): string[];
94
+ /**
95
+ * Resolve a `ToolSpec` to an array of tools.
96
+ *
97
+ * Supports group names, individual tool IDs, comma-separated strings,
98
+ * exclusions with `-` prefix, booleans, and pass-through arrays.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * registry.resolve("read-only"); // group name
103
+ * registry.resolve("read,grep,glob"); // comma-separated IDs
104
+ * registry.resolve("all,-bash"); // all except bash
105
+ * registry.resolve(["read", "grep"]); // array of IDs
106
+ * registry.resolve(true); // all registered tools
107
+ * registry.resolve(false); // empty array
108
+ * ```
109
+ */
110
+ resolve(spec: ToolSpec): Tool.AnyInfo[];
111
+ }
112
+ /**
113
+ * Default tool registry instance.
114
+ * Shared across the application — register tools here for global access.
115
+ */
116
+ declare const defaultRegistry: ToolRegistry;
117
+
118
+ /**
119
+ * Output truncation utilities for @cuylabs/agent-core
120
+ */
121
+ /** Maximum lines before truncation */
122
+ declare const MAX_LINES = 2000;
123
+ /** Maximum bytes before truncation */
124
+ declare const MAX_BYTES = 100000;
125
+ /** Directory for storing truncated outputs */
126
+ declare const TRUNCATE_DIR: string;
127
+ /** Glob pattern for truncation directory */
128
+ declare const TRUNCATE_GLOB: string;
129
+ interface TruncateResult {
130
+ /** The (possibly truncated) content */
131
+ content: string;
132
+ /** Whether the content was truncated */
133
+ truncated: boolean;
134
+ /** Path to full output if truncated */
135
+ outputPath?: string;
136
+ }
137
+ /**
138
+ * Truncate output if it exceeds limits
139
+ */
140
+ declare function truncateOutput(output: string, options?: {
141
+ maxLines?: number;
142
+ maxBytes?: number;
143
+ }): TruncateResult;
144
+ /**
145
+ * Format file size for display
146
+ */
147
+ declare function formatSize(bytes: number): string;
148
+
149
+ interface ExecuteAgentToolCallOptions {
150
+ toolName: string;
151
+ tool: Tool.Info;
152
+ params: unknown;
153
+ cwd: string;
154
+ abort: AbortSignal;
155
+ sessionID: string;
156
+ messageID: string;
157
+ agent?: string;
158
+ host?: ToolHost;
159
+ turnTracker?: TurnTrackerContext;
160
+ middleware?: MiddlewareRunner;
161
+ }
162
+ interface ExecuteAgentToolCallResult {
163
+ output: string;
164
+ }
165
+ /**
166
+ * Execute one initialized framework tool with the same semantics used by the
167
+ * standard AI SDK path.
168
+ *
169
+ * This keeps middleware, baseline capture, and output normalization in one
170
+ * place so resumable runtimes do not need a second tool execution stack.
171
+ */
172
+ declare function executeAgentToolCall(options: ExecuteAgentToolCallOptions): Promise<ExecuteAgentToolCallResult>;
173
+
174
+ export { type ExecuteAgentToolCallOptions, type ExecuteAgentToolCallResult, MAX_BYTES, MAX_LINES, TRUNCATE_DIR, TRUNCATE_GLOB, Tool, ToolRegistry, type ToolSpec, type TruncateResult, defaultRegistry, executeAgentToolCall, formatSize, normalizeToolReplayPolicy, truncateOutput };
@@ -1,15 +1,22 @@
1
+ import {
2
+ ToolRegistry,
3
+ defaultRegistry
4
+ } from "../chunk-SDSBEQXG.js";
5
+ import {
6
+ executeAgentToolCall
7
+ } from "../chunk-FG4MD5MU.js";
1
8
  import {
2
9
  MAX_BYTES,
3
10
  MAX_LINES,
4
11
  TRUNCATE_DIR,
5
12
  TRUNCATE_GLOB,
6
13
  Tool,
7
- ToolRegistry,
8
- defaultRegistry,
9
14
  defineTool,
10
15
  formatSize,
16
+ normalizeToolReplayPolicy,
11
17
  truncateOutput
12
- } from "../chunk-6VKLWNRE.js";
18
+ } from "../chunk-P6YF7USR.js";
19
+ import "../chunk-VEKUXUVF.js";
13
20
  export {
14
21
  MAX_BYTES,
15
22
  MAX_LINES,
@@ -19,6 +26,8 @@ export {
19
26
  ToolRegistry,
20
27
  defaultRegistry,
21
28
  defineTool,
29
+ executeAgentToolCall,
22
30
  formatSize,
31
+ normalizeToolReplayPolicy,
23
32
  truncateOutput
24
33
  };