@mondaydotcomorg/atp-client 0.19.14 → 0.19.15
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/client.d.ts +21 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +21 -3
- package/dist/client.js.map +1 -1
- package/dist/core/execution-operations.d.ts +8 -3
- package/dist/core/execution-operations.d.ts.map +1 -1
- package/dist/core/execution-operations.js +19 -6
- package/dist/core/execution-operations.js.map +1 -1
- package/dist/core/index.cjs +19 -6
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +19 -6
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +40 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +22 -2
- package/src/core/execution-operations.ts +21 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/atp-client",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.15",
|
|
4
4
|
"description": "Client SDK for Agent Tool Protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"license": "MIT",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@mondaydotcomorg/atp-protocol": "0.19.
|
|
52
|
-
"@mondaydotcomorg/atp-runtime": "0.19.
|
|
51
|
+
"@mondaydotcomorg/atp-protocol": "0.19.15",
|
|
52
|
+
"@mondaydotcomorg/atp-runtime": "0.19.14",
|
|
53
53
|
"undici": "*",
|
|
54
54
|
"zod-to-json-schema": "^3.24.6"
|
|
55
55
|
},
|
package/src/client.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ClientTool,
|
|
7
7
|
ClientToolDefinition,
|
|
8
8
|
ExploreResult,
|
|
9
|
+
ATPEvent,
|
|
9
10
|
} from '@mondaydotcomorg/atp-protocol';
|
|
10
11
|
import type { RuntimeAPIName } from '@mondaydotcomorg/atp-runtime';
|
|
11
12
|
import { CallbackType } from '@mondaydotcomorg/atp-protocol';
|
|
@@ -250,14 +251,33 @@ export class AgentToolProtocolClient {
|
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
/**
|
|
253
|
-
* Executes code on the server with real-time
|
|
254
|
+
* Executes code on the server with real-time streaming events via SSE.
|
|
255
|
+
*
|
|
256
|
+
* @param code - TypeScript code to execute
|
|
257
|
+
* @param config - Optional execution configuration
|
|
258
|
+
* @param onEvent - Callback for all streaming events (thinking, tool_start, tool_end, text, source, etc.)
|
|
259
|
+
* @param onProgress - Legacy callback for progress events only (deprecated, use onEvent instead)
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const result = await client.executeStream(
|
|
264
|
+
* code,
|
|
265
|
+
* {},
|
|
266
|
+
* (event) => {
|
|
267
|
+
* if (event.type === 'thinking') console.log('Thinking:', event.data.content);
|
|
268
|
+
* if (event.type === 'text') console.log('Text:', event.data.text);
|
|
269
|
+
* if (event.type === 'tool_start') console.log('Tool started:', event.data.toolName);
|
|
270
|
+
* }
|
|
271
|
+
* );
|
|
272
|
+
* ```
|
|
254
273
|
*/
|
|
255
274
|
async executeStream(
|
|
256
275
|
code: string,
|
|
257
276
|
config?: Partial<ExecutionConfig>,
|
|
277
|
+
onEvent?: (event: ATPEvent) => void,
|
|
258
278
|
onProgress?: (message: string, fraction: number) => void
|
|
259
279
|
): Promise<ExecutionResult> {
|
|
260
|
-
return await this.execOps.executeStream(code, config, onProgress);
|
|
280
|
+
return await this.execOps.executeStream(code, config, onEvent, onProgress);
|
|
261
281
|
}
|
|
262
282
|
|
|
263
283
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecutionResult, ExecutionConfig } from '@mondaydotcomorg/atp-protocol';
|
|
1
|
+
import type { ExecutionResult, ExecutionConfig, ATPEvent } from '@mondaydotcomorg/atp-protocol';
|
|
2
2
|
import { ExecutionStatus, CallbackType } from '@mondaydotcomorg/atp-protocol';
|
|
3
3
|
import { log } from '@mondaydotcomorg/atp-runtime';
|
|
4
4
|
import type { ISession } from './session.js';
|
|
@@ -26,11 +26,17 @@ export class ExecutionOperations {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Executes code on the server with real-time
|
|
29
|
+
* Executes code on the server with real-time streaming events via SSE.
|
|
30
|
+
*
|
|
31
|
+
* @param code - TypeScript code to execute
|
|
32
|
+
* @param config - Optional execution configuration
|
|
33
|
+
* @param onEvent - Callback for all streaming events (thinking, tool_start, tool_end, text, source, etc.)
|
|
34
|
+
* @param onProgress - Legacy callback for progress events only (deprecated, use onEvent instead)
|
|
30
35
|
*/
|
|
31
36
|
async executeStream(
|
|
32
37
|
code: string,
|
|
33
38
|
config?: Partial<ExecutionConfig>,
|
|
39
|
+
onEvent?: (event: ATPEvent) => void,
|
|
34
40
|
onProgress?: (message: string, fraction: number) => void
|
|
35
41
|
): Promise<ExecutionResult> {
|
|
36
42
|
await this.session.ensureInitialized();
|
|
@@ -74,7 +80,7 @@ export class ExecutionOperations {
|
|
|
74
80
|
const line = lines[i];
|
|
75
81
|
|
|
76
82
|
if (line && line.startsWith('event:')) {
|
|
77
|
-
const
|
|
83
|
+
const eventType = line.substring(6).trim();
|
|
78
84
|
|
|
79
85
|
for (let j = i + 1; j < lines.length; j++) {
|
|
80
86
|
const dataLine = lines[j];
|
|
@@ -84,11 +90,20 @@ export class ExecutionOperations {
|
|
|
84
90
|
try {
|
|
85
91
|
const data = JSON.parse(dataStr);
|
|
86
92
|
|
|
87
|
-
if (
|
|
93
|
+
if (onEvent) {
|
|
94
|
+
const event: ATPEvent = {
|
|
95
|
+
type: eventType,
|
|
96
|
+
data,
|
|
97
|
+
timestamp: Date.now(),
|
|
98
|
+
};
|
|
99
|
+
onEvent(event);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (eventType === 'progress' && onProgress) {
|
|
88
103
|
onProgress(data.message, data.fraction);
|
|
89
|
-
} else if (
|
|
104
|
+
} else if (eventType === 'result') {
|
|
90
105
|
result = data as ExecutionResult;
|
|
91
|
-
} else if (
|
|
106
|
+
} else if (eventType === 'error') {
|
|
92
107
|
reject(new Error(data.message));
|
|
93
108
|
return;
|
|
94
109
|
}
|