@anvia/core 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/agent/index.d.ts +10 -8
  2. package/dist/agent/index.js +5 -3
  3. package/dist/{agent-D5KKP9_z.d.ts → agent-CkVbMA1A.d.ts} +55 -6
  4. package/dist/{chunk-JDPPZCOY.js → chunk-2VCWYCPV.js} +2 -2
  5. package/dist/{chunk-GNWMOSNR.js → chunk-3H7FVGHU.js} +3 -3
  6. package/dist/chunk-3H7FVGHU.js.map +1 -0
  7. package/dist/{chunk-B4QHQN5K.js → chunk-445TT5Q5.js} +3 -3
  8. package/dist/chunk-445TT5Q5.js.map +1 -0
  9. package/dist/{chunk-SXLGKGKJ.js → chunk-4ILKTES4.js} +3 -3
  10. package/dist/{chunk-S55WOHX5.js → chunk-BT3I6O56.js} +1 -1
  11. package/dist/chunk-BT3I6O56.js.map +1 -0
  12. package/dist/{chunk-67X6U5HI.js → chunk-HGJDC56F.js} +157 -25
  13. package/dist/chunk-HGJDC56F.js.map +1 -0
  14. package/dist/{chunk-UEUE6W2X.js → chunk-JSCITGBH.js} +2 -2
  15. package/dist/{chunk-SRGJPXKT.js → chunk-MQVFDXPC.js} +2 -2
  16. package/dist/{chunk-WZTPK5HV.js → chunk-RLA7SST2.js} +12 -4
  17. package/dist/chunk-RLA7SST2.js.map +1 -0
  18. package/dist/chunk-RTOGIJH2.js +345 -0
  19. package/dist/chunk-RTOGIJH2.js.map +1 -0
  20. package/dist/{chunk-J23SIK6Y.js → chunk-X2LR54ZO.js} +4 -4
  21. package/dist/evals/index.d.ts +3 -3
  22. package/dist/evals/index.js +7 -7
  23. package/dist/extractor/index.d.ts +3 -3
  24. package/dist/extractor/index.js +6 -6
  25. package/dist/index.d.ts +7 -7
  26. package/dist/index.js +13 -11
  27. package/dist/mcp/index.d.ts +3 -3
  28. package/dist/mcp/index.js +1 -1
  29. package/dist/{zod-schema-Cq_9zlmJ.d.ts → middleware-2iCGCsB6.d.ts} +5 -5
  30. package/dist/observability/index.d.ts +6 -1
  31. package/dist/observability/index.js +1 -1
  32. package/dist/pipeline/index.d.ts +89 -14
  33. package/dist/pipeline/index.js +1 -1
  34. package/dist/skills/index.d.ts +3 -3
  35. package/dist/skills/index.js +5 -5
  36. package/dist/tool/index.d.ts +6 -6
  37. package/dist/tool/index.js +4 -4
  38. package/dist/{tool-DhuBQ3yb.d.ts → tool-DiWtAf_Q.d.ts} +10 -2
  39. package/dist/{types-HvopERm0.d.ts → types-21n32ltl.d.ts} +1 -1
  40. package/dist/{types-B5B8Sdl4.d.ts → types-ChJoZ0OH.d.ts} +1 -1
  41. package/dist/vector-store/index.d.ts +1 -1
  42. package/dist/vector-store/index.js +2 -2
  43. package/package.json +1 -1
  44. package/dist/chunk-67X6U5HI.js.map +0 -1
  45. package/dist/chunk-B4QHQN5K.js.map +0 -1
  46. package/dist/chunk-FI2BTRT5.js +0 -86
  47. package/dist/chunk-FI2BTRT5.js.map +0 -1
  48. package/dist/chunk-GNWMOSNR.js.map +0 -1
  49. package/dist/chunk-S55WOHX5.js.map +0 -1
  50. package/dist/chunk-WZTPK5HV.js.map +0 -1
  51. /package/dist/{chunk-JDPPZCOY.js.map → chunk-2VCWYCPV.js.map} +0 -0
  52. /package/dist/{chunk-SXLGKGKJ.js.map → chunk-4ILKTES4.js.map} +0 -0
  53. /package/dist/{chunk-UEUE6W2X.js.map → chunk-JSCITGBH.js.map} +0 -0
  54. /package/dist/{chunk-SRGJPXKT.js.map → chunk-MQVFDXPC.js.map} +0 -0
  55. /package/dist/{chunk-J23SIK6Y.js.map → chunk-X2LR54ZO.js.map} +0 -0
