@cuylabs/agent-core 0.7.0 → 0.9.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 (79) hide show
  1. package/dist/{builder-BRvqCcIk.d.ts → builder-BgZ_j4Vs.d.ts} +3 -2
  2. package/dist/chunk-4QFNWPIF.js +202 -0
  3. package/dist/chunk-5ARZJWD2.js +259 -0
  4. package/dist/chunk-DXFBQMXP.js +53 -0
  5. package/dist/chunk-EKR6PKXU.js +180 -0
  6. package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
  7. package/dist/{chunk-IEFIQENH.js → chunk-H3FUYU52.js} +15 -7
  8. package/dist/chunk-I6PKJ7XQ.js +292 -0
  9. package/dist/chunk-IYWQOJMQ.js +102 -0
  10. package/dist/{chunk-3HNO5SVI.js → chunk-J4QDGZIA.js} +20 -4
  11. package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
  12. package/dist/{chunk-CDTV2UYU.js → chunk-MAZ5DY5B.js} +64 -276
  13. package/dist/{chunk-P6YF7USR.js → chunk-MHKK374K.js} +12 -11
  14. package/dist/{chunk-VBWWUHWI.js → chunk-OFDKHNCX.js} +4 -1
  15. package/dist/{chunk-YUUJK53A.js → chunk-RKEW5WXI.js} +1 -1
  16. package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
  17. package/dist/{chunk-QGOGIP7T.js → chunk-UDCZ673N.js} +385 -233
  18. package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
  19. package/dist/chunk-WGZAPU6N.js +929 -0
  20. package/dist/{chunk-5K7AQVOU.js → chunk-WKHDSSXG.js} +130 -209
  21. package/dist/{chunk-BNSHUWCV.js → chunk-WWYYNWEW.js} +1 -1
  22. package/dist/context/index.js +1 -1
  23. package/dist/events-CE72w8W4.d.ts +149 -0
  24. package/dist/index-BCqEGzBj.d.ts +251 -0
  25. package/dist/{index-C33hlD6H.d.ts → index-DQuTZ8xL.d.ts} +319 -56
  26. package/dist/index.d.ts +42 -121
  27. package/dist/index.js +951 -848
  28. package/dist/inference/errors/index.d.ts +11 -0
  29. package/dist/inference/errors/index.js +16 -0
  30. package/dist/inference/index.d.ts +12 -8
  31. package/dist/inference/index.js +35 -7
  32. package/dist/llm-error-D93FNNLY.d.ts +32 -0
  33. package/dist/middleware/index.d.ts +246 -7
  34. package/dist/middleware/index.js +3 -1
  35. package/dist/models/index.d.ts +132 -9
  36. package/dist/models/index.js +48 -8
  37. package/dist/models/reasoning/index.d.ts +4 -0
  38. package/dist/{reasoning → models/reasoning}/index.js +2 -7
  39. package/dist/plugin/index.d.ts +414 -0
  40. package/dist/plugin/index.js +32 -0
  41. package/dist/presets/index.d.ts +53 -0
  42. package/dist/presets/index.js +30 -0
  43. package/dist/prompt/index.d.ts +11 -8
  44. package/dist/prompt/index.js +3 -2
  45. package/dist/{registry-BDLIHOQB.d.ts → registry-DwYqsQkX.d.ts} +1 -1
  46. package/dist/runner-CI-XeR16.d.ts +91 -0
  47. package/dist/runtime/index.d.ts +12 -8
  48. package/dist/runtime/index.js +8 -7
  49. package/dist/safety/index.d.ts +38 -0
  50. package/dist/safety/index.js +12 -0
  51. package/dist/scope/index.d.ts +2 -2
  52. package/dist/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
  53. package/dist/signal/index.d.ts +28 -0
  54. package/dist/signal/index.js +6 -0
  55. package/dist/skill/index.d.ts +7 -6
  56. package/dist/skill/index.js +3 -3
  57. package/dist/storage/index.d.ts +2 -2
  58. package/dist/storage/index.js +1 -1
  59. package/dist/sub-agent/index.d.ts +16 -10
  60. package/dist/sub-agent/index.js +21 -4
  61. package/dist/tool/index.d.ts +22 -6
  62. package/dist/tool/index.js +3 -3
  63. package/dist/tool-CZWN3KbO.d.ts +141 -0
  64. package/dist/{tool-HUtkiVBx.d.ts → tool-DkhSCV2Y.d.ts} +2 -2
  65. package/dist/tracking/index.d.ts +2 -2
  66. package/dist/tracking/index.js +1 -1
  67. package/dist/{tool-Db1Ue-1U.d.ts → types-BfNpU8NS.d.ts} +1 -150
  68. package/dist/{types-FRpzzg_9.d.ts → types-BlOKk-Bb.d.ts} +10 -35
  69. package/dist/types-BlZwmnuW.d.ts +50 -0
  70. package/dist/{types-9jGQUjqW.d.ts → types-CQL-SvTn.d.ts} +1 -1
  71. package/dist/types-CWm-7rvB.d.ts +55 -0
  72. package/dist/{runner-DSKaEz3z.d.ts → types-DTSkxakL.d.ts} +7 -235
  73. package/dist/{types-CqDZTh4d.d.ts → types-DmDwi2zI.d.ts} +8 -4
  74. package/dist/types-YuWV4ag7.d.ts +72 -0
  75. package/package.json +67 -6
  76. package/dist/capability-resolver-CgRGsWVX.d.ts +0 -254
  77. package/dist/chunk-ZPMACVZK.js +0 -305
  78. package/dist/index-CfBGYrpd.d.ts +0 -317
  79. package/dist/reasoning/index.d.ts +0 -117
