@dvina/agents 0.3.7 → 0.5.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.
@@ -0,0 +1,158 @@
1
+ import { ZodObject } from 'zod';
2
+
3
+ interface Agent {
4
+ run(input: AgentRunInput): Promise<AgentResult>;
5
+ stream(input: AgentRunInput): AsyncGenerator<StreamEvent>;
6
+ }
7
+ interface BaseStreamEvent {
8
+ type: string;
9
+ }
10
+ interface MessageStartEvent extends BaseStreamEvent {
11
+ type: 'message_start';
12
+ }
13
+ interface MessageEndEvent extends BaseStreamEvent {
14
+ type: 'message_end';
15
+ }
16
+ interface ChatTitleEvent extends BaseStreamEvent {
17
+ type: 'chat_title';
18
+ title: string;
19
+ }
20
+ interface AudioEvent extends BaseStreamEvent {
21
+ type: 'audio';
22
+ data: string;
23
+ duration: number;
24
+ }
25
+ interface TextBlockEvent extends BaseStreamEvent {
26
+ type: 'text_block';
27
+ text: string;
28
+ }
29
+ interface TextDeltaEvent extends BaseStreamEvent {
30
+ type: 'text_delta';
31
+ delta: string;
32
+ }
33
+ interface ToolStartEvent extends BaseStreamEvent {
34
+ type: 'tool_start';
35
+ name: string;
36
+ toolKit: string;
37
+ toolKitIconUrl?: string;
38
+ index: number;
39
+ toolCallId: string;
40
+ }
41
+ interface ToolInputDeltaEvent extends BaseStreamEvent {
42
+ type: 'tool_input_delta';
43
+ name: string;
44
+ args: string;
45
+ index: number;
46
+ toolCallId: string;
47
+ }
48
+ interface ToolResultEvent extends BaseStreamEvent {
49
+ type: 'tool_result';
50
+ name: string;
51
+ toolKit: string;
52
+ toolKitIconUrl?: string;
53
+ input: string;
54
+ output: string;
55
+ index: number;
56
+ toolCallId: string;
57
+ }
58
+ interface ReasoningEvent extends BaseStreamEvent {
59
+ type: 'reasoning';
60
+ delta: string;
61
+ }
62
+ interface FinalContentEvent extends BaseStreamEvent {
63
+ type: 'final_content';
64
+ content: ContentBlock[];
65
+ usage: UsageMeta;
66
+ }
67
+ type StreamEvent = MessageStartEvent | MessageEndEvent | ChatTitleEvent | AudioEvent | TextBlockEvent | TextDeltaEvent | ToolStartEvent | ToolResultEvent | ReasoningEvent | ToolInputDeltaEvent | FinalContentEvent;
68
+ interface ToolSpec {
69
+ toolKit: string;
70
+ name: string;
71
+ description: string;
72
+ inputSchema: ZodObject;
73
+ instruction?: string;
74
+ toolKitIconUrl?: string;
75
+ }
76
+ interface ToolDefinition extends ToolSpec {
77
+ exec: (input: any) => Promise<unknown> | unknown;
78
+ }
79
+ interface ToolCall {
80
+ id: string;
81
+ name: string;
82
+ input: unknown;
83
+ output?: unknown;
84
+ }
85
+ type ToolCallContentBlock = {
86
+ type: 'tool_call';
87
+ name: string;
88
+ toolKit: string;
89
+ toolKitIconUrl?: string;
90
+ input: string | null;
91
+ output: string;
92
+ toolCallId: string;
93
+ };
94
+ type TextContentBlock = {
95
+ type: 'text';
96
+ output: string;
97
+ };
98
+ type ContentBlock = ToolCallContentBlock | TextContentBlock;
99
+ interface AgentResult {
100
+ content: ContentBlock[];
101
+ toolCalls: ToolCall[];
102
+ usage: UsageMeta;
103
+ }
104
+ interface AgentRunInput {
105
+ threadId: string;
106
+ messages: Message[];
107
+ }
108
+ interface UsageMeta {
109
+ promptTokens: number;
110
+ completionTokens: number;
111
+ totalTokens: number;
112
+ cachedPromptTokens?: number;
113
+ }
114
+ type Message = HumanMessage | AiMessage | ToolMessage;
115
+ interface HumanMessage {
116
+ role: 'human';
117
+ content: InputContentBlock[];
118
+ }
119
+ interface AiMessage {
120
+ role: 'ai';
121
+ content: string;
122
+ toolCalls?: {
123
+ name: string;
124
+ input?: string;
125
+ }[];
126
+ }
127
+ interface ToolMessage {
128
+ role: 'tool';
129
+ name: string;
130
+ output: string;
131
+ }
132
+ type InputContentBlock = {
133
+ type: 'text';
134
+ text: string;
135
+ } | {
136
+ type: 'image';
137
+ url: string;
138
+ };
139
+
140
+ type LangchainOpenAIConfig = {
141
+ apiKey: string;
142
+ };
143
+ type LangchainAzureResourceConfig = {
144
+ apiKey: string;
145
+ endpoint: string;
146
+ models: {
147
+ model: string;
148
+ apiVersion: string;
149
+ deploymentName: string;
150
+ }[];
151
+ };
152
+ type ResourceName = string;
153
+ type LangchainModelConfig = {
154
+ openai?: Record<string, LangchainOpenAIConfig>;
155
+ azure?: Record<ResourceName, LangchainAzureResourceConfig>;
156
+ };
157
+
158
+ export type { Agent as A, ContentBlock as C, HumanMessage as H, LangchainModelConfig as L, Message as M, StreamEvent as S, ToolDefinition as T, UsageMeta as U, ToolSpec as a, AgentResult as b, AgentRunInput as c, AiMessage as d, ToolCall as e, ToolMessage as f };
@@ -0,0 +1,158 @@
1
+ import { ZodObject } from 'zod';
2
+
3
+ interface Agent {
4
+ run(input: AgentRunInput): Promise<AgentResult>;
5
+ stream(input: AgentRunInput): AsyncGenerator<StreamEvent>;
6
+ }
7
+ interface BaseStreamEvent {
8
+ type: string;
9
+ }
10
+ interface MessageStartEvent extends BaseStreamEvent {
11
+ type: 'message_start';
12
+ }
13
+ interface MessageEndEvent extends BaseStreamEvent {
14
+ type: 'message_end';
15
+ }
16
+ interface ChatTitleEvent extends BaseStreamEvent {
17
+ type: 'chat_title';
18
+ title: string;
19
+ }
20
+ interface AudioEvent extends BaseStreamEvent {
21
+ type: 'audio';
22
+ data: string;
23
+ duration: number;
24
+ }
25
+ interface TextBlockEvent extends BaseStreamEvent {
26
+ type: 'text_block';
27
+ text: string;
28
+ }
29
+ interface TextDeltaEvent extends BaseStreamEvent {
30
+ type: 'text_delta';
31
+ delta: string;
32
+ }
33
+ interface ToolStartEvent extends BaseStreamEvent {
34
+ type: 'tool_start';
35
+ name: string;
36
+ toolKit: string;
37
+ toolKitIconUrl?: string;
38
+ index: number;
39
+ toolCallId: string;
40
+ }
41
+ interface ToolInputDeltaEvent extends BaseStreamEvent {
42
+ type: 'tool_input_delta';
43
+ name: string;
44
+ args: string;
45
+ index: number;
46
+ toolCallId: string;
47
+ }
48
+ interface ToolResultEvent extends BaseStreamEvent {
49
+ type: 'tool_result';
50
+ name: string;
51
+ toolKit: string;
52
+ toolKitIconUrl?: string;
53
+ input: string;
54
+ output: string;
55
+ index: number;
56
+ toolCallId: string;
57
+ }
58
+ interface ReasoningEvent extends BaseStreamEvent {
59
+ type: 'reasoning';
60
+ delta: string;
61
+ }
62
+ interface FinalContentEvent extends BaseStreamEvent {
63
+ type: 'final_content';
64
+ content: ContentBlock[];
65
+ usage: UsageMeta;
66
+ }
67
+ type StreamEvent = MessageStartEvent | MessageEndEvent | ChatTitleEvent | AudioEvent | TextBlockEvent | TextDeltaEvent | ToolStartEvent | ToolResultEvent | ReasoningEvent | ToolInputDeltaEvent | FinalContentEvent;
68
+ interface ToolSpec {
69
+ toolKit: string;
70
+ name: string;
71
+ description: string;
72
+ inputSchema: ZodObject;
73
+ instruction?: string;
74
+ toolKitIconUrl?: string;
75
+ }
76
+ interface ToolDefinition extends ToolSpec {
77
+ exec: (input: any) => Promise<unknown> | unknown;
78
+ }
79
+ interface ToolCall {
80
+ id: string;
81
+ name: string;
82
+ input: unknown;
83
+ output?: unknown;
84
+ }
85
+ type ToolCallContentBlock = {
86
+ type: 'tool_call';
87
+ name: string;
88
+ toolKit: string;
89
+ toolKitIconUrl?: string;
90
+ input: string | null;
91
+ output: string;
92
+ toolCallId: string;
93
+ };
94
+ type TextContentBlock = {
95
+ type: 'text';
96
+ output: string;
97
+ };
98
+ type ContentBlock = ToolCallContentBlock | TextContentBlock;
99
+ interface AgentResult {
100
+ content: ContentBlock[];
101
+ toolCalls: ToolCall[];
102
+ usage: UsageMeta;
103
+ }
104
+ interface AgentRunInput {
105
+ threadId: string;
106
+ messages: Message[];
107
+ }
108
+ interface UsageMeta {
109
+ promptTokens: number;
110
+ completionTokens: number;
111
+ totalTokens: number;
112
+ cachedPromptTokens?: number;
113
+ }
114
+ type Message = HumanMessage | AiMessage | ToolMessage;
115
+ interface HumanMessage {
116
+ role: 'human';
117
+ content: InputContentBlock[];
118
+ }
119
+ interface AiMessage {
120
+ role: 'ai';
121
+ content: string;
122
+ toolCalls?: {
123
+ name: string;
124
+ input?: string;
125
+ }[];
126
+ }
127
+ interface ToolMessage {
128
+ role: 'tool';
129
+ name: string;
130
+ output: string;
131
+ }
132
+ type InputContentBlock = {
133
+ type: 'text';
134
+ text: string;
135
+ } | {
136
+ type: 'image';
137
+ url: string;
138
+ };
139
+
140
+ type LangchainOpenAIConfig = {
141
+ apiKey: string;
142
+ };
143
+ type LangchainAzureResourceConfig = {
144
+ apiKey: string;
145
+ endpoint: string;
146
+ models: {
147
+ model: string;
148
+ apiVersion: string;
149
+ deploymentName: string;
150
+ }[];
151
+ };
152
+ type ResourceName = string;
153
+ type LangchainModelConfig = {
154
+ openai?: Record<string, LangchainOpenAIConfig>;
155
+ azure?: Record<ResourceName, LangchainAzureResourceConfig>;
156
+ };
157
+
158
+ export type { Agent as A, ContentBlock as C, HumanMessage as H, LangchainModelConfig as L, Message as M, StreamEvent as S, ToolDefinition as T, UsageMeta as U, ToolSpec as a, AgentResult as b, AgentRunInput as c, AiMessage as d, ToolCall as e, ToolMessage as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvina/agents",
3
- "version": "0.3.7",
3
+ "version": "0.5.0",
4
4
  "description": "Standalone, provider-agnostic AI agent library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -13,6 +13,16 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "default": "./dist/index.js"
15
15
  }