package/dist/index.js CHANGED
@@ -5,22 +5,22 @@ import {
5
5
  import {
6
6
  connectMcp,
7
7
  mcp
8
- } from "./chunk-WZTPK5HV.js";
8
+ } from "./chunk-RLA7SST2.js";
9
9
  import {
10
10
  ModelListingError
11
11
  } from "./chunk-WJT22R3T.js";
12
12
  import {
13
13
  createObserver
14
- } from "./chunk-S55WOHX5.js";
14
+ } from "./chunk-BT3I6O56.js";
15
15
  import {
16
16
  Pipeline,
17
17
  PipelineBuilder
18
- } from "./chunk-FI2BTRT5.js";
18
+ } from "./chunk-RTOGIJH2.js";
19
19
  import {
20
20
  SkillValidationError,
21
21
  loadSkills,
22
22
  skill
23
- } from "./chunk-JDPPZCOY.js";
23
+ } from "./chunk-2VCWYCPV.js";
24
24
  import {
25
25
  AudioGenerationRequestBuilder,
26
26
  audioGenerationRequest
@@ -34,25 +34,25 @@ import {
34
34
  llmScore,
35
35
  runEvalSuite,
36
36
  semanticSimilarity
37
- } from "./chunk-UEUE6W2X.js";
37
+ } from "./chunk-JSCITGBH.js";
38
38
  import {
39
39
  ExtractionError,
40
40
  Extractor,
41
41
  ExtractorBuilder
42
- } from "./chunk-SXLGKGKJ.js";
42
+ } from "./chunk-4ILKTES4.js";
43
43
  import {
44
44
  createThinkTool,
45
45
  createToolIndex,
46
46
  createToolMiddleware,
47
47
  embedTools,
48
48
  isDynamicToolIndex
49
- } from "./chunk-J23SIK6Y.js";
49
+ } from "./chunk-X2LR54ZO.js";
50
50
  import {
51
51
  InMemoryVectorIndex,
52
52
  InMemoryVectorStore,
53
53
  createVectorSearchTool,
54
54
  vectorFilter
55
- } from "./chunk-SRGJPXKT.js";
55
+ } from "./chunk-MQVFDXPC.js";
56
56
  import {
57
57
  Agent,
58
58
  AgentBuilder,
@@ -63,10 +63,11 @@ import {
63
63
  PromptRequest,
64
64
  cancelPrompt,
65
65
  createHook,
66
+ requestToolApproval,
66
67
  runControl,
67
68
  skipTool,
68
69
  toolCallControl
69
- } from "./chunk-67X6U5HI.js";
70
+ } from "./chunk-HGJDC56F.js";
70
71
  import {
71
72
  resolveMemoryOptions
72
73
  } from "./chunk-XXT2UCAR.js";
@@ -78,10 +79,10 @@ import {
78
79
  ToolSet,
79
80
  parseToolArgs,
80
81
  serializeToolOutput
81
- } from "./chunk-GNWMOSNR.js";
82
+ } from "./chunk-3H7FVGHU.js";
82
83
  import {
83
84
  createTool
84
- } from "./chunk-B4QHQN5K.js";
85
+ } from "./chunk-445TT5Q5.js";
85
86
  import {
86
87
  toReadableStream
87
88
  } from "./chunk-XUUY2L2D.js";
