@inkeep/agents-sdk 0.29.6 → 0.29.8

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.
Files changed (3) hide show
  1. package/dist/index.cjs +259 -296
  2. package/dist/index.js +259 -296
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -194,9 +194,218 @@ var ArtifactComponent = class {
194
194
  );
195
195
  }
196
196
  };
197
- var logger2 = agentsCore.getLogger("agentFullClient");
198
- async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agentData) {
197
+ var logger2 = agentsCore.getLogger("projectFullClient");
198
+ async function createFullProjectViaAPI(tenantId, apiUrl, projectData, apiKey) {
199
+ logger2.info(
200
+ {
201
+ tenantId,
202
+ projectId: projectData.id,
203
+ apiUrl
204
+ },
205
+ "Creating full project via API"
206
+ );
207
+ const url = `${apiUrl}/tenants/${tenantId}/project-full`;
208
+ const headers = {};
209
+ if (apiKey) {
210
+ headers.Authorization = `Bearer ${apiKey}`;
211
+ }
212
+ let response;
213
+ try {
214
+ response = await agentsCore.apiFetch(url, {
215
+ method: "POST",
216
+ headers,
217
+ body: JSON.stringify(projectData)
218
+ });
219
+ } catch (fetchError) {
220
+ logger2.error(
221
+ {
222
+ error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
223
+ url,
224
+ tenantId,
225
+ projectId: projectData.id
226
+ },
227
+ "Fetch request failed"
228
+ );
229
+ throw fetchError;
230
+ }
231
+ if (!response.ok) {
232
+ const errorText = await response.text();
233
+ const errorMessage = parseError(errorText) ?? `Failed to create project: ${response.status} ${response.statusText}`;
234
+ logger2.error(
235
+ {
236
+ status: response.status,
237
+ error: errorMessage
238
+ },
239
+ "Failed to create project via API"
240
+ );
241
+ throw new Error(errorMessage);
242
+ }
243
+ const result = await response.json();
244
+ logger2.info(
245
+ {
246
+ projectId: projectData.id
247
+ },
248
+ "Successfully created project via API"
249
+ );
250
+ return result.data;
251
+ }
252
+ async function updateFullProjectViaAPI(tenantId, apiUrl, projectId, projectData, apiKey) {
199
253
  logger2.info(
254
+ {
255
+ tenantId,
256
+ projectId,
257
+ apiUrl
258
+ },
259
+ "Updating full project via API"
260
+ );
261
+ const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
262
+ const headers = {};
263
+ if (apiKey) {
264
+ headers.Authorization = `Bearer ${apiKey}`;
265
+ }
266
+ let response;
267
+ try {
268
+ response = await agentsCore.apiFetch(url, {
269
+ method: "PUT",
270
+ headers,
271
+ body: JSON.stringify(projectData)
272
+ });
273
+ } catch (fetchError) {
274
+ logger2.error(
275
+ {
276
+ error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
277
+ url,
278
+ tenantId,
279
+ projectId
280
+ },
281
+ "Fetch request failed"
282
+ );
283
+ throw fetchError;
284
+ }
285
+ if (!response.ok) {
286
+ const errorText = await response.text();
287
+ const errorMessage = parseError(errorText) ?? `Failed to update project: ${response.status} ${response.statusText}`;
288
+ logger2.error(
289
+ {
290
+ status: response.status,
291
+ error: errorMessage
292
+ },
293
+ "Failed to update project via API"
294
+ );
295
+ throw new Error(errorMessage);
296
+ }
297
+ const result = await response.json();
298
+ logger2.info(
299
+ {
300
+ projectId
301
+ },
302
+ "Successfully updated project via API"
303
+ );
304
+ return result.data;
305
+ }
306
+ async function getFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
307
+ logger2.info(
308
+ {
309
+ tenantId,
310
+ projectId,
311
+ apiUrl
312
+ },
313
+ "Getting full project via API"
314
+ );
315
+ const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
316
+ const headers = {};
317
+ if (apiKey) {
318
+ headers.Authorization = `Bearer ${apiKey}`;
319
+ }
320
+ const response = await agentsCore.apiFetch(url, {
321
+ method: "GET",
322
+ headers
323
+ });
324
+ if (!response.ok) {
325
+ if (response.status === 404) {
326
+ logger2.info(
327
+ {
328
+ projectId
329
+ },
330
+ "Project not found"
331
+ );
332
+ return null;
333
+ }
334
+ const errorText = await response.text();
335
+ const errorMessage = parseError(errorText) ?? `Failed to get project: ${response.status} ${response.statusText}`;
336
+ logger2.error(
337
+ {
338
+ status: response.status,
339
+ error: errorMessage
340
+ },
341
+ "Failed to get project via API"
342
+ );
343
+ throw new Error(errorMessage);
344
+ }
345
+ const result = await response.json();
346
+ logger2.info(
347
+ {
348
+ projectId
349
+ },
350
+ "Successfully retrieved project via API"
351
+ );
352
+ return result.data;
353
+ }
354
+ async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
355
+ logger2.info(
356
+ {
357
+ tenantId,
358
+ projectId,
359
+ apiUrl
360
+ },
361
+ "Deleting full project via API"
362
+ );
363
+ const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
364
+ const headers = {};
365
+ if (apiKey) {
366
+ headers.Authorization = `Bearer ${apiKey}`;
367
+ }
368
+ const response = await agentsCore.apiFetch(url, {
369
+ method: "DELETE",
370
+ headers
371
+ });
372
+ if (!response.ok) {
373
+ const errorText = await response.text();
374
+ const errorMessage = parseError(errorText) ?? `Failed to delete project: ${response.status} ${response.statusText}`;
375
+ logger2.error(
376
+ {
377
+ status: response.status,
378
+ error: errorMessage
379
+ },
380
+ "Failed to delete project via API"
381
+ );
382
+ throw new Error(errorMessage);
383
+ }
384
+ logger2.info(
385
+ {
386
+ projectId
387
+ },
388
+ "Successfully deleted project via API"
389
+ );
390
+ }
391
+ function parseError(errorText) {
392
+ try {
393
+ const errorJson = JSON.parse(errorText);
394
+ if (errorJson.error) {
395
+ const { error } = errorJson;
396
+ return error?.message ?? error;
397
+ }
398
+ } catch {
399
+ if (errorText) {
400
+ return errorText;
401
+ }
402
+ }
403
+ }
404
+
405
+ // src/agentFullClient.ts
406
+ var logger3 = agentsCore.getLogger("agentFullClient");
407
+ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agentData) {
408
+ logger3.info(
200
409
  {
201
410
  tenantId,
202
411
  projectId,
@@ -215,18 +424,8 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
215
424
  });
216
425
  if (!response.ok) {
217
426
  const errorText = await response.text();
218
- let errorMessage = `Failed to update agent: ${response.status} ${response.statusText}`;
219
- try {
220
- const errorJson = JSON.parse(errorText);
221
- if (errorJson.error) {
222
- errorMessage = errorJson.error;
223
- }
224
- } catch {
225
- if (errorText) {
226
- errorMessage = errorText;
227
- }
228
- }
229
- logger2.error(
427
+ const errorMessage = parseError(errorText) ?? `Failed to update agent: ${response.status} ${response.statusText}`;
428
+ logger3.error(
230
429
  {
231
430
  status: response.status,
232
431
  error: errorMessage
@@ -236,7 +435,7 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
236
435
  throw new Error(errorMessage);
237
436
  }
238
437
  const result = await response.json();
239
- logger2.info(
438
+ logger3.info(
240
439
  {
241
440
  agentId
242
441
  },
@@ -244,11 +443,11 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
244
443
  );
245
444
  return result.data;
246
445
  }
247
- var logger3 = agentsCore.getLogger("function-tool");
446
+ var logger4 = agentsCore.getLogger("function-tool");
248
447
  var getFunctionToolDeps = (name, code) => {
249
448
  const { dependencies, warnings } = buildToolManifestFromCodeTS(code);
250
449
  if (warnings.length > 0) {
251
- logger3.warn({ warnings }, `FunctionTool dependencies warnings for ${name}`);
450
+ logger4.warn({ warnings }, `FunctionTool dependencies warnings for ${name}`);
252
451
  }
253
452
  return dependencies;
254
453
  };
@@ -391,7 +590,7 @@ function buildToolManifestFromCodeTS(code, projectRoot = process.cwd()) {
391
590
  }
392
591
 
393
592
  // src/function-tool.ts
394
- var logger4 = agentsCore.getLogger("function-tool");
593
+ var logger5 = agentsCore.getLogger("function-tool");
395
594
  var FunctionTool = class {
396
595
  constructor(config) {
397
596
  __publicField(this, "config");
@@ -411,7 +610,7 @@ var FunctionTool = class {
411
610
  }
412
611
  this.config.dependencies = deps;
413
612
  }
414
- logger4.info(
613
+ logger5.info(
415
614
  {
416
615
  id: this.id,
417
616
  name: config.name
@@ -465,7 +664,7 @@ var FunctionTool = class {
465
664
  };
466
665
 
467
666
  // src/agent.ts
468
- var logger5 = agentsCore.getLogger("agent");
667
+ var logger6 = agentsCore.getLogger("agent");
469
668
  function resolveGetter(value) {
470
669
  if (typeof value === "function") {
471
670
  return value();
@@ -525,7 +724,7 @@ var Agent = class {
525
724
  if (this.models) {
526
725
  this.propagateImmediateModelSettings();
527
726
  }
528
- logger5.info(
727
+ logger6.info(
529
728
  {
530
729
  agentId: this.agentId,
531
730
  tenantId: this.tenantId,
@@ -562,7 +761,7 @@ var Agent = class {
562
761
  if (this.contextConfig?.setContext) {
563
762
  this.contextConfig.setContext(tenantId, projectId, this.agentId, this.baseURL);
564
763
  }
565
- logger5.info(
764
+ logger6.info(
566
765
  {
567
766
  agentId: this.agentId,
568
767
  tenantId: this.tenantId,
@@ -721,7 +920,7 @@ var Agent = class {
721
920
  * Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
722
921
  */
723
922
  async initializeAllTools() {
724
- logger5.info({ agentId: this.agentId }, "Initializing all tools in agent");
923
+ logger6.info({ agentId: this.agentId }, "Initializing all tools in agent");
725
924
  const toolInitPromises = [];
726
925
  for (const subAgent2 of this.subAgents) {
727
926
  const agentTools = subAgent2.getTools();
@@ -741,7 +940,7 @@ var Agent = class {
741
940
  await toolInstance.init();
742
941
  }
743
942
  }
744
- logger5.debug(
943
+ logger6.debug(
745
944
  {
746
945
  subAgentId: subAgent2.getId(),
747
946
  toolName,
@@ -751,7 +950,7 @@ var Agent = class {
751
950
  "Tool initialized successfully"
752
951
  );
753
952
  } catch (error) {
754
- logger5.error(
953
+ logger6.error(
755
954
  {
756
955
  subAgentId: subAgent2.getId(),
757
956
  toolName,
@@ -768,7 +967,7 @@ var Agent = class {
768
967
  }
769
968
  }
770
969
  await Promise.all(toolInitPromises);
771
- logger5.info(
970
+ logger6.info(
772
971
  { agentId: this.agentId, toolCount: toolInitPromises.length },
773
972
  "All tools initialized successfully"
774
973
  );
@@ -778,10 +977,10 @@ var Agent = class {
778
977
  */
779
978
  async init() {
780
979
  if (this.initialized) {
781
- logger5.info({ agentId: this.agentId }, "Agent already initialized");
980
+ logger6.info({ agentId: this.agentId }, "Agent already initialized");
782
981
  return;
783
982
  }
784
- logger5.info(
983
+ logger6.info(
785
984
  {
786
985
  agentId: this.agentId,
787
986
  agentCount: this.subAgents.length
@@ -792,7 +991,7 @@ var Agent = class {
792
991
  await this.initializeAllTools();
793
992
  await this.applyModelInheritance();
794
993
  const agentDefinition = await this.toFullAgentDefinition();
795
- logger5.info(
994
+ logger6.info(
796
995
  {
797
996
  agentId: this.agentId,
798
997
  mode: "api-client",
@@ -807,7 +1006,7 @@ var Agent = class {
807
1006
  this.agentId,
808
1007
  agentDefinition
809
1008
  );
810
- logger5.info(
1009
+ logger6.info(
811
1010
  {
812
1011
  agentId: this.agentId,
813
1012
  agentCount: Object.keys(createdAgent.subAgents || {}).length
@@ -816,7 +1015,7 @@ var Agent = class {
816
1015
  );
817
1016
  this.initialized = true;
818
1017
  } catch (error) {
819
- logger5.error(
1018
+ logger6.error(
820
1019
  {
821
1020
  agentId: this.agentId,
822
1021
  error: error instanceof Error ? error.message : "Unknown error"
@@ -834,7 +1033,7 @@ var Agent = class {
834
1033
  if (!this.defaultSubAgent) {
835
1034
  throw new Error("No default agent configured for this agent");
836
1035
  }
837
- logger5.info(
1036
+ logger6.info(
838
1037
  {
839
1038
  agentId: this.agentId,
840
1039
  defaultSubAgent: this.defaultSubAgent.getName(),
@@ -853,7 +1052,7 @@ var Agent = class {
853
1052
  if (!this.defaultSubAgent) {
854
1053
  throw new Error("No default agent configured for this agent");
855
1054
  }
856
- logger5.info(
1055
+ logger6.info(
857
1056
  {
858
1057
  agentId: this.agentId,
859
1058
  defaultSubAgent: this.defaultSubAgent.getName(),
@@ -887,7 +1086,7 @@ var Agent = class {
887
1086
  if (!agent2) {
888
1087
  throw new Error(`Agent '${subAgentId}' not found in agent`);
889
1088
  }
890
- logger5.info(
1089
+ logger6.info(
891
1090
  {
892
1091
  agentId: this.agentId,
893
1092
  subAgentId,
@@ -922,7 +1121,7 @@ var Agent = class {
922
1121
  if (this.models) {
923
1122
  this.propagateModelSettingsToAgent(agent2);
924
1123
  }
925
- logger5.info(
1124
+ logger6.info(
926
1125
  {
927
1126
  agentId: this.agentId,
928
1127
  subAgentId: agent2.getId()
@@ -938,7 +1137,7 @@ var Agent = class {
938
1137
  if (agentToRemove) {
939
1138
  this.agentMap.delete(agentToRemove.getId());
940
1139
  this.subAgents = this.subAgents.filter((agent2) => agent2.getId() !== agentToRemove.getId());
941
- logger5.info(
1140
+ logger6.info(
942
1141
  {
943
1142
  agentId: this.agentId,
944
1143
  subAgentId: agentToRemove.getId()
@@ -967,7 +1166,7 @@ var Agent = class {
967
1166
  setDefaultSubAgent(agent2) {
968
1167
  this.defaultSubAgent = agent2;
969
1168
  this.addSubAgent(agent2);
970
- logger5.info(
1169
+ logger6.info(
971
1170
  {
972
1171
  agentId: this.agentId,
973
1172
  defaultSubAgent: agent2.getId()
@@ -1116,7 +1315,7 @@ var Agent = class {
1116
1315
  });
1117
1316
  return project2?.models;
1118
1317
  } catch (error) {
1119
- logger5.warn(
1318
+ logger6.warn(
1120
1319
  {
1121
1320
  tenantId: this.tenantId,
1122
1321
  projectId: this.projectId,
@@ -1137,7 +1336,7 @@ var Agent = class {
1137
1336
  });
1138
1337
  return project2?.stopWhen;
1139
1338
  } catch (error) {
1140
- logger5.warn(
1339
+ logger6.warn(
1141
1340
  {
1142
1341
  tenantId: this.tenantId,
1143
1342
  projectId: this.projectId,
@@ -1196,7 +1395,7 @@ var Agent = class {
1196
1395
  }
1197
1396
  }
1198
1397
  }
1199
- logger5.debug(
1398
+ logger6.debug(
1200
1399
  {
1201
1400
  agentId: this.agentId,
1202
1401
  agentStopWhen: this.stopWhen,
@@ -1238,7 +1437,7 @@ var Agent = class {
1238
1437
  async executeWithBackend(input, options) {
1239
1438
  const normalizedMessages = this.normalizeMessages(input);
1240
1439
  const url = `${this.baseURL}/tenants/${this.tenantId}/agent/${this.agentId}/v1/chat/completions`;
1241
- logger5.info({ url }, "Executing with backend");
1440
+ logger6.info({ url }, "Executing with backend");
1242
1441
  const requestBody = {
1243
1442
  model: "gpt-4o-mini",
1244
1443
  messages: normalizedMessages.map((msg) => ({
@@ -1322,7 +1521,7 @@ var Agent = class {
1322
1521
  }
1323
1522
  });
1324
1523
  if (getResponse.ok) {
1325
- logger5.info({ agentId: this.agentId }, "Agent already exists in backend");
1524
+ logger6.info({ agentId: this.agentId }, "Agent already exists in backend");
1326
1525
  return;
1327
1526
  }
1328
1527
  if (getResponse.status !== 404) {
@@ -1333,7 +1532,7 @@ var Agent = class {
1333
1532
  throw error;
1334
1533
  }
1335
1534
  }
1336
- logger5.info({ agentId: this.agentId }, "Creating agent in backend");
1535
+ logger6.info({ agentId: this.agentId }, "Creating agent in backend");
1337
1536
  const createUrl = `${this.baseURL}/tenants/${this.tenantId}/agents`;
1338
1537
  const createResponse = await fetch(createUrl, {
1339
1538
  method: "POST",
@@ -1353,7 +1552,7 @@ var Agent = class {
1353
1552
  }
1354
1553
  const createData = await createResponse.json();
1355
1554
  this.agentId = createData.data.id;
1356
- logger5.info({ agent: createData.data }, "Agent created in backend");
1555
+ logger6.info({ agent: createData.data }, "Agent created in backend");
1357
1556
  } catch (error) {
1358
1557
  throw new Error(
1359
1558
  `Failed to save agent to database: ${error instanceof Error ? error.message : "Unknown error"}`
@@ -1378,7 +1577,7 @@ var Agent = class {
1378
1577
  if (!updateResponse.ok) {
1379
1578
  throw new Error(`HTTP ${updateResponse.status}: ${updateResponse.statusText}`);
1380
1579
  }
1381
- logger5.debug(
1580
+ logger6.debug(
1382
1581
  {
1383
1582
  agentId: this.agentId,
1384
1583
  defaultSubAgent: this.defaultSubAgent.getName()
@@ -1386,7 +1585,7 @@ var Agent = class {
1386
1585
  "Agent relationships configured"
1387
1586
  );
1388
1587
  } catch (error) {
1389
- logger5.error(
1588
+ logger6.error(
1390
1589
  {
1391
1590
  agentId: this.agentId,
1392
1591
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1423,7 +1622,7 @@ var Agent = class {
1423
1622
  successCount++;
1424
1623
  } else {
1425
1624
  errors.push(result.reason);
1426
- logger5.error(
1625
+ logger6.error(
1427
1626
  {
1428
1627
  error: result.reason instanceof Error ? result.reason.message : "Unknown error",
1429
1628
  agentId: this.agentId
@@ -1432,7 +1631,7 @@ var Agent = class {
1432
1631
  );
1433
1632
  }
1434
1633
  }
1435
- logger5.info(
1634
+ logger6.info(
1436
1635
  {
1437
1636
  agentId: this.agentId,
1438
1637
  totalRelations: allSubAgentRelationPromises.length,
@@ -1462,7 +1661,7 @@ var Agent = class {
1462
1661
  if (!response.ok) {
1463
1662
  const errorText = await response.text().catch(() => "Unknown error");
1464
1663
  if (response.status === 422 && errorText.includes("already exists")) {
1465
- logger5.info(
1664
+ logger6.info(
1466
1665
  {
1467
1666
  sourceSubAgentId: sourceAgent.getId(),
1468
1667
  targetSubAgentId: targetAgent.getId(),
@@ -1475,7 +1674,7 @@ var Agent = class {
1475
1674
  }
1476
1675
  throw new Error(`Failed to create subAgent relation: ${response.status} - ${errorText}`);
1477
1676
  }
1478
- logger5.info(
1677
+ logger6.info(
1479
1678
  {
1480
1679
  sourceSubAgentId: sourceAgent.getId(),
1481
1680
  targetSubAgentId: targetAgent.getId(),
@@ -1485,7 +1684,7 @@ var Agent = class {
1485
1684
  `${relationType} subAgent relation created successfully`
1486
1685
  );
1487
1686
  } catch (error) {
1488
- logger5.error(
1687
+ logger6.error(
1489
1688
  {
1490
1689
  sourceSubAgentId: sourceAgent.getId(),
1491
1690
  targetSubAgentId: targetAgent.getId(),
@@ -1499,7 +1698,7 @@ var Agent = class {
1499
1698
  }
1500
1699
  }
1501
1700
  };
1502
- var logger6 = agentsCore.getLogger("dataComponent");
1701
+ var logger7 = agentsCore.getLogger("dataComponent");
1503
1702
  var DataComponent = class {
1504
1703
  constructor(config) {
1505
1704
  __publicField(this, "config");
@@ -1524,7 +1723,7 @@ var DataComponent = class {
1524
1723
  this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
1525
1724
  this.tenantId = "default";
1526
1725
  this.projectId = "default";
1527
- logger6.info(
1726
+ logger7.info(
1528
1727
  {
1529
1728
  dataComponentId: this.getId(),
1530
1729
  dataComponentName: config.name
@@ -1561,7 +1760,7 @@ var DataComponent = class {
1561
1760
  if (this.initialized) return;
1562
1761
  try {
1563
1762
  await this.upsertDataComponent();
1564
- logger6.info(
1763
+ logger7.info(
1565
1764
  {
1566
1765
  dataComponentId: this.getId()
1567
1766
  },
@@ -1569,7 +1768,7 @@ var DataComponent = class {
1569
1768
  );
1570
1769
  this.initialized = true;
1571
1770
  } catch (error) {
1572
- logger6.error(
1771
+ logger7.error(
1573
1772
  {
1574
1773
  dataComponentId: this.getId(),
1575
1774
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1588,7 +1787,7 @@ var DataComponent = class {
1588
1787
  props: this.config.props,
1589
1788
  render: this.config.render
1590
1789
  };
1591
- logger6.info({ dataComponentData }, "dataComponentData for create/update");
1790
+ logger7.info({ dataComponentData }, "dataComponentData for create/update");
1592
1791
  const updateResponse = await fetch(
1593
1792
  `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/data-components/${this.getId()}`,
1594
1793
  {
@@ -1599,7 +1798,7 @@ var DataComponent = class {
1599
1798
  body: JSON.stringify(dataComponentData)
1600
1799
  }
1601
1800
  );
1602
- logger6.info(
1801
+ logger7.info(
1603
1802
  {
1604
1803
  status: updateResponse.status,
1605
1804
  dataComponentId: this.getId()
@@ -1607,7 +1806,7 @@ var DataComponent = class {
1607
1806
  "data component updateResponse"
1608
1807
  );
1609
1808
  if (updateResponse.ok) {
1610
- logger6.info(
1809
+ logger7.info(
1611
1810
  {
1612
1811
  dataComponentId: this.getId()
1613
1812
  },
@@ -1616,7 +1815,7 @@ var DataComponent = class {
1616
1815
  return;
1617
1816
  }
1618
1817
  if (updateResponse.status === 404) {
1619
- logger6.info(
1818
+ logger7.info(
1620
1819
  {
1621
1820
  dataComponentId: this.getId()
1622
1821
  },
@@ -1638,7 +1837,7 @@ var DataComponent = class {
1638
1837
  `Failed to create data component: ${createResponse.status} ${createResponse.statusText} - ${errorText2}`
1639
1838
  );
1640
1839
  }
1641
- logger6.info(
1840
+ logger7.info(
1642
1841
  {
1643
1842
  dataComponentId: this.getId()
1644
1843
  },
@@ -1652,242 +1851,6 @@ var DataComponent = class {
1652
1851
  );
1653
1852
  }
1654
1853
  };
1655
- var logger7 = agentsCore.getLogger("projectFullClient");
1656
- async function createFullProjectViaAPI(tenantId, apiUrl, projectData, apiKey) {
1657
- logger7.info(
1658
- {
1659
- tenantId,
1660
- projectId: projectData.id,
1661
- apiUrl
1662
- },
1663
- "Creating full project via API"
1664
- );
1665
- const url = `${apiUrl}/tenants/${tenantId}/project-full`;
1666
- const headers = {};
1667
- if (apiKey) {
1668
- headers.Authorization = `Bearer ${apiKey}`;
1669
- }
1670
- let response;
1671
- try {
1672
- response = await agentsCore.apiFetch(url, {
1673
- method: "POST",
1674
- headers,
1675
- body: JSON.stringify(projectData)
1676
- });
1677
- } catch (fetchError) {
1678
- logger7.error(
1679
- {
1680
- error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
1681
- url,
1682
- tenantId,
1683
- projectId: projectData.id
1684
- },
1685
- "Fetch request failed"
1686
- );
1687
- throw fetchError;
1688
- }
1689
- if (!response.ok) {
1690
- const errorText = await response.text();
1691
- let errorMessage = `Failed to create project: ${response.status} ${response.statusText}`;
1692
- try {
1693
- const errorJson = JSON.parse(errorText);
1694
- if (errorJson.error) {
1695
- errorMessage = errorJson.error;
1696
- }
1697
- } catch {
1698
- if (errorText) {
1699
- errorMessage = errorText;
1700
- }
1701
- }
1702
- logger7.error(
1703
- {
1704
- status: response.status,
1705
- error: errorMessage
1706
- },
1707
- "Failed to create project via API"
1708
- );
1709
- throw new Error(errorMessage);
1710
- }
1711
- const result = await response.json();
1712
- logger7.info(
1713
- {
1714
- projectId: projectData.id
1715
- },
1716
- "Successfully created project via API"
1717
- );
1718
- return result.data;
1719
- }
1720
- async function updateFullProjectViaAPI(tenantId, apiUrl, projectId, projectData, apiKey) {
1721
- logger7.info(
1722
- {
1723
- tenantId,
1724
- projectId,
1725
- apiUrl
1726
- },
1727
- "Updating full project via API"
1728
- );
1729
- const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
1730
- const headers = {};
1731
- if (apiKey) {
1732
- headers.Authorization = `Bearer ${apiKey}`;
1733
- }
1734
- let response;
1735
- try {
1736
- response = await agentsCore.apiFetch(url, {
1737
- method: "PUT",
1738
- headers,
1739
- body: JSON.stringify(projectData)
1740
- });
1741
- } catch (fetchError) {
1742
- logger7.error(
1743
- {
1744
- error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
1745
- url,
1746
- tenantId,
1747
- projectId
1748
- },
1749
- "Fetch request failed"
1750
- );
1751
- throw fetchError;
1752
- }
1753
- if (!response.ok) {
1754
- const errorText = await response.text();
1755
- let errorMessage = `Failed to update project: ${response.status} ${response.statusText}`;
1756
- try {
1757
- const errorJson = JSON.parse(errorText);
1758
- if (errorJson.error) {
1759
- errorMessage = errorJson.error;
1760
- }
1761
- } catch {
1762
- if (errorText) {
1763
- errorMessage = errorText;
1764
- }
1765
- }
1766
- logger7.error(
1767
- {
1768
- status: response.status,
1769
- error: errorMessage
1770
- },
1771
- "Failed to update project via API"
1772
- );
1773
- throw new Error(errorMessage);
1774
- }
1775
- const result = await response.json();
1776
- logger7.info(
1777
- {
1778
- projectId
1779
- },
1780
- "Successfully updated project via API"
1781
- );
1782
- return result.data;
1783
- }
1784
- async function getFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
1785
- logger7.info(
1786
- {
1787
- tenantId,
1788
- projectId,
1789
- apiUrl
1790
- },
1791
- "Getting full project via API"
1792
- );
1793
- const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
1794
- const headers = {};
1795
- if (apiKey) {
1796
- headers.Authorization = `Bearer ${apiKey}`;
1797
- }
1798
- const response = await agentsCore.apiFetch(url, {
1799
- method: "GET",
1800
- headers
1801
- });
1802
- if (!response.ok) {
1803
- if (response.status === 404) {
1804
- logger7.info(
1805
- {
1806
- projectId
1807
- },
1808
- "Project not found"
1809
- );
1810
- return null;
1811
- }
1812
- const errorText = await response.text();
1813
- let errorMessage = `Failed to get project: ${response.status} ${response.statusText}`;
1814
- try {
1815
- const errorJson = JSON.parse(errorText);
1816
- if (errorJson.error) {
1817
- errorMessage = errorJson.error;
1818
- }
1819
- } catch {
1820
- if (errorText) {
1821
- errorMessage = errorText;
1822
- }
1823
- }
1824
- logger7.error(
1825
- {
1826
- status: response.status,
1827
- error: errorMessage
1828
- },
1829
- "Failed to get project via API"
1830
- );
1831
- throw new Error(errorMessage);
1832
- }
1833
- const result = await response.json();
1834
- logger7.info(
1835
- {
1836
- projectId
1837
- },
1838
- "Successfully retrieved project via API"
1839
- );
1840
- return result.data;
1841
- }
1842
- async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
1843
- logger7.info(
1844
- {
1845
- tenantId,
1846
- projectId,
1847
- apiUrl
1848
- },
1849
- "Deleting full project via API"
1850
- );
1851
- const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
1852
- const headers = {};
1853
- if (apiKey) {
1854
- headers.Authorization = `Bearer ${apiKey}`;
1855
- }
1856
- const response = await agentsCore.apiFetch(url, {
1857
- method: "DELETE",
1858
- headers
1859
- });
1860
- if (!response.ok) {
1861
- const errorText = await response.text();
1862
- let errorMessage = `Failed to delete project: ${response.status} ${response.statusText}`;
1863
- try {
1864
- const errorJson = JSON.parse(errorText);
1865
- if (errorJson.error) {
1866
- errorMessage = errorJson.error;
1867
- }
1868
- } catch {
1869
- if (errorText) {
1870
- errorMessage = errorText;
1871
- }
1872
- }
1873
- logger7.error(
1874
- {
1875
- status: response.status,
1876
- error: errorMessage
1877
- },
1878
- "Failed to delete project via API"
1879
- );
1880
- throw new Error(errorMessage);
1881
- }
1882
- logger7.info(
1883
- {
1884
- projectId
1885
- },
1886
- "Successfully deleted project via API"
1887
- );
1888
- }
1889
-
1890
- // src/project.ts
1891
1854
  var logger8 = agentsCore.getLogger("project");
1892
1855
  var Project = class {
1893
1856
  constructor(config) {