@agentick/ai-sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/.tsbuildinfo.build +1 -0
- package/dist/adapter.d.ts +127 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +761 -0
- package/dist/adapter.js.map +1 -0
- package/dist/compiler-v2.d.ts +224 -0
- package/dist/compiler-v2.d.ts.map +1 -0
- package/dist/compiler-v2.js +587 -0
- package/dist/compiler-v2.js.map +1 -0
- package/dist/compiler.d.ts +302 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +704 -0
- package/dist/compiler.js.map +1 -0
- package/dist/components.d.ts +164 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +239 -0
- package/dist/components.js.map +1 -0
- package/dist/components.jsx +239 -0
- package/dist/components.jsx.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +47 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +45 -0
- package/dist/model.js.map +1 -0
- package/dist/model.jsx +45 -0
- package/dist/model.jsx.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Compiler Adapter V2
|
|
3
|
+
*
|
|
4
|
+
* Design philosophy: Progressive adoption
|
|
5
|
+
* - Users keep their existing generateText/streamText code
|
|
6
|
+
* - We add JSX compilation on top
|
|
7
|
+
* - Use as little or as much as you want
|
|
8
|
+
*
|
|
9
|
+
* @example Minimal (user controls execution)
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const result = await compiler.run(
|
|
12
|
+
* <MyAgent />,
|
|
13
|
+
* initialMessages, // ai-sdk format
|
|
14
|
+
* async (formatted) => {
|
|
15
|
+
* return await generateText({
|
|
16
|
+
* model: openai('gpt-4o'),
|
|
17
|
+
* messages: formatted.messages,
|
|
18
|
+
* tools: formatted.tools,
|
|
19
|
+
* });
|
|
20
|
+
* }
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Fully managed (we handle model execution)
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const compiler = new AiSdkCompiler({
|
|
27
|
+
* model: openai('gpt-4o'),
|
|
28
|
+
* manageExecution: true, // We call generateText/streamText
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* const result = await compiler.run(<MyAgent />, initialMessages);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
import { CompileJSXService, } from 'aidk';
|
|
35
|
+
import { generateText, streamText } from 'ai';
|
|
36
|
+
import { EventEmitter } from 'node:events';
|
|
37
|
+
import { randomUUID } from 'node:crypto';
|
|
38
|
+
import { createAiSdkModel } from './adapter';
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Conversion Utilities
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Convert ai-sdk messages to EngineInput.
|
|
44
|
+
*/
|
|
45
|
+
function toEngineInput(messages) {
|
|
46
|
+
if (!messages || messages.length === 0) {
|
|
47
|
+
return { timeline: [], sections: {} };
|
|
48
|
+
}
|
|
49
|
+
const timeline = [];
|
|
50
|
+
for (const msg of messages) {
|
|
51
|
+
if (msg.role === 'system') {
|
|
52
|
+
// System messages become timeline entries
|
|
53
|
+
const content = typeof msg.content === 'string'
|
|
54
|
+
? [{ type: 'text', text: msg.content }]
|
|
55
|
+
: [];
|
|
56
|
+
timeline.push({
|
|
57
|
+
kind: 'message',
|
|
58
|
+
message: {
|
|
59
|
+
role: 'system',
|
|
60
|
+
content,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else if (msg.role === 'user' || msg.role === 'assistant') {
|
|
65
|
+
// Regular messages
|
|
66
|
+
const content = typeof msg.content === 'string'
|
|
67
|
+
? [{ type: 'text', text: msg.content }]
|
|
68
|
+
: Array.isArray(msg.content)
|
|
69
|
+
? msg.content.map((part) => {
|
|
70
|
+
if (part.type === 'text') {
|
|
71
|
+
return { type: 'text', text: part.text };
|
|
72
|
+
}
|
|
73
|
+
// TODO: Handle other content types
|
|
74
|
+
return { type: 'text', text: JSON.stringify(part) };
|
|
75
|
+
})
|
|
76
|
+
: [];
|
|
77
|
+
timeline.push({
|
|
78
|
+
kind: 'message',
|
|
79
|
+
message: {
|
|
80
|
+
role: msg.role,
|
|
81
|
+
content,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// TODO: Handle tool messages
|
|
86
|
+
}
|
|
87
|
+
return { timeline, sections: {} };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convert compiled output to ai-sdk formatted input.
|
|
91
|
+
*/
|
|
92
|
+
function toAiSdkFormat(compiled, tick) {
|
|
93
|
+
const { formatted, tools } = compiled;
|
|
94
|
+
// Extract messages from formatted timeline
|
|
95
|
+
const messages = [];
|
|
96
|
+
let system;
|
|
97
|
+
for (const entry of formatted.timeline || []) {
|
|
98
|
+
if (entry.kind === 'message') {
|
|
99
|
+
const msg = entry.message;
|
|
100
|
+
if (msg.role === 'system') {
|
|
101
|
+
// Extract system prompt
|
|
102
|
+
system = msg.content
|
|
103
|
+
.filter((c) => c.type === 'text')
|
|
104
|
+
.map((c) => c.text)
|
|
105
|
+
.join('\n');
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Convert to ai-sdk message
|
|
109
|
+
const content = msg.content.map((block) => {
|
|
110
|
+
if (block.type === 'text') {
|
|
111
|
+
return { type: 'text', text: block.text };
|
|
112
|
+
}
|
|
113
|
+
// TODO: Handle other block types
|
|
114
|
+
return { type: 'text', text: JSON.stringify(block) };
|
|
115
|
+
});
|
|
116
|
+
messages.push({
|
|
117
|
+
role: msg.role,
|
|
118
|
+
content: content,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Convert tools to ToolSet
|
|
124
|
+
const toolSet = tools && tools.length > 0
|
|
125
|
+
? tools.reduce((acc, tool) => {
|
|
126
|
+
if ('metadata' in tool) {
|
|
127
|
+
acc[tool.metadata.name] = {
|
|
128
|
+
description: tool.metadata.description,
|
|
129
|
+
parameters: tool.metadata.parameters,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return acc;
|
|
133
|
+
}, {})
|
|
134
|
+
: undefined;
|
|
135
|
+
return {
|
|
136
|
+
messages,
|
|
137
|
+
tools: toolSet,
|
|
138
|
+
system,
|
|
139
|
+
tick,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Convert ai-sdk result to TickResultInput.
|
|
144
|
+
*/
|
|
145
|
+
function toTickResult(result) {
|
|
146
|
+
// Extract assistant message
|
|
147
|
+
const assistantMessage = result.response?.messages?.find((m) => m.role === 'assistant');
|
|
148
|
+
const content = assistantMessage?.content
|
|
149
|
+
? (typeof assistantMessage.content === 'string'
|
|
150
|
+
? [{ type: 'text', text: assistantMessage.content }]
|
|
151
|
+
: assistantMessage.content.map((part) => {
|
|
152
|
+
if (part.type === 'text') {
|
|
153
|
+
return { type: 'text', text: part.text };
|
|
154
|
+
}
|
|
155
|
+
return { type: 'text', text: JSON.stringify(part) };
|
|
156
|
+
}))
|
|
157
|
+
: [];
|
|
158
|
+
const response = {
|
|
159
|
+
shouldStop: !result.toolCalls || result.toolCalls.length === 0,
|
|
160
|
+
newTimelineEntries: [{
|
|
161
|
+
kind: 'message',
|
|
162
|
+
message: {
|
|
163
|
+
role: 'assistant',
|
|
164
|
+
content,
|
|
165
|
+
},
|
|
166
|
+
}],
|
|
167
|
+
toolCalls: result.toolCalls?.map((tc) => ({
|
|
168
|
+
id: tc.toolCallId,
|
|
169
|
+
name: tc.toolName,
|
|
170
|
+
input: tc.args || {},
|
|
171
|
+
})),
|
|
172
|
+
};
|
|
173
|
+
return { response };
|
|
174
|
+
}
|
|
175
|
+
// ============================================================================
|
|
176
|
+
// Process Handle Implementation
|
|
177
|
+
// ============================================================================
|
|
178
|
+
class AiSdkProcessHandleImpl {
|
|
179
|
+
pid;
|
|
180
|
+
rootPid;
|
|
181
|
+
type;
|
|
182
|
+
parentPid;
|
|
183
|
+
_status = 'pending';
|
|
184
|
+
_result;
|
|
185
|
+
_events = new EventEmitter();
|
|
186
|
+
_completionPromise;
|
|
187
|
+
_resolve;
|
|
188
|
+
_reject;
|
|
189
|
+
_abortController = new AbortController();
|
|
190
|
+
constructor(type, parentPid, rootPid) {
|
|
191
|
+
this.pid = `aisdk-${type}-${randomUUID().slice(0, 8)}`;
|
|
192
|
+
this.type = type;
|
|
193
|
+
this.parentPid = parentPid;
|
|
194
|
+
this.rootPid = rootPid || this.pid;
|
|
195
|
+
this._completionPromise = new Promise((resolve, reject) => {
|
|
196
|
+
this._resolve = resolve;
|
|
197
|
+
this._reject = reject;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
get status() {
|
|
201
|
+
return this._status;
|
|
202
|
+
}
|
|
203
|
+
get result() {
|
|
204
|
+
return this._result;
|
|
205
|
+
}
|
|
206
|
+
start() {
|
|
207
|
+
this._status = 'running';
|
|
208
|
+
this._events.emit('start');
|
|
209
|
+
}
|
|
210
|
+
complete(result) {
|
|
211
|
+
this._status = 'completed';
|
|
212
|
+
this._result = result;
|
|
213
|
+
this._events.emit('complete', result);
|
|
214
|
+
this._resolve(result);
|
|
215
|
+
}
|
|
216
|
+
fail(error) {
|
|
217
|
+
this._status = 'failed';
|
|
218
|
+
this._events.emit('error', error);
|
|
219
|
+
this._reject(error);
|
|
220
|
+
}
|
|
221
|
+
cancel() {
|
|
222
|
+
if (this._status === 'running' || this._status === 'pending') {
|
|
223
|
+
this._status = 'cancelled';
|
|
224
|
+
this._abortController.abort();
|
|
225
|
+
this._events.emit('cancelled');
|
|
226
|
+
this._reject(new Error('Execution cancelled'));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
getCancelSignal() {
|
|
230
|
+
return this._abortController.signal;
|
|
231
|
+
}
|
|
232
|
+
waitForCompletion() {
|
|
233
|
+
return this._completionPromise;
|
|
234
|
+
}
|
|
235
|
+
on(event, handler) {
|
|
236
|
+
this._events.on(event, handler);
|
|
237
|
+
}
|
|
238
|
+
off(event, handler) {
|
|
239
|
+
this._events.off(event, handler);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// ============================================================================
|
|
243
|
+
// Compiler Adapter
|
|
244
|
+
// ============================================================================
|
|
245
|
+
/**
|
|
246
|
+
* AI SDK Compiler Adapter.
|
|
247
|
+
*
|
|
248
|
+
* Progressive adoption philosophy:
|
|
249
|
+
* - Start with just JSX compilation
|
|
250
|
+
* - Add multi-tick execution
|
|
251
|
+
* - Optionally use fully managed execution
|
|
252
|
+
* - Eventually migrate to full Engine
|
|
253
|
+
*/
|
|
254
|
+
export class AiSdkCompiler {
|
|
255
|
+
service;
|
|
256
|
+
model;
|
|
257
|
+
maxTicks;
|
|
258
|
+
manageExecution;
|
|
259
|
+
modelOptions;
|
|
260
|
+
// Track active executions for process methods
|
|
261
|
+
executions = new Map();
|
|
262
|
+
// Store the user's execution function for fork/spawn
|
|
263
|
+
userExecutor;
|
|
264
|
+
constructor(config = {}) {
|
|
265
|
+
this.model = config.model;
|
|
266
|
+
this.maxTicks = config.maxTicks ?? 10;
|
|
267
|
+
this.manageExecution = config.manageExecution ?? false;
|
|
268
|
+
this.modelOptions = config.modelOptions;
|
|
269
|
+
// Create process methods for fork/spawn
|
|
270
|
+
const processMethods = this.createProcessMethods();
|
|
271
|
+
// Initialize the compile service
|
|
272
|
+
// If managing execution, provide a model getter
|
|
273
|
+
const modelGetter = this.manageExecution && this.model
|
|
274
|
+
? () => createAiSdkModel({ model: this.model })
|
|
275
|
+
: undefined;
|
|
276
|
+
this.service = new CompileJSXService({
|
|
277
|
+
...config.serviceConfig,
|
|
278
|
+
modelGetter,
|
|
279
|
+
processMethods,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Create process methods for COMProcess.
|
|
284
|
+
* Fork/spawn will use the same executor function by default.
|
|
285
|
+
*/
|
|
286
|
+
createProcessMethods() {
|
|
287
|
+
return {
|
|
288
|
+
fork: (input, agent, options) => {
|
|
289
|
+
const parentPid = options?.parentPid;
|
|
290
|
+
const parentHandle = parentPid ? this.executions.get(parentPid) : undefined;
|
|
291
|
+
const handle = new AiSdkProcessHandleImpl('fork', parentPid, parentHandle?.rootPid);
|
|
292
|
+
this.executions.set(handle.pid, handle);
|
|
293
|
+
// Start fork execution asynchronously using the same executor
|
|
294
|
+
if (agent && this.userExecutor) {
|
|
295
|
+
const element = typeof agent === 'function'
|
|
296
|
+
? { type: agent, props: {}, key: null }
|
|
297
|
+
: agent;
|
|
298
|
+
// Convert EngineInput back to ai-sdk messages for consistency
|
|
299
|
+
const messages = this.engineInputToMessages(input);
|
|
300
|
+
this.runWithExecutor(element, messages, this.userExecutor).then(result => handle.complete(result))
|
|
301
|
+
.catch(error => handle.fail(error instanceof Error ? error : new Error(String(error))));
|
|
302
|
+
}
|
|
303
|
+
return handle;
|
|
304
|
+
},
|
|
305
|
+
spawn: (input, agent, options) => {
|
|
306
|
+
const handle = new AiSdkProcessHandleImpl('spawn');
|
|
307
|
+
this.executions.set(handle.pid, handle);
|
|
308
|
+
// Start spawn execution asynchronously using the same executor
|
|
309
|
+
if (agent && this.userExecutor) {
|
|
310
|
+
const element = typeof agent === 'function'
|
|
311
|
+
? { type: agent, props: {}, key: null }
|
|
312
|
+
: agent;
|
|
313
|
+
const messages = this.engineInputToMessages(input);
|
|
314
|
+
this.runWithExecutor(element, messages, this.userExecutor).then(result => handle.complete(result))
|
|
315
|
+
.catch(error => handle.fail(error instanceof Error ? error : new Error(String(error))));
|
|
316
|
+
}
|
|
317
|
+
return handle;
|
|
318
|
+
},
|
|
319
|
+
signal: (pid, signal, reason) => {
|
|
320
|
+
const handle = this.executions.get(pid);
|
|
321
|
+
if (handle && signal === 'abort') {
|
|
322
|
+
handle.cancel();
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
kill: (pid, reason) => {
|
|
326
|
+
const handle = this.executions.get(pid);
|
|
327
|
+
if (handle) {
|
|
328
|
+
handle.cancel();
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
list: () => {
|
|
332
|
+
return Array.from(this.executions.values())
|
|
333
|
+
.filter(h => h.status === 'running');
|
|
334
|
+
},
|
|
335
|
+
get: (pid) => {
|
|
336
|
+
return this.executions.get(pid);
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Convert EngineInput back to ai-sdk messages.
|
|
342
|
+
* Used for fork/spawn to maintain consistent interface.
|
|
343
|
+
*/
|
|
344
|
+
engineInputToMessages(input) {
|
|
345
|
+
// Simple conversion - just extract messages from timeline
|
|
346
|
+
return (input.timeline || [])
|
|
347
|
+
.filter((entry) => entry.kind === 'message')
|
|
348
|
+
.map((entry) => {
|
|
349
|
+
const msg = entry.message;
|
|
350
|
+
return {
|
|
351
|
+
role: msg.role,
|
|
352
|
+
content: msg.content.map((c) => ({ type: 'text', text: c.text || JSON.stringify(c) })),
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Execute with user-provided executor function.
|
|
358
|
+
*/
|
|
359
|
+
async runWithExecutor(rootElement, initialMessages, executor) {
|
|
360
|
+
// Store executor for fork/spawn
|
|
361
|
+
this.userExecutor = executor;
|
|
362
|
+
const engineInput = toEngineInput(initialMessages);
|
|
363
|
+
const config = {
|
|
364
|
+
input: engineInput,
|
|
365
|
+
rootElement,
|
|
366
|
+
maxTicks: this.maxTicks,
|
|
367
|
+
};
|
|
368
|
+
// Track tick manually since CompileTickResult doesn't expose it
|
|
369
|
+
let currentTick = 1;
|
|
370
|
+
// Use the raw _run method (not procedure-wrapped)
|
|
371
|
+
return this.service._run(config, async (compiled) => {
|
|
372
|
+
const formatted = toAiSdkFormat(compiled, currentTick);
|
|
373
|
+
if (executor) {
|
|
374
|
+
// User provided executor
|
|
375
|
+
const result = await executor(formatted, currentTick);
|
|
376
|
+
currentTick++;
|
|
377
|
+
return toTickResult(result);
|
|
378
|
+
}
|
|
379
|
+
else if (this.manageExecution && this.model) {
|
|
380
|
+
// Fully managed execution
|
|
381
|
+
const result = await generateText({
|
|
382
|
+
model: this.model,
|
|
383
|
+
messages: formatted.messages,
|
|
384
|
+
tools: formatted.tools,
|
|
385
|
+
system: formatted.system || this.modelOptions?.system,
|
|
386
|
+
temperature: this.modelOptions?.temperature,
|
|
387
|
+
maxOutputTokens: this.modelOptions?.maxOutputTokens,
|
|
388
|
+
topP: this.modelOptions?.topP,
|
|
389
|
+
});
|
|
390
|
+
currentTick++;
|
|
391
|
+
return toTickResult(result);
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
throw new Error('No executor provided and manageExecution is false');
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Execute a JSX program with user-provided execution callback.
|
|
400
|
+
*
|
|
401
|
+
* @param rootElement The root JSX element to compile
|
|
402
|
+
* @param initialMessages Optional initial messages in ai-sdk format
|
|
403
|
+
* @param executor User's execution function (gets formatted, returns library result)
|
|
404
|
+
* @returns Final library-native result
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const result = await compiler.run(
|
|
409
|
+
* <MyAgent />,
|
|
410
|
+
* initialMessages,
|
|
411
|
+
* async (formatted) => {
|
|
412
|
+
* return await generateText({
|
|
413
|
+
* model: openai('gpt-4o'),
|
|
414
|
+
* messages: formatted.messages,
|
|
415
|
+
* tools: formatted.tools,
|
|
416
|
+
* });
|
|
417
|
+
* }
|
|
418
|
+
* );
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
async run(rootElement, initialMessages, executor) {
|
|
422
|
+
return this.runWithExecutor(rootElement, initialMessages, executor);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Execute a JSX program with streaming.
|
|
426
|
+
*
|
|
427
|
+
* @param rootElement The root JSX element to compile
|
|
428
|
+
* @param initialMessages Optional initial messages in ai-sdk format
|
|
429
|
+
* @param executor User's streaming execution function
|
|
430
|
+
* @yields Execution events including library-native chunks
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* for await (const event of compiler.stream(
|
|
435
|
+
* <MyAgent />,
|
|
436
|
+
* initialMessages,
|
|
437
|
+
* async function* (formatted) {
|
|
438
|
+
* for await (const chunk of streamText({
|
|
439
|
+
* model: openai('gpt-4o'),
|
|
440
|
+
* messages: formatted.messages,
|
|
441
|
+
* }).fullStream) {
|
|
442
|
+
* yield chunk;
|
|
443
|
+
* }
|
|
444
|
+
* }
|
|
445
|
+
* )) {
|
|
446
|
+
* if (event.type === 'chunk') {
|
|
447
|
+
* process.stdout.write(event.chunk.textDelta || '');
|
|
448
|
+
* }
|
|
449
|
+
* }
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
async *stream(rootElement, initialMessages, executor) {
|
|
453
|
+
// Store executor for fork/spawn
|
|
454
|
+
this.userExecutor = executor;
|
|
455
|
+
const engineInput = toEngineInput(initialMessages);
|
|
456
|
+
const config = {
|
|
457
|
+
input: engineInput,
|
|
458
|
+
rootElement,
|
|
459
|
+
maxTicks: this.maxTicks,
|
|
460
|
+
};
|
|
461
|
+
const self = this;
|
|
462
|
+
// Use _runStream directly
|
|
463
|
+
for await (const event of this.service._runStream(config, {
|
|
464
|
+
onTick: async function* (compiled, tick) {
|
|
465
|
+
const formatted = toAiSdkFormat(compiled, tick);
|
|
466
|
+
// Yield formatted event so user can see what's being sent
|
|
467
|
+
yield { type: 'formatted', tick, formatted };
|
|
468
|
+
if (executor) {
|
|
469
|
+
// User provided executor
|
|
470
|
+
const streamResult = executor(formatted, tick);
|
|
471
|
+
// Could be AsyncGenerator or StreamTextResult
|
|
472
|
+
if (typeof streamResult.fullStream !== 'undefined') {
|
|
473
|
+
for await (const chunk of streamResult.fullStream) {
|
|
474
|
+
yield chunk;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
for await (const chunk of streamResult) {
|
|
479
|
+
yield chunk;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else if (self.manageExecution && self.model) {
|
|
484
|
+
// Fully managed streaming
|
|
485
|
+
for await (const chunk of streamText({
|
|
486
|
+
model: self.model,
|
|
487
|
+
messages: formatted.messages,
|
|
488
|
+
tools: formatted.tools,
|
|
489
|
+
system: formatted.system || self.modelOptions?.system,
|
|
490
|
+
temperature: self.modelOptions?.temperature,
|
|
491
|
+
maxOutputTokens: self.modelOptions?.maxOutputTokens,
|
|
492
|
+
}).fullStream) {
|
|
493
|
+
yield chunk;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
throw new Error('No executor provided and manageExecution is false');
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
finalizeChunks: (chunks) => {
|
|
501
|
+
// Check for direct result
|
|
502
|
+
const directResult = chunks.find((c) => c?.__result);
|
|
503
|
+
if (directResult) {
|
|
504
|
+
return directResult.__result;
|
|
505
|
+
}
|
|
506
|
+
// Aggregate chunks into result
|
|
507
|
+
// This is simplified - real implementation would use ai-sdk's response aggregation
|
|
508
|
+
let text = '';
|
|
509
|
+
const toolCalls = [];
|
|
510
|
+
for (const chunk of chunks) {
|
|
511
|
+
if (chunk?.type === 'text-delta') {
|
|
512
|
+
text += chunk.textDelta || chunk.text || '';
|
|
513
|
+
}
|
|
514
|
+
if (chunk?.type === 'tool-call') {
|
|
515
|
+
toolCalls.push({
|
|
516
|
+
toolCallId: chunk.toolCallId,
|
|
517
|
+
toolName: chunk.toolName,
|
|
518
|
+
args: chunk.args,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
// Build minimal GenerateTextResult-like object
|
|
523
|
+
const result = {
|
|
524
|
+
text,
|
|
525
|
+
toolCalls,
|
|
526
|
+
response: {
|
|
527
|
+
messages: [{
|
|
528
|
+
role: 'assistant',
|
|
529
|
+
content: text ? [{ type: 'text', text }] : [],
|
|
530
|
+
}],
|
|
531
|
+
},
|
|
532
|
+
};
|
|
533
|
+
return toTickResult(result);
|
|
534
|
+
},
|
|
535
|
+
})) {
|
|
536
|
+
yield event;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Cleanup and destroy the compiler.
|
|
541
|
+
*/
|
|
542
|
+
async destroy() {
|
|
543
|
+
// Cancel all running executions
|
|
544
|
+
for (const handle of this.executions.values()) {
|
|
545
|
+
if (handle.status === 'running') {
|
|
546
|
+
handle.cancel();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
this.executions.clear();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
// ============================================================================
|
|
553
|
+
// Factory Function
|
|
554
|
+
// ============================================================================
|
|
555
|
+
/**
|
|
556
|
+
* Create an AI SDK compiler adapter.
|
|
557
|
+
*
|
|
558
|
+
* @example User controls execution
|
|
559
|
+
* ```typescript
|
|
560
|
+
* const compiler = createAiSdkCompiler();
|
|
561
|
+
*
|
|
562
|
+
* const result = await compiler.run(
|
|
563
|
+
* <MyAgent />,
|
|
564
|
+
* initialMessages,
|
|
565
|
+
* async (formatted) => {
|
|
566
|
+
* return await generateText({
|
|
567
|
+
* model: openai('gpt-4o'),
|
|
568
|
+
* messages: formatted.messages,
|
|
569
|
+
* });
|
|
570
|
+
* }
|
|
571
|
+
* );
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @example Fully managed
|
|
575
|
+
* ```typescript
|
|
576
|
+
* const compiler = createAiSdkCompiler({
|
|
577
|
+
* model: openai('gpt-4o'),
|
|
578
|
+
* manageExecution: true,
|
|
579
|
+
* });
|
|
580
|
+
*
|
|
581
|
+
* const result = await compiler.run(<MyAgent />, initialMessages);
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
export function createAiSdkCompiler(config) {
|
|
585
|
+
return new AiSdkCompiler(config);
|
|
586
|
+
}
|
|
587
|
+
//# sourceMappingURL=compiler-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-v2.js","sourceRoot":"","sources":["../src/compiler-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACL,iBAAiB,GAiBlB,MAAM,MAAM,CAAC;AASd,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA2F7C,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,aAAa,CAAC,QAAyB;IAC9C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,QAAQ,GAAuB,EAAE,CAAC;IAExC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1B,0CAA0C;YAC1C,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;gBAC7C,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,GAAG,CAAC,O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