@@ -1,15 +1,19 @@
1
1
  import { LanguageModel } from 'ai';
2
- import { R as ReasoningLevel } from './types-CQaXbRsS.js';
3
- import { T as Tool } from './tool-Db1Ue-1U.js';
4
- import { h as AgentMiddleware, d as StreamProvider, P as PromptConfig, A as AgentEvent, M as MiddlewareRunner } from './runner-DSKaEz3z.js';
5
- import { S as SessionManager, f as SessionContext, i as SessionInfo } from './session-manager-B_CWGTsl.js';
2
+ import { P as Preset } from './types-BlZwmnuW.js';
3
+ import { T as Tool } from './tool-CZWN3KbO.js';
4
+ import { A as AgentMiddleware, f as StreamProvider, d as PromptConfig } from './types-DTSkxakL.js';
5
+ import { S as SessionManager, f as SessionContext, i as SessionInfo } from './session-manager-KbYt2WUh.js';
6
6
  import { T as ToolHost } from './types-CHiPh8U2.js';
7
7
  import { T as TokenUsage, M as Message } from './messages-BYWGn8TY.js';
8
+ import { A as AgentEvent } from './events-CE72w8W4.js';
9
+ import { R as ReasoningLevel } from './types-CQaXbRsS.js';
8
10
  import { a as MCPManager } from './types-VQgymC1N.js';
11
+ import { A as AgentSignal } from './types-YuWV4ag7.js';
9
12
  import { U as UndoResult, T as TurnChangeTracker } from './tracker-DClqYqTj.js';
10
- import { P as PromptBuilder } from './builder-BRvqCcIk.js';
11
- import { P as PendingIntervention, g as InterventionController } from './types-FRpzzg_9.js';
12
- import { s as DoomLoopHandler, o as AgentTurnStepRuntimeConfig } from './types-CqDZTh4d.js';
13
+ import { P as PromptBuilder } from './builder-BgZ_j4Vs.js';
14
+ import { P as PendingIntervention, n as InterventionController } from './types-BlOKk-Bb.js';
15
+ import { M as MiddlewareRunner } from './runner-CI-XeR16.js';
16
+ import { s as DoomLoopHandler, o as AgentTurnStepRuntimeConfig } from './types-DmDwi2zI.js';
13
17
 
14
18
  /**
15
19
  * Tools whose outputs should never be pruned automatically.
@@ -156,51 +160,17 @@ interface AgentConfig {
156
160
  * Simplest way to enable tracing.
157
161
  */
