@loomweaver/ag-ui 0.14.2 → 0.14.4
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/package.json +2 -2
- package/src/lib/command-tools.js +38 -75
- package/src/lib/command-tools.js.map +1 -1
- package/src/lib/tool-arguments.js.map +1 -1
- package/src/lib/tool-call-assembly.d.ts +15 -0
- package/src/lib/tool-call-assembly.js +43 -0
- package/src/lib/tool-call-assembly.js.map +1 -0
- package/src/lib/tool-definitions.js +1 -1
- package/src/lib/tool-definitions.js.map +1 -1
- package/src/lib/tool-results.d.ts +0 -2
- package/src/lib/tool-results.js +8 -16
- package/src/lib/tool-results.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomweaver/ag-ui",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "LoomWeaver: open-source plugin platform for Angular workbenches. The AG-UI adapter: offers the workbench's own commands to an agent and runs what it asks for. Headless, with no transport, no UI and no agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"loomweaver",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@ag-ui/core": "0.0.x",
|
|
31
|
-
"@loomweaver/plugin-sdk": "0.14.
|
|
31
|
+
"@loomweaver/plugin-sdk": "0.14.4"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
package/src/lib/command-tools.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EventType, } from '@ag-ui/core';
|
|
2
|
+
import { ToolCallAssembly } from './tool-call-assembly.js';
|
|
2
3
|
import { readArguments } from './tool-arguments.js';
|
|
3
4
|
import { toolsFor } from './tool-definitions.js';
|
|
4
5
|
import { answerFor, refusalFor, resultFor } from './tool-results.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
const UNREADABLE = 'its arguments did not arrive as readable JSON.';
|
|
7
|
+
const UNFINISHED = 'the run ended before its arguments were complete.';
|
|
8
8
|
/**
|
|
9
9
|
* Connects a plugin context to an agent's tool calls.
|
|
10
10
|
*
|
|
@@ -14,76 +14,35 @@ function textOf(value) {
|
|
|
14
14
|
* this carries what it says.
|
|
15
15
|
*/
|
|
16
16
|
export function commandTools(ctx, options = {}) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const forget = (call) => {
|
|
20
|
-
open.delete(call.toolCallId);
|
|
21
|
-
if (chunked === call.toolCallId) {
|
|
22
|
-
chunked = null;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const finish = async (call) => {
|
|
26
|
-
forget(call);
|
|
27
|
-
const args = readArguments(call.json);
|
|
28
|
-
if (args === null) {
|
|
29
|
-
return refusalFor(call.toolCallId, 'its arguments did not arrive as readable JSON.');
|
|
30
|
-
}
|
|
31
|
-
const decision = await decide(options, () => ({
|
|
32
|
-
toolCallId: call.toolCallId,
|
|
33
|
-
commandId: call.commandId,
|
|
34
|
-
args,
|
|
35
|
-
...consentOf(ctx, call.commandId),
|
|
36
|
-
}));
|
|
37
|
-
if (decision.decision === 'decline') {
|
|
38
|
-
return refusalFor(call.toolCallId, decision.reason);
|
|
39
|
-
}
|
|
40
|
-
if (decision.decision === 'answer') {
|
|
41
|
-
return answerFor(call.toolCallId, decision.content);
|
|
42
|
-
}
|
|
43
|
-
return resultFor(call.toolCallId, await ctx.invokeCommand(call.commandId, args));
|
|
44
|
-
};
|
|
17
|
+
const assembly = new ToolCallAssembly();
|
|
18
|
+
const answer = async (call) => call ? answerCall(ctx, options, call) : null;
|
|
45
19
|
const flush = async () => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
forget(left);
|
|
51
|
-
return refusalFor(left.toolCallId, 'the run ended before its arguments were complete.');
|
|
52
|
-
};
|
|
53
|
-
const finishRun = async () => {
|
|
54
|
-
const carried = chunked === null ? undefined : open.get(chunked);
|
|
55
|
-
return carried ? finish(carried) : flush();
|
|
20
|
+
const left = assembly.takeFirst();
|
|
21
|
+
return left ? refusalFor(left.toolCallId, UNFINISHED) : null;
|
|
56
22
|
};
|
|
57
23
|
return {
|
|
58
24
|
list: () => toolsFor(ctx.invocableCommands()),
|
|
59
25
|
flush,
|
|
60
|
-
receive: async (
|
|
61
|
-
const
|
|
26
|
+
receive: async (received) => {
|
|
27
|
+
const event = received;
|
|
62
28
|
switch (event.type) {
|
|
63
29
|
case EventType.TOOL_CALL_START: {
|
|
64
|
-
|
|
65
|
-
toolCallId: String(raw['toolCallId']),
|
|
66
|
-
commandId: String(raw['toolCallName']),
|
|
67
|
-
json: '',
|
|
68
|
-
});
|
|
30
|
+
assembly.start(event.toolCallId, event.toolCallName);
|
|
69
31
|
return null;
|
|
70
32
|
}
|
|
71
33
|
case EventType.TOOL_CALL_ARGS: {
|
|
72
|
-
|
|
73
|
-
if (call) {
|
|
74
|
-
call.json += textOf(raw['delta']);
|
|
75
|
-
}
|
|
34
|
+
assembly.append(event.toolCallId, event.delta);
|
|
76
35
|
return null;
|
|
77
36
|
}
|
|
78
37
|
case EventType.TOOL_CALL_END: {
|
|
79
|
-
|
|
80
|
-
return call ? finish(call) : null;
|
|
38
|
+
return answer(assembly.take(event.toolCallId));
|
|
81
39
|
}
|
|
82
40
|
case EventType.TOOL_CALL_CHUNK: {
|
|
83
|
-
return
|
|
41
|
+
return answer(assembly.chunk(event.toolCallId, event.toolCallName ?? '', event.delta ?? ''));
|
|
84
42
|
}
|
|
85
43
|
case EventType.RUN_FINISHED: {
|
|
86
|
-
|
|
44
|
+
const carried = assembly.takeChunked();
|
|
45
|
+
return carried ? answerCall(ctx, options, carried) : flush();
|
|
87
46
|
}
|
|
88
47
|
case EventType.RUN_ERROR: {
|
|
89
48
|
return flush();
|
|
@@ -94,27 +53,31 @@ export function commandTools(ctx, options = {}) {
|
|
|
94
53
|
}
|
|
95
54
|
},
|
|
96
55
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return
|
|
56
|
+
}
|
|
57
|
+
async function answerCall(ctx, options, call) {
|
|
58
|
+
const args = readArguments(call.json);
|
|
59
|
+
if (args === null) {
|
|
60
|
+
return refusalFor(call.toolCallId, UNREADABLE);
|
|
61
|
+
}
|
|
62
|
+
if (!options.before) {
|
|
63
|
+
return run(ctx, call, args);
|
|
64
|
+
}
|
|
65
|
+
const decision = await options.before({
|
|
66
|
+
toolCallId: call.toolCallId,
|
|
67
|
+
commandId: call.commandId,
|
|
68
|
+
args,
|
|
69
|
+
...consentOf(ctx, call.commandId),
|
|
70
|
+
});
|
|
71
|
+
if (decision.decision === 'decline') {
|
|
72
|
+
return refusalFor(call.toolCallId, decision.reason);
|
|
73
|
+
}
|
|
74
|
+
if (decision.decision === 'answer') {
|
|
75
|
+
return answerFor(call.toolCallId, decision.content);
|
|
114
76
|
}
|
|
77
|
+
return run(ctx, call, args);
|
|
115
78
|
}
|
|
116
|
-
async function
|
|
117
|
-
return
|
|
79
|
+
async function run(ctx, call, args) {
|
|
80
|
+
return resultFor(call.toolCallId, await ctx.invokeCommand(call.commandId, args));
|
|
118
81
|
}
|
|
119
82
|
function consentOf(ctx, commandId) {
|
|
120
83
|
const consent = ctx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-tools.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/command-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"command-tools.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/command-tools.ts"],"names":[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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-arguments.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-arguments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-arguments.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-arguments.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACzB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAyC,EAAE,CAAC;IACtD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YACnB,SAAS;QACX,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YACnB,SAAS;QACX,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface AssembledCall {
|
|
2
|
+
readonly toolCallId: string;
|
|
3
|
+
readonly commandId: string;
|
|
4
|
+
readonly json: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ToolCallAssembly {
|
|
7
|
+
private readonly openCalls;
|
|
8
|
+
private chunkedCallId;
|
|
9
|
+
start(toolCallId: string, commandId: string, json?: string): void;
|
|
10
|
+
append(toolCallId: string, delta: string): void;
|
|
11
|
+
take(toolCallId: string): AssembledCall | undefined;
|
|
12
|
+
chunk(toolCallId: string | undefined, commandId: string, delta: string): AssembledCall | undefined;
|
|
13
|
+
takeChunked(): AssembledCall | undefined;
|
|
14
|
+
takeFirst(): AssembledCall | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class ToolCallAssembly {
|
|
2
|
+
openCalls = new Map();
|
|
3
|
+
chunkedCallId = null;
|
|
4
|
+
start(toolCallId, commandId, json = '') {
|
|
5
|
+
this.openCalls.set(toolCallId, { toolCallId, commandId, json });
|
|
6
|
+
}
|
|
7
|
+
append(toolCallId, delta) {
|
|
8
|
+
const call = this.openCalls.get(toolCallId);
|
|
9
|
+
if (call) {
|
|
10
|
+
call.json += delta;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
take(toolCallId) {
|
|
14
|
+
const call = this.openCalls.get(toolCallId);
|
|
15
|
+
this.openCalls.delete(toolCallId);
|
|
16
|
+
if (this.chunkedCallId === toolCallId) {
|
|
17
|
+
this.chunkedCallId = null;
|
|
18
|
+
}
|
|
19
|
+
return call;
|
|
20
|
+
}
|
|
21
|
+
chunk(toolCallId, commandId, delta) {
|
|
22
|
+
if (toolCallId === undefined || toolCallId === this.chunkedCallId) {
|
|
23
|
+
if (this.chunkedCallId !== null) {
|
|
24
|
+
this.append(this.chunkedCallId, delta);
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const previous = this.takeChunked();
|
|
29
|
+
this.start(toolCallId, commandId, delta);
|
|
30
|
+
this.chunkedCallId = toolCallId;
|
|
31
|
+
return previous;
|
|
32
|
+
}
|
|
33
|
+
takeChunked() {
|
|
34
|
+
return this.chunkedCallId === null
|
|
35
|
+
? undefined
|
|
36
|
+
: this.take(this.chunkedCallId);
|
|
37
|
+
}
|
|
38
|
+
takeFirst() {
|
|
39
|
+
const [first] = this.openCalls.keys();
|
|
40
|
+
return first === undefined ? undefined : this.take(first);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=tool-call-assembly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call-assembly.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-call-assembly.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IACjD,aAAa,GAAkB,IAAI,CAAC;IAE5C,KAAK,CAAC,UAAkB,EAAE,SAAiB,EAAE,IAAI,GAAG,EAAE;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,CAAC,UAAkB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AI,EAAE,CAAC;QACtC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -48,7 +48,7 @@ function parametersFor(args) {
|
|
|
48
48
|
}
|
|
49
49
|
function propertyFor(argument) {
|
|
50
50
|
const scalar = {
|
|
51
|
-
type: SCALAR_TYPE[argument.kind]
|
|
51
|
+
type: SCALAR_TYPE[argument.kind],
|
|
52
52
|
...(argument.kind === 'choice' && { enum: argument.choices }),
|
|
53
53
|
};
|
|
54
54
|
return argument.list === true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-definitions.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-definitions.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"tool-definitions.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-definitions.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,GAAsD;IACrE,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,OAAyB;IAC/C,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,EAAE;QAChB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,KAAK;QACjD,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC;QAC5C,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI;YACxC,QAAQ,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE;SACjD,CAAC;KACH,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,QAAQ,CAAC,QAAqC;IAC5D,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,aAAa,CACpB,IAA4C;IAE5C,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAChC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IACD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,QAAQ,EAAE,QAAQ;aACf,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;aAChD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,QAAyB;IAC5C,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;QAChC,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;KAC9D,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,KAAK,IAAI;QAC3B,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;QACrE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -12,7 +12,5 @@ import type { CommandOutcome } from '@loomweaver/plugin-sdk';
|
|
|
12
12
|
* agent like a tool that returned nothing useful, and the usual response to that is to try again.
|
|
13
13
|
*/
|
|
14
14
|
export declare function resultFor(toolCallId: string, outcome: CommandOutcome): ToolMessage;
|
|
15
|
-
/** The message that answers a call the adapter could not put to the workbench at all. */
|
|
16
15
|
export declare function refusalFor(toolCallId: string, reason: string): ToolMessage;
|
|
17
|
-
/** The message that answers a call something in front of the workbench answered itself. */
|
|
18
16
|
export declare function answerFor(toolCallId: string, content: string): ToolMessage;
|
package/src/lib/tool-results.js
CHANGED
|
@@ -12,20 +12,21 @@ const RAN = 'The command ran.';
|
|
|
12
12
|
*/
|
|
13
13
|
export function resultFor(toolCallId, outcome) {
|
|
14
14
|
if (outcome.outcome === 'answered') {
|
|
15
|
-
return
|
|
15
|
+
return answerFor(toolCallId, contentOf(outcome.value));
|
|
16
16
|
}
|
|
17
17
|
if (outcome.outcome === 'refused') {
|
|
18
|
-
return
|
|
18
|
+
return refusalFor(toolCallId, outcome.message);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return errorMessage(toolCallId, `The command ran and failed: ${outcome.message}`);
|
|
21
21
|
}
|
|
22
|
-
/** The message that answers a call the adapter could not put to the workbench at all. */
|
|
23
22
|
export function refusalFor(toolCallId, reason) {
|
|
24
|
-
return
|
|
23
|
+
return errorMessage(toolCallId, `The command did not run: ${reason}`);
|
|
25
24
|
}
|
|
26
|
-
/** The message that answers a call something in front of the workbench answered itself. */
|
|
27
25
|
export function answerFor(toolCallId, content) {
|
|
28
|
-
return
|
|
26
|
+
return { id: `tool-${toolCallId}`, role: 'tool', toolCallId, content };
|
|
27
|
+
}
|
|
28
|
+
function errorMessage(toolCallId, error) {
|
|
29
|
+
return { ...answerFor(toolCallId, ''), error };
|
|
29
30
|
}
|
|
30
31
|
function contentOf(value) {
|
|
31
32
|
if (value === undefined) {
|
|
@@ -33,13 +34,4 @@ function contentOf(value) {
|
|
|
33
34
|
}
|
|
34
35
|
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
35
36
|
}
|
|
36
|
-
function message(toolCallId, content, error) {
|
|
37
|
-
return {
|
|
38
|
-
id: `tool-${toolCallId}`,
|
|
39
|
-
role: 'tool',
|
|
40
|
-
toolCallId,
|
|
41
|
-
content,
|
|
42
|
-
...(error !== undefined && { error }),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
37
|
//# sourceMappingURL=tool-results.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-results.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-results.ts"],"names":[],"mappings":"AAGA,MAAM,GAAG,GAAG,kBAAkB,CAAC;AAE/B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CACvB,UAAkB,EAClB,OAAuB;IAEvB,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"tool-results.js","sourceRoot":"","sources":["../../../../../../libs/integrations/ag-ui/src/lib/tool-results.ts"],"names":[],"mappings":"AAGA,MAAM,GAAG,GAAG,kBAAkB,CAAC;AAE/B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CACvB,UAAkB,EAClB,OAAuB;IAEvB,IAAI,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,YAAY,CACjB,UAAU,EACV,+BAA+B,OAAO,CAAC,OAAO,EAAE,CACjD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,UAAkB,EAAE,MAAc;IAC3D,OAAO,YAAY,CAAC,UAAU,EAAE,4BAA4B,MAAM,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,UAA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