@cuylabs/agent-core 0.7.0 → 0.8.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 (58) hide show
  1. package/dist/{builder-BRvqCcIk.d.ts → builder-UpOWQMW3.d.ts} +2 -2
  2. package/dist/{chunk-3HNO5SVI.js → chunk-4BDA7DQY.js} +3 -3
  3. package/dist/chunk-BFM2YHNM.js +222 -0
  4. package/dist/chunk-CAA7FHIH.js +280 -0
  5. package/dist/chunk-DWYX7ASF.js +26 -0
  6. package/dist/chunk-KUVSERLJ.js +50 -0
  7. package/dist/{chunk-5K7AQVOU.js → chunk-N6HWIEEA.js} +8 -204
  8. package/dist/{chunk-QGOGIP7T.js → chunk-RFEKJKTO.js} +131 -25
  9. package/dist/chunk-RZITT45F.js +202 -0
  10. package/dist/{chunk-ZPMACVZK.js → chunk-SQU2AJHO.js} +1 -1
  11. package/dist/{chunk-BNSHUWCV.js → chunk-WWYYNWEW.js} +1 -1
  12. package/dist/{chunk-CDTV2UYU.js → chunk-YSLSEQ6B.js} +52 -252
  13. package/dist/context/index.js +1 -1
  14. package/dist/errors/index.d.ts +11 -0
  15. package/dist/errors/index.js +16 -0
  16. package/dist/events-CE72w8W4.d.ts +149 -0
  17. package/dist/{index-C33hlD6H.d.ts → index-CWSchSql.d.ts} +36 -50
  18. package/dist/index.d.ts +36 -109
  19. package/dist/index.js +213 -396
  20. package/dist/inference/index.d.ts +10 -7
  21. package/dist/inference/index.js +7 -5
  22. package/dist/llm-error-D93FNNLY.d.ts +32 -0
  23. package/dist/middleware/index.d.ts +245 -7
  24. package/dist/middleware/index.js +3 -1
  25. package/dist/models/index.d.ts +125 -4
  26. package/dist/models/index.js +7 -3
  27. package/dist/presets/index.d.ts +53 -0
  28. package/dist/presets/index.js +28 -0
  29. package/dist/prompt/index.d.ts +10 -8
  30. package/dist/reasoning/index.d.ts +1 -2
  31. package/dist/reasoning/index.js +3 -7
  32. package/dist/{registry-BDLIHOQB.d.ts → registry-DwYqsQkX.d.ts} +1 -1
  33. package/dist/{runner-DSKaEz3z.d.ts → runner-e2YRcUoX.d.ts} +58 -151
  34. package/dist/runtime/index.d.ts +11 -8
  35. package/dist/runtime/index.js +9 -7
  36. package/dist/safety/index.d.ts +38 -0
  37. package/dist/safety/index.js +12 -0
  38. package/dist/scope/index.d.ts +2 -2
  39. package/dist/signal/index.d.ts +28 -0
  40. package/dist/signal/index.js +6 -0
  41. package/dist/skill/index.d.ts +7 -6
  42. package/dist/sub-agent/index.d.ts +14 -9
  43. package/dist/tool/index.d.ts +7 -5
  44. package/dist/tool/index.js +2 -2
  45. package/dist/tool-BHbyUAy3.d.ts +150 -0
  46. package/dist/{tool-HUtkiVBx.d.ts → tool-DLXAR9Ce.d.ts} +1 -1
  47. package/dist/tracking/index.d.ts +2 -2
  48. package/dist/{tool-Db1Ue-1U.d.ts → types-BfNpU8NS.d.ts} +1 -150
  49. package/dist/types-BnpEOYV-.d.ts +50 -0
  50. package/dist/{types-9jGQUjqW.d.ts → types-CQL-SvTn.d.ts} +1 -1
  51. package/dist/types-CWm-7rvB.d.ts +55 -0
  52. package/dist/{types-FRpzzg_9.d.ts → types-KKDrdU9Y.d.ts} +5 -35
  53. package/dist/{capability-resolver-CgRGsWVX.d.ts → types-QA4WhEfz.d.ts} +1 -117
  54. package/dist/{types-CqDZTh4d.d.ts → types-QKHHQLLq.d.ts} +5 -4
  55. package/dist/types-YuWV4ag7.d.ts +72 -0
  56. package/package.json +58 -3
  57. package/dist/index-CfBGYrpd.d.ts +0 -317
  58. package/dist/{chunk-IEFIQENH.js → chunk-7VKQ4WPB.js} +4 -4
