@abassey/aid 0.1.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 (53) hide show
  1. package/dist/agents/index.cjs +741 -0
  2. package/dist/agents/index.d.cts +78 -0
  3. package/dist/agents/index.d.ts +78 -0
  4. package/dist/agents/index.js +741 -0
  5. package/dist/ai-AWJOUXFM.js +9 -0
  6. package/dist/ai-DOAYJKKI.cjs +9 -0
  7. package/dist/chunk-2TNYBUNK.js +124 -0
  8. package/dist/chunk-3LGKZRGY.cjs +124 -0
  9. package/dist/chunk-AUR2BBB5.cjs +1436 -0
  10. package/dist/chunk-IJLTRQF4.cjs +276 -0
  11. package/dist/chunk-JPD7UBAZ.js +58 -0
  12. package/dist/chunk-M4RQALTT.js +276 -0
  13. package/dist/chunk-NB65IHJE.cjs +58 -0
  14. package/dist/chunk-YNIEOBDF.js +1436 -0
  15. package/dist/client/index.cjs +18 -0
  16. package/dist/client/index.d.cts +8 -0
  17. package/dist/client/index.d.ts +8 -0
  18. package/dist/client/index.js +18 -0
  19. package/dist/errors-CUVTnseb.d.ts +13 -0
  20. package/dist/errors-CgCce4cK.d.cts +158 -0
  21. package/dist/errors-CgCce4cK.d.ts +158 -0
  22. package/dist/errors-zAPbTlpe.d.cts +13 -0
  23. package/dist/eval/index.cjs +308 -0
  24. package/dist/eval/index.d.cts +106 -0
  25. package/dist/eval/index.d.ts +106 -0
  26. package/dist/eval/index.js +308 -0
  27. package/dist/index.cjs +35 -0
  28. package/dist/index.d.cts +107 -0
  29. package/dist/index.d.ts +107 -0
  30. package/dist/index.js +35 -0
  31. package/dist/middleware/index.cjs +201 -0
  32. package/dist/middleware/index.d.cts +36 -0
  33. package/dist/middleware/index.d.ts +36 -0
  34. package/dist/middleware/index.js +201 -0
  35. package/dist/observability/index.cjs +147 -0
  36. package/dist/observability/index.d.cts +30 -0
  37. package/dist/observability/index.d.ts +30 -0
  38. package/dist/observability/index.js +147 -0
  39. package/dist/react/index.cjs +253 -0
  40. package/dist/react/index.d.cts +64 -0
  41. package/dist/react/index.d.ts +64 -0
  42. package/dist/react/index.js +253 -0
  43. package/dist/serve/index.cjs +545 -0
  44. package/dist/serve/index.d.cts +69 -0
  45. package/dist/serve/index.d.ts +69 -0
  46. package/dist/serve/index.js +545 -0
  47. package/dist/types-BJReASS-.d.cts +196 -0
  48. package/dist/types-BJReASS-.d.ts +196 -0
  49. package/dist/types-CguX3F16.d.cts +173 -0
  50. package/dist/types-CrFH-_qp.d.cts +68 -0
  51. package/dist/types-DvdzPmW0.d.ts +173 -0
  52. package/dist/types-qfE32ADy.d.ts +68 -0
  53. package/package.json +144 -0
