@ideascol/agents-generator-sdk 0.3.4 → 0.4.0

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/README.md CHANGED
@@ -4,6 +4,8 @@ agents-generator-sdk
4
4
 
5
5
  ## Usage as library
6
6
 
7
+ ### Basic Usage - Get Agents
8
+
7
9
  ```ts
8
10
  import { useEffect, useState } from 'react';
9
11
  import {
@@ -39,6 +41,100 @@ export function Agents() {
39
41
  }
40
42
  ```
41
43
 
44
+ ### Send Message with Transfer Detection (Synchronous)
45
+
46
+ The `sendMessage` method now uses streaming internally to detect agent transfers (handoffs). It returns a promise with the complete response including any transfers that occurred.
47
+
48
+ ```ts
49
+ import { AgentClient, SendMessageResponse } from '@ideascol/agents-generator-sdk';
50
+
51
+ const client = new AgentClient({
52
+ apiUrl: 'https://api.agentsgenerator.dev',
53
+ apiToken: 'YOUR_API_TOKEN',
54
+ });
55
+
56
+ // Send a message and get the complete response with transfers
57
+ const response: SendMessageResponse = await client.sendMessage(
58
+ 'conversation-id',
59
+ { content: 'Hello, I need help with billing' }
60
+ );
61
+
62
+ console.log('Message:', response.message);
63
+ console.log('Message ID:', response.message_id);
64
+
65
+ // Check if there were any transfers
66
+ if (response.transfers && response.transfers.length > 0) {
67
+ console.log('Transfers detected:');
68
+ response.transfers.forEach(transfer => {
69
+ console.log(` From: ${transfer.from_agent}`);
70
+ console.log(` To: ${transfer.to_agent}`);
71
+ console.log(` Reason: ${transfer.reason}`);
72
+ });
73
+ }
74
+ ```
75
+
76
+ ### Send Message with Streaming (Real-time updates)
77
+
78
+ For real-time updates and custom handling of events, use `sendMessageWithStreaming`:
79
+
80
+ ```ts
81
+ import { AgentClient, TransferEvent } from '@ideascol/agents-generator-sdk';
82
+
83
+ const client = new AgentClient({
84
+ apiUrl: 'https://api.agentsgenerator.dev',
85
+ apiToken: 'YOUR_API_TOKEN',
86
+ });
87
+
88
+ const abort = client.sendMessageWithStreaming(
89
+ 'conversation-id',
90
+ { content: 'Hello!' },
91
+ {
92
+ onMessage: (content: string) => {
93
+ console.log('Message update:', content);
94
+ },
95
+ onDone: (messageId: string) => {
96
+ console.log('Message completed:', messageId);
97
+ },
98
+ onTransfer: (transfer: TransferEvent) => {
99
+ console.log('Transfer detected!');
100
+ console.log(` From: ${transfer.from_agent}`);
101
+ console.log(` To: ${transfer.to_agent}`);
102
+ console.log(` Reason: ${transfer.reason}`);
103
+ },
104
+ onError: (error: Error) => {
105
+ console.error('Error:', error);
106
+ }
107
+ }
108
+ );
109
+
110
+ // To abort the stream:
111
+ // abort();
112
+ ```
113
+
114
+ ### TypeScript Types
115
+
116
+ ```ts
117
+ interface SendMessageResponse {
118
+ status: string;
119
+ message: string;
120
+ message_id?: string;
121
+ transfers?: TransferEvent[];
122
+ }
123
+
124
+ interface TransferEvent {
125
+ from_agent?: string;
126
+ to_agent?: string;
127
+ reason?: string;
128
+ }
129
+
130
+ interface StreamCallbacks {
131
+ onMessage?: (content: string) => void;
132
+ onDone?: (messageId: string) => void;
133
+ onError?: (error: Error) => void;
134
+ onTransfer?: (transfer: TransferEvent) => void;
135
+ }
136
+ ```
137
+
42
138
  ## Quick start
