@moltzap/client 2026.503.4 → 2026.504.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.
Files changed (187) hide show
  1. package/dist/channel-core.d.ts +1 -4
  2. package/dist/channel-core.d.ts.map +1 -1
  3. package/dist/channel-core.js +0 -9
  4. package/dist/channel-core.js.map +1 -1
  5. package/dist/channel-core.test.js +90 -71
  6. package/dist/channel-core.test.js.map +1 -1
  7. package/dist/cli/commands/agents.js +2 -2
  8. package/dist/cli/commands/agents.js.map +1 -1
  9. package/dist/cli/commands/apps.d.ts +2 -24
  10. package/dist/cli/commands/apps.d.ts.map +1 -1
  11. package/dist/cli/commands/apps.js +22 -47
  12. package/dist/cli/commands/apps.js.map +1 -1
  13. package/dist/cli/commands/apps.test.js +59 -72
  14. package/dist/cli/commands/apps.test.js.map +1 -1
  15. package/dist/cli/commands/contacts.d.ts +1 -5
  16. package/dist/cli/commands/contacts.d.ts.map +1 -1
  17. package/dist/cli/commands/contacts.js +11 -26
  18. package/dist/cli/commands/contacts.js.map +1 -1
  19. package/dist/cli/commands/conversations-v2.test.js +30 -26
  20. package/dist/cli/commands/conversations-v2.test.js.map +1 -1
  21. package/dist/cli/commands/conversations.d.ts.map +1 -1
  22. package/dist/cli/commands/conversations.js +48 -33
  23. package/dist/cli/commands/conversations.js.map +1 -1
  24. package/dist/cli/commands/messages.d.ts.map +1 -1
  25. package/dist/cli/commands/messages.js +11 -8
  26. package/dist/cli/commands/messages.js.map +1 -1
  27. package/dist/cli/commands/messages.test.js +28 -30
  28. package/dist/cli/commands/messages.test.js.map +1 -1
  29. package/dist/cli/commands/presence.d.ts.map +1 -1
  30. package/dist/cli/commands/presence.js +5 -4
  31. package/dist/cli/commands/presence.js.map +1 -1
  32. package/dist/cli/commands/send.d.ts.map +1 -1
  33. package/dist/cli/commands/send.js +20 -11
  34. package/dist/cli/commands/send.js.map +1 -1
  35. package/dist/cli/commands/send.test.js +11 -9
  36. package/dist/cli/commands/send.test.js.map +1 -1
  37. package/dist/cli/commands/status.js +2 -2
  38. package/dist/cli/commands/status.js.map +1 -1
  39. package/dist/cli/commands/test-transport.d.ts +10 -0
  40. package/dist/cli/commands/test-transport.d.ts.map +1 -0
  41. package/dist/cli/commands/test-transport.js +29 -0
  42. package/dist/cli/commands/test-transport.js.map +1 -0
  43. package/dist/cli/index.d.ts.map +1 -1
  44. package/dist/cli/index.js +0 -2
  45. package/dist/cli/index.js.map +1 -1
  46. package/dist/cli/socket-client.d.ts +9 -4
  47. package/dist/cli/socket-client.d.ts.map +1 -1
  48. package/dist/cli/socket-client.js +27 -12
  49. package/dist/cli/socket-client.js.map +1 -1
  50. package/dist/cli/transport.d.ts +3 -2
  51. package/dist/cli/transport.d.ts.map +1 -1
  52. package/dist/cli/transport.js +6 -6
  53. package/dist/cli/transport.js.map +1 -1
  54. package/dist/cli/transport.test.js +4 -4
  55. package/dist/cli/transport.test.js.map +1 -1
  56. package/dist/index.d.ts +2 -3
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/internal/__tests__/app-callback-partition-key.test.d.ts +2 -0
  61. package/dist/internal/__tests__/app-callback-partition-key.test.d.ts.map +1 -0
  62. package/dist/internal/__tests__/app-callback-partition-key.test.js +33 -0
  63. package/dist/internal/__tests__/app-callback-partition-key.test.js.map +1 -0
  64. package/dist/internal/__tests__/app-callback-partition-worker.test.d.ts +2 -0
  65. package/dist/internal/__tests__/app-callback-partition-worker.test.d.ts.map +1 -0
  66. package/dist/internal/__tests__/{s2c-partition-worker.test.js → app-callback-partition-worker.test.js} +6 -9
  67. package/dist/internal/__tests__/app-callback-partition-worker.test.js.map +1 -0
  68. package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.d.ts +2 -0
  69. package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.d.ts.map +1 -0
  70. package/dist/internal/__tests__/{s2c-partitioned-dispatcher-real-ws.test.js → app-callback-partitioned-dispatcher-real-ws.test.js} +69 -94
  71. package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.js.map +1 -0
  72. package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.d.ts +2 -0
  73. package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.d.ts.map +1 -0
  74. package/dist/internal/__tests__/{s2c-partitioned-dispatcher.test.js → app-callback-partitioned-dispatcher.test.js} +35 -69
  75. package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.js.map +1 -0
  76. package/dist/internal/__tests__/app-callback-test-requests.d.ts +43 -0
  77. package/dist/internal/__tests__/app-callback-test-requests.d.ts.map +1 -0
  78. package/dist/internal/__tests__/app-callback-test-requests.js +101 -0
  79. package/dist/internal/__tests__/app-callback-test-requests.js.map +1 -0
  80. package/dist/internal/{s2c-dispatcher-errors.d.ts → app-callback-dispatcher-errors.d.ts} +5 -21
  81. package/dist/internal/app-callback-dispatcher-errors.d.ts.map +1 -0
  82. package/dist/internal/{s2c-dispatcher-errors.js → app-callback-dispatcher-errors.js} +3 -13
  83. package/dist/internal/app-callback-dispatcher-errors.js.map +1 -0
  84. package/dist/internal/app-callback-partition-key.d.ts +68 -0
  85. package/dist/internal/app-callback-partition-key.d.ts.map +1 -0
  86. package/dist/internal/app-callback-partition-key.js +90 -0
  87. package/dist/internal/app-callback-partition-key.js.map +1 -0
  88. package/dist/internal/{s2c-partition-worker.d.ts → app-callback-partition-worker.d.ts} +5 -5
  89. package/dist/internal/app-callback-partition-worker.d.ts.map +1 -0
  90. package/dist/internal/{s2c-partition-worker.js → app-callback-partition-worker.js} +5 -5
  91. package/dist/internal/app-callback-partition-worker.js.map +1 -0
  92. package/dist/internal/{s2c-partitioned-dispatcher.d.ts → app-callback-partitioned-dispatcher.d.ts} +9 -10
  93. package/dist/internal/app-callback-partitioned-dispatcher.d.ts.map +1 -0
  94. package/dist/internal/{s2c-partitioned-dispatcher.js → app-callback-partitioned-dispatcher.js} +12 -19
  95. package/dist/internal/app-callback-partitioned-dispatcher.js.map +1 -0
  96. package/dist/runtime/errors.d.ts +2 -28
  97. package/dist/runtime/errors.d.ts.map +1 -1
  98. package/dist/runtime/errors.js +0 -9
  99. package/dist/runtime/errors.js.map +1 -1
  100. package/dist/runtime/errors.test.js +2 -2
  101. package/dist/runtime/errors.test.js.map +1 -1
  102. package/dist/runtime/frame.d.ts +17 -18
  103. package/dist/runtime/frame.d.ts.map +1 -1
  104. package/dist/runtime/frame.js +83 -31
  105. package/dist/runtime/frame.js.map +1 -1
  106. package/dist/runtime/frame.test.js +15 -11
  107. package/dist/runtime/frame.test.js.map +1 -1
  108. package/dist/runtime/index.d.ts +1 -1
  109. package/dist/runtime/index.d.ts.map +1 -1
  110. package/dist/runtime/index.js +1 -1
  111. package/dist/runtime/index.js.map +1 -1
  112. package/dist/runtime/local-service-commands.d.ts +7 -0
  113. package/dist/runtime/local-service-commands.d.ts.map +1 -0
  114. package/dist/runtime/local-service-commands.js +6 -0
  115. package/dist/runtime/local-service-commands.js.map +1 -0
  116. package/dist/runtime/runtime.test.js +1 -2
  117. package/dist/runtime/runtime.test.js.map +1 -1
  118. package/dist/runtime/subscribers.d.ts +34 -29
  119. package/dist/runtime/subscribers.d.ts.map +1 -1
  120. package/dist/runtime/subscribers.js +19 -19
  121. package/dist/runtime/subscribers.js.map +1 -1
  122. package/dist/runtime/subscribers.test.js +50 -31
  123. package/dist/runtime/subscribers.test.js.map +1 -1
  124. package/dist/service.d.ts +24 -39
  125. package/dist/service.d.ts.map +1 -1
  126. package/dist/service.js +165 -161
  127. package/dist/service.js.map +1 -1
  128. package/dist/service.test.js +111 -170
  129. package/dist/service.test.js.map +1 -1
  130. package/dist/test-utils/channel-service-fixture.d.ts +1 -2
  131. package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
  132. package/dist/test-utils/channel-service-fixture.js +28 -20
  133. package/dist/test-utils/channel-service-fixture.js.map +1 -1
  134. package/dist/test-utils/conformance-adapter.d.ts +2 -2
  135. package/dist/test-utils/conformance-adapter.d.ts.map +1 -1
  136. package/dist/test-utils/conformance-adapter.js +33 -26
  137. package/dist/test-utils/conformance-adapter.js.map +1 -1
  138. package/dist/test-utils/fake-service.d.ts +14 -39
  139. package/dist/test-utils/fake-service.d.ts.map +1 -1
  140. package/dist/test-utils/fake-service.js +33 -39
  141. package/dist/test-utils/fake-service.js.map +1 -1
  142. package/dist/test-utils/ids.d.ts +9 -0
  143. package/dist/test-utils/ids.d.ts.map +1 -0
  144. package/dist/test-utils/ids.js +52 -0
  145. package/dist/test-utils/ids.js.map +1 -0
  146. package/dist/test-utils/index.d.ts +10 -2
  147. package/dist/test-utils/index.d.ts.map +1 -1
  148. package/dist/test-utils/index.js +12 -5
  149. package/dist/test-utils/index.js.map +1 -1
  150. package/dist/ws-client.d.ts +58 -64
  151. package/dist/ws-client.d.ts.map +1 -1
  152. package/dist/ws-client.js +151 -133
  153. package/dist/ws-client.js.map +1 -1
  154. package/dist/ws-client.test.js +157 -167
  155. package/dist/ws-client.test.js.map +1 -1
  156. package/package.json +3 -3
  157. package/dist/cli/commands/permissions.d.ts +0 -70
  158. package/dist/cli/commands/permissions.d.ts.map +0 -1
  159. package/dist/cli/commands/permissions.js +0 -100
  160. package/dist/cli/commands/permissions.js.map +0 -1
  161. package/dist/cli/commands/permissions.test.d.ts +0 -2
  162. package/dist/cli/commands/permissions.test.d.ts.map +0 -1
  163. package/dist/cli/commands/permissions.test.js +0 -127
  164. package/dist/cli/commands/permissions.test.js.map +0 -1
  165. package/dist/internal/__tests__/s2c-partition-key.test.d.ts +0 -2
  166. package/dist/internal/__tests__/s2c-partition-key.test.d.ts.map +0 -1
  167. package/dist/internal/__tests__/s2c-partition-key.test.js +0 -231
  168. package/dist/internal/__tests__/s2c-partition-key.test.js.map +0 -1
  169. package/dist/internal/__tests__/s2c-partition-worker.test.d.ts +0 -2
  170. package/dist/internal/__tests__/s2c-partition-worker.test.d.ts.map +0 -1
  171. package/dist/internal/__tests__/s2c-partition-worker.test.js.map +0 -1
  172. package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.d.ts +0 -2
  173. package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.d.ts.map +0 -1
  174. package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.js.map +0 -1
  175. package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.d.ts +0 -2
  176. package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.d.ts.map +0 -1
  177. package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.js.map +0 -1
  178. package/dist/internal/s2c-dispatcher-errors.d.ts.map +0 -1
  179. package/dist/internal/s2c-dispatcher-errors.js.map +0 -1
  180. package/dist/internal/s2c-partition-key.d.ts +0 -79
  181. package/dist/internal/s2c-partition-key.d.ts.map +0 -1
  182. package/dist/internal/s2c-partition-key.js +0 -146
  183. package/dist/internal/s2c-partition-key.js.map +0 -1
  184. package/dist/internal/s2c-partition-worker.d.ts.map +0 -1
  185. package/dist/internal/s2c-partition-worker.js.map +0 -1
  186. package/dist/internal/s2c-partitioned-dispatcher.d.ts.map +0 -1
  187. package/dist/internal/s2c-partitioned-dispatcher.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-test-requests.d.ts","sourceRoot":"","sources":["../../../src/internal/__tests__/app-callback-test-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EAInB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAE1C,eAAO,MAAM,SAAS,yCAAyC,CAAC;AAChE,eAAO,MAAM,SAAS,yCAAyC,CAAC;AAChE,eAAO,MAAM,MAAM,yDAAyD,CAAC;AAC7E,eAAO,MAAM,MAAM,yDAAyD,CAAC;AAC7E,eAAO,MAAM,MAAM,yDAAyD,CAAC;AAC7E,eAAO,MAAM,OAAO,kDAAkD,CAAC;AACvE,eAAO,MAAM,SAAS,oDAAoD,CAAC;AAG3E,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,4DAGjD,CAAC;AAEJ,wBAAgB,oBAAoB,CAClC,SAAS,SAAY,EACrB,IAAI,0DAAS,GACZ,MAAM,CAAC,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAalD;AAED,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,SAAS,SAAY,EACrB,IAAI,0DAAS,GACZ,oBAAoB,CAQtB;AAED,wBAAgB,2BAA2B,CACzC,SAAS,SAAY,EACrB,IAAI,0DAAS,GACZ,MAAM,CAAC,OAAO,2BAA2B,CAAC,YAAY,CAAC,CAQzD;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,SAAS,SAAY,EACrB,IAAI,0DAAS,GACZ,oBAAoB,CAQtB;AAED,wBAAgB,aAAa,CAC3B,SAAS,SAAY,GACpB,MAAM,CAAC,OAAO,WAAW,CAAC,YAAY,CAAC,CAOzC;AAED,wBAAgB,OAAO,CACrB,EAAE,EAAE,MAAM,EACV,SAAS,SAAY,GACpB,oBAAoB,CAUtB;AAED,wBAAgB,qBAAqB,CACnC,SAAS,SAAY,GACpB,MAAM,CAAC,OAAO,mBAAmB,CAAC,YAAY,CAAC,CAOjD;AAED,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,SAAS,SAAY,GACpB,oBAAoB,CAUtB;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;2BAGZ,MAAM;;;;;;;;;;2BAIN,MAAM;EAGd,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { agentId, AppsOnBeforeDispatch, AppsOnBeforeMessageDelivery, AppsOnClose, AppsOnSessionActive, conversationId, jsonRpcStringId, messageId, } from "@moltzap/protocol";
