@cuylabs/agent-core 0.8.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 (68) hide show
  1. package/dist/{builder-UpOWQMW3.d.ts → builder-BgZ_j4Vs.d.ts} +2 -1
  2. package/dist/{chunk-RZITT45F.js → chunk-4QFNWPIF.js} +4 -4
  3. package/dist/{chunk-BFM2YHNM.js → chunk-5ARZJWD2.js} +74 -37
  4. package/dist/{chunk-KUVSERLJ.js → chunk-DXFBQMXP.js} +5 -2
  5. package/dist/{chunk-CAA7FHIH.js → chunk-EKR6PKXU.js} +0 -100
  6. package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
  7. package/dist/{chunk-7VKQ4WPB.js → chunk-H3FUYU52.js} +11 -3
  8. package/dist/chunk-I6PKJ7XQ.js +292 -0
  9. package/dist/chunk-IYWQOJMQ.js +102 -0
  10. package/dist/{chunk-4BDA7DQY.js → chunk-J4QDGZIA.js} +19 -3
  11. package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
  12. package/dist/{chunk-YSLSEQ6B.js → chunk-MAZ5DY5B.js} +18 -30
  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-RFEKJKTO.js → chunk-UDCZ673N.js} +321 -275
  18. package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
  19. package/dist/chunk-WGZAPU6N.js +929 -0
  20. package/dist/{chunk-N6HWIEEA.js → chunk-WKHDSSXG.js} +140 -23
  21. package/dist/index-BCqEGzBj.d.ts +251 -0
  22. package/dist/{index-CWSchSql.d.ts → index-DQuTZ8xL.d.ts} +290 -13
  23. package/dist/index.d.ts +23 -29
  24. package/dist/index.js +776 -490
  25. package/dist/{errors → inference/errors}/index.d.ts +2 -2
  26. package/dist/{errors → inference/errors}/index.js +1 -1
  27. package/dist/inference/index.d.ts +10 -9
  28. package/dist/inference/index.js +34 -8
  29. package/dist/middleware/index.d.ts +5 -4
  30. package/dist/middleware/index.js +3 -3
  31. package/dist/models/index.d.ts +18 -16
  32. package/dist/models/index.js +47 -11
  33. package/dist/models/reasoning/index.d.ts +4 -0
  34. package/dist/{reasoning → models/reasoning}/index.js +2 -3
  35. package/dist/plugin/index.d.ts +414 -0
  36. package/dist/plugin/index.js +32 -0
  37. package/dist/presets/index.d.ts +3 -3
  38. package/dist/presets/index.js +7 -5
  39. package/dist/prompt/index.d.ts +6 -5
  40. package/dist/prompt/index.js +3 -2
  41. package/dist/runner-CI-XeR16.d.ts +91 -0
  42. package/dist/runtime/index.d.ts +7 -6
  43. package/dist/runtime/index.js +6 -7
  44. package/dist/safety/index.d.ts +1 -1
  45. package/dist/safety/index.js +1 -1
  46. package/dist/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
  47. package/dist/signal/index.js +1 -1
  48. package/dist/skill/index.d.ts +2 -2
  49. package/dist/skill/index.js +3 -3
  50. package/dist/storage/index.d.ts +2 -2
  51. package/dist/storage/index.js +1 -1
  52. package/dist/sub-agent/index.d.ts +10 -9
  53. package/dist/sub-agent/index.js +21 -4
  54. package/dist/tool/index.d.ts +19 -5
  55. package/dist/tool/index.js +2 -2
  56. package/dist/{tool-BHbyUAy3.d.ts → tool-CZWN3KbO.d.ts} +1 -10
  57. package/dist/{tool-DLXAR9Ce.d.ts → tool-DkhSCV2Y.d.ts} +1 -1
  58. package/dist/tracking/index.d.ts +1 -1
  59. package/dist/tracking/index.js +1 -1
  60. package/dist/{types-KKDrdU9Y.d.ts → types-BlOKk-Bb.d.ts} +9 -4
  61. package/dist/{types-BnpEOYV-.d.ts → types-BlZwmnuW.d.ts} +1 -1
  62. package/dist/{runner-e2YRcUoX.d.ts → types-DTSkxakL.d.ts} +3 -138
  63. package/dist/{types-QKHHQLLq.d.ts → types-DmDwi2zI.d.ts} +7 -4
  64. package/package.json +15 -9
  65. package/dist/chunk-DWYX7ASF.js +0 -26
  66. package/dist/chunk-SQU2AJHO.js +0 -305
  67. package/dist/reasoning/index.d.ts +0 -116
  68. package/dist/types-QA4WhEfz.d.ts +0 -138