43
139
  ```bash
44
140
  # Using npm
package/dist/bin/cli.js CHANGED
@@ -609,6 +609,15 @@ var init_OpenAPI = __esm(() => {
609
609
  };
610
610
  });
611
611
 
612
+ // src/lib/clients/agents-generator/models/CollaboratorRole.ts
613
+ var CollaboratorRole;
614
+ var init_CollaboratorRole = __esm(() => {
615
+ ((CollaboratorRole2) => {
616
+ CollaboratorRole2["DEV"] = "dev";
617
+ CollaboratorRole2["ADMIN"] = "admin";
618
+ })(CollaboratorRole ||= {});
619
+ });
620
+
612
621
  // src/lib/clients/agents-generator/core/request.ts
613
622
  var isDefined = (value) => {
614
623
  return value !== undefined && value !== null;
@@ -1446,6 +1455,79 @@ class AdminWorkspacesService {
1446
1455
  }
1447
1456
  });
1448
1457
  }
1458
+ static addWorkspaceCollaborator(workspaceId, requestBody) {
1459
+ return request(OpenAPI, {
1460
+ method: "POST",
1461
+ url: "/workspaces/{workspace_id}/collaborators",
1462
+ path: {
1463
+ workspace_id: workspaceId
1464
+ },
1465
+ body: requestBody,
1466
+ mediaType: "application/json",
1467
+ errors: {
1468
+ 422: `Validation Error`
1469
+ }
1470
+ });
1471
+ }
1472
+ static getWorkspaceCollaborators(workspaceId) {
1473
+ return request(OpenAPI, {
1474
+ method: "GET",
1475
+ url: "/workspaces/{workspace_id}/collaborators",
1476
+ path: {
1477
+ workspace_id: workspaceId
1478
+ },
1479
+ errors: {
1480
+ 422: `Validation Error`
1481
+ }
1482
+ });
1483
+ }
1484
+ static getWorkspaceCollaborator(workspaceId, collaboratorId) {
1485
+ return request(OpenAPI, {
1486
+ method: "GET",
1487
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1488
+ path: {
1489
+ workspace_id: workspaceId,
1490
+ collaborator_id: collaboratorId
1491
+ },
1492
+ errors: {
1493
+ 422: `Validation Error`
1494
+ }
1495
+ });
1496
+ }
1497
+ static updateWorkspaceCollaborator(workspaceId, collaboratorId, requestBody) {
1498
+ return request(OpenAPI, {
1499
+ method: "PUT",
1500
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1501
+ path: {
1502
+ workspace_id: workspaceId,
1503
+ collaborator_id: collaboratorId
1504
+ },
1505
+ body: requestBody,
1506
+ mediaType: "application/json",
1507
+ errors: {
1508
+ 422: `Validation Error`
1509
+ }
1510
+ });
1511
+ }
1512
+ static deleteWorkspaceCollaborator(workspaceId, collaboratorId) {
1513
+ return request(OpenAPI, {
1514
+ method: "DELETE",
1515
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1516
+ path: {
1517
+ workspace_id: workspaceId,
1518
+ collaborator_id: collaboratorId
1519
+ },
1520
+ errors: {
1521
+ 422: `Validation Error`
1522
+ }
1523
+ });
1524
+ }
1525
+ static getMyCollaborativeWorkspaces() {
1526
+ return request(OpenAPI, {
1527
+ method: "GET",
1528
+ url: "/workspaces/{workspace_id}/collaborators/me/workspaces"
1529
+ });
1530
+ }
1449
1531
  }
1450
1532
  var init_AdminWorkspacesService = __esm(() => {
1451
1533
  init_OpenAPI();
@@ -2133,6 +2215,87 @@ var init_RootService = __esm(() => {
2133
2215
  init_request();
2134
2216
  });
2135
2217
 
2218
+ // src/lib/clients/agents-generator/services/WorkspaceCollaboratorsService.ts
2219
+ class WorkspaceCollaboratorsService {
2220
+ static addWorkspaceCollaborator(workspaceId, requestBody) {
2221
+ return request(OpenAPI, {
2222
+ method: "POST",
2223
+ url: "/workspaces/{workspace_id}/collaborators",
2224
+ path: {
2225
+ workspace_id: workspaceId
2226
+ },
2227
+ body: requestBody,
2228
+ mediaType: "application/json",
2229
+ errors: {
2230
+ 422: `Validation Error`
2231
+ }
2232
+ });
2233
+ }
2234
+ static getWorkspaceCollaborators(workspaceId) {
2235
+ return request(OpenAPI, {
2236
+ method: "GET",
2237
+ url: "/workspaces/{workspace_id}/collaborators",
2238
+ path: {
2239
+ workspace_id: workspaceId
2240
+ },
2241
+ errors: {
2242
+ 422: `Validation Error`
2243
+ }
2244
+ });
2245
+ }
2246
+ static getWorkspaceCollaborator(workspaceId, collaboratorId) {
2247
+ return request(OpenAPI, {
2248
+ method: "GET",
2249
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
2250
+ path: {
2251
+ workspace_id: workspaceId,
2252
+ collaborator_id: collaboratorId
2253
+ },
2254
+ errors: {
2255
+ 422: `Validation Error`
2256
+ }
2257
+ });
2258
+ }
2259
+ static updateWorkspaceCollaborator(workspaceId, collaboratorId, requestBody) {
2260
+ return request(OpenAPI, {
2261
+ method: "PUT",
2262
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
2263
+ path: {
2264
+ workspace_id: workspaceId,
2265
+ collaborator_id: collaboratorId
2266
+ },
2267
+ body: requestBody,
2268
+ mediaType: "application/json",
2269
+ errors: {
2270
+ 422: `Validation Error`
2271
+ }
2272
+ });
2273
+ }
2274
+ static deleteWorkspaceCollaborator(workspaceId, collaboratorId) {
2275
+ return request(OpenAPI, {
2276
+ method: "DELETE",
2277
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
2278
+ path: {
2279
+ workspace_id: workspaceId,
2280
+ collaborator_id: collaboratorId
2281
+ },
2282
+ errors: {
2283
+ 422: `Validation Error`
2284
+ }
2285
+ });
2286
+ }
2287
+ static getMyCollaborativeWorkspaces() {
2288
+ return request(OpenAPI, {
2289
+ method: "GET",
2290
+ url: "/workspaces/{workspace_id}/collaborators/me/workspaces"
2291
+ });
2292
+ }
2293
+ }
2294
+ var init_WorkspaceCollaboratorsService = __esm(() => {
2295
+ init_OpenAPI();
2296
+ init_request();
2297
+ });
2298
+
2136
2299
  // src/lib/clients/agents-generator/services/WorkspacesService.ts
2137
2300
  class WorkspacesService {
2138
2301
  static createWorkspace(requestBody) {
@@ -2214,6 +2377,7 @@ var init_agents_generator = __esm(() => {
2214
2377
  init_ApiError();
2215
2378
  init_CancelablePromise();
2216
2379
  init_OpenAPI();
2380
+ init_CollaboratorRole();
2217
2381
  init_AdminAgentsService();
2218
2382
  init_AdminConversationsService();
2219
2383
  init_AdminCredentialsService();
@@ -2228,6 +2392,7 @@ var init_agents_generator = __esm(() => {
2228
2392
  init_PublicAgentsService();
2229
2393
  init_PublicConversationsService();
2230
2394
  init_RootService();
2395
+ init_WorkspaceCollaboratorsService();
2231
2396
  init_WorkspacesService();
2232
2397
  });
2233
2398
 
@@ -2268,7 +2433,8 @@ class AgentClient {
2268
2433
  credentials: AdminCredentialsService,
2269
2434
  fileLibrary: AdminFileLibraryService,
2270
2435
  mcpServers: AdminMcpServersService,
2271
- workspaces: AdminWorkspacesService
2436
+ workspaces: AdminWorkspacesService,
2437
+ collaborators: WorkspaceCollaboratorsService
2272
2438
  };
2273
2439
  this.public = {
2274
2440
  agents: PublicAgentsService,
@@ -2283,7 +2449,7 @@ class AgentClient {
2283
2449
  return ConversationsServiceStream.addMessageConversationsConversationIdMessagesPostStream(conversationId, requestBody, callbacks);
2284
2450
  }
2285
2451
  sendMessage(conversationId, requestBody) {
2286
- return ConversationsServiceStream.addMessage(conversationId, requestBody, "text/plain");
2452
+ return PublicConversationsServiceExtended.sendMessage(conversationId, requestBody);
2287
2453
  }
2288
2454
  }
2289
2455
  var ConversationsServiceStream, PublicConversationsServiceExtended, lib_default;
@@ -2414,6 +2580,8 @@ var init_lib = __esm(() => {
2414
2580
  callbacks.onMessage(fullMessage);
2415
2581
  } else if (data.type === "done" && data.message_id && callbacks.onDone) {
2416
2582
  callbacks.onDone(data.message_id);
2583
+ } else if (data.type === "transfer" && data.transfer && callbacks.onTransfer) {
2584
+ callbacks.onTransfer(data.transfer);
2417
2585
  }
2418
2586
  } catch (e) {
2419
2587
  console.error("Error al parsear JSON del evento:", e);
@@ -2471,7 +2639,46 @@ var init_lib = __esm(() => {
2471
2639
  return ConversationsServiceStream.addMessageConversationsConversationIdMessagesPostStream(conversationId, requestBody, callbacks);
2472
2640
  }
2473
2641
  static sendMessage(conversationId, requestBody) {
2474
- return ConversationsServiceStream.addMessage(conversationId, requestBody);
2642
+ return new Promise((resolve2, reject) => {
2643
+ let fullMessage = "";
2644
+ let messageId = "";
2645
+ const transfers = [];
2646
+ let streamCompleted = false;
2647
+ let timeoutId;
2648
+ const abort = ConversationsServiceStream.addMessageConversationsConversationIdMessagesPostStream(conversationId, requestBody, {
2649
+ onMessage: (content) => {
2650
+ fullMessage = content;
2651
+ },
2652
+ onDone: (id) => {
2653
+ messageId = id;
2654
+ streamCompleted = true;
2655
+ if (timeoutId) {
2656
+ clearTimeout(timeoutId);
2657
+ }
2658
+ resolve2({
2659
+ status: "success",
2660
+ message: fullMessage,
2661
+ message_id: messageId || undefined,
2662
+ transfers: transfers.length > 0 ? transfers : undefined
2663
+ });
2664
+ },
2665
+ onTransfer: (transfer) => {
2666
+ transfers.push(transfer);
2667
+ },
2668
+ onError: (error) => {
2669
+ if (timeoutId) {
2670
+ clearTimeout(timeoutId);
2671
+ }
2672
+ reject(error);
2673
+ }
2674
+ });
2675
+ timeoutId = setTimeout(() => {
2676
+ if (!streamCompleted) {
2677
+ abort();
2678
+ reject(new Error("Message send timeout after 60 seconds"));
2679
+ }
2680
+ }, 60000);
2681
+ });
2475
2682
  }
2476
2683
  };
2477
2684
  lib_default = AgentClient;
package/dist/index.js CHANGED
@@ -177,6 +177,15 @@ var init_OpenAPI = __esm(() => {
177
177
  };
178
178
  });
179
179
 
180
+ // src/lib/clients/agents-generator/models/CollaboratorRole.ts
181
+ var CollaboratorRole;
182
+ var init_CollaboratorRole = __esm(() => {
183
+ ((CollaboratorRole2) => {
184
+ CollaboratorRole2["DEV"] = "dev";
185
+ CollaboratorRole2["ADMIN"] = "admin";
186
+ })(CollaboratorRole ||= {});
187
+ });
188
+
180
189
  // src/lib/clients/agents-generator/core/request.ts
181
190
  var isDefined = (value) => {
182
191
  return value !== undefined && value !== null;
@@ -1014,6 +1023,79 @@ class AdminWorkspacesService {
1014
1023
  }
1015
1024
  });
1016
1025
  }
1026
+ static addWorkspaceCollaborator(workspaceId, requestBody) {
1027
+ return request(OpenAPI, {
1028
+ method: "POST",
1029
+ url: "/workspaces/{workspace_id}/collaborators",
1030
+ path: {
1031
+ workspace_id: workspaceId
1032
+ },
1033
+ body: requestBody,
1034
+ mediaType: "application/json",
1035
+ errors: {
1036
+ 422: `Validation Error`
1037
+ }
1038
+ });
1039
+ }
1040
+ static getWorkspaceCollaborators(workspaceId) {
1041
+ return request(OpenAPI, {
1042
+ method: "GET",
1043
+ url: "/workspaces/{workspace_id}/collaborators",
1044
+ path: {
1045
+ workspace_id: workspaceId
1046
+ },
1047
+ errors: {
1048
+ 422: `Validation Error`
1049
+ }
1050
+ });
1051
+ }
1052
+ static getWorkspaceCollaborator(workspaceId, collaboratorId) {
1053
+ return request(OpenAPI, {
1054
+ method: "GET",
1055
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1056
+ path: {
1057
+ workspace_id: workspaceId,
1058
+ collaborator_id: collaboratorId
1059
+ },
1060
+ errors: {
1061
+ 422: `Validation Error`
1062
+ }
1063
+ });
1064
+ }
1065
+ static updateWorkspaceCollaborator(workspaceId, collaboratorId, requestBody) {
1066
+ return request(OpenAPI, {
1067
+ method: "PUT",
1068
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1069
+ path: {
1070
+ workspace_id: workspaceId,
1071
+ collaborator_id: collaboratorId
1072
+ },
1073
+ body: requestBody,
1074
+ mediaType: "application/json",
1075
+ errors: {
1076
+ 422: `Validation Error`
1077
+ }
1078
+ });
1079
+ }
1080
+ static deleteWorkspaceCollaborator(workspaceId, collaboratorId) {
1081
+ return request(OpenAPI, {
1082
+ method: "DELETE",
1083
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1084
+ path: {
1085
+ workspace_id: workspaceId,
1086
+ collaborator_id: collaboratorId
1087
+ },
1088
+ errors: {
1089
+ 422: `Validation Error`
1090
+ }
1091
+ });
1092
+ }
1093
+ static getMyCollaborativeWorkspaces() {
1094
+ return request(OpenAPI, {
1095
+ method: "GET",
1096
+ url: "/workspaces/{workspace_id}/collaborators/me/workspaces"
1097
+ });
1098
+ }
1017
1099
  }
1018
1100
  var init_AdminWorkspacesService = __esm(() => {
1019
1101
  init_OpenAPI();
@@ -1701,6 +1783,87 @@ var init_RootService = __esm(() => {
1701
1783
  init_request();
1702
1784
  });
1703
1785
 
1786
+ // src/lib/clients/agents-generator/services/WorkspaceCollaboratorsService.ts
1787
+ class WorkspaceCollaboratorsService {
1788
+ static addWorkspaceCollaborator(workspaceId, requestBody) {
1789
+ return request(OpenAPI, {
1790
+ method: "POST",
1791
+ url: "/workspaces/{workspace_id}/collaborators",
1792
+ path: {
1793
+ workspace_id: workspaceId
1794
+ },
1795
+ body: requestBody,
1796
+ mediaType: "application/json",
1797
+ errors: {
1798
+ 422: `Validation Error`
1799
+ }
1800
+ });
1801
+ }
1802
+ static getWorkspaceCollaborators(workspaceId) {
1803
+ return request(OpenAPI, {
1804
+ method: "GET",
1805
+ url: "/workspaces/{workspace_id}/collaborators",
1806
+ path: {
1807
+ workspace_id: workspaceId
1808
+ },
1809
+ errors: {
1810
+ 422: `Validation Error`
1811
+ }
1812
+ });
1813
+ }
1814
+ static getWorkspaceCollaborator(workspaceId, collaboratorId) {
1815
+ return request(OpenAPI, {
1816
+ method: "GET",
1817
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1818
+ path: {
1819
+ workspace_id: workspaceId,
1820
+ collaborator_id: collaboratorId
1821
+ },
1822
+ errors: {
1823
+ 422: `Validation Error`
1824
+ }
1825
+ });
1826
+ }
1827
+ static updateWorkspaceCollaborator(workspaceId, collaboratorId, requestBody) {
1828
+ return request(OpenAPI, {
1829
+ method: "PUT",
1830
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1831
+ path: {
1832
+ workspace_id: workspaceId,
1833
+ collaborator_id: collaboratorId
1834
+ },
1835
+ body: requestBody,
1836
+ mediaType: "application/json",
1837
+ errors: {
1838
+ 422: `Validation Error`
1839
+ }
1840
+ });
1841
+ }
1842
+ static deleteWorkspaceCollaborator(workspaceId, collaboratorId) {
1843
+ return request(OpenAPI, {
1844
+ method: "DELETE",
1845
+ url: "/workspaces/{workspace_id}/collaborators/{collaborator_id}",
1846
+ path: {
1847
+ workspace_id: workspaceId,
1848
+ collaborator_id: collaboratorId
1849
+ },
1850
+ errors: {
1851
+ 422: `Validation Error`
1852
+ }
1853
+ });
1854
+ }
1855
+ static getMyCollaborativeWorkspaces() {
1856
+ return request(OpenAPI, {
1857
+ method: "GET",
1858
+ url: "/workspaces/{workspace_id}/collaborators/me/workspaces"
1859
+ });
1860
+ }
1861
+ }
1862
+ var init_WorkspaceCollaboratorsService = __esm(() => {
1863
+ init_OpenAPI();
1864
+ init_request();
1865
+ });
1866
+
1704
1867
  // src/lib/clients/agents-generator/services/WorkspacesService.ts
1705
1868
  class WorkspacesService {
1706
1869
  static createWorkspace(requestBody) {
@@ -1782,6 +1945,7 @@ var init_agents_generator = __esm(() => {
1782
1945
  init_ApiError();
1783
1946
  init_CancelablePromise();
1784
1947
  init_OpenAPI();
1948
+ init_CollaboratorRole();
1785
1949
  init_AdminAgentsService();
1786
1950
  init_AdminConversationsService();
1787
1951
  init_AdminCredentialsService();
@@ -1796,6 +1960,7 @@ var init_agents_generator = __esm(() => {
1796
1960
  init_PublicAgentsService();
1797
1961
  init_PublicConversationsService();
1798
1962
  init_RootService();
1963
+ init_WorkspaceCollaboratorsService();
1799
1964
  init_WorkspacesService();
1800
1965
  });
1801
1966
 
@@ -1836,7 +2001,8 @@ class AgentClient {
1836
2001
  credentials: AdminCredentialsService,
1837
2002
  fileLibrary: AdminFileLibraryService,
1838
2003
  mcpServers: AdminMcpServersService,
1839
- workspaces: AdminWorkspacesService
2004
+ workspaces: AdminWorkspacesService,
2005
+ collaborators: WorkspaceCollaboratorsService
1840
2006
  };
1841
2007
  this.public = {
1842
2008
  agents: PublicAgentsService,
@@ -1851,7 +2017,7 @@ class AgentClient {
1851
2017
  return ConversationsServiceStream.addMessageConversationsConversationIdMessagesPostStream(conversationId, requestBody, callbacks);
1852
2018
  }
1853
2019
  sendMessage(conversationId, requestBody) {
1854
- return ConversationsServiceStream.addMessage(conversationId, requestBody, "text/plain");
2020
+ return PublicConversationsServiceExtended.sendMessage(conversationId, requestBody);
1855
2021
  }
1856
2022
  }
1857
2023
  var ConversationsServiceStream, PublicConversationsServiceExtended, lib_default;
@@ -1982,6 +2148,8 @@ var init_lib = __esm(() => {
1982
2148
  callbacks.onMessage(fullMessage);
1983
2149
  } else if (data.type === "done" && data.message_id && callbacks.onDone) {
1984
2150
  callbacks.onDone(data.message_id);
2151
+ } else if (data.type === "transfer" && data.transfer && callbacks.onTransfer) {
2152
+ callbacks.onTransfer(data.transfer);
1985
2153
  }
1986
2154
  } catch (e) {
1987
2155
  console.error("Error al parsear JSON del evento:", e);
@@ -2039,7 +2207,46 @@ var init_lib = __esm(() => {
2039
2207
  return ConversationsServiceStream.addMessageConversationsConversationIdMessagesPostStream(conversationId, requestBody, callbacks);
2040
2208
  }
2041
2209
  static sendMessage(conversationId, requestBody) {
2042
- return ConversationsServiceStream.addMessage(conversationId, requestBody);
2210
+ return new Promise((resolve2, reject) => {
2211
+ let fullMessage = "";
2212
+ let messageId = "";
2213
+ const transfers = [];
2214
+ let streamCompleted = false;
2215
+ let timeoutId;
2216
+ const abort = ConversationsServiceStream.addMessageConversationsConversationIdMessagesPostStream(conversationId, requestBody, {
2217
+ onMessage: (content) => {
2218
+ fullMessage = content;
2219
+ },
2220
+ onDone: (id) => {
2221
+ messageId = id;
2222
+ streamCompleted = true;
2223
+ if (timeoutId) {
2224
+ clearTimeout(timeoutId);
2225
+ }
2226
+ resolve2({
2227
+ status: "success",
2228
+ message: fullMessage,
2229
+ message_id: messageId || undefined,
2230
+ transfers: transfers.length > 0 ? transfers : undefined
2231
+ });
2232
+ },
2233
+ onTransfer: (transfer) => {
2234
+ transfers.push(transfer);
2235
+ },
2236
+ onError: (error) => {
2237
+ if (timeoutId) {
2238
+ clearTimeout(timeoutId);
2239
+ }
2240
+ reject(error);
2241
+ }
2242
+ });
2243
+ timeoutId = setTimeout(() => {
2244
+ if (!streamCompleted) {
2245
+ abort();
2246
+ reject(new Error("Message send timeout after 60 seconds"));
2247
+ }
2248
+ }, 60000);
2249
+ });
2043
2250
  }
2044
2251
  };
2045
2252
  lib_default = AgentClient;
@@ -2049,6 +2256,7 @@ var init_lib = __esm(() => {
2049
2256
  var exports_src = {};
2050
2257
  __export(exports_src, {
2051
2258
  WorkspacesService: () => WorkspacesService,
2259
+ WorkspaceCollaboratorsService: () => WorkspaceCollaboratorsService,
2052
2260
  RootService: () => RootService,
2053
2261
  PublicConversationsService: () => PublicConversationsService,
2054
2262
  PublicAgentsService: () => PublicAgentsService,
@@ -2057,6 +2265,7 @@ __export(exports_src, {
2057
2265
  FileLibraryService: () => FileLibraryService,
2058
2266
  CredentialsService: () => CredentialsService,
2059
2267
  ConversationsService: () => ConversationsService,
2268
+ CollaboratorRole: () => CollaboratorRole,
2060
2269
  CancelablePromise: () => CancelablePromise,
2061
2270
  CancelError: () => CancelError,
2062
2271
  ApiError: () => ApiError,
@@ -11,6 +11,7 @@ export type { Body_upload_file } from './models/Body_upload_file';
11
11
  export type { BucketCreate } from './models/BucketCreate';
12
12
  export type { BucketResponse } from './models/BucketResponse';
13
13
  export type { CallbackTool } from './models/CallbackTool';
14
+ export { CollaboratorRole } from './models/CollaboratorRole';
14
15
  export type { ConversationCreate } from './models/ConversationCreate';
15
16
  export type { ConversationResponse } from './models/ConversationResponse';
16
17
  export type { ConversationUpdate } from './models/ConversationUpdate';
@@ -41,6 +42,9 @@ export type { NodeData } from './models/NodeData';
41
42
  export type { Position } from './models/Position';
42
43
  export type { UpdateMCPServerRequest } from './models/UpdateMCPServerRequest';
43
44
  export type { ValidationError } from './models/ValidationError';
45
+ export type { WorkspaceCollaboratorCreate } from './models/WorkspaceCollaboratorCreate';
46
+ export type { WorkspaceCollaboratorResponse } from './models/WorkspaceCollaboratorResponse';
47
+ export type { WorkspaceCollaboratorUpdate } from './models/WorkspaceCollaboratorUpdate';
44
48
  export type { WorkspaceCreate } from './models/WorkspaceCreate';
45
49
  export type { WorkspaceResponse } from './models/WorkspaceResponse';
46
50
  export type { WorkspaceUpdate } from './models/WorkspaceUpdate';
@@ -59,4 +63,5 @@ export { McpServersService } from './services/McpServersService';
59
63
  export { PublicAgentsService } from './services/PublicAgentsService';
60
64
  export { PublicConversationsService } from './services/PublicConversationsService';
61
65
  export { RootService } from './services/RootService';
66
+ export { WorkspaceCollaboratorsService } from './services/WorkspaceCollaboratorsService';
62
67
  export { WorkspacesService } from './services/WorkspacesService';
@@ -0,0 +1,4 @@
1
+ export declare enum CollaboratorRole {
2
+ DEV = "dev",
3
+ ADMIN = "admin"
4
+ }
@@ -0,0 +1,6 @@
1
+ import type { CollaboratorRole } from './CollaboratorRole';
2
+ export type WorkspaceCollaboratorCreate = {
3
+ user_id: string;
4
+ role: CollaboratorRole;
5
+ workspace_id: string;
6
+ };
@@ -0,0 +1,10 @@
1
+ import type { CollaboratorRole } from './CollaboratorRole';
2
+ export type WorkspaceCollaboratorResponse = {
3
+ user_id: string;
4
+ role: CollaboratorRole;
5
+ id: string;
6
+ workspace_id: string;
7
+ invited_by: string;
8
+ created_at: string;
9
+ updated_at: string;
10
+ };
@@ -0,0 +1,4 @@
1
+ import type { CollaboratorRole } from './CollaboratorRole';
2
+ export type WorkspaceCollaboratorUpdate = {
3
+ role?: (CollaboratorRole | null);
4
+ };
@@ -5,4 +5,5 @@ export type WorkspaceResponse = {
5
5
  user_id: string;
6
6
  created_at: string;
7
7
  updated_at: string;
8
+ user_role?: (string | null);
8
9
  };
@@ -5,6 +5,7 @@ export type WorkspaceWithStats = {
5
5
  user_id: string;
6
6
  created_at: string;
7
7
  updated_at: string;
8
+ user_role?: (string | null);
8
9
  agents_count?: number;
9
10
  conversations_count?: number;
10
11
  credentials_count?: number;
@@ -1,3 +1,6 @@
1
+ import type { WorkspaceCollaboratorCreate } from '../models/WorkspaceCollaboratorCreate';
2
+ import type { WorkspaceCollaboratorResponse } from '../models/WorkspaceCollaboratorResponse';
3
+ import type { WorkspaceCollaboratorUpdate } from '../models/WorkspaceCollaboratorUpdate';
1
4
  import type { WorkspaceCreate } from '../models/WorkspaceCreate';
2
5
  import type { WorkspaceResponse } from '../models/WorkspaceResponse';
3
6
  import type { WorkspaceUpdate } from '../models/WorkspaceUpdate';
@@ -14,7 +17,7 @@ export declare class AdminWorkspacesService {
14
17
  static createWorkspace(requestBody: WorkspaceCreate): CancelablePromise<WorkspaceResponse>;
15
18
  /**
16
19
  * Get Workspaces
17
- * Get all workspaces for the current user
20
+ * Get all workspaces for the current user (owned + collaborator)
18
21
  * @param skip
19
22
  * @param limit
20
23
  * @returns WorkspaceResponse Successful Response
@@ -53,4 +56,60 @@ export declare class AdminWorkspacesService {
53
56
  * @throws ApiError
54
57
  */
55
58
  static deleteWorkspace(workspaceId: string): CancelablePromise<any>;
59
+ /**
60
+ * Add Collaborator
61
+ * Add a collaborator to a workspace.
62
+ * Only workspace owners can add collaborators.
63
+ * @param workspaceId
64
+ * @param requestBody
65
+ * @returns WorkspaceCollaboratorResponse Successful Response
66
+ * @throws ApiError
67
+ */
68
+ static addWorkspaceCollaborator(workspaceId: string, requestBody: WorkspaceCollaboratorCreate): CancelablePromise<WorkspaceCollaboratorResponse>;
69
+ /**
70
+ * Get Collaborators
71
+ * Get all collaborators for a workspace.
72
+ * Any user with access to the workspace can view collaborators.
73
+ * @param workspaceId
74
+ * @returns WorkspaceCollaboratorResponse Successful Response
75
+ * @throws ApiError
76
+ */
77
+ static getWorkspaceCollaborators(workspaceId: string): CancelablePromise<Array<WorkspaceCollaboratorResponse>>;
78
+ /**
79
+ * Get Collaborator
80
+ * Get a specific collaborator by ID
81
+ * @param workspaceId
82
+ * @param collaboratorId
83
+ * @returns WorkspaceCollaboratorResponse Successful Response
84
+ * @throws ApiError
85
+ */
86
+ static getWorkspaceCollaborator(workspaceId: string, collaboratorId: string): CancelablePromise<WorkspaceCollaboratorResponse>;
87
+ /**
88
+ * Update Collaborator
89
+ * Update a collaborator's role.
90
+ * Only workspace owners can update collaborators.
91
+ * @param workspaceId
92
+ * @param collaboratorId
93
+ * @param requestBody
94
+ * @returns WorkspaceCollaboratorResponse Successful Response
95
+ * @throws ApiError
96
+ */
97
+ static updateWorkspaceCollaborator(workspaceId: string, collaboratorId: string, requestBody: WorkspaceCollaboratorUpdate): CancelablePromise<WorkspaceCollaboratorResponse>;
98
+ /**
99
+ * Delete Collaborator
100
+ * Remove a collaborator from a workspace.
101
+ * Only workspace owners can remove collaborators.
102
+ * @param workspaceId
103
+ * @param collaboratorId
104
+ * @returns any Successful Response
105
+ * @throws ApiError
106
+ */
107
+ static deleteWorkspaceCollaborator(workspaceId: string, collaboratorId: string): CancelablePromise<any>;
108
+ /**
109
+ * Get My Collaborative Workspaces
110
+ * Get all workspaces where the current user is a collaborator.
111
+ * @returns any Successful Response
112
+ * @throws ApiError
113
+ */
114
+ static getMyCollaborativeWorkspaces(): CancelablePromise<Array<Record<string, any>>>;
56
115
  }
@@ -0,0 +1,62 @@
1
+ import type { WorkspaceCollaboratorCreate } from '../models/WorkspaceCollaboratorCreate';
2
+ import type { WorkspaceCollaboratorResponse } from '../models/WorkspaceCollaboratorResponse';
3
+ import type { WorkspaceCollaboratorUpdate } from '../models/WorkspaceCollaboratorUpdate';
4
+ import type { CancelablePromise } from '../core/CancelablePromise';
5
+ export declare class WorkspaceCollaboratorsService {
6
+ /**
7
+ * Add Collaborator
8
+ * Add a collaborator to a workspace.
9
+ * Only workspace owners can add collaborators.
10
+ * @param workspaceId
11
+ * @param requestBody
12
+ * @returns WorkspaceCollaboratorResponse Successful Response
13
+ * @throws ApiError
14
+ */
15
+ static addWorkspaceCollaborator(workspaceId: string, requestBody: WorkspaceCollaboratorCreate): CancelablePromise<WorkspaceCollaboratorResponse>;
16
+ /**
17
+ * Get Collaborators
18
+ * Get all collaborators for a workspace.
19
+ * Any user with access to the workspace can view collaborators.
20
+ * @param workspaceId
21
+ * @returns WorkspaceCollaboratorResponse Successful Response
22
+ * @throws ApiError
23
+ */
24
+ static getWorkspaceCollaborators(workspaceId: string): CancelablePromise<Array<WorkspaceCollaboratorResponse>>;
25
+ /**
26
+ * Get Collaborator
27
+ * Get a specific collaborator by ID
28
+ * @param workspaceId
29
+ * @param collaboratorId
30
+ * @returns WorkspaceCollaboratorResponse Successful Response
31
+ * @throws ApiError
32
+ */
33
+ static getWorkspaceCollaborator(workspaceId: string, collaboratorId: string): CancelablePromise<WorkspaceCollaboratorResponse>;
34
+ /**
35
+ * Update Collaborator
36
+ * Update a collaborator's role.
37
+ * Only workspace owners can update collaborators.
38
+ * @param workspaceId
39
+ * @param collaboratorId
40
+ * @param requestBody
41
+ * @returns WorkspaceCollaboratorResponse Successful Response
42
+ * @throws ApiError
43
+ */
44
+ static updateWorkspaceCollaborator(workspaceId: string, collaboratorId: string, requestBody: WorkspaceCollaboratorUpdate): CancelablePromise<WorkspaceCollaboratorResponse>;
45
+ /**
46
+ * Delete Collaborator
47
+ * Remove a collaborator from a workspace.
48
+ * Only workspace owners can remove collaborators.
49
+ * @param workspaceId
50
+ * @param collaboratorId
51
+ * @returns any Successful Response
52
+ * @throws ApiError
53
+ */
54
+ static deleteWorkspaceCollaborator(workspaceId: string, collaboratorId: string): CancelablePromise<any>;
55
+ /**
56
+ * Get My Collaborative Workspaces
57
+ * Get all workspaces where the current user is a collaborator.
58
+ * @returns any Successful Response
59
+ * @throws ApiError
60
+ */
61
+ static getMyCollaborativeWorkspaces(): CancelablePromise<Array<Record<string, any>>>;
62
+ }
@@ -14,7 +14,7 @@ export declare class WorkspacesService {
14
14
  static createWorkspace(requestBody: WorkspaceCreate): CancelablePromise<WorkspaceResponse>;
15
15
  /**
16
16
  * Get Workspaces
17
- * Get all workspaces for the current user
17
+ * Get all workspaces for the current user (owned + collaborator)
18
18
  * @param skip
19
19
  * @param limit
20
20
  * @returns WorkspaceResponse Successful Response
@@ -1,14 +1,27 @@
1
- import { ApiError, CancelablePromise, CancelError, ConversationsService, MessageCreate, OpenAPI, AgentService, McpServersService, RootService, FileLibraryService, CredentialsService, AdminAgentsService, PublicAgentsService, PublicConversationsService, AdminConversationsService, AdminCredentialsService, AdminFileLibraryService, AdminMcpServersService, AdminWorkspacesService } from "./clients/agents-generator";
1
+ import { ApiError, CancelablePromise, CancelError, ConversationsService, MessageCreate, OpenAPI, AgentService, McpServersService, RootService, FileLibraryService, CredentialsService, AdminAgentsService, PublicAgentsService, PublicConversationsService, AdminConversationsService, AdminCredentialsService, AdminFileLibraryService, AdminMcpServersService, AdminWorkspacesService, WorkspaceCollaboratorsService } from "./clients/agents-generator";
2
2
  export * from "./clients/agents-generator";
3
3
  export interface StreamEvent {
4
4
  type: string;
5
5
  content?: string;
6
6
  message_id?: string;
7
+ transfer?: TransferEvent;
8
+ }
9
+ export interface TransferEvent {
10
+ from_agent?: string;
11
+ to_agent?: string;
12
+ reason?: string;
7
13
  }
8
14
  export interface StreamCallbacks {
9
15
  onMessage?: (content: string) => void;
10
16
  onDone?: (messageId: string) => void;
11
17
  onError?: (error: Error) => void;
18
+ onTransfer?: (transfer: TransferEvent) => void;
19
+ }
20
+ export interface SendMessageResponse {
21
+ status: string;
22
+ message: string;
23
+ message_id?: string;
24
+ transfers?: TransferEvent[];
12
25
  }
13
26
  declare class ConversationsServiceStream extends ConversationsService {
14
27
  constructor();
@@ -23,11 +36,13 @@ declare class ConversationsServiceStream extends ConversationsService {
23
36
  }
24
37
  declare class PublicConversationsServiceExtended extends PublicConversationsService {
25
38
  static sendMessageWithStreaming(conversationId: string, requestBody: MessageCreate, callbacks: StreamCallbacks): () => void;
26
- static sendMessage(conversationId: string, requestBody: MessageCreate): CancelablePromise<{
27
- status: string;
28
- message: string;
29
- message_id?: string;
30
- }>;
39
+ /**
40
+ * Send a message synchronously using streaming internally to capture transfers
41
+ * @param conversationId The ID of the conversation
42
+ * @param requestBody The message data to send
43
+ * @returns Promise with the complete response including transfers
44
+ */
45
+ static sendMessage(conversationId: string, requestBody: MessageCreate): Promise<SendMessageResponse>;
31
46
  }
32
47
  export declare class AgentClient {
33
48
  admin: {
@@ -37,6 +52,7 @@ export declare class AgentClient {
37
52
  fileLibrary: typeof AdminFileLibraryService;
38
53
  mcpServers: typeof AdminMcpServersService;
39
54
  workspaces: typeof AdminWorkspacesService;
55
+ collaborators: typeof WorkspaceCollaboratorsService;
40
56
  };
41
57
  public: {
42
58
  agents: typeof PublicAgentsService;
@@ -82,14 +98,11 @@ export declare class AgentClient {
82
98
  */
83
99
  sendMessageWithStreaming(conversationId: string, requestBody: MessageCreate, callbacks: StreamCallbacks): () => void;
84
100
  /**
85
- * sendMessage: Sends a message to a conversation without streaming
86
- * @returns CancelablePromise with the response
101
+ * sendMessage: Sends a message to a conversation with transfer detection
102
+ * Uses streaming internally to capture transfer events
103
+ * @returns Promise with the complete response including transfers
87
104
  * Use client.public.conversations.sendMessage instead
88
105
  */
89
- sendMessage(conversationId: string, requestBody: MessageCreate): CancelablePromise<{
90
- status: string;
91
- message: string;
92
- message_id?: string;
93
- }>;
106
+ sendMessage(conversationId: string, requestBody: MessageCreate): Promise<SendMessageResponse>;
94
107
  }
95
108
  export default AgentClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ideascol/agents-generator-sdk",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "bun test",