@anvia/core 0.26.0 → 1.0.0-rc.2

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 (162) hide show
  1. package/README.md +303 -94
  2. package/dist/agent/index.d.ts +36 -70
  3. package/dist/agent/index.js +25 -18
  4. package/dist/agent-yBG8e9Jj.d.ts +153 -0
  5. package/dist/chunk-4WI3VGZK.js +127 -0
  6. package/dist/chunk-4WI3VGZK.js.map +1 -0
  7. package/dist/chunk-77AIYARB.js +654 -0
  8. package/dist/chunk-77AIYARB.js.map +1 -0
  9. package/dist/chunk-AI5JMUW7.js +45 -0
  10. package/dist/chunk-AI5JMUW7.js.map +1 -0
  11. package/dist/chunk-BEYBU7VJ.js +53 -0
  12. package/dist/chunk-BEYBU7VJ.js.map +1 -0
  13. package/dist/chunk-CWM7B2OO.js +315 -0
  14. package/dist/chunk-CWM7B2OO.js.map +1 -0
  15. package/dist/chunk-D37WMSP6.js +131 -0
  16. package/dist/chunk-D37WMSP6.js.map +1 -0
  17. package/dist/chunk-DBSCKTUL.js +3793 -0
  18. package/dist/chunk-DBSCKTUL.js.map +1 -0
  19. package/dist/chunk-EINTGEGY.js +629 -0
  20. package/dist/chunk-EINTGEGY.js.map +1 -0
  21. package/dist/chunk-FMHLROPQ.js +351 -0
  22. package/dist/chunk-FMHLROPQ.js.map +1 -0
  23. package/dist/chunk-FN7HLLAZ.js +211 -0
  24. package/dist/chunk-FN7HLLAZ.js.map +1 -0
  25. package/dist/chunk-GKDERULJ.js +50 -0
  26. package/dist/chunk-GKDERULJ.js.map +1 -0
  27. package/dist/{chunk-CWUJUSOS.js → chunk-KIDGIJM7.js} +26 -5
  28. package/dist/chunk-KIDGIJM7.js.map +1 -0
  29. package/dist/chunk-KR3RCCHJ.js +500 -0
  30. package/dist/chunk-KR3RCCHJ.js.map +1 -0
  31. package/dist/chunk-MGNTXGTX.js +37 -0
  32. package/dist/chunk-MGNTXGTX.js.map +1 -0
  33. package/dist/{chunk-MRQLEK2B.js → chunk-OJH6HWHX.js} +63 -51
  34. package/dist/chunk-OJH6HWHX.js.map +1 -0
  35. package/dist/chunk-QOUPWOGW.js +29 -0
  36. package/dist/chunk-QOUPWOGW.js.map +1 -0
  37. package/dist/chunk-TIZYTPJO.js +208 -0
  38. package/dist/chunk-TIZYTPJO.js.map +1 -0
  39. package/dist/{chunk-NCPN4SJR.js → chunk-XKYYBABH.js} +13 -13
  40. package/dist/chunk-XKYYBABH.js.map +1 -0
  41. package/dist/client-B8DT1vUG.d.ts +83 -0
  42. package/dist/completion/index.d.ts +6 -36
  43. package/dist/completion/index.js +25 -29
  44. package/dist/dynamic-tools-KwEGRbHp.d.ts +45 -0
  45. package/dist/embeddings/index.d.ts +11 -9
  46. package/dist/embeddings/index.js +2 -4
  47. package/dist/evals/index.d.ts +47 -20
  48. package/dist/evals/index.js +104 -65
  49. package/dist/evals/index.js.map +1 -1
  50. package/dist/extractor/index.d.ts +27 -42
  51. package/dist/extractor/index.js +7 -22
  52. package/dist/guardrails/index.d.ts +3 -2
  53. package/dist/guardrails/index.js +1 -1
  54. package/dist/image-generation/index.d.ts +23 -23
  55. package/dist/image-generation/index.js +5 -39
  56. package/dist/image-generation/index.js.map +1 -1
  57. package/dist/index.d.ts +25 -20
  58. package/dist/index.js +60 -63
  59. package/dist/internal/agent.d.ts +163 -9
  60. package/dist/internal/agent.js +25 -18
  61. package/dist/loaders/index.d.ts +6 -10
  62. package/dist/loaders/index.js.map +1 -1
  63. package/dist/mcp/index.d.ts +19 -13
  64. package/dist/mcp/index.js +13 -348
  65. package/dist/mcp/index.js.map +1 -1
  66. package/dist/memory/index.d.ts +20 -6
  67. package/dist/memory/index.js +9 -10
  68. package/dist/message-schema-Cn7ezRfJ.d.ts +52 -0
  69. package/dist/middleware-C7PdmKF7.d.ts +56 -0
  70. package/dist/model-call-options-CZkSw_xN.d.ts +6 -0
  71. package/dist/model-listing/index.d.ts +3 -1
  72. package/dist/observability/index.d.ts +20 -3
  73. package/dist/observability/index.js +8 -5
  74. package/dist/observability/index.js.map +1 -1
  75. package/dist/pipeline/index.d.ts +114 -72
  76. package/dist/pipeline/index.js +478 -286
  77. package/dist/pipeline/index.js.map +1 -1
  78. package/dist/retry-CjvSlKGW.d.ts +16 -0
  79. package/dist/skills/index.d.ts +5 -4
  80. package/dist/skills/index.js +7 -8
  81. package/dist/speech-generation/index.d.ts +37 -0
  82. package/dist/speech-generation/index.js +8 -0
  83. package/dist/streaming/index.js +37 -3
  84. package/dist/streaming/index.js.map +1 -1
  85. package/dist/{think-tool-DfCMuO8e.d.ts → think-tool-6H2QNQzQ.d.ts} +5 -5
  86. package/dist/tool/index.d.ts +10 -6
  87. package/dist/tool/index.js +15 -21
  88. package/dist/tool--Mz4v1eL.d.ts +57 -0
  89. package/dist/transcription/index.d.ts +29 -22
  90. package/dist/transcription/index.js +5 -57
  91. package/dist/transcription/index.js.map +1 -1
  92. package/dist/type-utils-CtHVDRn_.d.ts +6 -0
  93. package/dist/types-3x3mOLHU.d.ts +379 -0
  94. package/dist/types-BVzM4RsC.d.ts +155 -0
  95. package/dist/types-CQ_ioXWK.d.ts +319 -0
  96. package/dist/types-Cr4uiYo5.d.ts +99 -0
  97. package/dist/{types-04LqWrmy.d.ts → types-DiJqJejp.d.ts} +1 -1
  98. package/dist/types-Dld1TpWj.d.ts +130 -0
  99. package/dist/vector-store/index.d.ts +33 -34
  100. package/dist/vector-store/index.js +6 -6
  101. package/package.json +6 -18
  102. package/dist/agent-x3YTyv5i.d.ts +0 -222
  103. package/dist/audio-generation/index.d.ts +0 -33
  104. package/dist/audio-generation/index.js +0 -42
  105. package/dist/audio-generation/index.js.map +0 -1
  106. package/dist/chunk-2ODTMRHP.js +0 -54
  107. package/dist/chunk-2ODTMRHP.js.map +0 -1
  108. package/dist/chunk-ADH7NNCS.js +0 -512
  109. package/dist/chunk-ADH7NNCS.js.map +0 -1
  110. package/dist/chunk-BALBBVI3.js +0 -2732
  111. package/dist/chunk-BALBBVI3.js.map +0 -1
  112. package/dist/chunk-CWUJUSOS.js.map +0 -1
  113. package/dist/chunk-DALYP4PX.js +0 -225
  114. package/dist/chunk-DALYP4PX.js.map +0 -1
  115. package/dist/chunk-HYUYZEAJ.js +0 -223
  116. package/dist/chunk-HYUYZEAJ.js.map +0 -1
  117. package/dist/chunk-I6XOQ4LK.js +0 -466
  118. package/dist/chunk-I6XOQ4LK.js.map +0 -1
  119. package/dist/chunk-JI5YZWNT.js +0 -220
  120. package/dist/chunk-JI5YZWNT.js.map +0 -1
  121. package/dist/chunk-MC3CCKEB.js +0 -221
  122. package/dist/chunk-MC3CCKEB.js.map +0 -1
  123. package/dist/chunk-MELYDKWQ.js +0 -337
  124. package/dist/chunk-MELYDKWQ.js.map +0 -1
  125. package/dist/chunk-MNWK2USR.js +0 -243
  126. package/dist/chunk-MNWK2USR.js.map +0 -1
  127. package/dist/chunk-MRQLEK2B.js.map +0 -1
  128. package/dist/chunk-NCPN4SJR.js.map +0 -1
  129. package/dist/chunk-OIMLU4SF.js +0 -20
  130. package/dist/chunk-OIMLU4SF.js.map +0 -1
  131. package/dist/chunk-Q25IWLBT.js +0 -138
  132. package/dist/chunk-Q25IWLBT.js.map +0 -1
  133. package/dist/chunk-UQX6EXWG.js +0 -33
  134. package/dist/chunk-UQX6EXWG.js.map +0 -1
  135. package/dist/chunk-WQKHFADH.js +0 -12
  136. package/dist/chunk-WQKHFADH.js.map +0 -1
  137. package/dist/chunk-XUUY2L2D.js +0 -42
  138. package/dist/chunk-XUUY2L2D.js.map +0 -1
  139. package/dist/chunk-XWUC7CIT.js +0 -1
  140. package/dist/chunk-XWUC7CIT.js.map +0 -1
  141. package/dist/chunk-YLMDBQO4.js +0 -141
  142. package/dist/chunk-YLMDBQO4.js.map +0 -1
  143. package/dist/errors-2moLDuuN.d.ts +0 -17
  144. package/dist/hooks/index.d.ts +0 -12
  145. package/dist/hooks/index.js +0 -17
  146. package/dist/index-BxSbmOMr.d.ts +0 -257
  147. package/dist/json-BVPssigK.d.ts +0 -39
  148. package/dist/middleware-Dp3d_pxi.d.ts +0 -90
  149. package/dist/request/index.d.ts +0 -28
  150. package/dist/request/index.js +0 -25
  151. package/dist/request/index.js.map +0 -1
  152. package/dist/tool-Cohdv5GC.d.ts +0 -65
  153. package/dist/types-BCTRUGex.d.ts +0 -47
  154. package/dist/types-BrLbKnEz.d.ts +0 -119
  155. package/dist/types-D9JpeAPF.d.ts +0 -114
  156. package/dist/types-G12i56s2.d.ts +0 -354
  157. package/dist/types-JJCxRnaZ.d.ts +0 -70
  158. package/dist/types-O-abTIin.d.ts +0 -79
  159. package/dist/ui/index.d.ts +0 -107
  160. package/dist/ui/index.js +0 -10
  161. package/dist/ui/index.js.map +0 -1
  162. /package/dist/{hooks → speech-generation}/index.js.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/observability/types.ts"],"sourcesContent":["import type {\n CompletionModelCapabilities,\n CompletionRequest,\n CompletionResponse,\n CompletionSource,\n JsonObject,\n JsonValue,\n Message,\n ProviderToolCall,\n ToolCall,\n ToolDefinition,\n ToolResultContent,\n Usage,\n} from \"../completion\";\nimport type { AgentDeltaEvent } from \"../request/types\";\nimport type { ToolCallStreamEvent } from \"../tool\";\n\nexport type AgentTraceInfo = {\n traceId?: string | undefined;\n observationId?: string | undefined;\n};\n\nexport type AgentTraceOptions = {\n name?: string | undefined;\n userId?: string | undefined;\n sessionId?: string | undefined;\n metadata?: Record<string, unknown> | undefined;\n tags?: string[] | undefined;\n version?: string | undefined;\n traceId?: string | undefined;\n failOnObserverError?: boolean | undefined;\n promptRef?: AgentRunPromptRef | undefined;\n};\n\nexport type AgentRunPromptRef = {\n name: string;\n version?: number | undefined;\n};\n\nexport type AgentRunStartArgs = {\n agentName?: string | undefined;\n agentDescription?: string | undefined;\n instructions?: string | undefined;\n trace?: AgentTraceOptions | undefined;\n prompt: Message;\n promptRef?: AgentRunPromptRef | undefined;\n history: Message[];\n maxTurns: number;\n};\n\nexport type AgentRunEndArgs = {\n output: string;\n usage: Usage;\n messages: Message[];\n sources?: CompletionSource[] | undefined;\n providerToolCalls?: ProviderToolCall[] | undefined;\n};\n\nexport type AgentRunErrorArgs = {\n error: unknown;\n usage: Usage;\n messages: Message[];\n};\n\nexport type AgentGenerationModelInfo = {\n provider: string;\n defaultModel: string;\n capabilities?: CompletionModelCapabilities | undefined;\n};\n\nexport type AgentGenerationStartArgs = {\n turn: number;\n request: CompletionRequest;\n providerRequest?: JsonObject | undefined;\n modelInfo?: AgentGenerationModelInfo | undefined;\n};\n\nexport type AgentGenerationEndArgs<RawResponse = unknown> = {\n turn: number;\n response: CompletionResponse<RawResponse>;\n firstDeltaMs?: number | undefined;\n};\n\nexport type AgentGenerationErrorArgs = {\n turn: number;\n error: unknown;\n};\n\nexport type AgentGenerationUpdateArgs = {\n turn: number;\n delta: AgentDeltaEvent;\n};\n\nexport type AgentRunEventArgs = {\n name: string;\n attributes?: Record<string, JsonValue | undefined> | undefined;\n level?: \"DEFAULT\" | \"WARNING\" | \"ERROR\" | undefined;\n timestamp?: Date | string | undefined;\n};\n\nexport type AgentToolStartArgs = {\n turn: number;\n toolCall: ToolCall;\n toolName: string;\n args: string;\n internalCallId: string;\n toolCallId?: string | undefined;\n toolDefinition?: ToolDefinition | undefined;\n toolMetadata?: JsonObject | undefined;\n};\n\nexport type AgentToolEndArgs = AgentToolStartArgs & {\n result: string;\n structuredResult?: ToolResultContent[] | undefined;\n skipped: boolean;\n};\n\nexport type AgentToolErrorArgs = AgentToolStartArgs & {\n error: unknown;\n};\n\nexport type AgentToolStreamEventArgs = AgentToolStartArgs & {\n event: ToolCallStreamEvent;\n};\n\nexport interface AgentGenerationObserver {\n end(args: AgentGenerationEndArgs): void | Promise<void>;\n error?(args: AgentGenerationErrorArgs): void | Promise<void>;\n update?(args: AgentGenerationUpdateArgs): void | Promise<void>;\n}\n\nexport interface AgentToolObserver {\n streamEvent?(args: AgentToolStreamEventArgs): void | Promise<void>;\n end(args: AgentToolEndArgs): void | Promise<void>;\n error?(args: AgentToolErrorArgs): void | Promise<void>;\n}\n\nexport interface AgentRunObserver {\n readonly trace?: AgentTraceInfo | undefined;\n startGeneration?(\n args: AgentGenerationStartArgs,\n ): AgentGenerationObserver | undefined | Promise<AgentGenerationObserver | undefined>;\n startTool?(\n args: AgentToolStartArgs,\n ): AgentToolObserver | undefined | Promise<AgentToolObserver | undefined>;\n end(args: AgentRunEndArgs): void | Promise<void>;\n error?(args: AgentRunErrorArgs): void | Promise<void>;\n event?(args: AgentRunEventArgs): void | Promise<void>;\n}\n\nexport interface AgentObserver {\n startRun(\n args: AgentRunStartArgs,\n ): AgentRunObserver | undefined | Promise<AgentRunObserver | undefined>;\n flush?(): void | Promise<void>;\n shutdown?(): void | Promise<void>;\n}\n\nexport type AgentObserverRegistration = {\n observer: AgentObserver;\n failOnObserverError?: boolean | undefined;\n};\n\nexport type ObserveOptions = {\n failOnObserverError?: boolean | undefined;\n};\n\nexport function createObserver(observer: AgentObserver): AgentObserver {\n return observer;\n}\n"],"mappings":";AAuKO,SAAS,eAAe,UAAwC;AACrE,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,44 +1,63 @@
