@cuylabs/agent-core 0.9.0 → 0.11.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 (116) hide show
  1. package/README.md +33 -17
  2. package/dist/chunk-2O4MCSQS.js +780 -0
  3. package/dist/chunk-2TTOLHBT.js +198 -0
  4. package/dist/chunk-5FMSGQVX.js +281 -0
  5. package/dist/chunk-5NVVNXPQ.js +288 -0
  6. package/dist/{chunk-EKR6PKXU.js → chunk-6HZBHFOL.js} +3 -3
  7. package/dist/chunk-CJI7PVS2.js +58 -0
  8. package/dist/{chunk-WKHDSSXG.js → chunk-CMYN2RCB.js} +146 -46
  9. package/dist/chunk-FII65CN7.js +117 -0
  10. package/dist/{chunk-UHCJEM2E.js → chunk-ICZ66572.js} +13 -6
  11. package/dist/chunk-KYLPMBHD.js +316 -0
  12. package/dist/chunk-MXAP4UG6.js +2956 -0
  13. package/dist/{chunk-4QFNWPIF.js → chunk-N3VX7FEE.js} +35 -2
  14. package/dist/{chunk-MAZ5DY5B.js → chunk-NDZWXCBZ.js} +213 -78
  15. package/dist/{chunk-MHKK374K.js → chunk-Q742PSH3.js} +11 -27
  16. package/dist/{chunk-WGZAPU6N.js → chunk-QAL3OMI3.js} +15 -1
  17. package/dist/{chunk-UDCZ673N.js → chunk-RN6WZEUF.js} +27 -23
  18. package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
  19. package/dist/chunk-SPBFQXOT.js +0 -0
  20. package/dist/chunk-SSFBF3US.js +602 -0
  21. package/dist/chunk-SZ2XBPTW.js +8 -0
  22. package/dist/chunk-T4UIX5D7.js +115 -0
  23. package/dist/{chunk-IYWQOJMQ.js → chunk-TIHPYVAJ.js} +34 -34
  24. package/dist/{chunk-RKEW5WXI.js → chunk-TOTDGK3P.js} +1 -1
  25. package/dist/chunk-V4RFNEET.js +563 -0
  26. package/dist/chunk-VOUEJSW6.js +0 -0
  27. package/dist/{chunk-J4QDGZIA.js → chunk-WBPOZ7CL.js} +659 -275
  28. package/dist/chunk-X4VN4GIJ.js +185 -0
  29. package/dist/dispatch/index.d.ts +93 -0
  30. package/dist/dispatch/index.js +37 -0
  31. package/dist/events/index.d.ts +93 -0
  32. package/dist/events/index.js +6 -0
  33. package/dist/{runtime → execution}/index.d.ts +120 -35
  34. package/dist/{runtime → execution}/index.js +17 -11
  35. package/dist/index.d.ts +489 -115
  36. package/dist/index.js +1665 -462
  37. package/dist/inference/errors/index.js +1 -1
  38. package/dist/inference/index.d.ts +13 -21
  39. package/dist/inference/index.js +15 -12
  40. package/dist/instance-DzPiv6EK.d.ts +5723 -0
  41. package/dist/logger/index.d.ts +50 -0
  42. package/dist/logger/index.js +11 -0
  43. package/dist/mcp/index.d.ts +5 -9
  44. package/dist/mcp/index.js +2 -3
  45. package/dist/middleware/index.d.ts +10 -150
  46. package/dist/middleware/index.js +10 -2
  47. package/dist/model-messages-CJfwfzGe.d.ts +13 -0
  48. package/dist/models/index.d.ts +5 -2
  49. package/dist/models/index.js +2 -1
  50. package/dist/models/reasoning/index.js +2 -1
  51. package/dist/plugin/index.d.ts +55 -11
  52. package/dist/plugin/index.js +1 -1
  53. package/dist/profiles/index.d.ts +55 -0
  54. package/dist/{presets → profiles}/index.js +10 -10
  55. package/dist/prompt/index.d.ts +8 -13
  56. package/dist/safety/index.d.ts +109 -14
  57. package/dist/safety/index.js +59 -3
  58. package/dist/sandbox/index.d.ts +81 -0
  59. package/dist/sandbox/index.js +1 -0
  60. package/dist/skill/index.d.ts +10 -8
  61. package/dist/skill/index.js +2 -2
  62. package/dist/storage/index.d.ts +12 -4
  63. package/dist/storage/index.js +1 -1
  64. package/dist/subagents/index.d.ts +177 -0
  65. package/dist/subagents/index.js +78 -0
  66. package/dist/team/index.d.ts +544 -0
  67. package/dist/team/index.js +41 -0
  68. package/dist/tool/host/index.d.ts +41 -0
  69. package/dist/tool/host/index.js +10 -0
  70. package/dist/tool/index.d.ts +111 -21
  71. package/dist/tool/index.js +20 -13
  72. package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
  73. package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
  74. package/dist/types-RSCv7nQ4.d.ts +59 -0
  75. package/package.json +46 -47
  76. package/dist/builder-BgZ_j4Vs.d.ts +0 -35
  77. package/dist/chunk-5ARZJWD2.js +0 -259
  78. package/dist/chunk-DXFBQMXP.js +0 -53
  79. package/dist/chunk-H3FUYU52.js +0 -81
  80. package/dist/chunk-JLXG2SH7.js +0 -905
  81. package/dist/chunk-N7P4PN3O.js +0 -84
  82. package/dist/chunk-OFDKHNCX.js +0 -727
  83. package/dist/chunk-SDSBEQXG.js +0 -157
  84. package/dist/chunk-VEKUXUVF.js +0 -41
  85. package/dist/chunk-VNQBHPCT.js +0 -398
  86. package/dist/chunk-WWYYNWEW.js +0 -259
  87. package/dist/context/index.d.ts +0 -259
  88. package/dist/context/index.js +0 -26
  89. package/dist/events-CE72w8W4.d.ts +0 -149
  90. package/dist/host/index.d.ts +0 -45
  91. package/dist/host/index.js +0 -8
  92. package/dist/index-DQuTZ8xL.d.ts +0 -1335
  93. package/dist/messages-BYWGn8TY.d.ts +0 -110
  94. package/dist/presets/index.d.ts +0 -53
  95. package/dist/registry-DwYqsQkX.d.ts +0 -164
  96. package/dist/runner-CI-XeR16.d.ts +0 -91
  97. package/dist/scope/index.d.ts +0 -10
  98. package/dist/scope/index.js +0 -14
  99. package/dist/session-manager-KbYt2WUh.d.ts +0 -282
  100. package/dist/signal/index.d.ts +0 -28
  101. package/dist/signal/index.js +0 -6
  102. package/dist/sub-agent/index.d.ts +0 -24
  103. package/dist/sub-agent/index.js +0 -32
  104. package/dist/tool-CZWN3KbO.d.ts +0 -141
  105. package/dist/tool-DkhSCV2Y.d.ts +0 -145
  106. package/dist/tracker-DClqYqTj.d.ts +0 -96
  107. package/dist/tracking/index.d.ts +0 -111
  108. package/dist/tracking/index.js +0 -20
  109. package/dist/types-BfNpU8NS.d.ts +0 -270
  110. package/dist/types-BlOKk-Bb.d.ts +0 -330
  111. package/dist/types-BlZwmnuW.d.ts +0 -50
  112. package/dist/types-CQL-SvTn.d.ts +0 -29
  113. package/dist/types-CWm-7rvB.d.ts +0 -55
  114. package/dist/types-DTSkxakL.d.ts +0 -651
  115. package/dist/types-DmDwi2zI.d.ts +0 -339
  116. package/dist/types-YuWV4ag7.d.ts +0 -72
