@moltzap/router 2026.902.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.
Files changed (49) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +19 -0
  3. package/README.md +31 -0
  4. package/bin/moltzap-router +9 -0
  5. package/dist/index.d.ts +16 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +16 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/router/contract.d.ts +209 -0
  10. package/dist/router/contract.d.ts.map +1 -0
  11. package/dist/router/contract.js +347 -0
  12. package/dist/router/contract.js.map +1 -0
  13. package/dist/router/feed.d.ts +89 -0
  14. package/dist/router/feed.d.ts.map +1 -0
  15. package/dist/router/feed.js +157 -0
  16. package/dist/router/feed.js.map +1 -0
  17. package/dist/router/http.d.ts +30 -0
  18. package/dist/router/http.d.ts.map +1 -0
  19. package/dist/router/http.js +219 -0
  20. package/dist/router/http.js.map +1 -0
  21. package/dist/router/poll-cursor.d.ts +50 -0
  22. package/dist/router/poll-cursor.d.ts.map +1 -0
  23. package/dist/router/poll-cursor.js +142 -0
  24. package/dist/router/poll-cursor.js.map +1 -0
  25. package/dist/router/poll-waiters.d.ts +24 -0
  26. package/dist/router/poll-waiters.d.ts.map +1 -0
  27. package/dist/router/poll-waiters.js +66 -0
  28. package/dist/router/poll-waiters.js.map +1 -0
  29. package/dist/router/poll.d.ts +38 -0
  30. package/dist/router/poll.d.ts.map +1 -0
  31. package/dist/router/poll.js +118 -0
  32. package/dist/router/poll.js.map +1 -0
  33. package/dist/router/rpc.d.ts +37 -0
  34. package/dist/router/rpc.d.ts.map +1 -0
  35. package/dist/router/rpc.js +75 -0
  36. package/dist/router/rpc.js.map +1 -0
  37. package/dist/router/send.d.ts +27 -0
  38. package/dist/router/send.d.ts.map +1 -0
  39. package/dist/router/send.js +91 -0
  40. package/dist/router/send.js.map +1 -0
  41. package/dist/router.d.ts +60 -0
  42. package/dist/router.d.ts.map +1 -0
  43. package/dist/router.js +177 -0
  44. package/dist/router.js.map +1 -0
  45. package/dist/server.d.ts +29 -0
  46. package/dist/server.d.ts.map +1 -0
  47. package/dist/server.js +112 -0
  48. package/dist/server.js.map +1 -0
  49. package/package.json +128 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Tapan Chugh
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ MoltZap
2
+ Copyright 2026 Tapan Chugh
3
+
4
+ This product is licensed under the Apache License, Version 2.0; see LICENSE.
5
+
6
+ Releases published before the four-layer cutover keep the license their
7
+ published manifests declared; the repository LICENSE was the MIT License at
8
+ the time. The source in this repository is original to the project; no
9
+ third-party MIT-licensed source is relicensed by this change.
10
+
11
+ Third-party software is consumed as npm packages, container base images, and
12
+ pinned upstream source archives at build time under their own licenses:
13
+
14
+ - OpenClaw (ghcr.io/openclaw/openclaw) as the base of the OpenClaw agent image.
15
+ - NanoClaw (github.com/nanocoai/nanoclaw) as the pinned source of the NanoClaw
16
+ agent image.
17
+ - The vendored `.claude/skills/cold-read` skill is adapted from the
18
+ safer-by-default project (github.com/chughtapan/safer-by-default) by the same
19
+ copyright holder.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # `@moltzap/router`
2
+
3
+ Router is MoltZap's content-blind, volatile data-plane package. It delivers
4
+ opaque signed messages to explicit agent ids through one globally ordered
5
+ feed. Conversations, membership, endpoint persistence, replay, recovery, and
6
+ policy remain outside this package.
7
+
8
+ It publishes to npm as part of the one-version set; `npm install
9
+ @moltzap/router` pulls the `@moltzap/identity` release it was built with.
10
+
11
+ ## Entry points
12
+
13
+ | Import | Purpose |
14
+ |---|---|
15
+ | `@moltzap/router` | Router Client capability, polling cursors, requests, results, and closed failures |
16
+ | `@moltzap/router/server` | In-memory Router process composition |
17
+
18
+ The package also builds the `moltzap-router` process executable. Its only
19
+ production MoltZap dependency is `@moltzap/identity` for signed messages,
20
+ Registry-backed authentication, and agent identity.
21
+
22
+ ## Verification
23
+
24
+ ```sh
25
+ pnpm nx run @moltzap/router:build
26
+ pnpm nx run @moltzap/router:typecheck:tests
27
+ pnpm nx run @moltzap/router:test
28
+ pnpm nx run @moltzap/router:test:integration
29
+ pnpm nx run @moltzap/router:lint
30
+ pnpm nx run @moltzap/router:arch:check
31
+ ```
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { NodeRuntime } from "@effect/platform-node";
3
+ import { ConfigProvider, Effect, Layer } from "effect";
4
+ import { RouterServer } from "../dist/server.js";
5
+
6
+ Layer.launch(RouterServer.layer).pipe(
7
+ Effect.withConfigProvider(ConfigProvider.fromEnv()),
8
+ NodeRuntime.runMain,
9
+ );
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Public Router contracts: opaque SignedMessages addressed to
3
+ * explicit AgentIds, send results, and bounded endpoint-wide
4
+ * PollCursors. Router carries no ConversationId, membership,
5
+ * transaction, persistence, replay, or recovery semantics; those
6
+ * belong to the endpoint Harness in `@moltzap/client`.
7
+ */
8
+ /** Canonical Router-owned refined values. */
9
+ export { PollCursor, RouterInstanceId, SignedMessageDigest, } from "./router/contract.js";
10
+ /** Closed operation Schemas and their decoded domain types. */
11
+ export { RouterPollRequest, RouterPollResult, RouterSendRequest, RouterSendResult, } from "./router/contract.js";
12
+ /** Public Router client capability. */
13
+ export { Router } from "./router.js";
14
+ /** Closed failures raised by the Router client transport. */
15
+ export { RouterConnectionError, RouterInvalidResponseError, RouterRequestTimeoutError, } from "./router/contract.js";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6CAA6C;AAC7C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,+DAA+D;AAC/D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,6DAA6D;AAC7D,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Public Router contracts: opaque SignedMessages addressed to
3
+ * explicit AgentIds, send results, and bounded endpoint-wide
4
+ * PollCursors. Router carries no ConversationId, membership,
5
+ * transaction, persistence, replay, or recovery semantics; those
6
+ * belong to the endpoint Harness in `@moltzap/client`.
7
+ */
8
+ /** Canonical Router-owned refined values. */
9
+ export { PollCursor, RouterInstanceId, SignedMessageDigest, } from "./router/contract.js";
10
+ /** Closed operation Schemas and their decoded domain types. */
11
+ export { RouterPollRequest, RouterPollResult, RouterSendRequest, RouterSendResult, } from "./router/contract.js";
12
+ /** Public Router client capability. */
13
+ export { Router } from "./router.js";
14
+ /** Closed failures raised by the Router client transport. */
15
+ export { RouterConnectionError, RouterInvalidResponseError, RouterRequestTimeoutError, } from "./router/contract.js";
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6CAA6C;AAC7C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,+DAA+D;AAC/D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,6DAA6D;AAC7D,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,209 @@
1
+ /** @file Closed Router wire values, requests, results, bounds, and client failures. */
2
+ import { type AgentId, type AgentSigningError, AuthenticationFailedError, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, type SignedMessage as SignedMessageValue, UnavailableError, UnsupportedMediaTypeError, VersionMismatchError } from "@moltzap/identity";
3
+ import { Effect, Option, Schema } from "effect";
4
+ /** Exact Router send target. */
5
+ export declare const routerSendPath = "/v1/messages:send";
6
+ /** Exact Router poll target. */
7
+ export declare const routerPollPath = "/v1/messages:poll";
8
+ /** Exact Router health target. */
9
+ export declare const routerHealthPath = "/healthz";
10
+ /** Effect HTTP Router pattern for the exact send target. */
11
+ export declare const routerSendRoutePattern = "/v1/messages::send";
12
+ /** Effect HTTP Router pattern for the exact poll target. */
13
+ export declare const routerPollRoutePattern = "/v1/messages::poll";
14
+ /** Exact media type for Router-owned JSON representations. */
15
+ export declare const routerJsonContentType = "application/json";
16
+ /** Exact protected header carried by every PollCursor. */
17
+ export declare const pollCursorProtectedHeader: Readonly<{
18
+ alg: "dir";
19
+ enc: "A256GCM";
20
+ typ: "application/vnd.moltzap.poll-cursor+jwe";
21
+ }>;
22
+ /** Canonical encoded protected header carried by every PollCursor. */
23
+ export declare const encodedPollCursorProtectedHeader: string;
24
+ /** Prefix separating PollCursor values from unrefined compact JWE text. */
25
+ export declare const pollCursorPrefix = "plc_";
26
+ /** Identifies one volatile Router process instance. */
27
+ export declare const RouterInstanceId: Schema.brand<Schema.filter<typeof Schema.String>, "RouterInstanceId">;
28
+ /** Validated Router process identity. */
29
+ export type RouterInstanceId = typeof RouterInstanceId.Type;
30
+ /** Equality receipt for one complete retained SignedMessage. */
31
+ export declare const SignedMessageDigest: Schema.brand<Schema.filter<typeof Schema.String>, "SignedMessageDigest">;
32
+ /** Validated SignedMessage equality receipt. */
33
+ export type SignedMessageDigest = typeof SignedMessageDigest.Type;
34
+ /** Opaque, authenticated continuation for one caller and Router instance. */
35
+ export declare const PollCursor: Schema.brand<Schema.filter<typeof Schema.String>, "PollCursor">;
36
+ /** Validated opaque Router poll continuation. */
37
+ export type PollCursor = typeof PollCursor.Type;
38
+ /** One authenticated request to accept or recover an opaque message. */
39
+ export interface RouterSendRequest {
40
+ readonly expectedRouterInstanceId: RouterInstanceId;
41
+ readonly mode: "initial" | "retry";
42
+ readonly signedMessage: SignedMessageValue;
43
+ }
44
+ type RouterSendRequestEncoded = Readonly<{
45
+ expectedRouterInstanceId: string;
46
+ mode: "initial" | "retry";
47
+ signedMessage: unknown;
48
+ }>;
49
+ /** Private send shape before the identity-owned artifact is decoded. */
50
+ export interface RawRouterSendRequest {
51
+ readonly expectedRouterInstanceId: RouterInstanceId;
52
+ readonly mode: "initial" | "retry";
53
+ readonly signedMessage: unknown;
54
+ }
55
+ /** Exact private send shape that preserves instance-fence precedence. */
56
+ export declare const RawRouterSendRequest: Schema.Struct<{
57
+ expectedRouterInstanceId: Schema.brand<Schema.filter<typeof Schema.String>, "RouterInstanceId">;
58
+ mode: Schema.Literal<["initial", "retry"]>;
59
+ signedMessage: typeof Schema.Unknown;
60
+ }>;
61
+ /** Exact Schema for one send request. */
62
+ export declare const RouterSendRequest: Schema.Schema<RouterSendRequest, RouterSendRequestEncoded>;
63
+ /** Closed outcome of accepting or recovering an opaque message. */
64
+ export type RouterSendResult = Readonly<{
65
+ kind: "accepted";
66
+ routerInstanceId: RouterInstanceId;
67
+ signedMessageDigest: SignedMessageDigest;
68
+ }> | Readonly<{
69
+ kind: "router_restarted";
70
+ routerInstanceId: RouterInstanceId;
71
+ }> | Readonly<{
72
+ kind: "message_invalid";
73
+ }> | Readonly<{
74
+ kind: "idempotency_conflict";
75
+ }> | Readonly<{
76
+ kind: "retry_identity_unknown";
77
+ }>;
78
+ type RouterSendResultEncoded = Readonly<{
79
+ kind: "accepted";
80
+ routerInstanceId: string;
81
+ signedMessageDigest: string;
82
+ }> | Readonly<{
83
+ kind: "router_restarted";
84
+ routerInstanceId: string;
85
+ }> | Readonly<{
86
+ kind: "message_invalid";
87
+ }> | Readonly<{
88
+ kind: "idempotency_conflict";
89
+ }> | Readonly<{
90
+ kind: "retry_identity_unknown";
91
+ }>;
92
+ /** Exact Schema for every closed send outcome. */
93
+ export declare const RouterSendResult: Schema.Schema<RouterSendResult, RouterSendResultEncoded>;
94
+ /** One authenticated endpoint-wide poll request. */
95
+ export interface RouterPollRequest {
96
+ readonly pollCursor?: PollCursor;
97
+ }
98
+ type RouterPollRequestEncoded = Readonly<{
99
+ pollCursor?: string;
100
+ }>;
101
+ /** Exact Schema for one endpoint-wide poll request. */
102
+ export declare const RouterPollRequest: Schema.Schema<RouterPollRequest, RouterPollRequestEncoded>;
103
+ /** Closed outcome of one endpoint-wide bounded poll. */
104
+ export type RouterPollResult = Readonly<{
105
+ kind: "batch";
106
+ routerInstanceId: RouterInstanceId;
107
+ signedMessages: readonly SignedMessageValue[];
108
+ pollCursor: PollCursor;
109
+ }> | Readonly<{
110
+ kind: "feed_gap";
111
+ routerInstanceId: RouterInstanceId;
112
+ }> | Readonly<{
113
+ kind: "cursor_invalid";
114
+ }>;
115
+ type RouterPollResultEncoded = Readonly<{
116
+ kind: "batch";
117
+ routerInstanceId: string;
118
+ signedMessages: readonly unknown[];
119
+ pollCursor: string;
120
+ }> | Readonly<{
121
+ kind: "feed_gap";
122
+ routerInstanceId: string;
123
+ }> | Readonly<{
124
+ kind: "cursor_invalid";
125
+ }>;
126
+ /** Exact Schema for every closed poll outcome. */
127
+ export declare const RouterPollResult: Schema.Schema<RouterPollResult, RouterPollResultEncoded>;
128
+ declare const RouterConnectionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
129
+ readonly _tag: "RouterConnectionError";
130
+ } & Readonly<A>;
131
+ /** The Router connection could not be established or used. */
132
+ export declare class RouterConnectionError extends RouterConnectionError_base {
133
+ }
134
+ declare const RouterRequestTimeoutError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
135
+ readonly _tag: "RouterRequestTimeoutError";
136
+ } & Readonly<A>;
137
+ /** The configured complete Router call deadline expired. */
138
+ export declare class RouterRequestTimeoutError extends RouterRequestTimeoutError_base {
139
+ }
140
+ declare const RouterInvalidResponseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
141
+ readonly _tag: "RouterInvalidResponseError";
142
+ } & Readonly<A>;
143
+ /** A Router response did not match the selected operation contract. */
144
+ export declare class RouterInvalidResponseError extends RouterInvalidResponseError_base {
145
+ }
146
+ /** Closed failures represented by Router HTTP error envelopes. */
147
+ export type RouterHttpEnvelopeError = MalformedRequestError | AuthenticationFailedError | RouteNotFoundError | MethodNotAllowedError | VersionMismatchError | PayloadTooLargeError | UnsupportedMediaTypeError | OverloadedError | UnavailableError | InternalServerError;
148
+ /** Closed public Router client failure union. */
149
+ export type RouterClientError = RouterHttpEnvelopeError | RouterConnectionError | RouterRequestTimeoutError | RouterInvalidResponseError | AgentSigningError;
150
+ /**
151
+ * Finds the exact status and body for one recognized Router failure tag.
152
+ *
153
+ * @param tag Candidate typed failure tag.
154
+ * @returns Its exact envelope or `undefined` when the tag is not recognized.
155
+ */
156
+ export declare const routerHttpErrorEnvelope: (tag: string) => Readonly<{
157
+ status: number;
158
+ body: string;
159
+ }> | undefined;
160
+ /**
161
+ * Decodes one exact status and body pair into its typed Router failure.
162
+ *
163
+ * @param status Candidate HTTP status.
164
+ * @param body Candidate exact body text.
165
+ * @returns The matching typed failure, when the pair is declared.
166
+ */
167
+ export declare const routerHttpErrorFromResponse: (status: number, body: string) => Option.Option<RouterHttpEnvelopeError>;
168
+ declare const RouterRepresentationLengthError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
169
+ readonly _tag: "RouterRepresentationLengthError";
170
+ } & Readonly<A>;
171
+ /** A Router enclosing representation cannot be measured safely. */
172
+ export declare class RouterRepresentationLengthError extends RouterRepresentationLengthError_base {
173
+ }
174
+ /** Exact maxima for the Router-owned enclosing representations. */
175
+ export interface RouterRepresentationLimits {
176
+ readonly sendRequestBodyBytes: number;
177
+ readonly pollRequestBodyBytes: number;
178
+ readonly oneMessageBatchBytes: number;
179
+ }
180
+ /**
181
+ * Calculates exact enclosing limits while treating SignedMessage as an
182
+ * identity-owned byte sequence.
183
+ *
184
+ * @param maximumSignedMessageByteLength Identity-owned complete message limit.
185
+ * @returns Exact maximum Router request and one-message result byte lengths.
186
+ */
187
+ export declare const calculateRouterRepresentationLimits: (maximumSignedMessageByteLength: number) => Effect.Effect<RouterRepresentationLimits, RouterRepresentationLengthError>;
188
+ /** Exact limits derived from the current closed Router representations. */
189
+ export declare const routerRepresentationLimits: RouterRepresentationLimits;
190
+ /**
191
+ * Computes exact cursor length for a caller, instance, and order width.
192
+ *
193
+ * @param input Plaintext cursor members.
194
+ * @param input.agentId Caller bound into the encrypted continuation.
195
+ * @param input.routerInstanceId Process bound into the continuation.
196
+ * @param input.lastScannedOrder Private order bound into the continuation.
197
+ * @returns The complete prefixed Compact JWE length.
198
+ */
199
+ export declare const pollCursorEncodedLength: (input: {
200
+ readonly agentId: AgentId;
201
+ readonly routerInstanceId: RouterInstanceId;
202
+ readonly lastScannedOrder: bigint;
203
+ }) => number;
204
+ /** Maximum ASCII characters in a valid PollCursor. */
205
+ export declare const maximumPollCursorLength = 348;
206
+ /** Encoded byte width of a RouterInstanceId payload. */
207
+ export declare const routerInstanceIdByteLength = 16;
208
+ export {};
209
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts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