@@ -1,3 +1,11 @@
1
+ import {
2
+ createApprovalHandler
3
+ } from "./chunk-BFM2YHNM.js";
4
+ import {
5
+ getModelId,
6
+ getProviderId
7
+ } from "./chunk-DWYX7ASF.js";
8
+
1
9
  // src/middleware/runner.ts
2
10
  function isBlockedModelCall(value) {
3
11
  return "block" in value && value.block === true;
@@ -249,221 +257,6 @@ var MiddlewareRunner = class {
249
257
  }
250
258
  };
251
259
 
252
- // src/safety/approval/risk.ts
253
- var DEFAULT_TOOL_RISKS = {
254
- read: "safe",
255
- read_file: "safe",
256
- grep: "safe",
257
- glob: "safe",
258
- list_dir: "safe",
259
- invoke_agent: "safe",
260
- wait_agent: "safe",
261
- close_agent: "safe",
262
- skill: "safe",
263
- skill_resource: "safe",
264
- write: "moderate",
265
- write_file: "moderate",
266
- edit: "moderate",
267
- edit_file: "moderate",
268
- create_file: "moderate",
269
- bash: "dangerous",
270
- shell: "dangerous",
271
- delete_file: "dangerous",
272
- remove: "dangerous"
273
- };
274
- function getToolRisk(tool, customRisks) {
275
- if (customRisks?.[tool]) {
276
- return customRisks[tool];
277
- }
278
- if (DEFAULT_TOOL_RISKS[tool]) {
279
- return DEFAULT_TOOL_RISKS[tool];
280
- }
281
- return "moderate";
282
- }
283
-
284
- // src/safety/approval/errors.ts
285
- var ApprovalDeniedError = class extends Error {
286
- constructor(tool, args, message) {
287
- super(message || `Operation denied: ${tool}`);
288
- this.tool = tool;
289
- this.args = args;
290
- this.name = "ApprovalDeniedError";
291
- }
292
- };
293
- var ApprovalTimeoutError = class extends Error {
294
- constructor(tool, timeoutMs) {
295
- super(`Approval timeout after ${timeoutMs}ms for: ${tool}`);
296
- this.tool = tool;
297
- this.timeoutMs = timeoutMs;
298
- this.name = "ApprovalTimeoutError";
299
- }
300
- };
301
-
302
- // src/safety/approval/patterns.ts
303
- function matchApprovalPattern(pattern, value) {
304
- const regex = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
305
- return new RegExp(`^${regex}$`, "i").test(value);
306
- }
307
- function extractApprovalPatterns(tool, args) {
308
- if (!args || typeof args !== "object") {
309
- return [tool];
310
- }
311
- const record = args;
312
- if ("path" in record && typeof record.path === "string" || "filePath" in record && typeof record.filePath === "string") {
313
- const path = record.path ?? record.filePath;
314
- const dir = path.substring(0, path.lastIndexOf("/") + 1);
315
- return [dir ? `${dir}*` : path];
316
- }
317
- if ("command" in record && typeof record.command === "string") {
318
- const command = record.command.split(/\s+/)[0];
319
- return [command];
320
- }
321
- if ("pattern" in record && typeof record.pattern === "string") {
322
- return [record.pattern];
323
- }
324
- return [tool];
325
- }
326
- function describeApprovalOperation(tool, args) {
327
- if (!args || typeof args !== "object") {
328
- return `Execute ${tool}`;
329
- }
330
- const record = args;
331
- switch (tool) {
332
- case "read":
333
- case "read_file":
334
- return `Read file: ${record.path ?? record.filePath}`;
335
- case "write":
336
- case "write_file":
337
- case "create_file":
338
- return `Write file: ${record.path ?? record.filePath}`;
339
- case "edit":
340
- case "edit_file":
341
- return `Edit file: ${record.path ?? record.filePath}`;
342
- case "delete_file":
343
- case "remove":
344
- return `Delete: ${record.path}`;
345
- case "bash":
346
- case "shell": {
347
- const command = String(record.command);
348
- return `Run command: ${command.slice(0, 100)}${command.length > 100 ? "..." : ""}`;
349
- }
350
- case "grep":
351
- return `Search for: ${record.pattern}`;
352
- case "glob":
353
- return `Find files: ${record.pattern}`;
354
- default:
355
- return `${tool}(${JSON.stringify(args).slice(0, 50)}...)`;
356
- }
357
- }
358
-
359
- // src/safety/approval/handler.ts
360
- var requestCounter = 0;
361
- function findMatchingRule(rules, tool, patterns) {
362
- for (let index = rules.length - 1; index >= 0; index--) {
363
- const rule = rules[index];
364
- const toolMatches = rule.tool === "*" || matchApprovalPattern(rule.tool, tool);
365
- const patternMatches = patterns.some(
366
- (pattern) => matchApprovalPattern(rule.pattern, pattern)
367
- );
368
- if (toolMatches && patternMatches) {
369
- return rule;
370
- }
371
- }
372
- return void 0;
373
- }
374
- function createApprovalHandler(config = {}) {
375
- const {
376
- defaultAction = "ask",
377
- timeout = 5 * 60 * 1e3,
378
- onRequest
379
- } = config;
380
- const rules = [...config.rules ?? []];
381
- const pending = /* @__PURE__ */ new Map();
382
- async function request(sessionId, tool, args, customRisks) {
383
- const risk = getToolRisk(tool, customRisks);
384
- const patterns = extractApprovalPatterns(tool, args);
385
- const matchingRule = findMatchingRule(rules, tool, patterns);
386
- if (matchingRule) {
387
- if (matchingRule.action === "allow") {
388
- return;
389
- }
390
- throw new ApprovalDeniedError(
391
- tool,
392
- args,
393
- `Denied by rule: ${matchingRule.pattern}`
394
- );
395
- }
396
- if (risk === "safe" && defaultAction !== "deny") {
397
- return;
398
- }
399
- if (!onRequest) {
400
- if (defaultAction === "allow") {
401
- return;
402
- }
403
- if (defaultAction === "deny") {
404
- throw new ApprovalDeniedError(tool, args);
405
- }
406
- throw new ApprovalDeniedError(tool, args, "No approval handler configured");
407
- }
408
- const id = `approval-${++requestCounter}-${Date.now()}`;
409
- const requestData = {
410
- id,
411
- sessionId,
412
- tool,
413
- args,
414
- description: describeApprovalOperation(tool, args),
415
- risk,
416
- patterns,
417
- timestamp: Date.now()
418
- };
419
- const action = await Promise.race([
420
- new Promise((resolve, reject) => {
421
- pending.set(id, { resolve, reject });
422
- onRequest(requestData).then(resolve).catch(reject).finally(() => pending.delete(id));
423
- }),
424
- new Promise((_, reject) => {
425
- setTimeout(() => {
426
- pending.delete(id);
427
- reject(new ApprovalTimeoutError(tool, timeout));
428
- }, timeout);
429
- })
430
- ]);
431
- switch (action) {
432
- case "allow":
433
- return;
434
- case "deny":
435
- throw new ApprovalDeniedError(tool, args);
436
- case "remember":
437
- for (const pattern of patterns) {
438
- rules.push({ pattern, tool, action: "allow" });
439
- }
440
- return;
441
- }
442
- }
443
- function cancelAll(reason) {
444
- for (const [id, { reject }] of pending) {
445
- reject(new Error(reason ?? "Cancelled"));
446
- pending.delete(id);
447
- }
448
- }
449
- function addRule(rule) {
450
- rules.push(rule);
451
- }
452
- function getRules() {
453
- return rules;
454
- }
455
- function clearSessionRules() {
456
- rules.length = config.rules?.length ?? 0;
457
- }
458
- return {
459
- request,
460
- cancelAll,
461
- addRule,
462
- getRules,
463
- clearSessionRules
464
- };
465
- }
466
-
467
260
  // src/middleware/approval.ts