2
+ import { LIFECYCLE_CONVERSATION_SENTINEL, } from "../app-callback-partition-key.js";
3
+ export const SESSION_A = "11111111-1111-4111-8111-111111111111";
4
+ export const SESSION_B = "22222222-2222-4222-8222-222222222222";
5
+ export const CONV_X = conversationId("33333333-3333-4333-8333-333333333333");
6
+ export const CONV_Y = conversationId("44444444-4444-4444-8444-444444444444");
7
+ export const CONV_Z = conversationId("77777777-7777-4777-8777-777777777777");
8
+ export const AGENT_A = agentId("55555555-5555-4555-8555-555555555555");
9
+ export const MESSAGE_A = messageId("66666666-6666-4666-8666-666666666666");
10
+ const UUID_SUFFIX_WIDTH = 12;
11
+ export const conversationIdForIndex = (index) => conversationId(`33333333-3333-4333-8333-${index.toString().padStart(UUID_SUFFIX_WIDTH, "0")}`);
12
+ export function beforeDispatchParams(sessionId = SESSION_A, conv = CONV_X) {
13
+ return {
14
+ sessionId,
15
+ appId: "test-app",
16
+ conversationId: conv,
17
+ recipient: { agentId: AGENT_A, ownerId: "owner-a" },
18
+ message: {
19
+ id: MESSAGE_A,
20
+ senderAgentId: AGENT_A,
21
+ parts: [{ type: "text", text: "hello" }],
22
+ },
23
+ attempt: 0,
24
+ };
25
+ }
26
+ export function beforeDispatch(id, sessionId = SESSION_A, conv = CONV_X) {
27
+ const params = beforeDispatchParams(sessionId, conv);
28
+ return {
29
+ id: jsonRpcStringId(id),
30
+ definition: AppsOnBeforeDispatch,
31
+ params,
32
+ partition: { sessionId, conversationId: conv },
33
+ };
34
+ }
35
+ export function beforeMessageDeliveryParams(sessionId = SESSION_A, conv = CONV_X) {
36
+ return {
37
+ sessionId,
38
+ appId: "test-app",
39
+ conversationId: conv,
40
+ sender: { agentId: AGENT_A, ownerId: "owner-a" },
41
+ message: { parts: [{ type: "text", text: "hello" }] },
42
+ };
43
+ }
44
+ export function beforeMessageDelivery(id, sessionId = SESSION_A, conv = CONV_X) {
45
+ const params = beforeMessageDeliveryParams(sessionId, conv);
46
+ return {
47
+ id: jsonRpcStringId(id),
48
+ definition: AppsOnBeforeMessageDelivery,
49
+ params,
50
+ partition: { sessionId, conversationId: conv },
51
+ };
52
+ }
53
+ export function onCloseParams(sessionId = SESSION_A) {
54
+ return {
55
+ sessionId,
56
+ appId: "test-app",
57
+ conversations: { main: CONV_X },
58
+ closedBy: { agentId: AGENT_A, ownerId: "owner-a" },
59
+ };
60
+ }
61
+ export function onClose(id, sessionId = SESSION_A) {
62
+ return {
63
+ id: jsonRpcStringId(id),
64
+ definition: AppsOnClose,
65
+ params: onCloseParams(sessionId),
66
+ partition: {
67
+ sessionId,
68
+ conversationId: LIFECYCLE_CONVERSATION_SENTINEL,
69
+ },
70
+ };
71
+ }
72
+ export function onSessionActiveParams(sessionId = SESSION_A) {
73
+ return {
74
+ sessionId,
75
+ appId: "test-app",
76
+ conversations: { main: CONV_X },
77
+ admittedAgentIds: [AGENT_A],
78
+ };
79
+ }
80
+ export function onSessionActive(id, sessionId = SESSION_A) {
81
+ return {
82
+ id: jsonRpcStringId(id),
83
+ definition: AppsOnSessionActive,
84
+ params: onSessionActiveParams(sessionId),
85
+ partition: {
86
+ sessionId,
87
+ conversationId: LIFECYCLE_CONVERSATION_SENTINEL,
88
+ },
89
+ };
90
+ }
91
+ export const lifecycleRequests = [
92
+ {
93
+ definition: AppsOnClose,
94
+ request: (id, sessionId = SESSION_A) => onClose(id, sessionId),
95
+ },
96
+ {
97
+ definition: AppsOnSessionActive,
98
+ request: (id, sessionId = SESSION_A) => onSessionActive(id, sessionId),
99
+ },
100
+ ];
101
+ //# sourceMappingURL=app-callback-test-requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-test-requests.js","sourceRoot":"","sources":["../../../src/internal/__tests__/app-callback-test-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,SAAS,GAEV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,+BAA+B,GAEhC,MAAM,kCAAkC,CAAC;AAE1C,MAAM,CAAC,MAAM,SAAS,GAAG,sCAAs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;QAChC,SAAS,EAAE;YACT,SAAS;YACT,cAAc,EAAE,+BAA+B;SAChD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,SAAS,GAAG,SAAS;IAErB,OAAO;QACL,SAAS;QACT,KAAK,EAAE,UAAU;QACjB,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QAC/B,gBAAgB,EAAE,CAAC,OAAO,CAAC;KAC5B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,EAAU,EACV,SAAS,GAAG,SAAS;IAErB,OAAO;QACL,EAAE,EAAE,eAAe,CAAC,EAAE,CAAC;QACvB,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC;QACxC,SAAS,EAAE;YACT,SAAS;YACT,cAAc,EAAE,+BAA+B;SAChD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B;QACE,UAAU,EAAE,WAAW;QACvB,OAAO,EAAE,CAAC,EAAU,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,CAAC;KACvE;IACD;QACE,UAAU,EAAE,mBAAmB;QAC/B,OAAO,EAAE,CAAC,EAAU,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,CAC7C,eAAe,CAAC,EAAE,EAAE,SAAS,CAAC;KACjC;CACO,CAAC"}
@@ -1,20 +1,4 @@
1
- declare const MalformedPartitionKeyError_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 & {
2
- readonly _tag: "MalformedPartitionKeyError";
3
- } & Readonly<A>;
4
- /**
5
- * The decoded server-request frame did not carry a usable partition key.
6
- * Examples: required `params.sessionId` missing or not a UUID; method
7
- * name absent from the s2c registry.
8
- *
9
- * Failure mode is structural — the request cannot be routed. The reader
10
- * synthesizes a `-32602 Invalid params` error response.
11
- */
12
- export declare class MalformedPartitionKeyError extends MalformedPartitionKeyError_base<{
13
- readonly method: string;
14
- readonly reason: "missing-session-id" | "missing-conversation-id" | "unknown-method" | "params-shape";
15
- readonly requestId: string;
16
- }> {
17
- }
1
+ import type { JsonRpcStringId } from "@moltzap/protocol";
18
2
  declare const PartitionLimitError_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 & {
19
3
  readonly _tag: "PartitionLimitError";
20
4
  } & Readonly<A>;