16
+ },
17
+ "./eval": {
18
+ "import": {
19
+ "types": "./dist/eval/index.d.mts",
20
+ "default": "./dist/eval/index.mjs"
21
+ },
22
+ "require": {
23
+ "types": "./dist/eval/index.d.ts",
24
+ "default": "./dist/eval/index.js"
25
+ }
16
26
  }
17
27
  },
18
28
  "files": [
@@ -35,7 +45,21 @@
35
45
  "author": "",
36
46
  "license": "MIT",
37
47
  "peerDependencies": {
38
- "zod": "^4.3.6"
48
+ "zod": "^4.3.6",
49
+ "agentevals": ">=0.0.6",
50
+ "langsmith": ">=0.4.0",
51
+ "vitest": ">=4.0.0"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "agentevals": {
55
+ "optional": true
56
+ },
57
+ "langsmith": {
58
+ "optional": true
59
+ },
60
+ "vitest": {
61
+ "optional": true
62
+ }
39
63
  },
40
64
  "dependencies": {
41
65
  "@anthropic-ai/sdk": "^0.71.2",
@@ -47,11 +71,16 @@
47
71
  "ioredis": "^5.9.2",
48
72
  "langchain": "^1.2.14"
49
73
  },
74
+ "overrides": {
75
+ "agentevals": {
76
+ "@langchain/openai": "0.5.18"
77
+ }
78
+ },
50
79
  "devDependencies": {
51
80
  "@types/node": "^20.11.16",
52
- "dotenv": "^17.2.3",
81
+ "agentevals": "^0.0.6",
82
+ "langsmith": "^0.4.12",
53
83
  "tsup": "^8.0.2",
54
- "tsx": "^4.21.0",
55
84
  "typescript": "^5.3.3",
56
85
  "vitest": "^4.0.17"
57
86
  },