@anvia/core 1.0.0-rc.4 → 1.0.0-rc.6
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.
- package/README.md +46 -3
- package/dist/agent/index.d.ts +41 -13
- package/dist/agent/index.js +17 -27
- package/dist/{interactions-csssHYcN.d.ts → agent/interactions/index.d.ts} +3 -55
- package/dist/agent/interactions/index.js +20 -0
- package/dist/agent/interactions/index.js.map +1 -0
- package/dist/{agent-CXScUOpX.d.ts → agent-BK3jud9q.d.ts} +10 -10
- package/dist/{chunk-VKYZZXP5.js → chunk-7O45T5F2.js} +2 -2
- package/dist/{chunk-AI5JMUW7.js → chunk-7OCVDT2X.js} +2 -2
- package/dist/{chunk-FXAIYTRE.js → chunk-7YAH2F3J.js} +3 -3
- package/dist/{chunk-RFHQY2IO.js → chunk-BAEFBTOW.js} +2 -2
- package/dist/chunk-BEU6FCTN.js +164 -0
- package/dist/chunk-BEU6FCTN.js.map +1 -0
- package/dist/{chunk-ZCPOIDAQ.js → chunk-BOCJCECN.js} +4 -4
- package/dist/{chunk-PK5LKOFL.js → chunk-G5OACQEI.js} +4 -66
- package/dist/chunk-G5OACQEI.js.map +1 -0
- package/dist/{chunk-GQL5KRAH.js → chunk-H7BI3BSP.js} +2 -2
- package/dist/{chunk-D2ECOWN5.js → chunk-HT4P3SSG.js} +66 -8
- package/dist/chunk-HT4P3SSG.js.map +1 -0
- package/dist/{chunk-BEYBU7VJ.js → chunk-HVHTVGPP.js} +2 -2
- package/dist/{chunk-J2W63PJI.js → chunk-JXZTTNCR.js} +3 -3
- package/dist/{chunk-KFR4CDGK.js → chunk-QXQQ2DBM.js} +2 -2
- package/dist/{chunk-5GXSQYQT.js → chunk-QXSVVYQK.js} +324 -191
- package/dist/chunk-QXSVVYQK.js.map +1 -0
- package/dist/{chunk-XYTPYUGB.js → chunk-RZDI7B6Z.js} +7 -5
- package/dist/{chunk-XYTPYUGB.js.map → chunk-RZDI7B6Z.js.map} +1 -1
- package/dist/chunk-SROQA7I7.js +69 -0
- package/dist/chunk-SROQA7I7.js.map +1 -0
- package/dist/{chunk-FN7HLLAZ.js → chunk-UBE4WH6G.js} +2 -1
- package/dist/chunk-UBE4WH6G.js.map +1 -0
- package/dist/{chunk-TRQ3XRFD.js → chunk-VGJRXUPT.js} +33 -1
- package/dist/chunk-VGJRXUPT.js.map +1 -0
- package/dist/{chunk-GKDERULJ.js → chunk-YXLDR2O4.js} +2 -2
- package/dist/{client-DvUatElp.d.ts → client-BdQ_QZsY.d.ts} +2 -2
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +8 -4
- package/dist/{dynamic-tools-AEBOTgu1.d.ts → dynamic-tools--Aw37H9d.d.ts} +3 -3
- package/dist/embeddings/index.js +2 -2
- package/dist/evals/index.d.ts +8 -7
- package/dist/evals/index.js +7 -6
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.d.ts +1 -1
- package/dist/extractor/index.js +5 -4
- package/dist/guardrails/index.d.ts +4 -4
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/image-generation/index.js +2 -2
- package/dist/index.d.ts +17 -16
- package/dist/index.js +24 -29
- package/dist/internal/agent.d.ts +12 -11
- package/dist/internal/agent.js +13 -11
- package/dist/internal/agent.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.js +7 -6
- package/dist/memory/index.d.ts +3 -3
- package/dist/memory/index.js +5 -4
- package/dist/{message-schema-B2M7AYzR.d.ts → message-schema-_sP_RKhh.d.ts} +18 -2
- package/dist/middleware-QZsbz7Hf.d.ts +56 -0
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +5 -4
- package/dist/pipeline/index.d.ts +13 -12
- package/dist/pipeline/index.js +6 -5
- package/dist/pipeline/index.js.map +1 -1
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +7 -6
- package/dist/speech-generation/index.d.ts +1 -1
- package/dist/speech-generation/index.js +2 -2
- package/dist/{text-C_6eKrbC.d.ts → text-DTg1a8Mg.d.ts} +1 -1
- package/dist/{think-tool-D8frXxwV.d.ts → think-tool-C0n_dF2K.d.ts} +2 -2
- package/dist/tool/index.d.ts +8 -7
- package/dist/tool/index.js +6 -5
- package/dist/{tool-r62gf3QY.d.ts → tool-xHM_GmzT.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/transcription/index.js +2 -2
- package/dist/{types-CElwurHZ.d.ts → types-2DBdXArn.d.ts} +8 -5
- package/dist/{types-DbolvLtZ.d.ts → types-B1KL4w14.d.ts} +1 -1
- package/dist/{types-C3gv9EX6.d.ts → types-D0Y2ZWS3.d.ts} +1 -1
- package/dist/{types-CIPaIbZo.d.ts → types-D7A6CIGt.d.ts} +1 -1
- package/dist/{types-D9rKQ_as.d.ts → types-DboZvHR_.d.ts} +8 -1
- package/dist/{types-RT3cuyRk.d.ts → types-Dyp7arZQ.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +4 -4
- package/dist/vector-store/index.js +5 -4
- package/package.json +6 -2
- package/dist/chunk-5GXSQYQT.js.map +0 -1
- package/dist/chunk-D2ECOWN5.js.map +0 -1
- package/dist/chunk-FN7HLLAZ.js.map +0 -1
- package/dist/chunk-PK5LKOFL.js.map +0 -1
- package/dist/chunk-TRQ3XRFD.js.map +0 -1
- /package/dist/{chunk-VKYZZXP5.js.map → chunk-7O45T5F2.js.map} +0 -0
- /package/dist/{chunk-AI5JMUW7.js.map → chunk-7OCVDT2X.js.map} +0 -0
- /package/dist/{chunk-FXAIYTRE.js.map → chunk-7YAH2F3J.js.map} +0 -0
- /package/dist/{chunk-RFHQY2IO.js.map → chunk-BAEFBTOW.js.map} +0 -0
- /package/dist/{chunk-ZCPOIDAQ.js.map → chunk-BOCJCECN.js.map} +0 -0
- /package/dist/{chunk-GQL5KRAH.js.map → chunk-H7BI3BSP.js.map} +0 -0
- /package/dist/{chunk-BEYBU7VJ.js.map → chunk-HVHTVGPP.js.map} +0 -0
- /package/dist/{chunk-J2W63PJI.js.map → chunk-JXZTTNCR.js.map} +0 -0
- /package/dist/{chunk-KFR4CDGK.js.map → chunk-QXQQ2DBM.js.map} +0 -0
- /package/dist/{chunk-GKDERULJ.js.map → chunk-YXLDR2O4.js.map} +0 -0
|
@@ -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,S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AM,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 { 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,MAAM,MAAM,QAAQ,QAAQ,gBAAgB,IAAI;AAAA,IAC/E,aAAa,MAAM;A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A,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":[]}
|
package/dist/skills/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as SkillLoader, a as SkillSet } from '../types-
|
|
2
|
-
export { c as Skill, S as SkillValidationError, d as SkillValidationIssue } from '../types-
|
|
3
|
-
import '../tool-
|
|
4
|
-
import '../types-
|
|
1
|
+
import { b as SkillLoader, a as SkillSet } from '../types-Dyp7arZQ.js';
|
|
2
|
+
export { c as Skill, S as SkillValidationError, d as SkillValidationIssue } from '../types-Dyp7arZQ.js';
|
|
3
|
+
import '../tool-xHM_GmzT.js';
|
|
4
|
+
import '../types-DboZvHR_.js';
|
|
5
5
|
import '../model-call-options-CZkSw_xN.js';
|
|
6
6
|
|
|
7
7
|
declare function loadSkills(loaders: SkillLoader | SkillLoader[]): Promise<SkillSet>;
|
package/dist/skills/index.js
CHANGED
|
@@ -2,15 +2,16 @@ import {
|
|
|
2
2
|
SkillValidationError,
|
|
3
3
|
loadSkills,
|
|
4
4
|
skill
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-BAEFBTOW.js";
|
|
6
6
|
import "../chunk-YK4WAAS4.js";
|
|
7
7
|
import "../chunk-CQNNSZPG.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-JXZTTNCR.js";
|
|
9
|
+
import "../chunk-RZDI7B6Z.js";
|
|
10
|
+
import "../chunk-H7BI3BSP.js";
|
|
11
11
|
import "../chunk-3RM57ZT2.js";
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-G5OACQEI.js";
|
|
13
|
+
import "../chunk-SROQA7I7.js";
|
|
14
|
+
import "../chunk-UBE4WH6G.js";
|
|
14
15
|
export {
|
|
15
16
|
SkillValidationError,
|
|
16
17
|
loadSkills,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
|
|
2
2
|
import { b as RetrySetting } from '../retry-CjvSlKGW.js';
|
|
3
3
|
export { R as RetryContext, a as RetryOptions } from '../retry-CjvSlKGW.js';
|
|
4
|
-
import { J as JsonObject } from '../types-
|
|
4
|
+
import { J as JsonObject } from '../types-DboZvHR_.js';
|
|
5
5
|
|
|
6
6
|
type SpeechGenerationRequest = {
|
|
7
7
|
text: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as GuardrailActionBase, n as GuardrailAllow, o as GuardrailBlock, e as GuardrailPolicyOptions, c as GuardrailPolicy, I as InputGuardrail, O as OutputGuardrail, d as GuardrailPolicyInput } from './types-
|
|
1
|
+
import { l as GuardrailActionBase, n as GuardrailAllow, o as GuardrailBlock, e as GuardrailPolicyOptions, c as GuardrailPolicy, I as InputGuardrail, O as OutputGuardrail, d as GuardrailPolicyInput } from './types-D7A6CIGt.js';
|
|
2
2
|
|
|
3
3
|
declare function allow(options?: GuardrailActionBase): GuardrailAllow;
|
|
4
4
|
declare function block(options: Omit<GuardrailBlock, "action">): GuardrailBlock;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
|
|
3
|
-
import { e as ToolRequiresApproval, c as ToolCallContext, T as Tool } from './tool-
|
|
4
|
-
import {
|
|
3
|
+
import { e as ToolRequiresApproval, c as ToolCallContext, T as Tool } from './tool-xHM_GmzT.js';
|
|
4
|
+
import { AgentQuestionPrompt, AgentQuestionAnswer } from './agent/interactions/index.js';
|
|
5
5
|
|
|
6
6
|
type CreateToolOptions<InputSchema extends ZodSchema, OutputSchema extends ZodSchema | undefined = undefined, Output = unknown> = {
|
|
7
7
|
name: string;
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export { d as CreateQuestionToolOptions, e as CreateThinkToolOptions, C as CreateToolOptions, Q as QuestionToolInput, f as QuestionToolOutput, c as createQuestionTool, a as createThinkTool, b as createTool, i as isQuestionTool } from '../think-tool-
|
|
2
|
-
export { C as CreateToolIndexOptions, E as EmbedToolsOptions, T as ToolIndex, a as ToolSearchDocument, c as createToolIndex, e as embedTools, i as isToolIndex } from '../dynamic-tools
|
|
3
|
-
export {
|
|
4
|
-
export { A as AnyTool, N as NormalizedToolOutput, R as RichToolOutput, T as Tool, a as ToolApprovalContext, b as ToolApprovalRequirement, f as ToolApprovalRunContext, c as ToolCallContext, d as ToolCallStreamEvent, g as ToolOutput, e as ToolRequiresApproval, h as ToolResultSerializationError, n as normalizeToolResultOutput, p as parseToolArgs, t as toolResultContentToText } from '../tool-
|
|
1
|
+
export { d as CreateQuestionToolOptions, e as CreateThinkToolOptions, C as CreateToolOptions, Q as QuestionToolInput, f as QuestionToolOutput, c as createQuestionTool, a as createThinkTool, b as createTool, i as isQuestionTool } from '../think-tool-C0n_dF2K.js';
|
|
2
|
+
export { C as CreateToolIndexOptions, E as EmbedToolsOptions, T as ToolIndex, a as ToolSearchDocument, c as createToolIndex, e as embedTools, i as isToolIndex } from '../dynamic-tools--Aw37H9d.js';
|
|
3
|
+
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-QZsbz7Hf.js';
|
|
4
|
+
export { A as AnyTool, N as NormalizedToolOutput, R as RichToolOutput, T as Tool, a as ToolApprovalContext, b as ToolApprovalRequirement, f as ToolApprovalRunContext, c as ToolCallContext, d as ToolCallStreamEvent, g as ToolOutput, e as ToolRequiresApproval, h as ToolResultSerializationError, n as normalizeToolResultOutput, p as parseToolArgs, t as toolResultContentToText } from '../tool-xHM_GmzT.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../zod-schema-C7F4clpm.js';
|
|
7
|
-
import '../
|
|
8
|
-
import '../types-
|
|
7
|
+
import '../agent/interactions/index.js';
|
|
8
|
+
import '../types-DboZvHR_.js';
|
|
9
9
|
import '../model-call-options-CZkSw_xN.js';
|
|
10
|
+
import '../retry-CjvSlKGW.js';
|
|
10
11
|
import '../types-Cr4uiYo5.js';
|
|
11
|
-
import '../types-
|
|
12
|
+
import '../types-D0Y2ZWS3.js';
|
|
12
13
|
import '../type-utils-CtHVDRn_.js';
|
|
13
14
|
|
|
14
15
|
declare class ToolCallError extends Error {
|
package/dist/tool/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
embedTools,
|
|
7
7
|
isQuestionTool,
|
|
8
8
|
isToolIndex
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-JXZTTNCR.js";
|
|
10
10
|
import {
|
|
11
11
|
ToolCallError,
|
|
12
12
|
ToolJsonError,
|
|
@@ -17,11 +17,12 @@ import {
|
|
|
17
17
|
normalizeToolResultOutput,
|
|
18
18
|
parseToolArgs,
|
|
19
19
|
toolResultContentToText
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-RZDI7B6Z.js";
|
|
21
|
+
import "../chunk-H7BI3BSP.js";
|
|
22
22
|
import "../chunk-3RM57ZT2.js";
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
23
|
+
import "../chunk-G5OACQEI.js";
|
|
24
|
+
import "../chunk-SROQA7I7.js";
|
|
25
|
+
import "../chunk-UBE4WH6G.js";
|
|
25
26
|
export {
|
|
26
27
|
ToolCallError,
|
|
27
28
|
ToolJsonError,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonObject,
|
|
1
|
+
import { J as JsonObject, w as ToolDefinition, p as JsonValue, z as ToolResultOutput, y as ToolResultContentPart } from './types-DboZvHR_.js';
|
|
2
2
|
|
|
3
3
|
type ToolApprovalRunContext = {
|
|
4
4
|
agentId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
|
|
2
2
|
import { b as RetrySetting } from '../retry-CjvSlKGW.js';
|
|
3
3
|
export { R as RetryContext, a as RetryOptions } from '../retry-CjvSlKGW.js';
|
|
4
|
-
import { J as JsonObject } from '../types-
|
|
4
|
+
import { J as JsonObject } from '../types-DboZvHR_.js';
|
|
5
5
|
|
|
6
6
|
type TranscriptionRequest = {
|
|
7
7
|
data: Uint8Array;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentInteractionRequest, AgentContinuation, AgentInteractionResponse } from './agent/interactions/index.js';
|
|
2
2
|
import { b as RetrySetting } from './retry-CjvSlKGW.js';
|
|
3
|
-
import { M as Message,
|
|
4
|
-
import { d as GuardrailPolicyInput, a as GuardrailDecisionRecord } from './types-
|
|
5
|
-
import { e as MemoryCompactionInfo, z as MemoryScope } from './types-
|
|
3
|
+
import { M as Message, g as CompletionResponse, U as Usage, R as ReasoningContentType, u as ToolCallPart, i as CompletionSource, r as ProviderToolCall, G as UserMessage, C as CompletionFinishReason, l as ContextUsage, f as CompletionRequest, z as ToolResultOutput, y as ToolResultContentPart, _ as ToolInteractionResponsePart, Z as ToolCallArgumentsMode, J as JsonObject, V as CompletionModelCapabilities, w as ToolDefinition } from './types-DboZvHR_.js';
|
|
4
|
+
import { d as GuardrailPolicyInput, a as GuardrailDecisionRecord } from './types-D7A6CIGt.js';
|
|
5
|
+
import { e as MemoryCompactionInfo, z as MemoryScope } from './types-B1KL4w14.js';
|
|
6
6
|
import { D as DeepReadonly, M as MaybePromise } from './type-utils-CtHVDRn_.js';
|
|
7
|
-
import { d as ToolCallStreamEvent } from './tool-
|
|
7
|
+
import { d as ToolCallStreamEvent } from './tool-xHM_GmzT.js';
|
|
8
|
+
import { A as AgentMiddleware } from './middleware-QZsbz7Hf.js';
|
|
8
9
|
|
|
9
10
|
type AgentLifecycleRunEvent = {
|
|
10
11
|
runId: string;
|
|
@@ -111,6 +112,8 @@ type AgentResultBase = {
|
|
|
111
112
|
runId: string;
|
|
112
113
|
text: string;
|
|
113
114
|
usage: Usage;
|
|
115
|
+
finishReason?: CompletionFinishReason | undefined;
|
|
116
|
+
providerFinishReason?: string | undefined;
|
|
114
117
|
contextUsage?: ContextUsage | undefined;
|
|
115
118
|
messages: Message[];
|
|
116
119
|
trace?: AgentTraceInfo | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as Usage, J as JsonObject, M as Message, S as SystemMessage,
|
|
1
|
+
import { U as Usage, J as JsonObject, M as Message, S as SystemMessage, c as CompletionModel } from './types-DboZvHR_.js';
|
|
2
2
|
import { b as RetrySetting } from './retry-CjvSlKGW.js';
|
|
3
3
|
|
|
4
4
|
type MemorySavePolicy = "message" | "turn" | "run";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as RetrySetting } from './retry-CjvSlKGW.js';
|
|
2
|
-
import { J as JsonObject } from './types-
|
|
2
|
+
import { J as JsonObject } from './types-DboZvHR_.js';
|
|
3
3
|
import { b as VectorMetadataValue, V as VectorMetadata, a as EmbeddedDocument, S as SparseVector, E as EmbeddingModel, c as SparseEmbeddingModel } from './types-Cr4uiYo5.js';
|
|
4
4
|
|
|
5
5
|
type VectorFilter = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Message, J as JsonObject, U as Usage } from './types-
|
|
1
|
+
import { M as Message, J as JsonObject, U as Usage } from './types-DboZvHR_.js';
|
|
2
2
|
import { M as MaybePromise } from './type-utils-CtHVDRn_.js';
|
|
3
3
|
|
|
4
4
|
type GuardrailMode = "enforce" | "observe";
|
|
@@ -211,6 +211,8 @@ type AssistantGenerationMetadata = {
|
|
|
211
211
|
provider: string;
|
|
212
212
|
modelId: string;
|
|
213
213
|
usage: Usage;
|
|
214
|
+
finishReason?: CompletionFinishReason;
|
|
215
|
+
providerFinishReason?: string;
|
|
214
216
|
contextUsage?: ContextUsage;
|
|
215
217
|
sources?: CompletionSource[];
|
|
216
218
|
providerToolCalls?: ProviderToolCall[];
|
|
@@ -240,9 +242,12 @@ type CompletionRequest = {
|
|
|
240
242
|
providerOptions?: JsonObject;
|
|
241
243
|
outputSchema?: JsonObject;
|
|
242
244
|
};
|
|
245
|
+
type CompletionFinishReason = "stop" | "length" | "content-filter" | "tool-calls" | "other";
|
|
243
246
|
type CompletionResponse<RawResponse = unknown> = {
|
|
244
247
|
choice: AssistantContentPart[];
|
|
245
248
|
usage: Usage;
|
|
249
|
+
finishReason?: CompletionFinishReason;
|
|
250
|
+
providerFinishReason?: string;
|
|
246
251
|
contextUsage?: ContextUsage;
|
|
247
252
|
rawResponse: RawResponse;
|
|
248
253
|
messageId?: string;
|
|
@@ -254,6 +259,8 @@ type CompletionResult<Output = string, RawResponse = unknown> = {
|
|
|
254
259
|
text: string;
|
|
255
260
|
content: readonly AssistantContentPart[];
|
|
256
261
|
usage: Usage;
|
|
262
|
+
finishReason?: CompletionFinishReason;
|
|
263
|
+
providerFinishReason?: string;
|
|
257
264
|
contextUsage?: ContextUsage;
|
|
258
265
|
rawResponse: RawResponse;
|
|
259
266
|
messageId?: string;
|
|
@@ -338,4 +345,4 @@ declare function assertCompletionRequestSupported(model: CompletionModel, reques
|
|
|
338
345
|
}): void;
|
|
339
346
|
declare function textFromAssistantContent(content: readonly AssistantContentPart[]): string;
|
|
340
347
|
|
|
341
|
-
export { type
|
|
348
|
+
export { type ToolQuestionAnswer as $, type AssistantContentPart as A, type ToolResultPart as B, type CompletionFinishReason as C, type Document as D, type UserContentPart as E, type FileData as F, type UserMessage as G, calculateContextUsage as H, type ImageDetail as I, type JsonObject as J, getAssistantGenerationMetadata as K, isProviderTool as L, type Message as M, resolveModelContextLimits as N, withContextUsage as O, type ProviderTool as P, CompletionCapabilityError as Q, type ReasoningContentType as R, type SystemMessage as S, type TextPart as T, Usage as U, type CompletionModelCapabilities as V, type CompletionStreamPart as W, type StreamingCompletionModel as X, type ToolApprovalResponsePart as Y, type ToolCallArgumentsMode as Z, type ToolInteractionResponsePart as _, type AssistantGenerationMetadata as a, type ToolQuestionResponsePart as a0, type UsageDetails as a1, assertCompletionRequestSupported as a2, reasoningDisplayText as a3, textFromAssistantContent as a4, type AssistantMessage as b, type CompletionModel as c, type CompletionModelInfo as d, type CompletionModelStreamEvent as e, type CompletionRequest as f, type CompletionResponse as g, type CompletionResult as h, type CompletionSource as i, type CompletionStreamEvent as j, type CompletionTool as k, type ContextUsage as l, type FilePart as m, type ImagePart as n, type JsonPrimitive as o, type JsonValue as p, type ModelContextLimits as q, type ProviderToolCall as r, type ReasoningDetail as s, type ReasoningPart as t, type ToolCallPart as u, type ToolChoice as v, type ToolDefinition as w, type ToolMessage as x, type ToolResultContentPart as y, type ToolResultOutput as z };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { V as VectorMetadata, b as VectorMetadataValue, a as EmbeddedDocument } from '../types-Cr4uiYo5.js';
|
|
2
|
-
import { T as Tool } from '../tool-
|
|
3
|
-
import { V as VectorFilter, R as RetrieveDocumentsOptions, a as VectorSearchResult, f as RetrieveHybridDocumentsOptions, d as VectorStore, I as IndexStrategy, g as VectorStoreUpsertOptions, h as VectorSearchRequest, b as VectorInspectRequest, c as VectorInspectPage, i as VectorSearchToolOptions } from '../types-
|
|
4
|
-
export { D as DenseVectorSearchToolOptions, j as HybridVectorSearchRequest, k as HybridVectorSearchToolOptions, H as HybridVectorStore, L as LshOptions, l as RetrieveDocumentsBaseOptions, e as VectorFusion, m as VectorInspectItem, n as VectorMetric, o as VectorSearchToolBaseOptions } from '../types-
|
|
2
|
+
import { T as Tool } from '../tool-xHM_GmzT.js';
|
|
3
|
+
import { V as VectorFilter, R as RetrieveDocumentsOptions, a as VectorSearchResult, f as RetrieveHybridDocumentsOptions, d as VectorStore, I as IndexStrategy, g as VectorStoreUpsertOptions, h as VectorSearchRequest, b as VectorInspectRequest, c as VectorInspectPage, i as VectorSearchToolOptions } from '../types-D0Y2ZWS3.js';
|
|
4
|
+
export { D as DenseVectorSearchToolOptions, j as HybridVectorSearchRequest, k as HybridVectorSearchToolOptions, H as HybridVectorStore, L as LshOptions, l as RetrieveDocumentsBaseOptions, e as VectorFusion, m as VectorInspectItem, n as VectorMetric, o as VectorSearchToolBaseOptions } from '../types-D0Y2ZWS3.js';
|
|
5
5
|
import '../model-call-options-CZkSw_xN.js';
|
|
6
6
|
import '../retry-CjvSlKGW.js';
|
|
7
|
-
import '../types-
|
|
7
|
+
import '../types-DboZvHR_.js';
|
|
8
8
|
|
|
9
9
|
declare const vectorFilter: {
|
|
10
10
|
eq(key: string, value: VectorMetadataValue): VectorFilter;
|
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
matchesVectorFilter,
|
|
5
5
|
retrieveDocuments,
|
|
6
6
|
vectorFilter
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-RZDI7B6Z.js";
|
|
8
|
+
import "../chunk-H7BI3BSP.js";
|
|
9
9
|
import "../chunk-3RM57ZT2.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-G5OACQEI.js";
|
|
11
|
+
import "../chunk-SROQA7I7.js";
|
|
12
|
+
import "../chunk-UBE4WH6G.js";
|
|
12
13
|
export {
|
|
13
14
|
InMemoryVectorStore,
|
|
14
15
|
createVectorSearchTool,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvia/core",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.6",
|
|
4
4
|
"description": "Core runtime primitives for context-aware Anvia agents.",
|
|
5
5
|
"author": "anvia",
|
|
6
6
|
"maintainer": "Indra Zulfi",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"types": "./dist/agent/index.d.ts",
|
|
30
30
|
"import": "./dist/agent/index.js"
|
|
31
31
|
},
|
|
32
|
+
"./agent/interactions": {
|
|
33
|
+
"types": "./dist/agent/interactions/index.d.ts",
|
|
34
|
+
"import": "./dist/agent/interactions/index.js"
|
|
35
|
+
},
|
|
32
36
|
"./internal/agent": {
|
|
33
37
|
"types": "./dist/internal/agent.d.ts",
|
|
34
38
|
"import": "./dist/internal/agent.js"
|
|
@@ -120,7 +124,7 @@
|
|
|
120
124
|
"vitest": "^4.0.8"
|
|
121
125
|
},
|
|
122
126
|
"scripts": {
|
|
123
|
-
"build": "tsup src/index.ts src/agent/index.ts src/internal/agent.ts src/speech-generation/index.ts src/completion/index.ts src/embeddings/index.ts src/evals/index.ts src/image-generation/index.ts src/documents/index.ts src/extractor/index.ts src/guardrails/index.ts src/mcp/index.ts src/memory/index.ts src/model-listing/index.ts src/observability/index.ts src/pipeline/index.ts src/skills/index.ts src/streaming/index.ts src/tool/index.ts src/transcription/index.ts src/vector-store/index.ts --format esm --dts --sourcemap --clean",
|
|
127
|
+
"build": "tsup src/index.ts src/agent/index.ts src/agent/interactions/index.ts src/internal/agent.ts src/speech-generation/index.ts src/completion/index.ts src/embeddings/index.ts src/evals/index.ts src/image-generation/index.ts src/documents/index.ts src/extractor/index.ts src/guardrails/index.ts src/mcp/index.ts src/memory/index.ts src/model-listing/index.ts src/observability/index.ts src/pipeline/index.ts src/skills/index.ts src/streaming/index.ts src/tool/index.ts src/transcription/index.ts src/vector-store/index.ts --format esm --dts --sourcemap --clean",
|
|
124
128
|
"test": "vitest run",
|
|
125
129
|
"typecheck": "tsc --noEmit"
|
|
126
130
|
}
|