@fuzdev/fuz_app 0.10.0 → 0.11.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/actions/action_bridge.d.ts +8 -8
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +5 -5
- package/dist/actions/action_codegen.d.ts +18 -1
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +49 -6
- package/dist/actions/action_event.d.ts +60 -0
- package/dist/actions/action_event.d.ts.map +1 -0
- package/dist/actions/action_event.js +361 -0
- package/dist/actions/action_event_data.d.ts +639 -0
- package/dist/actions/action_event_data.d.ts.map +1 -0
- package/dist/actions/action_event_data.js +29 -0
- package/dist/actions/action_event_helpers.d.ts +73 -0
- package/dist/actions/action_event_helpers.d.ts.map +1 -0
- package/dist/actions/action_event_helpers.js +96 -0
- package/dist/actions/action_event_types.d.ts +31 -0
- package/dist/actions/action_event_types.d.ts.map +1 -0
- package/dist/actions/action_event_types.js +38 -0
- package/dist/actions/action_peer.d.ts +30 -0
- package/dist/actions/action_peer.d.ts.map +1 -0
- package/dist/actions/action_peer.js +146 -0
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +6 -2
- package/dist/actions/action_spec.d.ts +1 -1
- package/dist/actions/action_spec.js +1 -1
- package/dist/actions/request_tracker.svelte.d.ts +69 -0
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -0
- package/dist/actions/request_tracker.svelte.js +161 -0
- package/dist/actions/rpc_client.d.ts +43 -0
- package/dist/actions/rpc_client.d.ts.map +1 -0
- package/dist/actions/rpc_client.js +151 -0
- package/dist/actions/transports.d.ts +47 -0
- package/dist/actions/transports.d.ts.map +1 -0
- package/dist/actions/transports.js +108 -0
- package/dist/actions/transports_http.d.ts +16 -0
- package/dist/actions/transports_http.d.ts.map +1 -0
- package/dist/actions/transports_http.js +81 -0
- package/dist/actions/transports_ws.d.ts +26 -0
- package/dist/actions/transports_ws.d.ts.map +1 -0
- package/dist/actions/transports_ws.js +94 -0
- package/dist/actions/transports_ws_backend.d.ts +42 -0
- package/dist/actions/transports_ws_backend.d.ts.map +1 -0
- package/dist/actions/transports_ws_backend.js +133 -0
- package/dist/http/jsonrpc.d.ts +22 -97
- package/dist/http/jsonrpc.d.ts.map +1 -1
- package/dist/http/jsonrpc.js +11 -24
- package/dist/http/jsonrpc_errors.d.ts +2 -0
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +2 -0
- package/dist/http/surface.d.ts +3 -3
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/realtime/sse.d.ts +5 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.d.ts +2 -2
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/server/app_server.d.ts +2 -2
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/uuid.d.ts +12 -0
- package/dist/uuid.d.ts.map +1 -0
- package/dist/uuid.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket transport — sends JSON-RPC messages via WebSocket with request tracking.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { ThrownJsonrpcError, jsonrpc_error_messages, UNKNOWN_ERROR_MESSAGE, } from '../http/jsonrpc_errors.js';
|
|
7
|
+
import { is_jsonrpc_notification, is_jsonrpc_request, is_jsonrpc_response, is_jsonrpc_error_response, to_jsonrpc_message_id, create_jsonrpc_error_response, } from '../http/jsonrpc_helpers.js';
|
|
8
|
+
import { RequestTracker } from './request_tracker.svelte.js';
|
|
9
|
+
export class FrontendWebsocketTransport {
|
|
10
|
+
transport_name = 'frontend_websocket_rpc';
|
|
11
|
+
#connection;
|
|
12
|
+
#receive;
|
|
13
|
+
#request_tracker;
|
|
14
|
+
#remove_message_handler;
|
|
15
|
+
#remove_error_handler;
|
|
16
|
+
constructor(connection, receive, request_timeout_ms) {
|
|
17
|
+
this.#connection = connection;
|
|
18
|
+
this.#receive = receive;
|
|
19
|
+
this.#request_tracker = new RequestTracker(request_timeout_ms);
|
|
20
|
+
// TODO maybe we want to do this setup elsewhere, not hardcoded like this
|
|
21
|
+
this.#remove_message_handler = connection.add_message_handler(async (event) => {
|
|
22
|
+
try {
|
|
23
|
+
const data = JSON.parse(event.data);
|
|
24
|
+
// TODO the `data.id !== null` check should be refactored, maybe we want the "Error Message Response" concept for non-null ids
|
|
25
|
+
// Check if this is a response to one of our requests
|
|
26
|
+
if (is_jsonrpc_response(data) || (is_jsonrpc_error_response(data) && data.id !== null)) {
|
|
27
|
+
// This is a response to a request we sent
|
|
28
|
+
this.#request_tracker.handle_message(data);
|
|
29
|
+
}
|
|
30
|
+
else if (is_jsonrpc_request(data) || is_jsonrpc_notification(data)) {
|
|
31
|
+
// This is a new request/notification from the server
|
|
32
|
+
await this.#receive(data);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.warn('[ws_transport] received unknown message type:', data);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('[ws_transport] error parsing WebSocket message:', error);
|
|
40
|
+
// TODO maybe send the whole thing back wrapped in an error?
|
|
41
|
+
// can't reference anything else for a response
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.#remove_error_handler = connection.add_error_handler((event) => {
|
|
45
|
+
console.error('[ws_transport] WebSocket error:', event);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async send(message) {
|
|
49
|
+
if (!this.is_ready()) {
|
|
50
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.service_unavailable('WebSocket not connected'));
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// If this is a JSON-RPC request with an id (not a notification), set up request tracking.
|
|
54
|
+
if (is_jsonrpc_request(message)) {
|
|
55
|
+
// TODO track the whole request?
|
|
56
|
+
const deferred = this.#request_tracker.track_request(message.id);
|
|
57
|
+
this.#connection.send(message);
|
|
58
|
+
// Return the promise that will resolve when the response is received
|
|
59
|
+
const result = await deferred.promise;
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
else if (is_jsonrpc_notification(message)) {
|
|
63
|
+
// For notifications, just send without tracking
|
|
64
|
+
this.#connection.send(message);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Invalid message type - return error with id if available
|
|
68
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.invalid_request());
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof ThrownJsonrpcError) {
|
|
72
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), {
|
|
73
|
+
code: error.code,
|
|
74
|
+
message: error.message,
|
|
75
|
+
data: error.data,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.internal_error(error.message || UNKNOWN_ERROR_MESSAGE));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
is_ready() {
|
|
82
|
+
return this.#connection.connected;
|
|
83
|
+
}
|
|
84
|
+
dispose() {
|
|
85
|
+
if (this.#remove_message_handler) {
|
|
86
|
+
this.#remove_message_handler();
|
|
87
|
+
this.#remove_message_handler = null;
|
|
88
|
+
}
|
|
89
|
+
if (this.#remove_error_handler) {
|
|
90
|
+
this.#remove_error_handler();
|
|
91
|
+
this.#remove_error_handler = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend WebSocket transport — manages server-side WebSocket connections
|
|
3
|
+
* with session tracking and revocation support.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { WSContext } from 'hono/ws';
|
|
8
|
+
import type { JsonrpcNotification, JsonrpcRequest, JsonrpcResponseOrError, JsonrpcErrorResponse } from '../http/jsonrpc.js';
|
|
9
|
+
import { type Uuid } from '../uuid.js';
|
|
10
|
+
import { type Transport } from './transports.js';
|
|
11
|
+
export declare class BackendWebsocketTransport implements Transport {
|
|
12
|
+
#private;
|
|
13
|
+
readonly transport_name: "backend_websocket_rpc";
|
|
14
|
+
/**
|
|
15
|
+
* Add a new WebSocket connection with auth info.
|
|
16
|
+
* Session connections pass a token hash for targeted revocation.
|
|
17
|
+
* Bearer token connections (api_token, daemon_token) pass null —
|
|
18
|
+
* they're still reachable via {@link close_sockets_for_account}.
|
|
19
|
+
*/
|
|
20
|
+
add_connection(ws: WSContext, token_hash: string | null, account_id: Uuid): Uuid;
|
|
21
|
+
/**
|
|
22
|
+
* Remove a WebSocket connection and its auth tracking data.
|
|
23
|
+
* Idempotent — safe to call after revocation has already cleaned up.
|
|
24
|
+
*/
|
|
25
|
+
remove_connection(ws: WSContext): void;
|
|
26
|
+
/**
|
|
27
|
+
* Close all sockets associated with a specific session token hash.
|
|
28
|
+
*
|
|
29
|
+
* @returns the number of sockets closed
|
|
30
|
+
*/
|
|
31
|
+
close_sockets_for_session(token_hash: string): number;
|
|
32
|
+
/**
|
|
33
|
+
* Close all sockets associated with a specific account.
|
|
34
|
+
*
|
|
35
|
+
* @returns the number of sockets closed
|
|
36
|
+
*/
|
|
37
|
+
close_sockets_for_account(account_id: Uuid): number;
|
|
38
|
+
send(message: JsonrpcRequest): Promise<JsonrpcResponseOrError>;
|
|
39
|
+
send(message: JsonrpcNotification): Promise<JsonrpcErrorResponse | null>;
|
|
40
|
+
is_ready(): boolean;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=transports_ws_backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports_ws_backend.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws_backend.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAc,KAAK,IAAI,EAAC,MAAM,YAAY,CAAC;AAClD,OAAO,EAA2B,KAAK,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAIzE,qBAAa,yBAA0B,YAAW,SAAS;;IAC1D,QAAQ,CAAC,cAAc,EAAG,uBAAuB,CAAU;IAY3D;;;;;OAKG;IACH,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,UAAU,EAAE,IAAI,GAAG,IAAI;IAWhF;;;OAGG;IACH,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAOtC;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAcrD;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM;IAiC7C,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA4C9E,QAAQ,IAAI,OAAO;CAGnB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend WebSocket transport — manages server-side WebSocket connections
|
|
3
|
+
* with session tracking and revocation support.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { jsonrpc_error_messages } from '../http/jsonrpc_errors.js';
|
|
8
|
+
import { create_jsonrpc_error_response, to_jsonrpc_message_id, is_jsonrpc_request, } from '../http/jsonrpc_helpers.js';
|
|
9
|
+
import { create_uuid } from '../uuid.js';
|
|
10
|
+
import { WS_CLOSE_SESSION_REVOKED } from './transports.js';
|
|
11
|
+
// TODO support a SSE backend transport
|
|
12
|
+
export class BackendWebsocketTransport {
|
|
13
|
+
transport_name = 'backend_websocket_rpc';
|
|
14
|
+
// Map connection IDs to WebSocket contexts
|
|
15
|
+
#connections = new Map();
|
|
16
|
+
// Reverse map to find connection ID by socket
|
|
17
|
+
#connection_ids = new WeakMap();
|
|
18
|
+
// Session auth tracking — parallel maps keyed by connection ID
|
|
19
|
+
#connection_token_hashes = new Map();
|
|
20
|
+
#connection_account_ids = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Add a new WebSocket connection with auth info.
|
|
23
|
+
* Session connections pass a token hash for targeted revocation.
|
|
24
|
+
* Bearer token connections (api_token, daemon_token) pass null —
|
|
25
|
+
* they're still reachable via {@link close_sockets_for_account}.
|
|
26
|
+
*/
|
|
27
|
+
add_connection(ws, token_hash, account_id) {
|
|
28
|
+
const connection_id = create_uuid();
|
|
29
|
+
this.#connections.set(connection_id, ws);
|
|
30
|
+
this.#connection_ids.set(ws, connection_id);
|
|
31
|
+
if (token_hash !== null) {
|
|
32
|
+
this.#connection_token_hashes.set(connection_id, token_hash);
|
|
33
|
+
}
|
|
34
|
+
this.#connection_account_ids.set(connection_id, account_id);
|
|
35
|
+
return connection_id;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Remove a WebSocket connection and its auth tracking data.
|
|
39
|
+
* Idempotent — safe to call after revocation has already cleaned up.
|
|
40
|
+
*/
|
|
41
|
+
remove_connection(ws) {
|
|
42
|
+
const connection_id = this.#connection_ids.get(ws);
|
|
43
|
+
if (connection_id) {
|
|
44
|
+
this.#cleanup_connection(connection_id, ws);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Close all sockets associated with a specific session token hash.
|
|
49
|
+
*
|
|
50
|
+
* @returns the number of sockets closed
|
|
51
|
+
*/
|
|
52
|
+
close_sockets_for_session(token_hash) {
|
|
53
|
+
let count = 0;
|
|
54
|
+
for (const [connection_id, hash] of this.#connection_token_hashes) {
|
|
55
|
+
if (hash === token_hash) {
|
|
56
|
+
const ws = this.#connections.get(connection_id);
|
|
57
|
+
if (ws) {
|
|
58
|
+
this.#revoke_connection(connection_id, ws);
|
|
59
|
+
count++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return count;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Close all sockets associated with a specific account.
|
|
67
|
+
*
|
|
68
|
+
* @returns the number of sockets closed
|
|
69
|
+
*/
|
|
70
|
+
close_sockets_for_account(account_id) {
|
|
71
|
+
let count = 0;
|
|
72
|
+
for (const [connection_id, id] of this.#connection_account_ids) {
|
|
73
|
+
if (id === account_id) {
|
|
74
|
+
const ws = this.#connections.get(connection_id);
|
|
75
|
+
if (ws) {
|
|
76
|
+
this.#revoke_connection(connection_id, ws);
|
|
77
|
+
count++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return count;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Remove all tracking state for a connection.
|
|
85
|
+
*/
|
|
86
|
+
#cleanup_connection(connection_id, ws) {
|
|
87
|
+
this.#connections.delete(connection_id);
|
|
88
|
+
this.#connection_ids.delete(ws);
|
|
89
|
+
this.#connection_token_hashes.delete(connection_id);
|
|
90
|
+
this.#connection_account_ids.delete(connection_id);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Clean up a connection and close its socket with a revocation code.
|
|
94
|
+
*/
|
|
95
|
+
#revoke_connection(connection_id, ws) {
|
|
96
|
+
this.#cleanup_connection(connection_id, ws);
|
|
97
|
+
ws.close(WS_CLOSE_SESSION_REVOKED, 'Session revoked');
|
|
98
|
+
}
|
|
99
|
+
async send(message) {
|
|
100
|
+
// TODO currently just broadcasts all messages to all clients, the transport abstraction is still a WIP
|
|
101
|
+
if (is_jsonrpc_request(message)) {
|
|
102
|
+
return create_jsonrpc_error_response(message.id,
|
|
103
|
+
// TODO maybe use a not yet implemented error message?
|
|
104
|
+
jsonrpc_error_messages.internal_error('TODO not yet implemented - backend WebSocket transport cannot send requests expecting responses yet'));
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
await this.#broadcast(message);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.internal_error(error instanceof Error ? error.message : 'failed to broadcast notification'));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Broadcast a message to all connected clients.
|
|
116
|
+
*/
|
|
117
|
+
#broadcast(message) {
|
|
118
|
+
const serialized = JSON.stringify(message);
|
|
119
|
+
for (const ws of this.#connections.values()) {
|
|
120
|
+
try {
|
|
121
|
+
ws.send(serialized);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('[backend websocket transport] Error broadcasting to client:', error);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// TODO hack - remove if not ever needed, I assume this will need to be async so let's hold that assumption
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
is_ready() {
|
|
131
|
+
return this.#connections.size > 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
package/dist/http/jsonrpc.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON-RPC 2.0 envelope schemas for RPC dispatch and SAES transport.
|
|
3
3
|
*
|
|
4
|
-
* MCP-superset: includes optional `_meta` and `progressToken` fields
|
|
5
|
-
* on params and results. These are `optional()` so consumers that
|
|
6
|
-
* don't use MCP are unaffected.
|
|
7
|
-
*
|
|
8
4
|
* Following MCP, params and result are object-only (no positional arrays).
|
|
5
|
+
* MCP `_meta` types (`JsonrpcMcpMeta`, `JsonrpcRequestParamsMeta`) are
|
|
6
|
+
* exported as building blocks for per-action schemas but are NOT validated
|
|
7
|
+
* at the envelope level — `_meta` content validation belongs in per-action
|
|
8
|
+
* schemas where it produces the correct error code (`invalid_params`, not
|
|
9
|
+
* `invalid_request`).
|
|
9
10
|
*
|
|
10
11
|
* @source https://github.com/modelcontextprotocol/typescript-sdk
|
|
11
12
|
* @see https://www.jsonrpc.org/specification
|
|
@@ -30,67 +31,35 @@ export declare const JsonrpcRequestParamsMeta: z.ZodObject<{
|
|
|
30
31
|
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
31
32
|
}, z.core.$loose>;
|
|
32
33
|
export type JsonrpcRequestParamsMeta = z.infer<typeof JsonrpcRequestParamsMeta>;
|
|
33
|
-
/** Request params — loose object
|
|
34
|
-
export declare const JsonrpcRequestParams: z.ZodObject<{
|
|
35
|
-
_meta: z.ZodOptional<z.ZodObject<{
|
|
36
|
-
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
37
|
-
}, z.core.$loose>>;
|
|
38
|
-
}, z.core.$loose>;
|
|
34
|
+
/** Request params — loose object. Per-action schemas validate `_meta` content. */
|
|
35
|
+
export declare const JsonrpcRequestParams: z.ZodObject<{}, z.core.$loose>;
|
|
39
36
|
export type JsonrpcRequestParams = z.infer<typeof JsonrpcRequestParams>;
|
|
40
|
-
/** Notification params — loose object
|
|
41
|
-
export declare const JsonrpcNotificationParams: z.ZodObject<{
|
|
42
|
-
/**
|
|
43
|
-
* Reserved by MCP to allow clients and servers to attach
|
|
44
|
-
* additional metadata to their notifications.
|
|
45
|
-
*/
|
|
46
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
47
|
-
}, z.core.$loose>;
|
|
37
|
+
/** Notification params — loose object. Per-action schemas validate `_meta` content. */
|
|
38
|
+
export declare const JsonrpcNotificationParams: z.ZodObject<{}, z.core.$loose>;
|
|
48
39
|
export type JsonrpcNotificationParams = z.infer<typeof JsonrpcNotificationParams>;
|
|
49
|
-
/** Result — loose object
|
|
50
|
-
export declare const JsonrpcResult: z.ZodObject<{
|
|
51
|
-
/**
|
|
52
|
-
* Reserved by the protocol to allow clients and servers
|
|
53
|
-
* to attach additional metadata to their responses.
|
|
54
|
-
*/
|
|
55
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
56
|
-
}, z.core.$loose>;
|
|
40
|
+
/** Result — loose object. Per-action schemas validate `_meta` content. */
|
|
41
|
+
export declare const JsonrpcResult: z.ZodObject<{}, z.core.$loose>;
|
|
57
42
|
export type JsonrpcResult = z.infer<typeof JsonrpcResult>;
|
|
58
43
|
/** A request that expects a response. */
|
|
59
44
|
export declare const JsonrpcRequest: z.ZodObject<{
|
|
60
45
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
61
46
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
62
47
|
method: z.ZodString;
|
|
63
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
64
|
-
_meta: z.ZodOptional<z.ZodObject<{
|
|
65
|
-
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
66
|
-
}, z.core.$loose>>;
|
|
67
|
-
}, z.core.$loose>>;
|
|
48
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
68
49
|
}, z.core.$loose>;
|
|
69
50
|
export type JsonrpcRequest = z.infer<typeof JsonrpcRequest>;
|
|
70
51
|
/** A notification which does not expect a response. */
|
|
71
52
|
export declare const JsonrpcNotification: z.ZodObject<{
|
|
72
53
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
73
54
|
method: z.ZodString;
|
|
74
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
75
|
-
/**
|
|
76
|
-
* Reserved by MCP to allow clients and servers to attach
|
|
77
|
-
* additional metadata to their notifications.
|
|
78
|
-
*/
|
|
79
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
80
|
-
}, z.core.$loose>>;
|
|
55
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
81
56
|
}, z.core.$loose>;
|
|
82
57
|
export type JsonrpcNotification = z.infer<typeof JsonrpcNotification>;
|
|
83
58
|
/** A successful (non-error) response to a request. */
|
|
84
59
|
export declare const JsonrpcResponse: z.ZodObject<{
|
|
85
60
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
86
61
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
87
|
-
result: z.ZodObject<{
|
|
88
|
-
/**
|
|
89
|
-
* Reserved by the protocol to allow clients and servers
|
|
90
|
-
* to attach additional metadata to their responses.
|
|
91
|
-
*/
|
|
92
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
93
|
-
}, z.core.$loose>;
|
|
62
|
+
result: z.ZodObject<{}, z.core.$loose>;
|
|
94
63
|
}, z.core.$loose>;
|
|
95
64
|
export type JsonrpcResponse = z.infer<typeof JsonrpcResponse>;
|
|
96
65
|
export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
@@ -133,13 +102,7 @@ export type JsonrpcErrorResponse = z.infer<typeof JsonrpcErrorResponse>;
|
|
|
133
102
|
export declare const JsonrpcResponseOrError: z.ZodUnion<readonly [z.ZodObject<{
|
|
134
103
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
135
104
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
136
|
-
result: z.ZodObject<{
|
|
137
|
-
/**
|
|
138
|
-
* Reserved by the protocol to allow clients and servers
|
|
139
|
-
* to attach additional metadata to their responses.
|
|
140
|
-
*/
|
|
141
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
142
|
-
}, z.core.$loose>;
|
|
105
|
+
result: z.ZodObject<{}, z.core.$loose>;
|
|
143
106
|
}, z.core.$loose>, z.ZodObject<{
|
|
144
107
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
145
108
|
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
@@ -155,31 +118,15 @@ export declare const JsonrpcMessage: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
155
118
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
156
119
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
157
120
|
method: z.ZodString;
|
|
158
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
159
|
-
_meta: z.ZodOptional<z.ZodObject<{
|
|
160
|
-
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
161
|
-
}, z.core.$loose>>;
|
|
162
|
-
}, z.core.$loose>>;
|
|
121
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
163
122
|
}, z.core.$loose>, z.ZodObject<{
|
|
164
123
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
165
124
|
method: z.ZodString;
|
|
166
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
167
|
-
/**
|
|
168
|
-
* Reserved by MCP to allow clients and servers to attach
|
|
169
|
-
* additional metadata to their notifications.
|
|
170
|
-
*/
|
|
171
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
172
|
-
}, z.core.$loose>>;
|
|
125
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
173
126
|
}, z.core.$loose>, z.ZodObject<{
|
|
174
127
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
175
128
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
176
|
-
result: z.ZodObject<{
|
|
177
|
-
/**
|
|
178
|
-
* Reserved by the protocol to allow clients and servers
|
|
179
|
-
* to attach additional metadata to their responses.
|
|
180
|
-
*/
|
|
181
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
182
|
-
}, z.core.$loose>;
|
|
129
|
+
result: z.ZodObject<{}, z.core.$loose>;
|
|
183
130
|
}, z.core.$loose>, z.ZodObject<{
|
|
184
131
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
185
132
|
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
@@ -195,44 +142,22 @@ export declare const JsonrpcMessageFromClientToServer: z.ZodUnion<readonly [z.Zo
|
|
|
195
142
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
196
143
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
197
144
|
method: z.ZodString;
|
|
198
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
199
|
-
_meta: z.ZodOptional<z.ZodObject<{
|
|
200
|
-
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
201
|
-
}, z.core.$loose>>;
|
|
202
|
-
}, z.core.$loose>>;
|
|
145
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
203
146
|
}, z.core.$loose>, z.ZodObject<{
|
|
204
147
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
205
148
|
method: z.ZodString;
|
|
206
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
207
|
-
/**
|
|
208
|
-
* Reserved by MCP to allow clients and servers to attach
|
|
209
|
-
* additional metadata to their notifications.
|
|
210
|
-
*/
|
|
211
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
212
|
-
}, z.core.$loose>>;
|
|
149
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
213
150
|
}, z.core.$loose>]>;
|
|
214
151
|
export type JsonrpcMessageFromClientToServer = z.infer<typeof JsonrpcMessageFromClientToServer>;
|
|
215
152
|
/** Messages a server can send to a client (notification, response, or error response). */
|
|
216
153
|
export declare const JsonrpcMessageFromServerToClient: z.ZodUnion<readonly [z.ZodObject<{
|
|
217
154
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
218
155
|
method: z.ZodString;
|
|
219
|
-
params: z.ZodOptional<z.ZodObject<{
|
|
220
|
-
/**
|
|
221
|
-
* Reserved by MCP to allow clients and servers to attach
|
|
222
|
-
* additional metadata to their notifications.
|
|
223
|
-
*/
|
|
224
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
225
|
-
}, z.core.$loose>>;
|
|
156
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
226
157
|
}, z.core.$loose>, z.ZodObject<{
|
|
227
158
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
228
159
|
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
229
|
-
result: z.ZodObject<{
|
|
230
|
-
/**
|
|
231
|
-
* Reserved by the protocol to allow clients and servers
|
|
232
|
-
* to attach additional metadata to their responses.
|
|
233
|
-
*/
|
|
234
|
-
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
235
|
-
}, z.core.$loose>;
|
|
160
|
+
result: z.ZodObject<{}, z.core.$loose>;
|
|
236
161
|
}, z.core.$loose>, z.ZodObject<{
|
|
237
162
|
jsonrpc: z.ZodLiteral<"2.0">;
|
|
238
163
|
id: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,iDAAoC,CAAC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,CAAC,CAAC;AAE5E,uFAAuF;AACvF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;mBAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,wEAAwE;AACxE,eAAO,MAAM,gCAAgC;;;;;;;;;mBAAiD,CAAC;AAC/F,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAEhG,0FAA0F;AAC1F,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;mBAI3C,CAAC;AACH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|
package/dist/http/jsonrpc.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON-RPC 2.0 envelope schemas for RPC dispatch and SAES transport.
|
|
3
3
|
*
|
|
4
|
-
* MCP-superset: includes optional `_meta` and `progressToken` fields
|
|
5
|
-
* on params and results. These are `optional()` so consumers that
|
|
6
|
-
* don't use MCP are unaffected.
|
|
7
|
-
*
|
|
8
4
|
* Following MCP, params and result are object-only (no positional arrays).
|
|
5
|
+
* MCP `_meta` types (`JsonrpcMcpMeta`, `JsonrpcRequestParamsMeta`) are
|
|
6
|
+
* exported as building blocks for per-action schemas but are NOT validated
|
|
7
|
+
* at the envelope level — `_meta` content validation belongs in per-action
|
|
8
|
+
* schemas where it produces the correct error code (`invalid_params`, not
|
|
9
|
+
* `invalid_request`).
|
|
9
10
|
*
|
|
10
11
|
* @source https://github.com/modelcontextprotocol/typescript-sdk
|
|
11
12
|
* @see https://www.jsonrpc.org/specification
|
|
@@ -30,26 +31,12 @@ export const JsonrpcRequestParamsMeta = JsonrpcMcpMeta.extend({
|
|
|
30
31
|
*/
|
|
31
32
|
progressToken: JsonrpcProgressToken.optional(),
|
|
32
33
|
});
|
|
33
|
-
/** Request params — loose object
|
|
34
|
-
export const JsonrpcRequestParams = z.looseObject({
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
export const
|
|
39
|
-
/**
|
|
40
|
-
* Reserved by MCP to allow clients and servers to attach
|
|
41
|
-
* additional metadata to their notifications.
|
|
42
|
-
*/
|
|
43
|
-
_meta: JsonrpcMcpMeta.optional(),
|
|
44
|
-
});
|
|
45
|
-
/** Result — loose object with optional MCP metadata. */
|
|
46
|
-
export const JsonrpcResult = z.looseObject({
|
|
47
|
-
/**
|
|
48
|
-
* Reserved by the protocol to allow clients and servers
|
|
49
|
-
* to attach additional metadata to their responses.
|
|
50
|
-
*/
|
|
51
|
-
_meta: JsonrpcMcpMeta.optional(),
|
|
52
|
-
});
|
|
34
|
+
/** Request params — loose object. Per-action schemas validate `_meta` content. */
|
|
35
|
+
export const JsonrpcRequestParams = z.looseObject({});
|
|
36
|
+
/** Notification params — loose object. Per-action schemas validate `_meta` content. */
|
|
37
|
+
export const JsonrpcNotificationParams = z.looseObject({});
|
|
38
|
+
/** Result — loose object. Per-action schemas validate `_meta` content. */
|
|
39
|
+
export const JsonrpcResult = z.looseObject({});
|
|
53
40
|
/** A request that expects a response. */
|
|
54
41
|
export const JsonrpcRequest = z.looseObject({
|
|
55
42
|
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import { type JsonrpcErrorCode, type JsonrpcErrorObject } from './jsonrpc.js';
|
|
20
|
+
/** Default message for unknown errors. */
|
|
21
|
+
export declare const UNKNOWN_ERROR_MESSAGE = "unknown error";
|
|
20
22
|
/** Names of standard and general application JSON-RPC error codes. */
|
|
21
23
|
export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_found' | 'invalid_params' | 'internal_error' | 'unauthenticated' | 'forbidden' | 'not_found' | 'conflict' | 'validation_error' | 'rate_limited' | 'service_unavailable' | 'timeout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AAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY;CAK3F;AAWD;;;;GAIG;AACH,eAAO,MAAM,cAAc;8CAXQ,kBAAkB;kDAAlB,kBAAkB;gFAAlB,kBAAkB;+EAAlB,kBAAkB;+EAAlB,kBAAkB;gFAAlB,kBAAkB;0EAAlB,kBAAkB;2EAAlB,kBAAkB;yEAAlB,kBAAkB;iFAAlB,kBAAkB;6EAAlB,kBAAkB;oFAAlB,kBAAkB;wEAAlB,kBAAkB;CAyBqC,CAAC;AAI3F;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAcpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAMzC,CAAC;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,GAAI,MAAM,gBAAgB,KAAG,MAClB,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,GAAI,QAAQ,MAAM,KAAG,gBACa,CAAC"}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import { JSONRPC_PARSE_ERROR, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_INVALID_PARAMS, JSONRPC_INTERNAL_ERROR, } from './jsonrpc.js';
|
|
20
|
+
/** Default message for unknown errors. */
|
|
21
|
+
export const UNKNOWN_ERROR_MESSAGE = 'unknown error';
|
|
20
22
|
/**
|
|
21
23
|
* Standard JSON-RPC error codes (5) plus general application codes (8).
|
|
22
24
|
*
|
package/dist/http/surface.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
|
-
import type {
|
|
10
|
+
import type { EventSpec } from '../realtime/sse.js';
|
|
11
11
|
import type { MiddlewareSpec } from './middleware_spec.js';
|
|
12
12
|
import type { RouteAuth, RouteSpec } from './route_spec.js';
|
|
13
13
|
import type { RateLimitKey, RouteErrorSchemas } from './error_schemas.js';
|
|
@@ -114,7 +114,7 @@ export interface GenerateAppSurfaceOptions {
|
|
|
114
114
|
route_specs: Array<RouteSpec>;
|
|
115
115
|
middleware_specs: Array<MiddlewareSpec>;
|
|
116
116
|
env_schema?: z.ZodObject;
|
|
117
|
-
event_specs?: Array<
|
|
117
|
+
event_specs?: Array<EventSpec>;
|
|
118
118
|
rpc_endpoints?: Array<RpcEndpointSpec>;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -138,7 +138,7 @@ export declare const env_schema_to_surface: (schema: z.ZodObject) => Array<AppSu
|
|
|
138
138
|
* @param event_specs - event specs to convert
|
|
139
139
|
* @returns array of event surface entries
|
|
140
140
|
*/
|
|
141
|
-
export declare const events_to_surface: (event_specs: Array<
|
|
141
|
+
export declare const events_to_surface: (event_specs: Array<EventSpec>) => Array<AppSurfaceEvent>;
|
|
142
142
|
/**
|
|
143
143
|
* Generate a JSON-serializable attack surface from middleware, route specs,
|
|
144
144
|
* and optional env/event metadata.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,cAAc,EAAC,MAA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** SSE comment sent on connect to flush headers through proxies. Exported for test assertions. */
|
|
57
57
|
export declare const SSE_CONNECTED_COMMENT = ": connected\n\n";
|
|
58
|
-
/** Spec for
|
|
59
|
-
export interface
|
|
58
|
+
/** Spec for a push event — declares params schema, description, and channel. */
|
|
59
|
+
export interface EventSpec {
|
|
60
60
|
method: string;
|
|
61
61
|
params: z.ZodType;
|
|
62
62
|
description: string;
|
|
63
63
|
channel?: string;
|
|
64
64
|
}
|
|
65
|
+
/** @deprecated Use `EventSpec` instead. */
|
|
66
|
+
export type SseEventSpec = EventSpec;
|
|
65
67
|
/**
|
|
66
68
|
* Create a broadcaster that validates events in DEV mode.
|
|
67
69
|
*
|
|
@@ -74,7 +76,7 @@ export interface SseEventSpec {
|
|
|
74
76
|
*/
|
|
75
77
|
export declare const create_validated_broadcaster: <T extends SseNotification>(broadcaster: {
|
|
76
78
|
broadcast: (channel: string, data: T) => void;
|
|
77
|
-
}, event_specs: Array<
|
|
79
|
+
}, event_specs: Array<EventSpec>, log: Logger) => {
|
|
78
80
|
broadcast: (channel: string, data: T) => void;
|
|
79
81
|
};
|
|
80
82
|
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACrC,mDAAmD;IACnD,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACh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