@anvia/core 1.0.0-rc.9 → 1.0.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 (50) hide show
  1. package/README.md +99 -77
  2. package/dist/agent/index.d.ts +11 -16
  3. package/dist/agent/index.js +8 -8
  4. package/dist/{agent-XPQBM4rX.d.ts → agent-qRKa3ibC.d.ts} +11 -7
  5. package/dist/{chunk-PISJAAMX.js → chunk-3ZLM6OAZ.js} +318 -114
  6. package/dist/chunk-3ZLM6OAZ.js.map +1 -0
  7. package/dist/{chunk-WZVHZZW6.js → chunk-6BBOCFHV.js} +2 -2
  8. package/dist/{chunk-WTRGYFCD.js → chunk-7PHMK7W4.js} +4 -4
  9. package/dist/{chunk-X4LK4ODN.js → chunk-AHLKV6KP.js} +1 -1
  10. package/dist/chunk-AHLKV6KP.js.map +1 -0
  11. package/dist/chunk-J6LVLV6P.js +13 -0
  12. package/dist/chunk-J6LVLV6P.js.map +1 -0
  13. package/dist/{chunk-KIXN5DGS.js → chunk-LTXABCOO.js} +2 -2
  14. package/dist/{chunk-QOUPWOGW.js → chunk-SPD4XVR7.js} +1 -1
  15. package/dist/{chunk-TC4FILD3.js → chunk-YA7BMX7D.js} +51 -4
  16. package/dist/chunk-YA7BMX7D.js.map +1 -0
  17. package/dist/completion/index.js +2 -2
  18. package/dist/documents/index.js +26 -1
  19. package/dist/documents/index.js.map +1 -1
  20. package/dist/evals/index.d.ts +5 -5
  21. package/dist/evals/index.js +6 -6
  22. package/dist/evals/index.js.map +1 -1
  23. package/dist/extractor/index.js +3 -3
  24. package/dist/index.d.ts +7 -12
  25. package/dist/index.js +22 -20
  26. package/dist/internal/agent.d.ts +4 -9
  27. package/dist/internal/agent.js +8 -8
  28. package/dist/mcp/index.d.ts +3 -17
  29. package/dist/mcp/index.js +1 -15
  30. package/dist/memory/index.d.ts +6 -3
  31. package/dist/memory/index.js +6 -4
  32. package/dist/observability/index.d.ts +2 -2
  33. package/dist/observability/index.js +3 -3
  34. package/dist/pipeline/index.d.ts +6 -11
  35. package/dist/pipeline/index.js +6 -6
  36. package/dist/pipeline/index.js.map +1 -1
  37. package/dist/{types-Sue2hb_L.d.ts → types-CLCLFpAL.d.ts} +23 -15
  38. package/dist/{types-DKOXVTcq.d.ts → types-CSYt7-It.d.ts} +18 -3
  39. package/dist/types-DjqRHeAi.d.ts +31 -0
  40. package/package.json +10 -4
  41. package/dist/chunk-76JLMBVT.js +0 -716
  42. package/dist/chunk-76JLMBVT.js.map +0 -1
  43. package/dist/chunk-PISJAAMX.js.map +0 -1
  44. package/dist/chunk-TC4FILD3.js.map +0 -1
  45. package/dist/chunk-X4LK4ODN.js.map +0 -1
  46. package/dist/client-DTPl0hZv.d.ts +0 -84
  47. /package/dist/{chunk-WZVHZZW6.js.map → chunk-6BBOCFHV.js.map} +0 -0
  48. /package/dist/{chunk-WTRGYFCD.js.map → chunk-7PHMK7W4.js.map} +0 -0
  49. /package/dist/{chunk-KIXN5DGS.js.map → chunk-LTXABCOO.js.map} +0 -0
  50. /package/dist/{chunk-QOUPWOGW.js.map → chunk-SPD4XVR7.js.map} +0 -0
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ExtractionError,
3
3
  extract
4
- } from "../chunk-KIXN5DGS.js";
4
+ } from "../chunk-LTXABCOO.js";
5
5
  import "../chunk-D4PACGPA.js";
6
- import "../chunk-WTRGYFCD.js";
7
- import "../chunk-QGX73TSQ.js";
6
+ import "../chunk-7PHMK7W4.js";
8
7
  import "../chunk-7JLAIN6E.js";
8
+ import "../chunk-QGX73TSQ.js";
9
9
  import "../chunk-3XQGVDU5.js";
10
10
  import "../chunk-3RWESPUG.js";
11
11
  export {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { A as Agent, a as AgentContextInput, b as AgentMemory, c as AgentMemoryOptions, d as AgentOptions, e as AgentToolInput, f as AgentToolOptions, C as CreateHybridVectorContextOptions, g as CreateVectorContextOptions, V as VectorContext, h as VectorContextBaseOptions, i as createVectorContext, j as isVectorContext } from './agent-XPQBM4rX.js';
1
+ export { A as Agent, a as AgentContextInput, b as AgentMemory, c as AgentMemoryOptions, d as AgentOptions, e as AgentToolInput, f as AgentToolOptions, C as CreateHybridVectorContextOptions, g as CreateVectorContextOptions, V as VectorContext, h as VectorContextBaseOptions, i as createVectorContext, j as isVectorContext } from './agent-qRKa3ibC.js';
2
2
  export { AgentRunBlockedError, AgentRunCancelledError, AgentStreamClosedError, AgentStructuredOutputError, AgentStructuredOutputFormat, AgentStructuredOutputPhase, AgentToolSuspensionError, MaxTurnsError } from './agent/index.js';
3
- export { A as AgentBlockedResult, a as AgentChildStreamEvent, b as AgentDeltaEvent, c as AgentErrorEvent, d as AgentErrorStreamEvent, e as AgentFinishEvent, f as AgentInput, g as AgentLifecycle, h as AgentMemoryCompactionEvent, i as AgentPrompt, j as AgentResponse, k as AgentResult, l as AgentRunOptions, m as AgentRunSettings, n as AgentStartEvent, o as AgentSteerInput, p as AgentSteerReceipt, q as AgentStepFinishEvent, r as AgentStream, s as AgentStreamEvent, t as AgentSuspendedResult, u as AgentToolCallDeltaEvent, v as AgentToolFinishEvent, w as AgentToolStartEvent } from './types-Sue2hb_L.js';
3
+ export { A as AgentBlockedOutcome, a as AgentChildStreamEvent, b as AgentDeltaEvent, c as AgentErrorEvent, d as AgentErrorStreamEvent, e as AgentFinishEvent, f as AgentInput, g as AgentInteractionOutcome, h as AgentLifecycle, i as AgentMemoryCompactionEvent, j as AgentMemoryCompactionOptions, k as AgentOutcome, l as AgentPrompt, m as AgentResponse, n as AgentRunOptions, o as AgentRunSettings, p as AgentStartEvent, q as AgentSteerInput, r as AgentSteerReceipt, s as AgentStepFinishEvent, t as AgentStream, u as AgentStreamEvent, v as AgentToolCallDeltaEvent, w as AgentToolFinishEvent, x as AgentToolStartEvent } from './types-CLCLFpAL.js';
4
4
  export { M as ModelCallOptions } from './model-call-options-CZkSw_xN.js';
5
5
  export { R as RetryContext, a as RetryOptions, b as RetrySetting } from './retry-CjvSlKGW.js';
6
6
  export { A as AssistantContentPart, a as AssistantGenerationMetadata, b as AssistantMessage, C as CompletionFinishReason, c as CompletionModel, d as CompletionModelInfo, e as CompletionModelStreamEvent, f as CompletionRequest, g as CompletionResponse, h as CompletionResult, i as CompletionSource, j as CompletionStreamEvent, k as CompletionTool, l as ContextUsage, D as Document, F as FileData, m as FilePart, I as ImageDetail, n as ImagePart, J as JsonObject, o as JsonPrimitive, p as JsonValue, M as Message, q as ModelContextLimits, P as ProviderTool, r as ProviderToolCall, R as ReasoningContentType, s as ReasoningDetail, t as ReasoningPart, S as SystemMessage, T as TextPart, u as ToolCallPart, v as ToolChoice, w as ToolDefinition, x as ToolMessage, y as ToolResultContentPart, z as ToolResultOutput, B as ToolResultPart, U as Usage, E as UserContentPart, G as UserMessage, H as calculateContextUsage, K as getAssistantGenerationMetadata, L as isProviderTool, N as resolveModelContextLimits, O as withContextUsage } from './types-DgvozfPc.js';
@@ -8,8 +8,8 @@ export { C as COMPLETION_PROVIDER_OUTPUT_ERROR_CODE, a as CompletionBaseOptions,
8
8
  export { a as allow, b as block, d as defineGuardrailPolicy, c as defineInputGuardrail, e as defineOutputGuardrail, g as guardrails } from './text-ZLECpQE7.js';
9
9
  export { G as GuardrailBoundary, a as GuardrailDecisionRecord, b as GuardrailMode, c as GuardrailPolicy, d as GuardrailPolicyInput, e as GuardrailPolicyOptions, I as InputGuardrail, f as InputGuardrailActions, g as InputGuardrailContext, O as OutputGuardrail, h as OutputGuardrailActions, i as OutputGuardrailContext } from './types-DhkodEft.js';
10
10
  export { GenerateImageOptions, GeneratedImage, ImageGenerationModel, ImageGenerationRequest, ImageGenerationResult, generateImage } from './image-generation/index.js';
11
- export { MemoryCompactionConflictError, MemoryCompactionError, createMemoryScopeKey, createSummaryMemoryCompactor, isMemoryCompactionMessage } from './memory/index.js';
12
- export { C as CreateMemoryScopeKeyOptions, a as CreateSummaryMemoryCompactorOptions, M as MemoryAppendOptions, b as MemoryClearOptions, c as MemoryCompactionCapability, d as MemoryCompactionConflictRetryOptions, e as MemoryCompactionInfo, f as MemoryCompactionMessage, g as MemoryCompactionMetadata, h as MemoryCompactionOptions, i as MemoryCompactionReplacePrefixOptions, j as MemoryCompactionReplacePrefixResult, k as MemoryCompactionSnapshot, l as MemoryCompactionSnapshotOptions, m as MemoryCompactor, n as MemoryCompactorInput, o as MemoryCompactorResult, p as MemoryConversation, q as MemoryConversationGetOptions, r as MemoryConversationListOptions, s as MemoryConversationMessage, t as MemoryConversationSummary, u as MemoryErrorOptions, v as MemoryInspector, w as MemoryLoadOptions, x as MemoryOptions, y as MemorySavePolicy, z as MemoryScope, A as MemoryScopeKeyOptions, B as MemoryScopeKeyResolver, D as MemoryStore } from './types-DKOXVTcq.js';
11
+ export { MemoryCompactionConflictError, MemoryCompactionError, createMemoryScopeKey, createSummaryMemoryCompactor, estimateMemoryTokens, isMemoryCompactionMessage } from './memory/index.js';
12
+ export { C as CreateMemoryScopeKeyOptions, a as CreateSummaryMemoryCompactorOptions, M as MemoryAppendOptions, b as MemoryClearOptions, c as MemoryCompactionCapability, d as MemoryCompactionConflictRetryOptions, e as MemoryCompactionInfo, f as MemoryCompactionMessage, g as MemoryCompactionMetadata, h as MemoryCompactionOptions, i as MemoryCompactionReplacePrefixOptions, j as MemoryCompactionReplacePrefixResult, k as MemoryCompactionResult, l as MemoryCompactionSnapshot, m as MemoryCompactionSnapshotOptions, n as MemoryCompactor, o as MemoryCompactorInput, p as MemoryCompactorResult, q as MemoryConversation, r as MemoryConversationGetOptions, s as MemoryConversationListOptions, t as MemoryConversationMessage, u as MemoryConversationSummary, v as MemoryErrorOptions, w as MemoryInspector, x as MemoryLoadOptions, y as MemoryOptions, z as MemorySavePolicy, A as MemoryScope, B as MemoryScopeKeyOptions, D as MemoryScopeKeyResolver, E as MemoryStore, F as MemoryTokenCounter } from './types-CSYt7-It.js';
13
13
  export { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
14
14
  export { loadSkills, skill } from './skills/index.js';
15
15
  export { S as SkillValidationError } from './types-DC1U1XwW.js';
@@ -18,15 +18,10 @@ export { C as CreateToolOptions, c as createQuestionTool, a as createThinkTool,
18
18
  export { A as AnyTool, T as Tool, a as ToolApprovalContext, b as ToolApprovalRequirement, c as ToolCallContext, d as ToolCallStreamEvent, e as ToolRequiresApproval } from './tool-BpqpoRSE.js';
19
19
  export { A as AgentMiddleware, C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, e as ToolOutputMiddlewareArgs, f as ToolOutputMiddlewareResult, g as ToolResultMiddlewareArgs, h as createMiddleware } from './middleware-kcF8AusP.js';
20
20
  export { TranscribeOptions, TranscriptionAudio, TranscriptionModel, TranscriptionRequest, TranscriptionResult, transcribe } from './transcription/index.js';
21
- import './client-DTPl0hZv.js';
22
- import 'node:child_process';
23
- import 'node:stream';
24
- import '@modelcontextprotocol/sdk/client/auth.js';
25
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
26
- import '@modelcontextprotocol/sdk/shared/transport.js';
21
+ import './types-DjqRHeAi.js';
22
+ import './agent/interactions/index.js';
23
+ import 'zod';
27
24
  import './dynamic-tools-aIZlg5x1.js';
28
25
  import './types-Cr4uiYo5.js';
29
26
  import './types-CXNE592e.js';
30
- import './agent/interactions/index.js';
31
- import 'zod';
32
27
  import './type-utils-CtHVDRn_.js';
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import {
2
- SkillValidationError,
3
- loadSkills,
4
- skill
5
- } from "./chunk-3SKZ2BKP.js";
2
+ generateSpeech
3
+ } from "./chunk-EFLT7XZD.js";
6
4
  import {
7
5
  transcribe
8
6
  } from "./chunk-T2C3CGDQ.js";
@@ -11,18 +9,28 @@ import {
11
9
  } from "./chunk-I3Q7XSBB.js";
12
10
  import {
13
11
  createMemoryScopeKey
14
- } from "./chunk-QOUPWOGW.js";
12
+ } from "./chunk-SPD4XVR7.js";
15
13
  import {
16
- generateSpeech
17
- } from "./chunk-EFLT7XZD.js";
14
+ SkillValidationError,
15
+ loadSkills,
16
+ skill
17
+ } from "./chunk-3SKZ2BKP.js";
18
18
  import {
19
19
  Agent,
20
20
  createVectorContext,
21
21
  isVectorContext
22
- } from "./chunk-PISJAAMX.js";
23
- import "./chunk-YK4WAAS4.js";
22
+ } from "./chunk-3ZLM6OAZ.js";
24
23
  import "./chunk-OJBFDBLG.js";