@@ -1,8 +1,8 @@
1
1
  import { LanguageModel } from 'ai';
2
- import { P as Preset } from './types-BnpEOYV-.js';
3
- import { T as Tool } from './tool-BHbyUAy3.js';
4
- import { A as AgentMiddleware, d as StreamProvider, P as PromptConfig, M as MiddlewareRunner } from './runner-e2YRcUoX.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
8
  import { A as AgentEvent } from './events-CE72w8W4.js';
@@ -10,9 +10,10 @@ import { R as ReasoningLevel } from './types-CQaXbRsS.js';
10
10
  import { a as MCPManager } from './types-VQgymC1N.js';
11
11
  import { A as AgentSignal } from './types-YuWV4ag7.js';
12
12
  import { U as UndoResult, T as TurnChangeTracker } from './tracker-DClqYqTj.js';
13
- import { P as PromptBuilder } from './builder-UpOWQMW3.js';
14
- import { P as PendingIntervention, g as InterventionController } from './types-KKDrdU9Y.js';
15
- import { s as DoomLoopHandler, o as AgentTurnStepRuntimeConfig } from './types-QKHHQLLq.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';
16
17
 
17
18
  /**
18
19
  * Tools whose outputs should never be pruned automatically.
@@ -230,7 +231,6 @@ declare class Agent {
230
231
  private config;
231
232
  private tools;
232
233
  private sessions;
233
- private loadedSessions;
234
234
  private state;
235
235
  /** Context manager for overflow detection and compaction */
236
236
  private contextManager;