468
261
  function approvalMiddleware(config = {}) {
469
262
  const handler = createApprovalHandler(config);
@@ -753,28 +546,48 @@ async function createAndRegisterProvider(spanProcessor, serviceName) {
753
546
  }
754
547
 
755
548
  // src/middleware/prompt-cache/cache.ts
549
+ function detectCacheProvider(input) {
550
+ const provider = getProviderId(input.model);
551
+ if (provider) {
552
+ const p = provider.toLowerCase();
553
+ if (p === "anthropic") return "anthropic";
554
+ if (p === "openai") return "openai";
555
+ if (p === "google") return "google";
556
+ }
557
+ const modelId = getModelId(input.model);
558
+ if (/claude/i.test(modelId)) return "anthropic";
559
+ return "unknown";
560
+ }
756
561
  var MAX_ANTHROPIC_BREAKPOINTS = 4;
757
- var DEFAULT_TTL = "5m";
758
- var DEFAULT_MESSAGE_BREAKPOINTS = 1;
759
- function isAnthropicModel(model) {
760
- if (typeof model === "object" && model !== null) {
761
- if ("provider" in model && typeof model.provider === "string") {
762
- if (model.provider.toLowerCase().startsWith("anthropic")) return true;
763
- }
764
- if ("modelId" in model && typeof model.modelId === "string") {
765
- if (/claude/i.test(model.modelId)) return true;
562
+ function applyAnthropicCache(input, ttl, maxMsgBreakpoints) {
563
+ const hasSystem = input.system.some((s) => s.length > 0);
564
+ if (hasSystem) {
565
+ input.systemMessages = buildAnthropicSystemMessages(input.system, ttl);
566
+ }
567
+ if (maxMsgBreakpoints > 0) {
568
+ const breakpointIndices = findMessageBreakpointIndices(
569
+ input.messages,
570
+ maxMsgBreakpoints
571
+ );
572
+ const cacheControl = buildAnthropicCacheControl(ttl);
573
+ for (const idx of breakpointIndices) {
574
+ const msg = input.messages[idx];
575
+ msg.providerOptions = {
576
+ ...msg.providerOptions,
577
+ ...cacheControl
578
+ };
766
579
  }
767
580
  }
768
- return false;
581
+ return input;
769
582
  }
770
- function buildCacheControl(ttl) {
583
+ function buildAnthropicCacheControl(ttl) {
771
584
  return {
772
585
  anthropic: {
773
586
  cacheControl: { type: "ephemeral", ttl }
774
587
  }
775
588
  };
776
589
  }
777
- function buildCachedSystemMessages(system, ttl) {
590
+ function buildAnthropicSystemMessages(system, ttl) {
778
591
  const filtered = system.filter(Boolean);
779
592
  if (filtered.length === 0) return [];
780
593
  return filtered.map((content, i) => {
@@ -784,7 +597,7 @@ function buildCachedSystemMessages(system, ttl) {
784
597
  content
785
598
  };
786
599
  if (isLast) {
787
- msg.providerOptions = buildCacheControl(ttl);
600
+ msg.providerOptions = buildAnthropicCacheControl(ttl);
788
601
  }
789
602
  return msg;
790
603
  });
@@ -800,37 +613,28 @@ function findMessageBreakpointIndices(messages, count) {
800
613
  }
801
614
  return indices;
802
615
  }
616
+ var DEFAULT_TTL = "5m";
617
+ var DEFAULT_MESSAGE_BREAKPOINTS = 1;
803
618
  function promptCacheMiddleware(config) {
804
619
  const ttl = config?.ttl ?? DEFAULT_TTL;
805
620
  const maxMsgBreakpoints = Math.min(
806
621
  config?.messageBreakpoints ?? DEFAULT_MESSAGE_BREAKPOINTS,
807
622
  MAX_ANTHROPIC_BREAKPOINTS - 1
808
- // Reserve 1 for system
809
623
  );
810
624
  return {
811
625
  name: "prompt-cache",
812
626
  model: {
813
627
  async input(input, _ctx) {
814
- if (!isAnthropicModel(input.model)) return;
815
- const hasSystem = input.system.some((s) => s.length > 0);
816
- if (hasSystem) {
817
- input.systemMessages = buildCachedSystemMessages(input.system, ttl);
818
- }
819
- if (maxMsgBreakpoints > 0) {
820
- const breakpointIndices = findMessageBreakpointIndices(
821
- input.messages,
822
- maxMsgBreakpoints
823
- );
824
- const cacheControl = buildCacheControl(ttl);
825
- for (const idx of breakpointIndices) {
826
- const msg = input.messages[idx];
827
- msg.providerOptions = {
828
- ...msg.providerOptions,
829
- ...cacheControl
830
- };
831
- }
628
+ const provider = detectCacheProvider(input);
629
+ switch (provider) {
630
+ case "anthropic":
631
+ return applyAnthropicCache(input, ttl, maxMsgBreakpoints);
632
+ // OpenAI caches prefixes automatically — no client action needed.
633
+ // case "openai":
634
+ // return applyOpenAICache(input);
635
+ default:
636
+ return;
832
637
  }
833
- return input;
834
638
  }
835
639
  }
836
640
  };
@@ -840,10 +644,6 @@ export {
840
644
  MiddlewareRunner,
841
645
  otelMiddleware,
842
646
  createTelemetryConfig,
843
- getToolRisk,
844
- ApprovalDeniedError,
845
- ApprovalTimeoutError,
846
- createApprovalHandler,
847
647
  approvalMiddleware,
848
648
  promptCacheMiddleware
849
649
  };
@@ -10,7 +10,7 @@ import {
10
10
  pruneContext,
11
11
  pruneToolResults,
12
12
  shouldPruneContext
13
- } from "../chunk-BNSHUWCV.js";
13
+ } from "../chunk-WWYYNWEW.js";
14
14
  export {
15
15
  ContextManager,
16
16
  DEFAULT_CONTEXT_LIMITS,
@@ -0,0 +1,11 @@
1
+ import { E as ErrorCategory, R as ResponseHeaders } from '../llm-error-D93FNNLY.js';
2
+ export { L as LLMError, a as LLMErrorOptions } from '../llm-error-D93FNNLY.js';
3
+
4
+ declare function isRetryableCategory(category: ErrorCategory): boolean;
5
+ declare function parseRetryDelay(headers: ResponseHeaders): number | undefined;
6
+
7
+ declare function isRetryable(error: unknown): boolean;
8
+ declare function getRetryDelay(error: unknown): number | undefined;
9
+ declare function getErrorCategory(error: unknown): ErrorCategory;
10
+
11
+ export { ErrorCategory, ResponseHeaders, getErrorCategory, getRetryDelay, isRetryable, isRetryableCategory, parseRetryDelay };
@@ -0,0 +1,16 @@
1
+ import {
2
+ LLMError,
3
+ getErrorCategory,
4
+ getRetryDelay,
5
+ isRetryable,
6
+ isRetryableCategory,
7
+ parseRetryDelay
8
+ } from "../chunk-RZITT45F.js";
9
+ export {
10
+ LLMError,
11
+ getErrorCategory,
12
+ getRetryDelay,
13
+ isRetryable,
14
+ isRetryableCategory,
15
+ parseRetryDelay
16
+ };
@@ -0,0 +1,149 @@
1
+ import * as ai from 'ai';
2
+ import { T as TokenUsage, M as Message } from './messages-BYWGn8TY.js';
3
+
4
+ /** Agent status for UI display */
5
+ type AgentStatus = "idle" | "processing" | "thinking" | "reasoning" | "calling-tool" | "waiting-approval" | "error";
6
+ /** Approval request for UI */
7
+ interface ApprovalEvent {
8
+ id: string;
9
+ tool: string;
10
+ args: unknown;
11
+ description: string;
12
+ risk: "safe" | "moderate" | "dangerous";
13
+ }
14
+ /** Neutral turn-commit boundaries for runtime/durability integrations */
15
+ type AgentTurnBoundaryKind = "input-commit-start" | "input-commit-finish" | "intervention-commit-start" | "intervention-commit-finish" | "step-commit-start" | "step-commit-finish" | "output-commit-start" | "output-commit-finish";
16
+ /**
17
+ * Events emitted during agent execution
18
+ *
19
+ * These events are designed for UI consumption:
20
+ * - status: Overall agent state for status indicators
21
+ * - approval-request: User confirmation needed
22
+ * - progress: Step counts for progress bars
23
+ */
24
+ type AgentEvent = {
25
+ type: "status";
26
+ status: AgentStatus;
27
+ } | {
28
+ type: "approval-request";
29
+ request: ApprovalEvent;
30
+ } | {
31
+ type: "approval-resolved";
32
+ id: string;
33
+ action: "allow" | "deny" | "remember";
34
+ } | {
35
+ type: "step-start";
36
+ step: number;
37
+ maxSteps: number;
38
+ } | {
39
+ type: "step-finish";
40
+ step: number;
41
+ usage?: TokenUsage;
42
+ finishReason?: string;
43
+ } | {
44
+ type: "turn-boundary";
45
+ boundary: AgentTurnBoundaryKind;
46
+ step?: number;
47
+ messageRole?: Message["role"];
48
+ pendingToolCallCount?: number;
49
+ } | {
50
+ type: "message";
51
+ message: Message;
52
+ } | {
53
+ type: "text-start";
54
+ } | {
55
+ type: "text-delta";
56
+ text: string;
57
+ } | {
58
+ type: "text-end";
59
+ } | {
60
+ type: "reasoning-start";
61
+ id: string;
62
+ } | {
63
+ type: "reasoning-delta";
64
+ id: string;
65
+ text: string;
66
+ } | {
67
+ type: "reasoning-end";
68
+ id: string;
69
+ } | {
70
+ type: "tool-start";
71
+ toolName: string;
72
+ toolCallId: string;
73
+ input: unknown;
74
+ } | {
75
+ type: "tool-result";
76
+ toolName: string;
77
+ toolCallId: string;
78
+ result: unknown;
79
+ } | {
80
+ type: "tool-error";
81
+ toolName: string;
82
+ toolCallId: string;
83
+ error: string;
84
+ } | {
85
+ type: "computer-call";
86
+ callId: string;
87
+ action: unknown;
88
+ pendingSafetyChecks?: unknown[];
89
+ } | {
90
+ type: "computer-result";
91
+ callId: string;
92
+ result: unknown;
93
+ } | {
94
+ type: "intervention-applied";
95
+ id: string;
96
+ message: string;
97
+ } | {
98
+ type: "doom-loop";
99
+ toolName: string;
100
+ repeatCount: number;
101
+ } | {
102
+ type: "context-overflow";
103
+ inputTokens: number;
104
+ limit: number;
105
+ } | {
106
+ type: "turn-summary";
107
+ turnId: string;
108
+ files: Array<{
109
+ path: string;
110
+ type: "created" | "modified" | "deleted" | "unchanged";
111
+ additions: number;
112
+ deletions: number;
113
+ }>;
114
+ additions: number;
115
+ deletions: number;
116
+ } | {
117
+ type: "retry";
118
+ attempt: number;
119
+ delayMs: number;
120
+ error: Error;
121
+ } | {
122
+ type: "error";
123
+ error: Error;
124
+ } | {
125
+ type: "complete";
126
+ usage?: TokenUsage;
127
+ output?: string;
128
+ };
129
+ /**
130
+ * Step-processing result - what happens after reducing one streamed step
131
+ */
132
+ type StepProcessingResult = "continue" | "stop" | "compact";
133
+ /**
134
+ * @deprecated Use `StepProcessingResult`.
135
+ */
136
+ type ProcessorResult = StepProcessingResult;
137
+ /**
138
+ * Stream input for model inference
139
+ */
140
+ interface StreamInput {
141
+ sessionID: string;
142
+ model: ai.LanguageModel;
143
+ system: string[];
144
+ messages: ai.ModelMessage[];
145
+ abort: AbortSignal;
146
+ tools: Record<string, unknown>;
147
+ }
148
+
149
+ export type { AgentEvent as A, ProcessorResult as P, StepProcessingResult as S, AgentStatus as a, AgentTurnBoundaryKind as b, ApprovalEvent as c, StreamInput as d };
@@ -1,15 +1,18 @@
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';
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
5
  import { S as SessionManager, f as SessionContext, i as SessionInfo } from './session-manager-B_CWGTsl.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-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
16
 
14
17
  /**
15
18
  * Tools whose outputs should never be pruned automatically.
@@ -156,51 +159,17 @@ interface AgentConfig {
156
159
  * Simplest way to enable tracing.
157
160
  */
158
161
  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
- /**
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
162
  /**
180
- * Override system prompt.
181
- * Use `{basePrompt}` to include the parent's system prompt.
163
+ * Event signal for multi-consumer dispatch.
164
+ *
165
+ * Every event yielded by `chat()` is also emitted here, enabling
166
+ * passive observers (SSE routes, TUI renderers, plugins) to
167
+ * subscribe without consuming the primary generator.
168
+ *
169
+ * Defaults to an in-process `LocalSignal`. A distributed runtime
170
+ * can supply its own implementation to bridge events externally.
182
171
  */
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;
172
+ signal?: AgentSignal;
204
173
  }
205
174
 
206
175
  interface AgentForkOptions {
@@ -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) */
@@ -289,7 +260,17 @@ declare class Agent {
289
260
  private telemetrySettings?;
290
261
  /** Tracing shutdown function (from `tracing` config auto-setup) */
291
262
  private tracingShutdown?;
263
+ /** Multi-consumer event dispatch */
264
+ private readonly _signal;
292
265
  constructor(config: AgentConstructionOptions);
266
+ /**
267
+ * Event signal — subscribe to events without consuming the generator.
268
+ *
269
+ * Every event yielded by `chat()` is also dispatched here, allowing
270
+ * multiple passive observers (SSE routes, TUI, plugins) to listen
271
+ * concurrently.
272
+ */
273
+ get signal(): AgentSignal;
293
274
  /** Agent name (identity for spans, Dapr workflows, etc.) */
294
275
  get name(): string;
295
276
  /** Working directory for file operations */
@@ -315,6 +296,11 @@ declare class Agent {
315
296
  * Check if current model supports reasoning
316
297
  */
317
298
  supportsReasoning(): boolean;
299
+ /**
300
+ * Ensure skill tools are registered when `prompt.skills` is configured.
301
+ * Lazy initialization — resolves the registry and adds tools on first use.
302
+ */
303
+ private ensureSkillTools;
318
304
  /**
319
305
  * Ensure MCP is connected and return tools
320
306
  * Lazy initialization - only connects on first use
@@ -1069,4 +1055,4 @@ declare class SubAgentTracker {
1069
1055
  */
1070
1056
  declare function createSubAgentTools(parent: Agent, config: SubAgentToolConfig): Tool.AnyInfo[];
1071
1057
 
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 };
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 };