25
- import "./chunk-76JLMBVT.js";
24
+ import "./chunk-J6LVLV6P.js";
25
+ import {
26
+ MemoryCompactionConflictError,
27
+ MemoryCompactionError,
28
+ createSummaryMemoryCompactor,
29
+ estimateMemoryTokens,
30
+ isMemoryCompactionMessage
31
+ } from "./chunk-YA7BMX7D.js";
32
+ import "./chunk-6BBOCFHV.js";
33
+ import "./chunk-YK4WAAS4.js";
26
34
  import {
27
35
  createMiddleware,
28
36
  createQuestionTool,
@@ -31,13 +39,6 @@ import {
31
39
  import {
32
40
  createTool
33
41
  } from "./chunk-EMZKPRE6.js";
34
- import {
35
- MemoryCompactionConflictError,
36
- MemoryCompactionError,
37
- createSummaryMemoryCompactor,
38
- isMemoryCompactionMessage
39
- } from "./chunk-TC4FILD3.js";
40
- import "./chunk-WZVHZZW6.js";
41
42
  import {
42
43
  AgentRunBlockedError,
43
44
  AgentRunCancelledError,
@@ -45,7 +46,7 @@ import {
45
46
  AgentStructuredOutputError,
46
47
  AgentToolSuspensionError,
47
48
  MaxTurnsError
48
- } from "./chunk-X4LK4ODN.js";
49
+ } from "./chunk-AHLKV6KP.js";
49
50
  import "./chunk-ZA564323.js";
50
51
  import "./chunk-3RM57ZT2.js";
51
52
  import "./chunk-D4PACGPA.js";
@@ -61,7 +62,8 @@ import {
61
62
  resolveModelContextLimits,
62
63
  streamCompletion,
63
64
  withContextUsage
64
- } from "./chunk-WTRGYFCD.js";
65
+ } from "./chunk-7PHMK7W4.js";
66
+ import "./chunk-7JLAIN6E.js";
65
67
  import {
66
68
  createMessageSchema,
67
69
  isMessage,
@@ -70,7 +72,6 @@ import {
70
72
  parseMessage,
71
73
  parseMessages
72
74
  } from "./chunk-QGX73TSQ.js";
73
- import "./chunk-7JLAIN6E.js";
74
75
  import {
75
76
  isJsonValue
76
77
  } from "./chunk-3XQGVDU5.js";
@@ -112,6 +113,7 @@ export {
112
113
  defineGuardrailPolicy,
113
114
  defineInputGuardrail,
114
115
  defineOutputGuardrail,
116
+ estimateMemoryTokens,
115
117
  generateCompletion,
116
118
  generateImage,
117
119
  generateSpeech,
@@ -1,20 +1,15 @@
1
- import { R as ResolvedAgentOptions, A as Agent } from '../agent-XPQBM4rX.js';
1
+ import { R as ResolvedAgentOptions, A as Agent } from '../agent-qRKa3ibC.js';
2
2
  import { c as CompletionModel, P as ProviderTool, M as Message, U as Usage, g as CompletionResponse, y as ToolResultContentPart } from '../types-DgvozfPc.js';
3
3
  import { T as ToolIndex } from '../dynamic-tools-aIZlg5x1.js';
4
4
  import { A as AnyTool } from '../tool-BpqpoRSE.js';
5
- import { e as MemoryCompactionInfo } from '../types-DKOXVTcq.js';
5
+ import { e as MemoryCompactionInfo } from '../types-CSYt7-It.js';
6
6
  import '../retry-CjvSlKGW.js';
7
7
  import '../zod-schema-C7F4clpm.js';
8
8
  import 'zod';
9
9
  import '../types-DhkodEft.js';
10
10
  import '../type-utils-CtHVDRn_.js';
11
- import '../client-DTPl0hZv.js';
12
- import 'node:child_process';
13
- import 'node:stream';
14
- import '@modelcontextprotocol/sdk/client/auth.js';
15
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
16
- import '@modelcontextprotocol/sdk/shared/transport.js';
17
- import '../types-Sue2hb_L.js';
11
+ import '../types-DjqRHeAi.js';
12
+ import '../types-CLCLFpAL.js';
18
13
  import '../agent/interactions/index.js';
19
14
  import '../middleware-kcF8AusP.js';
20
15
  import '../types-DC1U1XwW.js';
@@ -4,21 +4,21 @@ import {
4
4
  getAgentToolState,
5
5
  markResolvedAgentOptions,
6
6
  withInternalAgentRunOptions
7
- } from "../chunk-PISJAAMX.js";
8
- import "../chunk-YK4WAAS4.js";
7
+ } from "../chunk-3ZLM6OAZ.js";
9
8
  import "../chunk-OJBFDBLG.js";
10
- import "../chunk-76JLMBVT.js";
9
+ import "../chunk-J6LVLV6P.js";
10
+ import "../chunk-YA7BMX7D.js";
11
+ import "../chunk-6BBOCFHV.js";
12
+ import "../chunk-YK4WAAS4.js";
11
13
  import "../chunk-SJMSS5SI.js";
12
14
  import "../chunk-EMZKPRE6.js";
13
- import "../chunk-TC4FILD3.js";
14
- import "../chunk-WZVHZZW6.js";
15
- import "../chunk-X4LK4ODN.js";
15
+ import "../chunk-AHLKV6KP.js";
16
16
  import "../chunk-ZA564323.js";
17
17
  import "../chunk-3RM57ZT2.js";
18
18
  import "../chunk-D4PACGPA.js";
19
- import "../chunk-WTRGYFCD.js";
20
- import "../chunk-QGX73TSQ.js";
19
+ import "../chunk-7PHMK7W4.js";
21
20
  import "../chunk-7JLAIN6E.js";
21
+ import "../chunk-QGX73TSQ.js";
22
22
  import "../chunk-3XQGVDU5.js";
23
23
  import "../chunk-3RWESPUG.js";
24
24
  import "../chunk-AZB6N7P4.js";
@@ -1,23 +1,9 @@
1
- import { M as McpClient, a as McpServer, b as McpClientGroupConnectOptions, c as McpTool } from '../client-DTPl0hZv.js';
2
- export { d as McpClientOptions, e as McpClientTransport, f as McpConnectOptions, g as McpCustomTransport, h as McpServerInfo, i as McpStdioTransport, j as McpStreamableHttpTransport, k as McpTransport } from '../client-DTPl0hZv.js';
3
- import 'node:child_process';
4
- import 'node:stream';
5
- import '@modelcontextprotocol/sdk/client/auth.js';
6
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
7
- import '@modelcontextprotocol/sdk/shared/transport.js';
1
+ import { M as McpTool } from '../types-DjqRHeAi.js';
2
+ export { a as McpServer, b as McpServerInfo } from '../types-DjqRHeAi.js';
8
3
  import '../types-DgvozfPc.js';
9
4
  import '../model-call-options-CZkSw_xN.js';
10
5
  import '../tool-BpqpoRSE.js';
11
6
 
12
- declare class McpClientGroup {
13
- #private;
14
- readonly clients: readonly McpClient[];
15
- readonly servers: readonly McpServer[];
16
- private constructor();
17
- static connect(options: McpClientGroupConnectOptions): Promise<McpClientGroup>;
18
- close(): Promise<void>;
19
- }
20
-
21
7
  declare function isMcpTool(tool: unknown): tool is McpTool;
22
8
 
23
- export { McpClient, McpClientGroup, McpClientGroupConnectOptions, McpServer, McpTool, isMcpTool };
9
+ export { McpTool, isMcpTool };
package/dist/mcp/index.js CHANGED
@@ -1,21 +1,7 @@
1
1
  import {
2
- McpClient,
3
- McpClientGroup,
4
2
  isMcpTool
5
- } from "../chunk-76JLMBVT.js";
6
- import "../chunk-SJMSS5SI.js";
7
- import "../chunk-EMZKPRE6.js";
8
- import "../chunk-ZA564323.js";
9
- import "../chunk-3RM57ZT2.js";
10
- import "../chunk-D4PACGPA.js";
11
- import "../chunk-WTRGYFCD.js";
12
- import "../chunk-QGX73TSQ.js";
13
- import "../chunk-7JLAIN6E.js";
14
- import "../chunk-3XQGVDU5.js";
15
- import "../chunk-3RWESPUG.js";
3
+ } from "../chunk-J6LVLV6P.js";
16
4
  export {
17
- McpClient,
18
- McpClientGroup,
19
5
  isMcpTool
20
6
  };
21
7
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import { M as Message, U as Usage } from '../types-DgvozfPc.js';
2
- import { a as CreateSummaryMemoryCompactorOptions, m as MemoryCompactor, f as MemoryCompactionMessage, C as CreateMemoryScopeKeyOptions } from '../types-DKOXVTcq.js';
3
- export { M as MemoryAppendOptions, b as MemoryClearOptions, c as MemoryCompactionCapability, d as MemoryCompactionConflictRetryOptions, e as MemoryCompactionInfo, g as MemoryCompactionMetadata, h as MemoryCompactionOptions, i as MemoryCompactionReplacePrefixOptions, j as MemoryCompactionReplacePrefixResult, k as MemoryCompactionSnapshot, l as MemoryCompactionSnapshotOptions, n as MemoryCompactorInput, o as MemoryCompactorResult, p as MemoryConversation, q as MemoryConversationGetOptions, r as MemoryConversationListOptions, s as MemoryConversationMessage, t as MemoryConversationSummary, u as MemoryErrorOptions, v as MemoryInspector, w as MemoryLoadOptions, x as MemoryOptions, y as MemorySavePolicy, z as MemoryScope, A as MemoryScopeKeyOptions, B as MemoryScopeKeyResolver, D as MemoryStore } from '../types-DKOXVTcq.js';
2
+ import { a as CreateSummaryMemoryCompactorOptions, n as MemoryCompactor, f as MemoryCompactionMessage, C as CreateMemoryScopeKeyOptions } from '../types-CSYt7-It.js';
3
+ export { M as MemoryAppendOptions, b as MemoryClearOptions, c as MemoryCompactionCapability, d as MemoryCompactionConflictRetryOptions, e as MemoryCompactionInfo, g as MemoryCompactionMetadata, h as MemoryCompactionOptions, i as MemoryCompactionReplacePrefixOptions, j as MemoryCompactionReplacePrefixResult, k as MemoryCompactionResult, l as MemoryCompactionSnapshot, m as MemoryCompactionSnapshotOptions, o as MemoryCompactorInput, p as MemoryCompactorResult, q as MemoryConversation, r as MemoryConversationGetOptions, s as MemoryConversationListOptions, t as MemoryConversationMessage, u as MemoryConversationSummary, v as MemoryErrorOptions, w as MemoryInspector, x as MemoryLoadOptions, y as MemoryOptions, z as MemorySavePolicy, A as MemoryScope, B as MemoryScopeKeyOptions, D as MemoryScopeKeyResolver, E as MemoryStore, F as MemoryTokenCounter } from '../types-CSYt7-It.js';
4
4
  import '../model-call-options-CZkSw_xN.js';
5
5
  import '../retry-CjvSlKGW.js';
6
6
 
@@ -17,6 +17,9 @@ declare class MemoryCompactionConflictError extends MemoryCompactionError {
17
17
  constructor(attempts: number, usage?: Usage);
18
18
  }
19
19
 
20
+ /** Lightweight provider-neutral estimate used when no model-specific counter is supplied. */
21
+ declare function estimateMemoryTokens(messages: readonly Message[]): number;
22
+
20
23
  declare function createMemoryScopeKey(options: CreateMemoryScopeKeyOptions): string;
21
24
 
22
- export { CreateMemoryScopeKeyOptions, CreateSummaryMemoryCompactorOptions, MemoryCompactionConflictError, MemoryCompactionError, MemoryCompactionMessage, MemoryCompactor, createMemoryScopeKey, createSummaryMemoryCompactor, isMemoryCompactionMessage };
25
+ export { CreateMemoryScopeKeyOptions, CreateSummaryMemoryCompactorOptions, MemoryCompactionConflictError, MemoryCompactionError, MemoryCompactionMessage, MemoryCompactor, createMemoryScopeKey, createSummaryMemoryCompactor, estimateMemoryTokens, isMemoryCompactionMessage };
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  createMemoryScopeKey
3
- } from "../chunk-QOUPWOGW.js";
3
+ } from "../chunk-SPD4XVR7.js";
4
4
  import {
5
5
  MemoryCompactionConflictError,
6
6
  MemoryCompactionError,
7
7
  createSummaryMemoryCompactor,
8
+ estimateMemoryTokens,
8
9
  isMemoryCompactionMessage
9
- } from "../chunk-TC4FILD3.js";
10
- import "../chunk-WTRGYFCD.js";
11
- import "../chunk-QGX73TSQ.js";
10
+ } from "../chunk-YA7BMX7D.js";
11
+ import "../chunk-7PHMK7W4.js";
12
12
  import "../chunk-7JLAIN6E.js";