158
162
  tracing?: TracingConfig;
159
- }
160
-
161
- /**
162
- * Agent preset - a reusable configuration profile.
163
- */
164
- interface Preset {
165
- /** Unique identifier for this preset */
166
- name: string;
167
- /** Human-readable description */
168
- description: string;
169
163
  /**
170
- * Tool allow patterns (glob-like).
171
- * If provided, only tools matching these patterns are candidates.
172
- */
173
- allowTools?: string[];
174
- /**
175
- * Tool deny patterns (glob-like).
176
- * Deny patterns apply only after allow matching, so explicit allows win.
177
- */
178
- denyTools?: string[];
179
- /**
180
- * Override system prompt.
181
- * Use `{basePrompt}` to include the parent's system prompt.
164
+ * Event signal for multi-consumer dispatch.
165
+ *
166
+ * Every event yielded by `chat()` is also emitted here, enabling
167
+ * passive observers (SSE routes, TUI renderers, plugins) to
168
+ * subscribe without consuming the primary generator.
169
+ *
170
+ * Defaults to an in-process `LocalSignal`. A distributed runtime
171
+ * can supply its own implementation to bridge events externally.
182
172
  */
183
- systemPrompt?: string;
184
- /** Override temperature (0-1). */
185
- temperature?: number;
186
- /** Override max steps. */
187
- maxSteps?: number;
188
- /** Override reasoning level. */
189
- reasoningLevel?: ReasoningLevel;
190
- /** Override model. */
191
- model?: LanguageModel;
192
- }
193
- /**
194
- * Result of applying a preset - ready for `fork()`.
195
- */
196
- interface AppliedPreset {
197
- name: string;
198
- systemPrompt?: string;
199
- tools?: Tool.AnyInfo[];
200
- temperature?: number;
201
- maxSteps?: number;
202
- reasoningLevel?: ReasoningLevel;
203
- model?: LanguageModel;
173
+ signal?: AgentSignal;
204
174
  }
205
175
 
