@agentfield/sdk 0.1.64 → 0.1.65-rc.10
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.d.ts +1 -91
- package/dist/index.js +13 -303
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -839,7 +839,6 @@ interface AgentConfig {
|
|
|
839
839
|
apiKey?: string;
|
|
840
840
|
did?: string;
|
|
841
841
|
privateKeyJwk?: string;
|
|
842
|
-
mcp?: MCPConfig;
|
|
843
842
|
deploymentType?: DeploymentType;
|
|
844
843
|
/** Enable decentralized local verification of incoming DID signatures. */
|
|
845
844
|
localVerification?: boolean;
|
|
@@ -869,19 +868,6 @@ interface MemoryConfig {
|
|
|
869
868
|
ttl?: number;
|
|
870
869
|
}
|
|
871
870
|
type MemoryScope = 'workflow' | 'session' | 'actor' | 'global';
|
|
872
|
-
interface MCPServerConfig {
|
|
873
|
-
alias: string;
|
|
874
|
-
url?: string;
|
|
875
|
-
port?: number;
|
|
876
|
-
transport?: 'http' | 'bridge';
|
|
877
|
-
headers?: Record<string, string>;
|
|
878
|
-
}
|
|
879
|
-
interface MCPConfig {
|
|
880
|
-
servers?: MCPServerConfig[];
|
|
881
|
-
autoRegisterTools?: boolean;
|
|
882
|
-
namespace?: string;
|
|
883
|
-
tags?: string[];
|
|
884
|
-
}
|
|
885
871
|
interface AgentCapability {
|
|
886
872
|
agentId: string;
|
|
887
873
|
baseUrl: string;
|
|
@@ -1055,29 +1041,6 @@ declare class HarnessRunner {
|
|
|
1055
1041
|
private sleep;
|
|
1056
1042
|
}
|
|
1057
1043
|
|
|
1058
|
-
interface MCPTool {
|
|
1059
|
-
name: string;
|
|
1060
|
-
description?: string;
|
|
1061
|
-
inputSchema?: any;
|
|
1062
|
-
input_schema?: any;
|
|
1063
|
-
}
|
|
1064
|
-
interface MCPToolRegistration {
|
|
1065
|
-
server: string;
|
|
1066
|
-
skillName: string;
|
|
1067
|
-
tool: MCPTool;
|
|
1068
|
-
}
|
|
1069
|
-
interface MCPHealthSummary {
|
|
1070
|
-
status: 'ok' | 'degraded' | 'disabled';
|
|
1071
|
-
totalServers: number;
|
|
1072
|
-
healthyServers: number;
|
|
1073
|
-
servers: Array<{
|
|
1074
|
-
alias: string;
|
|
1075
|
-
baseUrl: string;
|
|
1076
|
-
transport: 'http' | 'bridge';
|
|
1077
|
-
healthy: boolean;
|
|
1078
|
-
}>;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
1044
|
declare class Agent {
|
|
1082
1045
|
readonly config: AgentConfig;
|
|
1083
1046
|
readonly app: express.Express;
|
|
@@ -1092,8 +1055,6 @@ declare class Agent {
|
|
|
1092
1055
|
private readonly didClient;
|
|
1093
1056
|
private readonly didManager;
|
|
1094
1057
|
private readonly memoryWatchers;
|
|
1095
|
-
private readonly mcpClientRegistry?;
|
|
1096
|
-
private readonly mcpToolRegistrar?;
|
|
1097
1058
|
private readonly localVerifier?;
|
|
1098
1059
|
private readonly realtimeValidationFunctions;
|
|
1099
1060
|
private readonly processLogRing;
|
|
@@ -1108,9 +1069,6 @@ declare class Agent {
|
|
|
1108
1069
|
scopeId?: string;
|
|
1109
1070
|
}): void;
|
|
1110
1071
|
discover(options?: DiscoveryOptions): Promise<DiscoveryResult>;
|
|
1111
|
-
registerMcpTools(): Promise<{
|
|
1112
|
-
registered: MCPToolRegistration[];
|
|
1113
|
-
}>;
|
|
1114
1072
|
getAIClient(): AIClient;
|
|
1115
1073
|
getExecutionLogger(): ExecutionLogger;
|
|
1116
1074
|
getHarnessRunner(): Promise<HarnessRunner>;
|
|
@@ -1148,7 +1106,6 @@ declare class Agent {
|
|
|
1148
1106
|
private waitForApproval;
|
|
1149
1107
|
private startHeartbeat;
|
|
1150
1108
|
private health;
|
|
1151
|
-
private mcpStatus;
|
|
1152
1109
|
private dispatchMemoryEvent;
|
|
1153
1110
|
private parseTarget;
|
|
1154
1111
|
}
|
|
@@ -1221,53 +1178,6 @@ declare class DidManager {
|
|
|
1221
1178
|
getIdentitySummary(): Record<string, any>;
|
|
1222
1179
|
}
|
|
1223
1180
|
|
|
1224
|
-
declare class MCPClient {
|
|
1225
|
-
readonly alias: string;
|
|
1226
|
-
readonly baseUrl: string;
|
|
1227
|
-
readonly transport: 'http' | 'bridge';
|
|
1228
|
-
private readonly http;
|
|
1229
|
-
private readonly devMode;
|
|
1230
|
-
private lastHealthy;
|
|
1231
|
-
constructor(config: MCPServerConfig, devMode?: boolean);
|
|
1232
|
-
healthCheck(): Promise<boolean>;
|
|
1233
|
-
listTools(): Promise<MCPTool[]>;
|
|
1234
|
-
callTool(toolName: string, arguments_?: Record<string, any>): Promise<any>;
|
|
1235
|
-
get lastHealthStatus(): boolean;
|
|
1236
|
-
private normalizeTools;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
declare class MCPClientRegistry {
|
|
1240
|
-
private readonly clients;
|
|
1241
|
-
private readonly devMode;
|
|
1242
|
-
constructor(devMode?: boolean);
|
|
1243
|
-
register(config: MCPServerConfig): MCPClient;
|
|
1244
|
-
get(alias: string): MCPClient | undefined;
|
|
1245
|
-
list(): MCPClient[];
|
|
1246
|
-
clear(): void;
|
|
1247
|
-
healthSummary(): Promise<MCPHealthSummary>;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
interface MCPToolRegistrarOptions {
|
|
1251
|
-
namespace?: string;
|
|
1252
|
-
tags?: string[];
|
|
1253
|
-
devMode?: boolean;
|
|
1254
|
-
}
|
|
1255
|
-
declare class MCPToolRegistrar {
|
|
1256
|
-
private readonly agent;
|
|
1257
|
-
private readonly registry;
|
|
1258
|
-
private readonly options;
|
|
1259
|
-
private readonly registered;
|
|
1260
|
-
private readonly devMode;
|
|
1261
|
-
constructor(agent: Agent, registry: MCPClientRegistry, options?: MCPToolRegistrarOptions);
|
|
1262
|
-
registerServers(servers: MCPServerConfig[]): void;
|
|
1263
|
-
registerAll(): Promise<{
|
|
1264
|
-
registered: MCPToolRegistration[];
|
|
1265
|
-
}>;
|
|
1266
|
-
private buildTags;
|
|
1267
|
-
private buildSkillName;
|
|
1268
|
-
private sanitize;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
1181
|
declare class RateLimitError extends Error {
|
|
1272
1182
|
retryAfter?: number;
|
|
1273
1183
|
constructor(message: string, retryAfter?: number);
|
|
@@ -1729,4 +1639,4 @@ declare class ApprovalClient {
|
|
|
1729
1639
|
waitForApproval(executionId: string, opts?: WaitForApprovalOptions): Promise<ApprovalStatusResponse>;
|
|
1730
1640
|
}
|
|
1731
1641
|
|
|
1732
|
-
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalRequestResponse, type ApprovalStatusResponse, Audio, type AudioOutput, type AuditTrailExport, type AuditTrailFilters, type Awaitable, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessOptions, type HarnessProvider, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput,
|
|
1642
|
+
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalRequestResponse, type ApprovalStatusResponse, Audio, type AudioOutput, type AuditTrailExport, type AuditTrailFilters, type Awaitable, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessOptions, type HarnessProvider, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput, type MemoryChangeEvent, MemoryClient, MemoryClientBase, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, type MemoryEventHistoryOptions, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, type Metrics, type MultimodalContent, MultimodalResponse, RateLimitError, type RateLimiterOptions, type RawResult, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, SUPPORTED_PROVIDERS, type ServerlessAdapter, type ServerlessEvent, type ServerlessResponse, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, TERMINAL_STATUSES, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolsOption, type VectorSearchOptions, type VectorSearchResult, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type ZodSchema, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, executeToolCallLoop, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeStatus, serializeExecutionLogEntry, text };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import express from 'express';
|
|
|
7
7
|
import rateLimit from 'express-rate-limit';
|
|
8
8
|
import crypto2, { randomUUID, createHash } from 'crypto';
|
|
9
9
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
10
|
-
import { tool, jsonSchema, generateText, stepCountIs,
|
|
10
|
+
import { tool, jsonSchema, generateText, stepCountIs, streamText, embed, embedMany, generateObject } from 'ai';
|
|
11
11
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
12
12
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
13
13
|
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
@@ -17,7 +17,7 @@ import { createXai } from '@ai-sdk/xai';
|
|
|
17
17
|
import { createDeepSeek } from '@ai-sdk/deepseek';
|
|
18
18
|
import { createCohere } from '@ai-sdk/cohere';
|
|
19
19
|
import os from 'os';
|
|
20
|
-
import
|
|
20
|
+
import axios4, { isAxiosError } from 'axios';
|
|
21
21
|
import http from 'http';
|
|
22
22
|
import https from 'https';
|
|
23
23
|
import WebSocket from 'ws';
|
|
@@ -1592,12 +1592,10 @@ var AIClient = class {
|
|
|
1592
1592
|
const model = this.buildModel(options);
|
|
1593
1593
|
if (options.schema) {
|
|
1594
1594
|
const schema = options.schema;
|
|
1595
|
-
const mode = options.mode ?? "json";
|
|
1596
1595
|
const call2 = async () => generateObject({
|
|
1597
1596
|
model,
|
|
1598
1597
|
prompt,
|
|
1599
1598
|
output: "object",
|
|
1600
|
-
mode,
|
|
1601
1599
|
system: options.system,
|
|
1602
1600
|
temperature: options.temperature ?? this.config.temperature,
|
|
1603
1601
|
maxOutputTokens: options.maxTokens ?? this.config.maxTokens,
|
|
@@ -2021,7 +2019,7 @@ var AgentFieldClient = class {
|
|
|
2021
2019
|
didAuthenticator;
|
|
2022
2020
|
constructor(config) {
|
|
2023
2021
|
const baseURL = (config.agentFieldUrl ?? "http://localhost:8080").replace(/\/$/, "");
|
|
2024
|
-
this.http =
|
|
2022
|
+
this.http = axios4.create({
|
|
2025
2023
|
baseURL,
|
|
2026
2024
|
timeout: 3e4,
|
|
2027
2025
|
httpAgent,
|
|
@@ -2317,7 +2315,7 @@ var AgentFieldClient = class {
|
|
|
2317
2315
|
...executionHeaders,
|
|
2318
2316
|
...authHeaders
|
|
2319
2317
|
});
|
|
2320
|
-
|
|
2318
|
+
axios4.post(`${uiApiBaseUrl}/executions/note`, bodyStr, {
|
|
2321
2319
|
headers,
|
|
2322
2320
|
timeout: devMode ? 5e3 : 1e4,
|
|
2323
2321
|
httpAgent,
|
|
@@ -2330,7 +2328,7 @@ var MemoryClientBase = class {
|
|
|
2330
2328
|
http;
|
|
2331
2329
|
defaultHeaders;
|
|
2332
2330
|
constructor(baseUrl, defaultHeaders) {
|
|
2333
|
-
this.http =
|
|
2331
|
+
this.http = axios4.create({
|
|
2334
2332
|
baseURL: baseUrl.replace(/\/$/, ""),
|
|
2335
2333
|
timeout: 3e4,
|
|
2336
2334
|
httpAgent,
|
|
@@ -2758,7 +2756,7 @@ var DidClient = class {
|
|
|
2758
2756
|
http;
|
|
2759
2757
|
defaultHeaders;
|
|
2760
2758
|
constructor(baseUrl, defaultHeaders) {
|
|
2761
|
-
this.http =
|
|
2759
|
+
this.http = axios4.create({
|
|
2762
2760
|
baseURL: baseUrl.replace(/\/$/, ""),
|
|
2763
2761
|
timeout: 3e4,
|
|
2764
2762
|
httpAgent,
|
|
@@ -3130,237 +3128,6 @@ var WorkflowReporter = class {
|
|
|
3130
3128
|
});
|
|
3131
3129
|
}
|
|
3132
3130
|
};
|
|
3133
|
-
var MCPClient = class {
|
|
3134
|
-
alias;
|
|
3135
|
-
baseUrl;
|
|
3136
|
-
transport;
|
|
3137
|
-
http;
|
|
3138
|
-
devMode;
|
|
3139
|
-
lastHealthy = false;
|
|
3140
|
-
constructor(config, devMode) {
|
|
3141
|
-
if (!config.alias) {
|
|
3142
|
-
throw new Error("MCP server alias is required");
|
|
3143
|
-
}
|
|
3144
|
-
if (!config.url && !config.port) {
|
|
3145
|
-
throw new Error(`MCP server "${config.alias}" requires a url or port`);
|
|
3146
|
-
}
|
|
3147
|
-
this.alias = config.alias;
|
|
3148
|
-
this.transport = config.transport ?? "http";
|
|
3149
|
-
this.baseUrl = (config.url ?? `http://localhost:${config.port}`).replace(/\/$/, "");
|
|
3150
|
-
this.http = axios5.create({
|
|
3151
|
-
baseURL: this.baseUrl,
|
|
3152
|
-
headers: config.headers,
|
|
3153
|
-
timeout: 3e4,
|
|
3154
|
-
httpAgent,
|
|
3155
|
-
httpsAgent
|
|
3156
|
-
});
|
|
3157
|
-
this.devMode = Boolean(devMode);
|
|
3158
|
-
}
|
|
3159
|
-
async healthCheck() {
|
|
3160
|
-
try {
|
|
3161
|
-
await this.http.get("/health");
|
|
3162
|
-
this.lastHealthy = true;
|
|
3163
|
-
return true;
|
|
3164
|
-
} catch (err) {
|
|
3165
|
-
this.lastHealthy = false;
|
|
3166
|
-
if (this.devMode) {
|
|
3167
|
-
console.warn(`MCP health check failed for ${this.alias}:`, err instanceof Error ? err.message : err);
|
|
3168
|
-
}
|
|
3169
|
-
return false;
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
async listTools() {
|
|
3173
|
-
try {
|
|
3174
|
-
if (this.transport === "bridge") {
|
|
3175
|
-
const res2 = await this.http.post("/mcp/tools/list");
|
|
3176
|
-
const tools2 = res2.data?.tools ?? [];
|
|
3177
|
-
return this.normalizeTools(tools2);
|
|
3178
|
-
}
|
|
3179
|
-
const res = await this.http.post("/mcp/v1", {
|
|
3180
|
-
jsonrpc: "2.0",
|
|
3181
|
-
id: Date.now(),
|
|
3182
|
-
method: "tools/list",
|
|
3183
|
-
params: {}
|
|
3184
|
-
});
|
|
3185
|
-
const tools = res.data?.result?.tools ?? [];
|
|
3186
|
-
return this.normalizeTools(tools);
|
|
3187
|
-
} catch (err) {
|
|
3188
|
-
if (this.devMode) {
|
|
3189
|
-
console.warn(`MCP listTools failed for ${this.alias}:`, err instanceof Error ? err.message : err);
|
|
3190
|
-
}
|
|
3191
|
-
return [];
|
|
3192
|
-
}
|
|
3193
|
-
}
|
|
3194
|
-
async callTool(toolName, arguments_ = {}) {
|
|
3195
|
-
if (!toolName) {
|
|
3196
|
-
throw new Error("toolName is required");
|
|
3197
|
-
}
|
|
3198
|
-
try {
|
|
3199
|
-
if (this.transport === "bridge") {
|
|
3200
|
-
const res2 = await this.http.post("/mcp/tools/call", {
|
|
3201
|
-
tool_name: toolName,
|
|
3202
|
-
arguments: arguments_
|
|
3203
|
-
});
|
|
3204
|
-
return res2.data?.result ?? res2.data;
|
|
3205
|
-
}
|
|
3206
|
-
const res = await this.http.post("/mcp/v1", {
|
|
3207
|
-
jsonrpc: "2.0",
|
|
3208
|
-
id: Date.now(),
|
|
3209
|
-
method: "tools/call",
|
|
3210
|
-
params: { name: toolName, arguments: arguments_ }
|
|
3211
|
-
});
|
|
3212
|
-
if (res.data?.error) {
|
|
3213
|
-
throw new Error(String(res.data.error?.message ?? res.data.error));
|
|
3214
|
-
}
|
|
3215
|
-
if (res.data?.result !== void 0) {
|
|
3216
|
-
return res.data.result;
|
|
3217
|
-
}
|
|
3218
|
-
return res.data;
|
|
3219
|
-
} catch (err) {
|
|
3220
|
-
if (this.devMode) {
|
|
3221
|
-
console.warn(`MCP callTool failed for ${this.alias}.${toolName}:`, err instanceof Error ? err.message : err);
|
|
3222
|
-
}
|
|
3223
|
-
throw err;
|
|
3224
|
-
}
|
|
3225
|
-
}
|
|
3226
|
-
get lastHealthStatus() {
|
|
3227
|
-
return this.lastHealthy;
|
|
3228
|
-
}
|
|
3229
|
-
normalizeTools(tools) {
|
|
3230
|
-
return (tools ?? []).map((tool2) => ({
|
|
3231
|
-
name: tool2?.name ?? "unknown",
|
|
3232
|
-
description: tool2?.description,
|
|
3233
|
-
inputSchema: tool2?.inputSchema ?? tool2?.input_schema,
|
|
3234
|
-
input_schema: tool2?.input_schema
|
|
3235
|
-
}));
|
|
3236
|
-
}
|
|
3237
|
-
};
|
|
3238
|
-
|
|
3239
|
-
// src/mcp/MCPClientRegistry.ts
|
|
3240
|
-
var MCPClientRegistry = class {
|
|
3241
|
-
clients = /* @__PURE__ */ new Map();
|
|
3242
|
-
devMode;
|
|
3243
|
-
constructor(devMode) {
|
|
3244
|
-
this.devMode = Boolean(devMode);
|
|
3245
|
-
}
|
|
3246
|
-
register(config) {
|
|
3247
|
-
const client = new MCPClient(config, this.devMode);
|
|
3248
|
-
this.clients.set(config.alias, client);
|
|
3249
|
-
return client;
|
|
3250
|
-
}
|
|
3251
|
-
get(alias) {
|
|
3252
|
-
return this.clients.get(alias);
|
|
3253
|
-
}
|
|
3254
|
-
list() {
|
|
3255
|
-
return Array.from(this.clients.values());
|
|
3256
|
-
}
|
|
3257
|
-
clear() {
|
|
3258
|
-
this.clients.clear();
|
|
3259
|
-
}
|
|
3260
|
-
async healthSummary() {
|
|
3261
|
-
if (!this.clients.size) {
|
|
3262
|
-
return {
|
|
3263
|
-
status: "disabled",
|
|
3264
|
-
totalServers: 0,
|
|
3265
|
-
healthyServers: 0,
|
|
3266
|
-
servers: []
|
|
3267
|
-
};
|
|
3268
|
-
}
|
|
3269
|
-
const results = await Promise.all(
|
|
3270
|
-
Array.from(this.clients.values()).map(async (client) => {
|
|
3271
|
-
const healthy = await client.healthCheck();
|
|
3272
|
-
return {
|
|
3273
|
-
alias: client.alias,
|
|
3274
|
-
baseUrl: client.baseUrl,
|
|
3275
|
-
transport: client.transport,
|
|
3276
|
-
healthy
|
|
3277
|
-
};
|
|
3278
|
-
})
|
|
3279
|
-
);
|
|
3280
|
-
const healthyCount = results.filter((r) => r.healthy).length;
|
|
3281
|
-
const status = healthyCount === 0 ? "degraded" : healthyCount === results.length ? "ok" : "degraded";
|
|
3282
|
-
return {
|
|
3283
|
-
status,
|
|
3284
|
-
totalServers: results.length,
|
|
3285
|
-
healthyServers: healthyCount,
|
|
3286
|
-
servers: results
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
};
|
|
3290
|
-
|
|
3291
|
-
// src/mcp/MCPToolRegistrar.ts
|
|
3292
|
-
var MCPToolRegistrar = class {
|
|
3293
|
-
constructor(agent, registry, options = {}) {
|
|
3294
|
-
this.agent = agent;
|
|
3295
|
-
this.registry = registry;
|
|
3296
|
-
this.options = options;
|
|
3297
|
-
this.devMode = Boolean(options.devMode);
|
|
3298
|
-
}
|
|
3299
|
-
registered = /* @__PURE__ */ new Set();
|
|
3300
|
-
devMode;
|
|
3301
|
-
registerServers(servers) {
|
|
3302
|
-
servers.forEach((server) => this.registry.register(server));
|
|
3303
|
-
}
|
|
3304
|
-
async registerAll() {
|
|
3305
|
-
const registrations = [];
|
|
3306
|
-
const clients = this.registry.list();
|
|
3307
|
-
for (const client of clients) {
|
|
3308
|
-
const healthy = await client.healthCheck();
|
|
3309
|
-
if (!healthy) {
|
|
3310
|
-
if (this.devMode) {
|
|
3311
|
-
console.warn(`Skipping MCP server ${client.alias} (health check failed)`);
|
|
3312
|
-
}
|
|
3313
|
-
continue;
|
|
3314
|
-
}
|
|
3315
|
-
const tools = await client.listTools();
|
|
3316
|
-
for (const tool2 of tools) {
|
|
3317
|
-
if (!tool2?.name) continue;
|
|
3318
|
-
const skillName = this.buildSkillName(client.alias, tool2.name);
|
|
3319
|
-
if (this.registered.has(skillName) || this.agent.skills.get(skillName)) {
|
|
3320
|
-
continue;
|
|
3321
|
-
}
|
|
3322
|
-
this.agent.skill(
|
|
3323
|
-
skillName,
|
|
3324
|
-
async (ctx) => {
|
|
3325
|
-
const args = ctx.input && typeof ctx.input === "object" ? ctx.input : {};
|
|
3326
|
-
const result = await client.callTool(tool2.name, args);
|
|
3327
|
-
return {
|
|
3328
|
-
status: "success",
|
|
3329
|
-
result,
|
|
3330
|
-
server: client.alias,
|
|
3331
|
-
tool: tool2.name
|
|
3332
|
-
};
|
|
3333
|
-
},
|
|
3334
|
-
{
|
|
3335
|
-
description: tool2.description ?? `MCP tool ${tool2.name} from ${client.alias}`,
|
|
3336
|
-
inputSchema: tool2.inputSchema ?? tool2.input_schema ?? {},
|
|
3337
|
-
tags: this.buildTags(client.alias)
|
|
3338
|
-
}
|
|
3339
|
-
);
|
|
3340
|
-
this.registered.add(skillName);
|
|
3341
|
-
registrations.push({ server: client.alias, skillName, tool: tool2 });
|
|
3342
|
-
if (this.devMode) {
|
|
3343
|
-
console.info(`Registered MCP skill ${skillName}`);
|
|
3344
|
-
}
|
|
3345
|
-
}
|
|
3346
|
-
}
|
|
3347
|
-
return { registered: registrations };
|
|
3348
|
-
}
|
|
3349
|
-
buildTags(alias) {
|
|
3350
|
-
return Array.from(/* @__PURE__ */ new Set(["mcp", alias, ...this.options.tags ?? []]));
|
|
3351
|
-
}
|
|
3352
|
-
buildSkillName(serverAlias, toolName) {
|
|
3353
|
-
const base = [this.options.namespace, serverAlias, toolName].filter(Boolean).join("_");
|
|
3354
|
-
return this.sanitize(base);
|
|
3355
|
-
}
|
|
3356
|
-
sanitize(value) {
|
|
3357
|
-
const collapsed = value.replace(/[^a-zA-Z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
3358
|
-
if (/^[0-9]/.test(collapsed)) {
|
|
3359
|
-
return `mcp_${collapsed}`;
|
|
3360
|
-
}
|
|
3361
|
-
return collapsed || "mcp_tool";
|
|
3362
|
-
}
|
|
3363
|
-
};
|
|
3364
3131
|
var LocalVerifier = class {
|
|
3365
3132
|
agentFieldUrl;
|
|
3366
3133
|
refreshInterval;
|
|
@@ -3389,7 +3156,7 @@ var LocalVerifier = class {
|
|
|
3389
3156
|
}
|
|
3390
3157
|
let success = true;
|
|
3391
3158
|
try {
|
|
3392
|
-
const resp = await
|
|
3159
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/policies`, {
|
|
3393
3160
|
headers,
|
|
3394
3161
|
timeout: 1e4
|
|
3395
3162
|
});
|
|
@@ -3402,7 +3169,7 @@ var LocalVerifier = class {
|
|
|
3402
3169
|
success = false;
|
|
3403
3170
|
}
|
|
3404
3171
|
try {
|
|
3405
|
-
const resp = await
|
|
3172
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/revocations`, {
|
|
3406
3173
|
headers,
|
|
3407
3174
|
timeout: 1e4
|
|
3408
3175
|
});
|
|
@@ -3415,7 +3182,7 @@ var LocalVerifier = class {
|
|
|
3415
3182
|
success = false;
|
|
3416
3183
|
}
|
|
3417
3184
|
try {
|
|
3418
|
-
const resp = await
|
|
3185
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/registered-dids`, {
|
|
3419
3186
|
headers,
|
|
3420
3187
|
timeout: 1e4
|
|
3421
3188
|
});
|
|
@@ -3428,7 +3195,7 @@ var LocalVerifier = class {
|
|
|
3428
3195
|
success = false;
|
|
3429
3196
|
}
|
|
3430
3197
|
try {
|
|
3431
|
-
const resp = await
|
|
3198
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/admin/public-key`, {
|
|
3432
3199
|
headers,
|
|
3433
3200
|
timeout: 1e4
|
|
3434
3201
|
});
|
|
@@ -3757,25 +3524,18 @@ var Agent = class {
|
|
|
3757
3524
|
didClient;
|
|
3758
3525
|
didManager;
|
|
3759
3526
|
memoryWatchers = [];
|
|
3760
|
-
mcpClientRegistry;
|
|
3761
|
-
mcpToolRegistrar;
|
|
3762
3527
|
localVerifier;
|
|
3763
3528
|
realtimeValidationFunctions = /* @__PURE__ */ new Set();
|
|
3764
3529
|
processLogRing = new ProcessLogRing();
|
|
3765
3530
|
executionLogger;
|
|
3766
3531
|
constructor(config) {
|
|
3767
|
-
const mcp = config.mcp ? {
|
|
3768
|
-
autoRegisterTools: config.mcp.autoRegisterTools ?? true,
|
|
3769
|
-
...config.mcp
|
|
3770
|
-
} : void 0;
|
|
3771
3532
|
this.config = {
|
|
3772
3533
|
port: 8001,
|
|
3773
3534
|
agentFieldUrl: "http://localhost:8080",
|
|
3774
3535
|
host: "0.0.0.0",
|
|
3775
3536
|
...config,
|
|
3776
3537
|
didEnabled: config.didEnabled ?? true,
|
|
3777
|
-
deploymentType: config.deploymentType ?? "long_running"
|
|
3778
|
-
mcp
|
|
3538
|
+
deploymentType: config.deploymentType ?? "long_running"
|
|
3779
3539
|
};
|
|
3780
3540
|
this.app = express();
|
|
3781
3541
|
this.app.use(express.json());
|
|
@@ -3792,15 +3552,6 @@ var Agent = class {
|
|
|
3792
3552
|
}
|
|
3793
3553
|
});
|
|
3794
3554
|
this.memoryEventClient.onEvent((event) => this.dispatchMemoryEvent(event));
|
|
3795
|
-
if (this.config.mcp?.servers?.length) {
|
|
3796
|
-
this.mcpClientRegistry = new MCPClientRegistry(this.config.devMode);
|
|
3797
|
-
this.mcpToolRegistrar = new MCPToolRegistrar(this, this.mcpClientRegistry, {
|
|
3798
|
-
namespace: this.config.mcp.namespace,
|
|
3799
|
-
tags: this.config.mcp.tags,
|
|
3800
|
-
devMode: this.config.devMode
|
|
3801
|
-
});
|
|
3802
|
-
this.mcpToolRegistrar.registerServers(this.config.mcp.servers);
|
|
3803
|
-
}
|
|
3804
3555
|
if (this.config.localVerification && this.config.agentFieldUrl) {
|
|
3805
3556
|
this.localVerifier = new LocalVerifier(
|
|
3806
3557
|
this.config.agentFieldUrl,
|
|
@@ -3850,10 +3601,6 @@ var Agent = class {
|
|
|
3850
3601
|
discover(options) {
|
|
3851
3602
|
return this.agentFieldClient.discoverCapabilities(options);
|
|
3852
3603
|
}
|
|
3853
|
-
async registerMcpTools() {
|
|
3854
|
-
if (!this.mcpToolRegistrar) return { registered: [] };
|
|
3855
|
-
return this.mcpToolRegistrar.registerAll();
|
|
3856
|
-
}
|
|
3857
3604
|
getAIClient() {
|
|
3858
3605
|
return this.aiClient;
|
|
3859
3606
|
}
|
|
@@ -3950,15 +3697,6 @@ var Agent = class {
|
|
|
3950
3697
|
};
|
|
3951
3698
|
}
|
|
3952
3699
|
async serve() {
|
|
3953
|
-
if (this.config.mcp?.autoRegisterTools !== false) {
|
|
3954
|
-
try {
|
|
3955
|
-
await this.registerMcpTools();
|
|
3956
|
-
} catch (err) {
|
|
3957
|
-
if (this.config.devMode) {
|
|
3958
|
-
console.warn("MCP tool registration failed", err);
|
|
3959
|
-
}
|
|
3960
|
-
}
|
|
3961
|
-
}
|
|
3962
3700
|
await this.registerWithControlPlane();
|
|
3963
3701
|
if (this.localVerifier) {
|
|
3964
3702
|
try {
|
|
@@ -4230,21 +3968,6 @@ var Agent = class {
|
|
|
4230
3968
|
this.app.get("/discover", (_req, res) => {
|
|
4231
3969
|
res.json(this.discoveryPayload(this.config.deploymentType ?? "long_running"));
|
|
4232
3970
|
});
|
|
4233
|
-
this.app.get("/health/mcp", async (_req, res) => {
|
|
4234
|
-
if (!this.mcpClientRegistry) {
|
|
4235
|
-
res.json({ status: "disabled", totalServers: 0, healthyServers: 0, servers: [] });
|
|
4236
|
-
return;
|
|
4237
|
-
}
|
|
4238
|
-
try {
|
|
4239
|
-
const summary = await this.mcpClientRegistry.healthSummary();
|
|
4240
|
-
res.json(summary);
|
|
4241
|
-
} catch (err) {
|
|
4242
|
-
res.status(500).json({ status: "error", error: err?.message ?? "MCP health check failed" });
|
|
4243
|
-
}
|
|
4244
|
-
});
|
|
4245
|
-
this.app.get("/mcp/status", (_req, res) => {
|
|
4246
|
-
res.json(this.mcpStatus());
|
|
4247
|
-
});
|
|
4248
3971
|
this.app.get("/status", (_req, res) => {
|
|
4249
3972
|
res.json({
|
|
4250
3973
|
...this.health(),
|
|
@@ -5007,19 +4730,6 @@ var Agent = class {
|
|
|
5007
4730
|
version: this.config.version
|
|
5008
4731
|
};
|
|
5009
4732
|
}
|
|
5010
|
-
mcpStatus() {
|
|
5011
|
-
const servers = this.mcpClientRegistry ? this.mcpClientRegistry.list().map((client) => ({
|
|
5012
|
-
alias: client.alias,
|
|
5013
|
-
baseUrl: client.baseUrl,
|
|
5014
|
-
transport: client.transport
|
|
5015
|
-
})) : [];
|
|
5016
|
-
const skills = this.skills.all().filter((skill) => skill.options?.tags?.includes("mcp")).map((skill) => skill.name);
|
|
5017
|
-
return {
|
|
5018
|
-
status: servers.length ? "configured" : "disabled",
|
|
5019
|
-
servers,
|
|
5020
|
-
skills
|
|
5021
|
-
};
|
|
5022
|
-
}
|
|
5023
4733
|
dispatchMemoryEvent(event) {
|
|
5024
4734
|
this.memoryWatchers.forEach(({ pattern, handler, scope, scopeId }) => {
|
|
5025
4735
|
const scopeMatch = (!scope || scope === event.scope) && (!scopeId || scopeId === event.scopeId);
|
|
@@ -5716,7 +5426,7 @@ var ApprovalClient = class {
|
|
|
5716
5426
|
nodeId;
|
|
5717
5427
|
headers;
|
|
5718
5428
|
constructor(opts) {
|
|
5719
|
-
this.http =
|
|
5429
|
+
this.http = axios4.create({
|
|
5720
5430
|
baseURL: opts.baseURL.replace(/\/$/, ""),
|
|
5721
5431
|
timeout: 3e4,
|
|
5722
5432
|
httpAgent,
|
|
@@ -5810,6 +5520,6 @@ function sleep(ms) {
|
|
|
5810
5520
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
5811
5521
|
}
|
|
5812
5522
|
|
|
5813
|
-
export { ACTIVE_STATUSES, AIClient, Agent, AgentRouter, ApprovalClient, Audio, CANONICAL_STATUSES, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionLogger, ExecutionStatus, File, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessRunner, Image,
|
|
5523
|
+
export { ACTIVE_STATUSES, AIClient, Agent, AgentRouter, ApprovalClient, Audio, CANONICAL_STATUSES, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionLogger, ExecutionStatus, File, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessRunner, Image, MemoryClient, MemoryClientBase, MemoryEventClient, MemoryInterface, MultimodalResponse, RateLimitError, ReasonerContext, SUPPORTED_PROVIDERS, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, Text, WorkflowReporter, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, executeToolCallLoop, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeStatus, serializeExecutionLogEntry, text };
|
|
5814
5524
|
//# sourceMappingURL=index.js.map
|
|
5815
5525
|
//# sourceMappingURL=index.js.map
|