13
+ import "../chunk-QGX73TSQ.js";
13
14
  import "../chunk-3XQGVDU5.js";
14
15
  import "../chunk-3RWESPUG.js";
15
16
  export {
@@ -17,6 +18,7 @@ export {
17
18
  MemoryCompactionError,
18
19
  createMemoryScopeKey,
19
20
  createSummaryMemoryCompactor,
21
+ estimateMemoryTokens,
20
22
  isMemoryCompactionMessage
21
23
  };
22
24
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export { x as AgentGenerationEndArgs, y as AgentGenerationErrorArgs, z as AgentGenerationModelInfo, B as AgentGenerationObserver, C as AgentGenerationStartArgs, D as AgentGenerationUpdateArgs, E as AgentObservabilityOptions, F as AgentObserver, G as AgentObserverErrorPolicy, H as AgentObserverMap, I as AgentObserverTraceInfo, J as AgentRunEndArgs, K as AgentRunErrorArgs, L as AgentRunEventArgs, M as AgentRunObserver, N as AgentRunPromptRef, O as AgentRunStartArgs, P as AgentToolEndArgs, Q as AgentToolErrorArgs, R as AgentToolObserver, S as AgentToolStartArgs, T as AgentToolStreamEventArgs, U as AgentToolSuspendedArgs, V as AgentTraceInfo, W as AgentTraceOptions } from '../types-Sue2hb_L.js';
1
+ export { y as AgentGenerationEndArgs, z as AgentGenerationErrorArgs, B as AgentGenerationModelInfo, C as AgentGenerationObserver, D as AgentGenerationStartArgs, E as AgentGenerationUpdateArgs, F as AgentObservabilityOptions, G as AgentObserver, H as AgentObserverErrorPolicy, I as AgentObserverMap, J as AgentObserverTraceInfo, K as AgentRunEndArgs, L as AgentRunErrorArgs, M as AgentRunEventArgs, N as AgentRunObserver, O as AgentRunPromptRef, P as AgentRunStartArgs, Q as AgentToolEndArgs, R as AgentToolErrorArgs, S as AgentToolObserver, T as AgentToolStartArgs, U as AgentToolStreamEventArgs, V as AgentToolSuspendedArgs, W as AgentTraceInfo, X as AgentTraceOptions } from '../types-CLCLFpAL.js';
2
2
  import '../agent/interactions/index.js';
3
3
  import 'zod';
4
4
  import '../types-DgvozfPc.js';
@@ -6,7 +6,7 @@ import '../model-call-options-CZkSw_xN.js';
6
6
  import '../retry-CjvSlKGW.js';
7
7
  import '../types-DhkodEft.js';
8
8
  import '../type-utils-CtHVDRn_.js';
9
- import '../types-DKOXVTcq.js';
9
+ import '../types-CSYt7-It.js';
10
10
  import '../tool-BpqpoRSE.js';
11
11
  import '../middleware-kcF8AusP.js';
12
12
 
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AgentObserverDispatchError
3
- } from "../chunk-WZVHZZW6.js";
3
+ } from "../chunk-6BBOCFHV.js";
4
4
  import "../chunk-D4PACGPA.js";
5
- import "../chunk-WTRGYFCD.js";
6
- import "../chunk-QGX73TSQ.js";
5
+ import "../chunk-7PHMK7W4.js";
7
6
  import "../chunk-7JLAIN6E.js";
7
+ import "../chunk-QGX73TSQ.js";
8
8
  import "../chunk-3XQGVDU5.js";
9
9
  import "../chunk-3RWESPUG.js";
10
10
  export {
@@ -1,5 +1,5 @@
1
- import { t as AgentSuspendedResult, f as AgentInput, m as AgentRunSettings } from '../types-Sue2hb_L.js';
2
- import { A as Agent } from '../agent-XPQBM4rX.js';
1
+ import { g as AgentInteractionOutcome, f as AgentInput, o as AgentRunSettings } from '../types-CLCLFpAL.js';
2
+ import { A as Agent } from '../agent-qRKa3ibC.js';
3
3
  import { J as JsonObject, c as CompletionModel } from '../types-DgvozfPc.js';
4
4
  import { ExtractOptions } from '../extractor/index.js';
5
5
  import { z } from 'zod';
@@ -7,16 +7,11 @@ import '../agent/interactions/index.js';
7
7
  import '../retry-CjvSlKGW.js';
8
8
  import '../types-DhkodEft.js';
9
9
  import '../type-utils-CtHVDRn_.js';
10
- import '../types-DKOXVTcq.js';
10
+ import '../types-CSYt7-It.js';
11
11
  import '../tool-BpqpoRSE.js';
12
12
  import '../middleware-kcF8AusP.js';
13
13
  import '../zod-schema-C7F4clpm.js';
14
- import '../client-DTPl0hZv.js';
15
- import 'node:child_process';
16
- import 'node:stream';
17
- import '@modelcontextprotocol/sdk/client/auth.js';
18
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
19
- import '@modelcontextprotocol/sdk/shared/transport.js';
14
+ import '../types-DjqRHeAi.js';
20
15
  import '../types-DC1U1XwW.js';
21
16
  import '../dynamic-tools-aIZlg5x1.js';
22
17
  import '../types-Cr4uiYo5.js';
@@ -24,8 +19,8 @@ import '../model-call-options-CZkSw_xN.js';
24
19
  import '../types-CXNE592e.js';
25
20
 
26
21
  declare class PipelineAgentSuspensionError extends Error {
27
- readonly result: AgentSuspendedResult;
28
- constructor(result: AgentSuspendedResult);
22
+ readonly result: AgentInteractionOutcome;
23
+ constructor(result: AgentInteractionOutcome);
29
24
  }
30
25
 
31
26
  type PipelineMetadata = {
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  AgentRunBlockedError
3
- } from "../chunk-X4LK4ODN.js";
3
+ } from "../chunk-AHLKV6KP.js";
4
4
  import {
5
5
  mapWithConcurrency
6
6
  } from "../chunk-3RM57ZT2.js";
7
7
  import {
8
8
  extract
9
- } from "../chunk-KIXN5DGS.js";
9
+ } from "../chunk-LTXABCOO.js";
10
10
  import "../chunk-D4PACGPA.js";
11
- import "../chunk-WTRGYFCD.js";
12
- import "../chunk-QGX73TSQ.js";
11
+ import "../chunk-7PHMK7W4.js";
13
12
  import "../chunk-7JLAIN6E.js";
13
+ import "../chunk-QGX73TSQ.js";
14
14
  import "../chunk-3XQGVDU5.js";
15
15
  import {
16
16
  abortError,
@@ -433,10 +433,10 @@ var Pipeline = class {
433
433
  ...request,
434
434
  abortSignal: context.abortSignal
435
435
  });
