@dudko.dev/agent 0.0.1 → 0.0.3

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/dist/index.d.cts CHANGED
@@ -1,20 +1,40 @@
1
+ import { ToolSet } from 'ai';
2
+
1
3
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google';
2
4
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
3
5
  type ToolSelectionStrategy = 'all' | 'plan-narrowed';
4
- interface IMcpServerConfig {
6
+ interface IMcpHttpServerConfig {
5
7
  url: string;
6
8
  headers?: Record<string, string>;
7
9
  getHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
8
10
  }
11
+ interface IMcpStdioServerConfig {
12
+ command: string;
13
+ args?: string[];
14
+ env?: Record<string, string>;
15
+ cwd?: string;
16
+ }
17
+ type IMcpServerConfig = IMcpHttpServerConfig | IMcpStdioServerConfig;
18
+ interface IAgentStageOverride {
19
+ providerType?: ProviderType;
20
+ baseURL?: string;
21
+ apiKey?: string;
22
+ model?: string;
23
+ }
9
24
  interface IAgentConfig {
10
25
  clientName: string;
11
26
  providerType: ProviderType;
12
27
  baseURL?: string;
13
28
  apiKey: string;
14
29
  model: string;
30
+ planner?: IAgentStageOverride;
31
+ synthesizer?: IAgentStageOverride;
32
+ /** @deprecated use `planner: { model }` */
15
33
  plannerModel?: string;
34
+ /** @deprecated use `synthesizer: { model }` */
16
35
  synthesizerModel?: string;
17
36
  mcpServers: Record<string, IMcpServerConfig>;
37
+ tools?: ToolSet;
18
38
  availableTools?: string[];
19
39
  excludedTools?: string[];
20
40
  maxIterations: number;
@@ -23,10 +43,15 @@ interface IAgentConfig {
23
43
  maxTotalTokens?: number;
24
44
  llmTimeoutMs?: number;
25
45
  llmMaxRetries?: number;
46
+ maxConcurrentRuns?: number;
47
+ persistence?: IPersistence;
26
48
  toolSelectionStrategy?: ToolSelectionStrategy;
49
+ inputSanitizer?: (toolName: string, input: unknown) => unknown | Promise<unknown>;
27
50
  outputSanitizer?: (toolName: string, output: unknown) => unknown | Promise<unknown>;
28
51
  logLevel: LogLevel;
29
52
  systemPrompt?: string;
53
+ sandboxRoot?: string;
54
+ keepSandbox?: boolean;
30
55
  failOnNoTools?: boolean;
31
56
  }
32
57
  interface IConversationTurn {
@@ -65,6 +90,10 @@ type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision';
65
90
  type AgentEventBody = {
66
91
  type: 'plan.thought-delta';
67
92
  delta: string;
93
+ } | {
94
+ type: 'plan.step-added';
95
+ step: IPlanStep;
96
+ index: number;
68
97
  } | {
69
98
  type: 'plan.created';
70
99
  plan: IPlan;
@@ -135,11 +164,18 @@ type AgentEvent = AgentEventBody & {
135
164
  runId?: string;
136
165
  };
137
166
  type EventHandler = (event: AgentEvent) => void;
167
+ interface IStepStartInfo {
168
+ step: IPlanStep;
169
+ index: number;
170
+ abort: () => void;
171
+ }
138
172
  interface IAgentRunOptions {
139
173
  input: string;
140
174
  history?: IConversationTurn[];
141
175
  signal?: AbortSignal;
142
176
  onEvent?: EventHandler;
177
+ onStepStart?: (info: IStepStartInfo) => void;
178
+ resumeFromRunId?: string;
143
179
  }
144
180
  interface IAgentRunResult {
145
181
  text: string;
@@ -148,8 +184,31 @@ interface IAgentRunResult {
148
184
  iterations: number;
149
185
  usage: IUsage;
150
186
  }
187
+ interface IRunSnapshot {
188
+ runId: string;
189
+ startedAt: number;
190
+ status: 'executing' | 'complete' | 'failed' | 'cancelled';
191
+ input: string;
192
+ history?: IConversationTurn[];
193
+ plan?: IPlan;
194
+ trace: IStepResult[];
195
+ usage: IUsage;
196
+ stepIndex: number;
197
+ iterations: number;
198
+ revisions: number;
199
+ text?: string;
200
+ error?: string;
201
+ completedAt?: number;
202
+ }
203
+ interface IPersistence {
204
+ onRunStart?: (snapshot: IRunSnapshot) => void | Promise<void>;
205
+ onStepComplete?: (snapshot: IRunSnapshot) => void | Promise<void>;
206
+ onRunComplete?: (snapshot: IRunSnapshot) => void | Promise<void>;
207
+ loadRun?: (runId: string) => IRunSnapshot | null | Promise<IRunSnapshot | null>;
208
+ }
151
209
 
152
210
  declare const getCurrentRunId: () => string | undefined;
211
+ declare const getCurrentRunSandbox: () => string | undefined;
153
212
 
154
213
  declare const redactHeaders: (headers: Record<string, string> | undefined) => Record<string, string> | undefined;
155
214
 
@@ -169,4 +228,4 @@ interface IAgent {
169
228
  }
170
229
  declare const createAgent: (config: IAgentConfig, baseEventHandler?: EventHandler) => Promise<IAgent>;
171
230
 
172
- export { type AgentEvent, type EventHandler, type IAgent, type IAgentConfig, type IAgentRunOptions, type IAgentRunResult, type ICloseOptions, type IConversationTurn, type IMcpServerConfig, type IPlan, type IPlanStep, type IStepResult, type IUsage, type LogLevel, type ProviderType, type ReplanCause, type ToolSelectionStrategy, createAgent, getCurrentRunId, redactHeaders };
231
+ export { type AgentEvent, type EventHandler, type IAgent, type IAgentConfig, type IAgentRunOptions, type IAgentRunResult, type IAgentStageOverride, type ICloseOptions, type IConversationTurn, type IMcpHttpServerConfig, type IMcpServerConfig, type IMcpStdioServerConfig, type IPersistence, type IPlan, type IPlanStep, type IRunSnapshot, type IStepResult, type IStepStartInfo, type IUsage, type LogLevel, type ProviderType, type ReplanCause, type ToolSelectionStrategy, createAgent, getCurrentRunId, getCurrentRunSandbox, redactHeaders };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,40 @@
1
+ import { ToolSet } from 'ai';
2
+
1
3
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google';
2
4
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
3
5
  type ToolSelectionStrategy = 'all' | 'plan-narrowed';
4
- interface IMcpServerConfig {
6
+ interface IMcpHttpServerConfig {
5
7
  url: string;
6
8
  headers?: Record<string, string>;
7
9
  getHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
8
10
  }
11
+ interface IMcpStdioServerConfig {
12
+ command: string;
13
+ args?: string[];
14
+ env?: Record<string, string>;
15
+ cwd?: string;
16
+ }
17
+ type IMcpServerConfig = IMcpHttpServerConfig | IMcpStdioServerConfig;
18
+ interface IAgentStageOverride {
19
+ providerType?: ProviderType;
20
+ baseURL?: string;
21
+ apiKey?: string;
22
+ model?: string;
23
+ }
9
24
  interface IAgentConfig {
10
25
  clientName: string;
11
26
  providerType: ProviderType;
12
27
  baseURL?: string;
13
28
  apiKey: string;
14
29
  model: string;
30
+ planner?: IAgentStageOverride;
31
+ synthesizer?: IAgentStageOverride;
32
+ /** @deprecated use `planner: { model }` */
15
33
  plannerModel?: string;
34
+ /** @deprecated use `synthesizer: { model }` */
16
35
  synthesizerModel?: string;
17
36
  mcpServers: Record<string, IMcpServerConfig>;
37
+ tools?: ToolSet;
18
38
  availableTools?: string[];
19
39
  excludedTools?: string[];
20
40
  maxIterations: number;
@@ -23,10 +43,15 @@ interface IAgentConfig {
23
43
  maxTotalTokens?: number;
24
44
  llmTimeoutMs?: number;
25
45
  llmMaxRetries?: number;
46
+ maxConcurrentRuns?: number;
47
+ persistence?: IPersistence;
26
48
  toolSelectionStrategy?: ToolSelectionStrategy;
49
+ inputSanitizer?: (toolName: string, input: unknown) => unknown | Promise<unknown>;
27
50
  outputSanitizer?: (toolName: string, output: unknown) => unknown | Promise<unknown>;
28
51
  logLevel: LogLevel;
29
52
  systemPrompt?: string;
53
+ sandboxRoot?: string;
54
+ keepSandbox?: boolean;
30
55
  failOnNoTools?: boolean;
31
56
  }
32
57
  interface IConversationTurn {
@@ -65,6 +90,10 @@ type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision';
65
90
  type AgentEventBody = {
66
91
  type: 'plan.thought-delta';
67
92
  delta: string;
93
+ } | {
94
+ type: 'plan.step-added';
95
+ step: IPlanStep;
96
+ index: number;
68
97
  } | {
69
98
  type: 'plan.created';
70
99
  plan: IPlan;
@@ -135,11 +164,18 @@ type AgentEvent = AgentEventBody & {
135
164
  runId?: string;
136
165
  };
137
166
  type EventHandler = (event: AgentEvent) => void;
167
+ interface IStepStartInfo {
168
+ step: IPlanStep;
169
+ index: number;
170
+ abort: () => void;
171
+ }
138
172
  interface IAgentRunOptions {
139
173
  input: string;
140
174
  history?: IConversationTurn[];
141
175
  signal?: AbortSignal;
142
176
  onEvent?: EventHandler;
177
+ onStepStart?: (info: IStepStartInfo) => void;
178
+ resumeFromRunId?: string;
143
179
  }
144
180
  interface IAgentRunResult {
145
181
  text: string;
@@ -148,8 +184,31 @@ interface IAgentRunResult {
148
184
  iterations: number;
149
185
  usage: IUsage;
150
186
  }
187
+ interface IRunSnapshot {
188
+ runId: string;
189
+ startedAt: number;
190
+ status: 'executing' | 'complete' | 'failed' | 'cancelled';
191
+ input: string;
192
+ history?: IConversationTurn[];
193
+ plan?: IPlan;
194
+ trace: IStepResult[];
195
+ usage: IUsage;
196
+ stepIndex: number;
197
+ iterations: number;
198
+ revisions: number;
199
+ text?: string;
200
+ error?: string;
201
+ completedAt?: number;
202
+ }
203
+ interface IPersistence {
204
+ onRunStart?: (snapshot: IRunSnapshot) => void | Promise<void>;
205
+ onStepComplete?: (snapshot: IRunSnapshot) => void | Promise<void>;
206
+ onRunComplete?: (snapshot: IRunSnapshot) => void | Promise<void>;
207
+ loadRun?: (runId: string) => IRunSnapshot | null | Promise<IRunSnapshot | null>;
208
+ }
151
209
 
152
210
  declare const getCurrentRunId: () => string | undefined;
211
+ declare const getCurrentRunSandbox: () => string | undefined;
153
212
 
154
213
  declare const redactHeaders: (headers: Record<string, string> | undefined) => Record<string, string> | undefined;
155
214
 
@@ -169,4 +228,4 @@ interface IAgent {
169
228
  }
170
229
  declare const createAgent: (config: IAgentConfig, baseEventHandler?: EventHandler) => Promise<IAgent>;
171
230
 
172
- export { type AgentEvent, type EventHandler, type IAgent, type IAgentConfig, type IAgentRunOptions, type IAgentRunResult, type ICloseOptions, type IConversationTurn, type IMcpServerConfig, type IPlan, type IPlanStep, type IStepResult, type IUsage, type LogLevel, type ProviderType, type ReplanCause, type ToolSelectionStrategy, createAgent, getCurrentRunId, redactHeaders };
231
+ export { type AgentEvent, type EventHandler, type IAgent, type IAgentConfig, type IAgentRunOptions, type IAgentRunResult, type IAgentStageOverride, type ICloseOptions, type IConversationTurn, type IMcpHttpServerConfig, type IMcpServerConfig, type IMcpStdioServerConfig, type IPersistence, type IPlan, type IPlanStep, type IRunSnapshot, type IStepResult, type IStepStartInfo, type IUsage, type LogLevel, type ProviderType, type ReplanCause, type ToolSelectionStrategy, createAgent, getCurrentRunId, getCurrentRunSandbox, redactHeaders };