@moltzap/client 2026.414.0 → 2026.425.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/channel-core.d.ts +28 -15
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +113 -74
- package/dist/channel-core.js.map +1 -1
- package/dist/channel-core.test.js +126 -34
- package/dist/channel-core.test.js.map +1 -1
- package/dist/cli/__tests__/cli-multi-agent.int.test.d.ts +2 -0
- package/dist/cli/__tests__/cli-multi-agent.int.test.d.ts.map +1 -0
- package/dist/cli/__tests__/cli-multi-agent.int.test.js +26 -0
- package/dist/cli/__tests__/cli-multi-agent.int.test.js.map +1 -0
- package/dist/cli/commands/agents.d.ts +13 -2
- package/dist/cli/commands/agents.d.ts.map +1 -1
- package/dist/cli/commands/agents.js +30 -18
- package/dist/cli/commands/agents.js.map +1 -1
- package/dist/cli/commands/apps.d.ts +96 -0
- package/dist/cli/commands/apps.d.ts.map +1 -0
- package/dist/cli/commands/apps.js +193 -0
- package/dist/cli/commands/apps.js.map +1 -0
- package/dist/cli/commands/apps.test.d.ts +2 -0
- package/dist/cli/commands/apps.test.d.ts.map +1 -0
- package/dist/cli/commands/apps.test.js +220 -0
- package/dist/cli/commands/apps.test.js.map +1 -0
- package/dist/cli/commands/contacts.d.ts +18 -2
- package/dist/cli/commands/contacts.d.ts.map +1 -1
- package/dist/cli/commands/contacts.js +44 -52
- package/dist/cli/commands/contacts.js.map +1 -1
- package/dist/cli/commands/conversations-v2.test.d.ts +2 -0
- package/dist/cli/commands/conversations-v2.test.d.ts.map +1 -0
- package/dist/cli/commands/conversations-v2.test.js +92 -0
- package/dist/cli/commands/conversations-v2.test.js.map +1 -0
- package/dist/cli/commands/conversations.d.ts +73 -3
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +157 -108
- package/dist/cli/commands/conversations.js.map +1 -1
- package/dist/cli/commands/invite.d.ts +6 -2
- package/dist/cli/commands/invite.d.ts.map +1 -1
- package/dist/cli/commands/invite.js +8 -6
- package/dist/cli/commands/invite.js.map +1 -1
- package/dist/cli/commands/messages.d.ts +48 -0
- package/dist/cli/commands/messages.d.ts.map +1 -0
- package/dist/cli/commands/messages.js +68 -0
- package/dist/cli/commands/messages.js.map +1 -0
- package/dist/cli/commands/messages.test.d.ts +2 -0
- package/dist/cli/commands/messages.test.d.ts.map +1 -0
- package/dist/cli/commands/messages.test.js +73 -0
- package/dist/cli/commands/messages.test.js.map +1 -0
- package/dist/cli/commands/permissions.d.ts +66 -0
- package/dist/cli/commands/permissions.d.ts.map +1 -0
- package/dist/cli/commands/permissions.js +101 -0
- package/dist/cli/commands/permissions.js.map +1 -0
- package/dist/cli/commands/permissions.test.d.ts +2 -0
- package/dist/cli/commands/permissions.test.d.ts.map +1 -0
- package/dist/cli/commands/permissions.test.js +126 -0
- package/dist/cli/commands/permissions.test.js.map +1 -0
- package/dist/cli/commands/ping.d.ts +6 -2
- package/dist/cli/commands/ping.d.ts.map +1 -1
- package/dist/cli/commands/ping.js +21 -20
- package/dist/cli/commands/ping.js.map +1 -1
- package/dist/cli/commands/presence.d.ts +10 -2
- package/dist/cli/commands/presence.d.ts.map +1 -1
- package/dist/cli/commands/presence.js +27 -15
- package/dist/cli/commands/presence.js.map +1 -1
- package/dist/cli/commands/register.d.ts +24 -2
- package/dist/cli/commands/register.d.ts.map +1 -1
- package/dist/cli/commands/register.js +123 -47
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/register.test.js +45 -27
- package/dist/cli/commands/register.test.js.map +1 -1
- package/dist/cli/commands/send.d.ts +43 -2
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +55 -13
- package/dist/cli/commands/send.js.map +1 -1
- package/dist/cli/commands/send.test.js +20 -19
- package/dist/cli/commands/send.test.js.map +1 -1
- package/dist/cli/commands/status.d.ts +6 -2
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +16 -10
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/whoami.d.ts +7 -2
- package/dist/cli/commands/whoami.d.ts.map +1 -1
- package/dist/cli/commands/whoami.js +13 -7
- package/dist/cli/commands/whoami.js.map +1 -1
- package/dist/cli/config.d.ts +24 -8
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +65 -39
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/config.test.js +12 -10
- package/dist/cli/config.test.js.map +1 -1
- package/dist/cli/http-client.d.ts +6 -2
- package/dist/cli/http-client.d.ts.map +1 -1
- package/dist/cli/http-client.js +25 -24
- package/dist/cli/http-client.js.map +1 -1
- package/dist/cli/index.d.ts +16 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +160 -27
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/profile.d.ts +134 -0
- package/dist/cli/profile.d.ts.map +1 -0
- package/dist/cli/profile.js +217 -0
- package/dist/cli/profile.js.map +1 -0
- package/dist/cli/profile.test.d.ts +2 -0
- package/dist/cli/profile.test.d.ts.map +1 -0
- package/dist/cli/profile.test.js +263 -0
- package/dist/cli/profile.test.js.map +1 -0
- package/dist/cli/runtime.d.ts +34 -0
- package/dist/cli/runtime.d.ts.map +1 -0
- package/dist/cli/runtime.js +94 -0
- package/dist/cli/runtime.js.map +1 -0
- package/dist/cli/socket-client.d.ts +15 -12
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +72 -75
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts +181 -0
- package/dist/cli/transport.d.ts.map +1 -0
- package/dist/cli/transport.js +324 -0
- package/dist/cli/transport.js.map +1 -0
- package/dist/cli/transport.test.d.ts +2 -0
- package/dist/cli/transport.test.d.ts.map +1 -0
- package/dist/cli/transport.test.js +197 -0
- package/dist/cli/transport.test.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/close-info.d.ts +94 -0
- package/dist/runtime/close-info.d.ts.map +1 -0
- package/dist/runtime/close-info.js +109 -0
- package/dist/runtime/close-info.js.map +1 -0
- package/dist/runtime/close-info.test.d.ts +2 -0
- package/dist/runtime/close-info.test.d.ts.map +1 -0
- package/dist/runtime/close-info.test.js +102 -0
- package/dist/runtime/close-info.test.js.map +1 -0
- package/dist/runtime/errors.d.ts +47 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +20 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/errors.test.d.ts +2 -0
- package/dist/runtime/errors.test.d.ts.map +1 -0
- package/dist/runtime/errors.test.js +66 -0
- package/dist/runtime/errors.test.js.map +1 -0
- package/dist/runtime/frame.d.ts +25 -0
- package/dist/runtime/frame.d.ts.map +1 -0
- package/dist/runtime/frame.js +106 -0
- package/dist/runtime/frame.js.map +1 -0
- package/dist/runtime/frame.test.d.ts +2 -0
- package/dist/runtime/frame.test.d.ts.map +1 -0
- package/dist/runtime/frame.test.js +32 -0
- package/dist/runtime/frame.test.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/refs.d.ts +10 -0
- package/dist/runtime/refs.d.ts.map +1 -0
- package/dist/runtime/refs.js +10 -0
- package/dist/runtime/refs.js.map +1 -0
- package/dist/runtime/runtime.test.d.ts +2 -0
- package/dist/runtime/runtime.test.d.ts.map +1 -0
- package/dist/runtime/runtime.test.js +29 -0
- package/dist/runtime/runtime.test.js.map +1 -0
- package/dist/runtime/subscribers.d.ts +157 -0
- package/dist/runtime/subscribers.d.ts.map +1 -0
- package/dist/runtime/subscribers.js +131 -0
- package/dist/runtime/subscribers.js.map +1 -0
- package/dist/runtime/subscribers.test.d.ts +2 -0
- package/dist/runtime/subscribers.test.d.ts.map +1 -0
- package/dist/runtime/subscribers.test.js +155 -0
- package/dist/runtime/subscribers.test.js.map +1 -0
- package/dist/service.d.ts +68 -17
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +461 -307
- package/dist/service.js.map +1 -1
- package/dist/service.test.js +266 -77
- package/dist/service.test.js.map +1 -1
- package/dist/test/index.d.ts +33 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +44 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test-utils/channel-service-fixture.d.ts +2 -1
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js +31 -11
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/conformance-adapter.d.ts +50 -0
- package/dist/test-utils/conformance-adapter.d.ts.map +1 -0
- package/dist/test-utils/conformance-adapter.js +206 -0
- package/dist/test-utils/conformance-adapter.js.map +1 -0
- package/dist/test-utils/fake-service.d.ts +85 -0
- package/dist/test-utils/fake-service.d.ts.map +1 -0
- package/dist/test-utils/fake-service.js +103 -0
- package/dist/test-utils/fake-service.js.map +1 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +3 -2
- package/dist/test-utils/index.js.map +1 -1
- package/dist/ws-client.d.ts +157 -18
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +432 -94
- package/dist/ws-client.js.map +1 -1
- package/dist/ws-client.test.d.ts +2 -0
- package/dist/ws-client.test.d.ts.map +1 -0
- package/dist/ws-client.test.js +672 -0
- package/dist/ws-client.test.js.map +1 -0
- package/package.json +23 -14
- package/LICENSE +0 -21
- package/dist/__tests__/service.integration.test.d.ts +0 -2
- package/dist/__tests__/service.integration.test.d.ts.map +0 -1
- package/dist/__tests__/service.integration.test.js +0 -1087
- package/dist/__tests__/service.integration.test.js.map +0 -1
- package/dist/cli/commands/delete.d.ts +0 -3
- package/dist/cli/commands/delete.d.ts.map +0 -1
- package/dist/cli/commands/delete.js +0 -10
- package/dist/cli/commands/delete.js.map +0 -1
- package/dist/cli/commands/react.d.ts +0 -3
- package/dist/cli/commands/react.d.ts.map +0 -1
- package/dist/cli/commands/react.js +0 -18
- package/dist/cli/commands/react.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fake `MoltZapService` test double, reusable across the client's own tests
|
|
3
|
+
* and downstream consumers (nanoclaw, openclaw).
|
|
4
|
+
*
|
|
5
|
+
* Strategy: extend the real `MoltZapService`, keeping all stateful logic
|
|
6
|
+
* intact, and override only `sendRpc` so every RPC is answered from a
|
|
7
|
+
* canned-response map. The typed `setResponse` helper indexes by
|
|
8
|
+
* `RpcMethodName` so a typo in the wire name is a compile error — unknown
|
|
9
|
+
* methods fail *at compile time*, not at runtime.
|
|
10
|
+
*
|
|
11
|
+
* Motivation: the `sendToAgent` contract drift bug (A7) happened because a
|
|
12
|
+
* hand-maintained mock drifted from the real wire shape. Typed method names
|
|
13
|
+
* surface renames and additions to the RPC surface as compile errors across
|
|
14
|
+
* every test that uses the fake.
|
|
15
|
+
*
|
|
16
|
+
* Two APIs:
|
|
17
|
+
* (1) `setResponse(method, result)` — strict. `method` must be a
|
|
18
|
+
* `RpcMethodName`; `result` must match `RpcMap[M]["result"]`.
|
|
19
|
+
* (2) `responses` — the underlying `Map<string, unknown>`. Permissive,
|
|
20
|
+
* preserved so existing callers that set unstyped shapes
|
|
21
|
+
* (e.g. `{}` for a method whose real result has required fields)
|
|
22
|
+
* keep working. Prefer `setResponse` in new code.
|
|
23
|
+
*/
|
|
24
|
+
import type { Message, RpcMap, RpcMethodName } from "@moltzap/protocol";
|
|
25
|
+
import { Effect } from "effect";
|
|
26
|
+
import { MoltZapService, type ServiceRpcError } from "../service.js";
|
|
27
|
+
/** A tracked `sendRpc` invocation. */
|
|
28
|
+
export interface RecordedCall {
|
|
29
|
+
method: string;
|
|
30
|
+
params: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Strict canned-response registry shape. Methods must be known protocol
|
|
34
|
+
* names; results must match their declared schema. Use via `setResponse` —
|
|
35
|
+
* spelled out as a type so downstream consumers can compose their own
|
|
36
|
+
* factories.
|
|
37
|
+
*/
|
|
38
|
+
export type CannedResponses = Partial<{
|
|
39
|
+
[M in RpcMethodName]: RpcMap[M]["result"] | ((params: RpcMap[M]["params"]) => RpcMap[M]["result"]);
|
|
40
|
+
}>;
|
|
41
|
+
export declare class FakeMoltZapService extends MoltZapService {
|
|
42
|
+
calls: RecordedCall[];
|
|
43
|
+
/**
|
|
44
|
+
* Permissive response map. Prefer {@link setResponse} for typed
|
|
45
|
+
* registration. Keep this as `Map<string, unknown>` so tests that pass
|
|
46
|
+
* partial or loosely-shaped canned values — and tests that assert on
|
|
47
|
+
* unknown-method rejection — keep working.
|
|
48
|
+
*/
|
|
49
|
+
responses: Map<string, unknown>;
|
|
50
|
+
constructor(opts?: {
|
|
51
|
+
serverUrl?: string;
|
|
52
|
+
agentKey?: string;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Register a canned response, typed against the real RPC map. Unknown
|
|
56
|
+
* method names are a compile error (`RpcMethodName` is a union literal),
|
|
57
|
+
* and values must match `RpcMap[M]["result"]` — a schema change in the
|
|
58
|
+
* protocol flows through to every test that sets a response for that
|
|
59
|
+
* method.
|
|
60
|
+
*/
|
|
61
|
+
setResponse<M extends RpcMethodName>(method: M, result: RpcMap[M]["result"] | ((params: RpcMap[M]["params"]) => RpcMap[M]["result"])): void;
|
|
62
|
+
/**
|
|
63
|
+
* Remove a previously-registered response. Typed against `RpcMethodName`
|
|
64
|
+
* so `deleteResponse("agents/lookpByName")` (typo) is a compile error.
|
|
65
|
+
*/
|
|
66
|
+
deleteResponse(method: RpcMethodName): void;
|
|
67
|
+
sendRpc(method: string, params?: unknown): Effect.Effect<unknown, ServiceRpcError>;
|
|
68
|
+
/**
|
|
69
|
+
* Insert a message into the service's internal buffer without going
|
|
70
|
+
* through the WebSocket path — used to stage state for context-building
|
|
71
|
+
* tests.
|
|
72
|
+
*/
|
|
73
|
+
addMessage(convId: string, msg: Message): void;
|
|
74
|
+
/** Pin an agent name in the internal cache without an RPC round-trip. */
|
|
75
|
+
setAgentNameDirect(id: string, name: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Typed view of the parent class's private Refs, exposed only to this
|
|
78
|
+
* fake so its test-only harness methods (addMessage, setAgentNameDirect)
|
|
79
|
+
* can stage state without going through the WebSocket pipeline. This is
|
|
80
|
+
* the single spot where the subclass widens its own `this` to see parent
|
|
81
|
+
* privates — every other caller goes through the narrow harness API.
|
|
82
|
+
*/
|
|
83
|
+
private get internals();
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=fake-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-service.d.ts","sourceRoot":"","sources":["../../src/test-utils/fake-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAwB,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrE,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC;KACnC,CAAC,IAAI,aAAa,GACf,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACnB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC3D,CAAC,CAAC;AAEH,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,KAAK,EAAE,YAAY,EAAE,CAAM;IAC3B;;;;;OAKG;IACH,SAAS,uBAA8B;gBAGrC,IAAI,GAAE;QACJ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACd;IAQR;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,SAAS,aAAa,EACjC,MAAM,EAAE,CAAC,EACT,MAAM,EACF,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACnB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GACzD,IAAI;IAIP;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAIlC,OAAO,CACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,GACf,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC;IAqB1C;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI;IAY9C,yEAAyE;IACzE,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAMlD;;;;;;OAMG;IACH,OAAO,KAAK,SAAS,GAGpB;CACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fake `MoltZapService` test double, reusable across the client's own tests
|
|
3
|
+
* and downstream consumers (nanoclaw, openclaw).
|
|
4
|
+
*
|
|
5
|
+
* Strategy: extend the real `MoltZapService`, keeping all stateful logic
|
|
6
|
+
* intact, and override only `sendRpc` so every RPC is answered from a
|
|
7
|
+
* canned-response map. The typed `setResponse` helper indexes by
|
|
8
|
+
* `RpcMethodName` so a typo in the wire name is a compile error — unknown
|
|
9
|
+
* methods fail *at compile time*, not at runtime.
|
|
10
|
+
*
|
|
11
|
+
* Motivation: the `sendToAgent` contract drift bug (A7) happened because a
|
|
12
|
+
* hand-maintained mock drifted from the real wire shape. Typed method names
|
|
13
|
+
* surface renames and additions to the RPC surface as compile errors across
|
|
14
|
+
* every test that uses the fake.
|
|
15
|
+
*
|
|
16
|
+
* Two APIs:
|
|
17
|
+
* (1) `setResponse(method, result)` — strict. `method` must be a
|
|
18
|
+
* `RpcMethodName`; `result` must match `RpcMap[M]["result"]`.
|
|
19
|
+
* (2) `responses` — the underlying `Map<string, unknown>`. Permissive,
|
|
20
|
+
* preserved so existing callers that set unstyped shapes
|
|
21
|
+
* (e.g. `{}` for a method whose real result has required fields)
|
|
22
|
+
* keep working. Prefer `setResponse` in new code.
|
|
23
|
+
*/
|
|
24
|
+
import { Effect, HashMap, Option, Ref } from "effect";
|
|
25
|
+
import { MoltZapService } from "../service.js";
|
|
26
|
+
import { RpcServerError } from "../runtime/errors.js";
|
|
27
|
+
export class FakeMoltZapService extends MoltZapService {
|
|
28
|
+
calls = [];
|
|
29
|
+
/**
|
|
30
|
+
* Permissive response map. Prefer {@link setResponse} for typed
|
|
31
|
+
* registration. Keep this as `Map<string, unknown>` so tests that pass
|
|
32
|
+
* partial or loosely-shaped canned values — and tests that assert on
|
|
33
|
+
* unknown-method rejection — keep working.
|
|
34
|
+
*/
|
|
35
|
+
responses = new Map();
|
|
36
|
+
constructor(opts = {}) {
|
|
37
|
+
super({
|
|
38
|
+
serverUrl: opts.serverUrl ?? "ws://test.invalid",
|
|
39
|
+
agentKey: opts.agentKey ?? "test-key",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Register a canned response, typed against the real RPC map. Unknown
|
|
44
|
+
* method names are a compile error (`RpcMethodName` is a union literal),
|
|
45
|
+
* and values must match `RpcMap[M]["result"]` — a schema change in the
|
|
46
|
+
* protocol flows through to every test that sets a response for that
|
|
47
|
+
* method.
|
|
48
|
+
*/
|
|
49
|
+
setResponse(method, result) {
|
|
50
|
+
this.responses.set(method, result);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Remove a previously-registered response. Typed against `RpcMethodName`
|
|
54
|
+
* so `deleteResponse("agents/lookpByName")` (typo) is a compile error.
|
|
55
|
+
*/
|
|
56
|
+
deleteResponse(method) {
|
|
57
|
+
this.responses.delete(method);
|
|
58
|
+
}
|
|
59
|
+
sendRpc(method, params) {
|
|
60
|
+
return Effect.suspend(() => {
|
|
61
|
+
this.calls.push({ method, params });
|
|
62
|
+
if (this.responses.has(method)) {
|
|
63
|
+
const entry = this.responses.get(method);
|
|
64
|
+
if (typeof entry === "function") {
|
|
65
|
+
return Effect.sync(() => entry(params));
|
|
66
|
+
}
|
|
67
|
+
return Effect.succeed(entry);
|
|
68
|
+
}
|
|
69
|
+
return Effect.fail(new RpcServerError({
|
|
70
|
+
code: -32601,
|
|
71
|
+
message: `FakeMoltZapService: no canned response for ${method}`,
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// --- Test harness: reach into private state ---
|
|
76
|
+
/**
|
|
77
|
+
* Insert a message into the service's internal buffer without going
|
|
78
|
+
* through the WebSocket path — used to stage state for context-building
|
|
79
|
+
* tests.
|
|
80
|
+
*/
|
|
81
|
+
addMessage(convId, msg) {
|
|
82
|
+
Effect.runSync(Ref.update(this.internals.messagesRef, (m) => {
|
|
83
|
+
const existing = Option.getOrElse(HashMap.get(m, convId), () => []);
|
|
84
|
+
return HashMap.set(m, convId, [...existing, msg]);
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
/** Pin an agent name in the internal cache without an RPC round-trip. */
|
|
88
|
+
setAgentNameDirect(id, name) {
|
|
89
|
+
Effect.runSync(Ref.update(this.internals.agentNamesRef, (m) => HashMap.set(m, id, name)));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Typed view of the parent class's private Refs, exposed only to this
|
|
93
|
+
* fake so its test-only harness methods (addMessage, setAgentNameDirect)
|
|
94
|
+
* can stage state without going through the WebSocket pipeline. This is
|
|
95
|
+
* the single spot where the subclass widens its own `this` to see parent
|
|
96
|
+
* privates — every other caller goes through the narrow harness API.
|
|
97
|
+
*/
|
|
98
|
+
get internals() {
|
|
99
|
+
// #ignore-sloppy-code-next-line[as-unknown-as]: single test-only view over parent class's private state; callers use this.internals.<ref>
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=fake-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-service.js","sourceRoot":"","sources":["../../src/test-utils/fake-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,cAAc,EAAwB,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAoBtD,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACpD,KAAK,GAAmB,EAAE,CAAC;IAC3B;;;;;OAKG;IACH,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEvC,YACE,OAGI,EAAE;QAEN,KAAK,CAAC;YACJ,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,mBAAmB;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,UAAU;SACtC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CACT,MAAS,EACT,MAE0D;QAE1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,MAAqB;QAClC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAEQ,OAAO,CACd,MAAc,EACd,MAAgB;QAEhB,OAAO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GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAC1E,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,IAAY,SAAS;QACnB,0IAA0I;QAC1I,OAAO,IAAkC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { createFakeChannelService, type ChannelServiceEmit, type ChannelServiceState, type CreateFakeChannelServiceOptions, type FakeChannelService, } from "./channel-service-fixture.js";
|
|
2
|
+
export { FakeMoltZapService, type CannedResponses, type RecordedCall, } from "./fake-service.js";
|
|
3
|
+
export { createMoltZapRealClientFactory, type RealClientFactoryOptions, } from "./conformance-adapter.js";
|
|
2
4
|
import type { Message } from "@moltzap/protocol";
|
|
3
5
|
export declare function buildMessage(overrides?: Partial<Message>): Message;
|
|
4
6
|
export declare function flushDispatchChain(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,wBAAgB,YAAY,CAAC,SAAS,GAAE,OAAO,CAAC,OAAO,CAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,8BAA8B,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,wBAAgB,YAAY,CAAC,SAAS,GAAE,OAAO,CAAC,OAAO,CAAM,GAAG,OAAO,CAStE;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIxD"}
|
package/dist/test-utils/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { createFakeChannelService, } from "./channel-service-fixture.js";
|
|
2
|
+
export { FakeMoltZapService, } from "./fake-service.js";
|
|
3
|
+
export { createMoltZapRealClientFactory, } from "./conformance-adapter.js";
|
|
2
4
|
export function buildMessage(overrides = {}) {
|
|
3
5
|
return {
|
|
4
6
|
id: "msg-1",
|
|
5
7
|
conversationId: "conv-1",
|
|
6
|
-
|
|
7
|
-
seq: 1,
|
|
8
|
+
senderId: "agent-alice",
|
|
8
9
|
parts: [{ type: "text", text: "hello" }],
|
|
9
10
|
createdAt: "2026-04-10T12:00:00.000Z",
|
|
10
11
|
...overrides,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAKzB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAKzB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,kBAAkB,GAGnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,8BAA8B,GAE/B,MAAM,0BAA0B,CAAC;AAIlC,MAAM,UAAU,YAAY,CAAC,YAA8B,EAAE;IAC3D,OAAO;QACL,EAAE,EAAE,OAAO;QACX,cAAc,EAAE,QAAQ;QACxB,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACxC,SAAS,EAAE,0BAA0B;QACrC,GAAG,SAAS;KACF,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
package/dist/ws-client.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type EventFrame, type RpcDefinition, type TSchema, type Static } from "@moltzap/protocol";
|
|
3
|
+
import { NotConnectedError, RpcServerError, RpcTimeoutError } from "./runtime/errors.js";
|
|
4
|
+
import { type EventSubscription, type SubscriberHandler, type SubscriptionFilter } from "./runtime/subscribers.js";
|
|
5
|
+
import { type CloseInfo } from "./runtime/close-info.js";
|
|
6
|
+
export type { CloseInfo };
|
|
7
|
+
/**
|
|
8
|
+
* Default per-RPC timeout. Exported so tests driving `TestClock` can match
|
|
9
|
+
* exactly — keeps tests from silently drifting if this changes.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RPC_TIMEOUT_MS = 30000;
|
|
2
12
|
export interface WsClientLogger {
|
|
3
13
|
info: (...args: unknown[]) => void;
|
|
4
14
|
warn: (...args: unknown[]) => void;
|
|
@@ -7,35 +17,164 @@ export interface WsClientLogger {
|
|
|
7
17
|
export interface MoltZapWsClientOptions {
|
|
8
18
|
serverUrl: string;
|
|
9
19
|
agentKey: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Called once per disconnect (not reconnect). Spec #222 §5.4 + OQ-5 (A):
|
|
22
|
+
* `close` is the typed close metadata — real WebSocket `{code, reason}`
|
|
23
|
+
* when the transport surfaces them, OQ-5 defaults otherwise. Required
|
|
24
|
+
* arg (OQ-6 rewrite): zero-arg `() => void` callers must migrate to
|
|
25
|
+
* accept (and may ignore) the arg.
|
|
26
|
+
*
|
|
27
|
+
* Migration note (spec #222 OQ-4 rewrite): the previous `onEvent`
|
|
28
|
+
* callback was deleted in this rewrite. Callers that want to observe
|
|
29
|
+
* every inbound event register `client.subscribe({}, handler)` after
|
|
30
|
+
* construction; events flow through the per-subscription registry,
|
|
31
|
+
* not through a top-level option.
|
|
32
|
+
*/
|
|
33
|
+
onDisconnect?: (close: CloseInfo) => void;
|
|
34
|
+
onReconnect?: (helloOk: unknown) => void;
|
|
13
35
|
logger?: WsClientLogger;
|
|
14
36
|
}
|
|
15
37
|
/**
|
|
16
|
-
*
|
|
38
|
+
* Return shape of `MoltZapWsClient.sendRpcTracked`. Spec #222 OQ-1
|
|
39
|
+
* resolution (B): surface the outbound request `id` (un-vacuates B4 at
|
|
40
|
+
* `packages/protocol/src/testing/conformance/client/rpc-semantics.ts:205-216`)
|
|
41
|
+
* and the response envelope `type` (un-vacuates V5 at
|
|
42
|
+
* `rpc-semantics.ts:103-110`), without leaking `jsonrpc` onto the
|
|
43
|
+
* caller surface.
|
|
44
|
+
*
|
|
45
|
+
* `type` is the literal `"response"` — the only response-frame kind
|
|
46
|
+
* `packages/protocol/src/schema/frames.ts:18` defines — but it is
|
|
47
|
+
* surfaced as an observable value (not a synthesized adapter constant)
|
|
48
|
+
* so the V5 predicate can flip under a mutation that forges a
|
|
49
|
+
* non-response shape.
|
|
50
|
+
*/
|
|
51
|
+
export interface TrackedRpcResponse<R> {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly type: "response";
|
|
54
|
+
readonly result: R;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* WebSocket lifecycle: open → auth/connect → active. On disconnect,
|
|
58
|
+
* exponential backoff (1s base, 30s cap, jittered) retries the handshake via
|
|
59
|
+
* `Effect.sleep` + `Schedule` so TestClock can drive it. Public API is
|
|
60
|
+
* Effect-based — consumers run the returned Effects themselves (typically at
|
|
61
|
+
* a framework or CLI edge).
|
|
17
62
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
63
|
+
* Transport: `@effect/platform/Socket.makeWebSocket` backed by
|
|
64
|
+
* `@effect/platform-node/NodeSocket.layerWebSocketConstructor`. The Node
|
|
65
|
+
* `WebSocketConstructor` layer is provided internally via `ManagedRuntime`
|
|
66
|
+
* so callers' `connect()` / `sendRpc()` Effects have no extra requirement.
|
|
21
67
|
*/
|
|
22
68
|
export declare class MoltZapWsClient {
|
|
23
|
-
private options;
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
69
|
+
private readonly options;
|
|
70
|
+
private readonly pendingRef;
|
|
71
|
+
private readonly stateRef;
|
|
72
|
+
private readonly malformedRef;
|
|
73
|
+
private readonly eventsBufferRef;
|
|
74
|
+
/**
|
|
75
|
+
* Waiters keyed by event name. Each bucket is a FIFO stack: delivery
|
|
76
|
+
* pops the most recently registered waiter (the tail). Keying by event
|
|
77
|
+
* name keeps dispatch O(1) per inbound frame regardless of total
|
|
78
|
+
* outstanding waiters.
|
|
79
|
+
*/
|
|
80
|
+
private readonly eventWaitersRef;
|
|
81
|
+
private readonly runtime;
|
|
82
|
+
/**
|
|
83
|
+
* Per-subscription event registry. Spec #222 §5.3 (C4 + the
|
|
84
|
+
* `RealClientEventSubscriber.subscribe` filter stub). Constructed
|
|
85
|
+
* synchronously alongside the other Refs; `MoltZapWsClient.subscribe`
|
|
86
|
+
* delegates to it directly.
|
|
87
|
+
*/
|
|
88
|
+
private readonly subscribers;
|
|
28
89
|
private requestCounter;
|
|
29
90
|
private closed;
|
|
91
|
+
private reconnectFiber;
|
|
30
92
|
private _helloOk;
|
|
31
93
|
constructor(options: MoltZapWsClientOptions);
|
|
32
94
|
get helloOk(): unknown;
|
|
33
|
-
connect
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
95
|
+
/** Open the socket, perform auth/connect, resolve with HelloOk. Fails
|
|
96
|
+
* immediately on pre-open close or error. */
|
|
97
|
+
connect(): Effect.Effect<unknown, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
98
|
+
/**
|
|
99
|
+
* Send an RPC. Fails with a typed error:
|
|
100
|
+
* - `NotConnectedError` if the socket isn't OPEN or closes mid-RPC
|
|
101
|
+
* - `RpcTimeoutError` after `RPC_TIMEOUT_MS` — no automatic retry
|
|
102
|
+
* - `RpcServerError` on a typed server-error frame
|
|
103
|
+
*
|
|
104
|
+
* Overloads: pass an `RpcDefinition` for compile-time param/result typing,
|
|
105
|
+
* or a raw method string for untyped legacy call sites.
|
|
106
|
+
*/
|
|
107
|
+
sendRpc<D extends RpcDefinition<string, TSchema, TSchema>>(method: D, params: Static<D["paramsSchema"]>): Effect.Effect<Static<D["resultSchema"]>, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
108
|
+
sendRpc(method: string, params?: unknown): Effect.Effect<unknown, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
109
|
+
/**
|
|
110
|
+
* Send an RPC and surface the outbound request id alongside the
|
|
111
|
+
* response envelope `type` and `result`. Spec #222 §5.1–5.2:
|
|
112
|
+
* un-vacuates B4 (request-id tracking) and V5 (response-type
|
|
113
|
+
* exposure). Mirrors `sendRpc`'s typed/raw overloads.
|
|
114
|
+
*
|
|
115
|
+
* Invariant 3 (spec #222 §4): the returned `id` is the same identity
|
|
116
|
+
* minted inside the existing `rpc-${++counter}` site — no parallel
|
|
117
|
+
* counter, no mirror. The single-id pre-condition is what makes B4 a
|
|
118
|
+
* real check rather than a tautology.
|
|
119
|
+
*/
|
|
120
|
+
sendRpcTracked<D extends RpcDefinition<string, TSchema, TSchema>>(method: D, params: Static<D["paramsSchema"]>): Effect.Effect<TrackedRpcResponse<Static<D["resultSchema"]>>, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
121
|
+
sendRpcTracked(method: string, params?: unknown): Effect.Effect<TrackedRpcResponse<unknown>, NotConnectedError | RpcTimeoutError | RpcServerError>;
|
|
122
|
+
/**
|
|
123
|
+
* Register a per-subscription event handler. Spec #222 §5.3 + OQ-2
|
|
124
|
+
* (A): filter grammar is the three-field `SubscriptionFilter`
|
|
125
|
+
* (`emissionTag` / `conversationId` / `eventNamePrefix`). Returns a
|
|
126
|
+
* handle whose `unsubscribe` Effect drops delivery starting with the
|
|
127
|
+
* next inbound frame (OQ-3 A snapshot semantics).
|
|
128
|
+
*
|
|
129
|
+
* Subscription is legal pre-`connect()`; the registry buffers
|
|
130
|
+
* registrations and starts dispatching once the reader fiber begins
|
|
131
|
+
* producing frames. Fails with `NotConnectedError` only if the client
|
|
132
|
+
* has been permanently torn down via `close()`.
|
|
133
|
+
*/
|
|
134
|
+
subscribe(filter: SubscriptionFilter, handler: SubscriberHandler): Effect.Effect<EventSubscription, NotConnectedError>;
|
|
135
|
+
/**
|
|
136
|
+
* Close the socket permanently (no reconnection). Writes a clean WebSocket
|
|
137
|
+
* close frame (code 1000) before tearing down the scope so the server
|
|
138
|
+
* observes a graceful handshake rather than an abrupt disconnect, preventing
|
|
139
|
+
* lingering CLOSE_WAIT sockets on the server side.
|
|
140
|
+
*/
|
|
141
|
+
close(): Effect.Effect<void, never>;
|
|
142
|
+
/** Wait for the next inbound event whose `event` field equals `eventName`.
|
|
143
|
+
* Consumes a buffered match if present; otherwise awaits the next match
|
|
144
|
+
* with a per-call timeout. */
|
|
145
|
+
waitForEvent(eventName: string, timeoutMs?: number): Effect.Effect<EventFrame, Error>;
|
|
146
|
+
/** Return all buffered events and clear the buffer. Synchronous. */
|
|
147
|
+
drainEvents(): EventFrame[];
|
|
37
148
|
/** Close the socket without marking as permanently closed, triggering reconnection. */
|
|
38
|
-
disconnect(): void
|
|
149
|
+
disconnect(): Effect.Effect<void, never>;
|
|
150
|
+
private disconnectSync;
|
|
151
|
+
private connectEffect;
|
|
152
|
+
/**
|
|
153
|
+
* Tracked variant of `sendRpcEffect`. Reuses the same Deferred /
|
|
154
|
+
* pendingRef plumbing — the only difference is the resolved value:
|
|
155
|
+
* `{id, type: "response", result}` instead of bare `result`. This
|
|
156
|
+
* keeps Invariant 3 (single id source) trivially: we mint `id` once
|
|
157
|
+
* inside this body, register the Deferred under that id, and return
|
|
158
|
+
* the same id to the caller alongside the result.
|
|
159
|
+
*/
|
|
160
|
+
private sendRpcTrackedEffect;
|
|
161
|
+
/**
|
|
162
|
+
* Bare-result RPC — projects the tracked RPC envelope onto its
|
|
163
|
+
* `result` field, discarding the `{id, type}` observability surface.
|
|
164
|
+
* The write / race / timeout plumbing lives in `sendRpcTrackedEffect`
|
|
165
|
+
* so there is one shared site for Invariant 3 (single id source),
|
|
166
|
+
* Invariant 5 (typed error channel), and the `socket.writer` latch
|
|
167
|
+
* race described below.
|
|
168
|
+
*/
|
|
169
|
+
private sendRpcEffect;
|
|
170
|
+
/** Route an inbound frame. Malformed frames are logged + dropped; event
|
|
171
|
+
* frames dispatch to `onEvent` after the shape check. */
|
|
172
|
+
private handleIncoming;
|
|
173
|
+
/** Fail every outstanding event waiter with `message` and clear the map. */
|
|
174
|
+
private failAllEventWaiters;
|
|
175
|
+
private failAllPending;
|
|
176
|
+
/** Schedule a reconnect attempt. Jittered exponential backoff (1s base,
|
|
177
|
+
* 30s cap) routed through `Effect.sleep` so `TestClock` can drive it. */
|
|
39
178
|
private scheduleReconnect;
|
|
40
179
|
}
|
|
41
180
|
//# sourceMappingURL=ws-client.d.ts.map
|
package/dist/ws-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-client.d.ts","sourceRoot":"","sources":["../src/ws-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ws-client.d.ts","sourceRoot":"","sources":["../src/ws-client.ts"],"names":[],"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