@@ -0,0 +1,196 @@
1
+ interface AiOptions {
2
+ model?: string;
3
+ system?: string;
4
+ context?: string;
5
+ temperature?: number;
6
+ maxTokens?: number;
7
+ topP?: number;
8
+ stop?: string[];
9
+ timeout?: number;
10
+ tools?: Tool[];
11
+ middleware?: Middleware[];
12
+ stream?: boolean;
13
+ /** Internal: used by Conversation and tool loop to pass message history */
14
+ _messages?: Message[];
15
+ }
16
+ interface AiResponse {
17
+ text: string;
18
+ model: string;
19
+ tokens: TokenUsage;
20
+ cost: number;
21
+ latencyMs: number;
22
+ finishReason: "stop" | "length" | "tool_use" | "error";
23
+ toolCalls?: ToolCall[];
24
+ raw: unknown;
25
+ }
26
+ interface AiStreamChunk {
27
+ text: string;
28
+ delta: string;
29
+ done: boolean;
30
+ response?: AiResponse;
31
+ }
32
+ interface TokenUsage {
33
+ input: number;
34
+ output: number;
35
+ total: number;
36
+ }
37
+ interface ToolCall {
38
+ id: string;
39
+ name: string;
40
+ args: Record<string, unknown>;
41
+ }
42
+ type Message = {
43
+ role: "user";
44
+ content: string | ContentBlock[];
45
+ } | {
46
+ role: "assistant";
47
+ content: string | ContentBlock[];
48
+ } | {
49
+ role: "system";
50
+ content: string;
51
+ } | {
52
+ role: "tool";
53
+ toolCallId: string;
54
+ content: string;
55
+ };
56
+ type ContentBlock = {
57
+ type: "text";
58
+ text: string;
59
+ } | {
60
+ type: "image";
61
+ source: ImageSource;
62
+ } | {
63
+ type: "tool_use";
64
+ id: string;
65
+ name: string;
66
+ input: Record<string, unknown>;
67
+ } | {
68
+ type: "tool_result";
69
+ toolUseId: string;
70
+ content: string;
71
+ isError?: boolean;
72
+ };
73
+ interface ImageSource {
74
+ type: "base64" | "url";
75
+ mediaType?: string;
76
+ data: string;
77
+ }
78
+ interface ProviderRequest {
79
+ model: string;
80
+ messages: Message[];
81
+ options: ResolvedOptions;
82
+ system?: string;
83
+ tools?: ToolDefinition[];
84
+ }
85
+ type AiStream = AsyncIterable<AiStreamChunk> & {
86
+ on(event: "text", cb: (delta: string) => void): void;
87
+ on(event: "done", cb: (response: AiResponse) => void): void;
88
+ on(event: "error", cb: (error: Error) => void): void;
89
+ abort(): void;
90
+ };
91
+ interface ResolvedOptions {
92
+ model: string;
93
+ temperature: number;
94
+ maxTokens: number;
95
+ topP: number;
96
+ stop: string[];
97
+ timeout: number;
98
+ tools: Tool[];
99
+ middleware: Middleware[];
100
+ [key: string]: unknown;
101
+ }
102
+ interface ConversationOptions {
103
+ system?: string;
104
+ model?: string;
105
+ maxHistory?: number;
106
+ [key: string]: unknown;
107
+ }
108
+ interface SerializedConversation {
109
+ system: string;
110
+ messages: Message[];
111
+ options: ConversationOptions;
112
+ }
113
+ interface FluentAi {
114
+ system(prompt: string): FluentAi;
115
+ temperature(value: number): FluentAi;
116
+ maxTokens(value: number): FluentAi;
117
+ run(prompt: string): Promise<AiResponse>;
118
+ stream(prompt: string): AiStream;
119
+ }
120
+ interface AiFunction {
121
+ (prompt: string, options?: AiOptions): Promise<AiResponse>;
122
+ with(options: AiOptions): AiFunction;
123
+ safe(prompt: string, options?: AiOptions): Promise<[AiResponse | null, Error | null]>;
124
+ stream(prompt: string, options?: AiOptions): AiStream;
125
+ model(name: string): FluentAi;
126
+ multi(prompt: string, models: string[]): Promise<AiResponse[]>;
127
+ race(prompt: string, models: string[]): Promise<AiResponse>;
128
+ all(promises: Promise<AiResponse>[]): Promise<AiResponse[]>;
129
+ batch(prompts: string[], options?: BatchOptions): Promise<AiResponse[]>;
130
+ extract<T>(text: string, schema: unknown, options?: AiOptions): Promise<T>;
131
+ classify<T extends string>(text: string, categories: readonly T[], options?: AiOptions): Promise<T>;
132
+ json(prompt: string, options?: AiOptions): Promise<unknown>;
133
+ summarize(text: string, options?: SummarizeOptions): Promise<string>;
134
+ translate(text: string, language: string, options?: AiOptions): Promise<string>;
135
+ rewrite(text: string, style: string, options?: AiOptions): Promise<string>;
136
+ conversation(systemOrOptions?: string | ConversationOptions): Conversation;
137
+ }
138
+ interface Conversation {
139
+ say(message: string, options?: AiOptions): Promise<AiResponse>;
140
+ save(): SerializedConversation;
141
+ fork(): Conversation;
142
+ }
143
+ interface Tool {
144
+ name: string;
145
+ description: string;
146
+ parameters: JsonSchema;
147
+ handler: (args: Record<string, unknown>) => string | Promise<string>;
148
+ }
149
+ interface ToolDefinition {
150
+ name: string;
151
+ description: string;
152
+ parameters: JsonSchema;
153
+ }
154
+ interface JsonSchema {
155
+ type: string;
156
+ properties?: Record<string, unknown>;
157
+ required?: string[];
158
+ [key: string]: unknown;
159
+ }
160
+ interface Middleware {
161
+ name: string;
162
+ execute(request: ProviderRequest, next: (request: ProviderRequest) => Promise<AiResponse>, context?: MiddlewareContext): Promise<AiResponse>;
163
+ }
164
+ interface MiddlewareContext {
165
+ config: ResolvedOptions;
166
+ attempt?: number;
167
+ startTime?: number;
168
+ }
169
+ type ErrorCode = "auth_error" | "rate_limit" | "context_length" | "invalid_request" | "provider_error" | "network" | "timeout" | "parse_error" | "cost_limit" | "tool_loop_limit" | "agent_loop_limit" | "handoff_error" | "workflow_error" | "not_found" | "serve_error" | "unknown";
170
+ interface AidErrorOptions {
171
+ provider?: string;
172
+ model?: string;
173
+ retryAfter?: number;
174
+ statusCode?: number;
175
+ raw?: unknown;
176
+ cause?: Error;
177
+ }
178
+ interface BatchOptions {
179
+ concurrency?: number;
180
+ onProgress?: (completed: number, total: number) => void;
181
+ failFast?: boolean;
182
+ }
183
+ interface SummarizeOptions extends AiOptions {
184
+ style?: "paragraph" | "bullets" | "headline";
185
+ maxLength?: number;
186
+ }
187
+ interface RewriteOptions extends AiOptions {
188
+ preserveLength?: boolean;
189
+ }
190
+ interface RetryConfig {
191
+ maxAttempts?: number;
192
+ backoff?: "exponential" | "linear" | "fixed";
193
+ _baseDelay?: number;
194
+ }
195
+
196
+ export type { AiOptions as A, BatchOptions as B, ConversationOptions as C, ErrorCode as E, FluentAi as F, Middleware as M, ProviderRequest as P, ResolvedOptions as R, SummarizeOptions as S, Tool as T, AiFunction as a, AiStreamChunk as b, AiResponse as c, Message as d, RetryConfig as e, RewriteOptions as f, TokenUsage as g, ToolCall as h, MiddlewareContext as i, Conversation as j, AidErrorOptions as k };
@@ -0,0 +1,196 @@
1
+ interface AiOptions {
2
+ model?: string;
3
+ system?: string;
4
+ context?: string;
5
+ temperature?: number;
6
+ maxTokens?: number;
7
+ topP?: number;
8
+ stop?: string[];
9
+ timeout?: number;
10
+ tools?: Tool[];
11
+ middleware?: Middleware[];
12
+ stream?: boolean;
13
+ /** Internal: used by Conversation and tool loop to pass message history */
14
+ _messages?: Message[];
15
+ }
16
+ interface AiResponse {
17
+ text: string;
18
+ model: string;
19
+ tokens: TokenUsage;
20
+ cost: number;
21
+ latencyMs: number;
22
+ finishReason: "stop" | "length" | "tool_use" | "error";
23
+ toolCalls?: ToolCall[];
24
+ raw: unknown;
25
+ }
26
+ interface AiStreamChunk {
27
+ text: string;
28
+ delta: string;
29
+ done: boolean;
30
+ response?: AiResponse;
31
+ }
32
+ interface TokenUsage {
33
+ input: number;
34
+ output: number;
35
+ total: number;
36
+ }
37
+ interface ToolCall {
38
+ id: string;
39
+ name: string;
40
+ args: Record<string, unknown>;
41
+ }
42
+ type Message = {
43
+ role: "user";
44
+ content: string | ContentBlock[];
45
+ } | {
46
+ role: "assistant";
47
+ content: string | ContentBlock[];
48
+ } | {
49
+ role: "system";
50
+ content: string;
51
+ } | {
52
+ role: "tool";
53
+ toolCallId: string;
54
+ content: string;
55
+ };
56
+ type ContentBlock = {
57
+ type: "text";
58
+ text: string;
59
+ } | {
60
+ type: "image";
61
+ source: ImageSource;
62
+ } | {
63
+ type: "tool_use";
64
+ id: string;
65
+ name: string;
66
+ input: Record<string, unknown>;
67
+ } | {
68
+ type: "tool_result";
69
+ toolUseId: string;
70
+ content: string;
71
+ isError?: boolean;
72
+ };
73
+ interface ImageSource {
74
+ type: "base64" | "url";
75
+ mediaType?: string;
76
+ data: string;
77
+ }
78
+ interface ProviderRequest {
79
+ model: string;
80
+ messages: Message[];
81
+ options: ResolvedOptions;
82
+ system?: string;
83
+ tools?: ToolDefinition[];
84
+ }
85
+ type AiStream = AsyncIterable<AiStreamChunk> & {
86
+ on(event: "text", cb: (delta: string) => void): void;
87
+ on(event: "done", cb: (response: AiResponse) => void): void;
88
+ on(event: "error", cb: (error: Error) => void): void;
89
+ abort(): void;
90
+ };
91
+ interface ResolvedOptions {
92
+ model: string;
93
+ temperature: number;
94
+ maxTokens: number;
95
+ topP: number;
96
+ stop: string[];
97
+ timeout: number;
98
+ tools: Tool[];
99
+ middleware: Middleware[];
100
+ [key: string]: unknown;
101
+ }
102
+ interface ConversationOptions {
103
+ system?: string;
104
+ model?: string;
105
+ maxHistory?: number;
106
+ [key: string]: unknown;
107
+ }
108
+ interface SerializedConversation {
109
+ system: string;
110
+ messages: Message[];
111
+ options: ConversationOptions;
112
+ }
113
+ interface FluentAi {
114
+ system(prompt: string): FluentAi;
115
+ temperature(value: number): FluentAi;
116
+ maxTokens(value: number): FluentAi;
117
+ run(prompt: string): Promise<AiResponse>;
118
+ stream(prompt: string): AiStream;
119
+ }
120
+ interface AiFunction {
121
+ (prompt: string, options?: AiOptions): Promise<AiResponse>;
122
+ with(options: AiOptions): AiFunction;
123
+ safe(prompt: string, options?: AiOptions): Promise<[AiResponse | null, Error | null]>;
124
+ stream(prompt: string, options?: AiOptions): AiStream;
125
+ model(name: string): FluentAi;
126
+ multi(prompt: string, models: string[]): Promise<AiResponse[]>;
127
+ race(prompt: string, models: string[]): Promise<AiResponse>;
128
+ all(promises: Promise<AiResponse>[]): Promise<AiResponse[]>;
129
+ batch(prompts: string[], options?: BatchOptions): Promise<AiResponse[]>;
130
+ extract<T>(text: string, schema: unknown, options?: AiOptions): Promise<T>;
131
+ classify<T extends string>(text: string, categories: readonly T[], options?: AiOptions): Promise<T>;
132
+ json(prompt: string, options?: AiOptions): Promise<unknown>;
133
+ summarize(text: string, options?: SummarizeOptions): Promise<string>;
134
+ translate(text: string, language: string, options?: AiOptions): Promise<string>;
135
+ rewrite(text: string, style: string, options?: AiOptions): Promise<string>;
136
+ conversation(systemOrOptions?: string | ConversationOptions): Conversation;
137
+ }
138
+ interface Conversation {
139
+ say(message: string, options?: AiOptions): Promise<AiResponse>;
140
+ save(): SerializedConversation;
141
+ fork(): Conversation;
142
+ }
143
+ interface Tool {
144
+ name: string;
145
+ description: string;
146
+ parameters: JsonSchema;
147
+ handler: (args: Record<string, unknown>) => string | Promise<string>;
148
+ }
149
+ interface ToolDefinition {
150
+ name: string;
151
+ description: string;
152
+ parameters: JsonSchema;
153
+ }
154
+ interface JsonSchema {
155
+ type: string;
156
+ properties?: Record<string, unknown>;
157
+ required?: string[];
158
+ [key: string]: unknown;
159
+ }
160
+ interface Middleware {
161
+ name: string;
162
+ execute(request: ProviderRequest, next: (request: ProviderRequest) => Promise<AiResponse>, context?: MiddlewareContext): Promise<AiResponse>;
163
+ }
164
+ interface MiddlewareContext {
165
+ config: ResolvedOptions;
166
+ attempt?: number;
167
+ startTime?: number;
168
+ }
169
+ type ErrorCode = "auth_error" | "rate_limit" | "context_length" | "invalid_request" | "provider_error" | "network" | "timeout" | "parse_error" | "cost_limit" | "tool_loop_limit" | "agent_loop_limit" | "handoff_error" | "workflow_error" | "not_found" | "serve_error" | "unknown";
170
+ interface AidErrorOptions {
171
+ provider?: string;
172
+ model?: string;
173
+ retryAfter?: number;
174
+ statusCode?: number;
175
+ raw?: unknown;
176
+ cause?: Error;
177
+ }
178
+ interface BatchOptions {
179
+ concurrency?: number;
180
+ onProgress?: (completed: number, total: number) => void;
181
+ failFast?: boolean;
182
+ }
183
+ interface SummarizeOptions extends AiOptions {
184
+ style?: "paragraph" | "bullets" | "headline";
185
+ maxLength?: number;
186
+ }
187
+ interface RewriteOptions extends AiOptions {
188
+ preserveLength?: boolean;
189
+ }
190
+ interface RetryConfig {
191
+ maxAttempts?: number;
192
+ backoff?: "exponential" | "linear" | "fixed";
193
+ _baseDelay?: number;
194
+ }
195
+
196
+ export type { AiOptions as A, BatchOptions as B, ConversationOptions as C, ErrorCode as E, FluentAi as F, Middleware as M, ProviderRequest as P, ResolvedOptions as R, SummarizeOptions as S, Tool as T, AiFunction as a, AiStreamChunk as b, AiResponse as c, Message as d, RetryConfig as e, RewriteOptions as f, TokenUsage as g, ToolCall as h, MiddlewareContext as i, Conversation as j, AidErrorOptions as k };
@@ -0,0 +1,173 @@
1
+ import { T as Tool, d as Message, M as Middleware, a as AiFunction, g as TokenUsage, h as ToolCall, c as AiResponse } from './types-BJReASS-.cjs';
2
+ import { A as AidError } from './errors-zAPbTlpe.cjs';
3
+
4
+ type AgentEventCallback<E extends AgentEvent> = (payload: AgentEventMap[E]) => void;
5
+ interface AgentResult {
6
+ text: string;
7
+ completed: boolean;
8
+ messages: Message[];
9
+ steps: AgentStep[];
10
+ tokens: TokenUsage;
11
+ cost: number;
12
+ latencyMs: number;
13
+ toolCalls: ToolCall[];
14
+ error?: AidError;
15
+ }
16
+ interface AgentStep {
17
+ type: "llm_call" | "tool_call" | "handoff";
18
+ iteration: number;
19
+ timestamp: number;
20
+ data: LlmCallData | ToolCallData | HandoffData;
21
+ durationMs: number;
22
+ }
23
+ interface LlmCallData {
24
+ model: string;
25
+ tokens: TokenUsage;
26
+ finishReason: string;
27
+ }
28
+ interface ToolCallData {
29
+ id: string;
30
+ name: string;
31
+ args: Record<string, unknown>;
32
+ result: string;
33
+ isError: boolean;
34
+ }
35
+ interface HandoffData {
36
+ from: string;
37
+ to: string;
38
+ message: string;
39
+ }
40
+ type AgentEvent = "step:start" | "step:end" | "tool:call" | "tool:result" | "handoff" | "message" | "done" | "error";
41
+ interface AgentEventMap {
42
+ "step:start": {
43
+ step: number;
44
+ iteration: number;
45
+ };
46
+ "step:end": {
47
+ step: number;
48
+ iteration: number;
49
+ result?: AiResponse;
50
+ };
51
+ "tool:call": {
52
+ id: string;
53
+ name: string;
54
+ args: Record<string, unknown>;
55
+ };
56
+ "tool:result": {
57
+ id: string;
58
+ name: string;
59
+ result: string;
60
+ durationMs: number;
61
+ };
62
+ "handoff": {
63
+ from: string;
64
+ to: string;
65
+ message: string;
66
+ };
67
+ "message": {
68
+ role: string;
69
+ content: string;
70
+ };
71
+ "done": {
72
+ result: AgentResult;
73
+ };
74
+ "error": {
75
+ error: AidError;
76
+ step?: number;
77
+ };
78
+ }
79
+ interface AgentConfig {
80
+ name: string;
81
+ role: string;
82
+ model?: string;
83
+ tools?: Tool[];
84
+ memory?: boolean | MemoryProvider;
85
+ maxIterations?: number;
86
+ maxChatHistory?: number;
87
+ middleware?: Middleware[];
88
+ temperature?: number;
89
+ maxTokens?: number;
90
+ ai?: AiFunction;
91
+ }
92
+ interface Agent {
93
+ readonly name: string;
94
+ readonly config: AgentConfig;
95
+ run(task: string): Promise<AgentResult>;
96
+ chat(message: string): Promise<AgentResult>;
97
+ clone(overrides?: Partial<AgentConfig>): Agent;
98
+ on<E extends AgentEvent>(event: E, cb: AgentEventCallback<E>): void;
99
+ off<E extends AgentEvent>(event: E, cb: AgentEventCallback<E>): void;
100
+ }
101
+ interface MemoryProvider {
102
+ add(messages: Message[]): Promise<void>;
103
+ retrieve(query: string, limit?: number): Promise<Message[]>;
104
+ clear(): Promise<void>;
105
+ }
106
+ type OrchestratorEventPayload<E extends AgentEvent> = AgentEventMap[E] & {
107
+ agent: string;
108
+ };
109
+ type OrchestratorEventCallback<E extends AgentEvent> = (payload: OrchestratorEventPayload<E>) => void;
110
+ type CrewConfig = {
111
+ agents: Agent[];
112
+ strategy: "sequential";
113
+ } | {
114
+ agents: Agent[];
115
+ strategy: "parallel";
116
+ } | {
117
+ agents: Agent[];
118
+ strategy: "conditional";
119
+ router: (task: string) => string;
120
+ };
121
+ interface CrewResult {
122
+ text: string;
123
+ agentResults: Map<string, AgentResult>;
124
+ totalTokens: TokenUsage;
125
+ totalCost: number;
126
+ latencyMs: number;
127
+ }
128
+ interface Crew {
129
+ run(task: string): Promise<CrewResult>;
130
+ on<E extends AgentEvent>(event: E, cb: OrchestratorEventCallback<E>): void;
131
+ off<E extends AgentEvent>(event: E, cb: OrchestratorEventCallback<E>): void;
132
+ }
133
+ interface WorkflowStep {
134
+ name: string;
135
+ agent: Agent;
136
+ input?: string | string[];
137
+ condition?: (results: Map<string, AgentResult>) => boolean;
138
+ }
139
+ interface WorkflowConfig {
140
+ steps: WorkflowStep[];
141
+ }
142
+ interface WorkflowResult {
143
+ text: string;
144
+ stepResults: Map<string, AgentResult>;
145
+ totalTokens: TokenUsage;
146
+ totalCost: number;
147
+ latencyMs: number;
148
+ }
149
+ interface Workflow {
150
+ run(task: string): Promise<WorkflowResult>;
151
+ on<E extends AgentEvent>(event: E, cb: OrchestratorEventCallback<E>): void;
152
+ off<E extends AgentEvent>(event: E, cb: OrchestratorEventCallback<E>): void;
153
+ }
154
+ interface SwarmConfig {
155
+ agents: Agent[];
156
+ entry: string;
157
+ maxHandoffs?: number;
158
+ }
159
+ interface SwarmResult {
160
+ text: string;
161
+ handoffChain: string[];
162
+ agentResults: Map<string, AgentResult>;
163
+ totalTokens: TokenUsage;
164
+ totalCost: number;
165
+ latencyMs: number;
166
+ }
167
+ interface Swarm {
168
+ run(task: string): Promise<SwarmResult>;
169
+ on<E extends AgentEvent>(event: E, cb: OrchestratorEventCallback<E>): void;
170
+ off<E extends AgentEvent>(event: E, cb: OrchestratorEventCallback<E>): void;
171
+ }
172
+
173
+ export type { AgentConfig as A, CrewConfig as C, HandoffData as H, LlmCallData as L, MemoryProvider as M, OrchestratorEventCallback as O, SwarmConfig as S, ToolCallData as T, WorkflowConfig as W, Agent as a, Crew as b, Workflow as c, Swarm as d, AgentEvent as e, AgentEventCallback as f, AgentEventMap as g, AgentResult as h, AgentStep as i, CrewResult as j, OrchestratorEventPayload as k, SwarmResult as l, WorkflowResult as m, WorkflowStep as n };
@@ -0,0 +1,68 @@
1
+ import { g as TokenUsage, P as ProviderRequest } from './types-BJReASS-.cjs';
2
+
3
+ interface Span {
4
+ id: string;
5
+ parentId?: string;
6
+ name: string;
7
+ startTime: number;
8
+ endTime: number;
9
+ durationMs: number;
10
+ model: string;
11
+ provider: string;
12
+ tokens: TokenUsage;
13
+ cost: number;
14
+ status: "ok" | "error";
15
+ error?: {
16
+ message: string;
17
+ code?: string;
18
+ };
19
+ metadata: Record<string, unknown>;
20
+ }
21
+ interface SpanFilter {
22
+ name?: string;
23
+ model?: string;
24
+ status?: "ok" | "error";
25
+ from?: number;
26
+ to?: number;
27
+ parentId?: string;
28
+ }
29
+ interface TraceStore {
30
+ add(span: Span): void;
31
+ list(filter?: SpanFilter): Span[];
32
+ get(id: string): Span | undefined;
33
+ clear(): void;
34
+ }
35
+ interface ActiveSpan {
36
+ readonly id: string;
37
+ readonly name: string;
38
+ annotate(key: string, value: unknown): void;
39
+ }
40
+ type CostPeriod = "today" | "yesterday" | "this-week" | "this-month" | {
41
+ from: number;
42
+ to: number;
43
+ };
44
+ interface CostReport {
45
+ totalCost: number;
46
+ totalTokens: TokenUsage;
47
+ calls: number;
48
+ byModel: Record<string, ModelCostBreakdown>;
49
+ byProvider: Record<string, {
50
+ cost: number;
51
+ calls: number;
52
+ }>;
53
+ period: {
54
+ from: number;
55
+ to: number;
56
+ };
57
+ }
58
+ interface ModelCostBreakdown {
59
+ cost: number;
60
+ calls: number;
61
+ tokens: TokenUsage;
62
+ }
63
+ interface TracingOptions {
64
+ store?: TraceStore;
65
+ nameFrom?: (req: ProviderRequest) => string;
66
+ }
67
+
68
+ export type { ActiveSpan as A, CostPeriod as C, ModelCostBreakdown as M, Span as S, TracingOptions as T, TraceStore as a, SpanFilter as b, CostReport as c };