@@ -180,6 +181,7 @@ export {
180
181
  normalizeDocuments,
181
182
  parseToolArgs,
182
183
  reasoningDisplayText,
184
+ requestToolApproval,
183
185
  resolveMemoryOptions,
184
186
  runControl,
185
187
  runEvalSuite,
@@ -1,9 +1,9 @@
1
- import { a as McpConnection, c as McpServer, d as McpStdioOptions, b as McpHttpOptions } from '../types-B5B8Sdl4.js';
2
- export { M as McpClient, e as McpToolCallContent, f as McpToolCallResult, g as McpToolDefinition } from '../types-B5B8Sdl4.js';
1
+ import { a as McpConnection, c as McpServer, d as McpStdioOptions, b as McpHttpOptions } from '../types-ChJoZ0OH.js';
2
+ export { M as McpClient, e as McpToolCallContent, f as McpToolCallResult, g as McpToolDefinition } from '../types-ChJoZ0OH.js';
3
3
  import '@modelcontextprotocol/sdk/client/stdio.js';
4
4
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
5
5
  import '../types-BrxLd7ay.js';
6
- import '../tool-DhuBQ3yb.js';
6
+ import '../tool-DiWtAf_Q.js';
7
7
 
8
8
  declare function connectMcp(connection: McpConnection): Promise<McpServer>;
9
9
 
package/dist/mcp/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  connectMcp,
3
3
  mcp
4
- } from "../chunk-WZTPK5HV.js";
4
+ } from "../chunk-RLA7SST2.js";
5
5
  export {
6
6
  connectMcp,
7
7
  mcp
@@ -1,8 +1,10 @@
1
+ import { z } from 'zod';
1
2
  import { q as ToolDefinition } from './types-BrxLd7ay.js';
2
3
  import { VectorMetadata, EmbeddingModel, EmbeddedDocument } from './embeddings/index.js';
3
4
  import { VectorSearchIndex } from './vector-store/index.js';
4
- import { A as AnyTool } from './tool-DhuBQ3yb.js';
5
- import { z } from 'zod';
5
+ import { A as AnyTool, d as ToolCallContext } from './tool-DiWtAf_Q.js';
6
+
7
+ type ZodSchema<T = unknown> = z.ZodType<T>;
6
8
 
7
9
  declare class ToolSet {
8
10
  private readonly tools;
@@ -14,7 +16,7 @@ declare class ToolSet {
14
16
  get(toolName: string): AnyTool | undefined;
15
17
  values(): AnyTool[];
16
18
  getToolDefinitions(prompt?: string): Promise<ToolDefinition[]>;
17
- call(toolName: string, args: string): Promise<string>;
19
+ call(toolName: string, args: string, context?: ToolCallContext): Promise<string>;
18
20
  }
19
21
 
20
22
  type ToolSearchDocument<Metadata extends VectorMetadata = VectorMetadata> = {
@@ -49,6 +51,4 @@ interface ToolMiddleware {
49
51
  }
50
52
  declare function createToolMiddleware(middleware: ToolMiddleware): ToolMiddleware;
51
53
 
52
- type ZodSchema<T = unknown> = z.ZodType<T>;
53
-
54
54
  export { type DynamicToolIndex as D, type EmbedToolsOptions as E, type ToolMiddleware as T, type ZodSchema as Z, type ToolResultMiddlewareArgs as a, type ToolSearchDocument as b, ToolSet as c, createToolIndex as d, createToolMiddleware as e, embedTools as f, isDynamicToolIndex as i };
@@ -1,4 +1,5 @@
1
1
  import { M as Message, d as CompletionRequest, e as CompletionResponse, n as ToolCall, U as Usage } from '../types-BrxLd7ay.js';
2
+ import { e as ToolCallStreamEvent } from '../tool-DiWtAf_Q.js';
2
3
 
3
4
  type AgentTraceInfo = {
4
5
  traceId?: string | undefined;
@@ -61,11 +62,15 @@ type AgentToolEndArgs = AgentToolStartArgs & {
61
62
  type AgentToolErrorArgs = AgentToolStartArgs & {
62
63
  error: unknown;
63
64
  };
65
+ type AgentToolStreamEventArgs = AgentToolStartArgs & {
66
+ event: ToolCallStreamEvent;
67
+ };
64
68
  interface AgentGenerationObserver {
65
69
  end(args: AgentGenerationEndArgs): void | Promise<void>;
66
70
  error?(args: AgentGenerationErrorArgs): void | Promise<void>;
67
71
  }
68
72
  interface AgentToolObserver {
73
+ streamEvent?(args: AgentToolStreamEventArgs): void | Promise<void>;
69
74
  end(args: AgentToolEndArgs): void | Promise<void>;
70
75
  error?(args: AgentToolErrorArgs): void | Promise<void>;
71
76
  }
@@ -90,4 +95,4 @@ type ObserveOptions = {
90
95
  };
91
96
  declare function createObserver(observer: AgentObserver): AgentObserver;
92
97
 
93
- export { type AgentGenerationEndArgs, type AgentGenerationErrorArgs, type AgentGenerationObserver, type AgentGenerationStartArgs, type AgentObserver, type AgentObserverRegistration, type AgentRunEndArgs, type AgentRunErrorArgs, type AgentRunObserver, type AgentRunStartArgs, type AgentToolEndArgs, type AgentToolErrorArgs, type AgentToolObserver, type AgentToolStartArgs, type AgentTraceInfo, type AgentTraceOptions, type ObserveOptions, createObserver };
98
+ export { type AgentGenerationEndArgs, type AgentGenerationErrorArgs, type AgentGenerationObserver, type AgentGenerationStartArgs, type AgentObserver, type AgentObserverRegistration, type AgentRunEndArgs, type AgentRunErrorArgs, type AgentRunObserver, type AgentRunStartArgs, type AgentToolEndArgs, type AgentToolErrorArgs, type AgentToolObserver, type AgentToolStartArgs, type AgentToolStreamEventArgs, type AgentTraceInfo, type AgentTraceOptions, type ObserveOptions, createObserver };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createObserver
3
- } from "../chunk-S55WOHX5.js";
3
+ } from "../chunk-BT3I6O56.js";
4
4
  export {
5
5
  createObserver
6
6
  };
@@ -1,13 +1,13 @@
1
- import { b as CompletionModel } from '../types-BrxLd7ay.js';
2
- import { A as Agent } from '../agent-D5KKP9_z.js';
1
+ import { J as JsonObject, b as CompletionModel } from '../types-BrxLd7ay.js';
2
+ import { A as Agent } from '../agent-CkVbMA1A.js';
3
3
  import { Extractor } from '../extractor/index.js';
4
4
  import '../memory/index.js';
5
5
  import '../observability/index.js';
6
- import '../zod-schema-Cq_9zlmJ.js';
6
+ import '../tool-DiWtAf_Q.js';
7
+ import '../middleware-2iCGCsB6.js';
8
+ import 'zod';
7
9
  import '../embeddings/index.js';
8
10
  import '../vector-store/index.js';
9
- import '../tool-DhuBQ3yb.js';
10
- import 'zod';
11
11
 
12
12
  /** Minimal interface for anything that can run as a pipeline stage. */
13
13
  interface PipelineOp<Input = unknown, Output = unknown> {
@@ -21,32 +21,107 @@ type AwaitedOutput<Op> = Op extends PipelineOp<unknown, infer Output> ? Awaited<
21
21
  type ParallelOutput<Branches extends Record<string, PipelineOp<unknown, unknown>>> = {
22
22
  [Key in keyof Branches]: AwaitedOutput<Branches[Key]>;
23
23
  };
24
+ type PipelineMetadata = {
25
+ id?: string | undefined;
26
+ name?: string | undefined;
27
+ description?: string | undefined;
28
+ metadata?: JsonObject | undefined;
29
+ };
30
+ type PipelineStageMetadata = {
31
+ id?: string | undefined;
32
+ name?: string | undefined;
33
+ description?: string | undefined;
34
+ metadata?: JsonObject | undefined;
35
+ };
36
+ type PipelineStageKind = "input" | "step" | "pipeline" | "parallel" | "branch" | "agent" | "extractor" | "output";
37
+ type PipelineGraphNode = {
38
+ id: string;
39
+ kind: PipelineStageKind;
40
+ label: string;
41
+ description?: string | undefined;
42
+ metadata?: JsonObject | undefined;
43
+ agentId?: string | undefined;
44
+ agentName?: string | undefined;
45
+ pipelineId?: string | undefined;
46
+ branchKey?: string | undefined;
47
+ };
48
+ type PipelineGraphEdge = {
49
+ id: string;
50
+ source: string;
51
+ target: string;
52
+ label?: string | undefined;
53
+ };
54
+ type PipelineGraph = PipelineMetadata & {
55
+ id: string;
56
+ nodes: PipelineGraphNode[];
57
+ edges: PipelineGraphEdge[];
58
+ };
59
+ type PipelineRunEvent = {
60
+ type: "stage_started";
61
+ node: PipelineGraphNode;
62
+ } | {
63
+ type: "stage_completed";
64
+ node: PipelineGraphNode;
65
+ durationMs: number;
66
+ } | {
67
+ type: "stage_failed";
68
+ node: PipelineGraphNode;
69
+ durationMs: number;
70
+ error: unknown;
71
+ };
72
+ type PipelineRunObserver = {
73
+ onEvent(event: PipelineRunEvent): void | Promise<void>;
74
+ };
75
+ type PipelineRunOptions = {
76
+ observer?: PipelineRunObserver | undefined;
77
+ };
78
+ type PipelineRunContext = {
79
+ observer?: PipelineRunObserver | undefined;
80
+ };
81
+ type PipelineExecutor<Input, Output> = (input: Input, context: PipelineRunContext) => Output | Promise<Output>;
82
+ type PipelineBuilderState = {
83
+ graph: PipelineGraph;
84
+ terminalNodeId: string;
85
+ terminalNodeIds: string[];
86
+ nextNodeIndex: number;
87
+ nextEdgeIndex: number;
88
+ };
24
89
  /** Runnable pipeline returned by `PipelineBuilder.build()`. */
25
90
  declare class Pipeline<Input, Output> implements PipelineOp<Input, Awaited<Output>> {
26
91
  private readonly executor;
27
- constructor(executor: (input: Input) => Output | Promise<Output>);
92
+ private readonly pipelineGraph;
93
+ readonly id: string;
94
+ readonly name: string | undefined;
95
+ readonly description: string | undefined;
96
+ readonly metadata: JsonObject | undefined;
97
+ constructor(executor: PipelineExecutor<Input, Output>, pipelineGraph?: PipelineGraph);
28
98
  /** Run one input through the built pipeline and return the final stage output. */
29
- run(input: Input): Promise<Awaited<Output>>;
99
+ run(input: Input, options?: PipelineRunOptions): Promise<Awaited<Output>>;
30
100
  /** Run many inputs through the same pipeline with bounded concurrency. */
31
101
  batch<I extends Iterable<Input>>(inputs: I, options: PipelineBatchOptions): Promise<Array<Awaited<Output>>>;
102
+ graph(): PipelineGraph;
32
103
  }
33
104
  /** Builds a typed pipeline from an original input type to an inferred output type. */
34
105
  declare class PipelineBuilder<Input, Output = Input> {
35
106
  private readonly executor;
36
- constructor(executor?: (input: Input) => Output | Promise<Output>);
107
+ private readonly state;
108
+ constructor();
109
+ constructor(metadata: PipelineMetadata);
110
+ constructor(executor: (input: Input) => Output | Promise<Output>);
111
+ constructor(executor: PipelineExecutor<Input, Output>, state: PipelineBuilderState);
37
112
  /** Add a synchronous or asynchronous transform stage. */
38
- step<Next>(fn: (input: Awaited<Output>) => Next | Promise<Next>): PipelineBuilder<Input, Awaited<Next>>;
113
+ step<Next>(fn: (input: Awaited<Output>) => Next | Promise<Next>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, Awaited<Next>>;
39
114
  /** Compose another pipeline operation after the current stage. */
40
- use<Next>(op: PipelineOp<Awaited<Output>, Next>): PipelineBuilder<Input, Awaited<Next>>;
115
+ use<Next>(op: PipelineOp<Awaited<Output>, Next>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, Awaited<Next>>;
41
116
  /** Run named branch operations concurrently from the current value. */
42
- parallel<Branches extends Record<string, PipelineOp<Awaited<Output>, unknown>>>(branches: Branches): PipelineBuilder<Input, ParallelOutput<Branches>>;
117
+ parallel<Branches extends Record<string, PipelineOp<Awaited<Output>, unknown>>>(branches: Branches, metadata?: PipelineStageMetadata): PipelineBuilder<Input, ParallelOutput<Branches>>;
43
118
  /** Send the current value to an agent as text and continue with the agent output. */
44
- prompt(agent: Agent<CompletionModel>): PipelineBuilder<Input, string>;
119
+ prompt(agent: Agent<CompletionModel>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, string>;
45
120
  /** Send the current value to an extractor as text and continue with typed schema data. */
46
- extract<T>(extractor: Extractor<T, CompletionModel>): PipelineBuilder<Input, T>;
121
+ extract<T>(extractor: Extractor<T, CompletionModel>, metadata?: PipelineStageMetadata): PipelineBuilder<Input, T>;
47
122
  /** Finish the builder and return a runnable pipeline. */
48
123
  build(): Pipeline<Input, Awaited<Output>>;
49
124
  private runStep;
50
125
  }
51
126
 
52
- export { Pipeline, type PipelineBatchOptions, PipelineBuilder, type PipelineOp };
127
+ 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 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Pipeline,
3
3
  PipelineBuilder
4
- } from "../chunk-FI2BTRT5.js";
4
+ } from "../chunk-RTOGIJH2.js";
5
5
  export {
6
6
  Pipeline,
7
7
  PipelineBuilder
@@ -1,6 +1,6 @@
1
- import { a as SkillLoader, b as SkillSet } from '../types-HvopERm0.js';
2
- export { S as Skill, c as SkillValidationError, d as SkillValidationIssue } from '../types-HvopERm0.js';
3
- import '../tool-DhuBQ3yb.js';
1
+ import { a as SkillLoader, b as SkillSet } from '../types-21n32ltl.js';
2
+ export { S as Skill, c as SkillValidationError, d as SkillValidationIssue } from '../types-21n32ltl.js';
3
+ import '../tool-DiWtAf_Q.js';
4
4
  import '../types-BrxLd7ay.js';
5
5
 
6
6
  declare function loadSkills(loaders: SkillLoader | SkillLoader[]): Promise<SkillSet>;
@@ -2,12 +2,12 @@ import {
2
2
  SkillValidationError,
3
3
  loadSkills,
4
4
  skill
5
- } from "../chunk-JDPPZCOY.js";
6
- import "../chunk-J23SIK6Y.js";
7
- import "../chunk-SRGJPXKT.js";
5
+ } from "../chunk-2VCWYCPV.js";
6
+ import "../chunk-X2LR54ZO.js";
7
+ import "../chunk-MQVFDXPC.js";
8
8
  import "../chunk-YK4WAAS4.js";
9
- import "../chunk-GNWMOSNR.js";
10
- import "../chunk-B4QHQN5K.js";
9
+ import "../chunk-3H7FVGHU.js";
10
+ import "../chunk-445TT5Q5.js";
11
11
  import "../chunk-A7VDIZQN.js";
12
12
  export {
13
13
  SkillValidationError,
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { Z as ZodSchema } from '../zod-schema-Cq_9zlmJ.js';
3
- export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware, a as ToolResultMiddlewareArgs, b as ToolSearchDocument, c as ToolSet, d as createToolIndex, e as createToolMiddleware, f as embedTools, i as isDynamicToolIndex } from '../zod-schema-Cq_9zlmJ.js';
4
- import { b as ToolApprovalPolicy, T as Tool } from '../tool-DhuBQ3yb.js';
5
- export { A as AnyTool, a as ToolApprovalContext, c as ToolApprovalRunContext, p as parseToolArgs, s as serializeToolOutput } from '../tool-DhuBQ3yb.js';
2
+ import { Z as ZodSchema } from '../middleware-2iCGCsB6.js';
3
+ export { D as DynamicToolIndex, E as EmbedToolsOptions, T as ToolMiddleware, a as ToolResultMiddlewareArgs, b as ToolSearchDocument, c as ToolSet, d as createToolIndex, e as createToolMiddleware, f as embedTools, i as isDynamicToolIndex } from '../middleware-2iCGCsB6.js';
4
+ import { b as ToolApprovalPolicy, d as ToolCallContext, T as Tool } from '../tool-DiWtAf_Q.js';
5
+ export { A as AnyTool, a as ToolApprovalContext, c as ToolApprovalRunContext, e as ToolCallStreamEvent, p as parseToolArgs, s as serializeToolOutput } from '../tool-DiWtAf_Q.js';
6
6
  import '../types-BrxLd7ay.js';
7
7
  import '../embeddings/index.js';
8
8
  import '../vector-store/index.js';
@@ -13,7 +13,7 @@ type CreateToolOptions<InputSchema extends ZodSchema, OutputSchema extends ZodSc
13
13
  input: InputSchema;
14
14
  output?: OutputSchema;
15
15
  approval?: ToolApprovalPolicy<z.output<InputSchema>>;
16
- execute(args: z.output<InputSchema>): OutputSchema extends ZodSchema ? z.input<OutputSchema> | Promise<z.input<OutputSchema>> : unknown | Promise<unknown>;
16
+ execute(args: z.output<InputSchema>, context: ToolCallContext): OutputSchema extends ZodSchema ? z.input<OutputSchema> | Promise<z.input<OutputSchema>> : unknown | Promise<unknown>;
17
17
  };
18
18
  type ToolOutput<OutputSchema extends ZodSchema | undefined> = OutputSchema extends ZodSchema ? z.output<OutputSchema> : unknown;
19
19
  declare function createTool<InputSchema extends ZodSchema, OutputSchema extends ZodSchema | undefined = undefined>(options: CreateToolOptions<InputSchema, OutputSchema>): Tool<z.output<InputSchema>, ToolOutput<OutputSchema>>;
@@ -39,4 +39,4 @@ declare function createThinkTool(options?: CreateThinkToolOptions): Tool<{
39
39
  thought: string;
40
40
  }, string>;
41
41
 
42
- export { type CreateThinkToolOptions, type CreateToolOptions, Tool, ToolApprovalPolicy, ToolCallError, ToolJsonError, ToolNotFoundError, createThinkTool, createTool };
42
+ export { type CreateThinkToolOptions, type CreateToolOptions, Tool, ToolApprovalPolicy, ToolCallContext, ToolCallError, ToolJsonError, ToolNotFoundError, createThinkTool, createTool };
@@ -4,8 +4,8 @@ import {
4
4
  createToolMiddleware,
5
5
  embedTools,
6
6
  isDynamicToolIndex
7
- } from "../chunk-J23SIK6Y.js";
8
- import "../chunk-SRGJPXKT.js";
7
+ } from "../chunk-X2LR54ZO.js";
8
+ import "../chunk-MQVFDXPC.js";
9
9
  import {
10
10
  ToolCallError,
11
11
  ToolJsonError,
@@ -13,10 +13,10 @@ import {
13
13
  ToolSet,
14
14
  parseToolArgs,
15
15
  serializeToolOutput
16
- } from "../chunk-GNWMOSNR.js";
16
+ } from "../chunk-3H7FVGHU.js";
17
17
  import {
18
18
  createTool
19
- } from "../chunk-B4QHQN5K.js";
19
+ } from "../chunk-445TT5Q5.js";
20
20
  import "../chunk-A7VDIZQN.js";
21
21
  export {
22
22
  ToolCallError,
@@ -19,11 +19,19 @@ type ToolApprovalPolicy<Args = unknown> = {
19
19
  reason?: string | ((ctx: ToolApprovalContext<Args>) => string | Promise<string>);
20
20
  rejectMessage?: string | ((ctx: ToolApprovalContext<Args>) => string | Promise<string>);
21
21
  };
22
+ type ToolCallStreamEvent = {
23
+ agentId: string;
24
+ agentName?: string | undefined;
25
+ event: unknown;
26
+ };
27
+ type ToolCallContext = {
28
+ emitStreamEvent?(event: ToolCallStreamEvent): void | Promise<void>;
29
+ };
22
30
  interface Tool<Args = unknown, Output = unknown> {
23
31
  readonly name: string;
24
32
  readonly approval?: ToolApprovalPolicy<Args>;
25
33
  definition(prompt: string): ToolDefinition | Promise<ToolDefinition>;
26
- call(args: Args): Output | Promise<Output>;
34
+ call(args: Args, context?: ToolCallContext): Output | Promise<Output>;
27
35
  parseApprovalArgs?(args: unknown): Args;
28
36
  }
29
37
  type AnyTool = Omit<Tool<unknown, unknown>, "approval"> & {
@@ -32,4 +40,4 @@ type AnyTool = Omit<Tool<unknown, unknown>, "approval"> & {
32
40
  declare function serializeToolOutput(output: unknown): string;
33
41
  declare function parseToolArgs(args: string): JsonValue;
34
42
 
35
- export { type AnyTool as A, type Tool as T, type ToolApprovalContext as a, type ToolApprovalPolicy as b, type ToolApprovalRunContext as c, parseToolArgs as p, serializeToolOutput as s };
43
+ export { type AnyTool as A, type Tool as T, type ToolApprovalContext as a, type ToolApprovalPolicy as b, type ToolApprovalRunContext as c, type ToolCallContext as d, type ToolCallStreamEvent as e, parseToolArgs as p, serializeToolOutput as s };
@@ -1,4 +1,4 @@
1
- import { A as AnyTool } from './tool-DhuBQ3yb.js';
1
+ import { A as AnyTool } from './tool-DiWtAf_Q.js';
2
2
 
3
3
  type Skill = {
4
4
  readonly name: string;
@@ -1,7 +1,7 @@
1
1
  import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
2
2
  import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
3
3
  import { J as JsonObject } from './types-BrxLd7ay.js';
4
- import { A as AnyTool } from './tool-DhuBQ3yb.js';
4
+ import { A as AnyTool } from './tool-DiWtAf_Q.js';
5
5
 
6
6
  type McpToolDefinition = {
7
7
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { VectorMetadataValue, VectorMetadata, EmbeddingModel, EmbeddedDocument, Embedding } from '../embeddings/index.js';
2
- import { T as Tool } from '../tool-DhuBQ3yb.js';
2
+ import { T as Tool } from '../tool-DiWtAf_Q.js';
3
3
  import '../types-BrxLd7ay.js';
4
4
 
5
5
  type VectorFilter = {
@@ -3,8 +3,8 @@ import {
3
3
  InMemoryVectorStore,
4
4
  createVectorSearchTool,
5
5
  vectorFilter
6
- } from "../chunk-SRGJPXKT.js";
7
- import "../chunk-B4QHQN5K.js";
6
+ } from "../chunk-MQVFDXPC.js";
7
+ import "../chunk-445TT5Q5.js";
8
8
  import "../chunk-A7VDIZQN.js";
9
9
  export {
10
10
  InMemoryVectorIndex,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvia/core",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Core runtime primitives for context-aware Anvia agents.",
5
5
  "author": "anvia",
6
6
  "maintainer": "Indra Zulfi",