1
+ import { b as AgentApprovalRequiredResult, i as AgentInput, p as AgentRunSettings } from '../types-3x3mOLHU.js';
2
+ import { A as Agent } from '../agent-yBG8e9Jj.js';
3
+ import { J as JsonObject, C as CompletionModel } from '../types-CQ_ioXWK.js';
4
+ import { ExtractOptions } from '../extractor/index.js';
1
5
  import { z } from 'zod';
2
- import { A as Agent } from '../agent-x3YTyv5i.js';
3
- import { J as JsonObject, C as CompletionModel } from '../types-G12i56s2.js';
4
- import { Extractor } from '../extractor/index.js';
6
+ import '../retry-CjvSlKGW.js';
5
7
  import '../guardrails/index.js';
6
- import '../types-D9JpeAPF.js';
7
- import '../types-BrLbKnEz.js';
8
- import '../index-BxSbmOMr.js';
9
- import '../tool-Cohdv5GC.js';
10
- import '../middleware-Dp3d_pxi.js';
11
- import '../types-BCTRUGex.js';
12
- import '../types-O-abTIin.js';
8
+ import '../type-utils-CtHVDRn_.js';
9
+ import '../model-call-options-CZkSw_xN.js';
10
+ import '../types-BVzM4RsC.js';
11
+ import '../tool--Mz4v1eL.js';
12
+ import '../middleware-C7PdmKF7.js';
13
13
  import '../zod-schema-C7F4clpm.js';
