@inkeep/agents-sdk 0.39.4 → 0.40.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/dist/_virtual/rolldown_runtime.js +7 -0
- package/dist/agent.d.ts +186 -0
- package/dist/agent.js +720 -0
- package/dist/agentFullClient.d.ts +22 -0
- package/dist/agentFullClient.js +120 -0
- package/dist/artifact-component.d.ts +34 -0
- package/dist/artifact-component.js +104 -0
- package/dist/builderFunctions.d.ts +283 -0
- package/dist/builderFunctions.js +327 -0
- package/dist/builderFunctionsExperimental.d.ts +24 -0
- package/dist/builderFunctionsExperimental.js +27 -0
- package/dist/builders.d.ts +111 -0
- package/dist/builders.js +52 -0
- package/dist/credential-provider.d.ts +176 -0
- package/dist/credential-provider.js +237 -0
- package/dist/credential-ref.d.ts +60 -0
- package/dist/credential-ref.js +33 -0
- package/dist/data-component.d.ts +39 -0
- package/dist/data-component.js +109 -0
- package/dist/environment-settings.d.ts +27 -0
- package/dist/environment-settings.js +41 -0
- package/dist/external-agent.d.ts +64 -0
- package/dist/external-agent.js +156 -0
- package/dist/function-tool.d.ts +37 -0
- package/dist/function-tool.js +66 -0
- package/dist/index.d.ts +19 -1825
- package/dist/index.js +19 -4058
- package/dist/module-hosted-tool-manager.d.ts +40 -0
- package/dist/module-hosted-tool-manager.js +359 -0
- package/dist/project.d.ts +214 -0
- package/dist/project.js +615 -0
- package/dist/projectFullClient.d.ts +23 -0
- package/dist/projectFullClient.js +162 -0
- package/dist/runner.d.ts +41 -0
- package/dist/runner.js +145 -0
- package/dist/status-component.d.ts +22 -0
- package/dist/status-component.js +36 -0
- package/dist/subAgent.d.ts +52 -0
- package/dist/subAgent.js +616 -0
- package/dist/telemetry-provider.d.ts +218 -0
- package/dist/telemetry-provider.js +390 -0
- package/dist/tool.d.ts +53 -0
- package/dist/tool.js +130 -0
- package/dist/types.d.ts +296 -0
- package/dist/types.js +39 -0
- package/dist/utils/generateIdFromName.d.ts +9 -0
- package/dist/utils/generateIdFromName.js +12 -0
- package/dist/utils/getFunctionToolDeps.d.ts +17 -0
- package/dist/utils/getFunctionToolDeps.js +131 -0
- package/dist/utils/tool-normalization.d.ts +42 -0
- package/dist/utils/tool-normalization.js +41 -0
- package/dist/utils/validateFunction.d.ts +10 -0
- package/dist/utils/validateFunction.js +13 -0
- package/package.json +11 -16
- package/dist/index.cjs +0 -4147
- package/dist/index.d.cts +0 -1825
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FullAgentDefinition } from "@inkeep/agents-core";
|
|
2
|
+
|
|
3
|
+
//#region src/agentFullClient.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a full agent via HTTP API
|
|
7
|
+
*/
|
|
8
|
+
declare function createFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentData: FullAgentDefinition): Promise<FullAgentDefinition>;
|
|
9
|
+
/**
|
|
10
|
+
* Update a full agent via HTTP API (upsert behavior)
|
|
11
|
+
*/
|
|
12
|
+
declare function updateFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string, agentData: FullAgentDefinition): Promise<FullAgentDefinition>;
|
|
13
|
+
/**
|
|
14
|
+
* Get a full agent via HTTP API
|
|
15
|
+
*/
|
|
16
|
+
declare function getFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string): Promise<FullAgentDefinition | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Delete a full agent via HTTP API
|
|
19
|
+
*/
|
|
20
|
+
declare function deleteFullAgentViaAPI(tenantId: string, projectId: string, apiUrl: string, agentId: string): Promise<void>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createFullAgentViaAPI, deleteFullAgentViaAPI, getFullAgentViaAPI, updateFullAgentViaAPI };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { parseError } from "./projectFullClient.js";
|
|
2
|
+
import { getLogger } from "@inkeep/agents-core";
|
|
3
|
+
|
|
4
|
+
//#region src/agentFullClient.ts
|
|
5
|
+
const logger = getLogger("agentFullClient");
|
|
6
|
+
/**
|
|
7
|
+
* Create a full agent via HTTP API
|
|
8
|
+
*/
|
|
9
|
+
async function createFullAgentViaAPI(tenantId, projectId, apiUrl, agentData) {
|
|
10
|
+
logger.info({
|
|
11
|
+
tenantId,
|
|
12
|
+
projectId,
|
|
13
|
+
agentId: agentData.id,
|
|
14
|
+
apiUrl
|
|
15
|
+
}, "Creating full agent via API");
|
|
16
|
+
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent`;
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: { "Content-Type": "application/json" },
|
|
20
|
+
body: JSON.stringify(agentData)
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const errorMessage = parseError(await response.text()) ?? `Failed to create agent: ${response.status} ${response.statusText}`;
|
|
24
|
+
logger.error({
|
|
25
|
+
status: response.status,
|
|
26
|
+
error: errorMessage
|
|
27
|
+
}, "Failed to create agent via API");
|
|
28
|
+
throw new Error(errorMessage);
|
|
29
|
+
}
|
|
30
|
+
const result = await response.json();
|
|
31
|
+
logger.info({ agentId: agentData.id }, "Successfully created agent via API");
|
|
32
|
+
return result.data;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update a full agent via HTTP API (upsert behavior)
|
|
36
|
+
*/
|
|
37
|
+
async function updateFullAgentViaAPI(tenantId, projectId, apiUrl, agentId, agentData) {
|
|
38
|
+
logger.info({
|
|
39
|
+
tenantId,
|
|
40
|
+
projectId,
|
|
41
|
+
agentId,
|
|
42
|
+
apiUrl
|
|
43
|
+
}, "Updating full agent via API");
|
|
44
|
+
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
45
|
+
const response = await fetch(url, {
|
|
46
|
+
method: "PUT",
|
|
47
|
+
headers: { "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify(agentData)
|
|
49
|
+
});
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const errorMessage = parseError(await response.text()) ?? `Failed to update agent: ${response.status} ${response.statusText}`;
|
|
52
|
+
logger.error({
|
|
53
|
+
status: response.status,
|
|
54
|
+
error: errorMessage
|
|
55
|
+
}, "Failed to update agent via API");
|
|
56
|
+
throw new Error(errorMessage);
|
|
57
|
+
}
|
|
58
|
+
const result = await response.json();
|
|
59
|
+
logger.info({ agentId }, "Successfully updated agent via API");
|
|
60
|
+
return result.data;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get a full agent via HTTP API
|
|
64
|
+
*/
|
|
65
|
+
async function getFullAgentViaAPI(tenantId, projectId, apiUrl, agentId) {
|
|
66
|
+
logger.info({
|
|
67
|
+
tenantId,
|
|
68
|
+
projectId,
|
|
69
|
+
agentId,
|
|
70
|
+
apiUrl
|
|
71
|
+
}, "Getting full agent via API");
|
|
72
|
+
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
73
|
+
const response = await fetch(url, {
|
|
74
|
+
method: "GET",
|
|
75
|
+
headers: { "Content-Type": "application/json" }
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
if (response.status === 404) {
|
|
79
|
+
logger.info({ agentId }, "Agent not found");
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const errorMessage = parseError(await response.text()) ?? `Failed to get agent: ${response.status} ${response.statusText}`;
|
|
83
|
+
logger.error({
|
|
84
|
+
status: response.status,
|
|
85
|
+
error: errorMessage
|
|
86
|
+
}, "Failed to get agent via API");
|
|
87
|
+
throw new Error(errorMessage);
|
|
88
|
+
}
|
|
89
|
+
const result = await response.json();
|
|
90
|
+
logger.info({ agentId }, "Successfully retrieved agent via API");
|
|
91
|
+
return result.data;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Delete a full agent via HTTP API
|
|
95
|
+
*/
|
|
96
|
+
async function deleteFullAgentViaAPI(tenantId, projectId, apiUrl, agentId) {
|
|
97
|
+
logger.info({
|
|
98
|
+
tenantId,
|
|
99
|
+
projectId,
|
|
100
|
+
agentId,
|
|
101
|
+
apiUrl
|
|
102
|
+
}, "Deleting full agent via API");
|
|
103
|
+
const url = `${apiUrl}/tenants/${tenantId}/projects/${projectId}/agent/${agentId}`;
|
|
104
|
+
const response = await fetch(url, {
|
|
105
|
+
method: "DELETE",
|
|
106
|
+
headers: { "Content-Type": "application/json" }
|
|
107
|
+
});
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
const errorMessage = parseError(await response.text()) ?? `Failed to delete agent: ${response.status} ${response.statusText}`;
|
|
110
|
+
logger.error({
|
|
111
|
+
status: response.status,
|
|
112
|
+
error: errorMessage
|
|
113
|
+
}, "Failed to delete agent via API");
|
|
114
|
+
throw new Error(errorMessage);
|
|
115
|
+
}
|
|
116
|
+
logger.info({ agentId }, "Successfully deleted agent via API");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
export { createFullAgentViaAPI, deleteFullAgentViaAPI, getFullAgentViaAPI, updateFullAgentViaAPI };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ArtifactComponentInsert } from "@inkeep/agents-core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/artifact-component.d.ts
|
|
5
|
+
type ArtifactComponentConfigWithZod = Omit<ArtifactComponentInsert, 'tenantId' | 'projectId' | 'props'> & {
|
|
6
|
+
props?: Record<string, unknown> | z.ZodObject<any> | null;
|
|
7
|
+
};
|
|
8
|
+
interface ArtifactComponentInterface {
|
|
9
|
+
config: Omit<ArtifactComponentInsert, 'tenantId' | 'projectId'>;
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
getId(): ArtifactComponentInsert['id'];
|
|
12
|
+
getName(): ArtifactComponentInsert['name'];
|
|
13
|
+
getDescription(): ArtifactComponentInsert['description'];
|
|
14
|
+
getProps(): ArtifactComponentInsert['props'];
|
|
15
|
+
setContext(tenantId: string, projectId: string, baseURL?: string): void;
|
|
16
|
+
}
|
|
17
|
+
declare class ArtifactComponent implements ArtifactComponentInterface {
|
|
18
|
+
config: Omit<ArtifactComponentInsert, 'tenantId' | 'projectId'>;
|
|
19
|
+
private baseURL;
|
|
20
|
+
private tenantId;
|
|
21
|
+
private projectId;
|
|
22
|
+
private initialized;
|
|
23
|
+
private id;
|
|
24
|
+
constructor(config: ArtifactComponentConfigWithZod);
|
|
25
|
+
setContext(tenantId: string, projectId: string, baseURL?: string): void;
|
|
26
|
+
getId(): string;
|
|
27
|
+
getName(): string;
|
|
28
|
+
getDescription(): string;
|
|
29
|
+
getProps(): ArtifactComponentInsert['props'];
|
|
30
|
+
init(): Promise<void>;
|
|
31
|
+
private upsertArtifactComponent;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ArtifactComponent, ArtifactComponentInterface };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { generateIdFromName } from "./utils/generateIdFromName.js";
|
|
2
|
+
import { getLogger } from "@inkeep/agents-core";
|
|
3
|
+
import { convertZodToJsonSchemaWithPreview, isZodSchema } from "@inkeep/agents-core/utils/schema-conversion";
|
|
4
|
+
|
|
5
|
+
//#region src/artifact-component.ts
|
|
6
|
+
const logger = getLogger("artifactComponent");
|
|
7
|
+
var ArtifactComponent = class {
|
|
8
|
+
config;
|
|
9
|
+
baseURL;
|
|
10
|
+
tenantId;
|
|
11
|
+
projectId;
|
|
12
|
+
initialized = false;
|
|
13
|
+
id;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.id = config.id || generateIdFromName(config.name);
|
|
16
|
+
let processedProps;
|
|
17
|
+
if (config.props && isZodSchema(config.props)) processedProps = convertZodToJsonSchemaWithPreview(config.props);
|
|
18
|
+
else processedProps = config.props;
|
|
19
|
+
this.config = {
|
|
20
|
+
...config,
|
|
21
|
+
id: this.id,
|
|
22
|
+
props: processedProps
|
|
23
|
+
};
|
|
24
|
+
this.baseURL = process.env.INKEEP_API_URL || "http://localhost:3002";
|
|
25
|
+
this.tenantId = "default";
|
|
26
|
+
this.projectId = "default";
|
|
27
|
+
logger.info({
|
|
28
|
+
artifactComponentId: this.getId(),
|
|
29
|
+
artifactComponentName: config.name
|
|
30
|
+
}, "ArtifactComponent constructor initialized");
|
|
31
|
+
}
|
|
32
|
+
setContext(tenantId, projectId, baseURL) {
|
|
33
|
+
this.tenantId = tenantId;
|
|
34
|
+
this.projectId = projectId;
|
|
35
|
+
if (baseURL) this.baseURL = baseURL;
|
|
36
|
+
}
|
|
37
|
+
getId() {
|
|
38
|
+
return this.id;
|
|
39
|
+
}
|
|
40
|
+
getName() {
|
|
41
|
+
return this.config.name;
|
|
42
|
+
}
|
|
43
|
+
getDescription() {
|
|
44
|
+
return this.config.description || "";
|
|
45
|
+
}
|
|
46
|
+
getProps() {
|
|
47
|
+
return this.config.props;
|
|
48
|
+
}
|
|
49
|
+
async init() {
|
|
50
|
+
if (this.initialized) return;
|
|
51
|
+
try {
|
|
52
|
+
await this.upsertArtifactComponent();
|
|
53
|
+
logger.info({ artifactComponentId: this.getId() }, "ArtifactComponent initialized successfully");
|
|
54
|
+
this.initialized = true;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
logger.error({
|
|
57
|
+
artifactComponentId: this.getId(),
|
|
58
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
59
|
+
}, "Failed to initialize artifact component");
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async upsertArtifactComponent() {
|
|
64
|
+
const artifactComponentData = {
|
|
65
|
+
id: this.getId(),
|
|
66
|
+
name: this.config.name,
|
|
67
|
+
description: this.config.description,
|
|
68
|
+
props: this.config.props
|
|
69
|
+
};
|
|
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()}`, {
|
|
72
|
+
method: "PUT",
|
|
73
|
+
headers: { "Content-Type": "application/json" },
|
|
74
|
+
body: JSON.stringify(artifactComponentData)
|
|
75
|
+
});
|
|
76
|
+
logger.info({
|
|
77
|
+
status: updateResponse.status,
|
|
78
|
+
artifactComponentId: this.getId()
|
|
79
|
+
}, "artifact component updateResponse");
|
|
80
|
+
if (updateResponse.ok) {
|
|
81
|
+
logger.info({ artifactComponentId: this.getId() }, "ArtifactComponent updated successfully");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (updateResponse.status === 404) {
|
|
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`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: { "Content-Type": "application/json" },
|
|
89
|
+
body: JSON.stringify(artifactComponentData)
|
|
90
|
+
});
|
|
91
|
+
if (!createResponse.ok) {
|
|
92
|
+
const errorText$1 = await createResponse.text().catch(() => "Unknown error");
|
|
93
|
+
throw new Error(`Failed to create artifact component: ${createResponse.status} ${createResponse.statusText} - ${errorText$1}`);
|
|
94
|
+
}
|
|
95
|
+
logger.info({ artifactComponentId: this.getId() }, "ArtifactComponent created successfully");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const errorText = await updateResponse.text().catch(() => "Unknown error");
|
|
99
|
+
throw new Error(`Failed to update artifact component: ${updateResponse.status} ${updateResponse.statusText} - ${errorText}`);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { ArtifactComponent };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { ArtifactComponent } from "./artifact-component.js";
|
|
2
|
+
import { Tool } from "./tool.js";
|
|
3
|
+
import { SubAgent } from "./subAgent.js";
|
|
4
|
+
import { AgentMcpConfig, ArtifactComponentConfig, DataComponentConfig, MCPServerConfig, StatusComponentConfig } from "./builders.js";
|
|
5
|
+
import { DataComponent } from "./data-component.js";
|
|
6
|
+
import { FunctionTool } from "./function-tool.js";
|
|
7
|
+
import { AgentConfig, FunctionToolConfig, SubAgentConfig } from "./types.js";
|
|
8
|
+
import { Agent } from "./agent.js";
|
|
9
|
+
import { Project, ProjectConfig } from "./project.js";
|
|
10
|
+
import { StatusComponent as StatusComponent$1 } from "./status-component.js";
|
|
11
|
+
import { CredentialReferenceApiInsert, MCPToolConfig } from "@inkeep/agents-core";
|
|
12
|
+
|
|
13
|
+
//#region src/builderFunctions.d.ts
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to create agent - OpenAI style
|
|
17
|
+
*/
|
|
18
|
+
declare function agent(config: AgentConfig): Agent;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to create projects - OpenAI style
|
|
21
|
+
*
|
|
22
|
+
* Projects are the top-level organizational unit that contains Agents, Sub Agents, and shared configurations.
|
|
23
|
+
* They provide model inheritance and execution limits that cascade down to Agents and Sub Agents.
|
|
24
|
+
*
|
|
25
|
+
* @param config - Project configuration
|
|
26
|
+
* @returns A new Project instance
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const customerSupport = project({
|
|
31
|
+
* id: 'customer-support-project',
|
|
32
|
+
* name: 'Customer Support System',
|
|
33
|
+
* description: 'Multi-agent customer support system',
|
|
34
|
+
* models: {
|
|
35
|
+
* base: { model: 'gpt-4.1-mini' },
|
|
36
|
+
* structuredOutput: { model: 'gpt-4.1' }
|
|
37
|
+
* },
|
|
38
|
+
* stopWhen: {
|
|
39
|
+
* transferCountIs: 10,
|
|
40
|
+
* stepCountIs: 50
|
|
41
|
+
* },
|
|
42
|
+
* agent: () => [
|
|
43
|
+
* agent({
|
|
44
|
+
* id: 'support-agent',
|
|
45
|
+
* name: 'Support Agent',
|
|
46
|
+
* // ... agent config
|
|
47
|
+
* })
|
|
48
|
+
* ]
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function project(config: ProjectConfig): Project;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new agent with stable ID enforcement.
|
|
55
|
+
*
|
|
56
|
+
* Agents require explicit stable IDs to ensure consistency across deployments.
|
|
57
|
+
* This is different from tools which auto-generate IDs from their names.
|
|
58
|
+
*
|
|
59
|
+
* @param config - Agent configuration including required stable ID
|
|
60
|
+
* @returns A new SubAgent instance
|
|
61
|
+
* @throws {Error} If config.id is not provided
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const myAgent = agent({
|
|
66
|
+
* id: 'customer-support-agent',
|
|
67
|
+
* name: 'Customer Support',
|
|
68
|
+
* prompt: 'Help customers with their questions'
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function subAgent(config: SubAgentConfig): SubAgent;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a credential reference for authentication.
|
|
75
|
+
*
|
|
76
|
+
* Credentials are used to authenticate with external services.
|
|
77
|
+
* They should be stored securely and referenced by ID.
|
|
78
|
+
*
|
|
79
|
+
* @param config - Credential configuration
|
|
80
|
+
* @returns A validated credential reference
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const apiCredential = credential({
|
|
85
|
+
* id: 'github-token',
|
|
86
|
+
* name: 'GitHub Token',
|
|
87
|
+
* type: 'bearer',
|
|
88
|
+
* value: process.env.GITHUB_TOKEN
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function credential(config: CredentialReferenceApiInsert): {
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
credentialStoreId: string;
|
|
96
|
+
type: "memory" | "keychain" | "nango";
|
|
97
|
+
createdAt?: string | undefined;
|
|
98
|
+
updatedAt?: string | undefined;
|
|
99
|
+
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
100
|
+
userId?: string | null | undefined;
|
|
101
|
+
toolId?: string | null | undefined;
|
|
102
|
+
createdBy?: string | null | undefined;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Creates an MCP (Model Context Protocol) server for tool functionality.
|
|
106
|
+
*
|
|
107
|
+
* MCP servers provide tool functionality through a standardized protocol.
|
|
108
|
+
* They can be remote services accessed via HTTP/WebSocket.
|
|
109
|
+
*
|
|
110
|
+
* @param config - MCP server configuration
|
|
111
|
+
* @returns A Tool instance configured as an MCP server
|
|
112
|
+
* @throws {Error} If serverUrl is not provided
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Remote MCP server
|
|
117
|
+
* const apiServer = mcpServer({
|
|
118
|
+
* name: 'external_api',
|
|
119
|
+
* description: 'External API service',
|
|
120
|
+
* serverUrl: 'https://api.example.com/mcp'
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* // With authentication
|
|
124
|
+
* const secureServer = mcpServer({
|
|
125
|
+
* name: 'secure_api',
|
|
126
|
+
* description: 'Secure API service',
|
|
127
|
+
* serverUrl: 'https://secure.example.com/mcp',
|
|
128
|
+
* credential: credential({
|
|
129
|
+
* id: 'api-key',
|
|
130
|
+
* name: 'API Key',
|
|
131
|
+
* type: 'bearer',
|
|
132
|
+
* value: process.env.API_KEY
|
|
133
|
+
* })
|
|
134
|
+
* });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
declare function mcpServer(config: MCPServerConfig): Tool;
|
|
138
|
+
/**
|
|
139
|
+
* Creates an MCP tool from a raw configuration object.
|
|
140
|
+
*
|
|
141
|
+
* This is a low-level builder for advanced use cases where you need
|
|
142
|
+
* full control over the MCPToolConfig. For most cases, use `mcpServer()`.
|
|
143
|
+
*
|
|
144
|
+
* @param config - Complete MCP tool configuration
|
|
145
|
+
* @returns A Tool instance
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const customTool = mcpTool({
|
|
150
|
+
* id: 'custom-tool',
|
|
151
|
+
* name: 'Custom Tool',
|
|
152
|
+
* serverUrl: 'https://example.com/mcp',
|
|
153
|
+
* transport: { type: 'stdio' }
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function mcpTool(config: MCPToolConfig): Tool;
|
|
158
|
+
/**
|
|
159
|
+
* Creates an artifact component with automatic ID generation.
|
|
160
|
+
*
|
|
161
|
+
* Artifact components represent structured UI components that can
|
|
162
|
+
* be rendered with different levels of detail (summary vs full).
|
|
163
|
+
*
|
|
164
|
+
* @param config - Artifact component configuration
|
|
165
|
+
* @returns An ArtifactComponent instance
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const productCard = artifactComponent({
|
|
170
|
+
* name: 'Product Card',
|
|
171
|
+
* description: 'Display product information',
|
|
172
|
+
* props: {
|
|
173
|
+
* type: 'object',
|
|
174
|
+
* properties: {
|
|
175
|
+
* title: { type: 'string', inPreview: true },
|
|
176
|
+
* price: { type: 'string', inPreview: true },
|
|
177
|
+
* description: { type: 'string' },
|
|
178
|
+
* image: { type: 'string' }
|
|
179
|
+
* }
|
|
180
|
+
* }
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
|
|
185
|
+
/**
|
|
186
|
+
* Creates a data component with automatic ID generation.
|
|
187
|
+
*
|
|
188
|
+
* Data components represent structured data that can be
|
|
189
|
+
* passed between agents or used in processing.
|
|
190
|
+
*
|
|
191
|
+
* @param config - Data component configuration
|
|
192
|
+
* @returns A DataComponent instance
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const userProfile = dataComponent({
|
|
197
|
+
* name: 'User Profile',
|
|
198
|
+
* description: 'User profile data',
|
|
199
|
+
* props: {
|
|
200
|
+
* userId: '123',
|
|
201
|
+
* name: 'John Doe',
|
|
202
|
+
* email: 'john@example.com'
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare function dataComponent(config: DataComponentConfig): DataComponent;
|
|
208
|
+
/**
|
|
209
|
+
* Creates a status component for structured status updates.
|
|
210
|
+
*
|
|
211
|
+
* Status components define the structure of status updates
|
|
212
|
+
* that agents can generate during long-running operations.
|
|
213
|
+
*
|
|
214
|
+
* @param config - Status component configuration
|
|
215
|
+
* @returns A StatusComponent instance
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* import { z } from 'zod';
|
|
220
|
+
*
|
|
221
|
+
* const toolCallStatus = statusComponent({
|
|
222
|
+
* type: 'tool_call_summary',
|
|
223
|
+
* description: 'Summary of a tool execution',
|
|
224
|
+
* detailsSchema: z.object({
|
|
225
|
+
* tool_name: z.string(),
|
|
226
|
+
* summary: z.string(),
|
|
227
|
+
* status: z.enum(['success', 'error', 'in_progress'])
|
|
228
|
+
* })
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
declare function statusComponent(config: StatusComponentConfig): StatusComponent$1;
|
|
233
|
+
/**
|
|
234
|
+
* (deprecated in favor of mcpTool.with()) Creates an agent MCP configuration.
|
|
235
|
+
*
|
|
236
|
+
* Agent MCP configurations are used to configure the MCP server for an agent.
|
|
237
|
+
*
|
|
238
|
+
* @param config - Agent MCP configuration
|
|
239
|
+
* @returns An AgentMcpConfig instance
|
|
240
|
+
*/
|
|
241
|
+
declare function agentMcp(config: AgentMcpConfig): AgentMcpConfig;
|
|
242
|
+
/**
|
|
243
|
+
* Creates a function tool that executes user-defined code in a sandboxed environment.
|
|
244
|
+
*
|
|
245
|
+
* Function tools allow users to define custom logic that runs securely in isolated
|
|
246
|
+
* environments. Dependencies are installed automatically in the sandbox.
|
|
247
|
+
*
|
|
248
|
+
* @param config - Function tool configuration
|
|
249
|
+
* @returns A FunctionTool instance
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const calculatorTool = functionTool({
|
|
254
|
+
* name: 'calculator',
|
|
255
|
+
* description: 'Performs basic math operations',
|
|
256
|
+
* inputSchema: {
|
|
257
|
+
* type: 'object',
|
|
258
|
+
* properties: {
|
|
259
|
+
* operation: { type: 'string', enum: ['add', 'subtract', 'multiply', 'divide'] },
|
|
260
|
+
* a: { type: 'number' },
|
|
261
|
+
* b: { type: 'number' }
|
|
262
|
+
* },
|
|
263
|
+
* required: ['operation', 'a', 'b']
|
|
264
|
+
* },
|
|
265
|
+
* dependencies: {
|
|
266
|
+
* 'lodash': '^4.17.21'
|
|
267
|
+
* },
|
|
268
|
+
* execute: async (params) => {
|
|
269
|
+
* const { operation, a, b } = params;
|
|
270
|
+
* switch (operation) {
|
|
271
|
+
* case 'add': return { result: a + b };
|
|
272
|
+
* case 'subtract': return { result: a - b };
|
|
273
|
+
* case 'multiply': return { result: a * b };
|
|
274
|
+
* case 'divide': return { result: a / b };
|
|
275
|
+
* default: throw new Error(`Unknown operation: ${operation}`);
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
declare function functionTool(config: FunctionToolConfig): FunctionTool;
|
|
282
|
+
//#endregion
|
|
283
|
+
export { agent, agentMcp, artifactComponent, credential, dataComponent, functionTool, mcpServer, mcpTool, project, statusComponent, subAgent };
|