@olane/o-lane 0.7.12-alpha.75 → 0.7.12-alpha.76
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/src/ag-ui/ag-ui-constants.d.ts +90 -0
- package/dist/src/ag-ui/ag-ui-constants.d.ts.map +1 -0
- package/dist/src/ag-ui/ag-ui-constants.js +113 -0
- package/dist/src/ag-ui/ag-ui-event-mapper.d.ts +88 -0
- package/dist/src/ag-ui/ag-ui-event-mapper.d.ts.map +1 -0
- package/dist/src/ag-ui/ag-ui-event-mapper.js +487 -0
- package/dist/src/ag-ui/ag-ui-olane.tool.d.ts +45 -0
- package/dist/src/ag-ui/ag-ui-olane.tool.d.ts.map +1 -0
- package/dist/src/ag-ui/ag-ui-olane.tool.js +257 -0
- package/dist/src/ag-ui/ag-ui-stream-manager.d.ts +99 -0
- package/dist/src/ag-ui/ag-ui-stream-manager.d.ts.map +1 -0
- package/dist/src/ag-ui/ag-ui-stream-manager.js +160 -0
- package/dist/src/ag-ui/ag-ui-utils.d.ts +50 -0
- package/dist/src/ag-ui/ag-ui-utils.d.ts.map +1 -0
- package/dist/src/ag-ui/ag-ui-utils.js +287 -0
- package/dist/src/ag-ui/index.d.ts +17 -0
- package/dist/src/ag-ui/index.d.ts.map +1 -0
- package/dist/src/ag-ui/index.js +21 -0
- package/dist/src/ag-ui/transports/ag-ui-transport.interface.d.ts +44 -0
- package/dist/src/ag-ui/transports/ag-ui-transport.interface.d.ts.map +1 -0
- package/dist/src/ag-ui/transports/ag-ui-transport.interface.js +26 -0
- package/dist/src/ag-ui/transports/callback-transport.d.ts +13 -0
- package/dist/src/ag-ui/transports/callback-transport.d.ts.map +1 -0
- package/dist/src/ag-ui/transports/callback-transport.js +26 -0
- package/dist/src/ag-ui/transports/console-transport.d.ts +14 -0
- package/dist/src/ag-ui/transports/console-transport.d.ts.map +1 -0
- package/dist/src/ag-ui/transports/console-transport.js +63 -0
- package/dist/src/ag-ui/transports/index.d.ts +5 -0
- package/dist/src/ag-ui/transports/index.d.ts.map +1 -0
- package/dist/src/ag-ui/transports/index.js +4 -0
- package/dist/src/ag-ui/transports/onode-transport.d.ts +34 -0
- package/dist/src/ag-ui/transports/onode-transport.d.ts.map +1 -0
- package/dist/src/ag-ui/transports/onode-transport.js +83 -0
- package/dist/src/ag-ui/types/ag-ui-config.interface.d.ts +105 -0
- package/dist/src/ag-ui/types/ag-ui-config.interface.d.ts.map +1 -0
- package/dist/src/ag-ui/types/ag-ui-config.interface.js +1 -0
- package/dist/src/ag-ui/types/ag-ui-event.types.d.ts +266 -0
- package/dist/src/ag-ui/types/ag-ui-event.types.d.ts.map +1 -0
- package/dist/src/ag-ui/types/ag-ui-event.types.js +6 -0
- package/dist/src/ag-ui/types/index.d.ts +3 -0
- package/dist/src/ag-ui/types/index.d.ts.map +1 -0
- package/dist/src/ag-ui/types/index.js +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/package.json +7 -7
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { oCapabilityType } from '../capabilities/enums/o-capability.type-enum.js';
|
|
2
|
+
import { generateMessageId, generateToolCallId, generateTimestamp, generateJSONPatch, chunkString, capabilityTypeToStepName, safeJSONStringify, } from './ag-ui-utils.js';
|
|
3
|
+
import { AG_UI_DEFAULTS, ACTIVITY_TYPES } from './ag-ui-constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Maps oLane execution events to AG-UI protocol events
|
|
6
|
+
*/
|
|
7
|
+
export class AGUIEventMapper {
|
|
8
|
+
constructor(context, config = {}) {
|
|
9
|
+
this.context = context;
|
|
10
|
+
this.config = {
|
|
11
|
+
includeRawEvents: config.includeRawEvents ?? AG_UI_DEFAULTS.INCLUDE_RAW_EVENTS,
|
|
12
|
+
emitActivityEvents: config.emitActivityEvents ?? AG_UI_DEFAULTS.EMIT_ACTIVITY_EVENTS,
|
|
13
|
+
emitReasoningEvents: config.emitReasoningEvents ?? AG_UI_DEFAULTS.EMIT_REASONING_EVENTS,
|
|
14
|
+
textChunkSize: config.textChunkSize ?? AG_UI_DEFAULTS.TEXT_CHUNK_SIZE,
|
|
15
|
+
autoGenerateThreadId: config.autoGenerateThreadId ?? AG_UI_DEFAULTS.AUTO_GENERATE_THREAD_ID,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Map lane creation to RunStarted event
|
|
20
|
+
*/
|
|
21
|
+
mapLaneStartToRunStarted(intent, input) {
|
|
22
|
+
return {
|
|
23
|
+
type: 'RunStarted',
|
|
24
|
+
threadId: this.context.threadId,
|
|
25
|
+
runId: this.context.runId,
|
|
26
|
+
parentRunId: this.context.parentRunId,
|
|
27
|
+
input: input || { intent: intent.value },
|
|
28
|
+
timestamp: generateTimestamp(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Map lane completion to RunFinished event
|
|
33
|
+
*/
|
|
34
|
+
mapLaneCompleteToRunFinished(result) {
|
|
35
|
+
return {
|
|
36
|
+
type: 'RunFinished',
|
|
37
|
+
threadId: this.context.threadId,
|
|
38
|
+
runId: this.context.runId,
|
|
39
|
+
result: result.result,
|
|
40
|
+
outcome: 'success',
|
|
41
|
+
timestamp: generateTimestamp(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Map lane error to RunError event
|
|
46
|
+
*/
|
|
47
|
+
mapLaneErrorToRunError(error) {
|
|
48
|
+
const message = typeof error === 'string' ? error : error.message;
|
|
49
|
+
return {
|
|
50
|
+
type: 'RunError',
|
|
51
|
+
message,
|
|
52
|
+
code: typeof error === 'object' && 'code' in error
|
|
53
|
+
? error.code
|
|
54
|
+
: undefined,
|
|
55
|
+
timestamp: generateTimestamp(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Map capability execution start to StepStarted event
|
|
60
|
+
*/
|
|
61
|
+
mapCapabilityStartToStepStarted(capabilityType) {
|
|
62
|
+
return {
|
|
63
|
+
type: 'StepStarted',
|
|
64
|
+
stepName: capabilityTypeToStepName(capabilityType),
|
|
65
|
+
timestamp: generateTimestamp(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Map capability execution end to StepFinished event
|
|
70
|
+
*/
|
|
71
|
+
mapCapabilityEndToStepFinished(capabilityType) {
|
|
72
|
+
return {
|
|
73
|
+
type: 'StepFinished',
|
|
74
|
+
stepName: capabilityTypeToStepName(capabilityType),
|
|
75
|
+
timestamp: generateTimestamp(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Map capability result to appropriate AG-UI events
|
|
80
|
+
* This is the core mapping logic that handles different capability types
|
|
81
|
+
*/
|
|
82
|
+
mapCapabilityToEvents(result, cycleNumber) {
|
|
83
|
+
const events = [];
|
|
84
|
+
// Map based on capability type
|
|
85
|
+
switch (result.type) {
|
|
86
|
+
case oCapabilityType.EVALUATE:
|
|
87
|
+
events.push(...this.mapEvaluateCapability(result, cycleNumber));
|
|
88
|
+
break;
|
|
89
|
+
case oCapabilityType.TASK:
|
|
90
|
+
events.push(...this.mapTaskCapability(result, cycleNumber));
|
|
91
|
+
break;
|
|
92
|
+
case oCapabilityType.SEARCH:
|
|
93
|
+
events.push(...this.mapSearchCapability(result, cycleNumber));
|
|
94
|
+
break;
|
|
95
|
+
case oCapabilityType.CONFIGURE:
|
|
96
|
+
events.push(...this.mapConfigureCapability(result, cycleNumber));
|
|
97
|
+
break;
|
|
98
|
+
case oCapabilityType.MULTIPLE_STEP:
|
|
99
|
+
events.push(...this.mapMultipleStepCapability(result, cycleNumber));
|
|
100
|
+
break;
|
|
101
|
+
case oCapabilityType.ERROR:
|
|
102
|
+
events.push(...this.mapErrorCapability(result, cycleNumber));
|
|
103
|
+
break;
|
|
104
|
+
case oCapabilityType.STOP:
|
|
105
|
+
// STOP doesn't generate events - it's handled at the lane level
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
// Unknown capability type - emit as custom event
|
|
109
|
+
events.push(this.mapUnknownCapability(result, cycleNumber));
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return events;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Map EVALUATE capability to text message events (agent reasoning)
|
|
116
|
+
*/
|
|
117
|
+
mapEvaluateCapability(result, cycleNumber) {
|
|
118
|
+
const events = [];
|
|
119
|
+
const messageId = generateMessageId();
|
|
120
|
+
// Store message ID for this cycle
|
|
121
|
+
if (!this.context.cycleToMessageId) {
|
|
122
|
+
this.context.cycleToMessageId = new Map();
|
|
123
|
+
}
|
|
124
|
+
this.context.cycleToMessageId.set(cycleNumber, messageId);
|
|
125
|
+
this.context.currentMessageId = messageId;
|
|
126
|
+
// Start message
|
|
127
|
+
events.push({
|
|
128
|
+
type: 'TextMessageStart',
|
|
129
|
+
messageId,
|
|
130
|
+
role: 'assistant',
|
|
131
|
+
timestamp: generateTimestamp(),
|
|
132
|
+
});
|
|
133
|
+
// Extract reasoning/summary from result
|
|
134
|
+
const reasoning = result.config?.params?.reasoning ||
|
|
135
|
+
result.config?.params?.summary ||
|
|
136
|
+
result.result?.reasoning ||
|
|
137
|
+
result.result?.summary ||
|
|
138
|
+
'Evaluating next steps...';
|
|
139
|
+
const content = typeof reasoning === 'string' ? reasoning : safeJSONStringify(reasoning);
|
|
140
|
+
// Chunk the content for streaming effect
|
|
141
|
+
if (this.config.textChunkSize &&
|
|
142
|
+
content.length > this.config.textChunkSize) {
|
|
143
|
+
const chunks = chunkString(content, this.config.textChunkSize);
|
|
144
|
+
for (const chunk of chunks) {
|
|
145
|
+
events.push({
|
|
146
|
+
type: 'TextMessageContent',
|
|
147
|
+
messageId,
|
|
148
|
+
delta: chunk,
|
|
149
|
+
timestamp: generateTimestamp(),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
events.push({
|
|
155
|
+
type: 'TextMessageContent',
|
|
156
|
+
messageId,
|
|
157
|
+
delta: content,
|
|
158
|
+
timestamp: generateTimestamp(),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// End message
|
|
162
|
+
events.push({
|
|
163
|
+
type: 'TextMessageEnd',
|
|
164
|
+
messageId,
|
|
165
|
+
timestamp: generateTimestamp(),
|
|
166
|
+
});
|
|
167
|
+
return events;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Map TASK capability to tool call events
|
|
171
|
+
*/
|
|
172
|
+
mapTaskCapability(result, cycleNumber) {
|
|
173
|
+
const events = [];
|
|
174
|
+
const toolCallId = generateToolCallId();
|
|
175
|
+
const messageId = this.context.currentMessageId || generateMessageId();
|
|
176
|
+
// Store tool call ID
|
|
177
|
+
if (!this.context.taskToToolCallId) {
|
|
178
|
+
this.context.taskToToolCallId = new Map();
|
|
179
|
+
}
|
|
180
|
+
this.context.taskToToolCallId.set(`cycle-${cycleNumber}`, toolCallId);
|
|
181
|
+
this.context.currentToolCallId = toolCallId;
|
|
182
|
+
// Extract tool information
|
|
183
|
+
const toolName = result.config?.params?.task?.address ||
|
|
184
|
+
result.config?.params?.tool ||
|
|
185
|
+
'task';
|
|
186
|
+
// Tool call start
|
|
187
|
+
events.push({
|
|
188
|
+
type: 'ToolCallStart',
|
|
189
|
+
toolCallId,
|
|
190
|
+
toolCallName: String(toolName),
|
|
191
|
+
parentMessageId: messageId,
|
|
192
|
+
timestamp: generateTimestamp(),
|
|
193
|
+
});
|
|
194
|
+
// Tool call arguments
|
|
195
|
+
const args = result.config?.params?.task?.payload || result.config?.params || {};
|
|
196
|
+
const argsStr = safeJSONStringify(args);
|
|
197
|
+
events.push({
|
|
198
|
+
type: 'ToolCallArgs',
|
|
199
|
+
toolCallId,
|
|
200
|
+
delta: argsStr,
|
|
201
|
+
timestamp: generateTimestamp(),
|
|
202
|
+
});
|
|
203
|
+
// Tool call end
|
|
204
|
+
events.push({
|
|
205
|
+
type: 'ToolCallEnd',
|
|
206
|
+
toolCallId,
|
|
207
|
+
timestamp: generateTimestamp(),
|
|
208
|
+
});
|
|
209
|
+
// Tool call result
|
|
210
|
+
events.push({
|
|
211
|
+
type: 'ToolCallResult',
|
|
212
|
+
messageId,
|
|
213
|
+
toolCallId,
|
|
214
|
+
content: result.result || result.error || null,
|
|
215
|
+
role: 'tool',
|
|
216
|
+
timestamp: generateTimestamp(),
|
|
217
|
+
});
|
|
218
|
+
return events;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Map SEARCH capability to activity events
|
|
222
|
+
*/
|
|
223
|
+
mapSearchCapability(result, cycleNumber) {
|
|
224
|
+
if (!this.config.emitActivityEvents) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
const messageId = generateMessageId();
|
|
228
|
+
return [
|
|
229
|
+
{
|
|
230
|
+
type: 'ActivitySnapshot',
|
|
231
|
+
messageId,
|
|
232
|
+
activityType: ACTIVITY_TYPES.SEARCH,
|
|
233
|
+
content: {
|
|
234
|
+
cycle: cycleNumber,
|
|
235
|
+
query: result.config?.params?.query || 'searching...',
|
|
236
|
+
results: result.result,
|
|
237
|
+
},
|
|
238
|
+
replace: true,
|
|
239
|
+
timestamp: generateTimestamp(),
|
|
240
|
+
},
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Map CONFIGURE capability to activity events
|
|
245
|
+
*/
|
|
246
|
+
mapConfigureCapability(result, cycleNumber) {
|
|
247
|
+
if (!this.config.emitActivityEvents) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
const messageId = generateMessageId();
|
|
251
|
+
return [
|
|
252
|
+
{
|
|
253
|
+
type: 'ActivitySnapshot',
|
|
254
|
+
messageId,
|
|
255
|
+
activityType: ACTIVITY_TYPES.CONFIGURE,
|
|
256
|
+
content: {
|
|
257
|
+
cycle: cycleNumber,
|
|
258
|
+
configuration: result.config?.params || {},
|
|
259
|
+
status: result.error ? 'failed' : 'completed',
|
|
260
|
+
},
|
|
261
|
+
replace: true,
|
|
262
|
+
timestamp: generateTimestamp(),
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Map MULTIPLE_STEP capability to activity events
|
|
268
|
+
*/
|
|
269
|
+
mapMultipleStepCapability(result, cycleNumber) {
|
|
270
|
+
if (!this.config.emitActivityEvents) {
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
const messageId = generateMessageId();
|
|
274
|
+
return [
|
|
275
|
+
{
|
|
276
|
+
type: 'ActivitySnapshot',
|
|
277
|
+
messageId,
|
|
278
|
+
activityType: ACTIVITY_TYPES.PLAN,
|
|
279
|
+
content: {
|
|
280
|
+
cycle: cycleNumber,
|
|
281
|
+
steps: result.result?.steps || [],
|
|
282
|
+
currentStep: result.result?.currentStep || 0,
|
|
283
|
+
},
|
|
284
|
+
replace: true,
|
|
285
|
+
timestamp: generateTimestamp(),
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Map ERROR capability to activity events
|
|
291
|
+
*/
|
|
292
|
+
mapErrorCapability(result, cycleNumber) {
|
|
293
|
+
const messageId = generateMessageId();
|
|
294
|
+
return [
|
|
295
|
+
{
|
|
296
|
+
type: 'ActivitySnapshot',
|
|
297
|
+
messageId,
|
|
298
|
+
activityType: ACTIVITY_TYPES.ERROR,
|
|
299
|
+
content: {
|
|
300
|
+
cycle: cycleNumber,
|
|
301
|
+
error: result.error || 'Unknown error',
|
|
302
|
+
recovery: result.result || 'Attempting recovery...',
|
|
303
|
+
},
|
|
304
|
+
replace: true,
|
|
305
|
+
timestamp: generateTimestamp(),
|
|
306
|
+
},
|
|
307
|
+
];
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Map unknown capability to custom event
|
|
311
|
+
*/
|
|
312
|
+
mapUnknownCapability(result, cycleNumber) {
|
|
313
|
+
return {
|
|
314
|
+
type: 'Custom',
|
|
315
|
+
name: `capability_${result.type}`,
|
|
316
|
+
value: {
|
|
317
|
+
cycle: cycleNumber,
|
|
318
|
+
result: result.result,
|
|
319
|
+
error: result.error,
|
|
320
|
+
},
|
|
321
|
+
timestamp: generateTimestamp(),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Map execution sequence to state snapshot
|
|
326
|
+
*/
|
|
327
|
+
mapSequenceToStateSnapshot(sequence) {
|
|
328
|
+
return {
|
|
329
|
+
type: 'StateSnapshot',
|
|
330
|
+
snapshot: {
|
|
331
|
+
sequence: sequence.map((s) => ({
|
|
332
|
+
type: s.type,
|
|
333
|
+
result: s.result,
|
|
334
|
+
error: s.error,
|
|
335
|
+
id: s.id,
|
|
336
|
+
})),
|
|
337
|
+
cycleCount: sequence.length,
|
|
338
|
+
},
|
|
339
|
+
timestamp: generateTimestamp(),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Map execution sequence update to state delta
|
|
344
|
+
*/
|
|
345
|
+
mapSequenceToStateDelta(oldSequence, newSequence) {
|
|
346
|
+
const oldState = {
|
|
347
|
+
sequence: oldSequence.map((s) => ({
|
|
348
|
+
type: s.type,
|
|
349
|
+
result: s.result,
|
|
350
|
+
error: s.error,
|
|
351
|
+
id: s.id,
|
|
352
|
+
})),
|
|
353
|
+
cycleCount: oldSequence.length,
|
|
354
|
+
};
|
|
355
|
+
const newState = {
|
|
356
|
+
sequence: newSequence.map((s) => ({
|
|
357
|
+
type: s.type,
|
|
358
|
+
result: s.result,
|
|
359
|
+
error: s.error,
|
|
360
|
+
id: s.id,
|
|
361
|
+
})),
|
|
362
|
+
cycleCount: newSequence.length,
|
|
363
|
+
};
|
|
364
|
+
const delta = generateJSONPatch(oldState, newState);
|
|
365
|
+
if (delta.length === 0) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
type: 'StateDelta',
|
|
370
|
+
delta,
|
|
371
|
+
timestamp: generateTimestamp(),
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Map streaming chunk to activity event
|
|
376
|
+
* Extracts capability result from oResponse wrapper and maps appropriately
|
|
377
|
+
*/
|
|
378
|
+
mapChunkToActivity(chunk, cycleNumber) {
|
|
379
|
+
const messageId = generateMessageId();
|
|
380
|
+
// Extract capability result from oResponse wrapper
|
|
381
|
+
// Structure: { data: { id, result, humanResult, type, error, ... }, _last, _isStreaming, ... }
|
|
382
|
+
const capabilityData = chunk.data || chunk;
|
|
383
|
+
const capabilityType = capabilityData.type;
|
|
384
|
+
const result = capabilityData.result;
|
|
385
|
+
const humanResult = capabilityData.humanResult;
|
|
386
|
+
const error = capabilityData.error;
|
|
387
|
+
// Determine activity type based on capability type
|
|
388
|
+
let activityType;
|
|
389
|
+
let content;
|
|
390
|
+
switch (capabilityType) {
|
|
391
|
+
case oCapabilityType.EVALUATE:
|
|
392
|
+
activityType = ACTIVITY_TYPES.EVALUATE;
|
|
393
|
+
content = {
|
|
394
|
+
cycle: cycleNumber,
|
|
395
|
+
reasoning: result?.reasoning || result?.summary || humanResult,
|
|
396
|
+
status: error ? 'error' : 'evaluating',
|
|
397
|
+
};
|
|
398
|
+
break;
|
|
399
|
+
case oCapabilityType.TASK:
|
|
400
|
+
activityType = ACTIVITY_TYPES.EXECUTE;
|
|
401
|
+
content = {
|
|
402
|
+
cycle: cycleNumber,
|
|
403
|
+
task: result?.task?.address || result?.tool || 'task',
|
|
404
|
+
status: error ? 'error' : 'executing',
|
|
405
|
+
result: humanResult || result,
|
|
406
|
+
};
|
|
407
|
+
break;
|
|
408
|
+
case oCapabilityType.SEARCH:
|
|
409
|
+
activityType = ACTIVITY_TYPES.SEARCH;
|
|
410
|
+
content = {
|
|
411
|
+
cycle: cycleNumber,
|
|
412
|
+
query: result?.query || 'searching',
|
|
413
|
+
results: result?.results || result,
|
|
414
|
+
status: error ? 'error' : 'searching',
|
|
415
|
+
};
|
|
416
|
+
break;
|
|
417
|
+
case oCapabilityType.CONFIGURE:
|
|
418
|
+
activityType = ACTIVITY_TYPES.CONFIGURE;
|
|
419
|
+
content = {
|
|
420
|
+
cycle: cycleNumber,
|
|
421
|
+
configuration: result,
|
|
422
|
+
status: error ? 'error' : 'configuring',
|
|
423
|
+
};
|
|
424
|
+
break;
|
|
425
|
+
case oCapabilityType.ERROR:
|
|
426
|
+
activityType = ACTIVITY_TYPES.ERROR;
|
|
427
|
+
content = {
|
|
428
|
+
cycle: cycleNumber,
|
|
429
|
+
error: error || result?.error || 'Unknown error',
|
|
430
|
+
recovery: result?.recovery || result?.message,
|
|
431
|
+
status: 'error',
|
|
432
|
+
};
|
|
433
|
+
break;
|
|
434
|
+
case oCapabilityType.MULTIPLE_STEP:
|
|
435
|
+
activityType = ACTIVITY_TYPES.PLAN;
|
|
436
|
+
content = {
|
|
437
|
+
cycle: cycleNumber,
|
|
438
|
+
steps: result?.steps || [],
|
|
439
|
+
currentStep: result?.currentStep || 0,
|
|
440
|
+
status: error ? 'error' : 'planning',
|
|
441
|
+
};
|
|
442
|
+
break;
|
|
443
|
+
case oCapabilityType.STOP:
|
|
444
|
+
activityType = ACTIVITY_TYPES.EXECUTE;
|
|
445
|
+
content = {
|
|
446
|
+
cycle: cycleNumber,
|
|
447
|
+
status: 'completed',
|
|
448
|
+
result: humanResult || result,
|
|
449
|
+
};
|
|
450
|
+
break;
|
|
451
|
+
default:
|
|
452
|
+
// Unknown capability type - provide generic progress
|
|
453
|
+
activityType = ACTIVITY_TYPES.PROGRESS;
|
|
454
|
+
content = {
|
|
455
|
+
cycle: cycleNumber,
|
|
456
|
+
type: capabilityType,
|
|
457
|
+
result: humanResult || result,
|
|
458
|
+
status: error ? 'error' : 'processing',
|
|
459
|
+
};
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
// Add error details if present
|
|
463
|
+
if (error) {
|
|
464
|
+
content.error = error;
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
type: 'ActivitySnapshot',
|
|
468
|
+
messageId,
|
|
469
|
+
activityType,
|
|
470
|
+
content,
|
|
471
|
+
replace: false, // Don't replace - show progress updates
|
|
472
|
+
timestamp: generateTimestamp(),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Update the event context
|
|
477
|
+
*/
|
|
478
|
+
updateContext(updates) {
|
|
479
|
+
Object.assign(this.context, updates);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Get current context
|
|
483
|
+
*/
|
|
484
|
+
getContext() {
|
|
485
|
+
return { ...this.context };
|
|
486
|
+
}
|
|
487
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { oLaneTool } from '../o-lane.tool.js';
|
|
2
|
+
import { AGUIoLaneConfig } from './types/ag-ui-config.interface.js';
|
|
3
|
+
import { oRequest } from '@olane/o-core';
|
|
4
|
+
import { oStreamRequest } from '@olane/o-node';
|
|
5
|
+
/**
|
|
6
|
+
* AG-UI compatible oLane Tool
|
|
7
|
+
* Extends oLaneTool with AG-UI event streaming capabilities
|
|
8
|
+
*/
|
|
9
|
+
export declare class AGUIoLaneTool extends oLaneTool {
|
|
10
|
+
private agUIConfig;
|
|
11
|
+
protected manager: any;
|
|
12
|
+
constructor(config: AGUIoLaneConfig);
|
|
13
|
+
/**
|
|
14
|
+
* AG-UI compatible intent method with full event streaming
|
|
15
|
+
* This is the main entry point for AG-UI enabled intent resolution
|
|
16
|
+
*/
|
|
17
|
+
_tool_ag_ui_intent(request: oStreamRequest): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Standard intent method - optionally enable AG-UI if configured
|
|
20
|
+
* Overrides the base _tool_intent to add AG-UI support
|
|
21
|
+
*/
|
|
22
|
+
_tool_intent(request: oStreamRequest): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Receive AG-UI event from remote sources
|
|
25
|
+
* Allows other tools to send events to this tool
|
|
26
|
+
*/
|
|
27
|
+
_tool_receive_ag_ui_event(request: oRequest): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Create default transport based on request configuration
|
|
30
|
+
*/
|
|
31
|
+
private createDefaultTransport;
|
|
32
|
+
/**
|
|
33
|
+
* Enable or disable AG-UI at runtime
|
|
34
|
+
*/
|
|
35
|
+
setAGUIEnabled(enabled: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* Check if AG-UI is enabled
|
|
38
|
+
*/
|
|
39
|
+
isAGUIEnabled(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get AG-UI configuration
|
|
42
|
+
*/
|
|
43
|
+
getAGUIConfig(): AGUIoLaneConfig;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ag-ui-olane.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ag-ui-olane.tool.d.ts","sourceRoot":"","sources":["../../../src/ag-ui/ag-ui-olane.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,eAAe,EAEhB,MAAM,mCAAmC,CAAC;AAS3C,OAAO,EAAE,QAAQ,EAAY,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQ/C;;;GAGG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,CAAC,UAAU,CAAkB;IACpC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC;gBAEX,MAAM,EAAE,eAAe;IAanC;;;OAGG;IACG,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAqM/D;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAqCzD;;;OAGG;IACG,yBAAyB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAYhE;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAiB9B;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAItC;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,eAAe;CAGjC"}
|