@lupaflow/types 0.1.0 → 0.1.2
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.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +319 -0
- package/dist/index.d.ts +319 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -2
- package/tsconfig.json +0 -8
- package/tsup.config.ts +0 -9
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./events\"\nexport * from \"./provider\"\nexport * from \"./tool\"\nexport * from \"./memory\"\nexport * from \"./agent\"\nexport * from \"./workflow\"\nexport * from \"./plugin\"\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
type EventName = "agent:start" | "agent:thinking" | "agent:response" | "agent:error" | "agent:complete" | "tool:start" | "tool:finish" | "tool:error" | "memory:update" | "memory:retrieve" | "workflow:start" | "workflow:step" | "workflow:complete" | "workflow:error" | "provider:start" | "provider:complete" | "provider:error" | "llm:token";
|
|
2
|
+
interface BaseEvent {
|
|
3
|
+
id: string;
|
|
4
|
+
name: EventName;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
agentId?: string;
|
|
7
|
+
runId?: string;
|
|
8
|
+
}
|
|
9
|
+
interface AgentStartEvent extends BaseEvent {
|
|
10
|
+
name: "agent:start";
|
|
11
|
+
config: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface AgentThinkingEvent extends BaseEvent {
|
|
14
|
+
name: "agent:thinking";
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
interface AgentResponseEvent extends BaseEvent {
|
|
18
|
+
name: "agent:response";
|
|
19
|
+
content: string;
|
|
20
|
+
tokens?: number;
|
|
21
|
+
latencyMs?: number;
|
|
22
|
+
}
|
|
23
|
+
interface AgentErrorEvent extends BaseEvent {
|
|
24
|
+
name: "agent:error";
|
|
25
|
+
error: string;
|
|
26
|
+
retryAttempt?: number;
|
|
27
|
+
}
|
|
28
|
+
interface AgentCompleteEvent extends BaseEvent {
|
|
29
|
+
name: "agent:complete";
|
|
30
|
+
totalTokens: number;
|
|
31
|
+
totalLatencyMs: number;
|
|
32
|
+
toolCalls: number;
|
|
33
|
+
}
|
|
34
|
+
interface ToolStartEvent extends BaseEvent {
|
|
35
|
+
name: "tool:start";
|
|
36
|
+
tool: string;
|
|
37
|
+
args: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
interface ToolFinishEvent extends BaseEvent {
|
|
40
|
+
name: "tool:finish";
|
|
41
|
+
tool: string;
|
|
42
|
+
result: unknown;
|
|
43
|
+
durationMs: number;
|
|
44
|
+
}
|
|
45
|
+
interface ToolErrorEvent extends BaseEvent {
|
|
46
|
+
name: "tool:error";
|
|
47
|
+
tool: string;
|
|
48
|
+
error: string;
|
|
49
|
+
}
|
|
50
|
+
interface MemoryUpdateEvent extends BaseEvent {
|
|
51
|
+
name: "memory:update";
|
|
52
|
+
type: string;
|
|
53
|
+
key: string;
|
|
54
|
+
}
|
|
55
|
+
interface MemoryRetrieveEvent extends BaseEvent {
|
|
56
|
+
name: "memory:retrieve";
|
|
57
|
+
type: string;
|
|
58
|
+
key: string;
|
|
59
|
+
results: number;
|
|
60
|
+
}
|
|
61
|
+
interface WorkflowStartEvent extends BaseEvent {
|
|
62
|
+
name: "workflow:start";
|
|
63
|
+
steps: number;
|
|
64
|
+
}
|
|
65
|
+
interface WorkflowStepEvent extends BaseEvent {
|
|
66
|
+
name: "workflow:step";
|
|
67
|
+
step: number;
|
|
68
|
+
stepName: string;
|
|
69
|
+
status: "running" | "completed" | "failed";
|
|
70
|
+
}
|
|
71
|
+
interface WorkflowCompleteEvent extends BaseEvent {
|
|
72
|
+
name: "workflow:complete";
|
|
73
|
+
totalSteps: number;
|
|
74
|
+
failedSteps: number;
|
|
75
|
+
durationMs: number;
|
|
76
|
+
}
|
|
77
|
+
interface ProviderStartEvent extends BaseEvent {
|
|
78
|
+
name: "provider:start";
|
|
79
|
+
provider: string;
|
|
80
|
+
model: string;
|
|
81
|
+
}
|
|
82
|
+
interface ProviderCompleteEvent extends BaseEvent {
|
|
83
|
+
name: "provider:complete";
|
|
84
|
+
provider: string;
|
|
85
|
+
model: string;
|
|
86
|
+
tokens: number;
|
|
87
|
+
latencyMs: number;
|
|
88
|
+
cost?: number;
|
|
89
|
+
}
|
|
90
|
+
interface ProviderErrorEvent extends BaseEvent {
|
|
91
|
+
name: "provider:error";
|
|
92
|
+
provider: string;
|
|
93
|
+
model: string;
|
|
94
|
+
error: string;
|
|
95
|
+
}
|
|
96
|
+
interface LLMTokenEvent extends BaseEvent {
|
|
97
|
+
name: "llm:token";
|
|
98
|
+
tokens: number;
|
|
99
|
+
cost?: number;
|
|
100
|
+
}
|
|
101
|
+
type LupaEvent = AgentStartEvent | AgentThinkingEvent | AgentResponseEvent | AgentErrorEvent | AgentCompleteEvent | ToolStartEvent | ToolFinishEvent | ToolErrorEvent | MemoryUpdateEvent | MemoryRetrieveEvent | WorkflowStartEvent | WorkflowStepEvent | WorkflowCompleteEvent | ProviderStartEvent | ProviderCompleteEvent | ProviderErrorEvent | LLMTokenEvent;
|
|
102
|
+
|
|
103
|
+
interface ToolParameter {
|
|
104
|
+
type: "string" | "number" | "boolean" | "array" | "object";
|
|
105
|
+
description: string;
|
|
106
|
+
required?: boolean;
|
|
107
|
+
enum?: string[];
|
|
108
|
+
items?: ToolParameter;
|
|
109
|
+
properties?: Record<string, ToolParameter>;
|
|
110
|
+
}
|
|
111
|
+
interface ToolDefinition {
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
parameters: Record<string, ToolParameter>;
|
|
115
|
+
required?: string[];
|
|
116
|
+
}
|
|
117
|
+
interface Tool {
|
|
118
|
+
definition: ToolDefinition;
|
|
119
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type ProviderName = "openai" | "anthropic" | "google" | "openrouter" | "groq" | "mistral" | "xai" | "ollama";
|
|
123
|
+
type ModelRole = "system" | "user" | "assistant" | "tool";
|
|
124
|
+
interface Message {
|
|
125
|
+
role: ModelRole;
|
|
126
|
+
content: string | null;
|
|
127
|
+
toolCallId?: string;
|
|
128
|
+
name?: string;
|
|
129
|
+
toolCalls?: Array<{
|
|
130
|
+
id: string;
|
|
131
|
+
type: "function";
|
|
132
|
+
function: {
|
|
133
|
+
name: string;
|
|
134
|
+
arguments: string;
|
|
135
|
+
};
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
interface ToolCall {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
args: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
interface ToolResult {
|
|
144
|
+
toolCallId: string;
|
|
145
|
+
name: string;
|
|
146
|
+
content: string;
|
|
147
|
+
}
|
|
148
|
+
interface ProviderConfig {
|
|
149
|
+
apiKey?: string;
|
|
150
|
+
baseUrl?: string;
|
|
151
|
+
model?: string;
|
|
152
|
+
temperature?: number;
|
|
153
|
+
maxTokens?: number;
|
|
154
|
+
topP?: number;
|
|
155
|
+
}
|
|
156
|
+
interface CompletionRequest {
|
|
157
|
+
messages: Message[];
|
|
158
|
+
tools?: Tool[];
|
|
159
|
+
systemPrompt?: string;
|
|
160
|
+
temperature?: number;
|
|
161
|
+
maxTokens?: number;
|
|
162
|
+
topP?: number;
|
|
163
|
+
model?: string;
|
|
164
|
+
}
|
|
165
|
+
interface CompletionResponse {
|
|
166
|
+
content: string | null;
|
|
167
|
+
toolCalls: ToolCall[];
|
|
168
|
+
usage: {
|
|
169
|
+
promptTokens: number;
|
|
170
|
+
completionTokens: number;
|
|
171
|
+
totalTokens: number;
|
|
172
|
+
};
|
|
173
|
+
model: string;
|
|
174
|
+
latencyMs: number;
|
|
175
|
+
finishReason: string;
|
|
176
|
+
}
|
|
177
|
+
type StreamChunk = {
|
|
178
|
+
type: "text";
|
|
179
|
+
text: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: "tool_call";
|
|
182
|
+
toolCall: ToolCall;
|
|
183
|
+
} | {
|
|
184
|
+
type: "finish";
|
|
185
|
+
content: string;
|
|
186
|
+
toolCalls: ToolCall[];
|
|
187
|
+
usage: {
|
|
188
|
+
promptTokens: number;
|
|
189
|
+
completionTokens: number;
|
|
190
|
+
totalTokens: number;
|
|
191
|
+
};
|
|
192
|
+
model: string;
|
|
193
|
+
finishReason: string;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
type MemoryType = "short-term" | "long-term" | "semantic" | "session" | "user" | "project" | "vector";
|
|
197
|
+
interface MemoryEntry {
|
|
198
|
+
id: string;
|
|
199
|
+
type: MemoryType;
|
|
200
|
+
key: string;
|
|
201
|
+
content: string;
|
|
202
|
+
metadata?: Record<string, unknown>;
|
|
203
|
+
timestamp: number;
|
|
204
|
+
scope?: string;
|
|
205
|
+
}
|
|
206
|
+
interface MemoryQuery {
|
|
207
|
+
type?: MemoryType;
|
|
208
|
+
key?: string;
|
|
209
|
+
scope?: string;
|
|
210
|
+
query?: string;
|
|
211
|
+
limit?: number;
|
|
212
|
+
threshold?: number;
|
|
213
|
+
}
|
|
214
|
+
interface MemorySearchResult {
|
|
215
|
+
entry: MemoryEntry;
|
|
216
|
+
score: number;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface Personality {
|
|
220
|
+
name?: string;
|
|
221
|
+
traits?: string[];
|
|
222
|
+
tone?: string;
|
|
223
|
+
style?: string;
|
|
224
|
+
}
|
|
225
|
+
interface Goal {
|
|
226
|
+
description: string;
|
|
227
|
+
priority?: number;
|
|
228
|
+
completed?: boolean;
|
|
229
|
+
}
|
|
230
|
+
interface Constraint {
|
|
231
|
+
description: string;
|
|
232
|
+
type?: "hard" | "soft";
|
|
233
|
+
}
|
|
234
|
+
interface AgentConfig {
|
|
235
|
+
id?: string;
|
|
236
|
+
name: string;
|
|
237
|
+
provider: ProviderName;
|
|
238
|
+
model?: string;
|
|
239
|
+
systemPrompt?: string;
|
|
240
|
+
personality?: Personality;
|
|
241
|
+
goals?: Goal[];
|
|
242
|
+
constraints?: Constraint[];
|
|
243
|
+
temperature?: number;
|
|
244
|
+
maxTokens?: number;
|
|
245
|
+
topP?: number;
|
|
246
|
+
maxRetries?: number;
|
|
247
|
+
retryDelay?: number;
|
|
248
|
+
maxContextMessages?: number;
|
|
249
|
+
tools?: Tool[];
|
|
250
|
+
memory?: {
|
|
251
|
+
shortTerm?: boolean;
|
|
252
|
+
longTerm?: boolean;
|
|
253
|
+
semantic?: boolean;
|
|
254
|
+
session?: boolean;
|
|
255
|
+
user?: boolean;
|
|
256
|
+
project?: boolean;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
type WorkflowStepType = "agent" | "tool" | "transform" | "condition" | "loop";
|
|
261
|
+
interface WorkflowStepConfig {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
type: WorkflowStepType;
|
|
265
|
+
agent?: AgentConfig;
|
|
266
|
+
tool?: Tool;
|
|
267
|
+
input?: Record<string, unknown>;
|
|
268
|
+
transform?: (input: unknown) => unknown;
|
|
269
|
+
condition?: (input: unknown) => boolean;
|
|
270
|
+
maxIterations?: number;
|
|
271
|
+
onComplete?: (result: unknown) => void;
|
|
272
|
+
onError?: (error: Error) => void;
|
|
273
|
+
}
|
|
274
|
+
interface WorkflowConfig {
|
|
275
|
+
id?: string;
|
|
276
|
+
name: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
steps: WorkflowStepConfig[];
|
|
279
|
+
maxRetries?: number;
|
|
280
|
+
onComplete?: (results: unknown[]) => void;
|
|
281
|
+
onError?: (error: Error) => void;
|
|
282
|
+
}
|
|
283
|
+
interface WorkflowResult {
|
|
284
|
+
id: string;
|
|
285
|
+
name: string;
|
|
286
|
+
success: boolean;
|
|
287
|
+
steps: WorkflowStepResult[];
|
|
288
|
+
durationMs: number;
|
|
289
|
+
error?: string;
|
|
290
|
+
}
|
|
291
|
+
interface WorkflowStepResult {
|
|
292
|
+
id: string;
|
|
293
|
+
name: string;
|
|
294
|
+
type: WorkflowStepType;
|
|
295
|
+
status: "success" | "failed" | "skipped";
|
|
296
|
+
input?: unknown;
|
|
297
|
+
output?: unknown;
|
|
298
|
+
durationMs: number;
|
|
299
|
+
error?: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface Plugin {
|
|
303
|
+
name: string;
|
|
304
|
+
version: string;
|
|
305
|
+
description?: string;
|
|
306
|
+
onLoad?: () => void | Promise<void>;
|
|
307
|
+
onUnload?: () => void | Promise<void>;
|
|
308
|
+
onEvent?: (event: LupaEvent) => void | Promise<void>;
|
|
309
|
+
hooks?: {
|
|
310
|
+
beforeAgentRun?: (config: Record<string, unknown>) => Record<string, unknown>;
|
|
311
|
+
afterAgentRun?: (result: unknown) => unknown;
|
|
312
|
+
beforeToolCall?: (tool: string, args: Record<string, unknown>) => Record<string, unknown>;
|
|
313
|
+
afterToolCall?: (result: unknown) => unknown;
|
|
314
|
+
beforeProviderCall?: (provider: string, request: Record<string, unknown>) => Record<string, unknown>;
|
|
315
|
+
afterProviderCall?: (response: Record<string, unknown>) => Record<string, unknown>;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export type { AgentCompleteEvent, AgentConfig, AgentErrorEvent, AgentResponseEvent, AgentStartEvent, AgentThinkingEvent, BaseEvent, CompletionRequest, CompletionResponse, Constraint, EventName, Goal, LLMTokenEvent, LupaEvent, MemoryEntry, MemoryQuery, MemoryRetrieveEvent, MemorySearchResult, MemoryType, MemoryUpdateEvent, Message, ModelRole, Personality, Plugin, ProviderCompleteEvent, ProviderConfig, ProviderErrorEvent, ProviderName, ProviderStartEvent, StreamChunk, Tool, ToolCall, ToolDefinition, ToolErrorEvent, ToolFinishEvent, ToolParameter, ToolResult, ToolStartEvent, WorkflowCompleteEvent, WorkflowConfig, WorkflowResult, WorkflowStartEvent, WorkflowStepConfig, WorkflowStepEvent, WorkflowStepResult, WorkflowStepType };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
type EventName = "agent:start" | "agent:thinking" | "agent:response" | "agent:error" | "agent:complete" | "tool:start" | "tool:finish" | "tool:error" | "memory:update" | "memory:retrieve" | "workflow:start" | "workflow:step" | "workflow:complete" | "workflow:error" | "provider:start" | "provider:complete" | "provider:error" | "llm:token";
|
|
2
|
+
interface BaseEvent {
|
|
3
|
+
id: string;
|
|
4
|
+
name: EventName;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
agentId?: string;
|
|
7
|
+
runId?: string;
|
|
8
|
+
}
|
|
9
|
+
interface AgentStartEvent extends BaseEvent {
|
|
10
|
+
name: "agent:start";
|
|
11
|
+
config: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface AgentThinkingEvent extends BaseEvent {
|
|
14
|
+
name: "agent:thinking";
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
interface AgentResponseEvent extends BaseEvent {
|
|
18
|
+
name: "agent:response";
|
|
19
|
+
content: string;
|
|
20
|
+
tokens?: number;
|
|
21
|
+
latencyMs?: number;
|
|
22
|
+
}
|
|
23
|
+
interface AgentErrorEvent extends BaseEvent {
|
|
24
|
+
name: "agent:error";
|
|
25
|
+
error: string;
|
|
26
|
+
retryAttempt?: number;
|
|
27
|
+
}
|
|
28
|
+
interface AgentCompleteEvent extends BaseEvent {
|
|
29
|
+
name: "agent:complete";
|
|
30
|
+
totalTokens: number;
|
|
31
|
+
totalLatencyMs: number;
|
|
32
|
+
toolCalls: number;
|
|
33
|
+
}
|
|
34
|
+
interface ToolStartEvent extends BaseEvent {
|
|
35
|
+
name: "tool:start";
|
|
36
|
+
tool: string;
|
|
37
|
+
args: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
interface ToolFinishEvent extends BaseEvent {
|
|
40
|
+
name: "tool:finish";
|
|
41
|
+
tool: string;
|
|
42
|
+
result: unknown;
|
|
43
|
+
durationMs: number;
|
|
44
|
+
}
|
|
45
|
+
interface ToolErrorEvent extends BaseEvent {
|
|
46
|
+
name: "tool:error";
|
|
47
|
+
tool: string;
|
|
48
|
+
error: string;
|
|
49
|
+
}
|
|
50
|
+
interface MemoryUpdateEvent extends BaseEvent {
|
|
51
|
+
name: "memory:update";
|
|
52
|
+
type: string;
|
|
53
|
+
key: string;
|
|
54
|
+
}
|
|
55
|
+
interface MemoryRetrieveEvent extends BaseEvent {
|
|
56
|
+
name: "memory:retrieve";
|
|
57
|
+
type: string;
|
|
58
|
+
key: string;
|
|
59
|
+
results: number;
|
|
60
|
+
}
|
|
61
|
+
interface WorkflowStartEvent extends BaseEvent {
|
|
62
|
+
name: "workflow:start";
|
|
63
|
+
steps: number;
|
|
64
|
+
}
|
|
65
|
+
interface WorkflowStepEvent extends BaseEvent {
|
|
66
|
+
name: "workflow:step";
|
|
67
|
+
step: number;
|
|
68
|
+
stepName: string;
|
|
69
|
+
status: "running" | "completed" | "failed";
|
|
70
|
+
}
|
|
71
|
+
interface WorkflowCompleteEvent extends BaseEvent {
|
|
72
|
+
name: "workflow:complete";
|
|
73
|
+
totalSteps: number;
|
|
74
|
+
failedSteps: number;
|
|
75
|
+
durationMs: number;
|
|
76
|
+
}
|
|
77
|
+
interface ProviderStartEvent extends BaseEvent {
|
|
78
|
+
name: "provider:start";
|
|
79
|
+
provider: string;
|
|
80
|
+
model: string;
|
|
81
|
+
}
|
|
82
|
+
interface ProviderCompleteEvent extends BaseEvent {
|
|
83
|
+
name: "provider:complete";
|
|
84
|
+
provider: string;
|
|
85
|
+
model: string;
|
|
86
|
+
tokens: number;
|
|
87
|
+
latencyMs: number;
|
|
88
|
+
cost?: number;
|
|
89
|
+
}
|
|
90
|
+
interface ProviderErrorEvent extends BaseEvent {
|
|
91
|
+
name: "provider:error";
|
|
92
|
+
provider: string;
|
|
93
|
+
model: string;
|
|
94
|
+
error: string;
|
|
95
|
+
}
|
|
96
|
+
interface LLMTokenEvent extends BaseEvent {
|
|
97
|
+
name: "llm:token";
|
|
98
|
+
tokens: number;
|
|
99
|
+
cost?: number;
|
|
100
|
+
}
|
|
101
|
+
type LupaEvent = AgentStartEvent | AgentThinkingEvent | AgentResponseEvent | AgentErrorEvent | AgentCompleteEvent | ToolStartEvent | ToolFinishEvent | ToolErrorEvent | MemoryUpdateEvent | MemoryRetrieveEvent | WorkflowStartEvent | WorkflowStepEvent | WorkflowCompleteEvent | ProviderStartEvent | ProviderCompleteEvent | ProviderErrorEvent | LLMTokenEvent;
|
|
102
|
+
|
|
103
|
+
interface ToolParameter {
|
|
104
|
+
type: "string" | "number" | "boolean" | "array" | "object";
|
|
105
|
+
description: string;
|
|
106
|
+
required?: boolean;
|
|
107
|
+
enum?: string[];
|
|
108
|
+
items?: ToolParameter;
|
|
109
|
+
properties?: Record<string, ToolParameter>;
|
|
110
|
+
}
|
|
111
|
+
interface ToolDefinition {
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
parameters: Record<string, ToolParameter>;
|
|
115
|
+
required?: string[];
|
|
116
|
+
}
|
|
117
|
+
interface Tool {
|
|
118
|
+
definition: ToolDefinition;
|
|
119
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type ProviderName = "openai" | "anthropic" | "google" | "openrouter" | "groq" | "mistral" | "xai" | "ollama";
|
|
123
|
+
type ModelRole = "system" | "user" | "assistant" | "tool";
|
|
124
|
+
interface Message {
|
|
125
|
+
role: ModelRole;
|
|
126
|
+
content: string | null;
|
|
127
|
+
toolCallId?: string;
|
|
128
|
+
name?: string;
|
|
129
|
+
toolCalls?: Array<{
|
|
130
|
+
id: string;
|
|
131
|
+
type: "function";
|
|
132
|
+
function: {
|
|
133
|
+
name: string;
|
|
134
|
+
arguments: string;
|
|
135
|
+
};
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
interface ToolCall {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
args: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
interface ToolResult {
|
|
144
|
+
toolCallId: string;
|
|
145
|
+
name: string;
|
|
146
|
+
content: string;
|
|
147
|
+
}
|
|
148
|
+
interface ProviderConfig {
|
|
149
|
+
apiKey?: string;
|
|
150
|
+
baseUrl?: string;
|
|
151
|
+
model?: string;
|
|
152
|
+
temperature?: number;
|
|
153
|
+
maxTokens?: number;
|
|
154
|
+
topP?: number;
|
|
155
|
+
}
|
|
156
|
+
interface CompletionRequest {
|
|
157
|
+
messages: Message[];
|
|
158
|
+
tools?: Tool[];
|
|
159
|
+
systemPrompt?: string;
|
|
160
|
+
temperature?: number;
|
|
161
|
+
maxTokens?: number;
|
|
162
|
+
topP?: number;
|
|
163
|
+
model?: string;
|
|
164
|
+
}
|
|
165
|
+
interface CompletionResponse {
|
|
166
|
+
content: string | null;
|
|
167
|
+
toolCalls: ToolCall[];
|
|
168
|
+
usage: {
|
|
169
|
+
promptTokens: number;
|
|
170
|
+
completionTokens: number;
|
|
171
|
+
totalTokens: number;
|
|
172
|
+
};
|
|
173
|
+
model: string;
|
|
174
|
+
latencyMs: number;
|
|
175
|
+
finishReason: string;
|
|
176
|
+
}
|
|
177
|
+
type StreamChunk = {
|
|
178
|
+
type: "text";
|
|
179
|
+
text: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: "tool_call";
|
|
182
|
+
toolCall: ToolCall;
|
|
183
|
+
} | {
|
|
184
|
+
type: "finish";
|
|
185
|
+
content: string;
|
|
186
|
+
toolCalls: ToolCall[];
|
|
187
|
+
usage: {
|
|
188
|
+
promptTokens: number;
|
|
189
|
+
completionTokens: number;
|
|
190
|
+
totalTokens: number;
|
|
191
|
+
};
|
|
192
|
+
model: string;
|
|
193
|
+
finishReason: string;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
type MemoryType = "short-term" | "long-term" | "semantic" | "session" | "user" | "project" | "vector";
|
|
197
|
+
interface MemoryEntry {
|
|
198
|
+
id: string;
|
|
199
|
+
type: MemoryType;
|
|
200
|
+
key: string;
|
|
201
|
+
content: string;
|
|
202
|
+
metadata?: Record<string, unknown>;
|
|
203
|
+
timestamp: number;
|
|
204
|
+
scope?: string;
|
|
205
|
+
}
|
|
206
|
+
interface MemoryQuery {
|
|
207
|
+
type?: MemoryType;
|
|
208
|
+
key?: string;
|
|
209
|
+
scope?: string;
|
|
210
|
+
query?: string;
|
|
211
|
+
limit?: number;
|
|
212
|
+
threshold?: number;
|
|
213
|
+
}
|
|
214
|
+
interface MemorySearchResult {
|
|
215
|
+
entry: MemoryEntry;
|
|
216
|
+
score: number;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface Personality {
|
|
220
|
+
name?: string;
|
|
221
|
+
traits?: string[];
|
|
222
|
+
tone?: string;
|
|
223
|
+
style?: string;
|
|
224
|
+
}
|
|
225
|
+
interface Goal {
|
|
226
|
+
description: string;
|
|
227
|
+
priority?: number;
|
|
228
|
+
completed?: boolean;
|
|
229
|
+
}
|
|
230
|
+
interface Constraint {
|
|
231
|
+
description: string;
|
|
232
|
+
type?: "hard" | "soft";
|
|
233
|
+
}
|
|
234
|
+
interface AgentConfig {
|
|
235
|
+
id?: string;
|
|
236
|
+
name: string;
|
|
237
|
+
provider: ProviderName;
|
|
238
|
+
model?: string;
|
|
239
|
+
systemPrompt?: string;
|
|
240
|
+
personality?: Personality;
|
|
241
|
+
goals?: Goal[];
|
|
242
|
+
constraints?: Constraint[];
|
|
243
|
+
temperature?: number;
|
|
244
|
+
maxTokens?: number;
|
|
245
|
+
topP?: number;
|
|
246
|
+
maxRetries?: number;
|
|
247
|
+
retryDelay?: number;
|
|
248
|
+
maxContextMessages?: number;
|
|
249
|
+
tools?: Tool[];
|
|
250
|
+
memory?: {
|
|
251
|
+
shortTerm?: boolean;
|
|
252
|
+
longTerm?: boolean;
|
|
253
|
+
semantic?: boolean;
|
|
254
|
+
session?: boolean;
|
|
255
|
+
user?: boolean;
|
|
256
|
+
project?: boolean;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
type WorkflowStepType = "agent" | "tool" | "transform" | "condition" | "loop";
|
|
261
|
+
interface WorkflowStepConfig {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
type: WorkflowStepType;
|
|
265
|
+
agent?: AgentConfig;
|
|
266
|
+
tool?: Tool;
|
|
267
|
+
input?: Record<string, unknown>;
|
|
268
|
+
transform?: (input: unknown) => unknown;
|
|
269
|
+
condition?: (input: unknown) => boolean;
|
|
270
|
+
maxIterations?: number;
|
|
271
|
+
onComplete?: (result: unknown) => void;
|
|
272
|
+
onError?: (error: Error) => void;
|
|
273
|
+
}
|
|
274
|
+
interface WorkflowConfig {
|
|
275
|
+
id?: string;
|
|
276
|
+
name: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
steps: WorkflowStepConfig[];
|
|
279
|
+
maxRetries?: number;
|
|
280
|
+
onComplete?: (results: unknown[]) => void;
|
|
281
|
+
onError?: (error: Error) => void;
|
|
282
|
+
}
|
|
283
|
+
interface WorkflowResult {
|
|
284
|
+
id: string;
|
|
285
|
+
name: string;
|
|
286
|
+
success: boolean;
|
|
287
|
+
steps: WorkflowStepResult[];
|
|
288
|
+
durationMs: number;
|
|
289
|
+
error?: string;
|
|
290
|
+
}
|
|
291
|
+
interface WorkflowStepResult {
|
|
292
|
+
id: string;
|
|
293
|
+
name: string;
|
|
294
|
+
type: WorkflowStepType;
|
|
295
|
+
status: "success" | "failed" | "skipped";
|
|
296
|
+
input?: unknown;
|
|
297
|
+
output?: unknown;
|
|
298
|
+
durationMs: number;
|
|
299
|
+
error?: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface Plugin {
|
|
303
|
+
name: string;
|
|
304
|
+
version: string;
|
|
305
|
+
description?: string;
|
|
306
|
+
onLoad?: () => void | Promise<void>;
|
|
307
|
+
onUnload?: () => void | Promise<void>;
|
|
308
|
+
onEvent?: (event: LupaEvent) => void | Promise<void>;
|
|
309
|
+
hooks?: {
|
|
310
|
+
beforeAgentRun?: (config: Record<string, unknown>) => Record<string, unknown>;
|
|
311
|
+
afterAgentRun?: (result: unknown) => unknown;
|
|
312
|
+
beforeToolCall?: (tool: string, args: Record<string, unknown>) => Record<string, unknown>;
|
|
313
|
+
afterToolCall?: (result: unknown) => unknown;
|
|
314
|
+
beforeProviderCall?: (provider: string, request: Record<string, unknown>) => Record<string, unknown>;
|
|
315
|
+
afterProviderCall?: (response: Record<string, unknown>) => Record<string, unknown>;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export type { AgentCompleteEvent, AgentConfig, AgentErrorEvent, AgentResponseEvent, AgentStartEvent, AgentThinkingEvent, BaseEvent, CompletionRequest, CompletionResponse, Constraint, EventName, Goal, LLMTokenEvent, LupaEvent, MemoryEntry, MemoryQuery, MemoryRetrieveEvent, MemorySearchResult, MemoryType, MemoryUpdateEvent, Message, ModelRole, Personality, Plugin, ProviderCompleteEvent, ProviderConfig, ProviderErrorEvent, ProviderName, ProviderStartEvent, StreamChunk, Tool, ToolCall, ToolDefinition, ToolErrorEvent, ToolFinishEvent, ToolParameter, ToolResult, ToolStartEvent, WorkflowCompleteEvent, WorkflowConfig, WorkflowResult, WorkflowStartEvent, WorkflowStepConfig, WorkflowStepEvent, WorkflowStepResult, WorkflowStepType };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lupaflow/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"import": "./dist/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
"files": ["dist", "src", "package.json"],
|
|
20
|
+
"scripts": {
|
|
20
21
|
"build": "tsup",
|
|
21
22
|
"dev": "tsup --watch"
|
|
22
23
|
},
|
package/tsconfig.json
DELETED