@inkeep/agents-sdk 0.0.0-dev-20250912172534 → 0.0.0-dev-20250912184011
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 +527 -13
- package/dist/index.d.cts +223 -11
- package/dist/index.d.ts +223 -11
- package/dist/index.js +522 -14
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1962,10 +1962,10 @@ var AgentGraph = class {
|
|
|
1962
1962
|
*/
|
|
1963
1963
|
async getProjectModelDefaults() {
|
|
1964
1964
|
try {
|
|
1965
|
-
const
|
|
1965
|
+
const project2 = await agentsCore.getProject(this.dbClient)({
|
|
1966
1966
|
scopes: { tenantId: this.tenantId, projectId: this.projectId }
|
|
1967
1967
|
});
|
|
1968
|
-
return
|
|
1968
|
+
return project2?.models;
|
|
1969
1969
|
} catch (error) {
|
|
1970
1970
|
logger7.warn(
|
|
1971
1971
|
{
|
|
@@ -1983,10 +1983,10 @@ var AgentGraph = class {
|
|
|
1983
1983
|
*/
|
|
1984
1984
|
async getProjectStopWhenDefaults() {
|
|
1985
1985
|
try {
|
|
1986
|
-
const
|
|
1986
|
+
const project2 = await agentsCore.getProject(this.dbClient)({
|
|
1987
1987
|
scopes: { tenantId: this.tenantId, projectId: this.projectId }
|
|
1988
1988
|
});
|
|
1989
|
-
return
|
|
1989
|
+
return project2?.stopWhen;
|
|
1990
1990
|
} catch (error) {
|
|
1991
1991
|
logger7.warn(
|
|
1992
1992
|
{
|
|
@@ -2483,6 +2483,511 @@ var AgentGraph = class {
|
|
|
2483
2483
|
}
|
|
2484
2484
|
}
|
|
2485
2485
|
};
|
|
2486
|
+
var logger8 = agentsCore.getLogger("projectFullClient");
|
|
2487
|
+
async function createFullProjectViaAPI(tenantId, apiUrl, projectData) {
|
|
2488
|
+
logger8.info(
|
|
2489
|
+
{
|
|
2490
|
+
tenantId,
|
|
2491
|
+
projectId: projectData.id,
|
|
2492
|
+
apiUrl
|
|
2493
|
+
},
|
|
2494
|
+
"Creating full project via API"
|
|
2495
|
+
);
|
|
2496
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full`;
|
|
2497
|
+
const response = await fetch(url, {
|
|
2498
|
+
method: "POST",
|
|
2499
|
+
headers: {
|
|
2500
|
+
"Content-Type": "application/json"
|
|
2501
|
+
},
|
|
2502
|
+
body: JSON.stringify(projectData)
|
|
2503
|
+
});
|
|
2504
|
+
if (!response.ok) {
|
|
2505
|
+
const errorText = await response.text();
|
|
2506
|
+
let errorMessage = `Failed to create project: ${response.status} ${response.statusText}`;
|
|
2507
|
+
try {
|
|
2508
|
+
const errorJson = JSON.parse(errorText);
|
|
2509
|
+
if (errorJson.error) {
|
|
2510
|
+
errorMessage = errorJson.error;
|
|
2511
|
+
}
|
|
2512
|
+
} catch {
|
|
2513
|
+
if (errorText) {
|
|
2514
|
+
errorMessage = errorText;
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
logger8.error(
|
|
2518
|
+
{
|
|
2519
|
+
status: response.status,
|
|
2520
|
+
error: errorMessage
|
|
2521
|
+
},
|
|
2522
|
+
"Failed to create project via API"
|
|
2523
|
+
);
|
|
2524
|
+
throw new Error(errorMessage);
|
|
2525
|
+
}
|
|
2526
|
+
const result = await response.json();
|
|
2527
|
+
logger8.info(
|
|
2528
|
+
{
|
|
2529
|
+
projectId: projectData.id
|
|
2530
|
+
},
|
|
2531
|
+
"Successfully created project via API"
|
|
2532
|
+
);
|
|
2533
|
+
return result.data;
|
|
2534
|
+
}
|
|
2535
|
+
async function updateFullProjectViaAPI(tenantId, apiUrl, projectId, projectData) {
|
|
2536
|
+
logger8.info(
|
|
2537
|
+
{
|
|
2538
|
+
tenantId,
|
|
2539
|
+
projectId,
|
|
2540
|
+
apiUrl
|
|
2541
|
+
},
|
|
2542
|
+
"Updating full project via API"
|
|
2543
|
+
);
|
|
2544
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
2545
|
+
const response = await fetch(url, {
|
|
2546
|
+
method: "PUT",
|
|
2547
|
+
headers: {
|
|
2548
|
+
"Content-Type": "application/json"
|
|
2549
|
+
},
|
|
2550
|
+
body: JSON.stringify(projectData)
|
|
2551
|
+
});
|
|
2552
|
+
if (!response.ok) {
|
|
2553
|
+
const errorText = await response.text();
|
|
2554
|
+
let errorMessage = `Failed to update project: ${response.status} ${response.statusText}`;
|
|
2555
|
+
try {
|
|
2556
|
+
const errorJson = JSON.parse(errorText);
|
|
2557
|
+
if (errorJson.error) {
|
|
2558
|
+
errorMessage = errorJson.error;
|
|
2559
|
+
}
|
|
2560
|
+
} catch {
|
|
2561
|
+
if (errorText) {
|
|
2562
|
+
errorMessage = errorText;
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
logger8.error(
|
|
2566
|
+
{
|
|
2567
|
+
status: response.status,
|
|
2568
|
+
error: errorMessage
|
|
2569
|
+
},
|
|
2570
|
+
"Failed to update project via API"
|
|
2571
|
+
);
|
|
2572
|
+
throw new Error(errorMessage);
|
|
2573
|
+
}
|
|
2574
|
+
const result = await response.json();
|
|
2575
|
+
logger8.info(
|
|
2576
|
+
{
|
|
2577
|
+
projectId
|
|
2578
|
+
},
|
|
2579
|
+
"Successfully updated project via API"
|
|
2580
|
+
);
|
|
2581
|
+
return result.data;
|
|
2582
|
+
}
|
|
2583
|
+
async function getFullProjectViaAPI(tenantId, apiUrl, projectId) {
|
|
2584
|
+
logger8.info(
|
|
2585
|
+
{
|
|
2586
|
+
tenantId,
|
|
2587
|
+
projectId,
|
|
2588
|
+
apiUrl
|
|
2589
|
+
},
|
|
2590
|
+
"Getting full project via API"
|
|
2591
|
+
);
|
|
2592
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
2593
|
+
const response = await fetch(url, {
|
|
2594
|
+
method: "GET",
|
|
2595
|
+
headers: {
|
|
2596
|
+
"Content-Type": "application/json"
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2599
|
+
if (!response.ok) {
|
|
2600
|
+
if (response.status === 404) {
|
|
2601
|
+
logger8.info(
|
|
2602
|
+
{
|
|
2603
|
+
projectId
|
|
2604
|
+
},
|
|
2605
|
+
"Project not found"
|
|
2606
|
+
);
|
|
2607
|
+
return null;
|
|
2608
|
+
}
|
|
2609
|
+
const errorText = await response.text();
|
|
2610
|
+
let errorMessage = `Failed to get project: ${response.status} ${response.statusText}`;
|
|
2611
|
+
try {
|
|
2612
|
+
const errorJson = JSON.parse(errorText);
|
|
2613
|
+
if (errorJson.error) {
|
|
2614
|
+
errorMessage = errorJson.error;
|
|
2615
|
+
}
|
|
2616
|
+
} catch {
|
|
2617
|
+
if (errorText) {
|
|
2618
|
+
errorMessage = errorText;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
logger8.error(
|
|
2622
|
+
{
|
|
2623
|
+
status: response.status,
|
|
2624
|
+
error: errorMessage
|
|
2625
|
+
},
|
|
2626
|
+
"Failed to get project via API"
|
|
2627
|
+
);
|
|
2628
|
+
throw new Error(errorMessage);
|
|
2629
|
+
}
|
|
2630
|
+
const result = await response.json();
|
|
2631
|
+
logger8.info(
|
|
2632
|
+
{
|
|
2633
|
+
projectId
|
|
2634
|
+
},
|
|
2635
|
+
"Successfully retrieved project via API"
|
|
2636
|
+
);
|
|
2637
|
+
return result.data;
|
|
2638
|
+
}
|
|
2639
|
+
async function deleteFullProjectViaAPI(tenantId, apiUrl, projectId) {
|
|
2640
|
+
logger8.info(
|
|
2641
|
+
{
|
|
2642
|
+
tenantId,
|
|
2643
|
+
projectId,
|
|
2644
|
+
apiUrl
|
|
2645
|
+
},
|
|
2646
|
+
"Deleting full project via API"
|
|
2647
|
+
);
|
|
2648
|
+
const url = `${apiUrl}/tenants/${tenantId}/project-full/${projectId}`;
|
|
2649
|
+
const response = await fetch(url, {
|
|
2650
|
+
method: "DELETE",
|
|
2651
|
+
headers: {
|
|
2652
|
+
"Content-Type": "application/json"
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
if (!response.ok) {
|
|
2656
|
+
const errorText = await response.text();
|
|
2657
|
+
let errorMessage = `Failed to delete project: ${response.status} ${response.statusText}`;
|
|
2658
|
+
try {
|
|
2659
|
+
const errorJson = JSON.parse(errorText);
|
|
2660
|
+
if (errorJson.error) {
|
|
2661
|
+
errorMessage = errorJson.error;
|
|
2662
|
+
}
|
|
2663
|
+
} catch {
|
|
2664
|
+
if (errorText) {
|
|
2665
|
+
errorMessage = errorText;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
logger8.error(
|
|
2669
|
+
{
|
|
2670
|
+
status: response.status,
|
|
2671
|
+
error: errorMessage
|
|
2672
|
+
},
|
|
2673
|
+
"Failed to delete project via API"
|
|
2674
|
+
);
|
|
2675
|
+
throw new Error(errorMessage);
|
|
2676
|
+
}
|
|
2677
|
+
logger8.info(
|
|
2678
|
+
{
|
|
2679
|
+
projectId
|
|
2680
|
+
},
|
|
2681
|
+
"Successfully deleted project via API"
|
|
2682
|
+
);
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
// src/project.ts
|
|
2686
|
+
var logger9 = agentsCore.getLogger("project");
|
|
2687
|
+
var Project = class {
|
|
2688
|
+
constructor(config) {
|
|
2689
|
+
__publicField(this, "projectId");
|
|
2690
|
+
__publicField(this, "projectName");
|
|
2691
|
+
__publicField(this, "projectDescription");
|
|
2692
|
+
__publicField(this, "tenantId");
|
|
2693
|
+
__publicField(this, "baseURL");
|
|
2694
|
+
__publicField(this, "initialized", false);
|
|
2695
|
+
__publicField(this, "models");
|
|
2696
|
+
__publicField(this, "stopWhen");
|
|
2697
|
+
__publicField(this, "graphs", []);
|
|
2698
|
+
__publicField(this, "graphMap", /* @__PURE__ */ new Map());
|
|
2699
|
+
this.projectId = config.id;
|
|
2700
|
+
this.projectName = config.name;
|
|
2701
|
+
this.projectDescription = config.description;
|
|
2702
|
+
this.tenantId = config.tenantId || "default";
|
|
2703
|
+
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
2704
|
+
this.models = config.models;
|
|
2705
|
+
this.stopWhen = config.stopWhen;
|
|
2706
|
+
if (config.graphs) {
|
|
2707
|
+
this.graphs = config.graphs();
|
|
2708
|
+
this.graphMap = new Map(this.graphs.map((graph) => [graph.getId(), graph]));
|
|
2709
|
+
for (const graph of this.graphs) {
|
|
2710
|
+
graph.setConfig(this.tenantId, this.projectId, this.baseURL);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
logger9.info(
|
|
2714
|
+
{
|
|
2715
|
+
projectId: this.projectId,
|
|
2716
|
+
tenantId: this.tenantId,
|
|
2717
|
+
graphCount: this.graphs.length
|
|
2718
|
+
},
|
|
2719
|
+
"Project created"
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
/**
|
|
2723
|
+
* Set or update the configuration (tenantId and apiUrl)
|
|
2724
|
+
* This is used by the CLI to inject configuration from inkeep.config.ts
|
|
2725
|
+
*/
|
|
2726
|
+
setConfig(tenantId, apiUrl) {
|
|
2727
|
+
if (this.initialized) {
|
|
2728
|
+
throw new Error("Cannot set config after project has been initialized");
|
|
2729
|
+
}
|
|
2730
|
+
this.tenantId = tenantId;
|
|
2731
|
+
this.baseURL = apiUrl;
|
|
2732
|
+
for (const graph of this.graphs) {
|
|
2733
|
+
graph.setConfig(tenantId, this.projectId, apiUrl);
|
|
2734
|
+
}
|
|
2735
|
+
logger9.info(
|
|
2736
|
+
{
|
|
2737
|
+
projectId: this.projectId,
|
|
2738
|
+
tenantId: this.tenantId,
|
|
2739
|
+
apiUrl: this.baseURL
|
|
2740
|
+
},
|
|
2741
|
+
"Project configuration updated"
|
|
2742
|
+
);
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* Initialize the project and create/update it in the backend using full project approach
|
|
2746
|
+
*/
|
|
2747
|
+
async init() {
|
|
2748
|
+
if (this.initialized) {
|
|
2749
|
+
logger9.info({ projectId: this.projectId }, "Project already initialized");
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2752
|
+
logger9.info(
|
|
2753
|
+
{
|
|
2754
|
+
projectId: this.projectId,
|
|
2755
|
+
tenantId: this.tenantId,
|
|
2756
|
+
graphCount: this.graphs.length
|
|
2757
|
+
},
|
|
2758
|
+
"Initializing project using full project endpoint"
|
|
2759
|
+
);
|
|
2760
|
+
try {
|
|
2761
|
+
const initPromises = this.graphs.map(async (graph) => {
|
|
2762
|
+
try {
|
|
2763
|
+
await graph.init();
|
|
2764
|
+
logger9.debug(
|
|
2765
|
+
{
|
|
2766
|
+
projectId: this.projectId,
|
|
2767
|
+
graphId: graph.getId()
|
|
2768
|
+
},
|
|
2769
|
+
"Graph initialized in project"
|
|
2770
|
+
);
|
|
2771
|
+
} catch (error) {
|
|
2772
|
+
logger9.error(
|
|
2773
|
+
{
|
|
2774
|
+
projectId: this.projectId,
|
|
2775
|
+
graphId: graph.getId(),
|
|
2776
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
2777
|
+
},
|
|
2778
|
+
"Failed to initialize graph in project"
|
|
2779
|
+
);
|
|
2780
|
+
throw error;
|
|
2781
|
+
}
|
|
2782
|
+
});
|
|
2783
|
+
await Promise.all(initPromises);
|
|
2784
|
+
const projectDefinition = await this.toFullProjectDefinition();
|
|
2785
|
+
logger9.info(
|
|
2786
|
+
{
|
|
2787
|
+
projectId: this.projectId,
|
|
2788
|
+
mode: "api-client",
|
|
2789
|
+
apiUrl: this.baseURL
|
|
2790
|
+
},
|
|
2791
|
+
"Using API client to create/update full project"
|
|
2792
|
+
);
|
|
2793
|
+
const createdProject = await updateFullProjectViaAPI(
|
|
2794
|
+
this.tenantId,
|
|
2795
|
+
this.baseURL,
|
|
2796
|
+
this.projectId,
|
|
2797
|
+
projectDefinition
|
|
2798
|
+
);
|
|
2799
|
+
this.initialized = true;
|
|
2800
|
+
logger9.info(
|
|
2801
|
+
{
|
|
2802
|
+
projectId: this.projectId,
|
|
2803
|
+
tenantId: this.tenantId,
|
|
2804
|
+
graphCount: Object.keys(createdProject.graphs || {}).length
|
|
2805
|
+
},
|
|
2806
|
+
"Project initialized successfully using full project endpoint"
|
|
2807
|
+
);
|
|
2808
|
+
} catch (error) {
|
|
2809
|
+
logger9.error(
|
|
2810
|
+
{
|
|
2811
|
+
projectId: this.projectId,
|
|
2812
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
2813
|
+
},
|
|
2814
|
+
"Failed to initialize project using full project endpoint"
|
|
2815
|
+
);
|
|
2816
|
+
throw error;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
/**
|
|
2820
|
+
* Get the project ID
|
|
2821
|
+
*/
|
|
2822
|
+
getId() {
|
|
2823
|
+
return this.projectId;
|
|
2824
|
+
}
|
|
2825
|
+
/**
|
|
2826
|
+
* Get the project name
|
|
2827
|
+
*/
|
|
2828
|
+
getName() {
|
|
2829
|
+
return this.projectName;
|
|
2830
|
+
}
|
|
2831
|
+
/**
|
|
2832
|
+
* Get the project description
|
|
2833
|
+
*/
|
|
2834
|
+
getDescription() {
|
|
2835
|
+
return this.projectDescription;
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Get the tenant ID
|
|
2839
|
+
*/
|
|
2840
|
+
getTenantId() {
|
|
2841
|
+
return this.tenantId;
|
|
2842
|
+
}
|
|
2843
|
+
/**
|
|
2844
|
+
* Get the project's model configuration
|
|
2845
|
+
*/
|
|
2846
|
+
getModels() {
|
|
2847
|
+
return this.models;
|
|
2848
|
+
}
|
|
2849
|
+
/**
|
|
2850
|
+
* Set the project's model configuration
|
|
2851
|
+
*/
|
|
2852
|
+
setModels(models) {
|
|
2853
|
+
this.models = models;
|
|
2854
|
+
}
|
|
2855
|
+
/**
|
|
2856
|
+
* Get the project's stopWhen configuration
|
|
2857
|
+
*/
|
|
2858
|
+
getStopWhen() {
|
|
2859
|
+
return this.stopWhen;
|
|
2860
|
+
}
|
|
2861
|
+
/**
|
|
2862
|
+
* Set the project's stopWhen configuration
|
|
2863
|
+
*/
|
|
2864
|
+
setStopWhen(stopWhen) {
|
|
2865
|
+
this.stopWhen = stopWhen;
|
|
2866
|
+
}
|
|
2867
|
+
/**
|
|
2868
|
+
* Get all graphs in the project
|
|
2869
|
+
*/
|
|
2870
|
+
getGraphs() {
|
|
2871
|
+
return this.graphs;
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Get a graph by ID
|
|
2875
|
+
*/
|
|
2876
|
+
getGraph(id) {
|
|
2877
|
+
return this.graphMap.get(id);
|
|
2878
|
+
}
|
|
2879
|
+
/**
|
|
2880
|
+
* Add a graph to the project
|
|
2881
|
+
*/
|
|
2882
|
+
addGraph(graph) {
|
|
2883
|
+
this.graphs.push(graph);
|
|
2884
|
+
this.graphMap.set(graph.getId(), graph);
|
|
2885
|
+
graph.setConfig(this.tenantId, this.projectId, this.baseURL);
|
|
2886
|
+
logger9.info(
|
|
2887
|
+
{
|
|
2888
|
+
projectId: this.projectId,
|
|
2889
|
+
graphId: graph.getId()
|
|
2890
|
+
},
|
|
2891
|
+
"Graph added to project"
|
|
2892
|
+
);
|
|
2893
|
+
}
|
|
2894
|
+
/**
|
|
2895
|
+
* Remove a graph from the project
|
|
2896
|
+
*/
|
|
2897
|
+
removeGraph(id) {
|
|
2898
|
+
const graphToRemove = this.graphMap.get(id);
|
|
2899
|
+
if (graphToRemove) {
|
|
2900
|
+
this.graphMap.delete(id);
|
|
2901
|
+
this.graphs = this.graphs.filter((graph) => graph.getId() !== id);
|
|
2902
|
+
logger9.info(
|
|
2903
|
+
{
|
|
2904
|
+
projectId: this.projectId,
|
|
2905
|
+
graphId: id
|
|
2906
|
+
},
|
|
2907
|
+
"Graph removed from project"
|
|
2908
|
+
);
|
|
2909
|
+
return true;
|
|
2910
|
+
}
|
|
2911
|
+
return false;
|
|
2912
|
+
}
|
|
2913
|
+
/**
|
|
2914
|
+
* Get project statistics
|
|
2915
|
+
*/
|
|
2916
|
+
getStats() {
|
|
2917
|
+
return {
|
|
2918
|
+
projectId: this.projectId,
|
|
2919
|
+
tenantId: this.tenantId,
|
|
2920
|
+
graphCount: this.graphs.length,
|
|
2921
|
+
initialized: this.initialized
|
|
2922
|
+
};
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2925
|
+
* Validate the project configuration
|
|
2926
|
+
*/
|
|
2927
|
+
validate() {
|
|
2928
|
+
const errors = [];
|
|
2929
|
+
if (!this.projectId) {
|
|
2930
|
+
errors.push("Project must have an ID");
|
|
2931
|
+
}
|
|
2932
|
+
if (!this.projectName) {
|
|
2933
|
+
errors.push("Project must have a name");
|
|
2934
|
+
}
|
|
2935
|
+
const graphIds = /* @__PURE__ */ new Set();
|
|
2936
|
+
for (const graph of this.graphs) {
|
|
2937
|
+
const id = graph.getId();
|
|
2938
|
+
if (graphIds.has(id)) {
|
|
2939
|
+
errors.push(`Duplicate graph ID: ${id}`);
|
|
2940
|
+
}
|
|
2941
|
+
graphIds.add(id);
|
|
2942
|
+
}
|
|
2943
|
+
for (const graph of this.graphs) {
|
|
2944
|
+
const graphValidation = graph.validate();
|
|
2945
|
+
if (!graphValidation.valid) {
|
|
2946
|
+
errors.push(...graphValidation.errors.map((error) => `Graph '${graph.getId()}': ${error}`));
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
return {
|
|
2950
|
+
valid: errors.length === 0,
|
|
2951
|
+
errors
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
/**
|
|
2955
|
+
* Convert the Project to FullProjectDefinition format
|
|
2956
|
+
*/
|
|
2957
|
+
async toFullProjectDefinition() {
|
|
2958
|
+
const graphsObject = {};
|
|
2959
|
+
for (const graph of this.graphs) {
|
|
2960
|
+
const graphDefinition = await graph.toFullGraphDefinition();
|
|
2961
|
+
graphsObject[graph.getId()] = graphDefinition;
|
|
2962
|
+
}
|
|
2963
|
+
return {
|
|
2964
|
+
id: this.projectId,
|
|
2965
|
+
name: this.projectName,
|
|
2966
|
+
description: this.projectDescription || "",
|
|
2967
|
+
models: this.models,
|
|
2968
|
+
stopWhen: this.stopWhen,
|
|
2969
|
+
graphs: graphsObject,
|
|
2970
|
+
tools: {},
|
|
2971
|
+
// Empty tools object as SDK doesn't manage tools directly yet
|
|
2972
|
+
credentialReferences: void 0,
|
|
2973
|
+
// Projects don't directly hold credentials yet
|
|
2974
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2975
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
/**
|
|
2979
|
+
* Convert project configuration to API format
|
|
2980
|
+
*/
|
|
2981
|
+
toApiFormat() {
|
|
2982
|
+
return {
|
|
2983
|
+
id: this.projectId,
|
|
2984
|
+
name: this.projectName,
|
|
2985
|
+
description: this.projectDescription || "",
|
|
2986
|
+
models: this.models,
|
|
2987
|
+
stopWhen: this.stopWhen
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
};
|
|
2486
2991
|
|
|
2487
2992
|
// src/utils/generateIdFromName.ts
|
|
2488
2993
|
function generateIdFromName3(name) {
|
|
@@ -2493,6 +2998,9 @@ function generateIdFromName3(name) {
|
|
|
2493
2998
|
function agentGraph(config) {
|
|
2494
2999
|
return new AgentGraph(config);
|
|
2495
3000
|
}
|
|
3001
|
+
function project(config) {
|
|
3002
|
+
return new Project(config);
|
|
3003
|
+
}
|
|
2496
3004
|
function agent(config) {
|
|
2497
3005
|
if (!config.id) {
|
|
2498
3006
|
throw new Error(
|
|
@@ -2621,7 +3129,7 @@ var MaxTurnsExceededError = class extends AgentError {
|
|
|
2621
3129
|
};
|
|
2622
3130
|
|
|
2623
3131
|
// src/runner.ts
|
|
2624
|
-
var
|
|
3132
|
+
var logger10 = agentsCore.getLogger("runner");
|
|
2625
3133
|
var Runner = class _Runner {
|
|
2626
3134
|
/**
|
|
2627
3135
|
* Run a graph until completion, handling transfers and tool calls
|
|
@@ -2633,7 +3141,7 @@ var Runner = class _Runner {
|
|
|
2633
3141
|
let turnCount = 0;
|
|
2634
3142
|
const messageHistory = _Runner.normalizeToMessageHistory(messages);
|
|
2635
3143
|
const allToolCalls = [];
|
|
2636
|
-
|
|
3144
|
+
logger10.info(
|
|
2637
3145
|
{
|
|
2638
3146
|
graphId: graph.getId(),
|
|
2639
3147
|
defaultAgent: graph.getDefaultAgent()?.getName(),
|
|
@@ -2643,7 +3151,7 @@ var Runner = class _Runner {
|
|
|
2643
3151
|
"Starting graph run"
|
|
2644
3152
|
);
|
|
2645
3153
|
while (turnCount < maxTurns) {
|
|
2646
|
-
|
|
3154
|
+
logger10.debug(
|
|
2647
3155
|
{
|
|
2648
3156
|
graphId: graph.getId(),
|
|
2649
3157
|
turnCount,
|
|
@@ -2653,7 +3161,7 @@ var Runner = class _Runner {
|
|
|
2653
3161
|
);
|
|
2654
3162
|
const response = await graph.generate(messageHistory, options);
|
|
2655
3163
|
turnCount++;
|
|
2656
|
-
|
|
3164
|
+
logger10.info(
|
|
2657
3165
|
{
|
|
2658
3166
|
graphId: graph.getId(),
|
|
2659
3167
|
turnCount,
|
|
@@ -2673,7 +3181,7 @@ var Runner = class _Runner {
|
|
|
2673
3181
|
}
|
|
2674
3182
|
};
|
|
2675
3183
|
}
|
|
2676
|
-
|
|
3184
|
+
logger10.error(
|
|
2677
3185
|
{
|
|
2678
3186
|
graphId: graph.getId(),
|
|
2679
3187
|
maxTurns,
|
|
@@ -2687,7 +3195,7 @@ var Runner = class _Runner {
|
|
|
2687
3195
|
* Stream a graph's response
|
|
2688
3196
|
*/
|
|
2689
3197
|
static async stream(graph, messages, options) {
|
|
2690
|
-
|
|
3198
|
+
logger10.info(
|
|
2691
3199
|
{
|
|
2692
3200
|
graphId: graph.getId(),
|
|
2693
3201
|
defaultAgent: graph.getDefaultAgent()?.getName()
|
|
@@ -2703,7 +3211,7 @@ var Runner = class _Runner {
|
|
|
2703
3211
|
if (graphs.length === 0) {
|
|
2704
3212
|
throw new Error("No graphs provided for race");
|
|
2705
3213
|
}
|
|
2706
|
-
|
|
3214
|
+
logger10.info(
|
|
2707
3215
|
{
|
|
2708
3216
|
graphCount: graphs.length,
|
|
2709
3217
|
graphIds: graphs.map((g) => g.getId())
|
|
@@ -2715,7 +3223,7 @@ var Runner = class _Runner {
|
|
|
2715
3223
|
const result2 = await _Runner.run(graph, messages, options);
|
|
2716
3224
|
return { ...result2, raceIndex: index };
|
|
2717
3225
|
} catch (error) {
|
|
2718
|
-
|
|
3226
|
+
logger10.error(
|
|
2719
3227
|
{
|
|
2720
3228
|
graphId: graph.getId(),
|
|
2721
3229
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -2726,7 +3234,7 @@ var Runner = class _Runner {
|
|
|
2726
3234
|
}
|
|
2727
3235
|
});
|
|
2728
3236
|
const result = await Promise.race(promises);
|
|
2729
|
-
|
|
3237
|
+
logger10.info(
|
|
2730
3238
|
{
|
|
2731
3239
|
winningGraphId: result.graphId || "unknown",
|
|
2732
3240
|
raceIndex: result.raceIndex
|
|
@@ -2804,6 +3312,7 @@ exports.Agent = Agent;
|
|
|
2804
3312
|
exports.ArtifactComponent = ArtifactComponent;
|
|
2805
3313
|
exports.DataComponent = DataComponent;
|
|
2806
3314
|
exports.ExternalAgent = ExternalAgent;
|
|
3315
|
+
exports.Project = Project;
|
|
2807
3316
|
exports.Runner = Runner;
|
|
2808
3317
|
exports.Tool = Tool;
|
|
2809
3318
|
exports.agent = agent;
|
|
@@ -2811,14 +3320,19 @@ exports.agentGraph = agentGraph;
|
|
|
2811
3320
|
exports.agentMcp = agentMcp;
|
|
2812
3321
|
exports.artifactComponent = artifactComponent;
|
|
2813
3322
|
exports.createEnvironmentSettings = createEnvironmentSettings;
|
|
3323
|
+
exports.createFullProjectViaAPI = createFullProjectViaAPI;
|
|
2814
3324
|
exports.credential = credential;
|
|
2815
3325
|
exports.dataComponent = dataComponent;
|
|
3326
|
+
exports.deleteFullProjectViaAPI = deleteFullProjectViaAPI;
|
|
2816
3327
|
exports.externalAgent = externalAgent;
|
|
2817
3328
|
exports.externalAgents = externalAgents;
|
|
3329
|
+
exports.getFullProjectViaAPI = getFullProjectViaAPI;
|
|
2818
3330
|
exports.mcpServer = mcpServer;
|
|
2819
3331
|
exports.mcpTool = mcpTool;
|
|
3332
|
+
exports.project = project;
|
|
2820
3333
|
exports.raceGraphs = raceGraphs;
|
|
2821
3334
|
exports.registerEnvironmentSettings = registerEnvironmentSettings;
|
|
2822
3335
|
exports.run = run;
|
|
2823
3336
|
exports.stream = stream;
|
|
2824
3337
|
exports.transfer = transfer;
|
|
3338
|
+
exports.updateFullProjectViaAPI = updateFullProjectViaAPI;
|