@inkeep/agents-sdk 0.41.2 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +356 -2
- package/dist/agent.d.ts +84 -73
- package/dist/agent.js +42 -4
- package/dist/agentFullClient.d.ts +8 -8
- package/dist/agentFullClient.js +4 -4
- package/dist/artifact-component.d.ts +8 -8
- package/dist/artifact-component.js +2 -2
- package/dist/builderFunctions.d.ts +337 -248
- package/dist/builderFunctions.js +131 -2
- package/dist/builderFunctionsExperimental.d.ts +17 -17
- package/dist/builders.d.ts +48 -48
- package/dist/credential-provider.d.ts +93 -93
- package/dist/credential-provider.js +1 -1
- package/dist/credential-ref.d.ts +37 -37
- package/dist/data-component.d.ts +9 -9
- package/dist/data-component.js +2 -2
- package/dist/environment-settings.d.ts +4 -4
- package/dist/evaluationClient.d.ts +78 -0
- package/dist/evaluationClient.js +1202 -0
- package/dist/external-agent.d.ts +17 -17
- package/dist/external-agent.js +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/module-hosted-tool-manager.d.ts +1 -1
- package/dist/module-hosted-tool-manager.js +1 -1
- package/dist/project.d.ts +83 -83
- package/dist/project.js +23 -4
- package/dist/projectFullClient.d.ts +8 -8
- package/dist/projectFullClient.js +4 -4
- package/dist/runner.d.ts +15 -15
- package/dist/status-component.d.ts +3 -3
- package/dist/subAgent.d.ts +2 -2
- package/dist/subAgent.js +7 -7
- package/dist/telemetry-provider.d.ts +76 -76
- package/dist/tool.d.ts +16 -16
- package/dist/tool.js +23 -3
- package/dist/trigger.d.ts +46 -0
- package/dist/trigger.js +65 -0
- package/dist/types.d.ts +31 -22
- package/dist/utils/generateIdFromName.d.ts +4 -4
- package/dist/utils/tool-normalization.d.ts +10 -10
- package/dist/utils/validateFunction.d.ts +5 -5
- package/package.json +2 -2
package/dist/agent.js
CHANGED
|
@@ -27,6 +27,8 @@ var Agent = class {
|
|
|
27
27
|
statusUpdateSettings;
|
|
28
28
|
prompt;
|
|
29
29
|
stopWhen;
|
|
30
|
+
triggers = [];
|
|
31
|
+
triggerMap = /* @__PURE__ */ new Map();
|
|
30
32
|
constructor(config) {
|
|
31
33
|
this.defaultSubAgent = config.defaultSubAgent;
|
|
32
34
|
this.tenantId = "default";
|
|
@@ -43,6 +45,8 @@ var Agent = class {
|
|
|
43
45
|
this.stopWhen = config.stopWhen ? { transferCountIs: config.stopWhen.transferCountIs } : void 0;
|
|
44
46
|
this.subAgents = resolveGetter(config.subAgents) || [];
|
|
45
47
|
this.agentMap = new Map(this.subAgents.map((agent$1) => [agent$1.getId(), agent$1]));
|
|
48
|
+
this.triggers = resolveGetter(config.triggers) || [];
|
|
49
|
+
this.triggerMap = new Map(this.triggers.map((trigger) => [trigger.getId(), trigger]));
|
|
46
50
|
if (this.defaultSubAgent) {
|
|
47
51
|
if (!this.subAgents.some((agent$1) => agent$1.getId() === this.defaultSubAgent?.getId())) this.subAgents.push(this.defaultSubAgent);
|
|
48
52
|
this.agentMap.set(this.defaultSubAgent.getId(), this.defaultSubAgent);
|
|
@@ -52,8 +56,9 @@ var Agent = class {
|
|
|
52
56
|
agentId: this.agentId,
|
|
53
57
|
tenantId: this.tenantId,
|
|
54
58
|
agentCount: this.subAgents.length,
|
|
55
|
-
defaultSubAgent: this.defaultSubAgent?.getName()
|
|
56
|
-
|
|
59
|
+
defaultSubAgent: this.defaultSubAgent?.getName(),
|
|
60
|
+
triggerCount: this.triggers.length
|
|
61
|
+
}, "Agent initialized");
|
|
57
62
|
}
|
|
58
63
|
/**
|
|
59
64
|
* Set or update the configuration (tenantId, projectId and apiUrl)
|
|
@@ -77,7 +82,7 @@ var Agent = class {
|
|
|
77
82
|
tenantId: this.tenantId,
|
|
78
83
|
projectId: this.projectId,
|
|
79
84
|
apiUrl: this.baseURL
|
|
80
|
-
}, "Agent
|
|
85
|
+
}, "Agent configured");
|
|
81
86
|
}
|
|
82
87
|
/**
|
|
83
88
|
* Convert the Agent to FullAgentDefinition format for the new agent endpoint
|
|
@@ -221,6 +226,16 @@ var Agent = class {
|
|
|
221
226
|
}
|
|
222
227
|
}
|
|
223
228
|
}
|
|
229
|
+
const triggersObject = {};
|
|
230
|
+
for (const [triggerId, trigger] of this.triggerMap.entries()) {
|
|
231
|
+
const config = trigger.getConfig();
|
|
232
|
+
let processedInputSchema = config.inputSchema;
|
|
233
|
+
if (config.inputSchema && isZodSchema(config.inputSchema)) processedInputSchema = convertZodToJsonSchema(config.inputSchema);
|
|
234
|
+
triggersObject[triggerId] = {
|
|
235
|
+
...config,
|
|
236
|
+
inputSchema: processedInputSchema
|
|
237
|
+
};
|
|
238
|
+
}
|
|
224
239
|
return {
|
|
225
240
|
id: this.agentId,
|
|
226
241
|
name: this.agentName,
|
|
@@ -231,6 +246,7 @@ var Agent = class {
|
|
|
231
246
|
contextConfig: this.contextConfig?.toObject(),
|
|
232
247
|
...Object.keys(functionToolsObject).length > 0 && { functionTools: functionToolsObject },
|
|
233
248
|
...Object.keys(functionsObject).length > 0 && { functions: functionsObject },
|
|
249
|
+
triggers: triggersObject,
|
|
234
250
|
models: this.models,
|
|
235
251
|
stopWhen: this.stopWhen,
|
|
236
252
|
statusUpdates: processedStatusUpdates,
|
|
@@ -437,6 +453,28 @@ var Agent = class {
|
|
|
437
453
|
return this.defaultSubAgent;
|
|
438
454
|
}
|
|
439
455
|
/**
|
|
456
|
+
* Get all triggers for this agent
|
|
457
|
+
*/
|
|
458
|
+
getTriggers() {
|
|
459
|
+
const triggersObject = {};
|
|
460
|
+
for (const [id, trigger] of this.triggerMap.entries()) triggersObject[id] = trigger;
|
|
461
|
+
return triggersObject;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Add one or more triggers to the agent at runtime
|
|
465
|
+
*/
|
|
466
|
+
addTrigger(...triggers) {
|
|
467
|
+
for (const trigger of triggers) {
|
|
468
|
+
this.triggers.push(trigger);
|
|
469
|
+
this.triggerMap.set(trigger.getId(), trigger);
|
|
470
|
+
logger.info({
|
|
471
|
+
agentId: this.agentId,
|
|
472
|
+
triggerId: trigger.getId(),
|
|
473
|
+
triggerName: trigger.getName()
|
|
474
|
+
}, "Trigger added to agent");
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
440
478
|
* Get the agent ID
|
|
441
479
|
*/
|
|
442
480
|
getId() {
|
|
@@ -624,7 +662,7 @@ var Agent = class {
|
|
|
624
662
|
*/
|
|
625
663
|
async executeWithBackend(input, options) {
|
|
626
664
|
const normalizedMessages = this.normalizeMessages(input);
|
|
627
|
-
const url = `${this.baseURL}/
|
|
665
|
+
const url = `${this.baseURL}/run/v1/chat/completions`;
|
|
628
666
|
logger.info({ url }, "Executing with backend");
|
|
629
667
|
const requestBody = {
|
|
630
668
|
model: "gpt-4o-mini",
|
|
@@ -3,20 +3,20 @@ import { FullAgentDefinition } from "@inkeep/agents-core";
|
|
|
3
3
|
//#region src/agentFullClient.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* Create a full agent via HTTP API
|
|
7
|
+
*/
|
|
8
8
|
declare function createFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentData: FullAgentDefinition): Promise<FullAgentDefinition>;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Update a full agent via HTTP API (upsert behavior)
|
|
11
|
+
*/
|
|
12
12
|
declare function updateFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string, agentData: FullAgentDefinition): Promise<FullAgentDefinition>;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* Get a full agent via HTTP API
|
|
15
|
+
*/
|
|
16
16
|
declare function getFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string): Promise<FullAgentDefinition | null>;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* Delete a full agent via HTTP API
|
|
19
|
+
*/
|
|
20
20
|
declare function deleteFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string): Promise<void>;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { createFullAgentViaAPI, deleteFullAgentViaAPI, getFullAgentViaAPI, updateFullAgentViaAPI };
|
package/dist/agentFullClient.js
CHANGED
|
@@ -13,7 +13,7 @@ async function createFullAgentViaAPI(tenantId, projectId, apiUrl, agentData) {
|
|
|
13
13
|
agentId: agentData.id,
|
|
14
14
|
apiUrl
|
|
15
15
|
}, "Creating full agent via API");
|
|
16
|
-
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent`;
|
|
16
|
+
const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent`;
|
|
17
17
|
const response = await fetch(url, {
|
|
18
18
|
method: "POST",
|
|
19
19
|
headers: { "Content-Type": "application/json" },
|
|
@@ -41,7 +41,7 @@ async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agent
|
|
|
41
41
|
agentId,
|
|
42
42
|
apiUrl
|
|
43
43
|
}, "Updating full agent via API");
|
|
44
|
-
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
44
|
+
const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
45
45
|
const response = await fetch(url, {
|
|
46
46
|
method: "PUT",
|
|
47
47
|
headers: { "Content-Type": "application/json" },
|
|
@@ -69,7 +69,7 @@ async function getFullAgentViaAPI(tenantId, projectId, apiUrl, agentId) {
|
|
|
69
69
|
agentId,
|
|
70
70
|
apiUrl
|
|
71
71
|
}, "Getting full agent via API");
|
|
72
|
-
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
72
|
+
const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
73
73
|
const response = await fetch(url, {
|
|
74
74
|
method: "GET",
|
|
75
75
|
headers: { "Content-Type": "application/json" }
|
|
@@ -100,7 +100,7 @@ async function deleteFullAgentViaAPI(tenantId, projectId, apiUrl, agentId) {
|
|
|
100
100
|
agentId,
|
|
101
101
|
apiUrl
|
|
102
102
|
}, "Deleting full agent via API");
|
|
103
|
-
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
103
|
+
const url = `${apiUrl}/manage/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
104
104
|
const response = await fetch(url, {
|
|
105
105
|
method: "DELETE",
|
|
106
106
|
headers: { "Content-Type": "application/json" }
|
|
@@ -2,20 +2,20 @@ import { ArtifactComponentInsert } from "@inkeep/agents-core";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/artifact-component.d.ts
|
|
5
|
-
type ArtifactComponentConfigWithZod = Omit<ArtifactComponentInsert,
|
|
5
|
+
type ArtifactComponentConfigWithZod = Omit<ArtifactComponentInsert, "tenantId" | "projectId" | "props"> & {
|
|
6
6
|
props?: Record<string, unknown> | z.ZodObject<any> | null;
|
|
7
7
|
};
|
|
8
8
|
interface ArtifactComponentInterface {
|
|
9
|
-
config: Omit<ArtifactComponentInsert,
|
|
9
|
+
config: Omit<ArtifactComponentInsert, "tenantId" | "projectId">;
|
|
10
10
|
init(): Promise<void>;
|
|
11
|
-
getId(): ArtifactComponentInsert[
|
|
12
|
-
getName(): ArtifactComponentInsert[
|
|
13
|
-
getDescription(): ArtifactComponentInsert[
|
|
14
|
-
getProps(): ArtifactComponentInsert[
|
|
11
|
+
getId(): ArtifactComponentInsert["id"];
|
|
12
|
+
getName(): ArtifactComponentInsert["name"];
|
|
13
|
+
getDescription(): ArtifactComponentInsert["description"];
|
|
14
|
+
getProps(): ArtifactComponentInsert["props"];
|
|
15
15
|
setContext(tenantId: string, projectId: string, baseURL?: string): void;
|
|
16
16
|
}
|
|
17
17
|
declare class ArtifactComponent implements ArtifactComponentInterface {
|
|
18
|
-
config: Omit<ArtifactComponentInsert,
|
|
18
|
+
config: Omit<ArtifactComponentInsert, "tenantId" | "projectId">;
|
|
19
19
|
private baseURL;
|
|
20
20
|
private tenantId;
|
|
21
21
|
private projectId;
|
|
@@ -26,7 +26,7 @@ declare class ArtifactComponent implements ArtifactComponentInterface {
|
|
|
26
26
|
getId(): string;
|
|
27
27
|
getName(): string;
|
|
28
28
|
getDescription(): string;
|
|
29
|
-
getProps(): ArtifactComponentInsert[
|
|
29
|
+
getProps(): ArtifactComponentInsert["props"];
|
|
30
30
|
init(): Promise<void>;
|
|
31
31
|
private upsertArtifactComponent;
|
|
32
32
|
}
|
|
@@ -68,7 +68,7 @@ var ArtifactComponent = class {
|
|
|
68
68
|
props: this.config.props
|
|
69
69
|
};
|
|
70
70
|
logger.info({ artifactComponentData }, "artifactComponentData for create/update");
|
|
71
|
-
const updateResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components/${this.getId()}`, {
|
|
71
|
+
const updateResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components/${this.getId()}`, {
|
|
72
72
|
method: "PUT",
|
|
73
73
|
headers: { "Content-Type": "application/json" },
|
|
74
74
|
body: JSON.stringify(artifactComponentData)
|
|
@@ -83,7 +83,7 @@ var ArtifactComponent = class {
|
|
|
83
83
|
}
|
|
84
84
|
if (updateResponse.status === 404) {
|
|
85
85
|
logger.info({ artifactComponentId: this.getId() }, "ArtifactComponent not found, creating new artifact component");
|
|
86
|
-
const createResponse = await fetch(`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components`, {
|
|
86
|
+
const createResponse = await fetch(`${this.baseURL}/manage/tenants/${this.tenantId}/projects/${this.projectId}/artifact-components`, {
|
|
87
87
|
method: "POST",
|
|
88
88
|
headers: { "Content-Type": "application/json" },
|
|
89
89
|
body: JSON.stringify(artifactComponentData)
|