436
- if (response.status === "suspended") {
436
+ if (response.type === "interaction") {
437
437
  throw new PipelineAgentSuspensionError(response);
438
438
  }
439
- if (response.status === "blocked") {
439
+ if (response.type === "blocked") {
440
440
  throw new AgentRunBlockedError(response);
441
441
  }
442
442
  return response.output;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pipeline/errors.ts","../../src/pipeline/pipeline.ts","../../src/pipeline/graph.ts","../../src/pipeline/runtime.ts"],"sourcesContent":["import type { AgentSuspendedResult } from \"../agent/run-types\";\n\nexport class PipelineAgentSuspensionError extends Error {\n constructor(readonly result: AgentSuspendedResult) {\n super(\"Pipeline agent stage suspended for human interaction.\");\n this.name = \"PipelineAgentSuspensionError\";\n }\n}\n","import { z } from \"zod\";\nimport type { Agent } from \"../agent/agent\";\nimport { AgentRunBlockedError } from \"../agent/errors\";\nimport type { AgentInput, AgentRunOptions, AgentRunSettings } from \"../agent/run-types\";\nimport type { CompletionModel, JsonObject } from \"../completion\";\nimport { type ExtractOptions, extract as extractData } from \"../extractor\";\nimport { throwIfAborted } from \"../internal/abort\";\nimport { mapWithConcurrency } from \"../internal/concurrency\";\nimport { PipelineAgentSuspensionError } from \"./errors\";\nimport {\n appendComposedGraph,\n appendParallelBranch,\n appendStageNode,\n cloneGraph,\n initialPipelineState,\n withOutputNode,\n withTerminalPaths,\n} from \"./graph\";\nimport {\n childContext,\n combineAbortSignals,\n pipelineAbortError,\n runNode,\n stageContext,\n} from \"./runtime\";\nimport type {\n ParallelOutput,\n PipelineBatchItem,\n PipelineBatchOptions,\n PipelineExecutor,\n PipelineGraph,\n PipelineGraphNode,\n PipelineNodePath,\n PipelineOptions,\n PipelineRunContext,\n PipelineRunOptions,\n PipelineRunResult,\n PipelineStageContext,\n PipelineStageMetadata,\n PipelineState,\n} from \"./types\";\n\nconst internalPipelineOptions = Symbol(\"internal-pipeline-options\");\n\ntype RawResponseOf<Model> =\n Model extends CompletionModel<infer RawResponse> ? RawResponse : unknown;\n\ntype PipelineAgentRequest<Output, Model extends CompletionModel> = AgentInput &\n Omit<AgentRunSettings<Output, RawResponseOf<Model>>, \"abortSignal\">;\n\nexport type PipelineStepOptions<Input, Output> = PipelineStageMetadata & {\n run(context: PipelineStageContext<Input>): Output | Promise<Output>;\n};\n\nexport type PipelineComposeOptions<Input, Output> = PipelineStageMetadata & {\n pipeline: Pipeline<Input, Output>;\n};\n\nexport type PipelineParallelOptions<\n Input,\n Branches extends Record<string, Pipeline<Input, unknown>>,\n> = PipelineStageMetadata & {\n branches: Branches;\n};\n\nexport type PipelineAgentOptions<\n Input,\n AgentOutput,\n Model extends CompletionModel,\n> = PipelineStageMetadata & {\n agent: Agent<AgentOutput, Model>;\n request(\n context: PipelineStageContext<Input>,\n ): PipelineAgentRequest<AgentOutput, Model> | Promise<PipelineAgentRequest<AgentOutput, Model>>;\n suspension: \"reject\";\n};\n\nexport type PipelineExtractOptions<\n Input,\n Extracted,\n Model extends CompletionModel,\n> = PipelineStageMetadata &\n Omit<ExtractOptions<Extracted, Model>, \"text\" | \"abortSignal\"> & {\n text(context: PipelineStageContext<Input>): string | Promise<string>;\n };\n\ntype InternalPipelineOptions<Input, Output> = {\n [internalPipelineOptions]: {\n executor: PipelineExecutor<Input, Output>;\n state: PipelineState;\n };\n};\n\n/** Immutable, typed Pipeline with explicit stage and execution boundaries. */\nexport class Pipeline<Input, Output = Input> {\n readonly id: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly metadata: JsonObject | undefined;\n\n private readonly executor: PipelineExecutor<Input, Output>;\n private readonly state: PipelineState;\n\n constructor(options: PipelineOptions<Input, Output>);\n constructor(options: PipelineOptions<Input, Output> | InternalPipelineOptions<Input, Output>) {\n if (isInternalPipelineOptions(options)) {\n this.executor = options[internalPipelineOptions].executor;\n this.state = options[internalPipelineOptions].state;\n } else {\n const id = normalizePipelineId(options.id);\n if (!isZodSchema(options.inputSchema)) {\n throw new TypeError(\"Pipeline inputSchema must be a Zod schema.\");\n }\n const inputSchema = options.inputSchema;\n this.executor = (async (input, context) => {\n throwIfAborted(context.abortSignal);\n return inputSchema.parseAsync(input) as Promise<Output>;\n }) as PipelineExecutor<Input, Output>;\n this.state = initialPipelineState({\n id,\n name: options.name,\n description: options.description,\n metadata: options.metadata,\n });\n }\n\n const graph = this.state.graph;\n this.id = graph.id;\n this.name = graph.name;\n this.description = graph.description;\n this.metadata = graph.metadata;\n }\n\n step<Next>(options: PipelineStepOptions<Awaited<Output>, Next>): Pipeline<Input, Awaited<Next>> {\n const next = appendStageNode(this.state, \"step\", options);\n const executor = (async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, next.node.id];\n return (await runNode(context, next.node, path, () =>\n options.run(stageContext(value, context)),\n )) as Awaited<Next>;\n }) as PipelineExecutor<Input, Awaited<Next>>;\n return this.derive(executor, next.state);\n }\n\n compose<Next>(\n options: PipelineComposeOptions<Awaited<Output>, Next>,\n ): Pipeline<Input, Awaited<Next>> {\n const boundary = appendStageNode(this.state, \"pipeline\", options, {\n defaultLabel: options.pipeline.name ?? options.pipeline.id,\n pipelineId: options.pipeline.id,\n });\n const state = appendComposedGraph(boundary.state, boundary.node, options.pipeline.graph());\n const executor = (async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, boundary.node.id];\n return (await runNode(context, boundary.node, path, () =>\n options.pipeline.execute(value, context, path),\n )) as Awaited<Next>;\n }) as PipelineExecutor<Input, Awaited<Next>>;\n return this.derive(executor, state);\n }\n\n parallel<Branches extends Record<string, Pipeline<Awaited<Output>, unknown>>>(\n options: PipelineParallelOptions<Awaited<Output>, Branches>,\n ): Pipeline<Input, ParallelOutput<Branches>> {\n const branchEntries = normalizeParallelBranches(options.branches);\n if (branchEntries.length === 0) {\n throw new TypeError(\"Pipeline parallel branches must not be empty.\");\n }\n const parallel = appendStageNode(this.state, \"parallel\", options, {\n defaultLabel: `${branchEntries.length} parallel branches`,\n });\n let nextState = parallel.state;\n const branchNodes = new Map<string, PipelineGraphNode>();\n const terminalPaths: PipelineNodePath[] = [];\n for (const [key, branch] of branchEntries) {\n const appended = appendParallelBranch(nextState, parallel.node, key, branch.graph());\n nextState = appended.state;\n branchNodes.set(key, appended.node);\n terminalPaths.push(...appended.terminalPaths);\n }\n nextState = withTerminalPaths(nextState, terminalPaths);\n\n return this.derive<ParallelOutput<Branches>>(async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const parallelPath = [...pathPrefix, parallel.node.id];\n return runNode(context, parallel.node, parallelPath, async () => {\n const controller = new AbortController();\n const combined = combineAbortSignals(context.abortSignal, controller.signal);\n const branchContext = childContext(context, combined.signal);\n let firstError: unknown;\n const promises = branchEntries.map(async ([key, branch]) => {\n const node = branchNodes.get(key) as PipelineGraphNode;\n const path = [...parallelPath, node.id];\n try {\n const output = await runNode(branchContext, node, path, () =>\n branch.execute(value, branchContext, path),\n );\n return [key, output] as const;\n } catch (error) {\n if (firstError === undefined) firstError = error;\n if (!controller.signal.aborted) controller.abort(error);\n throw error;\n }\n });\n\n const settled = await Promise.allSettled(promises);\n combined.dispose();\n if (context.abortSignal?.aborted === true) {\n throw pipelineAbortError(context.abortSignal);\n }\n if (firstError !== undefined) throw firstError;\n return Object.fromEntries(\n settled.map(\n (result) => (result as PromiseFulfilledResult<readonly [string, unknown]>).value,\n ),\n ) as ParallelOutput<Branches>;\n });\n }, nextState);\n }\n\n agent<AgentOutput, Model extends CompletionModel>(\n options: PipelineAgentOptions<Awaited<Output>, AgentOutput, Model>,\n ): Pipeline<Input, AgentOutput> {\n if (options.suspension !== \"reject\") {\n throw new TypeError('Pipeline Agent stages require suspension: \"reject\".');\n }\n const next = appendStageNode(this.state, \"agent\", options, {\n defaultLabel: options.agent.name ?? options.agent.id,\n agentId: options.agent.id,\n agentName: options.agent.name,\n });\n return this.derive<AgentOutput>(async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, next.node.id];\n return runNode(context, next.node, path, async () => {\n const request = await options.request(stageContext(value, context));\n const response = await options.agent.generate({\n ...request,\n abortSignal: context.abortSignal,\n } as AgentRunOptions<AgentOutput, RawResponseOf<Model>>);\n if (response.status === \"suspended\") {\n throw new PipelineAgentSuspensionError(response);\n }\n if (response.status === \"blocked\") {\n throw new AgentRunBlockedError(response);\n }\n return response.output;\n });\n }, next.state);\n }\n\n extract<Extracted, Model extends CompletionModel>(\n options: PipelineExtractOptions<Awaited<Output>, Extracted, Model>,\n ): Pipeline<Input, Extracted> {\n const next = appendStageNode(this.state, \"extractor\", options);\n return this.derive<Extracted>(async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, next.node.id];\n return runNode(context, next.node, path, async () => {\n const text = await options.text(stageContext(value, context));\n const result = await extractData({\n model: options.model,\n text,\n outputSchema: options.outputSchema,\n instructions: options.instructions,\n retries: options.retries,\n temperature: options.temperature,\n maxTokens: options.maxTokens,\n providerOptions: options.providerOptions,\n abortSignal: context.abortSignal,\n });\n return result.output;\n });\n }, next.state);\n }\n\n async run(options: PipelineRunOptions<Input>): Promise<PipelineRunResult<Output>> {\n const runId = normalizeRunId(options.runId ?? globalThis.crypto.randomUUID());\n const context: PipelineRunContext = {\n runId,\n pipelineId: this.id,\n runMetadata: options.metadata,\n abortSignal: options.abortSignal,\n observer: options.observer,\n failOnObserverError: options.failOnObserverError === true,\n };\n throwIfAborted(context.abortSignal);\n const output = await this.execute(options.input, context, []);\n throwIfAborted(context.abortSignal);\n return { runId, output };\n }\n\n async runBatch(options: PipelineBatchOptions<Input>): Promise<Array<PipelineBatchItem<Output>>> {\n throwIfAborted(options.abortSignal);\n return mapWithConcurrency([...options.inputs], options.concurrency, async (input) => {\n const runId = globalThis.crypto.randomUUID();\n try {\n const result = await this.run({\n input,\n runId,\n metadata: options.metadata,\n abortSignal: options.abortSignal,\n observer: options.observer,\n failOnObserverError: options.failOnObserverError,\n });\n return { status: \"completed\", ...result } as const;\n } catch (error) {\n if (options.abortSignal?.aborted === true) {\n throw pipelineAbortError(options.abortSignal);\n }\n return { status: \"failed\", runId, error } as const;\n }\n });\n }\n\n graph(): PipelineGraph {\n return cloneGraph(withOutputNode(this.state));\n }\n\n private derive<DerivedOutput>(\n executor: PipelineExecutor<Input, DerivedOutput>,\n state: PipelineState,\n ): Pipeline<Input, DerivedOutput> {\n return createDerivedPipeline(executor, state);\n }\n\n private async execute(\n input: Input,\n context: PipelineRunContext,\n pathPrefix: PipelineNodePath,\n ): Promise<Awaited<Output>> {\n throwIfAborted(context.abortSignal);\n return (await this.executor(input, context, pathPrefix)) as Awaited<Output>;\n }\n}\n\nfunction createDerivedPipeline<Input, Output>(\n executor: PipelineExecutor<Input, Output>,\n state: PipelineState,\n): Pipeline<Input, Output> {\n const options: InternalPipelineOptions<Input, Output> = {\n [internalPipelineOptions]: { executor, state },\n };\n return new Pipeline<Input, Output>(options as unknown as PipelineOptions<Input, Output>);\n}\n\nfunction isInternalPipelineOptions<Input, Output>(\n options: PipelineOptions<Input, Output> | InternalPipelineOptions<Input, Output>,\n): options is InternalPipelineOptions<Input, Output> {\n return internalPipelineOptions in options;\n}\n\nfunction isZodSchema(value: unknown): value is z.ZodType {\n return value instanceof z.ZodType;\n}\n\nfunction normalizePipelineId(id: string): string {\n if (typeof id !== \"string\") {\n throw new TypeError(\"Pipeline id must be a string.\");\n }\n const normalized = id.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Pipeline id must be a non-empty string.\");\n }\n return normalized;\n}\n\nfunction normalizeRunId(runId: string): string {\n if (typeof runId !== \"string\") {\n throw new TypeError(\"Pipeline runId must be a string.\");\n }\n const normalized = runId.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Pipeline runId must be a non-empty string.\");\n }\n return normalized;\n}\n\nfunction normalizeParallelBranches<Branch>(\n branches: Readonly<Record<string, Branch>>,\n): Array<readonly [string, Branch]> {\n const entries: Array<readonly [string, Branch]> = [];\n const ids = new Set<string>();\n for (const key of Object.keys(branches)) {\n const pipeline = branches[key] as Branch;\n const id = key.trim();\n if (id.length === 0) {\n throw new TypeError(\"Pipeline parallel branch id must be a non-empty string.\");\n }\n if (ids.has(id)) {\n throw new TypeError(`Pipeline parallel branch id \"${id}\" is already registered.`);\n }\n ids.add(id);\n if (id !== key) {\n throw new TypeError(\"Pipeline parallel branch ids must not contain surrounding whitespace.\");\n }\n entries.push([id, pipeline]);\n }\n return entries;\n}\n","import type { JsonObject } from \"../completion\";\nimport type {\n PipelineGraph,\n PipelineGraphEdge,\n PipelineGraphNode,\n PipelineNodePath,\n PipelineStageKind,\n PipelineStageMetadata,\n PipelineState,\n} from \"./types\";\n\nconst INPUT_ID = \"$input\";\nconst OUTPUT_ID = \"$output\";\nconst RESERVED_STAGE_IDS = new Set([INPUT_ID, OUTPUT_ID]);\n\nexport function initialPipelineState(options: {\n id: string;\n name?: string | undefined;\n description?: string | undefined;\n metadata?: JsonObject | undefined;\n}): PipelineState {\n const input = graphNode(INPUT_ID, [INPUT_ID], \"input\", \"Input\");\n const graph: PipelineGraph = {\n id: options.id,\n nodes: [input],\n edges: [],\n };\n if (options.name !== undefined) graph.name = options.name;\n if (options.description !== undefined) graph.description = options.description;\n if (options.metadata !== undefined) graph.metadata = options.metadata;\n return {\n graph,\n terminalPaths: [input.path],\n stageIds: new Set(),\n nextEdgeIndex: 1,\n };\n}\n\nexport function appendStageNode(\n state: PipelineState,\n kind: PipelineStageKind,\n stage: PipelineStageMetadata,\n options: {\n defaultLabel?: string | undefined;\n agentId?: string | undefined;\n agentName?: string | undefined;\n pipelineId?: string | undefined;\n } = {},\n): { state: PipelineState; node: PipelineGraphNode } {\n const id = validateStageId(stage.id);\n if (state.stageIds.has(id)) {\n throw new TypeError(`Pipeline stage id \"${id}\" is already registered.`);\n }\n const node = graphNode(id, [id], kind, stage.name ?? options.defaultLabel ?? id, {\n description: stage.description,\n metadata: stage.metadata,\n agentId: options.agentId,\n agentName: options.agentName,\n pipelineId: options.pipelineId,\n });\n return {\n node,\n state: appendNode(state, node, state.terminalPaths, [node.path], id),\n };\n}\n\nexport function appendComposedGraph(\n state: PipelineState,\n boundary: PipelineGraphNode,\n child: PipelineGraph,\n): PipelineState {\n return appendChildGraph(state, boundary.path, child);\n}\n\nexport function appendParallelBranch(\n state: PipelineState,\n parallel: PipelineGraphNode,\n branchKey: string,\n child: PipelineGraph,\n): { state: PipelineState; node: PipelineGraphNode; terminalPaths: PipelineNodePath[] } {\n const id = validateStageId(branchKey);\n const path = [...parallel.path, id];\n const node = graphNode(id, path, \"branch\", id, { branchKey: id, pipelineId: child.id });\n const withBranch = appendNode(state, node, [parallel.path], state.terminalPaths);\n const withChild = appendChildGraph(withBranch, node.path, child);\n return { state: withChild, node, terminalPaths: withChild.terminalPaths };\n}\n\nexport function withTerminalPaths(\n state: PipelineState,\n terminalPaths: PipelineNodePath[],\n): PipelineState {\n return { ...state, terminalPaths };\n}\n\nexport function withOutputNode(state: PipelineState): PipelineGraph {\n const graph = cloneGraph(state.graph);\n const outputPath = [OUTPUT_ID];\n if (graph.nodes.some((node) => pathEquals(node.path, outputPath))) {\n return graph;\n }\n graph.nodes.push(graphNode(OUTPUT_ID, outputPath, \"output\", \"Output\"));\n graph.edges.push(\n ...state.terminalPaths.map((source, index) => ({\n id: `edge_${state.nextEdgeIndex + index}`,\n source: [...source],\n target: outputPath,\n })),\n );\n return graph;\n}\n\nexport function cloneGraph(graph: PipelineGraph): PipelineGraph {\n return {\n ...graph,\n nodes: graph.nodes.map((node) => ({ ...node, path: [...node.path] })),\n edges: graph.edges.map((edge) => ({\n ...edge,\n source: [...edge.source],\n target: [...edge.target],\n })),\n };\n}\n\nexport function scopedNode(node: PipelineGraphNode, path: PipelineNodePath): PipelineGraphNode {\n return { ...node, path: [...path] };\n}\n\nfunction appendChildGraph(\n state: PipelineState,\n parentPath: PipelineNodePath,\n child: PipelineGraph,\n): PipelineState {\n const childNodes = child.nodes\n .filter((node) => !isBoundaryPath(node.path))\n .map((node) => scopedNode(node, [...parentPath, ...node.path]));\n const childEdges: PipelineState[\"graph\"][\"edges\"] = [];\n const terminalPaths: PipelineNodePath[] = [];\n let nextEdgeIndex = state.nextEdgeIndex;\n\n for (const edge of child.edges) {\n const sourceIsInput = isInputPath(edge.source);\n const targetIsOutput = isOutputPath(edge.target);\n const source = sourceIsInput ? [...parentPath] : [...parentPath, ...edge.source];\n if (targetIsOutput) {\n terminalPaths.push(source);\n continue;\n }\n const target = [...parentPath, ...edge.target];\n let childEdge: PipelineGraphEdge = {\n id: `edge_${nextEdgeIndex}`,\n source,\n target,\n };\n if (edge.label !== undefined) childEdge = { ...childEdge, label: edge.label };\n childEdges.push(childEdge);\n nextEdgeIndex += 1;\n }\n\n return {\n ...state,\n graph: {\n ...state.graph,\n nodes: [...state.graph.nodes, ...childNodes],\n edges: [...state.graph.edges, ...childEdges],\n },\n terminalPaths: terminalPaths.length === 0 ? [[...parentPath]] : terminalPaths,\n nextEdgeIndex,\n };\n}\n\nfunction appendNode(\n state: PipelineState,\n node: PipelineGraphNode,\n sourcePaths: PipelineNodePath[],\n terminalPaths: PipelineNodePath[],\n stageId?: string,\n): PipelineState {\n const edges = sourcePaths.map((source, index) => ({\n id: `edge_${state.nextEdgeIndex + index}`,\n source: [...source],\n target: [...node.path],\n }));\n const stageIds = new Set(state.stageIds);\n if (stageId !== undefined) stageIds.add(stageId);\n return {\n graph: {\n ...state.graph,\n nodes: [...state.graph.nodes, node],\n edges: [...state.graph.edges, ...edges],\n },\n terminalPaths,\n stageIds,\n nextEdgeIndex: state.nextEdgeIndex + edges.length,\n };\n}\n\nfunction graphNode(\n id: string,\n path: PipelineNodePath,\n kind: PipelineStageKind,\n label: string,\n options: {\n description?: string | undefined;\n metadata?: JsonObject | undefined;\n agentId?: string | undefined;\n agentName?: string | undefined;\n pipelineId?: string | undefined;\n branchKey?: string | undefined;\n } = {},\n): PipelineGraphNode {\n const node: PipelineGraphNode = { id, path: [...path], kind, label };\n if (options.description !== undefined) node.description = options.description;\n if (options.metadata !== undefined) node.metadata = options.metadata;\n if (options.agentId !== undefined) node.agentId = options.agentId;\n if (options.agentName !== undefined) node.agentName = options.agentName;\n if (options.pipelineId !== undefined) node.pipelineId = options.pipelineId;\n if (options.branchKey !== undefined) node.branchKey = options.branchKey;\n return node;\n}\n\nfunction validateStageId(value: string): string {\n if (typeof value !== \"string\") {\n throw new TypeError(\"Pipeline stage id must be a string.\");\n }\n const id = value.trim();\n if (id.length === 0) {\n throw new TypeError(\"Pipeline stage id must be a non-empty string.\");\n }\n if (RESERVED_STAGE_IDS.has(id)) {\n throw new TypeError(`Pipeline stage id \"${id}\" is reserved.`);\n }\n return id;\n}\n\nfunction isBoundaryPath(path: PipelineNodePath): boolean {\n return isInputPath(path) || isOutputPath(path);\n}\n\nfunction isInputPath(path: PipelineNodePath): boolean {\n return path.length === 1 && path[0] === INPUT_ID;\n}\n\nfunction isOutputPath(path: PipelineNodePath): boolean {\n return path.length === 1 && path[0] === OUTPUT_ID;\n}\n\nfunction pathEquals(left: PipelineNodePath, right: PipelineNodePath): boolean {\n return left.length === right.length && left.every((segment, index) => segment === right[index]);\n}\n","import { abortError, throwIfAborted } from \"../internal/abort\";\nimport { scopedNode } from \"./graph\";\nimport type {\n PipelineGraphNode,\n PipelineNodePath,\n PipelineRunContext,\n PipelineRunEvent,\n PipelineStageContext,\n} from \"./types\";\n\nexport async function runNode<Output>(\n context: PipelineRunContext,\n node: PipelineGraphNode,\n path: PipelineNodePath,\n fn: () => Output | Promise<Output>,\n): Promise<Awaited<Output>> {\n throwIfAborted(context.abortSignal);\n const eventNode = scopedNode(node, path);\n const startedAt = Date.now();\n await emitEvent(context, {\n type: \"stage_started\",\n runId: context.runId,\n pipelineId: context.pipelineId,\n path: [...path],\n node: eventNode,\n });\n\n try {\n const output = (await fn()) as Awaited<Output>;\n throwIfAborted(context.abortSignal);\n await emitEvent(context, {\n type: \"stage_completed\",\n runId: context.runId,\n pipelineId: context.pipelineId,\n path: [...path],\n node: eventNode,\n durationMs: Date.now() - startedAt,\n });\n return output;\n } catch (error) {\n const failureEvent: PipelineRunEvent = {\n type: \"stage_failed\",\n runId: context.runId,\n pipelineId: context.pipelineId,\n path: [...path],\n node: eventNode,\n durationMs: Date.now() - startedAt,\n error,\n };\n try {\n await emitEvent(context, failureEvent);\n } catch (observerError) {\n throw new AggregateError(\n [error, observerError],\n `Pipeline stage \"${node.id}\" and its observer both failed.`,\n );\n }\n throw error;\n }\n}\n\nexport function stageContext<Input>(\n input: Input,\n context: PipelineRunContext,\n): PipelineStageContext<Input> {\n return {\n input,\n runId: context.runId,\n pipelineId: context.pipelineId,\n runMetadata: context.runMetadata,\n abortSignal: context.abortSignal,\n };\n}\n\nexport function childContext(\n context: PipelineRunContext,\n abortSignal: AbortSignal | undefined,\n): PipelineRunContext {\n return { ...context, abortSignal };\n}\n\nexport function combineAbortSignals(\n parent: AbortSignal | undefined,\n local: AbortSignal,\n): { signal: AbortSignal; dispose(): void } {\n const controller = new AbortController();\n const abortFromParent = () => controller.abort(parent?.reason);\n const abortFromLocal = () => controller.abort(local.reason);\n\n if (parent?.aborted === true) {\n controller.abort(parent.reason);\n } else if (local.aborted) {\n controller.abort(local.reason);\n } else {\n parent?.addEventListener(\"abort\", abortFromParent, { once: true });\n local.addEventListener(\"abort\", abortFromLocal, { once: true });\n }\n\n return {\n signal: controller.signal,\n dispose() {\n parent?.removeEventListener(\"abort\", abortFromParent);\n local.removeEventListener(\"abort\", abortFromLocal);\n },\n };\n}\n\nexport function pipelineAbortError(signal: AbortSignal | undefined): Error {\n return abortError(signal?.reason);\n}\n\nasync function emitEvent(context: PipelineRunContext, event: PipelineRunEvent): Promise<void> {\n if (context.observer === undefined) return;\n try {\n await context.observer.onEvent(event);\n } catch (error) {\n if (context.failOnObserverError) throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEO,IAAM,+BAAN,cAA2C,MAAM;AAAA,EACtD,YAAqB,QAA8B;AACjD,UAAM,uDAAuD;AAD1C;AAEnB,SAAK,OAAO;AAAA,EACd;AAAA,EAHqB;AAIvB;;;ACPA,SAAS,SAAS;;;ACWlB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,qBAAqB,oBAAI,IAAI,CAAC,UAAU,SAAS,CAAC;AAEjD,SAAS,qBAAqB,SAKnB;AAChB,QAAM,QAAQ,UAAU,UAAU,CAAC,QAAQ,GAAG,SAAS,OAAO;AAC9D,QAAM,QAAuB;AAAA,IAC3B,IAAI,QAAQ;AAAA,IACZ,OAAO,CAAC,KAAK;AAAA,IACb,OAAO,CAAC;AAAA,EACV;AACA,MAAI,QAAQ,SAAS,OAAW,OAAM,OAAO,QAAQ;AACrD,MAAI,QAAQ,gBAAgB,OAAW,OAAM,cAAc,QAAQ;AACnE,MAAI,QAAQ,aAAa,OAAW,OAAM,WAAW,QAAQ;AAC7D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,CAAC,MAAM,IAAI;AAAA,IAC1B,UAAU,oBAAI,IAAI;AAAA,IAClB,eAAe;AAAA,EACjB;AACF;AAEO,SAAS,gBACd,OACA,MACA,OACA,UAKI,CAAC,GAC8C;AACnD,QAAM,KAAK,gBAAgB,MAAM,EAAE;AACnC,MAAI,MAAM,SAAS,IAAI,EAAE,GAAG;AAC1B,UAAM,IAAI,UAAU,sBAAsB,EAAE,0BAA0B;AAAA,EACxE;AACA,QAAM,OAAO,UAAU,IAAI,CAAC,EAAE,GAAG,MAA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C3B,UAAM,IAAI,UAAU,yCAAyC;AAAA,EAC/D;AACA,SAAO;AACT;AAEA,SAAS,eAAe,OAAuB;AAC7C,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,IAAI,UAAU,kCAAkC;AAAA,EACxD;AACA,QAAM,aAAa,MAAM,KAAK;AAC9B,MAAI,WAAW,WAAW,GAAG;AAC3B,UAAM,IAAI,UAAU,4CAA4C;AAAA,EAClE;AACA,SAAO;AACT;AAEA,SAAS,0BACP,UACkC;AAClC,QAAM,UAA4C,CAAC;AACnD,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,OAAO,OAAO,KAAK,QAAQ,GAAG;AACvC,UAAM,WAAW,SAAS,GAAG;AAC7B,UAAM,KAAK,IAAI,KAAK;AACpB,QAAI,GAAG,WAAW,GAAG;AACnB,YAAM,IAAI,UAAU,yDAAyD;AAAA,IAC/E;AACA,QAAI,IAAI,IAAI,EAAE,GAAG;AACf,YAAM,IAAI,UAAU,gCAAgC,EAAE,0BAA0B;AAAA,IAClF;AACA,QAAI,IAAI,EAAE;AACV,QAAI,OAAO,KAAK;AACd,YAAM,IAAI,UAAU,uEAAuE;AAAA,IAC7F;AACA,YAAQ,KAAK,CAAC,IAAI,QAAQ,CAAC;AAAA,EAC7B;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/pipeline/errors.ts","../../src/pipeline/pipeline.ts","../../src/pipeline/graph.ts","../../src/pipeline/runtime.ts"],"sourcesContent":["import type { AgentInteractionOutcome } from \"../agent/run-types\";\n\nexport class PipelineAgentSuspensionError extends Error {\n constructor(readonly result: AgentInteractionOutcome) {\n super(\"Pipeline agent stage suspended for human interaction.\");\n this.name = \"PipelineAgentSuspensionError\";\n }\n}\n","import { z } from \"zod\";\nimport type { Agent } from \"../agent/agent\";\nimport { AgentRunBlockedError } from \"../agent/errors\";\nimport type { AgentInput, AgentRunOptions, AgentRunSettings } from \"../agent/run-types\";\nimport type { CompletionModel, JsonObject } from \"../completion\";\nimport { type ExtractOptions, extract as extractData } from \"../extractor\";\nimport { throwIfAborted } from \"../internal/abort\";\nimport { mapWithConcurrency } from \"../internal/concurrency\";\nimport { PipelineAgentSuspensionError } from \"./errors\";\nimport {\n appendComposedGraph,\n appendParallelBranch,\n appendStageNode,\n cloneGraph,\n initialPipelineState,\n withOutputNode,\n withTerminalPaths,\n} from \"./graph\";\nimport {\n childContext,\n combineAbortSignals,\n pipelineAbortError,\n runNode,\n stageContext,\n} from \"./runtime\";\nimport type {\n ParallelOutput,\n PipelineBatchItem,\n PipelineBatchOptions,\n PipelineExecutor,\n PipelineGraph,\n PipelineGraphNode,\n PipelineNodePath,\n PipelineOptions,\n PipelineRunContext,\n PipelineRunOptions,\n PipelineRunResult,\n PipelineStageContext,\n PipelineStageMetadata,\n PipelineState,\n} from \"./types\";\n\nconst internalPipelineOptions = Symbol(\"internal-pipeline-options\");\n\ntype RawResponseOf<Model> =\n Model extends CompletionModel<infer RawResponse> ? RawResponse : unknown;\n\ntype PipelineAgentRequest<Output, Model extends CompletionModel> = AgentInput &\n Omit<AgentRunSettings<Output, RawResponseOf<Model>>, \"abortSignal\">;\n\nexport type PipelineStepOptions<Input, Output> = PipelineStageMetadata & {\n run(context: PipelineStageContext<Input>): Output | Promise<Output>;\n};\n\nexport type PipelineComposeOptions<Input, Output> = PipelineStageMetadata & {\n pipeline: Pipeline<Input, Output>;\n};\n\nexport type PipelineParallelOptions<\n Input,\n Branches extends Record<string, Pipeline<Input, unknown>>,\n> = PipelineStageMetadata & {\n branches: Branches;\n};\n\nexport type PipelineAgentOptions<\n Input,\n AgentOutput,\n Model extends CompletionModel,\n> = PipelineStageMetadata & {\n agent: Agent<AgentOutput, Model>;\n request(\n context: PipelineStageContext<Input>,\n ): PipelineAgentRequest<AgentOutput, Model> | Promise<PipelineAgentRequest<AgentOutput, Model>>;\n suspension: \"reject\";\n};\n\nexport type PipelineExtractOptions<\n Input,\n Extracted,\n Model extends CompletionModel,\n> = PipelineStageMetadata &\n Omit<ExtractOptions<Extracted, Model>, \"text\" | \"abortSignal\"> & {\n text(context: PipelineStageContext<Input>): string | Promise<string>;\n };\n\ntype InternalPipelineOptions<Input, Output> = {\n [internalPipelineOptions]: {\n executor: PipelineExecutor<Input, Output>;\n state: PipelineState;\n };\n};\n\n/** Immutable, typed Pipeline with explicit stage and execution boundaries. */\nexport class Pipeline<Input, Output = Input> {\n readonly id: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly metadata: JsonObject | undefined;\n\n private readonly executor: PipelineExecutor<Input, Output>;\n private readonly state: PipelineState;\n\n constructor(options: PipelineOptions<Input, Output>);\n constructor(options: PipelineOptions<Input, Output> | InternalPipelineOptions<Input, Output>) {\n if (isInternalPipelineOptions(options)) {\n this.executor = options[internalPipelineOptions].executor;\n this.state = options[internalPipelineOptions].state;\n } else {\n const id = normalizePipelineId(options.id);\n if (!isZodSchema(options.inputSchema)) {\n throw new TypeError(\"Pipeline inputSchema must be a Zod schema.\");\n }\n const inputSchema = options.inputSchema;\n this.executor = (async (input, context) => {\n throwIfAborted(context.abortSignal);\n return inputSchema.parseAsync(input) as Promise<Output>;\n }) as PipelineExecutor<Input, Output>;\n this.state = initialPipelineState({\n id,\n name: options.name,\n description: options.description,\n metadata: options.metadata,\n });\n }\n\n const graph = this.state.graph;\n this.id = graph.id;\n this.name = graph.name;\n this.description = graph.description;\n this.metadata = graph.metadata;\n }\n\n step<Next>(options: PipelineStepOptions<Awaited<Output>, Next>): Pipeline<Input, Awaited<Next>> {\n const next = appendStageNode(this.state, \"step\", options);\n const executor = (async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, next.node.id];\n return (await runNode(context, next.node, path, () =>\n options.run(stageContext(value, context)),\n )) as Awaited<Next>;\n }) as PipelineExecutor<Input, Awaited<Next>>;\n return this.derive(executor, next.state);\n }\n\n compose<Next>(\n options: PipelineComposeOptions<Awaited<Output>, Next>,\n ): Pipeline<Input, Awaited<Next>> {\n const boundary = appendStageNode(this.state, \"pipeline\", options, {\n defaultLabel: options.pipeline.name ?? options.pipeline.id,\n pipelineId: options.pipeline.id,\n });\n const state = appendComposedGraph(boundary.state, boundary.node, options.pipeline.graph());\n const executor = (async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, boundary.node.id];\n return (await runNode(context, boundary.node, path, () =>\n options.pipeline.execute(value, context, path),\n )) as Awaited<Next>;\n }) as PipelineExecutor<Input, Awaited<Next>>;\n return this.derive(executor, state);\n }\n\n parallel<Branches extends Record<string, Pipeline<Awaited<Output>, unknown>>>(\n options: PipelineParallelOptions<Awaited<Output>, Branches>,\n ): Pipeline<Input, ParallelOutput<Branches>> {\n const branchEntries = normalizeParallelBranches(options.branches);\n if (branchEntries.length === 0) {\n throw new TypeError(\"Pipeline parallel branches must not be empty.\");\n }\n const parallel = appendStageNode(this.state, \"parallel\", options, {\n defaultLabel: `${branchEntries.length} parallel branches`,\n });\n let nextState = parallel.state;\n const branchNodes = new Map<string, PipelineGraphNode>();\n const terminalPaths: PipelineNodePath[] = [];\n for (const [key, branch] of branchEntries) {\n const appended = appendParallelBranch(nextState, parallel.node, key, branch.graph());\n nextState = appended.state;\n branchNodes.set(key, appended.node);\n terminalPaths.push(...appended.terminalPaths);\n }\n nextState = withTerminalPaths(nextState, terminalPaths);\n\n return this.derive<ParallelOutput<Branches>>(async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const parallelPath = [...pathPrefix, parallel.node.id];\n return runNode(context, parallel.node, parallelPath, async () => {\n const controller = new AbortController();\n const combined = combineAbortSignals(context.abortSignal, controller.signal);\n const branchContext = childContext(context, combined.signal);\n let firstError: unknown;\n const promises = branchEntries.map(async ([key, branch]) => {\n const node = branchNodes.get(key) as PipelineGraphNode;\n const path = [...parallelPath, node.id];\n try {\n const output = await runNode(branchContext, node, path, () =>\n branch.execute(value, branchContext, path),\n );\n return [key, output] as const;\n } catch (error) {\n if (firstError === undefined) firstError = error;\n if (!controller.signal.aborted) controller.abort(error);\n throw error;\n }\n });\n\n const settled = await Promise.allSettled(promises);\n combined.dispose();\n if (context.abortSignal?.aborted === true) {\n throw pipelineAbortError(context.abortSignal);\n }\n if (firstError !== undefined) throw firstError;\n return Object.fromEntries(\n settled.map(\n (result) => (result as PromiseFulfilledResult<readonly [string, unknown]>).value,\n ),\n ) as ParallelOutput<Branches>;\n });\n }, nextState);\n }\n\n agent<AgentOutput, Model extends CompletionModel>(\n options: PipelineAgentOptions<Awaited<Output>, AgentOutput, Model>,\n ): Pipeline<Input, AgentOutput> {\n if (options.suspension !== \"reject\") {\n throw new TypeError('Pipeline Agent stages require suspension: \"reject\".');\n }\n const next = appendStageNode(this.state, \"agent\", options, {\n defaultLabel: options.agent.name ?? options.agent.id,\n agentId: options.agent.id,\n agentName: options.agent.name,\n });\n return this.derive<AgentOutput>(async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, next.node.id];\n return runNode(context, next.node, path, async () => {\n const request = await options.request(stageContext(value, context));\n const response = await options.agent.generate({\n ...request,\n abortSignal: context.abortSignal,\n } as AgentRunOptions<AgentOutput, RawResponseOf<Model>>);\n if (response.type === \"interaction\") {\n throw new PipelineAgentSuspensionError(response);\n }\n if (response.type === \"blocked\") {\n throw new AgentRunBlockedError(response);\n }\n return response.output;\n });\n }, next.state);\n }\n\n extract<Extracted, Model extends CompletionModel>(\n options: PipelineExtractOptions<Awaited<Output>, Extracted, Model>,\n ): Pipeline<Input, Extracted> {\n const next = appendStageNode(this.state, \"extractor\", options);\n return this.derive<Extracted>(async (input, context, pathPrefix) => {\n const value = await this.execute(input, context, pathPrefix);\n const path = [...pathPrefix, next.node.id];\n return runNode(context, next.node, path, async () => {\n const text = await options.text(stageContext(value, context));\n const result = await extractData({\n model: options.model,\n text,\n outputSchema: options.outputSchema,\n instructions: options.instructions,\n retries: options.retries,\n temperature: options.temperature,\n maxTokens: options.maxTokens,\n providerOptions: options.providerOptions,\n abortSignal: context.abortSignal,\n });\n return result.output;\n });\n }, next.state);\n }\n\n async run(options: PipelineRunOptions<Input>): Promise<PipelineRunResult<Output>> {\n const runId = normalizeRunId(options.runId ?? globalThis.crypto.randomUUID());\n const context: PipelineRunContext = {\n runId,\n pipelineId: this.id,\n runMetadata: options.metadata,\n abortSignal: options.abortSignal,\n observer: options.observer,\n failOnObserverError: options.failOnObserverError === true,\n };\n throwIfAborted(context.abortSignal);\n const output = await this.execute(options.input, context, []);\n throwIfAborted(context.abortSignal);\n return { runId, output };\n }\n\n async runBatch(options: PipelineBatchOptions<Input>): Promise<Array<PipelineBatchItem<Output>>> {\n throwIfAborted(options.abortSignal);\n return mapWithConcurrency([...options.inputs], options.concurrency, async (input) => {\n const runId = globalThis.crypto.randomUUID();\n try {\n const result = await this.run({\n input,\n runId,\n metadata: options.metadata,\n abortSignal: options.abortSignal,\n observer: options.observer,\n failOnObserverError: options.failOnObserverError,\n });\n return { status: \"completed\", ...result } as const;\n } catch (error) {\n if (options.abortSignal?.aborted === true) {\n throw pipelineAbortError(options.abortSignal);\n }\n return { status: \"failed\", runId, error } as const;\n }\n });\n }\n\n graph(): PipelineGraph {\n return cloneGraph(withOutputNode(this.state));\n }\n\n private derive<DerivedOutput>(\n executor: PipelineExecutor<Input, DerivedOutput>,\n state: PipelineState,\n ): Pipeline<Input, DerivedOutput> {\n return createDerivedPipeline(executor, state);\n }\n\n private async execute(\n input: Input,\n context: PipelineRunContext,\n pathPrefix: PipelineNodePath,\n ): Promise<Awaited<Output>> {\n throwIfAborted(context.abortSignal);\n return (await this.executor(input, context, pathPrefix)) as Awaited<Output>;\n }\n}\n\nfunction createDerivedPipeline<Input, Output>(\n executor: PipelineExecutor<Input, Output>,\n state: PipelineState,\n): Pipeline<Input, Output> {\n const options: InternalPipelineOptions<Input, Output> = {\n [internalPipelineOptions]: { executor, state },\n };\n return new Pipeline<Input, Output>(options as unknown as PipelineOptions<Input, Output>);\n}\n\nfunction isInternalPipelineOptions<Input, Output>(\n options: PipelineOptions<Input, Output> | InternalPipelineOptions<Input, Output>,\n): options is InternalPipelineOptions<Input, Output> {\n return internalPipelineOptions in options;\n}\n\nfunction isZodSchema(value: unknown): value is z.ZodType {\n return value instanceof z.ZodType;\n}\n\nfunction normalizePipelineId(id: string): string {\n if (typeof id !== \"string\") {\n throw new TypeError(\"Pipeline id must be a string.\");\n }\n const normalized = id.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Pipeline id must be a non-empty string.\");\n }\n return normalized;\n}\n\nfunction normalizeRunId(runId: string): string {\n if (typeof runId !== \"string\") {\n throw new TypeError(\"Pipeline runId must be a string.\");\n }\n const normalized = runId.trim();\n if (normalized.length === 0) {\n throw new TypeError(\"Pipeline runId must be a non-empty string.\");\n }\n return normalized;\n}\n\nfunction normalizeParallelBranches<Branch>(\n branches: Readonly<Record<string, Branch>>,\n): Array<readonly [string, Branch]> {\n const entries: Array<readonly [string, Branch]> = [];\n const ids = new Set<string>();\n for (const key of Object.keys(branches)) {\n const pipeline = branches[key] as Branch;\n const id = key.trim();\n if (id.length === 0) {\n throw new TypeError(\"Pipeline parallel branch id must be a non-empty string.\");\n }\n if (ids.has(id)) {\n throw new TypeError(`Pipeline parallel branch id \"${id}\" is already registered.`);\n }\n ids.add(id);\n if (id !== key) {\n throw new TypeError(\"Pipeline parallel branch ids must not contain surrounding whitespace.\");\n }\n entries.push([id, pipeline]);\n }\n return entries;\n}\n","import type { JsonObject } from \"../completion\";\nimport type {\n PipelineGraph,\n PipelineGraphEdge,\n PipelineGraphNode,\n PipelineNodePath,\n PipelineStageKind,\n PipelineStageMetadata,\n PipelineState,\n} from \"./types\";\n\nconst INPUT_ID = \"$input\";\nconst OUTPUT_ID = \"$output\";\nconst RESERVED_STAGE_IDS = new Set([INPUT_ID, OUTPUT_ID]);\n\nexport function initialPipelineState(options: {\n id: string;\n name?: string | undefined;\n description?: string | undefined;\n metadata?: JsonObject | undefined;\n}): PipelineState {\n const input = graphNode(INPUT_ID, [INPUT_ID], \"input\", \"Input\");\n const graph: PipelineGraph = {\n id: options.id,\n nodes: [input],\n edges: [],\n };\n if (options.name !== undefined) graph.name = options.name;\n if (options.description !== undefined) graph.description = options.description;\n if (options.metadata !== undefined) graph.metadata = options.metadata;\n return {\n graph,\n terminalPaths: [input.path],\n stageIds: new Set(),\n nextEdgeIndex: 1,\n };\n}\n\nexport function appendStageNode(\n state: PipelineState,\n kind: PipelineStageKind,\n stage: PipelineStageMetadata,\n options: {\n defaultLabel?: string | undefined;\n agentId?: string | undefined;\n agentName?: string | undefined;\n pipelineId?: string | undefined;\n } = {},\n): { state: PipelineState; node: PipelineGraphNode } {\n const id = validateStageId(stage.id);\n if (state.stageIds.has(id)) {\n throw new TypeError(`Pipeline stage id \"${id}\" is already registered.`);\n }\n const node = graphNode(id, [id], kind, stage.name ?? options.defaultLabel ?? id, {\n description: stage.description,\n metadata: stage.metadata,\n agentId: options.agentId,\n agentName: options.agentName,\n pipelineId: options.pipelineId,\n });\n return {\n node,\n state: appendNode(state, node, state.terminalPaths, [node.path], id),\n };\n}\n\nexport function appendComposedGraph(\n state: PipelineState,\n boundary: PipelineGraphNode,\n child: PipelineGraph,\n): PipelineState {\n return appendChildGraph(state, boundary.path, child);\n}\n\nexport function appendParallelBranch(\n state: PipelineState,\n parallel: PipelineGraphNode,\n branchKey: string,\n child: PipelineGraph,\n): { state: PipelineState; node: PipelineGraphNode; terminalPaths: PipelineNodePath[] } {\n const id = validateStageId(branchKey);\n const path = [...parallel.path, id];\n const node = graphNode(id, path, \"branch\", id, { branchKey: id, pipelineId: child.id });\n const withBranch = appendNode(state, node, [parallel.path], state.terminalPaths);\n const withChild = appendChildGraph(withBranch, node.path, child);\n return { state: withChild, node, terminalPaths: withChild.terminalPaths };\n}\n\nexport function withTerminalPaths(\n state: PipelineState,\n terminalPaths: PipelineNodePath[],\n): PipelineState {\n return { ...state, terminalPaths };\n}\n\nexport function withOutputNode(state: PipelineState): PipelineGraph {\n const graph = cloneGraph(state.graph);\n const outputPath = [OUTPUT_ID];\n if (graph.nodes.some((node) => pathEquals(node.path, outputPath))) {\n return graph;\n }\n graph.nodes.push(graphNode(OUTPUT_ID, outputPath, \"output\", \"Output\"));\n graph.edges.push(\n ...state.terminalPaths.map((source, index) => ({\n id: `edge_${state.nextEdgeIndex + index}`,\n source: [...source],\n target: outputPath,\n })),\n );\n return graph;\n}\n\nexport function cloneGraph(graph: PipelineGraph): PipelineGraph {\n return {\n ...graph,\n nodes: graph.nodes.map((node) => ({ ...node, path: [...node.path] })),\n edges: graph.edges.map((edge) => ({\n ...edge,\n source: [...edge.source],\n target: [...edge.target],\n })),\n };\n}\n\nexport function scopedNode(node: PipelineGraphNode, path: PipelineNodePath): PipelineGraphNode {\n return { ...node, path: [...path] };\n}\n\nfunction appendChildGraph(\n state: PipelineState,\n parentPath: PipelineNodePath,\n child: PipelineGraph,\n): PipelineState {\n const childNodes = child.nodes\n .filter((node) => !isBoundaryPath(node.path))\n .map((node) => scopedNode(node, [...parentPath, ...node.path]));\n const childEdges: PipelineState[\"graph\"][\"edges\"] = [];\n const terminalPaths: PipelineNodePath[] = [];\n let nextEdgeIndex = state.nextEdgeIndex;\n\n for (const edge of child.edges) {\n const sourceIsInput = isInputPath(edge.source);\n const targetIsOutput = isOutputPath(edge.target);\n const source = sourceIsInput ? [...parentPath] : [...parentPath, ...edge.source];\n if (targetIsOutput) {\n terminalPaths.push(source);\n continue;\n }\n const target = [...parentPath, ...edge.target];\n let childEdge: PipelineGraphEdge = {\n id: `edge_${nextEdgeIndex}`,\n source,\n target,\n };\n if (edge.label !== undefined) childEdge = { ...childEdge, label: edge.label };\n childEdges.push(childEdge);\n nextEdgeIndex += 1;\n }\n\n return {\n ...state,\n graph: {\n ...state.graph,\n nodes: [...state.graph.nodes, ...childNodes],\n edges: [...state.graph.edges, ...childEdges],\n },\n terminalPaths: terminalPaths.length === 0 ? [[...parentPath]] : terminalPaths,\n nextEdgeIndex,\n };\n}\n\nfunction appendNode(\n state: PipelineState,\n node: PipelineGraphNode,\n sourcePaths: PipelineNodePath[],\n terminalPaths: PipelineNodePath[],\n stageId?: string,\n): PipelineState {\n const edges = sourcePaths.map((source, index) => ({\n id: `edge_${state.nextEdgeIndex + index}`,\n source: [...source],\n target: [...node.path],\n }));\n const stageIds = new Set(state.stageIds);\n if (stageId !== undefined) stageIds.add(stageId);\n return {\n graph: {\n ...state.graph,\n nodes: [...state.graph.nodes, node],\n edges: [...state.graph.edges, ...edges],\n },\n terminalPaths,\n stageIds,\n nextEdgeIndex: state.nextEdgeIndex + edges.length,\n };\n}\n\nfunction graphNode(\n id: string,\n path: PipelineNodePath,\n kind: PipelineStageKind,\n label: string,\n options: {\n description?: string | undefined;\n metadata?: JsonObject | undefined;\n agentId?: string | undefined;\n agentName?: string | undefined;\n pipelineId?: string | undefined;\n branchKey?: string | undefined;\n } = {},\n): PipelineGraphNode {\n const node: PipelineGraphNode = { id, path: [...path], kind, label };\n if (options.description !== undefined) node.description = options.description;\n if (options.metadata !== undefined) node.metadata = options.metadata;\n if (options.agentId !== undefined) node.agentId = options.agentId;\n if (options.agentName !== undefined) node.agentName = options.agentName;\n if (options.pipelineId !== undefined) node.pipelineId = options.pipelineId;\n if (options.branchKey !== undefined) node.branchKey = options.branchKey;\n return node;\n}\n\nfunction validateStageId(value: string): string {\n if (typeof value !== \"string\") {\n throw new TypeError(\"Pipeline stage id must be a string.\");\n }\n const id = value.trim();\n if (id.length === 0) {\n throw new TypeError(\"Pipeline stage id must be a non-empty string.\");\n }\n if (RESERVED_STAGE_IDS.has(id)) {\n throw new TypeError(`Pipeline stage id \"${id}\" is reserved.`);\n }\n return id;\n}\n\nfunction isBoundaryPath(path: PipelineNodePath): boolean {\n return isInputPath(path) || isOutputPath(path);\n}\n\nfunction isInputPath(path: PipelineNodePath): boolean {\n return path.length === 1 && path[0] === INPUT_ID;\n}\n\nfunction isOutputPath(path: PipelineNodePath): boolean {\n return path.length === 1 && path[0] === OUTPUT_ID;\n}\n\nfunction pathEquals(left: PipelineNodePath, right: PipelineNodePath): boolean {\n return left.length === right.length && left.every((segment, index) => segment === right[index]);\n}\n","import { abortError, throwIfAborted } from \"../internal/abort\";\nimport { scopedNode } from \"./graph\";\nimport type {\n PipelineGraphNode,\n PipelineNodePath,\n PipelineRunContext,\n PipelineRunEvent,\n PipelineStageContext,\n} from \"./types\";\n\nexport async function runNode<Output>(\n context: PipelineRunContext,\n node: PipelineGraphNode,\n path: PipelineNodePath,\n fn: () => Output | Promise<Output>,\n): Promise<Awaited<Output>> {\n throwIfAborted(context.abortSignal);\n const eventNode = scopedNode(node, path);\n const startedAt = Date.now();\n await emitEvent(context, {\n type: \"stage_started\",\n runId: context.runId,\n pipelineId: context.pipelineId,\n path: [...path],\n node: eventNode,\n });\n\n try {\n const output = (await fn()) as Awaited<Output>;\n throwIfAborted(context.abortSignal);\n await emitEvent(context, {\n type: \"stage_completed\",\n runId: context.runId,\n pipelineId: context.pipelineId,\n path: [...path],\n node: eventNode,\n durationMs: Date.now() - startedAt,\n });\n return output;\n } catch (error) {\n const failureEvent: PipelineRunEvent = {\n type: \"stage_failed\",\n runId: context.runId,\n pipelineId: context.pipelineId,\n path: [...path],\n node: eventNode,\n durationMs: Date.now() - startedAt,\n error,\n };\n try {\n await emitEvent(context, failureEvent);\n } catch (observerError) {\n throw new AggregateError(\n [error, observerError],\n `Pipeline stage \"${node.id}\" and its observer both failed.`,\n );\n }\n throw error;\n }\n}\n\nexport function stageContext<Input>(\n input: Input,\n context: PipelineRunContext,\n): PipelineStageContext<Input> {\n return {\n input,\n runId: context.runId,\n pipelineId: context.pipelineId,\n runMetadata: context.runMetadata,\n abortSignal: context.abortSignal,\n };\n}\n\nexport function childContext(\n context: PipelineRunContext,\n abortSignal: AbortSignal | undefined,\n): PipelineRunContext {\n return { ...context, abortSignal };\n}\n\nexport function combineAbortSignals(\n parent: AbortSignal | undefined,\n local: AbortSignal,\n): { signal: AbortSignal; dispose(): void } {\n const controller = new AbortController();\n const abortFromParent = () => controller.abort(parent?.reason);\n const abortFromLocal = () => controller.abort(local.reason);\n\n if (parent?.aborted === true) {\n controller.abort(parent.reason);\n } else if (local.aborted) {\n controller.abort(local.reason);\n } else {\n parent?.addEventListener(\"abort\", abortFromParent, { once: true });\n local.addEventListener(\"abort\", abortFromLocal, { once: true });\n }\n\n return {\n signal: controller.signal,\n dispose() {\n parent?.removeEventListener(\"abort\", abortFromParent);\n local.removeEventListener(\"abort\", abortFromLocal);\n },\n };\n}\n\nexport function pipelineAbortError(signal: AbortSignal | undefined): Error {\n return abortError(signal?.reason);\n}\n\nasync function emitEvent(context: PipelineRunContext, event: PipelineRunEvent): Promise<void> {\n if (context.observer === undefined) return;\n try {\n await context.observer.onEvent(event);\n } catch (error) {\n if (context.failOnObserverError) throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEO,IAAM,+BAAN,cAA2C,MAAM;AAAA,EACtD,YAAqB,QAAiC;AACpD,UAAM,uDAAuD;AAD1C;AAEnB,SAAK,OAAO;AAAA,EACd;AAAA,EAHqB;AAIvB;;;ACPA,SAAS,SAAS;;;ACWlB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,qBAAqB,oBAAI,IAAI,CAAC,UAAU,SAAS,CAAC;AAEjD,SAAS,qBAAqB,SAKnB;AAChB,QAAM,QAAQ,UAAU,UAAU,CAAC,QAAQ,GAAG,SAAS,OAAO;AAC9D,QAAM,QAAuB;AAAA,IAC3B,IAAI,QAAQ;AAAA,IACZ,OAAO,CAAC,KAAK;AAAA,IACb,OAAO,CAAC;AAAA,EACV;AACA,MAAI,QAAQ,SAAS,OAAW,OAAM,OAAO,QAAQ;AACrD,MAAI,QAAQ,gBAAgB,OAAW,OAAM,cAAc,QAAQ;AACnE,MAAI,QAAQ,aAAa,OAAW,OAAM,WAAW,QAAQ;AAC7D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,CAAC,MAAM,IAAI;AAAA,IAC1B,UAAU,oBAAI,IAA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