@@ -32,7 +16,7 @@ export declare class PartitionLimitError extends PartitionLimitError_base<{
32
16
  readonly key: string;
33
17
  readonly activePartitions: number;
34
18
  readonly maxPartitions: number;
35
- readonly requestId: string;
19
+ readonly requestId: JsonRpcStringId;
36
20
  }> {
37
21
  }
38
22
  declare const PartitionQueueFullError_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 & {
@@ -51,7 +35,7 @@ declare const PartitionQueueFullError_base: new <A extends Record<string, any> =
51
35
  export declare class PartitionQueueFullError extends PartitionQueueFullError_base<{
52
36
  readonly key: string;
53
37
  readonly capacity: number;
54
- readonly requestId: string;
38
+ readonly requestId: JsonRpcStringId;
55
39
  }> {
56
40
  }
57
41
  /**
@@ -61,6 +45,6 @@ export declare class PartitionQueueFullError extends PartitionQueueFullError_bas
61
45
  * frame-routing path discriminate on `_tag` to pick the right wire-error
62
46
  * code.
63
47
  */
64
- export type OfferRejected = MalformedPartitionKeyError | PartitionLimitError | PartitionQueueFullError;
48
+ export type OfferRejected = PartitionLimitError | PartitionQueueFullError;
65
49
  export {};
66
- //# sourceMappingURL=s2c-dispatcher-errors.d.ts.map
50
+ //# sourceMappingURL=app-callback-dispatcher-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-dispatcher-errors.d.ts","sourceRoot":"","sources":["../../src/internal/app-callback-dispatcher-errors.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;;;;AAEzD;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,SAAQ,yBAEvC;IACA,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;CACrC,CAAC;CAAG;;;;AAEL;;;;;;;;;GASG;AACH,qBAAa,uBAAwB,SAAQ,6BAE3C;IACA,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;CACrC,CAAC;CAAG;AAEL;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,uBAAuB,CAAC"}
@@ -1,24 +1,14 @@
1
1
  /**
2
- * Tagged error types for the partitioned s2c dispatcher.
2
+ * Tagged error types for the partitioned appCallback dispatcher.
3
3
  *
4
4
  * Spec: moltzap#356 — partitioned dispatch keyed on
5
5
  * `(sessionId, conversationId, hookKind)`.
6
6
  *
7
7
  * All errors are surfaced on `PartitionedDispatcher.offer`'s typed channel.
8
- * The reader fiber translates each tag into an immediate s2c error response
8
+ * The reader fiber translates each tag into an immediate appCallback error response
9
9
  * so the server's `Deferred.await` resolves deterministically (no hangs).
10
10
  */
11
11
  import { Data } from "effect";
12
- /**
13
- * The decoded server-request frame did not carry a usable partition key.
14
- * Examples: required `params.sessionId` missing or not a UUID; method
15
- * name absent from the s2c registry.
16
- *
17
- * Failure mode is structural — the request cannot be routed. The reader
18
- * synthesizes a `-32602 Invalid params` error response.
19
- */
20
- export class MalformedPartitionKeyError extends Data.TaggedError("MalformedPartitionKeyError") {
21
- }
22
12
  /**
23
13
  * The active-partition count has reached `maxPartitions` (soft cap, default
24
14
  * 256). New partitions cannot be allocated until an existing partition is
@@ -43,4 +33,4 @@ export class PartitionLimitError extends Data.TaggedError("PartitionLimitError")
43
33
  */
44
34
  export class PartitionQueueFullError extends Data.TaggedError("PartitionQueueFullError") {
45
35
  }
46
- //# sourceMappingURL=s2c-dispatcher-errors.js.map
36
+ //# sourceMappingURL=app-callback-dispatcher-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-dispatcher-errors.js","sourceRoot":"","sources":["../../src/internal/app-callback-dispatcher-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CACvD,qBAAqB,CAMrB;CAAG;AAEL;;;;;;;;;GASG;AACH,MAAM,OAAO,uBAAwB,SAAQ,IAAI,CAAC,WAAW,CAC3D,yBAAyB,CAKzB;CAAG"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Pure partition-key extractor for the partitioned appCallback dispatcher.
3
+ *
4
+ * Spec: moltzap#356.
5
+ *
6
+ * `decodeFrames` is the wire boundary. It matches the JSON-RPC method to an
7
+ * app-callback descriptor, validates params against that descriptor, and
8
+ * projects the routing tuple. This module only receives that typed decoded
9
+ * request and turns the tuple into an opaque branded `PartitionKey`.
10
+ *
11
+ * There is no malformed-input branch here: malformed app-callback frames are
12
+ * rejected before a request can enter the dispatcher.
13
+ */
14
+ import { Brand } from "effect";
15
+ import { type AnyAppCallbackRpcDefinition, type DecodedRpcRequest, type JsonRpcStringId } from "@moltzap/protocol";
16
+ /**
17
+ * Branded partition-key string. Constructed only by `extractPartitionKey`.
18
+ * Format is opaque to consumers; equality is value equality.
19
+ */
20
+ export type PartitionKey = string & Brand.Brand<"PartitionKey">;
21
+ export declare const PartitionKey: Brand.Brand.Constructor<PartitionKey>;
22
+ declare const PartitionKeyInvariantError_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 & {
23
+ readonly _tag: "PartitionKeyInvariantError";
24
+ } & Readonly<A>;
25
+ export declare class PartitionKeyInvariantError extends PartitionKeyInvariantError_base<{
26
+ readonly key: PartitionKey;
27
+ readonly message: string;
28
+ }> {
29
+ }
30
+ /**
31
+ * Sentinel placeholder for appCallback methods that carry no `conversationId`
32
+ * (lifecycle: `apps/onClose`, `apps/onSessionActive`).
33
+ * All lifecycle calls for the same `(sessionId, method)` share one
34
+ * partition; cross-method lifecycle ordering is preserved by the server,
35
+ * not the client.
36
+ */
37
+ export declare const LIFECYCLE_CONVERSATION_SENTINEL: "*lifecycle*";
38
+ export interface AppCallbackPartitionRoute {
39
+ readonly sessionId: string;
40
+ readonly conversationId: string;
41
+ }
42
+ /**
43
+ * Shape the dispatcher receives after the wire decoder has matched an
44
+ * app-callback descriptor and validated params against that descriptor.
45
+ */
46
+ export type PartitionableRequest = DecodedRpcRequest<AnyAppCallbackRpcDefinition> & {
47
+ readonly id: JsonRpcStringId;
48
+ readonly partition: AppCallbackPartitionRoute;
49
+ };
50
+ /**
51
+ * Project a partition key from a typed appCallback request. The wire decoder
52
+ * has already validated method membership and params shape, so this function
53
+ * has no malformed-input branch.
54
+ */
55
+ export declare function extractPartitionKey(request: PartitionableRequest): PartitionKey;
56
+ /**
57
+ * Inverse projection for tests + observability. Pure deconstruction of a
58
+ * `PartitionKey` back into its three components. Returning a structured
59
+ * record (rather than a tuple) lets callers discriminate on
60
+ * `conversationId === LIFECYCLE_CONVERSATION_SENTINEL`.
61
+ */
62
+ export declare function describePartitionKey(key: PartitionKey): {
63
+ readonly sessionId: string;
64
+ readonly conversationId: string;
65
+ readonly definition: AnyAppCallbackRpcDefinition;
66
+ };
67
+ export {};
68
+ //# sourceMappingURL=app-callback-partition-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-partition-key.d.ts","sourceRoot":"","sources":["../../src/internal/app-callback-partition-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,KAAK,EAAQ,MAAM,QAAQ,CAAC;AAErC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAChE,eAAO,MAAM,YAAY,uCAAgC,CAAC;;;;AAE1D,qBAAa,0BAA2B,SAAQ,gCAE9C;IACA,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,EAAG,aAAsB,CAAC;AAwBtE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC9B,iBAAiB,CAAC,2BAA2B,CAAC,GAAG;IAC/C,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;CAC/C,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,YAAY,CAId;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,GAAG;IACvD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC;CAClD,CA6BA"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Pure partition-key extractor for the partitioned appCallback dispatcher.
3
+ *
4
+ * Spec: moltzap#356.
5
+ *
6
+ * `decodeFrames` is the wire boundary. It matches the JSON-RPC method to an
7
+ * app-callback descriptor, validates params against that descriptor, and
8
+ * projects the routing tuple. This module only receives that typed decoded
9
+ * request and turns the tuple into an opaque branded `PartitionKey`.
10
+ *
11
+ * There is no malformed-input branch here: malformed app-callback frames are
12
+ * rejected before a request can enter the dispatcher.
13
+ */
14
+ import { Brand, Data } from "effect";
15
+ import {} from "@moltzap/protocol";
16
+ export const PartitionKey = Brand.nominal();
17
+ export class PartitionKeyInvariantError extends Data.TaggedError("PartitionKeyInvariantError") {
18
+ }
19
+ /**
20
+ * Sentinel placeholder for appCallback methods that carry no `conversationId`
21
+ * (lifecycle: `apps/onClose`, `apps/onSessionActive`).
22
+ * All lifecycle calls for the same `(sessionId, method)` share one
23
+ * partition; cross-method lifecycle ordering is preserved by the server,
24
+ * not the client.
25
+ */
26
+ export const LIFECYCLE_CONVERSATION_SENTINEL = "*lifecycle*";
27
+ /**
28
+ * Field separator inside a `PartitionKey`. ASCII vertical bar; not legal
29
+ * in a UUID and not legal in any of our `appId` values, so the encoded
30
+ * key parses unambiguously.
31
+ */
32
+ const KEY_SEP = "|";
33
+ const definitionSegments = new WeakMap();
34
+ const definitionsBySegment = new Map();
35
+ let nextDefinitionSegment = 0;
36
+ const segmentForDefinition = (definition) => {
37
+ const existing = definitionSegments.get(definition);
38
+ if (existing !== undefined)
39
+ return existing;
40
+ const segment = `rpc${nextDefinitionSegment}`;
41
+ nextDefinitionSegment += 1;
42
+ definitionSegments.set(definition, segment);
43
+ definitionsBySegment.set(segment, definition);
44
+ return segment;
45
+ };
46
+ /**
47
+ * Project a partition key from a typed appCallback request. The wire decoder
48
+ * has already validated method membership and params shape, so this function
49
+ * has no malformed-input branch.
50
+ */
51
+ export function extractPartitionKey(request) {
52
+ return PartitionKey(`${request.partition.sessionId}${KEY_SEP}${request.partition.conversationId}${KEY_SEP}${segmentForDefinition(request.definition)}`);
53
+ }
54
+ /**
55
+ * Inverse projection for tests + observability. Pure deconstruction of a
56
+ * `PartitionKey` back into its three components. Returning a structured
57
+ * record (rather than a tuple) lets callers discriminate on
58
+ * `conversationId === LIFECYCLE_CONVERSATION_SENTINEL`.
59
+ */
60
+ export function describePartitionKey(key) {
61
+ // Method is the only field that can contain a slash; sessionId is a
62
+ // UUID and conversationId is a UUID or the lifecycle sentinel. Split
63
+ // on the first two `KEY_SEP` occurrences only so a hypothetical
64
+ // future method name with `KEY_SEP` (impossible today; ASCII `|`)
65
+ // would still round-trip cleanly.
66
+ const first = key.indexOf(KEY_SEP);
67
+ const second = first === -1 ? -1 : key.indexOf(KEY_SEP, first + 1);
68
+ if (first === -1 || second === -1) {
69
+ // `extractPartitionKey` is the only constructor; an unparsable key
70
+ // means a caller bypassed branding. This is a programmer error,
71
+ // not a runtime user-input failure — fail loudly.
72
+ throw new PartitionKeyInvariantError({
73
+ key,
74
+ message: `describePartitionKey: malformed PartitionKey: ${key}`,
75
+ });
76
+ }
77
+ const definition = definitionsBySegment.get(key.slice(second + 1));
78
+ if (definition === undefined) {
79
+ throw new PartitionKeyInvariantError({
80
+ key,
81
+ message: `describePartitionKey: unknown descriptor segment: ${key}`,
82
+ });
83
+ }
84
+ return {
85
+ sessionId: key.slice(0, first),
86
+ conversationId: key.slice(first + 1, second),
87
+ definition,
88
+ };
89
+ }
90
+ //# sourceMappingURL=app-callback-partition-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-partition-key.js","sourceRoot":"","sources":["../../src/internal/app-callback-partition-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAIN,MAAM,mBAAmB,CAAC;AAO3B,MAAM,CAAC,MAAM,YA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,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACnE,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QAClC,mEAAmE;QACnE,gEAAgE;QAChE,kDAAkD;QAClD,MAAM,IAAI,0BAA0B,CAAC;YACnC,GAAG;YACH,OAAO,EAAE,iDAAiD,GAAG,EAAE;SAChE,CAAC,CAAC;IACL,CAAC;IACD,MAAM,UAAU,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACnE,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,0BAA0B,CAAC;YACnC,GAAG;YACH,OAAO,EAAE,qDAAqD,GAAG,EAAE;SACpE,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;QAC9B,cAAc,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC;QAC5C,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Spec: moltzap#356.
6
6
  *
7
7
  * Lifecycle is anchored in a per-worker `Scope.CloseableScope` provided
8
- * by the dispatcher (`s2c-partitioned-dispatcher.ts`'s
8
+ * by the dispatcher (`app-callback-partitioned-dispatcher.ts`'s
9
9
  * `getOrCreatePartitionWorker` calls `Scope.fork(dispatcherScope, …)`
10
10
  * for each new worker and hands the child scope in via the config).
11
11
  * Closing the worker's scope shuts the queue, runs registered
@@ -41,14 +41,14 @@
41
41
  * landing in between.
42
42
  */
43
43
  import { Effect, Fiber, MutableRef, Scope } from "effect";
44
- import { PartitionQueueFullError } from "./s2c-dispatcher-errors.js";
45
- import type { PartitionKey, PartitionableRequest } from "./s2c-partition-key.js";
44
+ import { PartitionQueueFullError } from "./app-callback-dispatcher-errors.js";
45
+ import type { PartitionKey, PartitionableRequest } from "./app-callback-partition-key.js";
46
46
  import type { WsClientLogger } from "../ws-client.js";
47
47
  /**
48
48
  * The handler the worker drains its queue against. Mirrors the existing
49
49
  * `dispatchInboundServerRequest` signature in `ws-client.ts:912-965` —
50
50
  * the dispatcher passes an already-bound function so the worker has no
51
- * direct knowledge of the registered s2c handler registry.
51
+ * direct knowledge of the registered appCallback handler registry.
52
52
  *
53
53
  * Defects inside `handle` are caught and logged by the worker; they
54
54
  * never escape into the per-connection scope's failure channel.
@@ -157,4 +157,4 @@ export interface PartitionWorkerConfig {
157
157
  * `Scope.extend`.
158
158
  */
159
159
  export declare function makePartitionWorker(config: PartitionWorkerConfig): Effect.Effect<PartitionWorker, never>;
160
- //# sourceMappingURL=s2c-partition-worker.d.ts.map
160
+ //# sourceMappingURL=app-callback-partition-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-partition-worker.d.ts","sourceRoot":"","sources":["../../src/internal/app-callback-partition-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,EAAS,MAAM,EAAE,KAAK,EAAE,UAAU,EAAS,KAAK,EAAU,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE,oBAAoB,KAC1B,MAAM,CAAC,MA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C,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,qBAAqB,GAC5B,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAmIvC"}
@@ -5,7 +5,7 @@
5
5
  * Spec: moltzap#356.
6
6
  *
7
7
  * Lifecycle is anchored in a per-worker `Scope.CloseableScope` provided
8
- * by the dispatcher (`s2c-partitioned-dispatcher.ts`'s
8
+ * by the dispatcher (`app-callback-partitioned-dispatcher.ts`'s
9
9
  * `getOrCreatePartitionWorker` calls `Scope.fork(dispatcherScope, …)`
10
10
  * for each new worker and hands the child scope in via the config).
11
11
  * Closing the worker's scope shuts the queue, runs registered
@@ -41,7 +41,7 @@
41
41
  * landing in between.
42
42
  */
43
43
  import { Cause, Effect, Fiber, MutableRef, Queue, Scope, Stream } from "effect";
44
- import { PartitionQueueFullError } from "./s2c-dispatcher-errors.js";
44
+ import { PartitionQueueFullError } from "./app-callback-dispatcher-errors.js";
45
45
  /**
46
46
  * Build one worker. Allocates a bounded queue, forks a draining fiber
47
47
  * via `Stream.fromQueue` + `Stream.runForEach`, and registers the
@@ -69,7 +69,7 @@ export function makePartitionWorker(config) {
69
69
  const drainEffect = Stream.fromQueue(queue).pipe(Stream.runForEach((request) => Effect.gen(function* () {
70
70
  MutableRef.set(idleSince, { _tag: "Busy" });
71
71
  yield* config.handle(request).pipe(Effect.catchAllCause((cause) => Effect.sync(() => {
72
- config.logger?.warn(`s2c partition worker handler defected (key=${config.key})`, Cause.pretty(cause));
72
+ config.logger?.warn(`appCallback partition worker handler defected (key=${config.key})`, Cause.pretty(cause));
73
73
  })));
74
74
  const remaining = yield* Queue.size(queue).pipe(Effect.catchAllCause(() => Effect.succeed(0)));
75
75
  if (remaining === 0) {
@@ -79,7 +79,7 @@ export function makePartitionWorker(config) {
79
79
  });
80
80
  }
81
81
  })), Effect.catchAllCause((cause) => Effect.sync(() => {
82
- config.logger?.warn(`s2c partition worker fiber exited (key=${config.key})`, Cause.pretty(cause));
82
+ config.logger?.warn(`appCallback partition worker fiber exited (key=${config.key})`, Cause.pretty(cause));
83
83
  })), Effect.asVoid);
84
84
  const fiber = yield* Effect.forkScoped(drainEffect);
85
85
  // Shut the queue when the worker scope closes. `Effect.forkScoped`
@@ -138,4 +138,4 @@ export function makePartitionWorker(config) {
138
138
  };
139
139
  }), config.scope);
140
140
  }
141
- //# sourceMappingURL=s2c-partition-worker.js.map
141
+ //# sourceMappingURL=app-callback-partition-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-partition-worker.js","sourceRoot":"","sources":["../../src/internal/app-callback-partition-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAgH9E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA6B;IAE7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC;IACvC,OAAO,KAAK,CAAC,MAAM,CACjB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAuB,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1E,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAY;YAC3C,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,KAAK,EAAE;SACjB,CAAC,CAAC;QAEH,gEAAgE;QAChE,6DAA6D;QAC7D,iEAAiE;QACjE,iEAAiE;QACjE,kBAAkB;QAClB,MAAM,WAAW,GAA+B,MAAM,CAA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}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Partitioned s2c dispatcher.
2
+ * Partitioned appCallback dispatcher.
3
3
  *
4
4
  * Spec: moltzap#356.
5
5
  *
6
- * Replaces the single `Stream.runForEach(handler)` over `s2cInboundQueue`
6
+ * Replaces the single `Stream.runForEach(handler)` over `appCallbackInboundQueue`
7
7
  * (`packages/client/src/ws-client.ts:658-687@f0df363`) with a
8
8
  * partition-router that owns a `Ref<HashMap<PartitionKey,
9
9
  * PartitionWorker>>`. For each inbound request:
@@ -37,8 +37,8 @@
37
37
  * The dispatcher Scope is held in `ConnState`; teardown from
38
38
  * `close()` / `disconnectSync()` is
39
39
  * `runtime.runFork(Scope.close(dispatcherScope, Exit.void))`, mirroring
40
- * today's `runFork(Queue.shutdown(s2cInboundQueue))` +
41
- * `runFork(Fiber.interrupt(s2cDispatcherFiber))` pair.
40
+ * today's `runFork(Queue.shutdown(appCallbackInboundQueue))` +
41
+ * `runFork(Fiber.interrupt(appCallbackDispatcherFiber))` pair.
42
42
  *
43
43
  * Why off-Scope from the socket: `close()` is invoked via `runSync` at
44
44
  * `packages/openclaw-channel/src/__tests__/reconnection.integration.test.ts:14`;
@@ -57,9 +57,9 @@
57
57
  * worker without leaking finalizers onto the dispatcher scope.
58
58
  */
59
59
  import { Effect, Scope } from "effect";
60
- import { type OfferRejected } from "./s2c-dispatcher-errors.js";
61
- import { type PartitionKey, type PartitionableRequest } from "./s2c-partition-key.js";
62
- import { type PartitionHandler } from "./s2c-partition-worker.js";
60
+ import { type OfferRejected } from "./app-callback-dispatcher-errors.js";
61
+ import { type PartitionKey, type PartitionableRequest } from "./app-callback-partition-key.js";
62
+ import { type PartitionHandler } from "./app-callback-partition-worker.js";
63
63
  import type { WsClientLogger } from "../ws-client.js";
64
64
  /**
65
65
  * Tunable knobs. Defaults named in the design doc; downstream picks
@@ -99,7 +99,6 @@ export interface DispatcherStats {
99
99
  readonly activePartitions: number;
100
100
  readonly totalOffered: number;
101
101
  readonly totalRejected: {
102
- readonly malformed: number;
103
102
  readonly partitionLimit: number;
104
103
  readonly partitionQueueFull: number;
105
104
  };
@@ -148,7 +147,7 @@ export interface PartitionedDispatcher {
148
147
  /**
149
148
  * Construction params. `handle` is the per-request work — passed in so
150
149
  * the dispatcher has no direct dependency on the handler-registry
151
- * `Ref<HashMap<string, ServerRpcHandler>>` (`s2cHandlersRef`); the
150
+ * `Ref<HashMap<string, ServerRpcHandler>>` (`appCallbackHandlersRef`); the
152
151
  * caller (`ws-client.ts`) closes over the registry and supplies a
153
152
  * pre-bound function. This preserves the wire-edge schema-decoding
154
153
  * boundary already established in `dispatchInboundServerRequest`.
@@ -178,4 +177,4 @@ export interface MakePartitionedDispatcherParams {
178
177
  * explicitly via `Scope.extend`.
179
178
  */
180
179
  export declare function makePartitionedDispatcher(params: MakePartitionedDispatcherParams): Effect.Effect<PartitionedDispatcher, never>;
181
- //# sourceMappingURL=s2c-partitioned-dispatcher.d.ts.map
180
+ //# sourceMappingURL=app-callback-partitioned-dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-callback-partitioned-dispatcher.d.ts","sourceRoot":"","sources":["../../src/internal/app-callback-partitioned-dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,EAGL,MAAM,EAQN,KAAK,EACN,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,aAA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AAC,cAAc,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,yDAAyD;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,+BAA+B,GACtC,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAgH7C"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Partitioned s2c dispatcher.
2
+ * Partitioned appCallback dispatcher.
3
3
  *
4
4
  * Spec: moltzap#356.
5
5
  *
6
- * Replaces the single `Stream.runForEach(handler)` over `s2cInboundQueue`
6
+ * Replaces the single `Stream.runForEach(handler)` over `appCallbackInboundQueue`
7
7
  * (`packages/client/src/ws-client.ts:658-687@f0df363`) with a
8
8
  * partition-router that owns a `Ref<HashMap<PartitionKey,
9
9
  * PartitionWorker>>`. For each inbound request:
@@ -37,8 +37,8 @@
37
37
  * The dispatcher Scope is held in `ConnState`; teardown from
38
38
  * `close()` / `disconnectSync()` is
39
39
  * `runtime.runFork(Scope.close(dispatcherScope, Exit.void))`, mirroring
40
- * today's `runFork(Queue.shutdown(s2cInboundQueue))` +
41
- * `runFork(Fiber.interrupt(s2cDispatcherFiber))` pair.
40
+ * today's `runFork(Queue.shutdown(appCallbackInboundQueue))` +
41
+ * `runFork(Fiber.interrupt(appCallbackDispatcherFiber))` pair.
42
42
  *
43
43
  * Why off-Scope from the socket: `close()` is invoked via `runSync` at
44
44
  * `packages/openclaw-channel/src/__tests__/reconnection.integration.test.ts:14`;
@@ -56,10 +56,10 @@
56
56
  * every worker; closing one worker's child scope retires only that
57
57
  * worker without leaking finalizers onto the dispatcher scope.
58
58
  */
59
- import { Cause, Duration, Effect, Either, ExecutionStrategy, Exit, HashMap, MutableRef, Option, Ref, Schedule, Scope, } from "effect";
60
- import { PartitionLimitError, } from "./s2c-dispatcher-errors.js";
61
- import { extractPartitionKey, } from "./s2c-partition-key.js";
62
- import { makePartitionWorker, } from "./s2c-partition-worker.js";
59
+ import { Cause, Duration, Effect, ExecutionStrategy, Exit, HashMap, MutableRef, Option, Ref, Schedule, Scope, } from "effect";
60
+ import { PartitionLimitError, } from "./app-callback-dispatcher-errors.js";
61
+ import { extractPartitionKey, } from "./app-callback-partition-key.js";
62
+ import { makePartitionWorker, } from "./app-callback-partition-worker.js";
63
63
  /** Defaults. Documented as the named knob values for the implementation. */
64
64
  export const DEFAULT_PARTITIONED_DISPATCHER_CONFIG = {
65
65
  maxPartitions: 256,
@@ -87,7 +87,6 @@ export function makePartitionedDispatcher(params) {
87
87
  const partitionsRef = yield* Ref.make(HashMap.empty());
88
88
  const counters = {
89
89
  totalOffered: yield* Ref.make(0),
90
- malformed: yield* Ref.make(0),
91
90
  partitionLimit: yield* Ref.make(0),
92
91
  partitionQueueFull: yield* Ref.make(0),
93
92
  };
@@ -104,15 +103,11 @@ export function makePartitionedDispatcher(params) {
104
103
  // Idle-reaper fiber. One fiber per dispatcher (NOT per partition);
105
104
  // walks the map every `idleReaperIntervalMs` and finalizes
106
105
  // partitions whose `idleSince._tag === "Idle"` exceeds the TTL.
107
- const reaperEffect = reapIdlePartitions(internal).pipe(Effect.repeat(Schedule.spaced(Duration.millis(config.idleReaperIntervalMs))), Effect.asVoid, Effect.catchAllCause((cause) => Effect.sync(() => params.logger?.warn("s2c idle reaper exited", Cause.pretty(cause)))));
106
+ const reaperEffect = reapIdlePartitions(internal).pipe(Effect.repeat(Schedule.spaced(Duration.millis(config.idleReaperIntervalMs))), Effect.asVoid, Effect.catchAllCause((cause) => Effect.sync(() => params.logger?.warn("appCallback idle reaper exited", Cause.pretty(cause)))));
108
107
  yield* Scope.extend(Effect.forkScoped(reaperEffect), dispatcherScope);
109
108
  const offer = (request) => Effect.gen(function* () {
110
109
  yield* Ref.update(counters.totalOffered, (n) => n + 1);
111
- const keyResult = extractPartitionKey(request);
112
- const key = yield* Either.match(keyResult, {
113
- onLeft: (err) => Ref.update(counters.malformed, (n) => n + 1).pipe(Effect.zipRight(Effect.fail(err))),
114
- onRight: (value) => Effect.succeed(value),
115
- });
110
+ const key = extractPartitionKey(request);
116
111
  const worker = yield* getOrCreatePartitionWorker({
117
112
  key,
118
113
  requestId: request.id,
@@ -133,14 +128,12 @@ export function makePartitionedDispatcher(params) {
133
128
  partitions.push({ key, queueSize, idle });
134
129
  }
135
130
  const totalOffered = yield* Ref.get(counters.totalOffered);
136
- const malformed = yield* Ref.get(counters.malformed);
137
131
  const partitionLimit = yield* Ref.get(counters.partitionLimit);
138
132
  const partitionQueueFull = yield* Ref.get(counters.partitionQueueFull);
139
133
  return {
140
134
  activePartitions: HashMap.size(map),
141
135
  totalOffered,
142
136
  totalRejected: {
143
- malformed,
144
137
  partitionLimit,
145
138
  partitionQueueFull,
146
139
  },
@@ -217,7 +210,7 @@ function getOrCreatePartitionWorker(params) {
217
210
  // Discard the redundant worker. Closing its scope cascades to
218
211
  // queue.shutdown + the drain fiber's interrupt, releasing every
219
212
  // resource we just allocated.
220
- state.logger?.warn(`s2c partition allocation lost race (key=${key}); discarding redundant worker`);
213
+ state.logger?.warn(`appCallback partition allocation lost race (key=${key}); discarding redundant worker`);
221
214
  yield* Scope.close(workerScope, Exit.void).pipe(Effect.catchAllCause(() => Effect.void));
222
215
  }
223
216
  return inserted.winner;
@@ -286,4 +279,4 @@ function reapIdlePartitions(state) {
286
279
  }
287
280
  });
288
281
  }
289
- //# sourceMappingURL=s2c-partitioned-dispatcher.js.map
282
+ //# sourceMappingURL=app-callback-partitioned-dispatcher.js.map