@moltzap/client 2026.430.0 → 2026.430.1

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/auth.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { Effect } from "effect";
2
+ /** HTTP response from the agent registration endpoints
3
+ * (`/api/v1/auth/register` and `/api/v1/admin/register-agent`). */
4
+ export interface RegisterResponse {
5
+ agentId: string;
6
+ apiKey: string;
7
+ claimUrl: string;
8
+ claimToken: string;
9
+ }
10
+ /** Options for {@link registerAgent}. */
11
+ export interface RegisterAgentOptions {
12
+ description?: string;
13
+ inviteCode?: string;
14
+ /** When set, registers via the secret-gated admin endpoint and pre-claims
15
+ * the agent for this user. See {@link registerAgent}. */
16
+ ownerUserId?: string;
17
+ }
18
+ /** Register a new agent via HTTP. Thin wrapper around the agent-registration
19
+ * endpoints — the WebSocket dance is `MoltZapWsClient`'s job; this just
20
+ * returns the credentials the caller feeds it as `agentKey` at construction.
21
+ *
22
+ * Routes to `/api/v1/admin/register-agent` when `ownerUserId` is provided
23
+ * (admin path pre-claims the agent for the given owner); otherwise routes
24
+ * to the public `/api/v1/auth/register` endpoint. */
25
+ export declare const registerAgent: (baseUrl: string, name: string, opts?: RegisterAgentOptions) => Effect.Effect<RegisterResponse, Error>;
26
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;mEACmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;6DACyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD;;;;;;qDAMqD;AACrD,eAAO,MAAM,aAAa,GACxB,SAAS,MAAM,EACf,MAAM,MAAM,EACZ,OAAO,oBAAoB,KAC1B,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAiCrC,CAAC"}
package/dist/auth.js ADDED
@@ -0,0 +1,37 @@
1
+ import { Effect } from "effect";
2
+ const PUBLIC_PATH = "/api/v1/auth/register";
3
+ const ADMIN_PATH = "/api/v1/admin/register-agent";
4
+ /** Register a new agent via HTTP. Thin wrapper around the agent-registration
5
+ * endpoints — the WebSocket dance is `MoltZapWsClient`'s job; this just
6
+ * returns the credentials the caller feeds it as `agentKey` at construction.
7
+ *
8
+ * Routes to `/api/v1/admin/register-agent` when `ownerUserId` is provided
9
+ * (admin path pre-claims the agent for the given owner); otherwise routes
10
+ * to the public `/api/v1/auth/register` endpoint. */
11
+ export const registerAgent = (baseUrl, name, opts) => Effect.tryPromise({
12
+ try: () => {
13
+ const body = { name };
14
+ if (opts?.description)
15
+ body.description = opts.description;
16
+ if (opts?.inviteCode)
17
+ body.inviteCode = opts.inviteCode;
18
+ if (opts?.ownerUserId)
19
+ body.ownerUserId = opts.ownerUserId;
20
+ const path = opts?.ownerUserId ? ADMIN_PATH : PUBLIC_PATH;
21
+ return fetch(`${baseUrl}${path}`, {
22
+ method: "POST",
23
+ headers: { "Content-Type": "application/json" },
24
+ body: JSON.stringify(body),
25
+ });
26
+ },
27
+ catch: (err) => (err instanceof Error ? err : new Error(String(err))),
28
+ }).pipe(Effect.flatMap((res) => res.ok
29
+ ? Effect.tryPromise({
30
+ try: () => res.json(),
31
+ catch: (err) => err instanceof Error ? err : new Error(String(err)),
32
+ })
33
+ : Effect.tryPromise({
34
+ try: () => res.text(),
35
+ catch: (err) => err instanceof Error ? err : new Error(String(err)),
36
+ }).pipe(Effect.flatMap((text) => Effect.fail(new Error(`Register failed: ${res.status} ${text}`))))));
37
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAoBhC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAC5C,MAAM,UAAU,GAAG,8BAA8B,CAAC;AAElD;;;;;;qDAMqD;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAe,EACf,IAAY,EACZ,IAA2B,EACa,EAAE,CAC1C,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE;QACR,MAAM,IAAI,GAA2B,EAAE,IAAI,EAAE,CAAC;QAC9C,IAAI,IAAI,EAAE,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAC3D,IAAI,IAAI,EAAE,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACxD,IAAI,IAAI,EAAE,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;QAC1D,OAAO,KAAK,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,EAAE;YAChC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;CACtE,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CACrB,GAAG,CAAC,EAAE;IACJ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QAChB,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAA+B;QAClD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACtD,CAAC;IACJ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QAChB,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE;QACrB,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACtD,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CACjE,CACF,CACN,CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=auth.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.test.d.ts","sourceRoot":"","sources":["../src/auth.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
+ import { Effect } from "effect";
3
+ import { registerAgent } from "./auth.js";
4
+ /** Run an Effect to a Promise for vitest assertions. */
5
+ const run = (e) => Effect.runPromise(e);
6
+ /** Build a fake `fetch` that captures the request and returns a canned
7
+ * `RegisterResponse` payload. The capture is the assertion target — we
8
+ * verify URL and body shape without standing up the real server. The
9
+ * fake matches `typeof globalThis.fetch` so it can replace the real
10
+ * binding without a cast. */
11
+ function makeFakeFetch(responder) {
12
+ const calls = [];
13
+ const fakeFetch = async (input, init) => {
14
+ const url = typeof input === "string"
15
+ ? input
16
+ : input instanceof URL
17
+ ? input.toString()
18
+ : input.url;
19
+ const bodyText = typeof init?.body === "string" ? init.body : "";
20
+ calls.push({
21
+ url,
22
+ method: init?.method,
23
+ body: bodyText ? JSON.parse(bodyText) : undefined,
24
+ });
25
+ if (responder)
26
+ return responder(url);
27
+ return new Response(JSON.stringify({
28
+ agentId: "agent-id",
29
+ apiKey: "api-key",
30
+ claimUrl: "http://example/claim",
31
+ claimToken: "claim-token",
32
+ }), { status: 201, headers: { "Content-Type": "application/json" } });
33
+ };
34
+ return { fakeFetch, calls };
35
+ }
36
+ describe("registerAgent", () => {
37
+ const baseUrl = "http://test.local";
38
+ let originalFetch;
39
+ beforeEach(() => {
40
+ originalFetch = globalThis.fetch;
41
+ });
42
+ afterEach(() => {
43
+ globalThis.fetch = originalFetch;
44
+ });
45
+ it("posts ownerUserId in the body to the admin endpoint", async () => {
46
+ const { fakeFetch, calls } = makeFakeFetch();
47
+ globalThis.fetch = fakeFetch;
48
+ const result = await run(registerAgent(baseUrl, "test", {
49
+ inviteCode: "secret",
50
+ ownerUserId: "00000000-0000-4000-8000-000000000001",
51
+ }));
52
+ expect(calls).toHaveLength(1);
53
+ const [call] = calls;
54
+ expect(call.url).toBe(`${baseUrl}/api/v1/admin/register-agent`);
55
+ expect(call.method).toBe("POST");
56
+ expect(call.body).toEqual({
57
+ name: "test",
58
+ inviteCode: "secret",
59
+ ownerUserId: "00000000-0000-4000-8000-000000000001",
60
+ });
61
+ expect(result.agentId).toBe("agent-id");
62
+ });
63
+ it("posts to the public endpoint without ownerUserId when absent", async () => {
64
+ const { fakeFetch, calls } = makeFakeFetch();
65
+ globalThis.fetch = fakeFetch;
66
+ await run(registerAgent(baseUrl, "test", { inviteCode: "secret" }));
67
+ expect(calls[0].url).toBe(`${baseUrl}/api/v1/auth/register`);
68
+ // toEqual with `additionalProperties` rejects extra keys, so this also
69
+ // proves ownerUserId is not on the body.
70
+ expect(calls[0].body).toEqual({ name: "test", inviteCode: "secret" });
71
+ });
72
+ it("fails when the server returns a non-2xx response", async () => {
73
+ const { fakeFetch } = makeFakeFetch(() => new Response("invite required", {
74
+ status: 403,
75
+ headers: { "Content-Type": "text/plain" },
76
+ }));
77
+ globalThis.fetch = fakeFetch;
78
+ const exit = await Effect.runPromiseExit(registerAgent(baseUrl, "test", {
79
+ ownerUserId: "00000000-0000-4000-8000-000000000001",
80
+ }));
81
+ expect(exit._tag).toBe("Failure");
82
+ });
83
+ });
84
+ //# sourceMappingURL=auth.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.test.js","sourceRoot":"","sources":["../src/auth.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,wDAAwD;AACxD,MAAM,GAAG,GAAG,CAAO,CAAsB,EAAc,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAQ/E;;;;6BAI6B;AAC7B,SAAS,aAAa,CAAC,SAAqC;IAI1D,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,MAAM,SAAS,GAA4B,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC/D,MAAM,GAAG,GACP,OAAO,KAAK,KAAK,QAAQ;YACvB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,KAAK,YAAY,GAAG;gBACpB,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE;gBAClB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QAClB,MAAM,QAAQ,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AC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CACjC,GAAG,EAAE,CACH,IAAI,QAAQ,CAAC,iBAAiB,EAAE;YAC9B,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;SAC1C,CAAC,CACL,CAAC;QACF,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;QAE7B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,cAAc,CACtC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE;YAC7B,WAAW,EAAE,sCAAsC;SACpD,CAAC,CACH,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export { MoltZapChannelCore, type ChannelCoreOptions, type ChannelService, type
5
5
  export { MoltZapWsClient, type WsClientLogger, type MoltZapWsClientOptions, type TrackedRpcResponse, } from "./ws-client.js";
