@thinkwell/protocol 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dispatch.d.ts +75 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +35 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/json-rpc.d.ts +103 -0
- package/dist/json-rpc.d.ts.map +1 -0
- package/dist/json-rpc.js +76 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/json.d.ts +34 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +2 -0
- package/dist/json.js.map +1 -0
- package/dist/mcp-over-acp.d.ts +125 -0
- package/dist/mcp-over-acp.d.ts.map +1 -0
- package/dist/mcp-over-acp.js +8 -0
- package/dist/mcp-over-acp.js.map +1 -0
- package/dist/proxy-protocol.d.ts +77 -0
- package/dist/proxy-protocol.d.ts.map +1 -0
- package/dist/proxy-protocol.js +67 -0
- package/dist/proxy-protocol.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch types for conductor message routing
|
|
3
|
+
*
|
|
4
|
+
* The Dispatch type is a unified envelope for messages flowing through the conductor.
|
|
5
|
+
* The Responder abstraction decouples response routing from the message itself,
|
|
6
|
+
* enabling the conductor to intercept and redirect responses.
|
|
7
|
+
*/
|
|
8
|
+
import type { JsonRpcId, JsonRpcError } from "./json-rpc.js";
|
|
9
|
+
/**
|
|
10
|
+
* Responder interface for sending responses back to the original requester.
|
|
11
|
+
*
|
|
12
|
+
* This abstraction allows the conductor to route responses through different
|
|
13
|
+
* paths depending on where the original request came from.
|
|
14
|
+
*/
|
|
15
|
+
export interface Responder {
|
|
16
|
+
/**
|
|
17
|
+
* Send a successful response
|
|
18
|
+
*/
|
|
19
|
+
respond(result: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Send an error response
|
|
22
|
+
*/
|
|
23
|
+
respondWithError(error: JsonRpcError): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A request dispatch - carries request data and a responder for sending the response
|
|
27
|
+
*/
|
|
28
|
+
export interface RequestDispatch {
|
|
29
|
+
type: "request";
|
|
30
|
+
id: JsonRpcId;
|
|
31
|
+
method: string;
|
|
32
|
+
params: unknown;
|
|
33
|
+
responder: Responder;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A notification dispatch - fire-and-forget message
|
|
37
|
+
*/
|
|
38
|
+
export interface NotificationDispatch {
|
|
39
|
+
type: "notification";
|
|
40
|
+
method: string;
|
|
41
|
+
params: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A response dispatch - result or error for a previous request
|
|
45
|
+
*/
|
|
46
|
+
export interface ResponseDispatch {
|
|
47
|
+
type: "response";
|
|
48
|
+
id: JsonRpcId;
|
|
49
|
+
result?: unknown;
|
|
50
|
+
error?: JsonRpcError;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Unified dispatch envelope for all message types.
|
|
54
|
+
*
|
|
55
|
+
* Messages flow through the conductor in this envelope format, which
|
|
56
|
+
* normalizes requests, notifications, and responses into a single type.
|
|
57
|
+
*/
|
|
58
|
+
export type Dispatch = RequestDispatch | NotificationDispatch | ResponseDispatch;
|
|
59
|
+
/**
|
|
60
|
+
* Type guard for request dispatch
|
|
61
|
+
*/
|
|
62
|
+
export declare function isRequestDispatch(dispatch: Dispatch): dispatch is RequestDispatch;
|
|
63
|
+
/**
|
|
64
|
+
* Type guard for notification dispatch
|
|
65
|
+
*/
|
|
66
|
+
export declare function isNotificationDispatch(dispatch: Dispatch): dispatch is NotificationDispatch;
|
|
67
|
+
/**
|
|
68
|
+
* Type guard for response dispatch
|
|
69
|
+
*/
|
|
70
|
+
export declare function isResponseDispatch(dispatch: Dispatch): dispatch is ResponseDispatch;
|
|
71
|
+
/**
|
|
72
|
+
* Create a simple responder from callback functions
|
|
73
|
+
*/
|
|
74
|
+
export declare function createResponder(onRespond: (result: unknown) => void, onError: (error: JsonRpcError) => void): Responder;
|
|
75
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AAEjF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,eAAe,CAEjF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,oBAAoB,CAE3F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,gBAAgB,CAEnF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EACpC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GACrC,SAAS,CAKX"}
|
package/dist/dispatch.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch types for conductor message routing
|
|
3
|
+
*
|
|
4
|
+
* The Dispatch type is a unified envelope for messages flowing through the conductor.
|
|
5
|
+
* The Responder abstraction decouples response routing from the message itself,
|
|
6
|
+
* enabling the conductor to intercept and redirect responses.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Type guard for request dispatch
|
|
10
|
+
*/
|
|
11
|
+
export function isRequestDispatch(dispatch) {
|
|
12
|
+
return dispatch.type === "request";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for notification dispatch
|
|
16
|
+
*/
|
|
17
|
+
export function isNotificationDispatch(dispatch) {
|
|
18
|
+
return dispatch.type === "notification";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard for response dispatch
|
|
22
|
+
*/
|
|
23
|
+
export function isResponseDispatch(dispatch) {
|
|
24
|
+
return dispatch.type === "response";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a simple responder from callback functions
|
|
28
|
+
*/
|
|
29
|
+
export function createResponder(onRespond, onError) {
|
|
30
|
+
return {
|
|
31
|
+
respond: onRespond,
|
|
32
|
+
respondWithError: onError,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4DH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAkB;IAClD,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACvD,OAAO,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAkB;IACnD,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAoC,EACpC,OAAsC;IAEtC,OAAO;QACL,OAAO,EAAE,SAAS;QAClB,gBAAgB,EAAE,OAAO;KAC1B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { JsonValue, JsonObject, JsonSchema } from "./json.js";
|
|
2
|
+
export type { JsonRpcId, JsonRpcError, JsonRpcRequest, JsonRpcNotification, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcResponse, JsonRpcMessage, } from "./json-rpc.js";
|
|
3
|
+
export { isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, JsonRpcErrorCodes, createRequest, createNotification, createSuccessResponse, createErrorResponse, } from "./json-rpc.js";
|
|
4
|
+
export type { McpServerConfig, McpContext, McpConnectRequest, McpConnectResponse, McpMessageRequest, McpMessageResponse, McpContent, McpError, McpDisconnectNotification, McpToolsListResult, McpToolDefinition, McpToolsCallParams, McpToolsCallResult, } from "./mcp-over-acp.js";
|
|
5
|
+
export type { Responder, RequestDispatch, NotificationDispatch, ResponseDispatch, Dispatch, } from "./dispatch.js";
|
|
6
|
+
export { isRequestDispatch, isNotificationDispatch, isResponseDispatch, createResponder, } from "./dispatch.js";
|
|
7
|
+
export type { ProxySuccessorRequestParams, ProxySuccessorNotificationParams, } from "./proxy-protocol.js";
|
|
8
|
+
export { PROXY_SUCCESSOR_REQUEST, PROXY_SUCCESSOR_NOTIFICATION, isProxySuccessorRequest, isProxySuccessorNotification, unwrapProxySuccessorRequest, unwrapProxySuccessorNotification, wrapAsProxySuccessorRequest, wrapAsProxySuccessorNotification, isProxyProtocolMethod, } from "./proxy-protocol.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGnE,YAAY,EACV,SAAS,EACT,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, JsonRpcErrorCodes, createRequest, createNotification, createSuccessResponse, createErrorResponse, } from "./json-rpc.js";
|
|
2
|
+
export { isRequestDispatch, isNotificationDispatch, isResponseDispatch, createResponder, } from "./dispatch.js";
|
|
3
|
+
export { PROXY_SUCCESSOR_REQUEST, PROXY_SUCCESSOR_NOTIFICATION, isProxySuccessorRequest, isProxySuccessorNotification, unwrapProxySuccessorRequest, unwrapProxySuccessorNotification, wrapAsProxySuccessorRequest, wrapAsProxySuccessorNotification, isProxyProtocolMethod, } from "./proxy-protocol.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AA4BvB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,GAChB,MAAM,eAAe,CAAC;AAQvB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 protocol types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* JSON-RPC message ID - can be string, number, or null
|
|
6
|
+
*/
|
|
7
|
+
export type JsonRpcId = string | number | null;
|
|
8
|
+
/**
|
|
9
|
+
* JSON-RPC error object
|
|
10
|
+
*/
|
|
11
|
+
export interface JsonRpcError {
|
|
12
|
+
code: number;
|
|
13
|
+
message: string;
|
|
14
|
+
data?: unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* JSON-RPC request message
|
|
18
|
+
*/
|
|
19
|
+
export interface JsonRpcRequest {
|
|
20
|
+
jsonrpc: "2.0";
|
|
21
|
+
id: JsonRpcId;
|
|
22
|
+
method: string;
|
|
23
|
+
params?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* JSON-RPC notification message (request without id)
|
|
27
|
+
*/
|
|
28
|
+
export interface JsonRpcNotification {
|
|
29
|
+
jsonrpc: "2.0";
|
|
30
|
+
method: string;
|
|
31
|
+
params?: unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* JSON-RPC success response
|
|
35
|
+
*/
|
|
36
|
+
export interface JsonRpcSuccessResponse {
|
|
37
|
+
jsonrpc: "2.0";
|
|
38
|
+
id: JsonRpcId;
|
|
39
|
+
result: unknown;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* JSON-RPC error response
|
|
43
|
+
*/
|
|
44
|
+
export interface JsonRpcErrorResponse {
|
|
45
|
+
jsonrpc: "2.0";
|
|
46
|
+
id: JsonRpcId;
|
|
47
|
+
error: JsonRpcError;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* JSON-RPC response (success or error)
|
|
51
|
+
*/
|
|
52
|
+
export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
|
53
|
+
/**
|
|
54
|
+
* Any JSON-RPC message
|
|
55
|
+
*/
|
|
56
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
57
|
+
/**
|
|
58
|
+
* Type guard for JSON-RPC request
|
|
59
|
+
*/
|
|
60
|
+
export declare function isJsonRpcRequest(message: JsonRpcMessage): message is JsonRpcRequest;
|
|
61
|
+
/**
|
|
62
|
+
* Type guard for JSON-RPC notification
|
|
63
|
+
*/
|
|
64
|
+
export declare function isJsonRpcNotification(message: JsonRpcMessage): message is JsonRpcNotification;
|
|
65
|
+
/**
|
|
66
|
+
* Type guard for JSON-RPC response
|
|
67
|
+
*/
|
|
68
|
+
export declare function isJsonRpcResponse(message: JsonRpcMessage): message is JsonRpcResponse;
|
|
69
|
+
/**
|
|
70
|
+
* Type guard for JSON-RPC success response
|
|
71
|
+
*/
|
|
72
|
+
export declare function isJsonRpcSuccessResponse(message: JsonRpcMessage): message is JsonRpcSuccessResponse;
|
|
73
|
+
/**
|
|
74
|
+
* Type guard for JSON-RPC error response
|
|
75
|
+
*/
|
|
76
|
+
export declare function isJsonRpcErrorResponse(message: JsonRpcMessage): message is JsonRpcErrorResponse;
|
|
77
|
+
/**
|
|
78
|
+
* Standard JSON-RPC error codes
|
|
79
|
+
*/
|
|
80
|
+
export declare const JsonRpcErrorCodes: {
|
|
81
|
+
readonly PARSE_ERROR: -32700;
|
|
82
|
+
readonly INVALID_REQUEST: -32600;
|
|
83
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
84
|
+
readonly INVALID_PARAMS: -32602;
|
|
85
|
+
readonly INTERNAL_ERROR: -32603;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Create a JSON-RPC request
|
|
89
|
+
*/
|
|
90
|
+
export declare function createRequest(id: JsonRpcId, method: string, params?: unknown): JsonRpcRequest;
|
|
91
|
+
/**
|
|
92
|
+
* Create a JSON-RPC notification
|
|
93
|
+
*/
|
|
94
|
+
export declare function createNotification(method: string, params?: unknown): JsonRpcNotification;
|
|
95
|
+
/**
|
|
96
|
+
* Create a JSON-RPC success response
|
|
97
|
+
*/
|
|
98
|
+
export declare function createSuccessResponse(id: JsonRpcId, result: unknown): JsonRpcSuccessResponse;
|
|
99
|
+
/**
|
|
100
|
+
* Create a JSON-RPC error response
|
|
101
|
+
*/
|
|
102
|
+
export declare function createErrorResponse(id: JsonRpcId, error: JsonRpcError): JsonRpcErrorResponse;
|
|
103
|
+
//# sourceMappingURL=json-rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-rpc.d.ts","sourceRoot":"","sources":["../src/json-rpc.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,SAAS,CAAC;IACd,KAAK,EAAE,YAAY,CAA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|
|
4
|
+
/**
|
|
5
|
+
* Type guard for JSON-RPC request
|
|
6
|
+
*/
|
|
7
|
+
export function isJsonRpcRequest(message) {
|
|
8
|
+
return "method" in message && "id" in message;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Type guard for JSON-RPC notification
|
|
12
|
+
*/
|
|
13
|
+
export function isJsonRpcNotification(message) {
|
|
14
|
+
return "method" in message && !("id" in message);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Type guard for JSON-RPC response
|
|
18
|
+
*/
|
|
19
|
+
export function isJsonRpcResponse(message) {
|
|
20
|
+
return "id" in message && !("method" in message);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type guard for JSON-RPC success response
|
|
24
|
+
*/
|
|
25
|
+
export function isJsonRpcSuccessResponse(message) {
|
|
26
|
+
return isJsonRpcResponse(message) && "result" in message;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Type guard for JSON-RPC error response
|
|
30
|
+
*/
|
|
31
|
+
export function isJsonRpcErrorResponse(message) {
|
|
32
|
+
return isJsonRpcResponse(message) && "error" in message;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Standard JSON-RPC error codes
|
|
36
|
+
*/
|
|
37
|
+
export const JsonRpcErrorCodes = {
|
|
38
|
+
PARSE_ERROR: -32700,
|
|
39
|
+
INVALID_REQUEST: -32600,
|
|
40
|
+
METHOD_NOT_FOUND: -32601,
|
|
41
|
+
INVALID_PARAMS: -32602,
|
|
42
|
+
INTERNAL_ERROR: -32603,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Create a JSON-RPC request
|
|
46
|
+
*/
|
|
47
|
+
export function createRequest(id, method, params) {
|
|
48
|
+
const request = { jsonrpc: "2.0", id, method };
|
|
49
|
+
if (params !== undefined) {
|
|
50
|
+
request.params = params;
|
|
51
|
+
}
|
|
52
|
+
return request;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a JSON-RPC notification
|
|
56
|
+
*/
|
|
57
|
+
export function createNotification(method, params) {
|
|
58
|
+
const notification = { jsonrpc: "2.0", method };
|
|
59
|
+
if (params !== undefined) {
|
|
60
|
+
notification.params = params;
|
|
61
|
+
}
|
|
62
|
+
return notification;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a JSON-RPC success response
|
|
66
|
+
*/
|
|
67
|
+
export function createSuccessResponse(id, result) {
|
|
68
|
+
return { jsonrpc: "2.0", id, result };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a JSON-RPC error response
|
|
72
|
+
*/
|
|
73
|
+
export function createErrorResponse(id, error) {
|
|
74
|
+
return { jsonrpc: "2.0", id, error };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=json-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../src/json-rpc.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+DH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAuB;IACtD,OAAO,QAAQ,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAuB;IAC3D,OAAO,QAAQ,IAAI,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAuB;IACvD,OAAO,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAuB;IAEvB,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,QAAQ,IAAI,OAAO,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAuB;IAC5D,O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
3
|
+
*/
|
|
4
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* JSON object type
|
|
9
|
+
*/
|
|
10
|
+
export type JsonObject = {
|
|
11
|
+
[key: string]: JsonValue;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* JSON Schema type for tool input/output validation.
|
|
15
|
+
*
|
|
16
|
+
* This is a structural subset of JSON Schema, designed to be compatible
|
|
17
|
+
* with schemas produced by third-party libraries without requiring them
|
|
18
|
+
* as dependencies.
|
|
19
|
+
*/
|
|
20
|
+
export interface JsonSchema {
|
|
21
|
+
type?: string;
|
|
22
|
+
properties?: Record<string, JsonSchema>;
|
|
23
|
+
required?: string[];
|
|
24
|
+
items?: JsonSchema;
|
|
25
|
+
description?: string;
|
|
26
|
+
enum?: JsonValue[];
|
|
27
|
+
oneOf?: JsonSchema[];
|
|
28
|
+
anyOf?: JsonSchema[];
|
|
29
|
+
allOf?: JsonSchema[];
|
|
30
|
+
$ref?: string;
|
|
31
|
+
additionalProperties?: boolean | JsonSchema;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
package/dist/json.js
ADDED
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-over-ACP protocol types
|
|
3
|
+
*
|
|
4
|
+
* These types define the protocol for bridging MCP (Model Context Protocol)
|
|
5
|
+
* over ACP (Agent Client Protocol) connections.
|
|
6
|
+
*/
|
|
7
|
+
import type { JsonSchema } from "./json.js";
|
|
8
|
+
/**
|
|
9
|
+
* MCP server configuration for session requests
|
|
10
|
+
*/
|
|
11
|
+
export interface McpServerConfig {
|
|
12
|
+
type: "http";
|
|
13
|
+
name: string;
|
|
14
|
+
url: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Context provided to tool handlers
|
|
18
|
+
*/
|
|
19
|
+
export interface McpContext {
|
|
20
|
+
/** The connection ID for this MCP session */
|
|
21
|
+
connectionId: string;
|
|
22
|
+
/** The session ID for the ACP session */
|
|
23
|
+
sessionId: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* MCP connect request from conductor
|
|
27
|
+
*/
|
|
28
|
+
export interface McpConnectRequest {
|
|
29
|
+
method: "_mcp/connect";
|
|
30
|
+
params: {
|
|
31
|
+
connectionId: string;
|
|
32
|
+
url: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* MCP connect response
|
|
37
|
+
*/
|
|
38
|
+
export interface McpConnectResponse {
|
|
39
|
+
connectionId: string;
|
|
40
|
+
serverInfo: {
|
|
41
|
+
name: string;
|
|
42
|
+
version: string;
|
|
43
|
+
};
|
|
44
|
+
capabilities: {
|
|
45
|
+
tools?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
/** Optional tool definitions - the bridge may use these to pre-populate tool info */
|
|
48
|
+
tools?: McpToolDefinition[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* MCP message request (tool call, etc.)
|
|
52
|
+
*/
|
|
53
|
+
export interface McpMessageRequest {
|
|
54
|
+
method: "_mcp/message";
|
|
55
|
+
params: {
|
|
56
|
+
connectionId: string;
|
|
57
|
+
method: string;
|
|
58
|
+
id?: string | number;
|
|
59
|
+
params?: unknown;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* MCP message response
|
|
64
|
+
*/
|
|
65
|
+
export interface McpMessageResponse {
|
|
66
|
+
connectionId: string;
|
|
67
|
+
content?: McpContent[];
|
|
68
|
+
result?: unknown;
|
|
69
|
+
error?: McpError;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* MCP content block
|
|
73
|
+
*/
|
|
74
|
+
export interface McpContent {
|
|
75
|
+
type: "text" | "image" | "resource";
|
|
76
|
+
text?: string;
|
|
77
|
+
data?: string;
|
|
78
|
+
mimeType?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* MCP error
|
|
82
|
+
*/
|
|
83
|
+
export interface McpError {
|
|
84
|
+
code: number;
|
|
85
|
+
message: string;
|
|
86
|
+
data?: unknown;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* MCP disconnect notification
|
|
90
|
+
*/
|
|
91
|
+
export interface McpDisconnectNotification {
|
|
92
|
+
method: "_mcp/disconnect";
|
|
93
|
+
params: {
|
|
94
|
+
connectionId: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* MCP tools/list response
|
|
99
|
+
*/
|
|
100
|
+
export interface McpToolsListResult {
|
|
101
|
+
tools: McpToolDefinition[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* MCP tool definition
|
|
105
|
+
*/
|
|
106
|
+
export interface McpToolDefinition {
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
inputSchema: JsonSchema;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* MCP tools/call request params
|
|
113
|
+
*/
|
|
114
|
+
export interface McpToolsCallParams {
|
|
115
|
+
name: string;
|
|
116
|
+
arguments: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* MCP tools/call response
|
|
120
|
+
*/
|
|
121
|
+
export interface McpToolsCallResult {
|
|
122
|
+
content: McpContent[];
|
|
123
|
+
isError?: boolean;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=mcp-over-acp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-over-acp.d.ts","sourceRoot":"","sources":["../src/mcp-over-acp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,SAA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IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-over-acp.js","sourceRoot":"","sources":["../src/mcp-over-acp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy protocol types for `_proxy/successor/*` messages
|
|
3
|
+
*
|
|
4
|
+
* Proxies communicate with their downstream component (next proxy or agent)
|
|
5
|
+
* through the conductor using these extension methods.
|
|
6
|
+
*/
|
|
7
|
+
import type { JsonRpcRequest, JsonRpcNotification, JsonRpcMessage } from "./json-rpc.js";
|
|
8
|
+
/**
|
|
9
|
+
* Method names for proxy-to-successor communication
|
|
10
|
+
*/
|
|
11
|
+
export declare const PROXY_SUCCESSOR_REQUEST = "_proxy/successor/request";
|
|
12
|
+
export declare const PROXY_SUCCESSOR_NOTIFICATION = "_proxy/successor/notification";
|
|
13
|
+
/**
|
|
14
|
+
* Parameters for `_proxy/successor/request`
|
|
15
|
+
*
|
|
16
|
+
* When a proxy receives an ACP request from upstream and wants to forward it
|
|
17
|
+
* (possibly transformed) to the downstream component, it sends this to the conductor.
|
|
18
|
+
*/
|
|
19
|
+
export interface ProxySuccessorRequestParams {
|
|
20
|
+
/** The method of the inner request to forward */
|
|
21
|
+
method: string;
|
|
22
|
+
/** The params of the inner request (optional) */
|
|
23
|
+
params?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parameters for `_proxy/successor/notification`
|
|
27
|
+
*
|
|
28
|
+
* When a proxy receives a notification from upstream and wants to forward it downstream.
|
|
29
|
+
*/
|
|
30
|
+
export interface ProxySuccessorNotificationParams {
|
|
31
|
+
/** The method of the inner notification to forward */
|
|
32
|
+
method: string;
|
|
33
|
+
/** The params of the inner notification (optional) */
|
|
34
|
+
params?: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type guard for `_proxy/successor/request` messages
|
|
38
|
+
*/
|
|
39
|
+
export declare function isProxySuccessorRequest(message: JsonRpcMessage): message is JsonRpcRequest & {
|
|
40
|
+
params: ProxySuccessorRequestParams;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Type guard for `_proxy/successor/notification` messages
|
|
44
|
+
*/
|
|
45
|
+
export declare function isProxySuccessorNotification(message: JsonRpcMessage): message is JsonRpcNotification & {
|
|
46
|
+
params: ProxySuccessorNotificationParams;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Extract the inner request from a `_proxy/successor/request` message
|
|
50
|
+
*/
|
|
51
|
+
export declare function unwrapProxySuccessorRequest(params: ProxySuccessorRequestParams): {
|
|
52
|
+
method: string;
|
|
53
|
+
params: unknown;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Extract the inner notification from a `_proxy/successor/notification` message
|
|
57
|
+
*/
|
|
58
|
+
export declare function unwrapProxySuccessorNotification(params: ProxySuccessorNotificationParams): {
|
|
59
|
+
method: string;
|
|
60
|
+
params: unknown;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Wrap a request for forwarding to a predecessor proxy
|
|
64
|
+
*
|
|
65
|
+
* When the conductor needs to send a message FROM a successor TO a proxy,
|
|
66
|
+
* it wraps the message in `_proxy/successor/request` format.
|
|
67
|
+
*/
|
|
68
|
+
export declare function wrapAsProxySuccessorRequest(method: string, params: unknown): ProxySuccessorRequestParams;
|
|
69
|
+
/**
|
|
70
|
+
* Wrap a notification for forwarding to a predecessor proxy
|
|
71
|
+
*/
|
|
72
|
+
export declare function wrapAsProxySuccessorNotification(method: string, params: unknown): ProxySuccessorNotificationParams;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a method is a proxy protocol method (starts with `_proxy/`)
|
|
75
|
+
*/
|
|
76
|
+
export declare function isProxyProtocolMethod(method: string): boolean;
|
|
77
|
+
//# sourceMappingURL=proxy-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-protocol.d.ts","sourceRoot":"","sources":["../src/proxy-protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAClE,eAAO,MAAM,4BAA4B,kCAAkC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,cAAc,GACtB,OAAO,IAAI,cAAc,GAAG;IAAE,MAAM,EAAE,2BAA2B,CAAA;CAAE,CAMrE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,cAAc,GACtB,OAAO,IAAI,mBAAmB,GAAG;IAAE,MAAM,EAAE,gCAAgC,CAAA;CAAE,CAM/E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,2BAA2B,GAClC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAKrC;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,gCAAgC,GACvC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAKrC;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACd,2BAA2B,CAE7B;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACd,gCAAgC,CAElC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy protocol types for `_proxy/successor/*` messages
|
|
3
|
+
*
|
|
4
|
+
* Proxies communicate with their downstream component (next proxy or agent)
|
|
5
|
+
* through the conductor using these extension methods.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Method names for proxy-to-successor communication
|
|
9
|
+
*/
|
|
10
|
+
export const PROXY_SUCCESSOR_REQUEST = "_proxy/successor/request";
|
|
11
|
+
export const PROXY_SUCCESSOR_NOTIFICATION = "_proxy/successor/notification";
|
|
12
|
+
/**
|
|
13
|
+
* Type guard for `_proxy/successor/request` messages
|
|
14
|
+
*/
|
|
15
|
+
export function isProxySuccessorRequest(message) {
|
|
16
|
+
return ("method" in message &&
|
|
17
|
+
"id" in message &&
|
|
18
|
+
message.method === PROXY_SUCCESSOR_REQUEST);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard for `_proxy/successor/notification` messages
|
|
22
|
+
*/
|
|
23
|
+
export function isProxySuccessorNotification(message) {
|
|
24
|
+
return ("method" in message &&
|
|
25
|
+
!("id" in message) &&
|
|
26
|
+
message.method === PROXY_SUCCESSOR_NOTIFICATION);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract the inner request from a `_proxy/successor/request` message
|
|
30
|
+
*/
|
|
31
|
+
export function unwrapProxySuccessorRequest(params) {
|
|
32
|
+
return {
|
|
33
|
+
method: params.method,
|
|
34
|
+
params: params.params,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extract the inner notification from a `_proxy/successor/notification` message
|
|
39
|
+
*/
|
|
40
|
+
export function unwrapProxySuccessorNotification(params) {
|
|
41
|
+
return {
|
|
42
|
+
method: params.method,
|
|
43
|
+
params: params.params,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Wrap a request for forwarding to a predecessor proxy
|
|
48
|
+
*
|
|
49
|
+
* When the conductor needs to send a message FROM a successor TO a proxy,
|
|
50
|
+
* it wraps the message in `_proxy/successor/request` format.
|
|
51
|
+
*/
|
|
52
|
+
export function wrapAsProxySuccessorRequest(method, params) {
|
|
53
|
+
return { method, params };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wrap a notification for forwarding to a predecessor proxy
|
|
57
|
+
*/
|
|
58
|
+
export function wrapAsProxySuccessorNotification(method, params) {
|
|
59
|
+
return { method, params };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if a method is a proxy protocol method (starts with `_proxy/`)
|
|
63
|
+
*/
|
|
64
|
+
export function isProxyProtocolMethod(method) {
|
|
65
|
+
return method.startsWith("_proxy/");
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=proxy-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-protocol.js","sourceRoot":"","sources":["../src/proxy-protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAClE,MAAM,CAAC,MAAM,4BAA4B,GAAG,+BAA+B,CAAC;AA2B5E;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAuB;IAEvB,OAAO,CACL,QAAQ,IAAI,OAAO;QACnB,IAAI,IAAI,OAAO;QACf,OAAO,CAAC,MAAM,KAAK,uBAAuB,CAC3C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAuB;IAEvB,OAAO,CACL,QAAQ,IAAI,OAAO;QACnB,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC;QAClB,OAAO,CAAC,MAAM,KAAK,4BAA4B,CAChD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAmC;IAEnC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAwC;IAExC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAc,EACd,MAAe;IAEf,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAc,EACd,MAAe;IAEf,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thinkwell/protocol",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shared protocol types for Thinkwell packages (JSON-RPC, MCP-over-ACP, Dispatch)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"test": "node --test --import tsx src/**/*.test.ts"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"acp",
|
|
24
|
+
"mcp",
|
|
25
|
+
"thinkwell",
|
|
26
|
+
"json-rpc",
|
|
27
|
+
"protocol"
|
|
28
|
+
],
|
|
29
|
+
"author": "David Herman",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^24.10.4",
|
|
33
|
+
"tsx": "^4.19.2",
|
|
34
|
+
"typescript": "^5.7.2"
|
|
35
|
+
}
|
|
36
|
+
}
|