@kadi.build/core 0.0.1-alpha.0 → 0.0.1-alpha.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/README.md +1387 -214
- package/dist/abilities/AbilityCache.d.ts +242 -0
- package/dist/abilities/AbilityCache.d.ts.map +1 -0
- package/dist/abilities/AbilityCache.js +285 -0
- package/dist/abilities/AbilityCache.js.map +1 -0
- package/dist/abilities/AbilityContext.d.ts +215 -0
- package/dist/abilities/AbilityContext.d.ts.map +1 -0
- package/dist/abilities/AbilityContext.js +36 -0
- package/dist/abilities/AbilityContext.js.map +1 -0
- package/dist/abilities/AbilityLoader.d.ts +177 -0
- package/dist/abilities/AbilityLoader.d.ts.map +1 -0
- package/dist/abilities/AbilityLoader.js +277 -0
- package/dist/abilities/AbilityLoader.js.map +1 -0
- package/dist/abilities/AbilityProxy.d.ts +463 -0
- package/dist/abilities/AbilityProxy.d.ts.map +1 -0
- package/dist/abilities/AbilityProxy.js +511 -0
- package/dist/abilities/AbilityProxy.js.map +1 -0
- package/dist/abilities/AbilityValidator.d.ts +172 -0
- package/dist/abilities/AbilityValidator.d.ts.map +1 -0
- package/dist/abilities/AbilityValidator.js +253 -0
- package/dist/abilities/AbilityValidator.js.map +1 -0
- package/dist/abilities/index.d.ts +26 -0
- package/dist/abilities/index.d.ts.map +1 -0
- package/dist/abilities/index.js +23 -0
- package/dist/abilities/index.js.map +1 -0
- package/dist/abilities/types.d.ts +156 -0
- package/dist/abilities/types.d.ts.map +1 -0
- package/dist/abilities/types.js +10 -0
- package/dist/abilities/types.js.map +1 -0
- package/dist/api/index.d.ts +92 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +124 -0
- package/dist/api/index.js.map +1 -0
- package/dist/broker/BrokerConnection.d.ts +253 -0
- package/dist/broker/BrokerConnection.d.ts.map +1 -0
- package/dist/broker/BrokerConnection.js +434 -0
- package/dist/broker/BrokerConnection.js.map +1 -0
- package/dist/broker/BrokerConnectionManager.d.ts +216 -0
- package/dist/broker/BrokerConnectionManager.d.ts.map +1 -0
- package/dist/broker/BrokerConnectionManager.js +305 -0
- package/dist/broker/BrokerConnectionManager.js.map +1 -0
- package/dist/broker/BrokerProtocol.d.ts +280 -0
- package/dist/broker/BrokerProtocol.d.ts.map +1 -0
- package/dist/broker/BrokerProtocol.js +466 -0
- package/dist/broker/BrokerProtocol.js.map +1 -0
- package/dist/broker/index.d.ts +9 -0
- package/dist/broker/index.d.ts.map +1 -0
- package/dist/broker/index.js +9 -0
- package/dist/broker/index.js.map +1 -0
- package/dist/client/KadiClient.d.ts +270 -0
- package/dist/client/KadiClient.d.ts.map +1 -0
- package/dist/client/KadiClient.js +492 -0
- package/dist/client/KadiClient.js.map +1 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/config/ConfigLoader.d.ts +138 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +226 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/config/ConfigResolver.d.ts +135 -0
- package/dist/config/ConfigResolver.d.ts.map +1 -0
- package/dist/config/ConfigResolver.js +282 -0
- package/dist/config/ConfigResolver.js.map +1 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +8 -0
- package/dist/config/index.js.map +1 -0
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +8 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/events/EventHub.d.ts +172 -0
- package/dist/events/EventHub.d.ts.map +1 -0
- package/dist/events/EventHub.js +333 -0
- package/dist/events/EventHub.js.map +1 -0
- package/dist/events/index.d.ts +7 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +7 -0
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/index.d.ts +33 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +33 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/schemas/index.d.ts +19 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +25 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/kadi-extensions.d.ts +231 -0
- package/dist/schemas/kadi-extensions.d.ts.map +1 -0
- package/dist/schemas/kadi-extensions.js +14 -0
- package/dist/schemas/kadi-extensions.js.map +1 -0
- package/dist/schemas/mcp/schema.d.ts +1399 -0
- package/dist/schemas/mcp/schema.d.ts.map +1 -0
- package/dist/schemas/mcp/schema.js +53 -0
- package/dist/schemas/mcp/schema.js.map +1 -0
- package/dist/schemas/mcp/version.d.ts +37 -0
- package/dist/schemas/mcp/version.d.ts.map +1 -0
- package/dist/schemas/mcp/version.js +39 -0
- package/dist/schemas/mcp/version.js.map +1 -0
- package/dist/schemas/schema-builders.d.ts +178 -0
- package/dist/schemas/schema-builders.d.ts.map +1 -0
- package/dist/schemas/schema-builders.js +258 -0
- package/dist/schemas/schema-builders.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts +256 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/ToolRegistry.js +340 -0
- package/dist/tools/ToolRegistry.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/transports/BrokerTransport.d.ts +151 -0
- package/dist/transports/BrokerTransport.d.ts.map +1 -0
- package/dist/transports/BrokerTransport.js +261 -0
- package/dist/transports/BrokerTransport.js.map +1 -0
- package/dist/transports/NativeTransport.d.ts +149 -0
- package/dist/transports/NativeTransport.d.ts.map +1 -0
- package/dist/transports/NativeTransport.js +302 -0
- package/dist/transports/NativeTransport.js.map +1 -0
- package/dist/transports/StdioTransport.d.ts +172 -0
- package/dist/transports/StdioTransport.d.ts.map +1 -0
- package/dist/transports/StdioTransport.js +410 -0
- package/dist/transports/StdioTransport.js.map +1 -0
- package/dist/transports/index.d.ts +10 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +9 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/types/broker.d.ts +301 -0
- package/dist/types/broker.d.ts.map +1 -0
- package/dist/types/broker.js +46 -0
- package/dist/types/broker.js.map +1 -0
- package/dist/types/config.d.ts +325 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +17 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/errors.d.ts +178 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +165 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/events.d.ts +210 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +8 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/protocol.d.ts +48 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +11 -0
- package/dist/types/protocol.js.map +1 -0
- package/dist/types/tools.d.ts +67 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +16 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/transport.d.ts +250 -0
- package/dist/types/transport.d.ts.map +1 -0
- package/dist/types/transport.js +18 -0
- package/dist/types/transport.js.map +1 -0
- package/dist/validation/SchemaValidator.d.ts +208 -0
- package/dist/validation/SchemaValidator.d.ts.map +1 -0
- package/dist/validation/SchemaValidator.js +411 -0
- package/dist/validation/SchemaValidator.js.map +1 -0
- package/dist/validation/index.d.ts +11 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +10 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +69 -5
- package/.prettierrc +0 -6
- package/agent.json +0 -18
- package/broker.js +0 -214
- package/index.js +0 -370
- package/ipc.js +0 -220
- package/ipcInterfaces/pythonAbilityIPC.py +0 -177
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Types Module
|
|
3
|
+
* ======================
|
|
4
|
+
*
|
|
5
|
+
* Re-exports protocol-related types for kadi-broker and other consumers.
|
|
6
|
+
* This provides a clean import path: @kadi.build/core/types/protocol
|
|
7
|
+
*
|
|
8
|
+
* @module types/protocol
|
|
9
|
+
*/
|
|
10
|
+
import type { NetworkId, ToolTag, KadiTool } from '../schemas/kadi-extensions.js';
|
|
11
|
+
import type { AgentRole } from './config.js';
|
|
12
|
+
export type { JsonRpcRequest, JsonRpcResponse, JsonRpcNotification, JsonRpcError, PendingRequest } from './broker.js';
|
|
13
|
+
export type { NetworkId, ToolTag };
|
|
14
|
+
export interface Provider {
|
|
15
|
+
agentId: string;
|
|
16
|
+
agentName?: string;
|
|
17
|
+
networks: NetworkId[];
|
|
18
|
+
tags?: ToolTag[];
|
|
19
|
+
displayName?: string;
|
|
20
|
+
lastSeen?: number;
|
|
21
|
+
registeredAt?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface SystemSnapshot {
|
|
24
|
+
agents: Array<{
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: 'agent';
|
|
28
|
+
tools: string[];
|
|
29
|
+
networks: string[];
|
|
30
|
+
status: 'active' | 'disconnected';
|
|
31
|
+
}>;
|
|
32
|
+
networks: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
type: 'network';
|
|
36
|
+
status: 'active';
|
|
37
|
+
}>;
|
|
38
|
+
connections: Array<{
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
status: 'connected' | 'disconnected';
|
|
42
|
+
}>;
|
|
43
|
+
timestamp: string;
|
|
44
|
+
}
|
|
45
|
+
export type { KadiTool as Tool };
|
|
46
|
+
export type { AgentRole as SessionRole };
|
|
47
|
+
export type QueueKind = 'direct' | 'fanout' | 'topic' | 'agent';
|
|
48
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,YAAY,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAGnC,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,EAAE,QAAQ,GAAG,cAAc,CAAC;KACnC,CAAC,CAAC;IACH,QAAQ,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,SAAS,CAAC;QAChB,MAAM,EAAE,QAAQ,CAAC;KAClB,CAAC,CAAC;IACH,WAAW,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,WAAW,GAAG,cAAc,CAAC;KACtC,CAAC,CAAC;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,YAAY,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;AAGjC,YAAY,EAAE,SAAS,IAAI,WAAW,EAAE,CAAC;AAGzC,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Types Module
|
|
3
|
+
* ======================
|
|
4
|
+
*
|
|
5
|
+
* Re-exports protocol-related types for kadi-broker and other consumers.
|
|
6
|
+
* This provides a clean import path: @kadi.build/core/types/protocol
|
|
7
|
+
*
|
|
8
|
+
* @module types/protocol
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Types (MCP-Based)
|
|
3
|
+
* ========================
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for tool registration, handlers, and schemas using the
|
|
6
|
+
* Model Context Protocol (MCP) standard.
|
|
7
|
+
*
|
|
8
|
+
* **Breaking Change (v2.0.0)**:
|
|
9
|
+
* - Replaced Zod schemas with MCP JSON Schemas
|
|
10
|
+
* - Full MCP compliance with KADI extensions
|
|
11
|
+
* - See migration guide for upgrading from v1.x
|
|
12
|
+
*
|
|
13
|
+
* @module types/tools
|
|
14
|
+
*/
|
|
15
|
+
export type { KadiTool, KadiToolResult, ToolDefinition, ToolHandler, RegisteredTool, ToolTag, NetworkId, ToolDiscoveryQuery, ToolDiscoveryResult } from '../schemas/index.js';
|
|
16
|
+
export type { McpTool, McpCallToolResult, ToolAnnotations, ListToolsRequest, ListToolsResult, CallToolRequest, ToolListChangedNotification } from '../schemas/index.js';
|
|
17
|
+
/**
|
|
18
|
+
* Tool invocation result
|
|
19
|
+
*
|
|
20
|
+
* Extended version of MCP CallToolResult with KADI-specific metadata.
|
|
21
|
+
*
|
|
22
|
+
* @template T - Result data type
|
|
23
|
+
*/
|
|
24
|
+
export interface ToolInvocationResult<T = unknown> {
|
|
25
|
+
/**
|
|
26
|
+
* Whether the invocation succeeded
|
|
27
|
+
*/
|
|
28
|
+
success: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The result data if successful
|
|
31
|
+
*/
|
|
32
|
+
data?: T;
|
|
33
|
+
/**
|
|
34
|
+
* Error information if failed
|
|
35
|
+
*/
|
|
36
|
+
error?: {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
details?: unknown;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Execution metadata
|
|
43
|
+
*/
|
|
44
|
+
metadata?: {
|
|
45
|
+
/**
|
|
46
|
+
* Execution time in milliseconds
|
|
47
|
+
*/
|
|
48
|
+
executionTime?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Timestamp when execution started
|
|
51
|
+
*/
|
|
52
|
+
timestamp?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Agent that executed the tool
|
|
55
|
+
*/
|
|
56
|
+
agentId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Network the tool was executed on
|
|
59
|
+
*/
|
|
60
|
+
networkId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether result was cached
|
|
63
|
+
*/
|
|
64
|
+
cacheHit?: boolean;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,YAAY,EACV,QAAQ,EACR,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,CAAC;IAET;;OAEG;IACH,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QAEvB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Types (MCP-Based)
|
|
3
|
+
* ========================
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for tool registration, handlers, and schemas using the
|
|
6
|
+
* Model Context Protocol (MCP) standard.
|
|
7
|
+
*
|
|
8
|
+
* **Breaking Change (v2.0.0)**:
|
|
9
|
+
* - Replaced Zod schemas with MCP JSON Schemas
|
|
10
|
+
* - Full MCP compliance with KADI extensions
|
|
11
|
+
* - See migration guide for upgrading from v1.x
|
|
12
|
+
*
|
|
13
|
+
* @module types/tools
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for ability transports.
|
|
5
|
+
* Transports enable loading and communicating with abilities across different protocols.
|
|
6
|
+
*/
|
|
7
|
+
import type { EventEmitter } from 'events';
|
|
8
|
+
/**
|
|
9
|
+
* Ability Transport Interface
|
|
10
|
+
*
|
|
11
|
+
* All transports (Native, Stdio, Broker) must implement this interface.
|
|
12
|
+
* This provides a uniform way to load and communicate with abilities
|
|
13
|
+
* regardless of their deployment location or protocol.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* class MyTransport implements AbilityTransport {
|
|
18
|
+
* async connect() { / * ... * / }
|
|
19
|
+
* async invoke(method, params) { / * ... * / }
|
|
20
|
+
* getMethods() { / * ... * / }
|
|
21
|
+
* async disconnect() { / * ... * / }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface AbilityTransport extends EventEmitter {
|
|
26
|
+
/**
|
|
27
|
+
* Establish connection to the ability
|
|
28
|
+
*
|
|
29
|
+
* - Native: Load the module from disk
|
|
30
|
+
* - Stdio: Spawn the child process
|
|
31
|
+
* - Broker: Connect to WebSocket and authenticate
|
|
32
|
+
*
|
|
33
|
+
* @throws {Error} If connection fails
|
|
34
|
+
*/
|
|
35
|
+
connect(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Invoke a method on the connected ability
|
|
38
|
+
*
|
|
39
|
+
* @template TInput - Input parameter type
|
|
40
|
+
* @template TOutput - Return value type
|
|
41
|
+
*
|
|
42
|
+
* @param method - Method name to invoke
|
|
43
|
+
* @param params - Parameters to pass
|
|
44
|
+
* @returns Promise resolving to the method result
|
|
45
|
+
*
|
|
46
|
+
* @throws {Error} If method doesn't exist or invocation fails
|
|
47
|
+
*/
|
|
48
|
+
invoke<TInput = unknown, TOutput = unknown>(method: string, params: TInput): Promise<TOutput>;
|
|
49
|
+
/**
|
|
50
|
+
* Get list of available methods on this ability
|
|
51
|
+
*
|
|
52
|
+
* @returns Array of method names
|
|
53
|
+
*/
|
|
54
|
+
getMethods(): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Disconnect and cleanup resources
|
|
57
|
+
*
|
|
58
|
+
* - Native: Cleanup module references
|
|
59
|
+
* - Stdio: Terminate child process
|
|
60
|
+
* - Broker: Close WebSocket connection
|
|
61
|
+
*/
|
|
62
|
+
disconnect(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get schema for a specific method (optional)
|
|
65
|
+
*
|
|
66
|
+
* @param method - Method name
|
|
67
|
+
* @returns Method schema if available
|
|
68
|
+
*/
|
|
69
|
+
getMethodSchema?(method: string): MethodSchema | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Publish an event from the ability (optional)
|
|
72
|
+
*
|
|
73
|
+
* @param eventName - Event name
|
|
74
|
+
* @param data - Event data
|
|
75
|
+
*/
|
|
76
|
+
publishEvent?(eventName: string, data: unknown): void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Method schema definition
|
|
80
|
+
*/
|
|
81
|
+
export interface MethodSchema {
|
|
82
|
+
/**
|
|
83
|
+
* Description of what the method does
|
|
84
|
+
*/
|
|
85
|
+
description?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Input schema (JSON Schema)
|
|
88
|
+
*/
|
|
89
|
+
inputSchema?: Record<string, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* Output schema (JSON Schema)
|
|
92
|
+
*/
|
|
93
|
+
outputSchema?: Record<string, unknown>;
|
|
94
|
+
/**
|
|
95
|
+
* Example usage
|
|
96
|
+
*/
|
|
97
|
+
examples?: Array<{
|
|
98
|
+
input: unknown;
|
|
99
|
+
output: unknown;
|
|
100
|
+
}>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Base transport configuration options
|
|
104
|
+
*/
|
|
105
|
+
export interface TransportOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Ability name
|
|
108
|
+
*/
|
|
109
|
+
abilityName: string;
|
|
110
|
+
/**
|
|
111
|
+
* Ability version (optional)
|
|
112
|
+
*/
|
|
113
|
+
abilityVersion?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Timeout for method invocations in milliseconds
|
|
116
|
+
* @default 30000
|
|
117
|
+
*/
|
|
118
|
+
timeout?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Native transport options (in-process loading)
|
|
122
|
+
*/
|
|
123
|
+
export interface NativeTransportOptions extends TransportOptions {
|
|
124
|
+
/**
|
|
125
|
+
* Path to ability directory
|
|
126
|
+
*/
|
|
127
|
+
abilityPath: string;
|
|
128
|
+
/**
|
|
129
|
+
* Entry point file (relative to abilityPath)
|
|
130
|
+
* @default 'index.js'
|
|
131
|
+
*/
|
|
132
|
+
entryPoint?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Stdio transport options (child process)
|
|
136
|
+
*/
|
|
137
|
+
export interface StdioTransportOptions extends TransportOptions {
|
|
138
|
+
/**
|
|
139
|
+
* Path to ability directory
|
|
140
|
+
*/
|
|
141
|
+
abilityPath: string;
|
|
142
|
+
/**
|
|
143
|
+
* Command to execute
|
|
144
|
+
* @default 'node'
|
|
145
|
+
*/
|
|
146
|
+
command?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Command arguments
|
|
149
|
+
* @default ['index.js']
|
|
150
|
+
*/
|
|
151
|
+
args?: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Environment variables to pass
|
|
154
|
+
*/
|
|
155
|
+
env?: Record<string, string>;
|
|
156
|
+
/**
|
|
157
|
+
* Working directory
|
|
158
|
+
*/
|
|
159
|
+
cwd?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Broker transport options (remote ability)
|
|
163
|
+
*/
|
|
164
|
+
export interface BrokerTransportOptions extends TransportOptions {
|
|
165
|
+
/**
|
|
166
|
+
* Broker URL
|
|
167
|
+
*/
|
|
168
|
+
brokerUrl: string;
|
|
169
|
+
/**
|
|
170
|
+
* Broker name identifier
|
|
171
|
+
*/
|
|
172
|
+
brokerName?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Networks to search for the ability
|
|
175
|
+
*/
|
|
176
|
+
networks?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* Authentication token
|
|
179
|
+
*/
|
|
180
|
+
authToken?: string;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Message transport interface (low-level)
|
|
184
|
+
*
|
|
185
|
+
* This is for the underlying message-passing layer (WebSocket, stdio streams, etc.)
|
|
186
|
+
* Distinct from AbilityTransport which is higher-level.
|
|
187
|
+
*/
|
|
188
|
+
export interface MessageTransport extends EventEmitter {
|
|
189
|
+
/**
|
|
190
|
+
* Connect to the message transport
|
|
191
|
+
*/
|
|
192
|
+
connect(): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Disconnect from the message transport
|
|
195
|
+
*/
|
|
196
|
+
disconnect(): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Send raw data
|
|
199
|
+
*/
|
|
200
|
+
send(data: Buffer | string): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Check if connected
|
|
203
|
+
*/
|
|
204
|
+
isConnected(): boolean;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Transport discovery result
|
|
208
|
+
*/
|
|
209
|
+
export interface TransportDiscoveryResult {
|
|
210
|
+
/**
|
|
211
|
+
* Available methods
|
|
212
|
+
*/
|
|
213
|
+
methods: string[];
|
|
214
|
+
/**
|
|
215
|
+
* Method schemas
|
|
216
|
+
*/
|
|
217
|
+
schemas?: Map<string, MethodSchema>;
|
|
218
|
+
/**
|
|
219
|
+
* Ability metadata
|
|
220
|
+
*/
|
|
221
|
+
metadata?: {
|
|
222
|
+
name: string;
|
|
223
|
+
version?: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Stdio message framing
|
|
229
|
+
*/
|
|
230
|
+
export interface StdioFrame {
|
|
231
|
+
/**
|
|
232
|
+
* Message length
|
|
233
|
+
*/
|
|
234
|
+
length: number;
|
|
235
|
+
/**
|
|
236
|
+
* Message content (JSON)
|
|
237
|
+
*/
|
|
238
|
+
content: unknown;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Stdio protocol message types
|
|
242
|
+
*/
|
|
243
|
+
export declare enum StdioMessageType {
|
|
244
|
+
DISCOVER = "__kadi_discover",
|
|
245
|
+
INVOKE = "__kadi_invoke",
|
|
246
|
+
RESULT = "__kadi_result",
|
|
247
|
+
ERROR = "__kadi_error",
|
|
248
|
+
EVENT = "__kadi_event"
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/types/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD;;;;;;;;OAQG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE,O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E,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,QAAQ,oBAAoB;IAC5B,MAAM,kBAAkB;IACxB,MAAM,kBAAkB;IACxB,KAAK,iBAAiB;IACtB,KAAK,iBAAiB;CACvB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for ability transports.
|
|
5
|
+
* Transports enable loading and communicating with abilities across different protocols.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Stdio protocol message types
|
|
9
|
+
*/
|
|
10
|
+
export var StdioMessageType;
|
|
11
|
+
(function (StdioMessageType) {
|
|
12
|
+
StdioMessageType["DISCOVER"] = "__kadi_discover";
|
|
13
|
+
StdioMessageType["INVOKE"] = "__kadi_invoke";
|
|
14
|
+
StdioMessageType["RESULT"] = "__kadi_result";
|
|
15
|
+
StdioMessageType["ERROR"] = "__kadi_error";
|
|
16
|
+
StdioMessageType["EVENT"] = "__kadi_event";
|
|
17
|
+
})(StdioMessageType || (StdioMessageType = {}));
|
|
18
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/types/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgRH;;GAEG;AACH,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,gDAA4B,CAAA;IAC5B,4CAAwB,CAAA;IACxB,4CAAwB,CAAA;IACxB,0CAAsB,CAAA;IACtB,0CAAsB,CAAA;AACxB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Validator
|
|
3
|
+
* =================
|
|
4
|
+
*
|
|
5
|
+
* Validates tool input/output against MCP JSON Schemas using AJV.
|
|
6
|
+
* Implements global caching for performance at scale.
|
|
7
|
+
*
|
|
8
|
+
* **Performance Optimization**:
|
|
9
|
+
* - Global cache prevents redundant schema compilations
|
|
10
|
+
* - At scale (1000+ tools), this provides 1000x performance improvement
|
|
11
|
+
* - Memory efficient: ~5KB per compiled schema vs 5MB for duplicates
|
|
12
|
+
*
|
|
13
|
+
* @module validation/SchemaValidator
|
|
14
|
+
*/
|
|
15
|
+
import { ErrorObject } from 'ajv';
|
|
16
|
+
/**
|
|
17
|
+
* Validation result
|
|
18
|
+
*/
|
|
19
|
+
export interface ValidationResult {
|
|
20
|
+
/**
|
|
21
|
+
* Whether validation passed
|
|
22
|
+
*/
|
|
23
|
+
valid: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Human-readable error messages
|
|
26
|
+
*/
|
|
27
|
+
errors: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Detailed error objects from AJV (for debugging)
|
|
30
|
+
*/
|
|
31
|
+
errorDetails?: ErrorObject[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Schema Validator
|
|
35
|
+
* =================
|
|
36
|
+
*
|
|
37
|
+
* Validates tool inputs and outputs against JSON Schemas.
|
|
38
|
+
* Each instance manages schemas for a set of tools, but shares
|
|
39
|
+
* the global compilation cache for efficiency.
|
|
40
|
+
*
|
|
41
|
+
* **Usage**:
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const validator = new SchemaValidator();
|
|
44
|
+
*
|
|
45
|
+
* // Register tool schemas
|
|
46
|
+
* validator.registerTool('add', inputSchema, outputSchema);
|
|
47
|
+
*
|
|
48
|
+
* // Validate input
|
|
49
|
+
* const result = validator.validateInput('add', { a: 5, b: 3 });
|
|
50
|
+
* if (!result.valid) {
|
|
51
|
+
* console.error('Validation failed:', result.errors);
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare class SchemaValidator {
|
|
56
|
+
/**
|
|
57
|
+
* Tool schemas (per validator instance)
|
|
58
|
+
*/
|
|
59
|
+
private readonly toolSchemas;
|
|
60
|
+
/**
|
|
61
|
+
* Compiled validators (per validator instance, but reuses global cache)
|
|
62
|
+
*/
|
|
63
|
+
private readonly validators;
|
|
64
|
+
/**
|
|
65
|
+
* Reference to global cache (shared across all instances)
|
|
66
|
+
*/
|
|
67
|
+
private readonly globalCache;
|
|
68
|
+
constructor();
|
|
69
|
+
/**
|
|
70
|
+
* Register a tool with its input and output schemas
|
|
71
|
+
*
|
|
72
|
+
* Compiles schemas using global cache to avoid redundant work.
|
|
73
|
+
* If these schemas were compiled before (by any validator instance),
|
|
74
|
+
* the cached validators are reused.
|
|
75
|
+
*
|
|
76
|
+
* @param toolName - Tool name
|
|
77
|
+
* @param inputSchema - Input JSON Schema (MCP format)
|
|
78
|
+
* @param outputSchema - Optional output JSON Schema (MCP format)
|
|
79
|
+
* @throws {KadiError} If schema compilation fails
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* validator.registerTool('add', {
|
|
84
|
+
* type: 'object',
|
|
85
|
+
* properties: {
|
|
86
|
+
* a: { type: 'number' },
|
|
87
|
+
* b: { type: 'number' }
|
|
88
|
+
* },
|
|
89
|
+
* required: ['a', 'b']
|
|
90
|
+
* }, {
|
|
91
|
+
* type: 'object',
|
|
92
|
+
* properties: {
|
|
93
|
+
* result: { type: 'number' }
|
|
94
|
+
* }
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
registerTool(toolName: string, inputSchema: object, outputSchema?: object): void;
|
|
99
|
+
/**
|
|
100
|
+
* Validate input data against a tool's input schema
|
|
101
|
+
*
|
|
102
|
+
* @param toolName - Tool name
|
|
103
|
+
* @param input - Input data to validate
|
|
104
|
+
* @returns Validation result
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const result = validator.validateInput('add', { a: 5, b: 3 });
|
|
109
|
+
* if (!result.valid) {
|
|
110
|
+
* console.error('Invalid input:', result.errors);
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
validateInput(toolName: string, input: unknown): ValidationResult;
|
|
115
|
+
/**
|
|
116
|
+
* Validate output data against a tool's output schema
|
|
117
|
+
*
|
|
118
|
+
* @param toolName - Tool name
|
|
119
|
+
* @param output - Output data to validate
|
|
120
|
+
* @returns Validation result
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const result = validator.validateOutput('add', { result: 8 });
|
|
125
|
+
* if (!result.valid) {
|
|
126
|
+
* console.error('Invalid output:', result.errors);
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
validateOutput(toolName: string, output: unknown): ValidationResult;
|
|
131
|
+
/**
|
|
132
|
+
* Get the schemas for a tool
|
|
133
|
+
*
|
|
134
|
+
* @param toolName - Tool name
|
|
135
|
+
* @returns Tool schemas or undefined if not registered
|
|
136
|
+
*/
|
|
137
|
+
getToolSchemas(toolName: string): {
|
|
138
|
+
input: object;
|
|
139
|
+
output?: object;
|
|
140
|
+
} | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Check if a tool has registered schemas
|
|
143
|
+
*
|
|
144
|
+
* @param toolName - Tool name
|
|
145
|
+
* @returns Whether tool is registered
|
|
146
|
+
*/
|
|
147
|
+
hasToolSchemas(toolName: string): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Remove schemas for a tool
|
|
150
|
+
*
|
|
151
|
+
* @param toolName - Tool name
|
|
152
|
+
*/
|
|
153
|
+
unregisterTool(toolName: string): void;
|
|
154
|
+
/**
|
|
155
|
+
* Get all registered tool names
|
|
156
|
+
*
|
|
157
|
+
* @returns Array of tool names
|
|
158
|
+
*/
|
|
159
|
+
getRegisteredTools(): string[];
|
|
160
|
+
/**
|
|
161
|
+
* Validate a schema definition itself (meta-validation)
|
|
162
|
+
*
|
|
163
|
+
* Checks if a schema is valid JSON Schema and can be compiled.
|
|
164
|
+
* Uses global cache to avoid redundant compilations.
|
|
165
|
+
*
|
|
166
|
+
* @param schema - JSON Schema to validate
|
|
167
|
+
* @returns Validation result
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const result = validator.validateSchemaDefinition({
|
|
172
|
+
* type: 'object',
|
|
173
|
+
* properties: {
|
|
174
|
+
* name: { type: 'string' }
|
|
175
|
+
* }
|
|
176
|
+
* });
|
|
177
|
+
* if (!result.valid) {
|
|
178
|
+
* console.error('Invalid schema:', result.errors);
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
validateSchemaDefinition(schema: object): ValidationResult;
|
|
183
|
+
/**
|
|
184
|
+
* Format validation errors for human readability
|
|
185
|
+
*
|
|
186
|
+
* Converts AJV error objects into clear, actionable error messages.
|
|
187
|
+
*
|
|
188
|
+
* @param errors - AJV error objects
|
|
189
|
+
* @returns Human-readable error messages
|
|
190
|
+
*/
|
|
191
|
+
private formatValidationErrors;
|
|
192
|
+
/**
|
|
193
|
+
* Get global cache statistics
|
|
194
|
+
*
|
|
195
|
+
* @returns Cache statistics
|
|
196
|
+
*/
|
|
197
|
+
static getCacheStats(): {
|
|
198
|
+
cachedSchemas: number;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Clear global cache
|
|
202
|
+
*
|
|
203
|
+
* **Warning**: This affects all SchemaValidator instances.
|
|
204
|
+
* Primarily for testing.
|
|
205
|
+
*/
|
|
206
|
+
static clearGlobalCache(): void;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=SchemaValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaValidator.d.ts","sourceRoot":"","sources":["../../src/validation/SchemaValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAmB,EAA8B,WAAW,EAAE,MAAM,KAAK,CAAC;AAoB1E;;GAEG;AACH,MAAM,WAAW,gBAAgB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