@@ -1,282 +0,0 @@
1
- import { M as Message } from './messages-BYWGn8TY.js';
2
-
3
- /**
4
- * Storage Types
5
- *
6
- * Core types for session storage with tree structure support.
7
- * Designed for append-only event sourcing with branching.
8
- */
9
- /**
10
- * Base interface for all session entries
11
- * Supports tree structure via id/parentId
12
- */
13
- interface EntryBase {
14
- /** Unique entry ID (8-char hex) */
15
- id: string;
16
- /** Parent entry ID (null for first entry after header) */
17
- parentId: string | null;
18
- /** ISO timestamp */
19
- timestamp: string;
20
- }
21
- /**
22
- * Session header - always first entry in file
23
- */
24
- interface SessionHeader {
25
- type: "header";
26
- /** Storage format version */
27
- version: number;
28
- /** Session ID */
29
- id: string;
30
- /** Working directory */
31
- cwd: string;
32
- /** ISO timestamp */
33
- timestamp: string;
34
- /** Parent session ID (if forked) */
35
- parentSessionId?: string;
36
- /** Session title */
37
- title?: string;
38
- }
39
- /**
40
- * Serialized message (dates as ISO strings)
41
- */
42
- interface SerializedMessage {
43
- id: string;
44
- role: "user" | "assistant" | "tool" | "system";
45
- content: string;
46
- createdAt: string;
47
- system?: string;
48
- finish?: string;
49
- tokens?: {
50
- inputTokens?: number;
51
- outputTokens?: number;
52
- totalTokens?: number;
53
- };
54
- cost?: number;
55
- error?: {
56
- name: string;
57
- message: string;
58
- code?: string;
59
- };
60
- /** Tool calls for assistant messages with finish=tool-calls */
61
- toolCalls?: Array<{
62
- toolCallId: string;
63
- toolName: string;
64
- args: unknown;
65
- }>;
66
- toolCallId?: string;
67
- toolName?: string;
68
- result?: unknown;
69
- }
70
- /**
71
- * Message entry
72
- */
73
- interface MessageEntry extends EntryBase {
74
- type: "message";
75
- message: SerializedMessage;
76
- }
77
- /**
78
- * Compaction/summarization entry
79
- * Replaces old messages with a summary
80
- */
81
- interface CompactionEntry extends EntryBase {
82
- type: "compaction";
83
- /** Summary of compacted messages */
84
- summary: string;
85
- /** ID of first entry that was kept (not compacted) */
86
- firstKeptEntryId: string;
87
- /** Token count before compaction */
88
- tokensBefore: number;
89
- /** Token count after compaction */
90
- tokensAfter: number;
91
- /** Files that were read during compacted messages */
92
- readFiles?: string[];
93
- /** Files that were modified during compacted messages */
94
- modifiedFiles?: string[];
95
- }
96
- /**
97
- * Session info/metadata update
98
- */
99
- interface MetadataEntry extends EntryBase {
100
- type: "metadata";
101
- /** Updated title */
102
- title?: string;
103
- /** User-defined name */
104
- name?: string;
105
- }
106
- /**
107
- * Branch marker - indicates a branch point
108
- */
109
- interface BranchEntry extends EntryBase {
110
- type: "branch";
111
- /** ID of the entry we're branching from */
112
- branchFromId: string;
113
- /** Optional summary of the branch */
114
- summary?: string;
115
- }
116
- /**
117
- * Model/config change entry
118
- */
119
- interface ConfigChangeEntry extends EntryBase {
120
- type: "config_change";
121
- /** What changed */
122
- change: "model" | "reasoning_level" | "temperature" | "other";
123
- /** Previous value */
124
- from?: string;
125
- /** New value */
126
- to: string;
127
- }
128
- /**
129
- * All entry types (excluding header)
130
- */
131
- type SessionEntry = MessageEntry | CompactionEntry | MetadataEntry | BranchEntry | ConfigChangeEntry;
132
- /**
133
- * All file entries (including header)
134
- */
135
- type FileEntry = SessionHeader | SessionEntry;
136
- /**
137
- * Session summary info (lightweight, for listing)
138
- */
139
- interface SessionInfo {
140
- /** Session ID */
141
- id: string;
142
- /** File path */
143
- path: string;
144
- /** Working directory */
145
- cwd: string;
146
- /** Session title */
147
- title?: string;
148
- /** User-defined name */
149
- name?: string;
150
- /** Parent session ID (if forked) */
151
- parentSessionId?: string;
152
- /** Creation time */
153
- createdAt: Date;
154
- /** Last modified time */
155
- updatedAt: Date;
156
- /** Number of message entries */
157
- messageCount: number;
158
- /** First user message (preview) */
159
- firstMessage?: string;
160
- }
161
- /**
162
- * Session storage interface
163
- * Pluggable backend for session persistence
164
- */
165
- interface SessionStorage {
166
- /**
167
- * Create a new session
168
- */
169
- create(header: SessionHeader): Promise<void>;
170
- /**
171
- * Append an entry to a session
172
- */
173
- append(sessionId: string, entry: SessionEntry): Promise<void>;
174
- /**
175
- * Append multiple entries atomically
176
- */
177
- appendBatch(sessionId: string, entries: SessionEntry[]): Promise<void>;
178
- /**
179
- * Read all entries from a session
180
- */
181
- read(sessionId: string): Promise<FileEntry[]>;
182
- /**
183
- * Delete a session
184
- */
185
- delete(sessionId: string): Promise<boolean>;
186
- /**
187
- * Check if session exists
188
- */
189
- exists(sessionId: string): Promise<boolean>;
190
- /**
191
- * List all sessions (lightweight info only)
192
- */
193
- list(): Promise<SessionInfo[]>;
194
- /**
195
- * Clear all sessions
196
- */
197
- clear(): Promise<void>;
198
- }
199
- /**
200
- * Current storage format version
201
- */
202
- declare const STORAGE_VERSION = 1;
203
-
204
- /**
205
- * Options for creating a new session.
206
- */
207
- interface CreateSessionOptions {
208
- /** Custom session ID (auto-generated if not provided) */
209
- id?: string;
210
- /** Working directory */
211
- cwd: string;
212
- /** Session title */
213
- title?: string;
214
- /** Parent session ID (if forking) */
215
- parentSessionId?: string;
216
- }
217
- /**
218
- * Session context for LLM calls.
219
- */
220
- interface SessionContext {
221
- /** Messages for LLM context */
222
- messages: Message[];
223
- /** Current leaf entry ID */
224
- leafId: string | null;
225
- /** Session metadata */
226
- metadata: {
227
- id: string;
228
- cwd: string;
229
- title?: string;
230
- name?: string;
231
- };
232
- }
233
-
234
- /**
235
- * Manages session lifecycle with tree-structured entries.
236
- */
237
- declare class SessionManager {
238
- private storage;
239
- private currentSessionId;
240
- private currentLeafId;
241
- private entriesCache;
242
- private idsCache;
243
- constructor(storage?: SessionStorage);
244
- create(options: CreateSessionOptions): Promise<string>;
245
- load(sessionId: string): Promise<void>;
246
- getSessionId(): string | null;
247
- getLeafId(): string | null;
248
- addMessage(message: Message): Promise<string>;
249
- addMessages(messages: Message[]): Promise<string[]>;
250
- getMessages(leafId?: string): Message[];
251
- addCompaction(options: {
252
- summary: string;
253
- firstKeptEntryId: string;
254
- tokensBefore: number;
255
- tokensAfter: number;
256
- readFiles?: string[];
257
- modifiedFiles?: string[];
258
- }): Promise<string>;
259
- replaceWithCompaction(options: {
260
- summary: string;
261
- messages: Message[];
262
- tokensBefore: number;
263
- tokensAfter: number;
264
- readFiles?: string[];
265
- modifiedFiles?: string[];
266
- }): Promise<string>;
267
- branch(fromEntryId: string, summary?: string): Promise<string>;
268
- switchToLeaf(leafId: string): void;
269
- updateMetadata(updates: {
270
- title?: string;
271
- name?: string;
272
- }): Promise<void>;
273
- getContext(): SessionContext;
274
- getEntries(): FileEntry[];
275
- getHeader(): SessionHeader | null;
276
- listSessions(): Promise<SessionInfo[]>;
277
- deleteSession(sessionId: string): Promise<boolean>;
278
- sessionExists(sessionId: string): Promise<boolean>;
279
- getStorage(): SessionStorage;
280
- }
281
-
282
- export { type BranchEntry as B, type CompactionEntry as C, type EntryBase as E, type FileEntry as F, type MessageEntry as M, SessionManager as S, type ConfigChangeEntry as a, type CreateSessionOptions as b, type MetadataEntry as c, STORAGE_VERSION as d, type SerializedMessage as e, type SessionContext as f, type SessionEntry as g, type SessionHeader as h, type SessionInfo as i, type SessionStorage as j };
@@ -1,28 +0,0 @@
1
- import { A as AgentSignal, T as TypedHandler, U as Unsubscribe, W as WildcardHandler } from '../types-YuWV4ag7.js';
2
- export { E as EventOf } from '../types-YuWV4ag7.js';
3
- import { A as AgentEvent } from '../events-CE72w8W4.js';
4
- import 'ai';
5
- import '../messages-BYWGn8TY.js';
6
-
7
- /**
8
- * LocalSignal — in-process event dispatch.
9
- *
10
- * Dispatches events synchronously via direct function calls.
11
- * Zero dependencies, zero serialization, zero network.
12
- *
13
- * Handler errors are caught silently — a broken listener must never
14
- * interrupt the agent's streaming pipeline.
15
- */
16
-
17
- declare class LocalSignal implements AgentSignal {
18
- /** type → Set<handler> for typed subscriptions */
19
- private readonly typed;
20
- /** handlers that receive every event */
21
- private readonly wildcard;
22
- on<T extends AgentEvent["type"]>(type: T, handler: TypedHandler<T>): Unsubscribe;
23
- onAny(handler: WildcardHandler): Unsubscribe;
24
- emit(event: AgentEvent): void;
25
- clear(): void;
26
- }
27
-
28
- export { AgentSignal, LocalSignal, TypedHandler, Unsubscribe, WildcardHandler };
@@ -1,6 +0,0 @@
1
- import {
2
- LocalSignal
3
- } from "../chunk-DXFBQMXP.js";
4
- export {
5
- LocalSignal
6
- };
@@ -1,24 +0,0 @@
1
- export { b as AgentDiscoveryOptions, c as AgentDiscoveryResult, d as AgentProfile, e as AgentSource, D as DEFAULT_MAX_CONCURRENT, f as DEFAULT_MAX_SPAWN_DEPTH, g as DEFAULT_SESSION_TITLE_PREFIX, h as DiscoveredProfile, M as MarkdownAgentFrontmatter, i as MarkdownAgentProfile, j as ParsedMarkdownAgent, k as ParsedToolSpec, l as ProfileResolvers, S as SubAgentCompletedResult, m as SubAgentHandle, n as SubAgentStatus, o as SubAgentToolConfig, p as SubAgentTracker, q as SubAgentUsage, T as ToolModifier, t as createSubAgentTools, u as discoverAgentProfiles, v as getProjectAgentsDir, w as getUserAgentsDir, x as isMarkdownProfile, y as parseAgentFrontmatter, z as parseMarkdownAgent, B as parseToolSpec, E as toAgentProfile } from '../index-DQuTZ8xL.js';
2
- import 'ai';
3
- import '../types-BlZwmnuW.js';
4
- import '../types-CQaXbRsS.js';
5
- import '../tool-CZWN3KbO.js';
6
- import 'zod';
7
- import '../tool-DkhSCV2Y.js';
8
- import '../types-CHiPh8U2.js';
9
- import '../types-CQL-SvTn.js';
10
- import '../types-DTSkxakL.js';
11
- import '@ai-sdk/provider-utils';
12
- import '../events-CE72w8W4.js';
13
- import '../messages-BYWGn8TY.js';
14
- import '../types-BfNpU8NS.js';
15
- import '../session-manager-KbYt2WUh.js';
16
- import '../types-VQgymC1N.js';
17
- import '../types-YuWV4ag7.js';
18
- import '../tracker-DClqYqTj.js';
19
- import '../builder-BgZ_j4Vs.js';
20
- import '../registry-DwYqsQkX.js';
21
- import '../runner-CI-XeR16.js';
22
- import '../types-BlOKk-Bb.js';
23
- import '../llm-error-D93FNNLY.js';
24
- import '../types-DmDwi2zI.js';
@@ -1,32 +0,0 @@
1
- import {
2
- DEFAULT_MAX_CONCURRENT,
3
- DEFAULT_MAX_SPAWN_DEPTH,
4
- DEFAULT_SESSION_TITLE_PREFIX,
5
- SubAgentTracker,
6
- createSubAgentTools,
7
- discoverAgentProfiles,
8
- getProjectAgentsDir,
9
- getUserAgentsDir,
10
- isMarkdownProfile,
11
- parseAgentFrontmatter,
12
- parseMarkdownAgent,
13
- parseToolSpec,
14
- toAgentProfile
15
- } from "../chunk-JLXG2SH7.js";
16
- import "../chunk-EKR6PKXU.js";
17
- import "../chunk-MHKK374K.js";
18
- export {
19
- DEFAULT_MAX_CONCURRENT,
20
- DEFAULT_MAX_SPAWN_DEPTH,
21
- DEFAULT_SESSION_TITLE_PREFIX,
22
- SubAgentTracker,
23
- createSubAgentTools,
24
- discoverAgentProfiles,
25
- getProjectAgentsDir,
26
- getUserAgentsDir,
27
- isMarkdownProfile,
28
- parseAgentFrontmatter,
29
- parseMarkdownAgent,
30
- parseToolSpec,
31
- toAgentProfile
32
- };
@@ -1,141 +0,0 @@
1
- import { z } from 'zod';
2
- import { a as ToolMetadata, b as ToolReplayPolicy, T as ToolContext, F as FileOperationMeta, c as ToolResult } from './tool-DkhSCV2Y.js';
3
-
4
- /**
5
- * Tool definition namespace for @cuylabs/agent-core
6
- *
7
- * Provides consistent tool creation via Tool.define.
8
- */
9
-
10
- /**
11
- * A schema type compatible with both Zod 3 and Zod 4.
12
- *
13
- * Uses structural typing so that schemas from either Zod version satisfy
14
- * the constraint. This avoids the problem where Zod 3's `ZodType` class
15
- * and Zod 4's `ZodType` class have incompatible internal shapes, causing
16
- * type errors when a library compiled against one version is consumed with
17
- * the other.
18
- *
19
- * Both Zod 3 and Zod 4 (classic API) schemas have `parse()` and `_output`.
20
- */
21
- interface CompatibleSchema<T = any> {
22
- /** Parse and validate input data. Present in both Zod 3 and Zod 4. */
23
- parse(data: unknown): T;
24
- /**
25
- * Type-level output marker used by both Zod versions:
26
- * - Zod 3: `readonly _output!: T` (definite assignment assertion)
27
- * - Zod 4 classic: `get _output(): T` (getter)
28
- */
29
- readonly _output: T;
30
- }
31
- /**
32
- * Infer the output type from a compatible schema.
33
- * Equivalent to `z.infer<T>` but works with both Zod 3 and Zod 4 schemas.
34
- */
35
- type InferSchemaOutput<T extends CompatibleSchema> = T["_output"];
36
- /**
37
- * Tool namespace - tool definition utilities
38
- */
39
- declare namespace Tool {
40
- /**
41
- * Tool info interface - the shape of a defined tool
42
- */
43
- interface Info<TParams extends CompatibleSchema = any, TMeta extends ToolMetadata = ToolMetadata> {
44
- /** Unique tool identifier */
45
- id: string;
46
- /** Recovery semantics for resume-capable runtimes. */
47
- replayPolicy?: ToolReplayPolicy;
48
- /** Initialize the tool (can be async for dynamic descriptions) */
49
- init: (ctx?: InitContext) => Promise<InitResult<TParams, TMeta>> | InitResult<TParams, TMeta>;
50
- }
51
- /**
52
- * Any tool info - for use in arrays and collections where generic types vary
53
- */
54
- type AnyInfo = Info<any, any>;
55
- /**
56
- * Context passed during tool initialization
57
- */
58
- interface InitContext {
59
- /** Working directory */
60
- cwd?: string;
61
- /** Agent name (if known) */
62
- agent?: string;
63
- }
64
- /**
65
- * Result of tool initialization
66
- */
67
- interface InitResult<TParams extends CompatibleSchema = any, TMeta extends ToolMetadata = ToolMetadata> {
68
- /** Tool description for the LLM */
69
- description: string;
70
- /** Zod schema for parameters */
71
- parameters: TParams;
72
- /** Execute the tool */
73
- execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ExecuteResult<TMeta>>;
74
- /** Optional custom validation error formatter */
75
- formatValidationError?: (error: z.ZodError) => string;
76
- /**
77
- * File operation metadata for automatic turn tracking.
78
- * When set, the agent will automatically capture file baselines
79
- * before tool execution for undo/diff capabilities.
80
- *
81
- * @example
82
- * ```typescript
83
- * // For a write tool
84
- * fileOps: {
85
- * pathArgs: ['path'],
86
- * operationType: 'write'
87
- * }
88
- * ```
89
- */
90
- fileOps?: FileOperationMeta;
91
- /** Optional replay metadata for resume-capable runtimes. */
92
- replayPolicy?: ToolReplayPolicy;
93
- }
94
- /**
95
- * Result of tool execution
96
- */
97
- interface ExecuteResult<TMeta extends ToolMetadata = ToolMetadata> {
98
- /** Short title for display */
99
- title: string;
100
- /** Main output text */
101
- output: string;
102
- /** Metadata */
103
- metadata: TMeta;
104
- }
105
- interface DefineOptions {
106
- /** Static replay metadata exposed to higher-level runtimes. */
107
- replayPolicy?: ToolReplayPolicy;
108
- }
109
- /**
110
- * Define a tool with standard patterns
111
- *
112
- * @example
113
- * ```typescript
114
- * const myTool = Tool.define("my_tool", {
115
- * description: "Does something useful",
116
- * parameters: z.object({
117
- * input: z.string().describe("The input to process"),
118
- * }),
119
- * execute: async (params, ctx) => ({
120
- * title: "Processed",
121
- * output: `Result: ${params.input}`,
122
- * metadata: {},
123
- * }),
124
- * });
125
- * ```
126
- */
127
- function define<TParams extends CompatibleSchema, TMeta extends ToolMetadata = ToolMetadata>(id: string, init: Info<TParams, TMeta>["init"] | Awaited<ReturnType<Info<TParams, TMeta>["init"]>>, options?: DefineOptions): Info<TParams, TMeta>;
128
- }
129
- /**
130
- * Legacy helper - wraps to Tool.Info format
131
- *
132
- * @deprecated Use Tool.define instead
133
- */
134
- declare function defineTool<TParams extends CompatibleSchema>(definition: {
135
- id: string;
136
- description: string;
137
- parameters: TParams;
138
- execute: (params: InferSchemaOutput<TParams>, ctx: ToolContext) => Promise<ToolResult>;
139
- }): Tool.Info<TParams>;
140
-
141
- export { type CompatibleSchema as C, type InferSchemaOutput as I, Tool as T, defineTool as d };
@@ -1,145 +0,0 @@
1
- import { T as ToolHost } from './types-CHiPh8U2.js';
2
- import { S as ScopeSnapshot } from './types-CQL-SvTn.js';
3
-
4
- /**
5
- * Tool-related types for @cuylabs/agent-core
6
- *
7
- * Defines the interfaces for tool execution context, results,
8
- * and metadata used throughout the agent system.
9
- */
10
-
11
- /**
12
- * Turn tracker interface for tool context
13
- * Minimal interface to avoid circular dependencies
14
- */
15
- interface TurnTrackerContext {
16
- /** Capture baseline before writing to a file */
17
- beforeWrite(path: string): Promise<boolean>;
18
- /** Check if a file is being tracked */
19
- isTracking(path: string): boolean;
20
- }
21
- /**
22
- * Tool execution context
23
- */
24
- interface ToolContext {
25
- /** Working directory for file operations */
26
- cwd: string;
27
- /** Abort signal for cancellation */
28
- abort: AbortSignal;
29
- /** Session ID */
30
- sessionID: string;
31
- /** Message ID */
32
- messageID: string;
33
- /** Agent name */
34
- agent: string;
35
- /** Active execution scope snapshot for this tool call. */
36
- scope?: ScopeSnapshot;
37
- /**
38
- * Execution environment for file and process operations.
39
- *
40
- * Tools should call `ctx.host.readFile()`, `ctx.host.exec()`, etc.
41
- * instead of importing `fs` and `child_process` directly. This
42
- * allows the same tools to work on local, Docker, SSH, or any
43
- * other host without code changes.
44
- *
45
- * When not provided, tools may fall back to direct Node.js APIs,
46
- * but new tools should always prefer `ctx.host`.
47
- */
48
- host?: ToolHost;
49
- /**
50
- * Turn change tracker - automatically captures file baselines.
51
- * Call `turnTracker.beforeWrite(path)` before modifying files
52
- * for undo/diff capabilities.
53
- */
54
- turnTracker?: TurnTrackerContext;
55
- /** Extra context data */
56
- extra?: Record<string, unknown>;
57
- }
58
- /**
59
- * Result returned by a tool
60
- */
61
- interface ToolResult {
62
- /** Short title for display */
63
- title: string;
64
- /** Main output text */
65
- output: string;
66
- /** Optional metadata */
67
- metadata?: ToolMetadata;
68
- }
69
- /**
70
- * File operation metadata - declare how a tool modifies files
71
- * Used by TurnChangeTracker for automatic baseline capture
72
- */
73
- interface FileOperationMeta {
74
- /**
75
- * Names of parameters that contain file paths to track.
76
- * The tracker will capture baselines for these files before the tool runs.
77
- * @example ['path'] for write tool, ['filePath'] for edit tool
78
- */
79
- pathArgs?: string[];
80
- /**
81
- * Type of file operation - determines if baseline capture is needed.
82
- * - 'read': No baseline capture (file not modified)
83
- * - 'write': Capture baseline before overwriting
84
- * - 'create': Capture baseline (to know file didn't exist)
85
- * - 'delete': Capture baseline before deletion
86
- */
87
- operationType?: "read" | "write" | "delete" | "create";
88
- }
89
- /**
90
- * Replay mode used by resume-capable runtimes after a crash.
91
- *
92
- * - `replay` — the tool may be executed again automatically
93
- * - `skip` — the tool should not be replayed automatically
94
- * - `manual` — a higher-level runtime must require an explicit decision
95
- */
96
- type ToolReplayMode = "replay" | "skip" | "manual";
97
- /**
98
- * Coarse side-effect classification for tool execution.
99
- *
100
- * - `none` — read-only or otherwise safe to repeat
101
- * - `local` — mutates local state such as files
102
- * - `external` — may affect processes, networks, services, or systems
103
- */
104
- type ToolSideEffectLevel = "none" | "local" | "external";
105
- /**
106
- * Declares how a resume-capable runtime should treat a tool after failure.
107
- *
108
- * This stays infrastructure-agnostic so Dapr and other runtimes can consume
109
- * the same semantics without leaking runtime-specific types into `agent-core`.
110
- */
111
- interface ToolReplayPolicy {
112
- /** Replay behavior requested by the tool author. */
113
- mode?: ToolReplayMode;
114
- /** Coarse side-effect classification. */
115
- sideEffectLevel?: ToolSideEffectLevel;
116
- /** Optional human-readable rationale for audits and recovery UIs. */
117
- reason?: string;
118
- }
119
- /**
120
- * Fully resolved replay policy with defaults applied.
121
- */
122
- interface NormalizedToolReplayPolicy {
123
- mode: ToolReplayMode;
124
- sideEffectLevel: ToolSideEffectLevel;
125
- reason?: string;
126
- }
127
- /**
128
- * Tool metadata
129
- */
130
- interface ToolMetadata {
131
- /** Whether output was truncated */
132
- truncated?: boolean;
133
- /** Path to full output if truncated */
134
- outputPath?: string;
135
- /**
136
- * File operation metadata for automatic turn tracking.
137
- * When set, the agent will automatically capture file baselines
138
- * before tool execution for undo/diff capabilities.
139
- */
140
- fileOps?: FileOperationMeta;
141
- /** Additional metadata */
142
- [key: string]: unknown;
143
- }
144
-
145
- export type { FileOperationMeta as F, NormalizedToolReplayPolicy as N, ToolContext as T, ToolMetadata as a, ToolReplayPolicy as b, ToolResult as c, TurnTrackerContext as d, ToolReplayMode as e, ToolSideEffectLevel as f };