@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/index.js CHANGED
@@ -647,9 +647,14 @@ var ExecutionOperations = class {
647
647
  this.tokenRegistry = new ProvenanceTokenRegistry();
648
648
  }
649
649
  /**
650
- * Executes code on the server with real-time progress updates via SSE.
650
+ * Executes code on the server with real-time streaming events via SSE.
651
+ *
652
+ * @param code - TypeScript code to execute
653
+ * @param config - Optional execution configuration
654
+ * @param onEvent - Callback for all streaming events (thinking, tool_start, tool_end, text, source, etc.)
655
+ * @param onProgress - Legacy callback for progress events only (deprecated, use onEvent instead)
651
656
  */
652
- async executeStream(code, config, onProgress) {
657
+ async executeStream(code, config, onEvent, onProgress) {
653
658
  await this.session.ensureInitialized();
654
659
  const url = `${this.session.getBaseUrl()}/api/execute/stream`;
655
660
  const body = JSON.stringify({
@@ -685,7 +690,7 @@ var ExecutionOperations = class {
685
690
  for (let i = 0; i < lines.length; i++) {
686
691
  const line = lines[i];
687
692
  if (line && line.startsWith("event:")) {
688
- const event = line.substring(6).trim();
693
+ const eventType = line.substring(6).trim();
689
694
  for (let j = i + 1; j < lines.length; j++) {
690
695
  const dataLine = lines[j];
691
696
  if (dataLine && dataLine.startsWith("data:")) {
@@ -693,11 +698,19 @@ var ExecutionOperations = class {
693
698
  if (dataStr) {
694
699
  try {
695
700
  const data = JSON.parse(dataStr);
696
- if (event === "progress" && onProgress) {
701
+ if (onEvent) {
702
+ const event = {
703
+ type: eventType,
704
+ data,
705
+ timestamp: Date.now()
706
+ };
707
+ onEvent(event);
708
+ }
709
+ if (eventType === "progress" && onProgress) {
697
710
  onProgress(data.message, data.fraction);
698
- } else if (event === "result") {
711
+ } else if (eventType === "result") {
699
712
  result = data;
700
- } else if (event === "error") {
713
+ } else if (eventType === "error") {
701
714
  reject(new Error(data.message));
702
715
  return;
703
716
  }
@@ -1498,10 +1511,28 @@ var AgentToolProtocolClient = class {
1498
1511
  return await this.apiOps.exploreAPI(path);
1499
1512
  }
1500
1513
  /**
1501
- * Executes code on the server with real-time progress updates via SSE.
1514
+ * Executes code on the server with real-time streaming events via SSE.
1515
+ *
1516
+ * @param code - TypeScript code to execute
1517
+ * @param config - Optional execution configuration
1518
+ * @param onEvent - Callback for all streaming events (thinking, tool_start, tool_end, text, source, etc.)
1519
+ * @param onProgress - Legacy callback for progress events only (deprecated, use onEvent instead)
1520
+ *
1521
+ * @example
1522
+ * ```typescript
1523
+ * const result = await client.executeStream(
1524
+ * code,
1525
+ * {},
1526
+ * (event) => {
1527
+ * if (event.type === 'thinking') console.log('Thinking:', event.data.content);
1528
+ * if (event.type === 'text') console.log('Text:', event.data.text);
1529
+ * if (event.type === 'tool_start') console.log('Tool started:', event.data.toolName);
1530
+ * }
1531
+ * );
1532
+ * ```
1502
1533
  */
1503
- async executeStream(code, config, onProgress) {
1504
- return await this.execOps.executeStream(code, config, onProgress);
1534
+ async executeStream(code, config, onEvent, onProgress) {
1535
+ return await this.execOps.executeStream(code, config, onEvent, onProgress);
1505
1536
  }
1506
1537
  /**
1507
1538
  * Executes code on the server in a sandboxed environment.