@agentfield/sdk 0.1.65-rc.3 → 0.1.65-rc.5
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 +12 -300
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
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
|
@@ -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';
|
|
@@ -2019,7 +2019,7 @@ var AgentFieldClient = class {
|
|
|
2019
2019
|
didAuthenticator;
|
|
2020
2020
|
constructor(config) {
|
|
2021
2021
|
const baseURL = (config.agentFieldUrl ?? "http://localhost:8080").replace(/\/$/, "");
|
|
2022
|
-
this.http =
|
|
2022
|
+
this.http = axios4.create({
|
|
2023
2023
|
baseURL,
|
|
2024
2024
|
timeout: 3e4,
|
|
2025
2025
|
httpAgent,
|
|
@@ -2315,7 +2315,7 @@ var AgentFieldClient = class {
|
|
|
2315
2315
|
...executionHeaders,
|
|
2316
2316
|
...authHeaders
|
|
2317
2317
|
});
|
|
2318
|
-
|
|
2318
|
+
axios4.post(`${uiApiBaseUrl}/executions/note`, bodyStr, {
|
|
2319
2319
|
headers,
|
|
2320
2320
|
timeout: devMode ? 5e3 : 1e4,
|
|
2321
2321
|
httpAgent,
|
|
@@ -2328,7 +2328,7 @@ var MemoryClientBase = class {
|
|
|
2328
2328
|
http;
|
|
2329
2329
|
defaultHeaders;
|
|
2330
2330
|
constructor(baseUrl, defaultHeaders) {
|
|
2331
|
-
this.http =
|
|
2331
|
+
this.http = axios4.create({
|
|
2332
2332
|
baseURL: baseUrl.replace(/\/$/, ""),
|
|
2333
2333
|
timeout: 3e4,
|
|
2334
2334
|
httpAgent,
|
|
@@ -2756,7 +2756,7 @@ var DidClient = class {
|
|
|
2756
2756
|
http;
|
|
2757
2757
|
defaultHeaders;
|
|
2758
2758
|
constructor(baseUrl, defaultHeaders) {
|
|
2759
|
-
this.http =
|
|
2759
|
+
this.http = axios4.create({
|
|
2760
2760
|
baseURL: baseUrl.replace(/\/$/, ""),
|
|
2761
2761
|
timeout: 3e4,
|
|
2762
2762
|
httpAgent,
|
|
@@ -3128,237 +3128,6 @@ var WorkflowReporter = class {
|
|
|
3128
3128
|
});
|
|
3129
3129
|
}
|
|
3130
3130
|
};
|
|
3131
|
-
var MCPClient = class {
|
|
3132
|
-
alias;
|
|
3133
|
-
baseUrl;
|
|
3134
|
-
transport;
|
|
3135
|
-
http;
|
|
3136
|
-
devMode;
|
|
3137
|
-
lastHealthy = false;
|
|
3138
|
-
constructor(config, devMode) {
|
|
3139
|
-
if (!config.alias) {
|
|
3140
|
-
throw new Error("MCP server alias is required");
|
|
3141
|
-
}
|
|
3142
|
-
if (!config.url && !config.port) {
|
|
3143
|
-
throw new Error(`MCP server "${config.alias}" requires a url or port`);
|
|
3144
|
-
}
|
|
3145
|
-
this.alias = config.alias;
|
|
3146
|
-
this.transport = config.transport ?? "http";
|
|
3147
|
-
this.baseUrl = (config.url ?? `http://localhost:${config.port}`).replace(/\/$/, "");
|
|
3148
|
-
this.http = axios5.create({
|
|
3149
|
-
baseURL: this.baseUrl,
|
|
3150
|
-
headers: config.headers,
|
|
3151
|
-
timeout: 3e4,
|
|
3152
|
-
httpAgent,
|
|
3153
|
-
httpsAgent
|
|
3154
|
-
});
|
|
3155
|
-
this.devMode = Boolean(devMode);
|
|
3156
|
-
}
|
|
3157
|
-
async healthCheck() {
|
|
3158
|
-
try {
|
|
3159
|
-
await this.http.get("/health");
|
|
3160
|
-
this.lastHealthy = true;
|
|
3161
|
-
return true;
|
|
3162
|
-
} catch (err) {
|
|
3163
|
-
this.lastHealthy = false;
|
|
3164
|
-
if (this.devMode) {
|
|
3165
|
-
console.warn(`MCP health check failed for ${this.alias}:`, err instanceof Error ? err.message : err);
|
|
3166
|
-
}
|
|
3167
|
-
return false;
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
|
-
async listTools() {
|
|
3171
|
-
try {
|
|
3172
|
-
if (this.transport === "bridge") {
|
|
3173
|
-
const res2 = await this.http.post("/mcp/tools/list");
|
|
3174
|
-
const tools2 = res2.data?.tools ?? [];
|
|
3175
|
-
return this.normalizeTools(tools2);
|
|
3176
|
-
}
|
|
3177
|
-
const res = await this.http.post("/mcp/v1", {
|
|
3178
|
-
jsonrpc: "2.0",
|
|
3179
|
-
id: Date.now(),
|
|
3180
|
-
method: "tools/list",
|
|
3181
|
-
params: {}
|
|
3182
|
-
});
|
|
3183
|
-
const tools = res.data?.result?.tools ?? [];
|
|
3184
|
-
return this.normalizeTools(tools);
|
|
3185
|
-
} catch (err) {
|
|
3186
|
-
if (this.devMode) {
|
|
3187
|
-
console.warn(`MCP listTools failed for ${this.alias}:`, err instanceof Error ? err.message : err);
|
|
3188
|
-
}
|
|
3189
|
-
return [];
|
|
3190
|
-
}
|
|
3191
|
-
}
|
|
3192
|
-
async callTool(toolName, arguments_ = {}) {
|
|
3193
|
-
if (!toolName) {
|
|
3194
|
-
throw new Error("toolName is required");
|
|
3195
|
-
}
|
|
3196
|
-
try {
|
|
3197
|
-
if (this.transport === "bridge") {
|
|
3198
|
-
const res2 = await this.http.post("/mcp/tools/call", {
|
|
3199
|
-
tool_name: toolName,
|
|
3200
|
-
arguments: arguments_
|
|
3201
|
-
});
|
|
3202
|
-
return res2.data?.result ?? res2.data;
|
|
3203
|
-
}
|
|
3204
|
-
const res = await this.http.post("/mcp/v1", {
|
|
3205
|
-
jsonrpc: "2.0",
|
|
3206
|
-
id: Date.now(),
|
|
3207
|
-
method: "tools/call",
|
|
3208
|
-
params: { name: toolName, arguments: arguments_ }
|
|
3209
|
-
});
|
|
3210
|
-
if (res.data?.error) {
|
|
3211
|
-
throw new Error(String(res.data.error?.message ?? res.data.error));
|
|
3212
|
-
}
|
|
3213
|
-
if (res.data?.result !== void 0) {
|
|
3214
|
-
return res.data.result;
|
|
3215
|
-
}
|
|
3216
|
-
return res.data;
|
|
3217
|
-
} catch (err) {
|
|
3218
|
-
if (this.devMode) {
|
|
3219
|
-
console.warn(`MCP callTool failed for ${this.alias}.${toolName}:`, err instanceof Error ? err.message : err);
|
|
3220
|
-
}
|
|
3221
|
-
throw err;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
get lastHealthStatus() {
|
|
3225
|
-
return this.lastHealthy;
|
|
3226
|
-
}
|
|
3227
|
-
normalizeTools(tools) {
|
|
3228
|
-
return (tools ?? []).map((tool2) => ({
|
|
3229
|
-
name: tool2?.name ?? "unknown",
|
|
3230
|
-
description: tool2?.description,
|
|
3231
|
-
inputSchema: tool2?.inputSchema ?? tool2?.input_schema,
|
|
3232
|
-
input_schema: tool2?.input_schema
|
|
3233
|
-
}));
|
|
3234
|
-
}
|
|
3235
|
-
};
|
|
3236
|
-
|
|
3237
|
-
// src/mcp/MCPClientRegistry.ts
|
|
3238
|
-
var MCPClientRegistry = class {
|
|
3239
|
-
clients = /* @__PURE__ */ new Map();
|
|
3240
|
-
devMode;
|
|
3241
|
-
constructor(devMode) {
|
|
3242
|
-
this.devMode = Boolean(devMode);
|
|
3243
|
-
}
|
|
3244
|
-
register(config) {
|
|
3245
|
-
const client = new MCPClient(config, this.devMode);
|
|
3246
|
-
this.clients.set(config.alias, client);
|
|
3247
|
-
return client;
|
|
3248
|
-
}
|
|
3249
|
-
get(alias) {
|
|
3250
|
-
return this.clients.get(alias);
|
|
3251
|
-
}
|
|
3252
|
-
list() {
|
|
3253
|
-
return Array.from(this.clients.values());
|
|
3254
|
-
}
|
|
3255
|
-
clear() {
|
|
3256
|
-
this.clients.clear();
|
|
3257
|
-
}
|
|
3258
|
-
async healthSummary() {
|
|
3259
|
-
if (!this.clients.size) {
|
|
3260
|
-
return {
|
|
3261
|
-
status: "disabled",
|
|
3262
|
-
totalServers: 0,
|
|
3263
|
-
healthyServers: 0,
|
|
3264
|
-
servers: []
|
|
3265
|
-
};
|
|
3266
|
-
}
|
|
3267
|
-
const results = await Promise.all(
|
|
3268
|
-
Array.from(this.clients.values()).map(async (client) => {
|
|
3269
|
-
const healthy = await client.healthCheck();
|
|
3270
|
-
return {
|
|
3271
|
-
alias: client.alias,
|
|
3272
|
-
baseUrl: client.baseUrl,
|
|
3273
|
-
transport: client.transport,
|
|
3274
|
-
healthy
|
|
3275
|
-
};
|
|
3276
|
-
})
|
|
3277
|
-
);
|
|
3278
|
-
const healthyCount = results.filter((r) => r.healthy).length;
|
|
3279
|
-
const status = healthyCount === 0 ? "degraded" : healthyCount === results.length ? "ok" : "degraded";
|
|
3280
|
-
return {
|
|
3281
|
-
status,
|
|
3282
|
-
totalServers: results.length,
|
|
3283
|
-
healthyServers: healthyCount,
|
|
3284
|
-
servers: results
|
|
3285
|
-
};
|
|
3286
|
-
}
|
|
3287
|
-
};
|
|
3288
|
-
|
|
3289
|
-
// src/mcp/MCPToolRegistrar.ts
|
|
3290
|
-
var MCPToolRegistrar = class {
|
|
3291
|
-
constructor(agent, registry, options = {}) {
|
|
3292
|
-
this.agent = agent;
|
|
3293
|
-
this.registry = registry;
|
|
3294
|
-
this.options = options;
|
|
3295
|
-
this.devMode = Boolean(options.devMode);
|
|
3296
|
-
}
|
|
3297
|
-
registered = /* @__PURE__ */ new Set();
|
|
3298
|
-
devMode;
|
|
3299
|
-
registerServers(servers) {
|
|
3300
|
-
servers.forEach((server) => this.registry.register(server));
|
|
3301
|
-
}
|
|
3302
|
-
async registerAll() {
|
|
3303
|
-
const registrations = [];
|
|
3304
|
-
const clients = this.registry.list();
|
|
3305
|
-
for (const client of clients) {
|
|
3306
|
-
const healthy = await client.healthCheck();
|
|
3307
|
-
if (!healthy) {
|
|
3308
|
-
if (this.devMode) {
|
|
3309
|
-
console.warn(`Skipping MCP server ${client.alias} (health check failed)`);
|
|
3310
|
-
}
|
|
3311
|
-
continue;
|
|
3312
|
-
}
|
|
3313
|
-
const tools = await client.listTools();
|
|
3314
|
-
for (const tool2 of tools) {
|
|
3315
|
-
if (!tool2?.name) continue;
|
|
3316
|
-
const skillName = this.buildSkillName(client.alias, tool2.name);
|
|
3317
|
-
if (this.registered.has(skillName) || this.agent.skills.get(skillName)) {
|
|
3318
|
-
continue;
|
|
3319
|
-
}
|
|
3320
|
-
this.agent.skill(
|
|
3321
|
-
skillName,
|
|
3322
|
-
async (ctx) => {
|
|
3323
|
-
const args = ctx.input && typeof ctx.input === "object" ? ctx.input : {};
|
|
3324
|
-
const result = await client.callTool(tool2.name, args);
|
|
3325
|
-
return {
|
|
3326
|
-
status: "success",
|
|
3327
|
-
result,
|
|
3328
|
-
server: client.alias,
|
|
3329
|
-
tool: tool2.name
|
|
3330
|
-
};
|
|
3331
|
-
},
|
|
3332
|
-
{
|
|
3333
|
-
description: tool2.description ?? `MCP tool ${tool2.name} from ${client.alias}`,
|
|
3334
|
-
inputSchema: tool2.inputSchema ?? tool2.input_schema ?? {},
|
|
3335
|
-
tags: this.buildTags(client.alias)
|
|
3336
|
-
}
|
|
3337
|
-
);
|
|
3338
|
-
this.registered.add(skillName);
|
|
3339
|
-
registrations.push({ server: client.alias, skillName, tool: tool2 });
|
|
3340
|
-
if (this.devMode) {
|
|
3341
|
-
console.info(`Registered MCP skill ${skillName}`);
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
return { registered: registrations };
|
|
3346
|
-
}
|
|
3347
|
-
buildTags(alias) {
|
|
3348
|
-
return Array.from(/* @__PURE__ */ new Set(["mcp", alias, ...this.options.tags ?? []]));
|
|
3349
|
-
}
|
|
3350
|
-
buildSkillName(serverAlias, toolName) {
|
|
3351
|
-
const base = [this.options.namespace, serverAlias, toolName].filter(Boolean).join("_");
|
|
3352
|
-
return this.sanitize(base);
|
|
3353
|
-
}
|
|
3354
|
-
sanitize(value) {
|
|
3355
|
-
const collapsed = value.replace(/[^a-zA-Z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
3356
|
-
if (/^[0-9]/.test(collapsed)) {
|
|
3357
|
-
return `mcp_${collapsed}`;
|
|
3358
|
-
}
|
|
3359
|
-
return collapsed || "mcp_tool";
|
|
3360
|
-
}
|
|
3361
|
-
};
|
|
3362
3131
|
var LocalVerifier = class {
|
|
3363
3132
|
agentFieldUrl;
|
|
3364
3133
|
refreshInterval;
|
|
@@ -3387,7 +3156,7 @@ var LocalVerifier = class {
|
|
|
3387
3156
|
}
|
|
3388
3157
|
let success = true;
|
|
3389
3158
|
try {
|
|
3390
|
-
const resp = await
|
|
3159
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/policies`, {
|
|
3391
3160
|
headers,
|
|
3392
3161
|
timeout: 1e4
|
|
3393
3162
|
});
|
|
@@ -3400,7 +3169,7 @@ var LocalVerifier = class {
|
|
|
3400
3169
|
success = false;
|
|
3401
3170
|
}
|
|
3402
3171
|
try {
|
|
3403
|
-
const resp = await
|
|
3172
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/revocations`, {
|
|
3404
3173
|
headers,
|
|
3405
3174
|
timeout: 1e4
|
|
3406
3175
|
});
|
|
@@ -3413,7 +3182,7 @@ var LocalVerifier = class {
|
|
|
3413
3182
|
success = false;
|
|
3414
3183
|
}
|
|
3415
3184
|
try {
|
|
3416
|
-
const resp = await
|
|
3185
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/registered-dids`, {
|
|
3417
3186
|
headers,
|
|
3418
3187
|
timeout: 1e4
|
|
3419
3188
|
});
|
|
@@ -3426,7 +3195,7 @@ var LocalVerifier = class {
|
|
|
3426
3195
|
success = false;
|
|
3427
3196
|
}
|
|
3428
3197
|
try {
|
|
3429
|
-
const resp = await
|
|
3198
|
+
const resp = await axios4.get(`${this.agentFieldUrl}/api/v1/admin/public-key`, {
|
|
3430
3199
|
headers,
|
|
3431
3200
|
timeout: 1e4
|
|
3432
3201
|
});
|
|
@@ -3755,25 +3524,18 @@ var Agent = class {
|
|
|
3755
3524
|
didClient;
|
|
3756
3525
|
didManager;
|
|
3757
3526
|
memoryWatchers = [];
|
|
3758
|
-
mcpClientRegistry;
|
|
3759
|
-
mcpToolRegistrar;
|
|
3760
3527
|
localVerifier;
|
|
3761
3528
|
realtimeValidationFunctions = /* @__PURE__ */ new Set();
|
|
3762
3529
|
processLogRing = new ProcessLogRing();
|
|
3763
3530
|
executionLogger;
|
|
3764
3531
|
constructor(config) {
|
|
3765
|
-
const mcp = config.mcp ? {
|
|
3766
|
-
autoRegisterTools: config.mcp.autoRegisterTools ?? true,
|
|
3767
|
-
...config.mcp
|
|
3768
|
-
} : void 0;
|
|
3769
3532
|
this.config = {
|
|
3770
3533
|
port: 8001,
|
|
3771
3534
|
agentFieldUrl: "http://localhost:8080",
|
|
3772
3535
|
host: "0.0.0.0",
|
|
3773
3536
|
...config,
|
|
3774
3537
|
didEnabled: config.didEnabled ?? true,
|
|
3775
|
-
deploymentType: config.deploymentType ?? "long_running"
|
|
3776
|
-
mcp
|
|
3538
|
+
deploymentType: config.deploymentType ?? "long_running"
|
|
3777
3539
|
};
|
|
3778
3540
|
this.app = express();
|
|
3779
3541
|
this.app.use(express.json());
|
|
@@ -3790,15 +3552,6 @@ var Agent = class {
|
|
|
3790
3552
|
}
|
|
3791
3553
|
});
|
|
3792
3554
|
this.memoryEventClient.onEvent((event) => this.dispatchMemoryEvent(event));
|
|
3793
|
-
if (this.config.mcp?.servers?.length) {
|
|
3794
|
-
this.mcpClientRegistry = new MCPClientRegistry(this.config.devMode);
|
|
3795
|
-
this.mcpToolRegistrar = new MCPToolRegistrar(this, this.mcpClientRegistry, {
|
|
3796
|
-
namespace: this.config.mcp.namespace,
|
|
3797
|
-
tags: this.config.mcp.tags,
|
|
3798
|
-
devMode: this.config.devMode
|
|
3799
|
-
});
|
|
3800
|
-
this.mcpToolRegistrar.registerServers(this.config.mcp.servers);
|
|
3801
|
-
}
|
|
3802
3555
|
if (this.config.localVerification && this.config.agentFieldUrl) {
|
|
3803
3556
|
this.localVerifier = new LocalVerifier(
|
|
3804
3557
|
this.config.agentFieldUrl,
|
|
@@ -3848,10 +3601,6 @@ var Agent = class {
|
|
|
3848
3601
|
discover(options) {
|
|
3849
3602
|
return this.agentFieldClient.discoverCapabilities(options);
|
|
3850
3603
|
}
|
|
3851
|
-
async registerMcpTools() {
|
|
3852
|
-
if (!this.mcpToolRegistrar) return { registered: [] };
|
|
3853
|
-
return this.mcpToolRegistrar.registerAll();
|
|
3854
|
-
}
|
|
3855
3604
|
getAIClient() {
|
|
3856
3605
|
return this.aiClient;
|
|
3857
3606
|
}
|
|
@@ -3948,15 +3697,6 @@ var Agent = class {
|
|
|
3948
3697
|
};
|
|
3949
3698
|
}
|
|
3950
3699
|
async serve() {
|
|
3951
|
-
if (this.config.mcp?.autoRegisterTools !== false) {
|
|
3952
|
-
try {
|
|
3953
|
-
await this.registerMcpTools();
|
|
3954
|
-
} catch (err) {
|
|
3955
|
-
if (this.config.devMode) {
|
|
3956
|
-
console.warn("MCP tool registration failed", err);
|
|
3957
|
-
}
|
|
3958
|
-
}
|
|
3959
|
-
}
|
|
3960
3700
|
await this.registerWithControlPlane();
|
|
3961
3701
|
if (this.localVerifier) {
|
|
3962
3702
|
try {
|
|
@@ -4228,21 +3968,6 @@ var Agent = class {
|
|
|
4228
3968
|
this.app.get("/discover", (_req, res) => {
|
|
4229
3969
|
res.json(this.discoveryPayload(this.config.deploymentType ?? "long_running"));
|
|
4230
3970
|
});
|
|
4231
|
-
this.app.get("/health/mcp", async (_req, res) => {
|
|
4232
|
-
if (!this.mcpClientRegistry) {
|
|
4233
|
-
res.json({ status: "disabled", totalServers: 0, healthyServers: 0, servers: [] });
|
|
4234
|
-
return;
|
|
4235
|
-
}
|
|
4236
|
-
try {
|
|
4237
|
-
const summary = await this.mcpClientRegistry.healthSummary();
|
|
4238
|
-
res.json(summary);
|
|
4239
|
-
} catch (err) {
|
|
4240
|
-
res.status(500).json({ status: "error", error: err?.message ?? "MCP health check failed" });
|
|
4241
|
-
}
|
|
4242
|
-
});
|
|
4243
|
-
this.app.get("/mcp/status", (_req, res) => {
|
|
4244
|
-
res.json(this.mcpStatus());
|
|
4245
|
-
});
|
|
4246
3971
|
this.app.get("/status", (_req, res) => {
|
|
4247
3972
|
res.json({
|
|
4248
3973
|
...this.health(),
|
|
@@ -5005,19 +4730,6 @@ var Agent = class {
|
|
|
5005
4730
|
version: this.config.version
|
|
5006
4731
|
};
|
|
5007
4732
|
}
|
|
5008
|
-
mcpStatus() {
|
|
5009
|
-
const servers = this.mcpClientRegistry ? this.mcpClientRegistry.list().map((client) => ({
|
|
5010
|
-
alias: client.alias,
|
|
5011
|
-
baseUrl: client.baseUrl,
|
|
5012
|
-
transport: client.transport
|
|
5013
|
-
})) : [];
|
|
5014
|
-
const skills = this.skills.all().filter((skill) => skill.options?.tags?.includes("mcp")).map((skill) => skill.name);
|
|
5015
|
-
return {
|
|
5016
|
-
status: servers.length ? "configured" : "disabled",
|
|
5017
|
-
servers,
|
|
5018
|
-
skills
|
|
5019
|
-
};
|
|
5020
|
-
}
|
|
5021
4733
|
dispatchMemoryEvent(event) {
|
|
5022
4734
|
this.memoryWatchers.forEach(({ pattern, handler, scope, scopeId }) => {
|
|
5023
4735
|
const scopeMatch = (!scope || scope === event.scope) && (!scopeId || scopeId === event.scopeId);
|
|
@@ -5714,7 +5426,7 @@ var ApprovalClient = class {
|
|
|
5714
5426
|
nodeId;
|
|
5715
5427
|
headers;
|
|
5716
5428
|
constructor(opts) {
|
|
5717
|
-
this.http =
|
|
5429
|
+
this.http = axios4.create({
|
|
5718
5430
|
baseURL: opts.baseURL.replace(/\/$/, ""),
|
|
5719
5431
|
timeout: 3e4,
|
|
5720
5432
|
httpAgent,
|
|
@@ -5808,6 +5520,6 @@ function sleep(ms) {
|
|
|
5808
5520
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
5809
5521
|
}
|
|
5810
5522
|
|
|
5811
|
-
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 };
|
|
5812
5524
|
//# sourceMappingURL=index.js.map
|
|
5813
5525
|
//# sourceMappingURL=index.js.map
|