@inkeep/agents-sdk 0.0.0-dev-20250910233133
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/LICENSE.md +56 -0
- package/README.md +53 -0
- package/dist/__tests__/utils/testTenant.d.ts +7 -0
- package/dist/__tests__/utils/testTenant.d.ts.map +1 -0
- package/dist/__tests__/utils/testTenant.js +10 -0
- package/dist/__tests__/utils/testTenant.js.map +1 -0
- package/dist/agent.d.ts +39 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +513 -0
- package/dist/agent.js.map +1 -0
- package/dist/artifact-component.d.ts +27 -0
- package/dist/artifact-component.d.ts.map +1 -0
- package/dist/artifact-component.js +118 -0
- package/dist/artifact-component.js.map +1 -0
- package/dist/builders.d.ts +211 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +244 -0
- package/dist/builders.js.map +1 -0
- package/dist/data-component.d.ts +25 -0
- package/dist/data-component.d.ts.map +1 -0
- package/dist/data-component.js +114 -0
- package/dist/data-component.js.map +1 -0
- package/dist/environment-settings.d.ts +28 -0
- package/dist/environment-settings.d.ts.map +1 -0
- package/dist/environment-settings.js +79 -0
- package/dist/environment-settings.js.map +1 -0
- package/dist/externalAgent.d.ts +58 -0
- package/dist/externalAgent.d.ts.map +1 -0
- package/dist/externalAgent.js +163 -0
- package/dist/externalAgent.js.map +1 -0
- package/dist/graph.d.ts +200 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +1322 -0
- package/dist/graph.js.map +1 -0
- package/dist/graphFullClient.d.ts +22 -0
- package/dist/graphFullClient.d.ts.map +1 -0
- package/dist/graphFullClient.js +189 -0
- package/dist/graphFullClient.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/module-hosted-tool-manager.d.ts +37 -0
- package/dist/module-hosted-tool-manager.d.ts.map +1 -0
- package/dist/module-hosted-tool-manager.js +378 -0
- package/dist/module-hosted-tool-manager.js.map +1 -0
- package/dist/runner.d.ts +38 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +164 -0
- package/dist/runner.js.map +1 -0
- package/dist/tool.d.ts +29 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +122 -0
- package/dist/tool.js.map +1 -0
- package/dist/types.d.ts +286 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +39 -0
- package/dist/types.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { generateIdFromName, getLogger, } from "@inkeep/agents-core";
|
|
2
|
+
const logger = getLogger("dataComponent");
|
|
3
|
+
export class DataComponent {
|
|
4
|
+
config;
|
|
5
|
+
baseURL;
|
|
6
|
+
tenantId;
|
|
7
|
+
projectId;
|
|
8
|
+
initialized = false;
|
|
9
|
+
id;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.id = generateIdFromName(config.name);
|
|
12
|
+
this.config = {
|
|
13
|
+
...config,
|
|
14
|
+
id: this.id,
|
|
15
|
+
tenantId: config.tenantId || "default",
|
|
16
|
+
projectId: config.projectId || "default",
|
|
17
|
+
};
|
|
18
|
+
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
19
|
+
this.tenantId = this.config.tenantId;
|
|
20
|
+
this.projectId = this.config.projectId;
|
|
21
|
+
logger.info({
|
|
22
|
+
dataComponentId: this.getId(),
|
|
23
|
+
dataComponentName: config.name,
|
|
24
|
+
}, "DataComponent constructor initialized");
|
|
25
|
+
}
|
|
26
|
+
// Compute ID from name using same slug transformation as agents
|
|
27
|
+
getId() {
|
|
28
|
+
return this.id;
|
|
29
|
+
}
|
|
30
|
+
getName() {
|
|
31
|
+
return this.config.name;
|
|
32
|
+
}
|
|
33
|
+
getDescription() {
|
|
34
|
+
return this.config.description;
|
|
35
|
+
}
|
|
36
|
+
getProps() {
|
|
37
|
+
return this.config.props;
|
|
38
|
+
}
|
|
39
|
+
// Public method to ensure data component exists in backend (with upsert behavior)
|
|
40
|
+
async init() {
|
|
41
|
+
if (this.initialized)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
// Always attempt to upsert the data component
|
|
45
|
+
await this.upsertDataComponent();
|
|
46
|
+
logger.info({
|
|
47
|
+
dataComponentId: this.getId(),
|
|
48
|
+
}, "DataComponent initialized successfully");
|
|
49
|
+
this.initialized = true;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
logger.error({
|
|
53
|
+
dataComponentId: this.getId(),
|
|
54
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
55
|
+
}, "Failed to initialize data component");
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Private method to upsert data component (create or update)
|
|
60
|
+
async upsertDataComponent() {
|
|
61
|
+
const dataComponentData = {
|
|
62
|
+
id: this.getId(),
|
|
63
|
+
name: this.config.name,
|
|
64
|
+
description: this.config.description,
|
|
65
|
+
props: this.config.props,
|
|
66
|
+
};
|
|
67
|
+
logger.info({ dataComponentData }, "dataComponentData for create/update");
|
|
68
|
+
// First try to update (in case data component exists)
|
|
69
|
+
const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/crud/data-components/${this.getId()}`, {
|
|
70
|
+
method: "PUT",
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify(dataComponentData),
|
|
75
|
+
});
|
|
76
|
+
logger.info({
|
|
77
|
+
status: updateResponse.status,
|
|
78
|
+
dataComponentId: this.getId(),
|
|
79
|
+
}, "data component updateResponse");
|
|
80
|
+
if (updateResponse.ok) {
|
|
81
|
+
logger.info({
|
|
82
|
+
dataComponentId: this.getId(),
|
|
83
|
+
}, "DataComponent updated successfully");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// If update failed with 404, data component doesn't exist - create it
|
|
87
|
+
if (updateResponse.status === 404) {
|
|
88
|
+
logger.info({
|
|
89
|
+
dataComponentId: this.getId(),
|
|
90
|
+
}, "DataComponent not found, creating new data component");
|
|
91
|
+
const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/crud/data-components`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: {
|
|
94
|
+
"Content-Type": "application/json",
|
|
95
|
+
},
|
|
96
|
+
body: JSON.stringify(dataComponentData),
|
|
97
|
+
});
|
|
98
|
+
if (!createResponse.ok) {
|
|
99
|
+
const errorText = await createResponse
|
|
100
|
+
.text()
|
|
101
|
+
.catch(() => "Unknown error");
|
|
102
|
+
throw new Error(`Failed to create data component: ${createResponse.status} ${createResponse.statusText} - ${errorText}`);
|
|
103
|
+
}
|
|
104
|
+
logger.info({
|
|
105
|
+
dataComponentId: this.getId(),
|
|
106
|
+
}, "DataComponent created successfully");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// If we get here, the update failed for some other reason
|
|
110
|
+
const errorText = await updateResponse.text().catch(() => "Unknown error");
|
|
111
|
+
throw new Error(`Failed to update data component: ${updateResponse.status} ${updateResponse.statusText} - ${errorText}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=data-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-component.js","sourceRoot":"","sources":["../src/data-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,kBAAkB,EAClB,SAAS,GACT,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;AAW1C,MAAM,OAAO,aAAa;IAClB,MAAM,CAAoB;IACzB,OAAO,CAAS;IAChB,QAAQ,CAAgC;IACxC,SAAS,CAAiC;IAC1C,WAAW,GAAG,KAAK,CAAC;IACpB,EAAE,CAA0B;IAEpC,YAAY,MAAqC;QAChD,IAAI,CAAC,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,I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AAC;YACnC,MAAM,CAAC,IAAI,CACV;gBACC,eAAe,EAAE,IAAI,CAAC,KAAK,EAAE;aAC7B,EACD,sDAAsD,CACtD,CAAC;YAEF,MAAM,cAAc,GAAG,MAAM,KAAK,CACjC,GAAG,IAAI,CAAC,OAAO,YAAY,IAAI,CAAC,QAAQ,uBAAuB,EAC/D;gBACC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACR,cAAc,EAAE,kBAAkB;iBAClC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;aACvC,CACD,CAAC;YAEF,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;gBACxB,MAAM,SAAS,GAAG,MAAM,cAAc;qBACpC,IAAI,EAAE;qBACN,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;gBAC/B,MAAM,IAAI,KAAK,CACd,oCAAoC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,UAAU,MAAM,SAAS,EAAE,CACvG,CAAC;YACH,CAAC;YAED,MAAM,CAAC,IAAI,CACV;gBACC,eAAe,EAAE,IAAI,CAAC,KAAK,EAAE;aAC7B,EACD,oCAAoC,CACpC,CAAC;YACF,OAAO;QACR,CAAC;QAED,0DAA0D;QAC1D,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;QAC3E,MAAM,IAAI,KAAK,CACd,oCAAoC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,UAAU,MAAM,SAAS,EAAE,CACvG,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CredentialReferenceApiInsert } from "@inkeep/agents-core";
|
|
2
|
+
interface EnvironmentSettingsConfig {
|
|
3
|
+
credentials?: {
|
|
4
|
+
[settingId: string]: CredentialReferenceApiInsert;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export type ExtractSettingKeys<T> = T extends {
|
|
8
|
+
credentials: infer B;
|
|
9
|
+
} ? B extends Record<string, any> ? keyof B : never : never;
|
|
10
|
+
/**
|
|
11
|
+
* Get all registered setting keys across all environments
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAllEnvironmentSettingKeys(): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Create a setting helper with TypeScript autocomplete
|
|
16
|
+
* Automatically infers environment names from object keys
|
|
17
|
+
*/
|
|
18
|
+
export declare function createEnvironmentSettings<T extends Record<string, EnvironmentSettingsConfig>>(environments: T): {
|
|
19
|
+
getEnvironmentSetting: <K extends string>(key: K) => Promise<CredentialReferenceApiInsert>;
|
|
20
|
+
getEnvironmentSettingKeys: () => string[];
|
|
21
|
+
hasEnvironmentSetting: (key: string) => key is string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Create type-safe environment configurations with setting registration
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerEnvironmentSettings<T extends EnvironmentSettingsConfig>(config: T): T;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=environment-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-settings.d.ts","sourceRoot":"","sources":["../src/environment-settings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,UAAU,yBAAyB;IAClC,WAAW,CAAC,EAAE;QACb,CAAC,SAAS,EAAE,MAAM,GAAG,4BAA4B,CAAC;KAClD,CAAC;CACF;AAGD,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,WAAW,EAAE,MAAM,CAAC,CAAA;CAAE,GACnE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,MAAM,CAAC,GACP,KAAK,GACN,KAAK,CAAC;AAYT;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,EAAE,CAEvD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,EAClD,YAAY,EAAE,CAAC;4BAUe,CAAC,sBACzB,CAAC,KACJ,OAAO,CAAC,4BAA4B,CAAC;qCA6BT,MAAM,EAAE;iCAmBV,MAAM,KAAG,GAAG,UAAe;EAczD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,CAAC,SAAS,yBAAyB,EAClC,MAAM,EAAE,CAAC,GAAG,CAAC,CAQd"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Environment settings system for environment-agnostic entities management
|
|
2
|
+
// Global registry to track all setting keys across environments
|
|
3
|
+
const globalSettingKeys = new Set();
|
|
4
|
+
/**
|
|
5
|
+
* Register setting keys globally for autocomplete and runtime access
|
|
6
|
+
*/
|
|
7
|
+
function registerSettingKeys(settingIds) {
|
|
8
|
+
settingIds.forEach((id) => globalSettingKeys.add(id));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get all registered setting keys across all environments
|
|
12
|
+
*/
|
|
13
|
+
export function getAllEnvironmentSettingKeys() {
|
|
14
|
+
return Array.from(globalSettingKeys);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a setting helper with TypeScript autocomplete
|
|
18
|
+
* Automatically infers environment names from object keys
|
|
19
|
+
*/
|
|
20
|
+
export function createEnvironmentSettings(environments) {
|
|
21
|
+
// Keep environments in their original object structure
|
|
22
|
+
const environmentMap = environments;
|
|
23
|
+
const environmentNames = Object.keys(environments);
|
|
24
|
+
const allEnvironments = Object.values(environments);
|
|
25
|
+
return {
|
|
26
|
+
getEnvironmentSetting: async (key) => {
|
|
27
|
+
if (environmentNames.length === 0) {
|
|
28
|
+
throw new Error(`No environments provided to createEnvironmentSettings().\n\n` +
|
|
29
|
+
`You must pass environments as an object: createEnvironmentSettings({ development, production })`);
|
|
30
|
+
}
|
|
31
|
+
const currentEnv = process.env.NODE_ENV || "development";
|
|
32
|
+
// Find environment that matches the current NODE_ENV exactly
|
|
33
|
+
const matchingEnv = environmentMap[currentEnv];
|
|
34
|
+
if (!matchingEnv) {
|
|
35
|
+
throw new Error(`Environment '${currentEnv}' not found.\n\n` +
|
|
36
|
+
`Available environments: ${environmentNames.join(", ")}\n` +
|
|
37
|
+
`Set NODE_ENV to one of the available environments or add a '${currentEnv}' environment.`);
|
|
38
|
+
}
|
|
39
|
+
if (!matchingEnv.credentials?.[key]) {
|
|
40
|
+
throw new Error(`Credential environment setting '${key}' not found in environment '${currentEnv}'.\n\n`);
|
|
41
|
+
}
|
|
42
|
+
return matchingEnv.credentials[key];
|
|
43
|
+
},
|
|
44
|
+
getEnvironmentSettingKeys: () => {
|
|
45
|
+
if (allEnvironments.length === 0)
|
|
46
|
+
return [];
|
|
47
|
+
if (allEnvironments.length === 1)
|
|
48
|
+
return Object.keys(allEnvironments[0].credentials || {});
|
|
49
|
+
// Multiple environments - intersection logic
|
|
50
|
+
let commonKeys = new Set(Object.keys(allEnvironments[0].credentials || {}));
|
|
51
|
+
for (let i = 1; i < allEnvironments.length; i++) {
|
|
52
|
+
const envKeys = new Set(Object.keys(allEnvironments[i].credentials || {}));
|
|
53
|
+
commonKeys = new Set([...commonKeys].filter((key) => envKeys.has(key)));
|
|
54
|
+
}
|
|
55
|
+
return Array.from(commonKeys);
|
|
56
|
+
},
|
|
57
|
+
hasEnvironmentSetting: (key) => {
|
|
58
|
+
if (allEnvironments.length === 0)
|
|
59
|
+
return false;
|
|
60
|
+
if (allEnvironments.length === 1)
|
|
61
|
+
return !!(allEnvironments[0].credentials &&
|
|
62
|
+
key in allEnvironments[0].credentials);
|
|
63
|
+
// Multiple environments - must exist in ALL
|
|
64
|
+
return allEnvironments.every((env) => env.credentials && key in env.credentials);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create type-safe environment configurations with setting registration
|
|
70
|
+
*/
|
|
71
|
+
export function registerEnvironmentSettings(config) {
|
|
72
|
+
// Register setting keys globally for autocomplete
|
|
73
|
+
if (config.credentials) {
|
|
74
|
+
const settingIds = Object.keys(config.credentials);
|
|
75
|
+
registerSettingKeys(settingIds);
|
|
76
|
+
}
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=environment-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-settings.js","sourceRoot":"","sources":["../src/environment-settings.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAiB3E,gEAAgE;AAChE,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE5C;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAoB;IAChD,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAEvC,YAAe;IAChB,uDAAuD;IACvD,MAAM,cAAc,GAAG,YAAY,CAAC;IACpC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAKpD,OAAO;QACN,qBAAqB,EAAE,KAAK,EAC3B,GAAM,EACkC,EAAE;YAC1C,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CACd,8DAA8D;oBAC7D,iGAAiG,CAClG,CAAC;YACH,CAAC;YAED,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;YAEzD,6DAA6D;YAC7D,MAAM,WAAW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AG,CAAC,CAAC,CAAC,CAAC;YACzE,CAAC;YAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QACD,qBAAqB,EAAE,CAAC,GAAW,EAAsB,EAAE;YAC1D,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC/C,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC/B,OAAO,CAAC,CAAC,CACR,eAAe,CAAC,CAAC,CAAC,CAAC,WAAW;oBAC9B,GAAG,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,WAAW,CACrC,CAAC;YAEH,4CAA4C;YAC5C,OAAO,eAAe,CAAC,KAAK,CAC3B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,IAAI,GAAG,CAAC,WAAW,CAClD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAEzC,MAAS;IACV,kDAAkD;IAClD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnD,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CredentialReferenceSelect } from "@inkeep/agents-core";
|
|
2
|
+
import type { ExternalAgentInterface } from "./types";
|
|
3
|
+
export type ExternalAgentConfig = {
|
|
4
|
+
type?: "external";
|
|
5
|
+
tenantId?: string;
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
credentialReference?: CredentialReferenceSelect;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
export declare class ExternalAgent implements ExternalAgentInterface {
|
|
14
|
+
config: ExternalAgentConfig;
|
|
15
|
+
readonly type: "external";
|
|
16
|
+
private initialized;
|
|
17
|
+
private tenantId;
|
|
18
|
+
private baseURL;
|
|
19
|
+
constructor(config: ExternalAgentConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the external agent by upserting it in the database
|
|
22
|
+
*/
|
|
23
|
+
init(): Promise<void>;
|
|
24
|
+
getId(): string;
|
|
25
|
+
private upsertExternalAgent;
|
|
26
|
+
/**
|
|
27
|
+
* Get the external agent configuration
|
|
28
|
+
*/
|
|
29
|
+
getConfig(): ExternalAgentConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Get the external agent name
|
|
32
|
+
*/
|
|
33
|
+
getName(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get the external agent base URL
|
|
36
|
+
*/
|
|
37
|
+
getBaseUrl(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get the tenant ID
|
|
40
|
+
*/
|
|
41
|
+
getTenantId(): string;
|
|
42
|
+
getDescription(): string;
|
|
43
|
+
getCredentialReferenceId(): string | undefined;
|
|
44
|
+
getHeaders(): Record<string, string> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Factory function to create external agents - follows the same pattern as agent()
|
|
48
|
+
*/
|
|
49
|
+
export declare function externalAgent(config: ExternalAgentConfig): ExternalAgent;
|
|
50
|
+
/**
|
|
51
|
+
* Helper function to create multiple external agents
|
|
52
|
+
*/
|
|
53
|
+
export declare function externalAgents(configs: Record<string, ExternalAgentConfig>): Record<string, ExternalAgent>;
|
|
54
|
+
/**
|
|
55
|
+
* Helper to batch initialize external agents
|
|
56
|
+
*/
|
|
57
|
+
export declare function initializeExternalAgents(builders: ExternalAgent[]): Promise<void>;
|
|
58
|
+
//# sourceMappingURL=externalAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalAgent.d.ts","sourceRoot":"","sources":["../src/externalAgent.ts"],"names":[],"mappings":"AAAA,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AC1C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAQ/B;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,aAAa,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { getLogger } from "@inkeep/agents-core";
|
|
2
|
+
const logger = getLogger("external-agent-builder");
|
|
3
|
+
export class ExternalAgent {
|
|
4
|
+
config;
|
|
5
|
+
type = "external";
|
|
6
|
+
initialized = false;
|
|
7
|
+
tenantId;
|
|
8
|
+
baseURL;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = { ...config, type: "external" };
|
|
11
|
+
this.tenantId = config.tenantId || "default";
|
|
12
|
+
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
13
|
+
logger.debug({
|
|
14
|
+
externalAgentName: this.config.name,
|
|
15
|
+
baseUrl: this.config.baseUrl,
|
|
16
|
+
tenantId: this.config.tenantId,
|
|
17
|
+
}, "External Agent constructor initialized");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the external agent by upserting it in the database
|
|
21
|
+
*/
|
|
22
|
+
async init() {
|
|
23
|
+
if (this.initialized)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
// Always attempt to upsert the external agent
|
|
27
|
+
await this.upsertExternalAgent();
|
|
28
|
+
logger.info({
|
|
29
|
+
externalAgentId: this.getId(),
|
|
30
|
+
}, "External agent initialized successfully");
|
|
31
|
+
this.initialized = true;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
logger.error({
|
|
35
|
+
externalAgentId: this.getId(),
|
|
36
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
37
|
+
}, "Failed to initialize external agent");
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Compute ID from name using a simple slug transformation
|
|
42
|
+
getId() {
|
|
43
|
+
return this.config.id;
|
|
44
|
+
}
|
|
45
|
+
// Private method to upsert external agent (create or update)
|
|
46
|
+
async upsertExternalAgent() {
|
|
47
|
+
const externalAgentData = {
|
|
48
|
+
id: this.getId(),
|
|
49
|
+
name: this.config.name,
|
|
50
|
+
description: this.config.description,
|
|
51
|
+
baseUrl: this.config.baseUrl,
|
|
52
|
+
credentialReferenceId: this.config.credentialReference?.id || undefined,
|
|
53
|
+
headers: this.config.headers || undefined,
|
|
54
|
+
};
|
|
55
|
+
// First try to update (in case external agent exists)
|
|
56
|
+
const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/crud/external-agents/${this.getId()}`, {
|
|
57
|
+
method: "PUT",
|
|
58
|
+
headers: {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
},
|
|
61
|
+
body: JSON.stringify(externalAgentData),
|
|
62
|
+
});
|
|
63
|
+
if (updateResponse.ok) {
|
|
64
|
+
logger.info({
|
|
65
|
+
externalAgentId: this.getId(),
|
|
66
|
+
}, "External agent updated successfully");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// If update failed with 404, external agent doesn't exist - create it
|
|
70
|
+
if (updateResponse.status === 404) {
|
|
71
|
+
logger.info({
|
|
72
|
+
externalAgentId: this.getId(),
|
|
73
|
+
}, "External agent not found, creating new external agent");
|
|
74
|
+
const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/crud/external-agents`, {
|
|
75
|
+
method: "POST",
|
|
76
|
+
headers: {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify(externalAgentData),
|
|
80
|
+
});
|
|
81
|
+
if (!createResponse.ok) {
|
|
82
|
+
const errorText = await createResponse
|
|
83
|
+
.text()
|
|
84
|
+
.catch(() => "Unknown error");
|
|
85
|
+
throw new Error(`Failed to create external agent: ${createResponse.status} ${createResponse.statusText} - ${errorText}`);
|
|
86
|
+
}
|
|
87
|
+
logger.info({
|
|
88
|
+
externalAgentId: this.getId(),
|
|
89
|
+
}, "External agent created successfully");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Update failed for some other reason
|
|
93
|
+
const errorText = await updateResponse.text().catch(() => "Unknown error");
|
|
94
|
+
throw new Error(`Failed to update external agent: ${updateResponse.status} ${updateResponse.statusText} - ${errorText}`);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get the external agent configuration
|
|
98
|
+
*/
|
|
99
|
+
getConfig() {
|
|
100
|
+
return { ...this.config };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the external agent name
|
|
104
|
+
*/
|
|
105
|
+
getName() {
|
|
106
|
+
return this.config.name;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get the external agent base URL
|
|
110
|
+
*/
|
|
111
|
+
getBaseUrl() {
|
|
112
|
+
return this.config.baseUrl;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get the tenant ID
|
|
116
|
+
*/
|
|
117
|
+
getTenantId() {
|
|
118
|
+
return this.tenantId;
|
|
119
|
+
}
|
|
120
|
+
getDescription() {
|
|
121
|
+
return this.config.description || "";
|
|
122
|
+
}
|
|
123
|
+
getCredentialReferenceId() {
|
|
124
|
+
return this.config.credentialReference?.id || undefined;
|
|
125
|
+
}
|
|
126
|
+
getHeaders() {
|
|
127
|
+
return this.config.headers;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Factory function to create external agents - follows the same pattern as agent()
|
|
132
|
+
*/
|
|
133
|
+
export function externalAgent(config) {
|
|
134
|
+
return new ExternalAgent(config);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Helper function to create multiple external agents
|
|
138
|
+
*/
|
|
139
|
+
export function externalAgents(configs) {
|
|
140
|
+
const builders = {};
|
|
141
|
+
for (const [name, config] of Object.entries(configs)) {
|
|
142
|
+
builders[name] = externalAgent(config);
|
|
143
|
+
}
|
|
144
|
+
return builders;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Helper to batch initialize external agents
|
|
148
|
+
*/
|
|
149
|
+
export async function initializeExternalAgents(builders) {
|
|
150
|
+
logger.info({ count: builders.length }, "Batch initializing external agents");
|
|
151
|
+
const initPromises = builders.map(async (builder) => {
|
|
152
|
+
return await builder.init();
|
|
153
|
+
});
|
|
154
|
+
try {
|
|
155
|
+
await Promise.all(initPromises);
|
|
156
|
+
logger.info({ count: builders.length }, "All external agents initialized successfully");
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
logger.error({ error: error instanceof Error ? error.message : "Unknown error" }, "Failed to initialize some external agents");
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=externalAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalAgent.js","sourceRoot":"","sources":["../src/externalAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,MAAM,MAAM,GAAG,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAanD,MAAM,OAAO,aAAa;IAClB,MAAM,CAAsB;IACnB,IAAI,GAAG,UAAmB,CAAC;IACnC,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,CAAS;IACjB,OAAO,CAAS;IAExB,YAAY,MAA2B;QACtC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,SAAS,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,uBAAuB,CAAC;QAErE,MAAM,CAAC,KAAK,CACX;YACC,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACnC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B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ACjB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC7C,QAAyB;IAEzB,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,oCAAoC,CAAC,CAAC;IAE9E,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACnD,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACJ,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAEhC,MAAM,CAAC,IAAI,CACV,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,EAC1B,8CAA8C,CAC9C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,KAAK,CACX,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,EACnE,2CAA2C,CAC3C,CAAC;QACF,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
|
package/dist/graph.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { AgentInterface, AllAgentInterface, ExternalAgentInterface, GenerateOptions, GraphConfig, GraphInterface, MessageInput, ModelSettings, RunResult, StatusUpdateSettings, StreamResponse } from "./types";
|
|
2
|
+
export declare class AgentGraph implements GraphInterface {
|
|
3
|
+
private agents;
|
|
4
|
+
private agentMap;
|
|
5
|
+
private defaultAgent?;
|
|
6
|
+
private baseURL;
|
|
7
|
+
private tenantId;
|
|
8
|
+
private projectId;
|
|
9
|
+
private graphId;
|
|
10
|
+
private graphName;
|
|
11
|
+
private graphDescription?;
|
|
12
|
+
private initialized;
|
|
13
|
+
private contextConfig?;
|
|
14
|
+
private credentials?;
|
|
15
|
+
private models?;
|
|
16
|
+
private statusUpdateSettings?;
|
|
17
|
+
private graphPrompt?;
|
|
18
|
+
private stopWhen?;
|
|
19
|
+
private dbClient;
|
|
20
|
+
constructor(config: GraphConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Set or update the configuration (tenantId, projectId and apiUrl)
|
|
23
|
+
* This is used by the CLI to inject configuration from inkeep.config.ts
|
|
24
|
+
*/
|
|
25
|
+
setConfig(tenantId: string, projectId: string, apiUrl: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Convert the AgentGraph to FullGraphDefinition format for the new graph endpoint
|
|
28
|
+
*/
|
|
29
|
+
private toFullGraphDefinition;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize all tools in all agents (especially IPCTools that need MCP server URLs)
|
|
32
|
+
*/
|
|
33
|
+
private initializeAllTools;
|
|
34
|
+
/**
|
|
35
|
+
* Initialize the graph and all agents in the backend using the new graph endpoint
|
|
36
|
+
*/
|
|
37
|
+
init(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Legacy initialization method - kept for backward compatibility
|
|
40
|
+
* Initialize the graph and all agents in the backend using individual endpoints
|
|
41
|
+
*/
|
|
42
|
+
initLegacy(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a response using the default agent
|
|
45
|
+
*/
|
|
46
|
+
generate(input: MessageInput, options?: GenerateOptions): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Stream a response using the default agent
|
|
49
|
+
*/
|
|
50
|
+
stream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Alias for stream() method for consistency with naming patterns
|
|
53
|
+
*/
|
|
54
|
+
generateStream(input: MessageInput, options?: GenerateOptions): Promise<StreamResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Run with a specific agent from the graph
|
|
57
|
+
*/
|
|
58
|
+
runWith(agentId: string, input: MessageInput, options?: GenerateOptions): Promise<RunResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Get an agent by name (unified method for all agent types)
|
|
61
|
+
*/
|
|
62
|
+
getAgent(name: string): AllAgentInterface | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Add an agent to the graph
|
|
65
|
+
*/
|
|
66
|
+
addAgent(agent: AgentInterface): void;
|
|
67
|
+
/**
|
|
68
|
+
* Remove an agent from the graph
|
|
69
|
+
*/
|
|
70
|
+
removeAgent(id: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get all agents in the graph
|
|
73
|
+
*/
|
|
74
|
+
getAgents(): AllAgentInterface[];
|
|
75
|
+
/**
|
|
76
|
+
* Get all agent ids (unified method for all agent types)
|
|
77
|
+
*/
|
|
78
|
+
getAgentIds(): string[];
|
|
79
|
+
/**
|
|
80
|
+
* Set the default agent
|
|
81
|
+
*/
|
|
82
|
+
setDefaultAgent(agent: AgentInterface): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get the default agent
|
|
85
|
+
*/
|
|
86
|
+
getDefaultAgent(): AgentInterface | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Get the graph ID
|
|
89
|
+
*/
|
|
90
|
+
getId(): string;
|
|
91
|
+
getName(): string;
|
|
92
|
+
getDescription(): string | undefined;
|
|
93
|
+
getTenantId(): string;
|
|
94
|
+
/**
|
|
95
|
+
* Get the graph's model settingsuration
|
|
96
|
+
*/
|
|
97
|
+
getModels(): typeof this.models;
|
|
98
|
+
/**
|
|
99
|
+
* Set the graph's model settingsuration
|
|
100
|
+
*/
|
|
101
|
+
setModels(models: typeof this.models): void;
|
|
102
|
+
/**
|
|
103
|
+
* Get the graph's prompt configuration
|
|
104
|
+
*/
|
|
105
|
+
getGraphPrompt(): string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Get the graph's stopWhen configuration
|
|
108
|
+
*/
|
|
109
|
+
getStopWhen(): {
|
|
110
|
+
transferCountIs?: number;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Get the graph's status updates configuration
|
|
114
|
+
*/
|
|
115
|
+
getStatusUpdateSettings(): StatusUpdateSettings | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Get the summarizer model from the graph's model settings
|
|
118
|
+
*/
|
|
119
|
+
getSummarizerModel(): ModelSettings | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Get graph statistics
|
|
122
|
+
*/
|
|
123
|
+
getStats(): {
|
|
124
|
+
agentCount: number;
|
|
125
|
+
defaultAgent: string | null;
|
|
126
|
+
initialized: boolean;
|
|
127
|
+
graphId: string;
|
|
128
|
+
tenantId: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Validate the graph configuration
|
|
132
|
+
*/
|
|
133
|
+
validate(): {
|
|
134
|
+
valid: boolean;
|
|
135
|
+
errors: string[];
|
|
136
|
+
};
|
|
137
|
+
private _init;
|
|
138
|
+
/**
|
|
139
|
+
* Type guard to check if an agent is an internal AgentInterface
|
|
140
|
+
*/
|
|
141
|
+
isInternalAgent(agent: AllAgentInterface): agent is AgentInterface;
|
|
142
|
+
/**
|
|
143
|
+
* Get project-level model settingsuration defaults
|
|
144
|
+
*/
|
|
145
|
+
private getProjectModelDefaults;
|
|
146
|
+
/**
|
|
147
|
+
* Get project-level stopWhen configuration defaults
|
|
148
|
+
*/
|
|
149
|
+
private getProjectStopWhenDefaults;
|
|
150
|
+
/**
|
|
151
|
+
* Apply model inheritance hierarchy: Project -> Graph -> Agent
|
|
152
|
+
*/
|
|
153
|
+
private applyModelInheritance;
|
|
154
|
+
/**
|
|
155
|
+
* Apply stopWhen inheritance hierarchy: Project -> Graph -> Agent
|
|
156
|
+
*/
|
|
157
|
+
private applyStopWhenInheritance;
|
|
158
|
+
/**
|
|
159
|
+
* Propagate graph-level model settings to agents (supporting partial inheritance)
|
|
160
|
+
*/
|
|
161
|
+
private propagateModelSettingsToAgent;
|
|
162
|
+
/**
|
|
163
|
+
* Immediately propagate graph-level models to all agents during construction
|
|
164
|
+
*/
|
|
165
|
+
private propagateImmediateModelSettings;
|
|
166
|
+
/**
|
|
167
|
+
* Type guard to check if an agent is an external AgentInterface
|
|
168
|
+
*/
|
|
169
|
+
isExternalAgent(agent: AllAgentInterface): agent is ExternalAgentInterface;
|
|
170
|
+
/**
|
|
171
|
+
* Execute agent using the backend system instead of local runner
|
|
172
|
+
*/
|
|
173
|
+
private executeWithBackend;
|
|
174
|
+
/**
|
|
175
|
+
* Parse streaming response in SSE format
|
|
176
|
+
*/
|
|
177
|
+
private parseStreamingResponse;
|
|
178
|
+
/**
|
|
179
|
+
* Normalize input messages to the expected format
|
|
180
|
+
*/
|
|
181
|
+
private normalizeMessages;
|
|
182
|
+
private saveToDatabase;
|
|
183
|
+
private saveRelations;
|
|
184
|
+
private createAgentRelations;
|
|
185
|
+
private createInternalAgentRelation;
|
|
186
|
+
private createExternalAgentRelation;
|
|
187
|
+
/**
|
|
188
|
+
* Create external agents in the database
|
|
189
|
+
*/
|
|
190
|
+
private createExternalAgents;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Helper function to create graphs - OpenAI style
|
|
194
|
+
*/
|
|
195
|
+
export declare function agentGraph(config: GraphConfig): AgentGraph;
|
|
196
|
+
/**
|
|
197
|
+
* Factory function to create graph from configuration file
|
|
198
|
+
*/
|
|
199
|
+
export declare function generateGraph(configPath: string): Promise<AgentGraph>;
|
|
200
|
+
//# sourceMappingURL=graph.d.ts.map
|