@inkeep/agents-sdk 0.29.7 → 0.29.9
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.cjs +259 -296
- package/dist/index.js +259 -296
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -167,9 +167,218 @@ var ArtifactComponent = class {
|
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
-
var logger2 = getLogger("
|
|
171
|
-
async function
|
|
170
|
+
var logger2 = getLogger("projectFullClient");
|
|
171
|
+
async function createFullProjectViaAPI(tenantId, apiUrl, projectData, apiKey) {
|
|
172
|
+
logger2.info(
|
|
173
|
+
{
|
|
174
|
+
tenantId,
|
|
175
|
+
projectId: projectData.id,
|
|
176
|
+
apiUrl
|
|
177
|
+
},
|
|
178
|
+
"Creating full project via API"
|
|
179
|
+
);
|
|
180
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full`;
|
|
181
|
+
const headers = {};
|
|
182
|
+
if (apiKey) {
|
|
183
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
184
|
+
}
|
|
185
|
+
let response;
|
|
186
|
+
try {
|
|
187
|
+
response = await apiFetch(url, {
|
|
188
|
+
method: "POST",
|
|
189
|
+
headers,
|
|
190
|
+
body: JSON.stringify(projectData)
|
|
191
|
+
});
|
|
192
|
+
} catch (fetchError) {
|
|
193
|
+
logger2.error(
|
|
194
|
+
{
|
|
195
|
+
error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
|
|
196
|
+
url,
|
|
197
|
+
tenantId,
|
|
198
|
+
projectId: projectData.id
|
|
199
|
+
},
|
|
200
|
+
"Fetch request failed"
|
|
201
|
+
);
|
|
202
|
+
throw fetchError;
|
|
203
|
+
}
|
|
204
|
+
if (!response.ok) {
|
|
205
|
+
const errorText = await response.text();
|
|
206
|
+
const errorMessage = parseError(errorText) ?? `Failed to create project: ${response.status} ${response.statusText}`;
|
|
207
|
+
logger2.error(
|
|
208
|
+
{
|
|
209
|
+
status: response.status,
|
|
210
|
+
error: errorMessage
|
|
211
|
+
},
|
|
212
|
+
"Failed to create project via API"
|
|
213
|
+
);
|
|
214
|
+
throw new Error(errorMessage);
|
|
215
|
+
}
|
|
216
|
+
const result = await response.json();
|
|
217
|
+
logger2.info(
|
|
218
|
+
{
|
|
219
|
+
projectId: projectData.id
|
|
220
|
+
},
|
|
221
|
+
"Successfully created project via API"
|
|
222
|
+
);
|
|
223
|
+
return result.data;
|
|
224
|
+
}
|
|
225
|
+
async function updateFullProjectViaAPI(tenantId, apiUrl, projectId, projectData, apiKey) {
|
|
172
226
|
logger2.info(
|
|
227
|
+
{
|
|
228
|
+
tenantId,
|
|
229
|
+
projectId,
|
|
230
|
+
apiUrl
|
|
231
|
+
},
|
|
232
|
+
"Updating full project via API"
|
|
233
|
+
);
|
|
234
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
235
|
+
const headers = {};
|
|
236
|
+
if (apiKey) {
|
|
237
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
238
|
+
}
|
|
239
|
+
let response;
|
|
240
|
+
try {
|
|
241
|
+
response = await apiFetch(url, {
|
|
242
|
+
method: "PUT",
|
|
243
|
+
headers,
|
|
244
|
+
body: JSON.stringify(projectData)
|
|
245
|
+
});
|
|
246
|
+
} catch (fetchError) {
|
|
247
|
+
logger2.error(
|
|
248
|
+
{
|
|
249
|
+
error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
|
|
250
|
+
url,
|
|
251
|
+
tenantId,
|
|
252
|
+
projectId
|
|
253
|
+
},
|
|
254
|
+
"Fetch request failed"
|
|
255
|
+
);
|
|
256
|
+
throw fetchError;
|
|
257
|
+
}
|
|
258
|
+
if (!response.ok) {
|
|
259
|
+
const errorText = await response.text();
|
|
260
|
+
const errorMessage = parseError(errorText) ?? `Failed to update project: ${response.status} ${response.statusText}`;
|
|
261
|
+
logger2.error(
|
|
262
|
+
{
|
|
263
|
+
status: response.status,
|
|
264
|
+
error: errorMessage
|
|
265
|
+
},
|
|
266
|
+
"Failed to update project via API"
|
|
267
|
+
);
|
|
268
|
+
throw new Error(errorMessage);
|
|
269
|
+
}
|
|
270
|
+
const result = await response.json();
|
|
271
|
+
logger2.info(
|
|
272
|
+
{
|
|
273
|
+
projectId
|
|
274
|
+
},
|
|
275
|
+
"Successfully updated project via API"
|
|
276
|
+
);
|
|
277
|
+
return result.data;
|
|
278
|
+
}
|
|
279
|
+
async function getFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
|
|
280
|
+
logger2.info(
|
|
281
|
+
{
|
|
282
|
+
tenantId,
|
|
283
|
+
projectId,
|
|
284
|
+
apiUrl
|
|
285
|
+
},
|
|
286
|
+
"Getting full project via API"
|
|
287
|
+
);
|
|
288
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
289
|
+
const headers = {};
|
|
290
|
+
if (apiKey) {
|
|
291
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
292
|
+
}
|
|
293
|
+
const response = await apiFetch(url, {
|
|
294
|
+
method: "GET",
|
|
295
|
+
headers
|
|
296
|
+
});
|
|
297
|
+
if (!response.ok) {
|
|
298
|
+
if (response.status === 404) {
|
|
299
|
+
logger2.info(
|
|
300
|
+
{
|
|
301
|
+
projectId
|
|
302
|
+
},
|
|
303
|
+
"Project not found"
|
|
304
|
+
);
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
const errorText = await response.text();
|
|
308
|
+
const errorMessage = parseError(errorText) ?? `Failed to get project: ${response.status} ${response.statusText}`;
|
|
309
|
+
logger2.error(
|
|
310
|
+
{
|
|
311
|
+
status: response.status,
|
|
312
|
+
error: errorMessage
|
|
313
|
+
},
|
|
314
|
+
"Failed to get project via API"
|
|
315
|
+
);
|
|
316
|
+
throw new Error(errorMessage);
|
|
317
|
+
}
|
|
318
|
+
const result = await response.json();
|
|
319
|
+
logger2.info(
|
|
320
|
+
{
|
|
321
|
+
projectId
|
|
322
|
+
},
|
|
323
|
+
"Successfully retrieved project via API"
|
|
324
|
+
);
|
|
325
|
+
return result.data;
|
|
326
|
+
}
|
|
327
|
+
async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
|
|
328
|
+
logger2.info(
|
|
329
|
+
{
|
|
330
|
+
tenantId,
|
|
331
|
+
projectId,
|
|
332
|
+
apiUrl
|
|
333
|
+
},
|
|
334
|
+
"Deleting full project via API"
|
|
335
|
+
);
|
|
336
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
337
|
+
const headers = {};
|
|
338
|
+
if (apiKey) {
|
|
339
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
340
|
+
}
|
|
341
|
+
const response = await apiFetch(url, {
|
|
342
|
+
method: "DELETE",
|
|
343
|
+
headers
|
|
344
|
+
});
|
|
345
|
+
if (!response.ok) {
|
|
346
|
+
const errorText = await response.text();
|
|
347
|
+
const errorMessage = parseError(errorText) ?? `Failed to delete project: ${response.status} ${response.statusText}`;
|
|
348
|
+
logger2.error(
|
|
349
|
+
{
|
|
350
|
+
status: response.status,
|
|
351
|
+
error: errorMessage
|
|
352
|
+
},
|
|
353
|
+
"Failed to delete project via API"
|
|
354
|
+
);
|
|
355
|
+
throw new Error(errorMessage);
|
|
356
|
+
}
|
|
357
|
+
logger2.info(
|
|
358
|
+
{
|
|
359
|
+
projectId
|
|
360
|
+
},
|
|
361
|
+
"Successfully deleted project via API"
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
function parseError(errorText) {
|
|
365
|
+
try {
|
|
366
|
+
const errorJson = JSON.parse(errorText);
|
|
367
|
+
if (errorJson.error) {
|
|
368
|
+
const { error } = errorJson;
|
|
369
|
+
return error?.message ?? error;
|
|
370
|
+
}
|
|
371
|
+
} catch {
|
|
372
|
+
if (errorText) {
|
|
373
|
+
return errorText;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// src/agentFullClient.ts
|
|
379
|
+
var logger3 = getLogger("agentFullClient");
|
|
380
|
+
async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agentData) {
|
|
381
|
+
logger3.info(
|
|
173
382
|
{
|
|
174
383
|
tenantId,
|
|
175
384
|
projectId,
|
|
@@ -188,18 +397,8 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
|
|
|
188
397
|
});
|
|
189
398
|
if (!response.ok) {
|
|
190
399
|
const errorText = await response.text();
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const errorJson = JSON.parse(errorText);
|
|
194
|
-
if (errorJson.error) {
|
|
195
|
-
errorMessage = errorJson.error;
|
|
196
|
-
}
|
|
197
|
-
} catch {
|
|
198
|
-
if (errorText) {
|
|
199
|
-
errorMessage = errorText;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
logger2.error(
|
|
400
|
+
const errorMessage = parseError(errorText) ?? `Failed to update agent: ${response.status} ${response.statusText}`;
|
|
401
|
+
logger3.error(
|
|
203
402
|
{
|
|
204
403
|
status: response.status,
|
|
205
404
|
error: errorMessage
|
|
@@ -209,7 +408,7 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
|
|
|
209
408
|
throw new Error(errorMessage);
|
|
210
409
|
}
|
|
211
410
|
const result = await response.json();
|
|
212
|
-
|
|
411
|
+
logger3.info(
|
|
213
412
|
{
|
|
214
413
|
agentId
|
|
215
414
|
},
|
|
@@ -217,11 +416,11 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
|
|
|
217
416
|
);
|
|
218
417
|
return result.data;
|
|
219
418
|
}
|
|
220
|
-
var
|
|
419
|
+
var logger4 = getLogger("function-tool");
|
|
221
420
|
var getFunctionToolDeps = (name, code) => {
|
|
222
421
|
const { dependencies, warnings } = buildToolManifestFromCodeTS(code);
|
|
223
422
|
if (warnings.length > 0) {
|
|
224
|
-
|
|
423
|
+
logger4.warn({ warnings }, `FunctionTool dependencies warnings for ${name}`);
|
|
225
424
|
}
|
|
226
425
|
return dependencies;
|
|
227
426
|
};
|
|
@@ -364,7 +563,7 @@ function buildToolManifestFromCodeTS(code, projectRoot = process.cwd()) {
|
|
|
364
563
|
}
|
|
365
564
|
|
|
366
565
|
// src/function-tool.ts
|
|
367
|
-
var
|
|
566
|
+
var logger5 = getLogger("function-tool");
|
|
368
567
|
var FunctionTool = class {
|
|
369
568
|
constructor(config) {
|
|
370
569
|
__publicField(this, "config");
|
|
@@ -384,7 +583,7 @@ var FunctionTool = class {
|
|
|
384
583
|
}
|
|
385
584
|
this.config.dependencies = deps;
|
|
386
585
|
}
|
|
387
|
-
|
|
586
|
+
logger5.info(
|
|
388
587
|
{
|
|
389
588
|
id: this.id,
|
|
390
589
|
name: config.name
|
|
@@ -438,7 +637,7 @@ var FunctionTool = class {
|
|
|
438
637
|
};
|
|
439
638
|
|
|
440
639
|
// src/agent.ts
|
|
441
|
-
var
|
|
640
|
+
var logger6 = getLogger("agent");
|
|
442
641
|
function resolveGetter(value) {
|
|
443
642
|
if (typeof value === "function") {
|
|
444
643
|
return value();
|
|
@@ -498,7 +697,7 @@ var Agent = class {
|
|
|
498
697
|
if (this.models) {
|
|
499
698
|
this.propagateImmediateModelSettings();
|
|
500
699
|
}
|
|
501
|
-
|
|
700
|
+
logger6.info(
|
|
502
701
|
{
|
|
503
702
|
agentId: this.agentId,
|
|
504
703
|
tenantId: this.tenantId,
|
|
@@ -535,7 +734,7 @@ var Agent = class {
|
|
|
535
734
|
if (this.contextConfig?.setContext) {
|
|
536
735
|
this.contextConfig.setContext(tenantId, projectId, this.agentId, this.baseURL);
|
|
537
736
|
}
|
|
538
|
-
|
|
737
|
+
logger6.info(
|
|
539
738
|
{
|
|
540
739
|
agentId: this.agentId,
|
|
541
740
|
tenantId: this.tenantId,
|
|
@@ -694,7 +893,7 @@ var Agent = class {
|
|
|
694
893
|
* Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
|
|
695
894
|
*/
|
|
696
895
|
async initializeAllTools() {
|
|
697
|
-
|
|
896
|
+
logger6.info({ agentId: this.agentId }, "Initializing all tools in agent");
|
|
698
897
|
const toolInitPromises = [];
|
|
699
898
|
for (const subAgent2 of this.subAgents) {
|
|
700
899
|
const agentTools = subAgent2.getTools();
|
|
@@ -714,7 +913,7 @@ var Agent = class {
|
|
|
714
913
|
await toolInstance.init();
|
|
715
914
|
}
|
|
716
915
|
}
|
|
717
|
-
|
|
916
|
+
logger6.debug(
|
|
718
917
|
{
|
|
719
918
|
subAgentId: subAgent2.getId(),
|
|
720
919
|
toolName,
|
|
@@ -724,7 +923,7 @@ var Agent = class {
|
|
|
724
923
|
"Tool initialized successfully"
|
|
725
924
|
);
|
|
726
925
|
} catch (error) {
|
|
727
|
-
|
|
926
|
+
logger6.error(
|
|
728
927
|
{
|
|
729
928
|
subAgentId: subAgent2.getId(),
|
|
730
929
|
toolName,
|
|
@@ -741,7 +940,7 @@ var Agent = class {
|
|
|
741
940
|
}
|
|
742
941
|
}
|
|
743
942
|
await Promise.all(toolInitPromises);
|
|
744
|
-
|
|
943
|
+
logger6.info(
|
|
745
944
|
{ agentId: this.agentId, toolCount: toolInitPromises.length },
|
|
746
945
|
"All tools initialized successfully"
|
|
747
946
|
);
|
|
@@ -751,10 +950,10 @@ var Agent = class {
|
|
|
751
950
|
*/
|
|
752
951
|
async init() {
|
|
753
952
|
if (this.initialized) {
|
|
754
|
-
|
|
953
|
+
logger6.info({ agentId: this.agentId }, "Agent already initialized");
|
|
755
954
|
return;
|
|
756
955
|
}
|
|
757
|
-
|
|
956
|
+
logger6.info(
|
|
758
957
|
{
|
|
759
958
|
agentId: this.agentId,
|
|
760
959
|
agentCount: this.subAgents.length
|
|
@@ -765,7 +964,7 @@ var Agent = class {
|
|
|
765
964
|
await this.initializeAllTools();
|
|
766
965
|
await this.applyModelInheritance();
|
|
767
966
|
const agentDefinition = await this.toFullAgentDefinition();
|
|
768
|
-
|
|
967
|
+
logger6.info(
|
|
769
968
|
{
|
|
770
969
|
agentId: this.agentId,
|
|
771
970
|
mode: "api-client",
|
|
@@ -780,7 +979,7 @@ var Agent = class {
|
|
|
780
979
|
this.agentId,
|
|
781
980
|
agentDefinition
|
|
782
981
|
);
|
|
783
|
-
|
|
982
|
+
logger6.info(
|
|
784
983
|
{
|
|
785
984
|
agentId: this.agentId,
|
|
786
985
|
agentCount: Object.keys(createdAgent.subAgents || {}).length
|
|
@@ -789,7 +988,7 @@ var Agent = class {
|
|
|
789
988
|
);
|
|
790
989
|
this.initialized = true;
|
|
791
990
|
} catch (error) {
|
|
792
|
-
|
|
991
|
+
logger6.error(
|
|
793
992
|
{
|
|
794
993
|
agentId: this.agentId,
|
|
795
994
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -807,7 +1006,7 @@ var Agent = class {
|
|
|
807
1006
|
if (!this.defaultSubAgent) {
|
|
808
1007
|
throw new Error("No default agent configured for this agent");
|
|
809
1008
|
}
|
|
810
|
-
|
|
1009
|
+
logger6.info(
|
|
811
1010
|
{
|
|
812
1011
|
agentId: this.agentId,
|
|
813
1012
|
defaultSubAgent: this.defaultSubAgent.getName(),
|
|
@@ -826,7 +1025,7 @@ var Agent = class {
|
|
|
826
1025
|
if (!this.defaultSubAgent) {
|
|
827
1026
|
throw new Error("No default agent configured for this agent");
|
|
828
1027
|
}
|
|
829
|
-
|
|
1028
|
+
logger6.info(
|
|
830
1029
|
{
|
|
831
1030
|
agentId: this.agentId,
|
|
832
1031
|
defaultSubAgent: this.defaultSubAgent.getName(),
|
|
@@ -860,7 +1059,7 @@ var Agent = class {
|
|
|
860
1059
|
if (!agent2) {
|
|
861
1060
|
throw new Error(`Agent '${subAgentId}' not found in agent`);
|
|
862
1061
|
}
|
|
863
|
-
|
|
1062
|
+
logger6.info(
|
|
864
1063
|
{
|
|
865
1064
|
agentId: this.agentId,
|
|
866
1065
|
subAgentId,
|
|
@@ -895,7 +1094,7 @@ var Agent = class {
|
|
|
895
1094
|
if (this.models) {
|
|
896
1095
|
this.propagateModelSettingsToAgent(agent2);
|
|
897
1096
|
}
|
|
898
|
-
|
|
1097
|
+
logger6.info(
|
|
899
1098
|
{
|
|
900
1099
|
agentId: this.agentId,
|
|
901
1100
|
subAgentId: agent2.getId()
|
|
@@ -911,7 +1110,7 @@ var Agent = class {
|
|
|
911
1110
|
if (agentToRemove) {
|
|
912
1111
|
this.agentMap.delete(agentToRemove.getId());
|
|
913
1112
|
this.subAgents = this.subAgents.filter((agent2) => agent2.getId() !== agentToRemove.getId());
|
|
914
|
-
|
|
1113
|
+
logger6.info(
|
|
915
1114
|
{
|
|
916
1115
|
agentId: this.agentId,
|
|
917
1116
|
subAgentId: agentToRemove.getId()
|
|
@@ -940,7 +1139,7 @@ var Agent = class {
|
|
|
940
1139
|
setDefaultSubAgent(agent2) {
|
|
941
1140
|
this.defaultSubAgent = agent2;
|
|
942
1141
|
this.addSubAgent(agent2);
|
|
943
|
-
|
|
1142
|
+
logger6.info(
|
|
944
1143
|
{
|
|
945
1144
|
agentId: this.agentId,
|
|
946
1145
|
defaultSubAgent: agent2.getId()
|
|
@@ -1089,7 +1288,7 @@ var Agent = class {
|
|
|
1089
1288
|
});
|
|
1090
1289
|
return project2?.models;
|
|
1091
1290
|
} catch (error) {
|
|
1092
|
-
|
|
1291
|
+
logger6.warn(
|
|
1093
1292
|
{
|
|
1094
1293
|
tenantId: this.tenantId,
|
|
1095
1294
|
projectId: this.projectId,
|
|
@@ -1110,7 +1309,7 @@ var Agent = class {
|
|
|
1110
1309
|
});
|
|
1111
1310
|
return project2?.stopWhen;
|
|
1112
1311
|
} catch (error) {
|
|
1113
|
-
|
|
1312
|
+
logger6.warn(
|
|
1114
1313
|
{
|
|
1115
1314
|
tenantId: this.tenantId,
|
|
1116
1315
|
projectId: this.projectId,
|
|
@@ -1169,7 +1368,7 @@ var Agent = class {
|
|
|
1169
1368
|
}
|
|
1170
1369
|
}
|
|
1171
1370
|
}
|
|
1172
|
-
|
|
1371
|
+
logger6.debug(
|
|
1173
1372
|
{
|
|
1174
1373
|
agentId: this.agentId,
|
|
1175
1374
|
agentStopWhen: this.stopWhen,
|
|
@@ -1211,7 +1410,7 @@ var Agent = class {
|
|
|
1211
1410
|
async executeWithBackend(input, options) {
|
|
1212
1411
|
const normalizedMessages = this.normalizeMessages(input);
|
|
1213
1412
|
const url = `${this.baseURL}/tenants/${this.tenantId}/agent/${this.agentId}/v1/chat/completions`;
|
|
1214
|
-
|
|
1413
|
+
logger6.info({ url }, "Executing with backend");
|
|
1215
1414
|
const requestBody = {
|
|
1216
1415
|
model: "gpt-4o-mini",
|
|
1217
1416
|
messages: normalizedMessages.map((msg) => ({
|
|
@@ -1295,7 +1494,7 @@ var Agent = class {
|
|
|
1295
1494
|
}
|
|
1296
1495
|
});
|
|
1297
1496
|
if (getResponse.ok) {
|
|
1298
|
-
|
|
1497
|
+
logger6.info({ agentId: this.agentId }, "Agent already exists in backend");
|
|
1299
1498
|
return;
|
|
1300
1499
|
}
|
|
1301
1500
|
if (getResponse.status !== 404) {
|
|
@@ -1306,7 +1505,7 @@ var Agent = class {
|
|
|
1306
1505
|
throw error;
|
|
1307
1506
|
}
|
|
1308
1507
|
}
|
|
1309
|
-
|
|
1508
|
+
logger6.info({ agentId: this.agentId }, "Creating agent in backend");
|
|
1310
1509
|
const createUrl = `${this.baseURL}/tenants/${this.tenantId}/agents`;
|
|
1311
1510
|
const createResponse = await fetch(createUrl, {
|
|
1312
1511
|
method: "POST",
|
|
@@ -1326,7 +1525,7 @@ var Agent = class {
|
|
|
1326
1525
|
}
|
|
1327
1526
|
const createData = await createResponse.json();
|
|
1328
1527
|
this.agentId = createData.data.id;
|
|
1329
|
-
|
|
1528
|
+
logger6.info({ agent: createData.data }, "Agent created in backend");
|
|
1330
1529
|
} catch (error) {
|
|
1331
1530
|
throw new Error(
|
|
1332
1531
|
`Failed to save agent to database: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
@@ -1351,7 +1550,7 @@ var Agent = class {
|
|
|
1351
1550
|
if (!updateResponse.ok) {
|
|
1352
1551
|
throw new Error(`HTTP ${updateResponse.status}: ${updateResponse.statusText}`);
|
|
1353
1552
|
}
|
|
1354
|
-
|
|
1553
|
+
logger6.debug(
|
|
1355
1554
|
{
|
|
1356
1555
|
agentId: this.agentId,
|
|
1357
1556
|
defaultSubAgent: this.defaultSubAgent.getName()
|
|
@@ -1359,7 +1558,7 @@ var Agent = class {
|
|
|
1359
1558
|
"Agent relationships configured"
|
|
1360
1559
|
);
|
|
1361
1560
|
} catch (error) {
|
|
1362
|
-
|
|
1561
|
+
logger6.error(
|
|
1363
1562
|
{
|
|
1364
1563
|
agentId: this.agentId,
|
|
1365
1564
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -1396,7 +1595,7 @@ var Agent = class {
|
|
|
1396
1595
|
successCount++;
|
|
1397
1596
|
} else {
|
|
1398
1597
|
errors.push(result.reason);
|
|
1399
|
-
|
|
1598
|
+
logger6.error(
|
|
1400
1599
|
{
|
|
1401
1600
|
error: result.reason instanceof Error ? result.reason.message : "Unknown error",
|
|
1402
1601
|
agentId: this.agentId
|
|
@@ -1405,7 +1604,7 @@ var Agent = class {
|
|
|
1405
1604
|
);
|
|
1406
1605
|
}
|
|
1407
1606
|
}
|
|
1408
|
-
|
|
1607
|
+
logger6.info(
|
|
1409
1608
|
{
|
|
1410
1609
|
agentId: this.agentId,
|
|
1411
1610
|
totalRelations: allSubAgentRelationPromises.length,
|
|
@@ -1435,7 +1634,7 @@ var Agent = class {
|
|
|
1435
1634
|
if (!response.ok) {
|
|
1436
1635
|
const errorText = await response.text().catch(() => "Unknown error");
|
|
1437
1636
|
if (response.status === 422 && errorText.includes("already exists")) {
|
|
1438
|
-
|
|
1637
|
+
logger6.info(
|
|
1439
1638
|
{
|
|
1440
1639
|
sourceSubAgentId: sourceAgent.getId(),
|
|
1441
1640
|
targetSubAgentId: targetAgent.getId(),
|
|
@@ -1448,7 +1647,7 @@ var Agent = class {
|
|
|
1448
1647
|
}
|
|
1449
1648
|
throw new Error(`Failed to create subAgent relation: ${response.status} - ${errorText}`);
|
|
1450
1649
|
}
|
|
1451
|
-
|
|
1650
|
+
logger6.info(
|
|
1452
1651
|
{
|
|
1453
1652
|
sourceSubAgentId: sourceAgent.getId(),
|
|
1454
1653
|
targetSubAgentId: targetAgent.getId(),
|
|
@@ -1458,7 +1657,7 @@ var Agent = class {
|
|
|
1458
1657
|
`${relationType} subAgent relation created successfully`
|
|
1459
1658
|
);
|
|
1460
1659
|
} catch (error) {
|
|
1461
|
-
|
|
1660
|
+
logger6.error(
|
|
1462
1661
|
{
|
|
1463
1662
|
sourceSubAgentId: sourceAgent.getId(),
|
|
1464
1663
|
targetSubAgentId: targetAgent.getId(),
|
|
@@ -1472,7 +1671,7 @@ var Agent = class {
|
|
|
1472
1671
|
}
|
|
1473
1672
|
}
|
|
1474
1673
|
};
|
|
1475
|
-
var
|
|
1674
|
+
var logger7 = getLogger("dataComponent");
|
|
1476
1675
|
var DataComponent = class {
|
|
1477
1676
|
constructor(config) {
|
|
1478
1677
|
__publicField(this, "config");
|
|
@@ -1497,7 +1696,7 @@ var DataComponent = class {
|
|
|
1497
1696
|
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
1498
1697
|
this.tenantId = "default";
|
|
1499
1698
|
this.projectId = "default";
|
|
1500
|
-
|
|
1699
|
+
logger7.info(
|
|
1501
1700
|
{
|
|
1502
1701
|
dataComponentId: this.getId(),
|
|
1503
1702
|
dataComponentName: config.name
|
|
@@ -1534,7 +1733,7 @@ var DataComponent = class {
|
|
|
1534
1733
|
if (this.initialized) return;
|
|
1535
1734
|
try {
|
|
1536
1735
|
await this.upsertDataComponent();
|
|
1537
|
-
|
|
1736
|
+
logger7.info(
|
|
1538
1737
|
{
|
|
1539
1738
|
dataComponentId: this.getId()
|
|
1540
1739
|
},
|
|
@@ -1542,7 +1741,7 @@ var DataComponent = class {
|
|
|
1542
1741
|
);
|
|
1543
1742
|
this.initialized = true;
|
|
1544
1743
|
} catch (error) {
|
|
1545
|
-
|
|
1744
|
+
logger7.error(
|
|
1546
1745
|
{
|
|
1547
1746
|
dataComponentId: this.getId(),
|
|
1548
1747
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -1561,7 +1760,7 @@ var DataComponent = class {
|
|
|
1561
1760
|
props: this.config.props,
|
|
1562
1761
|
render: this.config.render
|
|
1563
1762
|
};
|
|
1564
|
-
|
|
1763
|
+
logger7.info({ dataComponentData }, "dataComponentData for create/update");
|
|
1565
1764
|
const updateResponse = await fetch(
|
|
1566
1765
|
`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/data-components/${this.getId()}`,
|
|
1567
1766
|
{
|
|
@@ -1572,7 +1771,7 @@ var DataComponent = class {
|
|
|
1572
1771
|
body: JSON.stringify(dataComponentData)
|
|
1573
1772
|
}
|
|
1574
1773
|
);
|
|
1575
|
-
|
|
1774
|
+
logger7.info(
|
|
1576
1775
|
{
|
|
1577
1776
|
status: updateResponse.status,
|
|
1578
1777
|
dataComponentId: this.getId()
|
|
@@ -1580,7 +1779,7 @@ var DataComponent = class {
|
|
|
1580
1779
|
"data component updateResponse"
|
|
1581
1780
|
);
|
|
1582
1781
|
if (updateResponse.ok) {
|
|
1583
|
-
|
|
1782
|
+
logger7.info(
|
|
1584
1783
|
{
|
|
1585
1784
|
dataComponentId: this.getId()
|
|
1586
1785
|
},
|
|
@@ -1589,7 +1788,7 @@ var DataComponent = class {
|
|
|
1589
1788
|
return;
|
|
1590
1789
|
}
|
|
1591
1790
|
if (updateResponse.status === 404) {
|
|
1592
|
-
|
|
1791
|
+
logger7.info(
|
|
1593
1792
|
{
|
|
1594
1793
|
dataComponentId: this.getId()
|
|
1595
1794
|
},
|
|
@@ -1611,7 +1810,7 @@ var DataComponent = class {
|
|
|
1611
1810
|
`Failed to create data component: ${createResponse.status} ${createResponse.statusText} - ${errorText2}`
|
|
1612
1811
|
);
|
|
1613
1812
|
}
|
|
1614
|
-
|
|
1813
|
+
logger7.info(
|
|
1615
1814
|
{
|
|
1616
1815
|
dataComponentId: this.getId()
|
|
1617
1816
|
},
|
|
@@ -1625,242 +1824,6 @@ var DataComponent = class {
|
|
|
1625
1824
|
);
|
|
1626
1825
|
}
|
|
1627
1826
|
};
|
|
1628
|
-
var logger7 = getLogger("projectFullClient");
|
|
1629
|
-
async function createFullProjectViaAPI(tenantId, apiUrl, projectData, apiKey) {
|
|
1630
|
-
logger7.info(
|
|
1631
|
-
{
|
|
1632
|
-
tenantId,
|
|
1633
|
-
projectId: projectData.id,
|
|
1634
|
-
apiUrl
|
|
1635
|
-
},
|
|
1636
|
-
"Creating full project via API"
|
|
1637
|
-
);
|
|
1638
|
-
const url = `${apiUrl}/tenants/${tenantId}/project-full`;
|
|
1639
|
-
const headers = {};
|
|
1640
|
-
if (apiKey) {
|
|
1641
|
-
headers.Authorization = `Bearer ${apiKey}`;
|
|
1642
|
-
}
|
|
1643
|
-
let response;
|
|
1644
|
-
try {
|
|
1645
|
-
response = await apiFetch(url, {
|
|
1646
|
-
method: "POST",
|
|
1647
|
-
headers,
|
|
1648
|
-
body: JSON.stringify(projectData)
|
|
1649
|
-
});
|
|
1650
|
-
} catch (fetchError) {
|
|
1651
|
-
logger7.error(
|
|
1652
|
-
{
|
|
1653
|
-
error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
|
|
1654
|
-
url,
|
|
1655
|
-
tenantId,
|
|
1656
|
-
projectId: projectData.id
|
|
1657
|
-
},
|
|
1658
|
-
"Fetch request failed"
|
|
1659
|
-
);
|
|
1660
|
-
throw fetchError;
|
|
1661
|
-
}
|
|
1662
|
-
if (!response.ok) {
|
|
1663
|
-
const errorText = await response.text();
|
|
1664
|
-
let errorMessage = `Failed to create project: ${response.status} ${response.statusText}`;
|
|
1665
|
-
try {
|
|
1666
|
-
const errorJson = JSON.parse(errorText);
|
|
1667
|
-
if (errorJson.error) {
|
|
1668
|
-
errorMessage = errorJson.error;
|
|
1669
|
-
}
|
|
1670
|
-
} catch {
|
|
1671
|
-
if (errorText) {
|
|
1672
|
-
errorMessage = errorText;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
logger7.error(
|
|
1676
|
-
{
|
|
1677
|
-
status: response.status,
|
|
1678
|
-
error: errorMessage
|
|
1679
|
-
},
|
|
1680
|
-
"Failed to create project via API"
|
|
1681
|
-
);
|
|
1682
|
-
throw new Error(errorMessage);
|
|
1683
|
-
}
|
|
1684
|
-
const result = await response.json();
|
|
1685
|
-
logger7.info(
|
|
1686
|
-
{
|
|
1687
|
-
projectId: projectData.id
|
|
1688
|
-
},
|
|
1689
|
-
"Successfully created project via API"
|
|
1690
|
-
);
|
|
1691
|
-
return result.data;
|
|
1692
|
-
}
|
|
1693
|
-
async function updateFullProjectViaAPI(tenantId, apiUrl, projectId, projectData, apiKey) {
|
|
1694
|
-
logger7.info(
|
|
1695
|
-
{
|
|
1696
|
-
tenantId,
|
|
1697
|
-
projectId,
|
|
1698
|
-
apiUrl
|
|
1699
|
-
},
|
|
1700
|
-
"Updating full project via API"
|
|
1701
|
-
);
|
|
1702
|
-
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
1703
|
-
const headers = {};
|
|
1704
|
-
if (apiKey) {
|
|
1705
|
-
headers.Authorization = `Bearer ${apiKey}`;
|
|
1706
|
-
}
|
|
1707
|
-
let response;
|
|
1708
|
-
try {
|
|
1709
|
-
response = await apiFetch(url, {
|
|
1710
|
-
method: "PUT",
|
|
1711
|
-
headers,
|
|
1712
|
-
body: JSON.stringify(projectData)
|
|
1713
|
-
});
|
|
1714
|
-
} catch (fetchError) {
|
|
1715
|
-
logger7.error(
|
|
1716
|
-
{
|
|
1717
|
-
error: fetchError instanceof Error ? fetchError.message : "Unknown fetch error",
|
|
1718
|
-
url,
|
|
1719
|
-
tenantId,
|
|
1720
|
-
projectId
|
|
1721
|
-
},
|
|
1722
|
-
"Fetch request failed"
|
|
1723
|
-
);
|
|
1724
|
-
throw fetchError;
|
|
1725
|
-
}
|
|
1726
|
-
if (!response.ok) {
|
|
1727
|
-
const errorText = await response.text();
|
|
1728
|
-
let errorMessage = `Failed to update project: ${response.status} ${response.statusText}`;
|
|
1729
|
-
try {
|
|
1730
|
-
const errorJson = JSON.parse(errorText);
|
|
1731
|
-
if (errorJson.error) {
|
|
1732
|
-
errorMessage = errorJson.error;
|
|
1733
|
-
}
|
|
1734
|
-
} catch {
|
|
1735
|
-
if (errorText) {
|
|
1736
|
-
errorMessage = errorText;
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
logger7.error(
|
|
1740
|
-
{
|
|
1741
|
-
status: response.status,
|
|
1742
|
-
error: errorMessage
|
|
1743
|
-
},
|
|
1744
|
-
"Failed to update project via API"
|
|
1745
|
-
);
|
|
1746
|
-
throw new Error(errorMessage);
|
|
1747
|
-
}
|
|
1748
|
-
const result = await response.json();
|
|
1749
|
-
logger7.info(
|
|
1750
|
-
{
|
|
1751
|
-
projectId
|
|
1752
|
-
},
|
|
1753
|
-
"Successfully updated project via API"
|
|
1754
|
-
);
|
|
1755
|
-
return result.data;
|
|
1756
|
-
}
|
|
1757
|
-
async function getFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
|
|
1758
|
-
logger7.info(
|
|
1759
|
-
{
|
|
1760
|
-
tenantId,
|
|
1761
|
-
projectId,
|
|
1762
|
-
apiUrl
|
|
1763
|
-
},
|
|
1764
|
-
"Getting full project via API"
|
|
1765
|
-
);
|
|
1766
|
-
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
1767
|
-
const headers = {};
|
|
1768
|
-
if (apiKey) {
|
|
1769
|
-
headers.Authorization = `Bearer ${apiKey}`;
|
|
1770
|
-
}
|
|
1771
|
-
const response = await apiFetch(url, {
|
|
1772
|
-
method: "GET",
|
|
1773
|
-
headers
|
|
1774
|
-
});
|
|
1775
|
-
if (!response.ok) {
|
|
1776
|
-
if (response.status === 404) {
|
|
1777
|
-
logger7.info(
|
|
1778
|
-
{
|
|
1779
|
-
projectId
|
|
1780
|
-
},
|
|
1781
|
-
"Project not found"
|
|
1782
|
-
);
|
|
1783
|
-
return null;
|
|
1784
|
-
}
|
|
1785
|
-
const errorText = await response.text();
|
|
1786
|
-
let errorMessage = `Failed to get project: ${response.status} ${response.statusText}`;
|
|
1787
|
-
try {
|
|
1788
|
-
const errorJson = JSON.parse(errorText);
|
|
1789
|
-
if (errorJson.error) {
|
|
1790
|
-
errorMessage = errorJson.error;
|
|
1791
|
-
}
|
|
1792
|
-
} catch {
|
|
1793
|
-
if (errorText) {
|
|
1794
|
-
errorMessage = errorText;
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
logger7.error(
|
|
1798
|
-
{
|
|
1799
|
-
status: response.status,
|
|
1800
|
-
error: errorMessage
|
|
1801
|
-
},
|
|
1802
|
-
"Failed to get project via API"
|
|
1803
|
-
);
|
|
1804
|
-
throw new Error(errorMessage);
|
|
1805
|
-
}
|
|
1806
|
-
const result = await response.json();
|
|
1807
|
-
logger7.info(
|
|
1808
|
-
{
|
|
1809
|
-
projectId
|
|
1810
|
-
},
|
|
1811
|
-
"Successfully retrieved project via API"
|
|
1812
|
-
);
|
|
1813
|
-
return result.data;
|
|
1814
|
-
}
|
|
1815
|
-
async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId, apiKey) {
|
|
1816
|
-
logger7.info(
|
|
1817
|
-
{
|
|
1818
|
-
tenantId,
|
|
1819
|
-
projectId,
|
|
1820
|
-
apiUrl
|
|
1821
|
-
},
|
|
1822
|
-
"Deleting full project via API"
|
|
1823
|
-
);
|
|
1824
|
-
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
1825
|
-
const headers = {};
|
|
1826
|
-
if (apiKey) {
|
|
1827
|
-
headers.Authorization = `Bearer ${apiKey}`;
|
|
1828
|
-
}
|
|
1829
|
-
const response = await apiFetch(url, {
|
|
1830
|
-
method: "DELETE",
|
|
1831
|
-
headers
|
|
1832
|
-
});
|
|
1833
|
-
if (!response.ok) {
|
|
1834
|
-
const errorText = await response.text();
|
|
1835
|
-
let errorMessage = `Failed to delete project: ${response.status} ${response.statusText}`;
|
|
1836
|
-
try {
|
|
1837
|
-
const errorJson = JSON.parse(errorText);
|
|
1838
|
-
if (errorJson.error) {
|
|
1839
|
-
errorMessage = errorJson.error;
|
|
1840
|
-
}
|
|
1841
|
-
} catch {
|
|
1842
|
-
if (errorText) {
|
|
1843
|
-
errorMessage = errorText;
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
logger7.error(
|
|
1847
|
-
{
|
|
1848
|
-
status: response.status,
|
|
1849
|
-
error: errorMessage
|
|
1850
|
-
},
|
|
1851
|
-
"Failed to delete project via API"
|
|
1852
|
-
);
|
|
1853
|
-
throw new Error(errorMessage);
|
|
1854
|
-
}
|
|
1855
|
-
logger7.info(
|
|
1856
|
-
{
|
|
1857
|
-
projectId
|
|
1858
|
-
},
|
|
1859
|
-
"Successfully deleted project via API"
|
|
1860
|
-
);
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
// src/project.ts
|
|
1864
1827
|
var logger8 = getLogger("project");
|
|
1865
1828
|
var Project = class {
|
|
1866
1829
|
constructor(config) {
|