14
+ import '../client-B8DT1vUG.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';
20
+ import '../types-DiJqJejp.js';
21
+ import '../dynamic-tools-KwEGRbHp.js';
22
+ import '../types-Cr4uiYo5.js';
23
+ import '../types-Dld1TpWj.js';
14
24
 
15
- /** Minimal interface for anything that can run as a pipeline stage. */
16
- interface PipelineOp<Input = unknown, Output = unknown> {
17
- run(input: Input): Output | Promise<Output>;
25
+ declare class PipelineAgentApprovalError extends Error {
26
+ readonly result: AgentApprovalRequiredResult;
27
+ constructor(result: AgentApprovalRequiredResult);
18
28
  }
19
- interface PipelineBatchOptions {
20
- /** Maximum number of inputs processed at the same time. */
21
- concurrency: number;
22
- }
23
- type AwaitedOutput<Op> = Op extends PipelineOp<unknown, infer Output> ? Awaited<Output> : never;
24
- type ParallelOutput<Branches extends Record<string, PipelineOp<unknown, unknown>>> = {
25
- [Key in keyof Branches]: AwaitedOutput<Branches[Key]>;
26
- };
29
+
27
30
  type PipelineMetadata = {
28
31
  id?: string | undefined;
29
32
  name?: string | undefined;
30
33
  description?: string | undefined;
31
34
  metadata?: JsonObject | undefined;
32
35
  };
36
+ type PipelineOptions<Input, Parsed = Input> = {
37
+ id: string;
38
+ inputSchema: z.ZodType<Parsed, Input>;
39
+ name?: string | undefined;
40
+ description?: string | undefined;
41
+ metadata?: JsonObject | undefined;
42
+ };
33
43
  type PipelineStageMetadata = {
34
- id?: string | undefined;
44
+ id: string;
35
45
  name?: string | undefined;
36
46
  description?: string | undefined;
37
47
  metadata?: JsonObject | undefined;
38
48
  };
49
+ type PipelineStageContext<Input> = {
50
+ input: Input;
51
+ runId: string;
52
+ pipelineId: string;
53
+ runMetadata?: JsonObject | undefined;
54
+ abortSignal?: AbortSignal | undefined;
55
+ };
39
56
  type PipelineStageKind = "input" | "step" | "pipeline" | "parallel" | "branch" | "agent" | "extractor" | "output";
57
+ type PipelineNodePath = readonly string[];
40
58
  type PipelineGraphNode = {
41
59
  id: string;
60
+ path: PipelineNodePath;
42
61
  kind: PipelineStageKind;
43
62
  label: string;
44
63
  description?: string | undefined;
@@ -50,8 +69,8 @@ type PipelineGraphNode = {
50
69
  };
51
70
  type PipelineGraphEdge = {
52
71
  id: string;
53
- source: string;
54
- target: string;
72
+ source: PipelineNodePath;
73
+ target: PipelineNodePath;
55
74
  label?: string | undefined;
56
75
  };
57
76
  type PipelineGraph = PipelineMetadata & {
@@ -59,74 +78,97 @@ type PipelineGraph = PipelineMetadata & {
59
78
  nodes: PipelineGraphNode[];
60
79
  edges: PipelineGraphEdge[];
61
80
  };
62
- type PipelineRunEvent = {
63
- type: "stage_started";
81
+ type PipelineRunEventBase = {
82
+ runId: string;
83
+ pipelineId: string;
84
+ path: PipelineNodePath;
64
85
  node: PipelineGraphNode;
65
- } | {
86
+ };
87
+ type PipelineRunEvent = (PipelineRunEventBase & {
88
+ type: "stage_started";
89
+ }) | (PipelineRunEventBase & {
66
90
  type: "stage_completed";
67
- node: PipelineGraphNode;
68
91
  durationMs: number;
69
- } | {
92
+ }) | (PipelineRunEventBase & {
70
93
  type: "stage_failed";
71
- node: PipelineGraphNode;
72
94
  durationMs: number;
73
95
  error: unknown;
74
- };
96
+ });
75
97
  type PipelineRunObserver = {
76
98
  onEvent(event: PipelineRunEvent): void | Promise<void>;
77
99
  };
78
- type PipelineRunOptions = {
100
+ type PipelineRunOptions<Input> = {
101
+ input: Input;
102
+ runId?: string | undefined;
103
+ metadata?: JsonObject | undefined;
104
+ abortSignal?: AbortSignal | undefined;
79
105
  observer?: PipelineRunObserver | undefined;
106
+ failOnObserverError?: boolean | undefined;
107
+ };
108
+ type PipelineRunResult<Output> = {
109
+ runId: string;
110
+ output: Awaited<Output>;
80
111
  };
81
- type PipelineRunContext = {
112
+ type PipelineBatchOptions<Input> = {
113
+ inputs: Iterable<Input>;
114
+ concurrency: number;
115
+ metadata?: JsonObject | undefined;
116
+ abortSignal?: AbortSignal | undefined;
82
117
  observer?: PipelineRunObserver | undefined;
118
+ failOnObserverError?: boolean | undefined;
83
119
  };
84
- type PipelineExecutor<Input, Output> = (input: Input, context: PipelineRunContext) => Output | Promise<Output>;
85
- type PipelineBuilderState = {
86
- graph: PipelineGraph;
87
- terminalNodeId: string;
88
- terminalNodeIds: string[];
89
- nextNodeIndex: number;
90
- nextEdgeIndex: number;
120
+ type PipelineBatchItem<Output> = {
121
+ status: "completed";
122
+ runId: string;
123
+ output: Awaited<Output>;
124
+ } | {
125
+ status: "failed";
126
+ runId: string;
127
+ error: unknown;
128
+ };
129
+ type PipelineOutput<Value> = Value extends Pipeline<infer _Input, infer Output> ? Awaited<Output> : never;
130
+ type ParallelOutput<Branches extends Record<string, unknown>> = {
131
+ [Key in keyof Branches]: PipelineOutput<Branches[Key]>;
91
132
  };
92
133
 
93
- /** Runnable pipeline returned by `PipelineBuilder.build()`. */
94
- declare class Pipeline<Input, Output> implements PipelineOp<Input, Awaited<Output>> {
95
- private readonly executor;
96
- private readonly pipelineGraph;
134
+ type RawResponseOf<Model> = Model extends CompletionModel<infer RawResponse> ? RawResponse : unknown;
135
+ type PipelineAgentRequest<Output, Model extends CompletionModel> = AgentInput & Omit<AgentRunSettings<Output, RawResponseOf<Model>>, "abortSignal">;
136
+ type PipelineStepOptions<Input, Output> = PipelineStageMetadata & {
137
+ run(context: PipelineStageContext<Input>): Output | Promise<Output>;
138
+ };
139
+ type PipelineComposeOptions<Input, Output> = PipelineStageMetadata & {
140
+ pipeline: Pipeline<Input, Output>;
141
+ };
142
+ type PipelineParallelOptions<Input, Branches extends Record<string, Pipeline<Input, unknown>>> = PipelineStageMetadata & {
143
+ branches: Branches;
144
+ };
145
+ type PipelineAgentOptions<Input, AgentOutput, Model extends CompletionModel> = PipelineStageMetadata & {
146
+ agent: Agent<AgentOutput, Model>;
147
+ request(context: PipelineStageContext<Input>): PipelineAgentRequest<AgentOutput, Model> | Promise<PipelineAgentRequest<AgentOutput, Model>>;
148
+ approval: "reject";
149
+ };
150
+ type PipelineExtractOptions<Input, Extracted, Model extends CompletionModel> = PipelineStageMetadata & Omit<ExtractOptions<Extracted, Model>, "text" | "abortSignal"> & {
151
+ text(context: PipelineStageContext<Input>): string | Promise<string>;
152
+ };
153
+ /** Immutable, typed Pipeline with explicit stage and execution boundaries. */
154
+ declare class Pipeline<Input, Output = Input> {
97
155
  readonly id: string;
98
156
  readonly name: string | undefined;
99
157
  readonly description: string | undefined;
100
158
  readonly metadata: JsonObject | undefined;
101
- constructor(executor: PipelineExecutor<Input, Output>, pipelineGraph?: PipelineGraph);
102
- /** Run one input through the built pipeline and return the final stage output. */
103
- run(input: Input, options?: PipelineRunOptions): Promise<Awaited<Output>>;
104
- /** Run many inputs through the same pipeline with bounded concurrency. */
105
- batch<I extends Iterable<Input>>(inputs: I, options: PipelineBatchOptions): Promise<Array<Awaited<Output>>>;
106
- graph(): PipelineGraph;
107
- }
108
-
109
- /** Builds a typed pipeline from an original input type to an inferred output type. */
110
- declare class PipelineBuilder<Input, Output = Input> {
111
159
  private readonly executor;
112
160
  private readonly state;
113
- constructor(schema: z.ZodType<Output, Input>);
114
- constructor(schema: z.ZodType<Output, Input>, metadata: PipelineMetadata);
115
- constructor(executor: (input: Input) => Output | Promise<Output>);
116
- constructor(executor: PipelineExecutor<Input, Output>, state: PipelineBuilderState);
117
- /** Add a synchronous or asynchronous transform stage. */
118
- step<Next>(fn: (input: Awaited<Output>) => Next | Promise<Next>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, Awaited<Next>>;
119
- /** Compose another pipeline operation after the current stage. */
120
- use<Next>(op: PipelineOp<Awaited<Output>, Next>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, Awaited<Next>>;
121
- /** Run named branch operations concurrently from the current value. */
122
- parallel<Branches extends Record<string, PipelineOp<Awaited<Output>, unknown>>>(branches: Branches, metadata?: PipelineStageMetadata): PipelineBuilder<Input, ParallelOutput<Branches>>;
123
- /** Send the current value to an agent as text and continue with the agent output. */
124
- prompt(agent: Agent<CompletionModel>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, string>;
125
- /** Send the current value to an extractor as text and continue with typed schema data. */
126
- extract<T>(extractor: Extractor<T, CompletionModel>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, T>;
127
- /** Finish the builder and return a runnable pipeline. */
128
- build(): Pipeline<Input, Awaited<Output>>;
129
- private runStep;
161
+ constructor(options: PipelineOptions<Input, Output>);
162
+ step<Next>(options: PipelineStepOptions<Awaited<Output>, Next>): Pipeline<Input, Awaited<Next>>;
163
+ compose<Next>(options: PipelineComposeOptions<Awaited<Output>, Next>): Pipeline<Input, Awaited<Next>>;
164
+ parallel<Branches extends Record<string, Pipeline<Awaited<Output>, unknown>>>(options: PipelineParallelOptions<Awaited<Output>, Branches>): Pipeline<Input, ParallelOutput<Branches>>;
165
+ agent<AgentOutput, Model extends CompletionModel>(options: PipelineAgentOptions<Awaited<Output>, AgentOutput, Model>): Pipeline<Input, AgentOutput>;
166
+ extract<Extracted, Model extends CompletionModel>(options: PipelineExtractOptions<Awaited<Output>, Extracted, Model>): Pipeline<Input, Extracted>;
167
+ run(options: PipelineRunOptions<Input>): Promise<PipelineRunResult<Output>>;
168
+ runBatch(options: PipelineBatchOptions<Input>): Promise<Array<PipelineBatchItem<Output>>>;
169
+ graph(): PipelineGraph;
170
+ private derive;
171
+ private execute;
130
172
  }
131
173
 
132
- export { Pipeline, type PipelineBatchOptions, PipelineBuilder, type PipelineGraph, type PipelineGraphEdge, type PipelineGraphNode, type PipelineMetadata, type PipelineOp, type PipelineRunEvent, type PipelineRunObserver, type PipelineRunOptions, type PipelineStageKind, type PipelineStageMetadata };
174
+ export { type ParallelOutput, Pipeline, PipelineAgentApprovalError, type PipelineAgentOptions, type PipelineBatchItem, type PipelineBatchOptions, type PipelineComposeOptions, type PipelineExtractOptions, type PipelineGraph, type PipelineGraphEdge, type PipelineGraphNode, type PipelineMetadata, type PipelineNodePath, type PipelineOptions, type PipelineParallelOptions, type PipelineRunEvent, type PipelineRunObserver, type PipelineRunOptions, type PipelineRunResult, type PipelineStageContext, type PipelineStageKind, type PipelineStageMetadata, type PipelineStepOptions };