@inkeep/agents-sdk 0.0.0-dev-20250911052037 → 0.0.0-dev-20250911071658
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 +55 -80
- package/dist/index.d.cts +148 -88
- package/dist/index.d.ts +148 -88
- package/dist/index.js +57 -81
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -490,11 +490,11 @@ var Agent = class {
|
|
|
490
490
|
throw new Error("tools getter must return an array");
|
|
491
491
|
}
|
|
492
492
|
const toolRecord = {};
|
|
493
|
-
for (const
|
|
494
|
-
if (
|
|
495
|
-
const id =
|
|
493
|
+
for (const tool of tools) {
|
|
494
|
+
if (tool && typeof tool === "object") {
|
|
495
|
+
const id = tool.id || tool.getId?.() || tool.name;
|
|
496
496
|
if (id) {
|
|
497
|
-
toolRecord[id] =
|
|
497
|
+
toolRecord[id] = tool;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
}
|
|
@@ -518,9 +518,9 @@ var Agent = class {
|
|
|
518
518
|
getArtifactComponents() {
|
|
519
519
|
return resolveGetter(this.config.artifactComponents) || [];
|
|
520
520
|
}
|
|
521
|
-
addTool(_name,
|
|
521
|
+
addTool(_name, tool) {
|
|
522
522
|
const existingTools = this.config.tools ? this.config.tools() : [];
|
|
523
|
-
this.config.tools = () => [...existingTools,
|
|
523
|
+
this.config.tools = () => [...existingTools, tool];
|
|
524
524
|
}
|
|
525
525
|
addTransfer(...agents) {
|
|
526
526
|
if (typeof this.config.canTransferTo === "function") {
|
|
@@ -775,7 +775,7 @@ var Agent = class {
|
|
|
775
775
|
return;
|
|
776
776
|
}
|
|
777
777
|
const { Tool: Tool2 } = await Promise.resolve().then(() => (init_tool(), tool_exports));
|
|
778
|
-
let
|
|
778
|
+
let tool;
|
|
779
779
|
if (toolConfig instanceof Tool2) {
|
|
780
780
|
logger4.info(
|
|
781
781
|
{
|
|
@@ -785,8 +785,8 @@ var Agent = class {
|
|
|
785
785
|
},
|
|
786
786
|
"Initializing Tool instance"
|
|
787
787
|
);
|
|
788
|
-
|
|
789
|
-
await
|
|
788
|
+
tool = toolConfig;
|
|
789
|
+
await tool.init();
|
|
790
790
|
} else {
|
|
791
791
|
logger4.info(
|
|
792
792
|
{
|
|
@@ -796,7 +796,7 @@ var Agent = class {
|
|
|
796
796
|
},
|
|
797
797
|
"Creating Tool from config"
|
|
798
798
|
);
|
|
799
|
-
|
|
799
|
+
tool = new Tool2({
|
|
800
800
|
id: toolId,
|
|
801
801
|
tenantId: this.tenantId,
|
|
802
802
|
name: toolConfig.name || toolId,
|
|
@@ -805,13 +805,13 @@ var Agent = class {
|
|
|
805
805
|
activeTools: toolConfig.config?.mcp?.activeTools,
|
|
806
806
|
credential: toolConfig.credential
|
|
807
807
|
});
|
|
808
|
-
await
|
|
808
|
+
await tool.init();
|
|
809
809
|
}
|
|
810
|
-
await this.createAgentToolRelation(
|
|
810
|
+
await this.createAgentToolRelation(tool.getId());
|
|
811
811
|
logger4.info(
|
|
812
812
|
{
|
|
813
813
|
agentId: this.getId(),
|
|
814
|
-
toolId:
|
|
814
|
+
toolId: tool.getId()
|
|
815
815
|
},
|
|
816
816
|
"Tool created and linked to agent"
|
|
817
817
|
);
|
|
@@ -970,89 +970,65 @@ var Agent = class {
|
|
|
970
970
|
}
|
|
971
971
|
};
|
|
972
972
|
init_tool();
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
function credential(config) {
|
|
977
|
-
return agentsCore.CredentialReferenceApiInsertSchema.parse(config);
|
|
978
|
-
}
|
|
979
|
-
var ToolConfigSchema = zod.z.object({
|
|
980
|
-
id: zod.z.string().optional(),
|
|
981
|
-
name: zod.z.string(),
|
|
982
|
-
description: zod.z.string(),
|
|
983
|
-
parameters: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
984
|
-
schema: zod.z.unknown().optional()
|
|
985
|
-
});
|
|
986
|
-
ToolConfigSchema.extend({
|
|
987
|
-
execute: zod.z.any()
|
|
988
|
-
// Function - validated separately at runtime
|
|
973
|
+
var TransferConfigSchema = zod.z.object({
|
|
974
|
+
agent: zod.z.instanceof(Agent),
|
|
975
|
+
description: zod.z.string().optional()
|
|
989
976
|
});
|
|
990
|
-
function
|
|
991
|
-
|
|
992
|
-
throw new Error("execute must be a function");
|
|
993
|
-
}
|
|
994
|
-
const { execute, ...configWithoutFunction } = config;
|
|
995
|
-
const validatedConfig = ToolConfigSchema.parse(configWithoutFunction);
|
|
996
|
-
const fullConfig = { ...validatedConfig, execute };
|
|
997
|
-
const computedId = fullConfig.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
998
|
-
return {
|
|
999
|
-
id: computedId,
|
|
1000
|
-
name: fullConfig.name,
|
|
1001
|
-
description: fullConfig.description,
|
|
1002
|
-
execute: fullConfig.execute,
|
|
1003
|
-
parameters: fullConfig.parameters,
|
|
1004
|
-
schema: fullConfig.schema,
|
|
1005
|
-
type: "function"
|
|
1006
|
-
};
|
|
977
|
+
function generateIdFromName3(name) {
|
|
978
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1007
979
|
}
|
|
1008
|
-
function
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
980
|
+
function validateFunction(value, name) {
|
|
981
|
+
if (typeof value !== "function") {
|
|
982
|
+
throw new Error(`${name} must be a function`);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
function agent(config) {
|
|
986
|
+
if (!config.id) {
|
|
1015
987
|
throw new Error(
|
|
1016
|
-
"
|
|
988
|
+
"Agent ID is required. Agents must have stable IDs for consistency across deployments."
|
|
1017
989
|
);
|
|
1018
|
-
} else {
|
|
1019
|
-
if (!config.serverUrl) {
|
|
1020
|
-
throw new Error("Remote MCP server requires a serverUrl");
|
|
1021
|
-
}
|
|
1022
|
-
return new exports.Tool({
|
|
1023
|
-
id,
|
|
1024
|
-
name: config.name,
|
|
1025
|
-
description: config.description,
|
|
1026
|
-
serverUrl: config.serverUrl,
|
|
1027
|
-
tenantId: config.tenantId,
|
|
1028
|
-
credential: config.credential,
|
|
1029
|
-
activeTools: config.activeTools,
|
|
1030
|
-
headers: config.headers
|
|
1031
|
-
});
|
|
1032
990
|
}
|
|
991
|
+
return new Agent(config);
|
|
992
|
+
}
|
|
993
|
+
function mcpServer(config) {
|
|
994
|
+
if (!config.serverUrl) {
|
|
995
|
+
throw new Error("MCP server requires a serverUrl");
|
|
996
|
+
}
|
|
997
|
+
const id = config.id || generateIdFromName3(config.name);
|
|
998
|
+
return new exports.Tool({
|
|
999
|
+
id,
|
|
1000
|
+
name: config.name,
|
|
1001
|
+
description: config.description,
|
|
1002
|
+
serverUrl: config.serverUrl,
|
|
1003
|
+
tenantId: config.tenantId,
|
|
1004
|
+
credential: config.credential,
|
|
1005
|
+
activeTools: config.activeTools,
|
|
1006
|
+
headers: config.headers,
|
|
1007
|
+
imageUrl: config.imageUrl,
|
|
1008
|
+
transport: config.transport ? { type: config.transport } : void 0
|
|
1009
|
+
});
|
|
1033
1010
|
}
|
|
1034
1011
|
function mcpTool(config) {
|
|
1035
1012
|
const validatedConfig = agentsCore.MCPToolConfigSchema.parse(config);
|
|
1036
1013
|
return new exports.Tool(validatedConfig);
|
|
1037
1014
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
});
|
|
1042
|
-
var TransferSchema = TransferConfigSchema.extend({
|
|
1043
|
-
condition: zod.z.any().optional()
|
|
1044
|
-
// Function - validated separately at runtime when present
|
|
1045
|
-
});
|
|
1015
|
+
function credential(config) {
|
|
1016
|
+
return agentsCore.CredentialReferenceApiInsertSchema.parse(config);
|
|
1017
|
+
}
|
|
1046
1018
|
function transfer(targetAgent, description, condition) {
|
|
1047
|
-
if (condition !== void 0
|
|
1048
|
-
|
|
1019
|
+
if (condition !== void 0) {
|
|
1020
|
+
validateFunction(condition, "condition");
|
|
1049
1021
|
}
|
|
1050
1022
|
const config = {
|
|
1051
1023
|
agent: targetAgent,
|
|
1052
1024
|
description: description || `Hand off to ${targetAgent.getName()}`,
|
|
1053
1025
|
condition
|
|
1054
1026
|
};
|
|
1055
|
-
|
|
1027
|
+
TransferConfigSchema.parse({
|
|
1028
|
+
agent: config.agent,
|
|
1029
|
+
description: config.description
|
|
1030
|
+
});
|
|
1031
|
+
return config;
|
|
1056
1032
|
}
|
|
1057
1033
|
function artifactComponent(config) {
|
|
1058
1034
|
return new ArtifactComponent({
|
|
@@ -2876,5 +2852,4 @@ exports.raceGraphs = raceGraphs;
|
|
|
2876
2852
|
exports.registerEnvironmentSettings = registerEnvironmentSettings;
|
|
2877
2853
|
exports.run = run;
|
|
2878
2854
|
exports.stream = stream;
|
|
2879
|
-
exports.tool = tool;
|
|
2880
2855
|
exports.transfer = transfer;
|
package/dist/index.d.cts
CHANGED
|
@@ -451,12 +451,51 @@ declare class Tool implements ToolInterface {
|
|
|
451
451
|
private upsertTool;
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
+
/**
|
|
455
|
+
* Function signature for transfer conditions
|
|
456
|
+
*/
|
|
457
|
+
type TransferConditionFunction = (context: unknown) => boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Configuration for MCP server builders
|
|
460
|
+
*/
|
|
461
|
+
interface MCPServerConfig {
|
|
462
|
+
name: string;
|
|
463
|
+
description: string;
|
|
464
|
+
serverUrl: string;
|
|
465
|
+
id?: string;
|
|
466
|
+
parameters?: Record<string, z.ZodJSONSchema>;
|
|
467
|
+
credential?: CredentialReferenceApiInsert;
|
|
468
|
+
tenantId?: string;
|
|
469
|
+
transport?: keyof typeof MCPTransportType;
|
|
470
|
+
activeTools?: string[];
|
|
471
|
+
headers?: Record<string, string>;
|
|
472
|
+
imageUrl?: string;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Configuration for component builders
|
|
476
|
+
*/
|
|
477
|
+
interface ComponentConfig {
|
|
478
|
+
name: string;
|
|
479
|
+
description: string;
|
|
480
|
+
tenantId?: string;
|
|
481
|
+
projectId?: string;
|
|
482
|
+
}
|
|
483
|
+
interface ArtifactComponentConfig extends ComponentConfig {
|
|
484
|
+
summaryProps: Record<string, unknown>;
|
|
485
|
+
fullProps: Record<string, unknown>;
|
|
486
|
+
}
|
|
487
|
+
interface DataComponentConfig extends ComponentConfig {
|
|
488
|
+
props: Record<string, unknown>;
|
|
489
|
+
}
|
|
454
490
|
/**
|
|
455
491
|
* Creates a new agent with stable ID enforcement.
|
|
456
492
|
*
|
|
493
|
+
* Agents require explicit stable IDs to ensure consistency across deployments.
|
|
494
|
+
* This is different from tools which auto-generate IDs from their names.
|
|
495
|
+
*
|
|
457
496
|
* @param config - Agent configuration including required stable ID
|
|
458
497
|
* @returns A new Agent instance
|
|
459
|
-
* @throws Error
|
|
498
|
+
* @throws {Error} If config.id is not provided
|
|
460
499
|
*
|
|
461
500
|
* @example
|
|
462
501
|
* ```typescript
|
|
@@ -468,138 +507,159 @@ declare class Tool implements ToolInterface {
|
|
|
468
507
|
* ```
|
|
469
508
|
*/
|
|
470
509
|
declare function agent(config: AgentConfig): Agent;
|
|
471
|
-
declare function credential(config: CredentialReferenceApiInsert): {
|
|
472
|
-
id: string;
|
|
473
|
-
credentialStoreId: string;
|
|
474
|
-
type: "nango" | "memory" | "keychain";
|
|
475
|
-
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
476
|
-
};
|
|
477
510
|
/**
|
|
478
|
-
* Creates
|
|
511
|
+
* Creates an MCP (Model Context Protocol) server for tool functionality.
|
|
479
512
|
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
513
|
+
* MCP servers provide tool functionality through a standardized protocol.
|
|
514
|
+
* They can be remote services accessed via HTTP/WebSocket.
|
|
482
515
|
*
|
|
483
|
-
* @param config -
|
|
484
|
-
* @returns A Tool instance
|
|
516
|
+
* @param config - MCP server configuration
|
|
517
|
+
* @returns A Tool instance configured as an MCP server
|
|
518
|
+
* @throws {Error} If serverUrl is not provided
|
|
485
519
|
*
|
|
486
520
|
* @example
|
|
487
521
|
* ```typescript
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
522
|
+
* // Remote MCP server
|
|
523
|
+
* const apiServer = mcpServer({
|
|
524
|
+
* name: 'external_api',
|
|
525
|
+
* description: 'External API service',
|
|
526
|
+
* serverUrl: 'https://api.example.com/mcp'
|
|
527
|
+
* });
|
|
528
|
+
*
|
|
529
|
+
* // With authentication
|
|
530
|
+
* const secureServer = mcpServer({
|
|
531
|
+
* name: 'secure_api',
|
|
532
|
+
* description: 'Secure API service',
|
|
533
|
+
* serverUrl: 'https://secure.example.com/mcp',
|
|
534
|
+
* credential: credential({
|
|
535
|
+
* id: 'api-key',
|
|
536
|
+
* type: 'bearer',
|
|
537
|
+
* value: process.env.API_KEY
|
|
538
|
+
* })
|
|
492
539
|
* });
|
|
493
|
-
* // ID will be auto-generated as 'search-database'
|
|
494
540
|
* ```
|
|
495
541
|
*/
|
|
496
|
-
declare function
|
|
497
|
-
name: string;
|
|
498
|
-
description: string;
|
|
499
|
-
execute: (params: any) => Promise<any>;
|
|
500
|
-
parameters?: Record<string, any>;
|
|
501
|
-
schema?: z.ZodJSONSchema;
|
|
502
|
-
}): {
|
|
503
|
-
id: string;
|
|
504
|
-
name: string;
|
|
505
|
-
description: string;
|
|
506
|
-
execute: (params: any) => Promise<any>;
|
|
507
|
-
parameters: Record<string, any> | undefined;
|
|
508
|
-
schema: unknown;
|
|
509
|
-
type: "function";
|
|
510
|
-
};
|
|
542
|
+
declare function mcpServer(config: MCPServerConfig): Tool;
|
|
511
543
|
/**
|
|
512
|
-
* Creates an MCP
|
|
544
|
+
* Creates an MCP tool from a raw configuration object.
|
|
513
545
|
*
|
|
514
|
-
* This
|
|
515
|
-
*
|
|
546
|
+
* This is a low-level builder for advanced use cases where you need
|
|
547
|
+
* full control over the MCPToolConfig. For most cases, use `mcpServer()`.
|
|
516
548
|
*
|
|
517
|
-
* @param config - MCP
|
|
518
|
-
* @returns
|
|
549
|
+
* @param config - Complete MCP tool configuration
|
|
550
|
+
* @returns A Tool instance
|
|
519
551
|
*
|
|
520
552
|
* @example
|
|
521
553
|
* ```typescript
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
* name: '
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* // Implementation
|
|
528
|
-
* return results;
|
|
529
|
-
* }
|
|
554
|
+
* const customTool = mcpTool({
|
|
555
|
+
* id: 'custom-tool',
|
|
556
|
+
* name: 'Custom Tool',
|
|
557
|
+
* serverUrl: 'https://example.com/mcp',
|
|
558
|
+
* transport: { type: 'stdio' }
|
|
530
559
|
* });
|
|
560
|
+
* ```
|
|
561
|
+
*/
|
|
562
|
+
declare function mcpTool(config: MCPToolConfig$1): Tool;
|
|
563
|
+
/**
|
|
564
|
+
* Creates a credential reference for authentication.
|
|
531
565
|
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
566
|
+
* Credentials are used to authenticate with external services.
|
|
567
|
+
* They should be stored securely and referenced by ID.
|
|
568
|
+
*
|
|
569
|
+
* @param config - Credential configuration
|
|
570
|
+
* @returns A validated credential reference
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```typescript
|
|
574
|
+
* const apiCredential = credential({
|
|
575
|
+
* id: 'github-token',
|
|
576
|
+
* type: 'bearer',
|
|
577
|
+
* value: process.env.GITHUB_TOKEN
|
|
537
578
|
* });
|
|
538
579
|
* ```
|
|
539
580
|
*/
|
|
540
|
-
declare function
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
581
|
+
declare function credential(config: CredentialReferenceApiInsert): {
|
|
582
|
+
id: string;
|
|
583
|
+
credentialStoreId: string;
|
|
584
|
+
type: "nango" | "memory" | "keychain";
|
|
585
|
+
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Creates a transfer configuration for agent handoffs.
|
|
589
|
+
*
|
|
590
|
+
* Transfers allow one agent to hand off control to another agent
|
|
591
|
+
* based on optional conditions.
|
|
592
|
+
*
|
|
593
|
+
* @param targetAgent - The agent to transfer to
|
|
594
|
+
* @param description - Optional description of when/why to transfer
|
|
595
|
+
* @param condition - Optional function to determine if transfer should occur
|
|
596
|
+
* @returns A validated transfer configuration
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```typescript
|
|
600
|
+
* // Simple transfer
|
|
601
|
+
* const handoff = transfer(supportAgent, 'Transfer to support');
|
|
602
|
+
*
|
|
603
|
+
* // Conditional transfer
|
|
604
|
+
* const conditionalHandoff = transfer(
|
|
605
|
+
* specialistAgent,
|
|
606
|
+
* 'Transfer to specialist for complex issues',
|
|
607
|
+
* (context) => context.complexity > 0.8
|
|
608
|
+
* );
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
declare function transfer(targetAgent: Agent, description?: string, condition?: TransferConditionFunction): TransferConfig;
|
|
557
612
|
/**
|
|
558
613
|
* Creates an artifact component with automatic ID generation.
|
|
559
614
|
*
|
|
615
|
+
* Artifact components represent structured UI components that can
|
|
616
|
+
* be rendered with different levels of detail (summary vs full).
|
|
617
|
+
*
|
|
560
618
|
* @param config - Artifact component configuration
|
|
561
|
-
* @returns An ArtifactComponent instance
|
|
619
|
+
* @returns An ArtifactComponent instance
|
|
562
620
|
*
|
|
563
621
|
* @example
|
|
564
622
|
* ```typescript
|
|
565
623
|
* const productCard = artifactComponent({
|
|
566
624
|
* name: 'Product Card',
|
|
567
625
|
* description: 'Display product information',
|
|
568
|
-
* summaryProps: {
|
|
569
|
-
*
|
|
626
|
+
* summaryProps: {
|
|
627
|
+
* title: 'Product',
|
|
628
|
+
* price: '$0'
|
|
629
|
+
* },
|
|
630
|
+
* fullProps: {
|
|
631
|
+
* title: 'Product',
|
|
632
|
+
* price: '$0',
|
|
633
|
+
* description: 'Product description',
|
|
634
|
+
* image: 'product.jpg'
|
|
635
|
+
* }
|
|
570
636
|
* });
|
|
571
637
|
* ```
|
|
572
638
|
*/
|
|
573
|
-
declare function artifactComponent(config:
|
|
574
|
-
name: string;
|
|
575
|
-
description: string;
|
|
576
|
-
summaryProps: Record<string, any>;
|
|
577
|
-
fullProps: Record<string, any>;
|
|
578
|
-
tenantId?: string;
|
|
579
|
-
projectId?: string;
|
|
580
|
-
}): ArtifactComponent;
|
|
639
|
+
declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
|
|
581
640
|
/**
|
|
582
641
|
* Creates a data component with automatic ID generation.
|
|
583
642
|
*
|
|
643
|
+
* Data components represent structured data that can be
|
|
644
|
+
* passed between agents or used in processing.
|
|
645
|
+
*
|
|
584
646
|
* @param config - Data component configuration
|
|
585
|
-
* @returns A DataComponent instance
|
|
647
|
+
* @returns A DataComponent instance
|
|
586
648
|
*
|
|
587
649
|
* @example
|
|
588
650
|
* ```typescript
|
|
589
651
|
* const userProfile = dataComponent({
|
|
590
652
|
* name: 'User Profile',
|
|
591
653
|
* description: 'User profile data',
|
|
592
|
-
* props: {
|
|
654
|
+
* props: {
|
|
655
|
+
* userId: '123',
|
|
656
|
+
* name: 'John Doe',
|
|
657
|
+
* email: 'john@example.com'
|
|
658
|
+
* }
|
|
593
659
|
* });
|
|
594
660
|
* ```
|
|
595
661
|
*/
|
|
596
|
-
declare function dataComponent(config:
|
|
597
|
-
name: string;
|
|
598
|
-
description: string;
|
|
599
|
-
props: Record<string, any>;
|
|
600
|
-
tenantId?: string;
|
|
601
|
-
projectId?: string;
|
|
602
|
-
}): DataComponent;
|
|
662
|
+
declare function dataComponent(config: DataComponentConfig): DataComponent;
|
|
603
663
|
|
|
604
664
|
interface EnvironmentSettingsConfig {
|
|
605
665
|
credentials?: {
|
|
@@ -853,4 +913,4 @@ declare const run: typeof Runner.run;
|
|
|
853
913
|
declare const stream: typeof Runner.stream;
|
|
854
914
|
declare const raceGraphs: typeof Runner.raceGraphs;
|
|
855
915
|
|
|
856
|
-
export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream,
|
|
916
|
+
export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };
|
package/dist/index.d.ts
CHANGED
|
@@ -451,12 +451,51 @@ declare class Tool implements ToolInterface {
|
|
|
451
451
|
private upsertTool;
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
+
/**
|
|
455
|
+
* Function signature for transfer conditions
|
|
456
|
+
*/
|
|
457
|
+
type TransferConditionFunction = (context: unknown) => boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Configuration for MCP server builders
|
|
460
|
+
*/
|
|
461
|
+
interface MCPServerConfig {
|
|
462
|
+
name: string;
|
|
463
|
+
description: string;
|
|
464
|
+
serverUrl: string;
|
|
465
|
+
id?: string;
|
|
466
|
+
parameters?: Record<string, z.ZodJSONSchema>;
|
|
467
|
+
credential?: CredentialReferenceApiInsert;
|
|
468
|
+
tenantId?: string;
|
|
469
|
+
transport?: keyof typeof MCPTransportType;
|
|
470
|
+
activeTools?: string[];
|
|
471
|
+
headers?: Record<string, string>;
|
|
472
|
+
imageUrl?: string;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Configuration for component builders
|
|
476
|
+
*/
|
|
477
|
+
interface ComponentConfig {
|
|
478
|
+
name: string;
|
|
479
|
+
description: string;
|
|
480
|
+
tenantId?: string;
|
|
481
|
+
projectId?: string;
|
|
482
|
+
}
|
|
483
|
+
interface ArtifactComponentConfig extends ComponentConfig {
|
|
484
|
+
summaryProps: Record<string, unknown>;
|
|
485
|
+
fullProps: Record<string, unknown>;
|
|
486
|
+
}
|
|
487
|
+
interface DataComponentConfig extends ComponentConfig {
|
|
488
|
+
props: Record<string, unknown>;
|
|
489
|
+
}
|
|
454
490
|
/**
|
|
455
491
|
* Creates a new agent with stable ID enforcement.
|
|
456
492
|
*
|
|
493
|
+
* Agents require explicit stable IDs to ensure consistency across deployments.
|
|
494
|
+
* This is different from tools which auto-generate IDs from their names.
|
|
495
|
+
*
|
|
457
496
|
* @param config - Agent configuration including required stable ID
|
|
458
497
|
* @returns A new Agent instance
|
|
459
|
-
* @throws Error
|
|
498
|
+
* @throws {Error} If config.id is not provided
|
|
460
499
|
*
|
|
461
500
|
* @example
|
|
462
501
|
* ```typescript
|
|
@@ -468,138 +507,159 @@ declare class Tool implements ToolInterface {
|
|
|
468
507
|
* ```
|
|
469
508
|
*/
|
|
470
509
|
declare function agent(config: AgentConfig): Agent;
|
|
471
|
-
declare function credential(config: CredentialReferenceApiInsert): {
|
|
472
|
-
id: string;
|
|
473
|
-
credentialStoreId: string;
|
|
474
|
-
type: "nango" | "memory" | "keychain";
|
|
475
|
-
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
476
|
-
};
|
|
477
510
|
/**
|
|
478
|
-
* Creates
|
|
511
|
+
* Creates an MCP (Model Context Protocol) server for tool functionality.
|
|
479
512
|
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
513
|
+
* MCP servers provide tool functionality through a standardized protocol.
|
|
514
|
+
* They can be remote services accessed via HTTP/WebSocket.
|
|
482
515
|
*
|
|
483
|
-
* @param config -
|
|
484
|
-
* @returns A Tool instance
|
|
516
|
+
* @param config - MCP server configuration
|
|
517
|
+
* @returns A Tool instance configured as an MCP server
|
|
518
|
+
* @throws {Error} If serverUrl is not provided
|
|
485
519
|
*
|
|
486
520
|
* @example
|
|
487
521
|
* ```typescript
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
522
|
+
* // Remote MCP server
|
|
523
|
+
* const apiServer = mcpServer({
|
|
524
|
+
* name: 'external_api',
|
|
525
|
+
* description: 'External API service',
|
|
526
|
+
* serverUrl: 'https://api.example.com/mcp'
|
|
527
|
+
* });
|
|
528
|
+
*
|
|
529
|
+
* // With authentication
|
|
530
|
+
* const secureServer = mcpServer({
|
|
531
|
+
* name: 'secure_api',
|
|
532
|
+
* description: 'Secure API service',
|
|
533
|
+
* serverUrl: 'https://secure.example.com/mcp',
|
|
534
|
+
* credential: credential({
|
|
535
|
+
* id: 'api-key',
|
|
536
|
+
* type: 'bearer',
|
|
537
|
+
* value: process.env.API_KEY
|
|
538
|
+
* })
|
|
492
539
|
* });
|
|
493
|
-
* // ID will be auto-generated as 'search-database'
|
|
494
540
|
* ```
|
|
495
541
|
*/
|
|
496
|
-
declare function
|
|
497
|
-
name: string;
|
|
498
|
-
description: string;
|
|
499
|
-
execute: (params: any) => Promise<any>;
|
|
500
|
-
parameters?: Record<string, any>;
|
|
501
|
-
schema?: z.ZodJSONSchema;
|
|
502
|
-
}): {
|
|
503
|
-
id: string;
|
|
504
|
-
name: string;
|
|
505
|
-
description: string;
|
|
506
|
-
execute: (params: any) => Promise<any>;
|
|
507
|
-
parameters: Record<string, any> | undefined;
|
|
508
|
-
schema: unknown;
|
|
509
|
-
type: "function";
|
|
510
|
-
};
|
|
542
|
+
declare function mcpServer(config: MCPServerConfig): Tool;
|
|
511
543
|
/**
|
|
512
|
-
* Creates an MCP
|
|
544
|
+
* Creates an MCP tool from a raw configuration object.
|
|
513
545
|
*
|
|
514
|
-
* This
|
|
515
|
-
*
|
|
546
|
+
* This is a low-level builder for advanced use cases where you need
|
|
547
|
+
* full control over the MCPToolConfig. For most cases, use `mcpServer()`.
|
|
516
548
|
*
|
|
517
|
-
* @param config - MCP
|
|
518
|
-
* @returns
|
|
549
|
+
* @param config - Complete MCP tool configuration
|
|
550
|
+
* @returns A Tool instance
|
|
519
551
|
*
|
|
520
552
|
* @example
|
|
521
553
|
* ```typescript
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
* name: '
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* // Implementation
|
|
528
|
-
* return results;
|
|
529
|
-
* }
|
|
554
|
+
* const customTool = mcpTool({
|
|
555
|
+
* id: 'custom-tool',
|
|
556
|
+
* name: 'Custom Tool',
|
|
557
|
+
* serverUrl: 'https://example.com/mcp',
|
|
558
|
+
* transport: { type: 'stdio' }
|
|
530
559
|
* });
|
|
560
|
+
* ```
|
|
561
|
+
*/
|
|
562
|
+
declare function mcpTool(config: MCPToolConfig$1): Tool;
|
|
563
|
+
/**
|
|
564
|
+
* Creates a credential reference for authentication.
|
|
531
565
|
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
566
|
+
* Credentials are used to authenticate with external services.
|
|
567
|
+
* They should be stored securely and referenced by ID.
|
|
568
|
+
*
|
|
569
|
+
* @param config - Credential configuration
|
|
570
|
+
* @returns A validated credential reference
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```typescript
|
|
574
|
+
* const apiCredential = credential({
|
|
575
|
+
* id: 'github-token',
|
|
576
|
+
* type: 'bearer',
|
|
577
|
+
* value: process.env.GITHUB_TOKEN
|
|
537
578
|
* });
|
|
538
579
|
* ```
|
|
539
580
|
*/
|
|
540
|
-
declare function
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
581
|
+
declare function credential(config: CredentialReferenceApiInsert): {
|
|
582
|
+
id: string;
|
|
583
|
+
credentialStoreId: string;
|
|
584
|
+
type: "nango" | "memory" | "keychain";
|
|
585
|
+
retrievalParams?: Record<string, unknown> | null | undefined;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Creates a transfer configuration for agent handoffs.
|
|
589
|
+
*
|
|
590
|
+
* Transfers allow one agent to hand off control to another agent
|
|
591
|
+
* based on optional conditions.
|
|
592
|
+
*
|
|
593
|
+
* @param targetAgent - The agent to transfer to
|
|
594
|
+
* @param description - Optional description of when/why to transfer
|
|
595
|
+
* @param condition - Optional function to determine if transfer should occur
|
|
596
|
+
* @returns A validated transfer configuration
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```typescript
|
|
600
|
+
* // Simple transfer
|
|
601
|
+
* const handoff = transfer(supportAgent, 'Transfer to support');
|
|
602
|
+
*
|
|
603
|
+
* // Conditional transfer
|
|
604
|
+
* const conditionalHandoff = transfer(
|
|
605
|
+
* specialistAgent,
|
|
606
|
+
* 'Transfer to specialist for complex issues',
|
|
607
|
+
* (context) => context.complexity > 0.8
|
|
608
|
+
* );
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
declare function transfer(targetAgent: Agent, description?: string, condition?: TransferConditionFunction): TransferConfig;
|
|
557
612
|
/**
|
|
558
613
|
* Creates an artifact component with automatic ID generation.
|
|
559
614
|
*
|
|
615
|
+
* Artifact components represent structured UI components that can
|
|
616
|
+
* be rendered with different levels of detail (summary vs full).
|
|
617
|
+
*
|
|
560
618
|
* @param config - Artifact component configuration
|
|
561
|
-
* @returns An ArtifactComponent instance
|
|
619
|
+
* @returns An ArtifactComponent instance
|
|
562
620
|
*
|
|
563
621
|
* @example
|
|
564
622
|
* ```typescript
|
|
565
623
|
* const productCard = artifactComponent({
|
|
566
624
|
* name: 'Product Card',
|
|
567
625
|
* description: 'Display product information',
|
|
568
|
-
* summaryProps: {
|
|
569
|
-
*
|
|
626
|
+
* summaryProps: {
|
|
627
|
+
* title: 'Product',
|
|
628
|
+
* price: '$0'
|
|
629
|
+
* },
|
|
630
|
+
* fullProps: {
|
|
631
|
+
* title: 'Product',
|
|
632
|
+
* price: '$0',
|
|
633
|
+
* description: 'Product description',
|
|
634
|
+
* image: 'product.jpg'
|
|
635
|
+
* }
|
|
570
636
|
* });
|
|
571
637
|
* ```
|
|
572
638
|
*/
|
|
573
|
-
declare function artifactComponent(config:
|
|
574
|
-
name: string;
|
|
575
|
-
description: string;
|
|
576
|
-
summaryProps: Record<string, any>;
|
|
577
|
-
fullProps: Record<string, any>;
|
|
578
|
-
tenantId?: string;
|
|
579
|
-
projectId?: string;
|
|
580
|
-
}): ArtifactComponent;
|
|
639
|
+
declare function artifactComponent(config: ArtifactComponentConfig): ArtifactComponent;
|
|
581
640
|
/**
|
|
582
641
|
* Creates a data component with automatic ID generation.
|
|
583
642
|
*
|
|
643
|
+
* Data components represent structured data that can be
|
|
644
|
+
* passed between agents or used in processing.
|
|
645
|
+
*
|
|
584
646
|
* @param config - Data component configuration
|
|
585
|
-
* @returns A DataComponent instance
|
|
647
|
+
* @returns A DataComponent instance
|
|
586
648
|
*
|
|
587
649
|
* @example
|
|
588
650
|
* ```typescript
|
|
589
651
|
* const userProfile = dataComponent({
|
|
590
652
|
* name: 'User Profile',
|
|
591
653
|
* description: 'User profile data',
|
|
592
|
-
* props: {
|
|
654
|
+
* props: {
|
|
655
|
+
* userId: '123',
|
|
656
|
+
* name: 'John Doe',
|
|
657
|
+
* email: 'john@example.com'
|
|
658
|
+
* }
|
|
593
659
|
* });
|
|
594
660
|
* ```
|
|
595
661
|
*/
|
|
596
|
-
declare function dataComponent(config:
|
|
597
|
-
name: string;
|
|
598
|
-
description: string;
|
|
599
|
-
props: Record<string, any>;
|
|
600
|
-
tenantId?: string;
|
|
601
|
-
projectId?: string;
|
|
602
|
-
}): DataComponent;
|
|
662
|
+
declare function dataComponent(config: DataComponentConfig): DataComponent;
|
|
603
663
|
|
|
604
664
|
interface EnvironmentSettingsConfig {
|
|
605
665
|
credentials?: {
|
|
@@ -853,4 +913,4 @@ declare const run: typeof Runner.run;
|
|
|
853
913
|
declare const stream: typeof Runner.stream;
|
|
854
914
|
declare const raceGraphs: typeof Runner.raceGraphs;
|
|
855
915
|
|
|
856
|
-
export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream,
|
|
916
|
+
export { Agent, type AgentConfig, AgentError, AgentGraph, type AgentInterface, type AgentResponse, type AllAgentInterface, ArtifactComponent, type AssistantMessage, type BuilderAgentConfig, type BuilderRelationConfig, type BuilderToolConfig, DataComponent, ExternalAgent, type ExternalAgentInterface, type FetchDefinitionConfig, type GenerateOptions, type GraphConfig, type GraphInterface, type MCPToolConfig, MaxTurnsExceededError, type Message, type MessageInput, type ModelSettings, ModelSettingsSchema, type RequestSchemaConfig, type RequestSchemaDefinition, type RunResult, Runner, type ServerConfig, type StatusComponent, type StatusUpdateSettings, type StreamEvent, type StreamResponse, type SystemMessage, Tool, type ToolCall, type ToolConfig, ToolExecutionError, type ToolMessage, type ToolResult, type TransferConfig, TransferError, type UserMessage, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __publicField, Tool } from './chunk-BCJFVUMJ.js';
|
|
2
2
|
export { Tool } from './chunk-BCJFVUMJ.js';
|
|
3
|
-
import { getLogger, generateIdFromName,
|
|
3
|
+
import { getLogger, generateIdFromName, MCPToolConfigSchema, CredentialReferenceApiInsertSchema, createDatabaseClient, getProject } from '@inkeep/agents-core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
var logger = getLogger("artifactComponent");
|
|
@@ -330,11 +330,11 @@ var Agent = class {
|
|
|
330
330
|
throw new Error("tools getter must return an array");
|
|
331
331
|
}
|
|
332
332
|
const toolRecord = {};
|
|
333
|
-
for (const
|
|
334
|
-
if (
|
|
335
|
-
const id =
|
|
333
|
+
for (const tool of tools) {
|
|
334
|
+
if (tool && typeof tool === "object") {
|
|
335
|
+
const id = tool.id || tool.getId?.() || tool.name;
|
|
336
336
|
if (id) {
|
|
337
|
-
toolRecord[id] =
|
|
337
|
+
toolRecord[id] = tool;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
}
|
|
@@ -358,9 +358,9 @@ var Agent = class {
|
|
|
358
358
|
getArtifactComponents() {
|
|
359
359
|
return resolveGetter(this.config.artifactComponents) || [];
|
|
360
360
|
}
|
|
361
|
-
addTool(_name,
|
|
361
|
+
addTool(_name, tool) {
|
|
362
362
|
const existingTools = this.config.tools ? this.config.tools() : [];
|
|
363
|
-
this.config.tools = () => [...existingTools,
|
|
363
|
+
this.config.tools = () => [...existingTools, tool];
|
|
364
364
|
}
|
|
365
365
|
addTransfer(...agents) {
|
|
366
366
|
if (typeof this.config.canTransferTo === "function") {
|
|
@@ -615,7 +615,7 @@ var Agent = class {
|
|
|
615
615
|
return;
|
|
616
616
|
}
|
|
617
617
|
const { Tool: Tool2 } = await import('./tool-6K5MVNKA.js');
|
|
618
|
-
let
|
|
618
|
+
let tool;
|
|
619
619
|
if (toolConfig instanceof Tool2) {
|
|
620
620
|
logger3.info(
|
|
621
621
|
{
|
|
@@ -625,8 +625,8 @@ var Agent = class {
|
|
|
625
625
|
},
|
|
626
626
|
"Initializing Tool instance"
|
|
627
627
|
);
|
|
628
|
-
|
|
629
|
-
await
|
|
628
|
+
tool = toolConfig;
|
|
629
|
+
await tool.init();
|
|
630
630
|
} else {
|
|
631
631
|
logger3.info(
|
|
632
632
|
{
|
|
@@ -636,7 +636,7 @@ var Agent = class {
|
|
|
636
636
|
},
|
|
637
637
|
"Creating Tool from config"
|
|
638
638
|
);
|
|
639
|
-
|
|
639
|
+
tool = new Tool2({
|
|
640
640
|
id: toolId,
|
|
641
641
|
tenantId: this.tenantId,
|
|
642
642
|
name: toolConfig.name || toolId,
|
|
@@ -645,13 +645,13 @@ var Agent = class {
|
|
|
645
645
|
activeTools: toolConfig.config?.mcp?.activeTools,
|
|
646
646
|
credential: toolConfig.credential
|
|
647
647
|
});
|
|
648
|
-
await
|
|
648
|
+
await tool.init();
|
|
649
649
|
}
|
|
650
|
-
await this.createAgentToolRelation(
|
|
650
|
+
await this.createAgentToolRelation(tool.getId());
|
|
651
651
|
logger3.info(
|
|
652
652
|
{
|
|
653
653
|
agentId: this.getId(),
|
|
654
|
-
toolId:
|
|
654
|
+
toolId: tool.getId()
|
|
655
655
|
},
|
|
656
656
|
"Tool created and linked to agent"
|
|
657
657
|
);
|
|
@@ -809,89 +809,65 @@ var Agent = class {
|
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
811
|
};
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
function credential(config) {
|
|
816
|
-
return CredentialReferenceApiInsertSchema.parse(config);
|
|
817
|
-
}
|
|
818
|
-
var ToolConfigSchema = z.object({
|
|
819
|
-
id: z.string().optional(),
|
|
820
|
-
name: z.string(),
|
|
821
|
-
description: z.string(),
|
|
822
|
-
parameters: z.record(z.string(), z.any()).optional(),
|
|
823
|
-
schema: z.unknown().optional()
|
|
824
|
-
});
|
|
825
|
-
ToolConfigSchema.extend({
|
|
826
|
-
execute: z.any()
|
|
827
|
-
// Function - validated separately at runtime
|
|
812
|
+
var TransferConfigSchema = z.object({
|
|
813
|
+
agent: z.instanceof(Agent),
|
|
814
|
+
description: z.string().optional()
|
|
828
815
|
});
|
|
829
|
-
function
|
|
830
|
-
|
|
831
|
-
throw new Error("execute must be a function");
|
|
832
|
-
}
|
|
833
|
-
const { execute, ...configWithoutFunction } = config;
|
|
834
|
-
const validatedConfig = ToolConfigSchema.parse(configWithoutFunction);
|
|
835
|
-
const fullConfig = { ...validatedConfig, execute };
|
|
836
|
-
const computedId = fullConfig.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
837
|
-
return {
|
|
838
|
-
id: computedId,
|
|
839
|
-
name: fullConfig.name,
|
|
840
|
-
description: fullConfig.description,
|
|
841
|
-
execute: fullConfig.execute,
|
|
842
|
-
parameters: fullConfig.parameters,
|
|
843
|
-
schema: fullConfig.schema,
|
|
844
|
-
type: "function"
|
|
845
|
-
};
|
|
816
|
+
function generateIdFromName3(name) {
|
|
817
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
846
818
|
}
|
|
847
|
-
function
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
819
|
+
function validateFunction(value, name) {
|
|
820
|
+
if (typeof value !== "function") {
|
|
821
|
+
throw new Error(`${name} must be a function`);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function agent(config) {
|
|
825
|
+
if (!config.id) {
|
|
854
826
|
throw new Error(
|
|
855
|
-
"
|
|
827
|
+
"Agent ID is required. Agents must have stable IDs for consistency across deployments."
|
|
856
828
|
);
|
|
857
|
-
} else {
|
|
858
|
-
if (!config.serverUrl) {
|
|
859
|
-
throw new Error("Remote MCP server requires a serverUrl");
|
|
860
|
-
}
|
|
861
|
-
return new Tool({
|
|
862
|
-
id,
|
|
863
|
-
name: config.name,
|
|
864
|
-
description: config.description,
|
|
865
|
-
serverUrl: config.serverUrl,
|
|
866
|
-
tenantId: config.tenantId,
|
|
867
|
-
credential: config.credential,
|
|
868
|
-
activeTools: config.activeTools,
|
|
869
|
-
headers: config.headers
|
|
870
|
-
});
|
|
871
829
|
}
|
|
830
|
+
return new Agent(config);
|
|
831
|
+
}
|
|
832
|
+
function mcpServer(config) {
|
|
833
|
+
if (!config.serverUrl) {
|
|
834
|
+
throw new Error("MCP server requires a serverUrl");
|
|
835
|
+
}
|
|
836
|
+
const id = config.id || generateIdFromName3(config.name);
|
|
837
|
+
return new Tool({
|
|
838
|
+
id,
|
|
839
|
+
name: config.name,
|
|
840
|
+
description: config.description,
|
|
841
|
+
serverUrl: config.serverUrl,
|
|
842
|
+
tenantId: config.tenantId,
|
|
843
|
+
credential: config.credential,
|
|
844
|
+
activeTools: config.activeTools,
|
|
845
|
+
headers: config.headers,
|
|
846
|
+
imageUrl: config.imageUrl,
|
|
847
|
+
transport: config.transport ? { type: config.transport } : void 0
|
|
848
|
+
});
|
|
872
849
|
}
|
|
873
850
|
function mcpTool(config) {
|
|
874
851
|
const validatedConfig = MCPToolConfigSchema.parse(config);
|
|
875
852
|
return new Tool(validatedConfig);
|
|
876
853
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
});
|
|
881
|
-
var TransferSchema = TransferConfigSchema.extend({
|
|
882
|
-
condition: z.any().optional()
|
|
883
|
-
// Function - validated separately at runtime when present
|
|
884
|
-
});
|
|
854
|
+
function credential(config) {
|
|
855
|
+
return CredentialReferenceApiInsertSchema.parse(config);
|
|
856
|
+
}
|
|
885
857
|
function transfer(targetAgent, description, condition) {
|
|
886
|
-
if (condition !== void 0
|
|
887
|
-
|
|
858
|
+
if (condition !== void 0) {
|
|
859
|
+
validateFunction(condition, "condition");
|
|
888
860
|
}
|
|
889
861
|
const config = {
|
|
890
862
|
agent: targetAgent,
|
|
891
863
|
description: description || `Hand off to ${targetAgent.getName()}`,
|
|
892
864
|
condition
|
|
893
865
|
};
|
|
894
|
-
|
|
866
|
+
TransferConfigSchema.parse({
|
|
867
|
+
agent: config.agent,
|
|
868
|
+
description: config.description
|
|
869
|
+
});
|
|
870
|
+
return config;
|
|
895
871
|
}
|
|
896
872
|
function artifactComponent(config) {
|
|
897
873
|
return new ArtifactComponent({
|
|
@@ -2691,4 +2667,4 @@ var run = Runner.run.bind(Runner);
|
|
|
2691
2667
|
var stream = Runner.stream.bind(Runner);
|
|
2692
2668
|
var raceGraphs = Runner.raceGraphs.bind(Runner);
|
|
2693
2669
|
|
|
2694
|
-
export { Agent, AgentGraph, ArtifactComponent, DataComponent, ExternalAgent, Runner, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream,
|
|
2670
|
+
export { Agent, AgentGraph, ArtifactComponent, DataComponent, ExternalAgent, Runner, agent, agentGraph, artifactComponent, createEnvironmentSettings, credential, dataComponent, externalAgent, externalAgents, generateGraph, mcpServer, mcpTool, raceGraphs, registerEnvironmentSettings, run, stream, transfer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-sdk",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20250911071658",
|
|
4
4
|
"description": "SDK for building and managing agents in the Inkeep Agent Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"nanoid": "^5.1.5",
|
|
10
10
|
"zod": "^4.1.5",
|
|
11
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
11
|
+
"@inkeep/agents-core": "^0.0.0-dev-20250911071658"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@biomejs/biome": "2.1.4",
|
|
15
14
|
"@types/node": "^20.11.24",
|
|
16
15
|
"@vitest/coverage-v8": "^2.0.0",
|
|
17
16
|
"clean-package": "^2.2.0",
|
|
@@ -56,7 +55,8 @@
|
|
|
56
55
|
"test:watch": "ENVIRONMENT=test vitest",
|
|
57
56
|
"test:coverage": "ENVIRONMENT=test vitest --run --coverage",
|
|
58
57
|
"typecheck": "tsc --noEmit",
|
|
59
|
-
"lint": "biome
|
|
58
|
+
"lint": "biome lint .",
|
|
59
|
+
"lint:fix": "biome check --write .",
|
|
60
60
|
"format": "biome format --write ."
|
|
61
61
|
}
|
|
62
62
|
}
|