6
6
  export type { SubscriptionFilter, SubscriptionId, EventSubscription, SubscriberHandler, } from "./runtime/subscribers.js";
7
7
  export type { CloseInfo } from "./runtime/close-info.js";
8
+ export { registerAgent, type RegisterAgentOptions, type RegisterResponse, } from "./auth.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,kBAAk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;AACxB,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export { MoltZapService, formatCrossConversationBlock, sanitizeForSystemReminder
2
2
  export { AgentNotFoundError, NotConnectedError, RpcServerError, RpcTimeoutError, MalformedFrameError, } from "./runtime/errors.js";
3
3
  export { MoltZapChannelCore, } from "./channel-core.js";
4
4
  export { MoltZapWsClient, } from "./ws-client.js";
5
+ export { registerAgent, } from "./auth.js";
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,GAO1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,GAQnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,GAIhB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,GAO1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,GAQnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,GAIhB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EACL,aAAa,GAGd,MAAM,WAAW,CAAC"}
@@ -1,18 +1,11 @@
1
1
  import { Effect } from "effect";
2
2
  import { MoltZapWsClient } from "../ws-client.js";
3
- export interface RegisterResponse {
4
- agentId: string;
5
- apiKey: string;
6
- claimUrl: string;
7
- claimToken: string;
8
- }
9
- /** Register a new agent via HTTP. Thin wrapper around the `/api/v1/auth/register`
10
- * endpoint — the WebSocket dance is {@link MoltZapWsClient}'s job; this just
11
- * returns the credentials tests need to feed it `agentKey` at construction. */
12
- export declare const registerAgent: (baseUrl: string, name: string, opts?: {
13
- description?: string;
14
- inviteCode?: string;
15
- }) => Effect.Effect<RegisterResponse, Error>;
3
+ import { type RegisterAgentOptions } from "../auth.js";
4
+ /** Back-compat re-exports. `registerAgent` and its types were promoted to
5
+ * the `@moltzap/client` root; this surface stays so existing test imports
6
+ * (`@moltzap/client/test`) keep working unchanged. New callers should
7
+ * import from `@moltzap/client` directly. */
8
+ export { registerAgent, type RegisterAgentOptions, type RegisterResponse, } from "../auth.js";
16
9
  /** Strip the `/ws` suffix that test harnesses tack onto the WebSocket URL —
17
10
  * `MoltZapWsClient` re-appends it internally. */