206
176
  interface AgentForkOptions {
@@ -261,7 +231,6 @@ declare class Agent {
261
231
  private config;
262
232
  private tools;
263
233
  private sessions;
264
- private loadedSessions;
265
234
  private state;
266
235
  /** Context manager for overflow detection and compaction */
267
236
  private contextManager;
@@ -275,6 +244,8 @@ declare class Agent {
275
244
  private mcpManager?;
276
245
  /** Whether MCP has been connected (lazy init) */
277
246
  private mcpConnected;
247
+ /** Whether skill tools have been resolved (lazy init) */
248
+ private skillToolsResolved;
278
249
  /** Cached MCP tools (refreshed on connect) */
279
250
  private mcpToolsCache?;
280
251
  /** Prompt pipeline builder (when using layered prompt mode) */
@@ -283,13 +254,31 @@ declare class Agent {
283
254
  private interventionCtrl;
284
255
  /** Execution environment for tool operations */
285
256
  private host;
257
+ /** Whether the agent owns the host and can safely recreate it on cwd changes */
258
+ private ownsHost;
286
259
  /** Middleware runner for lifecycle hooks */
287
260
  private middlewareRunner;
288
261
  /** AI SDK telemetry settings (auto-created from `tracing` config) */
289
262
  private telemetrySettings?;
290
263
  /** Tracing shutdown function (from `tracing` config auto-setup) */
291
264
  private tracingShutdown?;
265
+ /** Multi-consumer event dispatch */
266
+ private readonly _signal;
267
+ /** Number of active turns across all sessions */
268
+ private activeTurnCount;
269
+ /** Active turn intervention controllers, keyed by turn id */
270
+ private readonly activeTurns;
271
+ /** Per-session turn queue to prevent concurrent writes to the same history */
272
+ private readonly sessionLocks;
292
273
  constructor(config: AgentConstructionOptions);
274
+ /**
275
+ * Event signal — subscribe to events without consuming the generator.
276
+ *
277
+ * Every event yielded by `chat()` is also dispatched here, allowing
278
+ * multiple passive observers (SSE routes, TUI, plugins) to listen
279
+ * concurrently.
280
+ */
281
+ get signal(): AgentSignal;
293
282
  /** Agent name (identity for spans, Dapr workflows, etc.) */
294
283
  get name(): string;
295
284
  /** Working directory for file operations */
@@ -315,6 +304,20 @@ declare class Agent {
315
304
  * Check if current model supports reasoning
316
305
  */
317
306
  supportsReasoning(): boolean;
307
+ /**
308
+ * Ensure skill tools are registered when `prompt.skills` is configured.
309
+ * Lazy initialization — resolves the registry and adds tools on first use.
310
+ */
311
+ private ensureSkillTools;
312
+ private resetPromptScopedTools;
313
+ private createSessionManager;
314
+ private acquireSessionLock;
315
+ private getActiveInterventionController;
316
+ private getInterventionControllerForTurn;
317
+ private createTurnInterventionController;
318
+ private releaseTurnInterventions;
319
+ private syncStreamingState;
320
+ private syncSessionView;
318
321
  /**
319
322
  * Ensure MCP is connected and return tools
320
323
  * Lazy initialization - only connects on first use
@@ -355,10 +358,6 @@ declare class Agent {
355
358
  abort?: AbortSignal;
356
359
  system?: string;
357
360
  }): AsyncGenerator<AgentEvent>;
358
- /**
359
- * Ensure a session is loaded or created
360
- */
361
- private ensureSession;
362
361
  /**
363
362
  * Send a message and wait for the complete response (non-streaming).
364
363
  *
@@ -465,6 +464,8 @@ declare class Agent {
465
464
  *
466
465
  * If called when no turn is active, the message will be picked up
467
466
  * by the first step of the next `chat()` call.
467
+ * If multiple turns are active concurrently, this throws because the
468
+ * target turn would be ambiguous.
468
469
  *
469
470
  * @param message - The user message to inject mid-turn
470
471
  * @returns Intervention ID for tracking
@@ -494,6 +495,9 @@ declare class Agent {
494
495
  * `chat()` finishes. The consumer decides whether to send it as a
495
496
  * new turn.
496
497
  *
498
+ * If multiple turns are active concurrently, this throws because the
499
+ * target turn would be ambiguous.
500
+ *
497
501
  * @param message - The message to queue
498
502
  * @returns Intervention ID for tracking
499
503
  *
@@ -1069,4 +1073,263 @@ declare class SubAgentTracker {
1069
1073
  */
1070
1074
  declare function createSubAgentTools(parent: Agent, config: SubAgentToolConfig): Tool.AnyInfo[];
1071
1075
 
1072
- export { type AppliedPreset as A, type CompactionConfig as C, DEFAULT_MAX_CONCURRENT as D, type Preset as P, type SubAgentCompletedResult as S, type TracingConfig as T, type AgentConfig as a, Agent as b, type AgentProfile as c, DEFAULT_MAX_SPAWN_DEPTH as d, DEFAULT_SESSION_TITLE_PREFIX as e, PRUNE_PROTECTED_TOOLS as f, type SubAgentHandle as g, type SubAgentStatus as h, type SubAgentToolConfig as i, SubAgentTracker as j, type SubAgentUsage as k, createAgent as l, createSubAgentTools as m };
1076
+ /**
1077
+ * Markdown Agent Profile Parser
1078
+ *
1079
+ * Parses `.md` files into `AgentProfile` objects using a hybrid approach:
1080
+ *
1081
+ * - **Frontmatter** (YAML between `---` fences) maps to profile config
1082
+ * - **Body** (everything after frontmatter) becomes the system prompt
1083
+ * - **Preset references** compose with the existing TypeScript preset system
1084
+ * - **Tool modifiers** (`+tool`, `-tool*`) extend or restrict preset tool lists
1085
+ * - **Inheritance** (`extends: parent-name`) layers on top of another profile
1086
+ *
1087
+ * No external YAML library required — the frontmatter grammar is deliberately
1088
+ * restricted to flat key-value pairs and comma-separated lists.
1089
+ *
1090
+ * @packageDocumentation
1091
+ */
1092
+
1093
+ /**
1094
+ * Raw frontmatter fields extracted from a markdown agent file.
1095
+ *
1096
+ * All values are strings at this stage — conversion to typed config
1097
+ * happens in {@link toAgentProfile}.
1098
+ */
1099
+ interface MarkdownAgentFrontmatter {
1100
+ /** Agent name (required). Lowercase, no spaces. */
1101
+ name: string;
1102
+ /** LLM-facing description of when to use this agent (required). */
1103
+ description: string;
1104
+ /** Built-in preset to inherit from (e.g. "explore", "code", "plan"). */
1105
+ preset?: string;
1106
+ /** Parent agent name to extend. */
1107
+ extends?: string;
1108
+ /** Model identifier (e.g. "anthropic/claude-sonnet-4-6"). */
1109
+ model?: string;
1110
+ /** Maximum agentic loop steps. */
1111
+ maxSteps?: string;
1112
+ /** LLM temperature (0–1). */
1113
+ temperature?: string;
1114
+ /** Reasoning level: off, minimal, low, medium, high, xhigh. */
1115
+ reasoning?: string;
1116
+ /**
1117
+ * Tool modifiers or explicit tool list.
1118
+ *
1119
+ * Three modes:
1120
+ * - **Additive/subtractive**: `"+bash, -delete*, +fetch"` — patch the preset
1121
+ * - **Explicit list**: `"read, grep, bash"` — ONLY these tools
1122
+ * - **Absent**: inherit preset filtering unchanged
1123
+ */
1124
+ tools?: string;
1125
+ /** Comma-separated skill names to activate for this agent. */
1126
+ skills?: string;
1127
+ /** Whether this agent can spawn further sub-agents. */
1128
+ canSpawn?: string;
1129
+ }
1130
+ /**
1131
+ * Result of parsing a markdown agent file.
1132
+ */
1133
+ interface ParsedMarkdownAgent {
1134
+ /** Parsed frontmatter fields. */
1135
+ frontmatter: MarkdownAgentFrontmatter;
1136
+ /** Markdown body — becomes the system prompt. */
1137
+ body: string;
1138
+ /** Original file path (for error messages). */
1139
+ filePath: string;
1140
+ }
1141
+ /**
1142
+ * Parsed tool modifier from frontmatter `tools` field.
1143
+ */
1144
+ type ToolModifier = {
1145
+ kind: "add";
1146
+ pattern: string;
1147
+ } | {
1148
+ kind: "remove";
1149
+ pattern: string;
1150
+ };
1151
+ /**
1152
+ * Parsed tool specification from frontmatter.
1153
+ */
1154
+ type ParsedToolSpec = {
1155
+ mode: "explicit";
1156
+ patterns: string[];
1157
+ } | {
1158
+ mode: "modifiers";
1159
+ modifiers: ToolModifier[];
1160
+ } | {
1161
+ mode: "inherit";
1162
+ };
1163
+ /**
1164
+ * Resolvers needed to convert parsed frontmatter into a full `AgentProfile`.
1165
+ *
1166
+ * These are injected by the caller so the parser stays pure (no I/O, no
1167
+ * global lookups).
1168
+ */
1169
+ interface ProfileResolvers {
1170
+ /** Look up a built-in preset by name. Returns undefined if not found. */
1171
+ resolvePreset?: (name: string) => Preset | undefined;
1172
+ /** Look up a parent profile by name (for `extends`). */
1173
+ resolveParent?: (name: string) => AgentProfile | undefined;
1174
+ }
1175
+ /**
1176
+ * Parse a YAML-like frontmatter block.
1177
+ *
1178
+ * Supports:
1179
+ * - `key: value` (string values, trimmed)
1180
+ * - `key: "quoted value"` (double-quoted, quotes stripped)
1181
+ * - `key: 'quoted value'` (single-quoted, quotes stripped)
1182
+ * - Multi-line values via `key: |` (indented block)
1183
+ * - Comments (`# ...`)
1184
+ * - Empty lines (skipped)
1185
+ *
1186
+ * Does NOT support nested objects, arrays, or advanced YAML features.
1187
+ * This is intentional — agent definitions should stay flat and readable.
1188
+ */
1189
+ declare function parseAgentFrontmatter(raw: string): Record<string, string>;
1190
+ /**
1191
+ * Parse a markdown agent file into structured frontmatter + body.
1192
+ *
1193
+ * @param content File content (UTF-8 string)
1194
+ * @param filePath Source file path (for error context)
1195
+ * @returns Parsed result, or null if the file lacks valid frontmatter
1196
+ */
1197
+ declare function parseMarkdownAgent(content: string, filePath: string): ParsedMarkdownAgent | null;
1198
+ /**
1199
+ * Parse the `tools` frontmatter field into a structured spec.
1200
+ *
1201
+ * - `"+bash, -delete*, +fetch"` → `{ mode: "modifiers", modifiers: [...] }`
1202
+ * - `"read, grep, bash"` → `{ mode: "explicit", patterns: ["read", "grep", "bash"] }`
1203
+ * - `undefined` → `{ mode: "inherit" }`
1204
+ */
1205
+ declare function parseToolSpec(raw: string | undefined): ParsedToolSpec;
1206
+ /**
1207
+ * Convert a parsed markdown agent into an `AgentProfile`.
1208
+ *
1209
+ * Resolution order for each field:
1210
+ * 1. Explicit frontmatter value (highest priority)
1211
+ * 2. Parent profile (via `extends`)
1212
+ * 3. Preset defaults
1213
+ * 4. Built-in defaults
1214
+ *
1215
+ * @param parsed Parsed markdown agent
1216
+ * @param resolvers Injected lookup functions
1217
+ * @returns A fully-resolved `AgentProfile`
1218
+ */
1219
+ declare function toAgentProfile(parsed: ParsedMarkdownAgent, resolvers?: ProfileResolvers): AgentProfile;
1220
+ /**
1221
+ * An `AgentProfile` that originated from a markdown file.
1222
+ *
1223
+ * Carries extra metadata that the discovery/wiring layer can use
1224
+ * to resolve model strings and activate skills.
1225
+ */
1226
+ interface MarkdownAgentProfile extends AgentProfile {
1227
+ /** Model identifier string (e.g. "anthropic/claude-sonnet-4-6"). */
1228
+ _modelId?: string;
1229
+ /** Skill names to activate for this agent. */
1230
+ _skillNames?: string[];
1231
+ /** Source file path. */
1232
+ _source?: string;
1233
+ }
1234
+ /**
1235
+ * Type guard for markdown-sourced profiles.
1236
+ */
1237
+ declare function isMarkdownProfile(profile: AgentProfile): profile is MarkdownAgentProfile;
1238
+
1239
+ /**
1240
+ * Agent Profile Discovery
1241
+ *
1242
+ * Discovers agent profiles from markdown files across multiple locations
1243
+ * and merges them with built-in TypeScript profiles.
1244
+ *
1245
+ * Discovery order (later wins by name):
1246
+ * 1. Built-in TypeScript profiles (e.g. explorer, coder, planner, runner)
1247
+ * 2. User global agents: `~/.cuylabs/agents/*.md`
1248
+ * 3. Project local agents: `.cuylabs/agents/*.md`
1249
+ * 4. Config-specified paths: `config.agents` array
1250
+ *
1251
+ * @packageDocumentation
1252
+ */
1253
+
1254
+ /** Source tier for an agent profile. */
1255
+ type AgentSource = "builtin" | "user" | "project" | "config";
1256
+ /** Metadata attached to discovered profiles for debugging/logging. */
1257
+ interface DiscoveredProfile {
1258
+ profile: AgentProfile;
1259
+ source: AgentSource;
1260
+ filePath?: string;
1261
+ }
1262
+ /**
1263
+ * Options for agent profile discovery.
1264
+ */
1265
+ interface AgentDiscoveryOptions {
1266
+ /** Project working directory. Used to find `.cuylabs/agents/`. */
1267
+ cwd: string;
1268
+ /**
1269
+ * User-global agents directory.
1270
+ * @default `~/.cuylabs/agents`
1271
+ */
1272
+ userDir?: string;
1273
+ /**
1274
+ * Project-local agents directory name (relative to cwd).
1275
+ * @default `.cuylabs/agents`
1276
+ */
1277
+ projectDir?: string;
1278
+ /**
1279
+ * Additional file paths from config.json `agents` array.
1280
+ * Resolved relative to cwd.
1281
+ */
1282
+ configPaths?: string[];
1283
+ /** Built-in TypeScript profiles to merge with. */
1284
+ builtInProfiles?: AgentProfile[];
1285
+ /**
1286
+ * Custom preset resolver. Defaults to the built-in `Presets` map.
1287
+ */
1288
+ resolvePreset?: (name: string) => Preset | undefined;
1289
+ }
1290
+ /**
1291
+ * Result of agent profile discovery.
1292
+ */
1293
+ interface AgentDiscoveryResult {
1294
+ /** Merged profiles (ready for `SubAgentToolConfig.profiles`). */
1295
+ profiles: AgentProfile[];
1296
+ /** All discovered entries with source metadata (for logging). */
1297
+ discovered: DiscoveredProfile[];
1298
+ /** Errors encountered during loading (non-fatal). */
1299
+ errors: Array<{
1300
+ path: string;
1301
+ error: string;
1302
+ }>;
1303
+ }
1304
+ /**
1305
+ * Discover agent profiles from markdown files and merge with built-in profiles.
1306
+ *
1307
+ * Merge strategy: later sources override earlier ones by profile name.
1308
+ * Within the same source tier, later files (alphabetical) override earlier ones.
1309
+ *
1310
+ * This means a project `.cuylabs/agents/explorer.md` overrides the built-in
1311
+ * `explorer` profile, and a user `~/.cuylabs/agents/explorer.md` overrides it
1312
+ * for all projects.
1313
+ *
1314
+ * @example
1315
+ * ```typescript
1316
+ * const { profiles } = discoverAgentProfiles({
1317
+ * cwd: "/path/to/project",
1318
+ * builtInProfiles: defaultCodingProfiles,
1319
+ * });
1320
+ *
1321
+ * // profiles now includes built-ins + user + project markdown agents
1322
+ * const config: SubAgentToolConfig = { profiles };
1323
+ * ```
1324
+ */
1325
+ declare function discoverAgentProfiles(options: AgentDiscoveryOptions): AgentDiscoveryResult;
1326
+ /**
1327
+ * Get the default user agents directory path.
1328
+ */
1329
+ declare function getUserAgentsDir(): string;
1330
+ /**
1331
+ * Get the project agents directory path for a given cwd.
1332
+ */
1333
+ declare function getProjectAgentsDir(cwd: string): string;
1334
+
1335
+ export { type AgentConfig as A, parseToolSpec as B, type CompactionConfig as C, DEFAULT_MAX_CONCURRENT as D, toAgentProfile as E, type MarkdownAgentFrontmatter as M, PRUNE_PROTECTED_TOOLS as P, type SubAgentCompletedResult as S, type ToolModifier as T, Agent as a, type AgentDiscoveryOptions as b, type AgentDiscoveryResult as c, type AgentProfile as d, type AgentSource as e, DEFAULT_MAX_SPAWN_DEPTH as f, DEFAULT_SESSION_TITLE_PREFIX as g, type DiscoveredProfile as h, type MarkdownAgentProfile as i, type ParsedMarkdownAgent as j, type ParsedToolSpec as k, type ProfileResolvers as l, type SubAgentHandle as m, type SubAgentStatus as n, type SubAgentToolConfig as o, SubAgentTracker as p, type SubAgentUsage as q, type TracingConfig as r, createAgent as s, createSubAgentTools as t, discoverAgentProfiles as u, getProjectAgentsDir as v, getUserAgentsDir as w, isMarkdownProfile as x, parseAgentFrontmatter as y, parseMarkdownAgent as z };