@@ -254,6 +254,8 @@ declare class Agent {
254
254
  private interventionCtrl;
255
255
  /** Execution environment for tool operations */
256
256
  private host;
257
+ /** Whether the agent owns the host and can safely recreate it on cwd changes */
258
+ private ownsHost;
257
259
  /** Middleware runner for lifecycle hooks */
258
260
  private middlewareRunner;
259
261
  /** AI SDK telemetry settings (auto-created from `tracing` config) */
@@ -262,6 +264,12 @@ declare class Agent {
262
264
  private tracingShutdown?;
263
265
  /** Multi-consumer event dispatch */
264
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;
265
273
  constructor(config: AgentConstructionOptions);
266
274
  /**
267
275
  * Event signal — subscribe to events without consuming the generator.
@@ -301,6 +309,15 @@ declare class Agent {
301
309
  * Lazy initialization — resolves the registry and adds tools on first use.
302
310
  */
303
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;
304
321
  /**
305
322
  * Ensure MCP is connected and return tools
306
323
  * Lazy initialization - only connects on first use
@@ -341,10 +358,6 @@ declare class Agent {
341
358
  abort?: AbortSignal;
342
359
  system?: string;
343
360
  }): AsyncGenerator<AgentEvent>;
344
- /**
345
- * Ensure a session is loaded or created
346
- */
347
- private ensureSession;
348
361
  /**
349
362
  * Send a message and wait for the complete response (non-streaming).
350
363
  *
@@ -451,6 +464,8 @@ declare class Agent {
451
464
  *
452
465
  * If called when no turn is active, the message will be picked up
453
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.
454
469
  *
455
470
  * @param message - The user message to inject mid-turn
456
471
  * @returns Intervention ID for tracking
@@ -480,6 +495,9 @@ declare class Agent {
480
495
  * `chat()` finishes. The consumer decides whether to send it as a
481
496
  * new turn.
482
497
  *
498
+ * If multiple turns are active concurrently, this throws because the
499
+ * target turn would be ambiguous.
500
+ *
483
501
  * @param message - The message to queue
484
502
  * @returns Intervention ID for tracking
485
503
  *
@@ -1055,4 +1073,263 @@ declare class SubAgentTracker {
1055
1073
  */
1056
1074
  declare function createSubAgentTools(parent: Agent, config: SubAgentToolConfig): Tool.AnyInfo[];
1057
1075
 
1058
- export { type AgentConfig as A, type CompactionConfig as C, DEFAULT_MAX_CONCURRENT as D, PRUNE_PROTECTED_TOOLS as P, type SubAgentCompletedResult as S, type TracingConfig as T, Agent as a, type AgentProfile as b, DEFAULT_MAX_SPAWN_DEPTH as c, DEFAULT_SESSION_TITLE_PREFIX as d, type SubAgentHandle as e, type SubAgentStatus as f, type SubAgentToolConfig as g, SubAgentTracker as h, type SubAgentUsage as i, createAgent as j, createSubAgentTools as k };
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 };
package/dist/index.d.ts CHANGED
@@ -1,40 +1,40 @@
1
- import { A as AgentConfig, a as Agent } from './index-CWSchSql.js';
2
- export { b as AgentProfile, C as CompactionConfig, D as DEFAULT_MAX_CONCURRENT, c as DEFAULT_MAX_SPAWN_DEPTH, d as DEFAULT_SESSION_TITLE_PREFIX, P as PRUNE_PROTECTED_TOOLS, S as SubAgentCompletedResult, e as SubAgentHandle, f as SubAgentStatus, g as SubAgentToolConfig, h as SubAgentTracker, i as SubAgentUsage, T as TracingConfig, j as createAgent, k as createSubAgentTools } from './index-CWSchSql.js';
1
+ import { A as AgentConfig, a as Agent } from './index-DQuTZ8xL.js';
2
+ export { b as AgentDiscoveryOptions, c as AgentDiscoveryResult, d as AgentProfile, e as AgentSource, C as CompactionConfig, 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, P as PRUNE_PROTECTED_TOOLS, 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, r as TracingConfig, s as createAgent, 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';
3
3
  import { LanguageModel, Tool as Tool$1, TelemetrySettings, ModelMessage } from 'ai';
4
4
  import { M as Message, T as TokenUsage } from './messages-BYWGn8TY.js';
5
5
  export { A as AssistantMessage, a as MessageBase, b as MessageError, c as MessageRole, S as Session, d as SystemMessage, e as ToolMessage, U as UserMessage } from './messages-BYWGn8TY.js';
6
- import { T as Tool } from './tool-BHbyUAy3.js';
7
- export { C as CompatibleSchema, I as InferSchemaOutput, d as defineTool } from './tool-BHbyUAy3.js';
6
+ import { T as Tool } from './tool-CZWN3KbO.js';
7
+ export { C as CompatibleSchema, I as InferSchemaOutput, d as defineTool } from './tool-CZWN3KbO.js';
8
8
  import { T as ToolHost } from './types-CHiPh8U2.js';
9
9
  export { D as DirEntry, E as ExecOptions, a as ExecResult, F as FileStat } from './types-CHiPh8U2.js';
10
- import { M as MiddlewareRunner, d as StreamProvider, E as EnhancedTools } from './runner-e2YRcUoX.js';
11
- export { A as AgentMiddleware, f as AgentModelHooks, B as BlockedModelCall, g as EnvironmentInfo, I as InstructionFile, h as ModelCallContext, e as ModelCallInput, i as ModelCallOutput, c as ModelFamily, j as PluginCommand, k as PluginContext, l as PluginInit, a as PromptBuildContext, P as PromptConfig, b as PromptSection, S as StreamChunk, m as StreamProviderConfig, n as StreamProviderFactory, o as StreamProviderInput, p as StreamProviderResult, T as ToolCallDecision } from './runner-e2YRcUoX.js';
12
- import { g as InterventionController } from './types-KKDrdU9Y.js';
13
- export { A as AnyInferenceResult, a as AnyStreamResult, C as CustomStreamProvider, b as CustomStreamResult, D as DEFAULT_MAX_OUTPUT_TOKENS, h as DEFAULT_RETRY_CONFIG, c as InferenceCustomResult, d as InferenceStepInfo, I as InferenceStreamInput, e as InferenceStreamResult, L as LLMStreamInput, f as LLMStreamResult, O as OUTPUT_TOKEN_MAX, i as OnInterventionApplied, P as PendingIntervention, R as RetryConfig, j as RetryHandlerOptions, k as RetryState, S as StepInfo, T as ToolExecutionMode, l as calculateDelay, m as createRetryHandler, n as createRetryState, s as shouldRetry, o as sleep, w as withRetry } from './types-KKDrdU9Y.js';
10
+ import { M as MiddlewareRunner } from './runner-CI-XeR16.js';
11
+ import { n as InterventionController } from './types-BlOKk-Bb.js';
12
+ export { A as AnyInferenceResult, a as AnyStreamResult, C as CustomStreamProvider, b as CustomStreamResult, D as DEFAULT_MAX_OUTPUT_TOKENS, c as DEFAULT_RETRY_CONFIG, d as InferenceCustomResult, e as InferenceStepInfo, I as InferenceStreamInput, f as InferenceStreamResult, L as LLMStreamInput, g as LLMStreamResult, O as OUTPUT_TOKEN_MAX, o as OnInterventionApplied, P as PendingIntervention, R as RetryConfig, h as RetryHandlerOptions, i as RetryState, S as StepInfo, T as ToolExecutionMode, j as calculateDelay, k as createRetryHandler, l as createRetryState, s as shouldRetry, m as sleep, w as withRetry } from './types-BlOKk-Bb.js';
14
13
  import { R as ReasoningLevel } from './types-CQaXbRsS.js';
15
14
  export { E as EXTENDED_LEVELS, F as FIXED_LEVELS, a as ReasoningConfig, S as STANDARD_LEVELS, s as shouldIncludeReasoningSummary } from './types-CQaXbRsS.js';
16
15
  import { ContextManager } from './context/index.js';
17
16
  export { ContextLimits, DEFAULT_CONTEXT_LIMITS, PruneContextOptions, PruneResult, SummarizationOptions, estimateConversationTokens, estimateMessageTokens, estimateTokens, findCutPoint, generateSummary, isContextOverflowing, pruneContext, pruneToolResults, shouldPruneContext } from './context/index.js';
18
17
  import { T as TurnChangeTracker } from './tracker-DClqYqTj.js';
19
18
  export { F as FileBaseline, a as TurnFileChange, b as TurnSummary, c as TurnTrackerConfig, U as UndoResult, d as createTurnTracker } from './tracker-DClqYqTj.js';
20
- import { P as PromptBuilder } from './builder-UpOWQMW3.js';
21
- export { c as createPromptBuilder } from './builder-UpOWQMW3.js';
22
- import { S as SessionManager } from './session-manager-B_CWGTsl.js';
23
- export { B as BranchEntry, C as CompactionEntry, a as ConfigChangeEntry, b as CreateSessionOptions, E as EntryBase, F as FileEntry, M as MessageEntry, c as MetadataEntry, d as STORAGE_VERSION, e as SerializedMessage, f as SessionContext, g as SessionEntry, h as SessionHeader, i as SessionInfo, j as SessionStorage } from './session-manager-B_CWGTsl.js';
19
+ import { P as PromptBuilder } from './builder-BgZ_j4Vs.js';
20
+ export { c as createPromptBuilder } from './builder-BgZ_j4Vs.js';
21
+ import { S as SessionManager } from './session-manager-KbYt2WUh.js';
22
+ export { B as BranchEntry, C as CompactionEntry, a as ConfigChangeEntry, b as CreateSessionOptions, E as EntryBase, F as FileEntry, M as MessageEntry, c as MetadataEntry, d as STORAGE_VERSION, e as SerializedMessage, f as SessionContext, g as SessionEntry, h as SessionHeader, i as SessionInfo, j as SessionStorage } from './session-manager-KbYt2WUh.js';
24
23
  import { A as AgentEvent } from './events-CE72w8W4.js';
25
24
  export { a as AgentStatus, b as AgentTurnBoundaryKind, c as ApprovalEvent, P as ProcessorResult, S as StepProcessingResult, d as StreamInput } from './events-CE72w8W4.js';
26
- export { A as AgentTurnActiveToolCall, a as AgentTurnBoundaryMetadata, b as AgentTurnBoundarySnapshot, c as AgentTurnCommitApplier, d as AgentTurnCommitBatch, e as AgentTurnCommitOptions, f as AgentTurnEngine, g as AgentTurnEngineOptions, h as AgentTurnPhase, i as AgentTurnResolvedToolCall, j as AgentTurnState, k as AgentTurnStateAdvanceOptions, l as AgentTurnStepCommitSnapshot, m as AgentTurnStepCommitToolCall, n as AgentTurnStepCommitToolResult, o as AgentTurnStepRuntimeConfig, C as CommitOutputOptions, p as CommitStepOptions, q as CreateAgentTurnStateOptions, r as CreateAgentTurnStepCommitBatchOptions, D as DoomLoopAction, s as DoomLoopHandler, t as DoomLoopRequest, P as PrepareModelStepOptions, u as PreparedAgentModelStep, v as ProcessorOptions, w as ProcessorOutput, R as RunModelStepOptions, x as RunToolBatchOptions, y as RunToolBatchResult, S as StepProcessingOptions, z as StepProcessingOutput, B as advanceAgentTurnState, E as createAgentTurnEngine, F as createAgentTurnState, G as failAgentTurnState } from './types-QKHHQLLq.js';
25
+ import { f as StreamProvider, E as EnhancedTools } from './types-DTSkxakL.js';
26
+ export { A as AgentMiddleware, g as AgentModelHooks, B as BlockedModelCall, h as EnvironmentInfo, I as InstructionFile, a as ModelCallContext, M as ModelCallInput, b as ModelCallOutput, e as ModelFamily, P as PromptBuildContext, d as PromptConfig, c as PromptSection, S as StreamChunk, i as StreamProviderConfig, j as StreamProviderFactory, k as StreamProviderInput, l as StreamProviderResult, T as ToolCallDecision } from './types-DTSkxakL.js';
27
+ export { A as AgentTurnActiveToolCall, a as AgentTurnBoundaryMetadata, b as AgentTurnBoundarySnapshot, c as AgentTurnCommitApplier, d as AgentTurnCommitBatch, e as AgentTurnCommitOptions, f as AgentTurnEngine, g as AgentTurnEngineOptions, h as AgentTurnPhase, i as AgentTurnResolvedToolCall, j as AgentTurnState, k as AgentTurnStateAdvanceOptions, l as AgentTurnStepCommitSnapshot, m as AgentTurnStepCommitToolCall, n as AgentTurnStepCommitToolResult, o as AgentTurnStepRuntimeConfig, C as CommitOutputOptions, p as CommitStepOptions, q as CreateAgentTurnStateOptions, r as CreateAgentTurnStepCommitBatchOptions, D as DoomLoopAction, s as DoomLoopHandler, t as DoomLoopRequest, P as PrepareModelStepOptions, u as PreparedAgentModelStep, v as ProcessorOptions, w as ProcessorOutput, R as RunModelStepOptions, x as RunToolBatchOptions, y as RunToolBatchResult, S as StepProcessingOptions, z as StepProcessingOutput, B as advanceAgentTurnState, E as createAgentTurnEngine, F as createAgentTurnState, G as failAgentTurnState } from './types-DmDwi2zI.js';
27
28
  export { ExecuteAgentToolCallOptions, ExecuteAgentToolCallResult, MAX_BYTES, MAX_LINES, TRUNCATE_DIR, TRUNCATE_GLOB, ToolRegistry, ToolSpec, TruncateResult, defaultRegistry, executeAgentToolCall, formatSize, normalizeToolReplayPolicy, truncateOutput } from './tool/index.js';
28
- export { AdapterSettings, CacheCapabilitySource, CapabilityCache, CapabilityOverrides, Directory, EngineSpec, ModelCapabilityResolver, Directory as ModelDirectory, Resolver as ModelResolver, ModelSpec, NetworkStatus, PatternCapabilitySource, RemoteCapabilityFetcher, RemoteCapabilitySource, ResolutionResult, Resolver, SyncResolver, applyCapabilityOverride, configureResolver, createResolver, extractModelId, extractProvider, findCapabilityOverride, getDefaultResolver, getModelId, getNetworkStatus, getProviderCompatibility, getProviderId, inferContextWindow, inferProvider, likelySupportsReasoning } from './models/index.js';
29
- export { C as CapabilitySource, D as DEFAULT_RESOLVER_OPTIONS, I as InputModality, M as ModelCapabilities, a as ModelEntry, O as OutputModality, P as ProviderCompatibility, R as ResolverOptions, S as SourcePriority, b as SourceResult } from './types-QA4WhEfz.js';
29
+ export { AdapterSettings, CacheCapabilitySource, CapabilityCache, CapabilityOverrides, Directory, EngineSpec, ModelCapabilityResolver, Directory as ModelDirectory, Resolver as ModelResolver, ModelSpec, NetworkStatus, PatternCapabilitySource, RemoteCapabilityFetcher, RemoteCapabilitySource, ResolutionResult, Resolver, applyCapabilityOverride, configureResolver, createResolver, extractModelId, extractProvider, findCapabilityOverride, getDefaultResolver, getModelId, getNetworkStatus, getProviderCompatibility, getProviderId, inferContextWindow, inferProvider, likelySupportsReasoning } from './models/index.js';
30
+ export { C as CapabilitySource, D as DEFAULT_RESOLVER_OPTIONS, I as InputModality, M as ModelCapabilities, a as ModelEntry, O as OutputModality, P as ProviderCompatibility, R as ResolverOptions, S as SourcePriority, b as SourceResult, c as buildAnthropicOptions, d as buildBedrockOptions, e as buildGoogleOptions, f as buildGroqOptions, g as buildOpenAIOptions, h as buildOpenRouterOptions, i as buildReasoningOptions, j as buildReasoningOptionsSync, k as buildXAIOptions, l as getProviderOptionsKey, m as getReasoningConfig, n as getReasoningConfigSync, s as supportsReasoning, o as supportsReasoningSync } from './index-BCqEGzBj.js';
30
31
  export { H as HttpTransportConfig, M as MCPConfig, a as MCPManager, b as MCPPrompt, c as MCPResource, d as MCPServerConfig, e as MCPServerStatus, S as SseTransportConfig, f as StdioTransportConfig } from './types-VQgymC1N.js';
31
32
  export { createMCPManager, defineServer, httpServer, sseServer, stdioServer } from './mcp/index.js';
32
33
  export { AgentTaskChatAdapter, AgentTaskCheckpointReason, AgentTaskCheckpointStrategy, AgentTaskCheckpointStrategyInput, AgentTaskExecutionCheckpoint, AgentTaskExecutionContext, AgentTaskExecutionRun, AgentTaskExecutionSnapshot, AgentTaskObserver, AgentTaskPayload, AgentTaskResult, AgentTaskRunner, AgentTaskRunnerOptions, AgentWorkflowAssistantMessageSnapshot, AgentWorkflowCommitResult, AgentWorkflowMessageSnapshot, AgentWorkflowModelStepPlan, AgentWorkflowModelStepResult, AgentWorkflowOperationPlan, AgentWorkflowOutputCommitPlan, AgentWorkflowReplayDecision, AgentWorkflowStepCommitPlan, AgentWorkflowSystemMessageSnapshot, AgentWorkflowToolBatchResult, AgentWorkflowToolCallPlan, AgentWorkflowToolCallResult, AgentWorkflowToolCallSnapshot, AgentWorkflowToolMessageSnapshot, AgentWorkflowTurnPhase, AgentWorkflowTurnState, AgentWorkflowUserMessageSnapshot, ContextOverflowError, CreateAgentWorkflowTurnStateOptions, DoomLoopError, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, cloneAgentWorkflowTurnState, commitOutput, commitStep, convertAgentMessagesToModelMessages, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, processStepStream, processStream, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages } from './runtime/index.js';
33
34
  export { ApprovalMiddlewareConfig, CacheTTL, OtelMiddlewareConfig, PromptCacheConfig, TelemetryConfig, TelemetryConfigResult, approvalMiddleware, createTelemetryConfig, otelMiddleware, promptCacheMiddleware } from './middleware/index.js';
34
35
  export { DEFAULT_INSTRUCTION_PATTERNS, DEFAULT_MAX_DEPTH, DEFAULT_MAX_FILE_SIZE, PRIORITY_BASE, PRIORITY_CUSTOM, PRIORITY_ENVIRONMENT, PRIORITY_INSTRUCTIONS, PRIORITY_OVERRIDE, PRIORITY_SKILLS, detectModelFamily, discoverInstructions, formatEnvironment, formatInstructions, gatherEnvironment, getAvailableFamilies, getTemplate, loadGlobalInstructions, summarizeEnvironment } from './prompt/index.js';
35
36
  export { R as RemoteSkillEntry, e as RemoteSkillIndex, d as SkillConfig, b as SkillContent, f as SkillDiscoveryError, S as SkillDiscoveryResult, a as SkillMetadata, c as SkillResource, g as SkillResourceType, h as SkillScope, i as SkillSource, j as SkillSourceType } from './types-BfNpU8NS.js';
36
- export { buildAnthropicOptions, buildBedrockOptions, buildGoogleOptions, buildGroqOptions, buildOpenAIOptions, buildOpenRouterOptions, buildReasoningOptions, buildReasoningOptionsSync, buildXAIOptions, getProviderOptionsKey, getReasoningConfig, getReasoningConfigSync, supportsReasoning, supportsReasoningSync } from './reasoning/index.js';
37
- export { A as AppliedPreset, P as Preset } from './types-BnpEOYV-.js';
37
+ export { A as AppliedPreset, P as Preset } from './types-BlZwmnuW.js';
38
38
  export { Presets, applyPreset, careful, code, createPreset, explore, filterTools, mergePresets, plan, quick, review, watch } from './presets/index.js';
39
39
  export { DockerHostOptions, dockerHost, localHost } from './host/index.js';
40
40
  export { a as Scope, b as ScopeAttributeValue, c as ScopeAttributes, d as ScopeKind, e as ScopeOptions, S as ScopeSnapshot } from './types-CQL-SvTn.js';
@@ -45,14 +45,16 @@ export { ChangeSet, Checkpoint, CheckpointConfig, CheckpointManager, FileChange,
45
45
  export { A as ApprovalAction, a as ApprovalConfig, b as ApprovalRequest, c as ApprovalRule, R as RiskLevel } from './types-CWm-7rvB.js';
46
46
  export { ApprovalDeniedError, ApprovalHandler, ApprovalTimeoutError, createApprovalHandler, getToolRisk } from './safety/index.js';
47
47
  export { E as ErrorCategory, L as LLMError, a as LLMErrorOptions, R as ResponseHeaders } from './llm-error-D93FNNLY.js';
48
- export { getErrorCategory, getRetryDelay, isRetryable, isRetryableCategory, parseRetryDelay } from './errors/index.js';
48
+ export { getErrorCategory, getRetryDelay, isRetryable, isRetryableCategory, parseRetryDelay } from './inference/errors/index.js';
49
49
  export { DEFAULT_EXTERNAL_DIRS, DEFAULT_MAX_SCAN_DEPTH, DEFAULT_SKILL_MAX_SIZE, SKILL_FILENAME, createSkillResourceTool, createSkillTool, createSkillTools, discoverSkills, inferResourceType, loadResourceContent, loadSkillContent, loadSkillMetadata, parseFrontmatter } from './skill/index.js';
50
50
  export { S as SkillRegistry, c as createSkillRegistry, e as emptySkillRegistry } from './registry-DwYqsQkX.js';
51
51
  export { A as AgentSignal, E as EventOf, T as TypedHandler, U as Unsubscribe, W as WildcardHandler } from './types-YuWV4ag7.js';
52
52
  export { LocalSignal } from './signal/index.js';
53
- export { F as FileOperationMeta, N as NormalizedToolReplayPolicy, b as ToolContext, T as ToolMetadata, e as ToolReplayMode, a as ToolReplayPolicy, c as ToolResult, f as ToolSideEffectLevel, d as TurnTrackerContext } from './tool-DLXAR9Ce.js';
53
+ export { DefinePluginInit, DiscoveredPlugin, LayeredSettings, NullSettings, PluginActivateContext, PluginCommand, PluginCompatibility, PluginContext, PluginContributions, PluginDefinition, PluginEventBus, PluginEventBusAPI, PluginEventHandler, PluginInit, PluginLifecycleHooks, PluginLoaderOptions, PluginManifest, PluginRegistry, PluginRegistryCompatibilityOptions, PluginRegistryOptions, PluginRegistryTimeoutOptions, PluginSessionContext, PluginSettingsDefinition, PluginSettingsProvider, PluginSettingsSchema, PluginUnsubscribe, StaticSettings, ValidatedSettings, definePlugin, discoverPlugins, getPluginLoader, isDefinedPlugin, loadPluginModule, resetFrameworkAliases, resetPluginLoader, resolveFrameworkAliases } from './plugin/index.js';
54
+ export { F as FileOperationMeta, N as NormalizedToolReplayPolicy, T as ToolContext, a as ToolMetadata, e as ToolReplayMode, b as ToolReplayPolicy, c as ToolResult, f as ToolSideEffectLevel, d as TurnTrackerContext } from './tool-DkhSCV2Y.js';
54
55
  import 'zod';
55
56
  import '@ai-sdk/provider-utils';
57
+ import 'jiti';
56
58
 
57
59
  /**
58
60
  * Mutable runtime state held by an `Agent` instance.
@@ -122,16 +124,8 @@ interface SubAgentResult {
122
124
  * Useful for parallelizing independent research or analysis tasks.
123
125
  * Results are returned in the same order as tasks.
124
126
  *
125
- * **IMPORTANT: Concurrency Considerations**
126
- *
127
- * When multiple tasks use the same `Agent` instance, they share the same
128
- * `SessionManager`. To avoid state conflicts:
129
- *
130
- * 1. Use distinct `parentSessionId` values for each task
131
- * 2. Or create separate `Agent` instances via `agent.fork()` for each task
132
- * 3. Or ensure tasks use unique session IDs (auto-generated if not specified)
133
- *
134
- * Tasks modifying the same session concurrently may cause race conditions.
127
+ * Distinct sub-agent sessions can run in parallel safely. Turns targeting the
128
+ * same session are serialized to preserve history order.
135
129
  *
136
130
  * @example
137
131
  * ```typescript