18
11
  export declare const stripWsPath: (wsUrl: string) => string;
@@ -26,8 +19,5 @@ export interface ConnectedTestAgent {
26
19
  /** Register a fresh agent, build a `MoltZapWsClient` with its apiKey, and
27
20
  * complete the `auth/connect` handshake. Returns the live client ready for
28
21
  * RPCs and event waits. Caller is responsible for `yield* client.close()`. */
29
- export declare const registerAndConnect: (baseUrl: string, wsUrl: string, name: string, opts?: {
30
- description?: string;
31
- inviteCode?: string;
32
- }) => Effect.Effect<ConnectedTestAgent, Error>;
22
+ export declare const registerAndConnect: (baseUrl: string, wsUrl: string, name: string, opts?: RegisterAgentOptions) => Effect.Effect<ConnectedTestAgent, Error>;
33
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.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;AAEtE;;;6CAG6C;AAC7C,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAEpB;iDACiD;AACjD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MACb,CAAC;AAEhC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;8EAE8E;AAC9E,eAAO,MAAM,kBAAkB,GAC7B,SAAS,MAAM,EACf,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,OAAO,oBAAoB,KAC1B,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CActC,CAAC"}
@@ -1,31 +1,11 @@
1
1
  import { Effect } from "effect";
2
2
  import { MoltZapWsClient } from "../ws-client.js";
3
- /** Register a new agent via HTTP. Thin wrapper around the `/api/v1/auth/register`
4
- * endpoint — the WebSocket dance is {@link MoltZapWsClient}'s job; this just
5
- * returns the credentials tests need to feed it `agentKey` at construction. */
6
- export const registerAgent = (baseUrl, name, opts) => Effect.tryPromise({
7
- try: () => {
8
- const body = { name };
9
- if (opts?.description)
10
- body.description = opts.description;
11
- if (opts?.inviteCode)
12
- body.inviteCode = opts.inviteCode;
13
- return fetch(`${baseUrl}/api/v1/auth/register`, {
14
- method: "POST",
15
- headers: { "Content-Type": "application/json" },
16
- body: JSON.stringify(body),
17
- });
18
- },
19
- catch: (err) => (err instanceof Error ? err : new Error(String(err))),
20
- }).pipe(Effect.flatMap((res) => res.ok
21
- ? Effect.tryPromise({
22
- try: () => res.json(),
23
- catch: (err) => err instanceof Error ? err : new Error(String(err)),
24
- })
25
- : Effect.tryPromise({
26
- try: () => res.text(),
27
- catch: (err) => err instanceof Error ? err : new Error(String(err)),
28
- }).pipe(Effect.flatMap((text) => Effect.fail(new Error(`Register failed: ${res.status} ${text}`))))));
3
+ import { registerAgent } from "../auth.js";
4
+ /** Back-compat re-exports. `registerAgent` and its types were promoted to
5
+ * the `@moltzap/client` root; this surface stays so existing test imports
6
+ * (`@moltzap/client/test`) keep working unchanged. New callers should
7
+ * import from `@moltzap/client` directly. */
8
+ export { registerAgent, } from "../auth.js";
29
9
  /** Strip the `/ws` suffix that test harnesses tack onto the WebSocket URL —
30
10
  * `MoltZapWsClient` re-appends it internally. */
31
11
  export const stripWsPath = (wsUrl) => wsUrl.replace(/\/ws\/?$/, "");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AASlD;;+EAE+E;AAC/E,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAe,EACf,IAAY,EACZ,IAAoD,EACZ,EAAE,CAC1C,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE;QACR,MAAM,IAAI,GAA2B,EAAE,IAAI,EAAE,CAAC;QAC9C,IAAI,IAAI,EAAE,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAC3D,IAAI,IAAI,EAAE,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACxD,OAAO,KAAK,CAAC,GAAG,OAAO,uBAAuB,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAA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KAAK,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC;QAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM;KACrB,CAAC,CAAC;IACH,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAC1B,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CACzC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,gBAAgB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CACrD,EACD,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CACjD,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC;AAC5B,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltzap/client",
3
- "version": "2026.430.0",
3
+ "version": "2026.430.1",
4
4
  "description": "MoltZap client service — connection, conversation state, and cross-conversation context",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "@effect/platform-node": "^0.106.0",
37
37
  "effect": "3.21.0",
38
38
  "pino": "^9.5.0",
39
- "@moltzap/protocol": "2026.430.0"
39
+ "@moltzap/protocol": "2026.430.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@effect/vitest": "^0.29.0",
@@ -46,7 +46,7 @@
46
46
  "pino-pretty": "^13.0.0",
47
47
  "typescript": "^5.7.0",
48
48
  "vitest": "^3.0.0",
49
- "@moltzap/server-core": "2026.430.1"
49
+ "@moltzap/server-core": "2026.430.2"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsc",