@olane/o-lane 0.7.12-alpha.76 → 0.7.12
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/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -2
- package/dist/src/prompts/agent.prompt.d.ts +11 -0
- package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
- package/dist/src/prompts/agent.prompt.js +14 -3
- package/dist/src/prompts/configure.prompt.d.ts +7 -0
- package/dist/src/prompts/configure.prompt.d.ts.map +1 -1
- package/dist/src/prompts/configure.prompt.js +8 -1
- package/dist/src/prompts/custom.prompt.d.ts +7 -0
- package/dist/src/prompts/custom.prompt.d.ts.map +1 -1
- package/dist/src/prompts/custom.prompt.js +77 -0
- package/dist/src/storage/index.d.ts +8 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +12 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.d.ts +102 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.d.ts.map +1 -0
- package/dist/src/storage/methods/prompt-storage.methods.d.ts +9 -0
- package/dist/src/storage/methods/prompt-storage.methods.d.ts.map +1 -0
- package/dist/src/storage/methods/prompt-storage.methods.js +338 -0
- package/dist/src/storage/prompt-loader.d.ts +40 -0
- package/dist/src/storage/prompt-loader.d.ts.map +1 -0
- package/dist/src/storage/prompt-loader.js +126 -0
- package/dist/src/storage/prompt-schema.d.ts +42 -0
- package/dist/src/storage/prompt-schema.d.ts.map +1 -0
- package/dist/src/storage/prompt-schema.js +29 -0
- package/dist/src/storage/prompt-seeder.d.ts +42 -0
- package/dist/src/storage/prompt-seeder.d.ts.map +1 -0
- package/dist/src/storage/prompt-seeder.js +141 -0
- package/dist/src/storage/prompt-storage-provider.tool.d.ts +99 -0
- package/dist/src/storage/prompt-storage-provider.tool.d.ts.map +1 -0
- package/dist/src/storage/prompt-storage-provider.tool.js +320 -0
- package/dist/test/prompt-seeder.spec.d.ts +2 -0
- package/dist/test/prompt-seeder.spec.d.ts.map +1 -0
- package/dist/test/prompt-seeder.spec.js +254 -0
- package/dist/test/prompt-storage-provider.spec.d.ts +2 -0
- package/dist/test/prompt-storage-provider.spec.d.ts.map +1 -0
- package/dist/test/prompt-storage-provider.spec.js +456 -0
- package/package.json +10 -7
- package/dist/src/ag-ui/ag-ui-constants.d.ts +0 -90
- package/dist/src/ag-ui/ag-ui-constants.d.ts.map +0 -1
- package/dist/src/ag-ui/ag-ui-constants.js +0 -113
- package/dist/src/ag-ui/ag-ui-event-mapper.d.ts +0 -88
- package/dist/src/ag-ui/ag-ui-event-mapper.d.ts.map +0 -1
- package/dist/src/ag-ui/ag-ui-event-mapper.js +0 -487
- package/dist/src/ag-ui/ag-ui-olane.tool.d.ts +0 -45
- package/dist/src/ag-ui/ag-ui-olane.tool.d.ts.map +0 -1
- package/dist/src/ag-ui/ag-ui-olane.tool.js +0 -257
- package/dist/src/ag-ui/ag-ui-stream-manager.d.ts +0 -99
- package/dist/src/ag-ui/ag-ui-stream-manager.d.ts.map +0 -1
- package/dist/src/ag-ui/ag-ui-stream-manager.js +0 -160
- package/dist/src/ag-ui/ag-ui-utils.d.ts +0 -50
- package/dist/src/ag-ui/ag-ui-utils.d.ts.map +0 -1
- package/dist/src/ag-ui/ag-ui-utils.js +0 -287
- package/dist/src/ag-ui/index.d.ts +0 -17
- package/dist/src/ag-ui/index.d.ts.map +0 -1
- package/dist/src/ag-ui/index.js +0 -21
- package/dist/src/ag-ui/transports/ag-ui-transport.interface.d.ts +0 -44
- package/dist/src/ag-ui/transports/ag-ui-transport.interface.d.ts.map +0 -1
- package/dist/src/ag-ui/transports/ag-ui-transport.interface.js +0 -26
- package/dist/src/ag-ui/transports/callback-transport.d.ts +0 -13
- package/dist/src/ag-ui/transports/callback-transport.d.ts.map +0 -1
- package/dist/src/ag-ui/transports/callback-transport.js +0 -26
- package/dist/src/ag-ui/transports/console-transport.d.ts +0 -14
- package/dist/src/ag-ui/transports/console-transport.d.ts.map +0 -1
- package/dist/src/ag-ui/transports/console-transport.js +0 -63
- package/dist/src/ag-ui/transports/index.d.ts +0 -5
- package/dist/src/ag-ui/transports/index.d.ts.map +0 -1
- package/dist/src/ag-ui/transports/index.js +0 -4
- package/dist/src/ag-ui/transports/onode-transport.d.ts +0 -34
- package/dist/src/ag-ui/transports/onode-transport.d.ts.map +0 -1
- package/dist/src/ag-ui/transports/onode-transport.js +0 -83
- package/dist/src/ag-ui/types/ag-ui-config.interface.d.ts +0 -105
- package/dist/src/ag-ui/types/ag-ui-config.interface.d.ts.map +0 -1
- package/dist/src/ag-ui/types/ag-ui-event.types.d.ts +0 -266
- package/dist/src/ag-ui/types/ag-ui-event.types.d.ts.map +0 -1
- package/dist/src/ag-ui/types/ag-ui-event.types.js +0 -6
- package/dist/src/ag-ui/types/index.d.ts +0 -3
- package/dist/src/ag-ui/types/index.d.ts.map +0 -1
- package/dist/src/ag-ui/types/index.js +0 -2
- package/dist/test/ai.spec.d.ts +0 -2
- package/dist/test/ai.spec.d.ts.map +0 -1
- package/dist/test/ai.spec.js +0 -19
- /package/dist/src/{ag-ui/types/ag-ui-config.interface.js → storage/interfaces/prompt-storage.interface.js} +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AG-UI Protocol Constants
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* AG-UI protocol version this implementation supports
|
|
6
|
-
*/
|
|
7
|
-
export const AG_UI_PROTOCOL_VERSION = '1.0.0';
|
|
8
|
-
/**
|
|
9
|
-
* Default configuration values
|
|
10
|
-
*/
|
|
11
|
-
export const AG_UI_DEFAULTS = {
|
|
12
|
-
/**
|
|
13
|
-
* Default state snapshot interval (every N cycles)
|
|
14
|
-
*/
|
|
15
|
-
STATE_SNAPSHOT_INTERVAL: 5,
|
|
16
|
-
/**
|
|
17
|
-
* Maximum delta history to keep
|
|
18
|
-
*/
|
|
19
|
-
MAX_DELTA_HISTORY: 100,
|
|
20
|
-
/**
|
|
21
|
-
* Default text chunk size for streaming
|
|
22
|
-
*/
|
|
23
|
-
TEXT_CHUNK_SIZE: 100,
|
|
24
|
-
/**
|
|
25
|
-
* Enable debug logging by default
|
|
26
|
-
*/
|
|
27
|
-
DEBUG_ENABLED: false,
|
|
28
|
-
/**
|
|
29
|
-
* Enable AG-UI by default
|
|
30
|
-
*/
|
|
31
|
-
AGUI_ENABLED: true,
|
|
32
|
-
/**
|
|
33
|
-
* Emit activity events by default
|
|
34
|
-
*/
|
|
35
|
-
EMIT_ACTIVITY_EVENTS: true,
|
|
36
|
-
/**
|
|
37
|
-
* Emit reasoning events by default
|
|
38
|
-
*/
|
|
39
|
-
EMIT_REASONING_EVENTS: true,
|
|
40
|
-
/**
|
|
41
|
-
* Include raw events by default
|
|
42
|
-
*/
|
|
43
|
-
INCLUDE_RAW_EVENTS: false,
|
|
44
|
-
/**
|
|
45
|
-
* Auto-generate thread ID by default
|
|
46
|
-
*/
|
|
47
|
-
AUTO_GENERATE_THREAD_ID: true,
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Activity types for AG-UI activity events
|
|
51
|
-
*/
|
|
52
|
-
export const ACTIVITY_TYPES = {
|
|
53
|
-
PLAN: 'PLAN',
|
|
54
|
-
EXECUTE: 'EXECUTE',
|
|
55
|
-
EVALUATE: 'EVALUATE',
|
|
56
|
-
SEARCH: 'SEARCH',
|
|
57
|
-
CONFIGURE: 'CONFIGURE',
|
|
58
|
-
ERROR: 'ERROR',
|
|
59
|
-
PROGRESS: 'PROGRESS',
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Event type categories for filtering
|
|
63
|
-
*/
|
|
64
|
-
export const EVENT_CATEGORIES = {
|
|
65
|
-
LIFECYCLE: [
|
|
66
|
-
'RunStarted',
|
|
67
|
-
'RunFinished',
|
|
68
|
-
'RunError',
|
|
69
|
-
'StepStarted',
|
|
70
|
-
'StepFinished',
|
|
71
|
-
],
|
|
72
|
-
MESSAGES: [
|
|
73
|
-
'TextMessageStart',
|
|
74
|
-
'TextMessageContent',
|
|
75
|
-
'TextMessageEnd',
|
|
76
|
-
'TextMessageChunk',
|
|
77
|
-
],
|
|
78
|
-
TOOL_CALLS: [
|
|
79
|
-
'ToolCallStart',
|
|
80
|
-
'ToolCallArgs',
|
|
81
|
-
'ToolCallEnd',
|
|
82
|
-
'ToolCallResult',
|
|
83
|
-
'ToolCallChunk',
|
|
84
|
-
],
|
|
85
|
-
STATE: ['StateSnapshot', 'StateDelta', 'MessagesSnapshot'],
|
|
86
|
-
ACTIVITY: ['ActivitySnapshot', 'ActivityDelta'],
|
|
87
|
-
SPECIAL: ['Raw', 'Custom'],
|
|
88
|
-
REASONING: [
|
|
89
|
-
'ReasoningStart',
|
|
90
|
-
'ReasoningEnd',
|
|
91
|
-
'ReasoningMessageStart',
|
|
92
|
-
'ReasoningMessageContent',
|
|
93
|
-
'ReasoningMessageEnd',
|
|
94
|
-
'ReasoningMessageChunk',
|
|
95
|
-
],
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Default message roles
|
|
99
|
-
*/
|
|
100
|
-
export const MESSAGE_ROLES = {
|
|
101
|
-
DEVELOPER: 'developer',
|
|
102
|
-
SYSTEM: 'system',
|
|
103
|
-
ASSISTANT: 'assistant',
|
|
104
|
-
USER: 'user',
|
|
105
|
-
TOOL: 'tool',
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Run outcome types
|
|
109
|
-
*/
|
|
110
|
-
export const RUN_OUTCOMES = {
|
|
111
|
-
SUCCESS: 'success',
|
|
112
|
-
INTERRUPT: 'interrupt',
|
|
113
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { oCapabilityType } from '../capabilities/enums/o-capability.type-enum.js';
|
|
2
|
-
import { oCapabilityResult } from '../capabilities/o-capability.result.js';
|
|
3
|
-
import { oIntent } from '../intent/o-intent.js';
|
|
4
|
-
import { AGUIEvent, RunStarted, RunFinished, RunError, StepStarted, StepFinished, StateSnapshot, StateDelta, ActivitySnapshot } from './types/ag-ui-event.types.js';
|
|
5
|
-
import { AGUIEventContext, AGUIEventMappingConfig } from './types/ag-ui-config.interface.js';
|
|
6
|
-
/**
|
|
7
|
-
* Maps oLane execution events to AG-UI protocol events
|
|
8
|
-
*/
|
|
9
|
-
export declare class AGUIEventMapper {
|
|
10
|
-
private config;
|
|
11
|
-
private context;
|
|
12
|
-
constructor(context: AGUIEventContext, config?: Partial<AGUIEventMappingConfig>);
|
|
13
|
-
/**
|
|
14
|
-
* Map lane creation to RunStarted event
|
|
15
|
-
*/
|
|
16
|
-
mapLaneStartToRunStarted(intent: oIntent, input?: unknown): RunStarted;
|
|
17
|
-
/**
|
|
18
|
-
* Map lane completion to RunFinished event
|
|
19
|
-
*/
|
|
20
|
-
mapLaneCompleteToRunFinished(result: oCapabilityResult): RunFinished;
|
|
21
|
-
/**
|
|
22
|
-
* Map lane error to RunError event
|
|
23
|
-
*/
|
|
24
|
-
mapLaneErrorToRunError(error: Error | string): RunError;
|
|
25
|
-
/**
|
|
26
|
-
* Map capability execution start to StepStarted event
|
|
27
|
-
*/
|
|
28
|
-
mapCapabilityStartToStepStarted(capabilityType: oCapabilityType): StepStarted;
|
|
29
|
-
/**
|
|
30
|
-
* Map capability execution end to StepFinished event
|
|
31
|
-
*/
|
|
32
|
-
mapCapabilityEndToStepFinished(capabilityType: oCapabilityType): StepFinished;
|
|
33
|
-
/**
|
|
34
|
-
* Map capability result to appropriate AG-UI events
|
|
35
|
-
* This is the core mapping logic that handles different capability types
|
|
36
|
-
*/
|
|
37
|
-
mapCapabilityToEvents(result: oCapabilityResult, cycleNumber: number): AGUIEvent[];
|
|
38
|
-
/**
|
|
39
|
-
* Map EVALUATE capability to text message events (agent reasoning)
|
|
40
|
-
*/
|
|
41
|
-
private mapEvaluateCapability;
|
|
42
|
-
/**
|
|
43
|
-
* Map TASK capability to tool call events
|
|
44
|
-
*/
|
|
45
|
-
private mapTaskCapability;
|
|
46
|
-
/**
|
|
47
|
-
* Map SEARCH capability to activity events
|
|
48
|
-
*/
|
|
49
|
-
private mapSearchCapability;
|
|
50
|
-
/**
|
|
51
|
-
* Map CONFIGURE capability to activity events
|
|
52
|
-
*/
|
|
53
|
-
private mapConfigureCapability;
|
|
54
|
-
/**
|
|
55
|
-
* Map MULTIPLE_STEP capability to activity events
|
|
56
|
-
*/
|
|
57
|
-
private mapMultipleStepCapability;
|
|
58
|
-
/**
|
|
59
|
-
* Map ERROR capability to activity events
|
|
60
|
-
*/
|
|
61
|
-
private mapErrorCapability;
|
|
62
|
-
/**
|
|
63
|
-
* Map unknown capability to custom event
|
|
64
|
-
*/
|
|
65
|
-
private mapUnknownCapability;
|
|
66
|
-
/**
|
|
67
|
-
* Map execution sequence to state snapshot
|
|
68
|
-
*/
|
|
69
|
-
mapSequenceToStateSnapshot(sequence: oCapabilityResult[]): StateSnapshot;
|
|
70
|
-
/**
|
|
71
|
-
* Map execution sequence update to state delta
|
|
72
|
-
*/
|
|
73
|
-
mapSequenceToStateDelta(oldSequence: oCapabilityResult[], newSequence: oCapabilityResult[]): StateDelta | null;
|
|
74
|
-
/**
|
|
75
|
-
* Map streaming chunk to activity event
|
|
76
|
-
* Extracts capability result from oResponse wrapper and maps appropriately
|
|
77
|
-
*/
|
|
78
|
-
mapChunkToActivity(chunk: any, cycleNumber: number): ActivitySnapshot;
|
|
79
|
-
/**
|
|
80
|
-
* Update the event context
|
|
81
|
-
*/
|
|
82
|
-
updateContext(updates: Partial<AGUIEventContext>): void;
|
|
83
|
-
/**
|
|
84
|
-
* Get current context
|
|
85
|
-
*/
|
|
86
|
-
getContext(): AGUIEventContext;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=ag-ui-event-mapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ag-ui-event-mapper.d.ts","sourceRoot":"","sources":["../../../src/ag-ui/ag-ui-event-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EAQZ,aAAa,EACb,UAAU,EACV,gBAAgB,EAEjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAY3C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,OAAO,CAAmB;gBAGhC,OAAO,EAAE,gBAAgB,EACzB,MAAM,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAgB9C;;OAEG;IACH,wBAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU;IAWtE;;OAEG;IACH,4BAA4B,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IAWpE;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ;IAavD;;OAEG;IACH,+BAA+B,CAC7B,cAAc,EAAE,eAAe,GAC9B,WAAW;IAQd;;OAEG;IACH,8BAA8B,CAC5B,cAAc,EAAE,eAAe,GAC9B,YAAY;IAQf;;;OAGG;IACH,qBAAqB,CACnB,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,MAAM,GAClB,SAAS,EAAE;IA0Cd;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAkE7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8DzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA0B3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0B9B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA0BjC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgB5B;;OAEG;IACH,0BAA0B,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,aAAa;IAgBxE;;OAEG;IACH,uBAAuB,CACrB,WAAW,EAAE,iBAAiB,EAAE,EAChC,WAAW,EAAE,iBAAiB,EAAE,GAC/B,UAAU,GAAG,IAAI;IAkCpB;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB;IA8GrE;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAIvD;;OAEG;IACH,UAAU,IAAI,gBAAgB;CAG/B"}
|
|
@@ -1,487 +0,0 @@
|
|
|
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
|
-
}
|