@moltzap/client 2026.506.0 → 2026.507.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/contacts.d.ts.map +1 -1
- package/dist/cli/commands/contacts.js +3 -3
- package/dist/cli/commands/contacts.js.map +1 -1
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +11 -11
- package/dist/cli/commands/conversations.js.map +1 -1
- package/dist/cli/commands/messages.d.ts.map +1 -1
- package/dist/cli/commands/messages.js +3 -3
- package/dist/cli/commands/messages.js.map +1 -1
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +3 -3
- package/dist/cli/commands/send.js.map +1 -1
- package/dist/cli/commands/test-transport.d.ts.map +1 -1
- package/dist/cli/commands/test-transport.js +11 -8
- package/dist/cli/commands/test-transport.js.map +1 -1
- package/dist/cli/http-client.d.ts +2 -2
- package/dist/cli/http-client.d.ts.map +1 -1
- package/dist/cli/socket-client.d.ts +4 -3
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +6 -4
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts +3 -3
- package/dist/cli/transport.d.ts.map +1 -1
- package/dist/cli/transport.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/__tests__/app-callback-test-requests.d.ts +2 -2
- package/dist/internal/__tests__/app-callback-test-requests.d.ts.map +1 -1
- package/dist/internal/__tests__/app-callback-test-requests.js +3 -2
- package/dist/internal/__tests__/app-callback-test-requests.js.map +1 -1
- package/dist/internal/app-callback-dispatcher-errors.d.ts +3 -3
- package/dist/internal/app-callback-dispatcher-errors.d.ts.map +1 -1
- package/dist/internal/app-callback-partition-key.d.ts +2 -2
- package/dist/internal/app-callback-partition-key.d.ts.map +1 -1
- package/dist/runtime/errors.d.ts +2 -12
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +4 -3
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/frame.d.ts +11 -18
- package/dist/runtime/frame.d.ts.map +1 -1
- package/dist/runtime/frame.js +23 -53
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/frame.test.js +28 -34
- package/dist/runtime/frame.test.js.map +1 -1
- package/dist/runtime/subscribers.d.ts +8 -11
- package/dist/runtime/subscribers.d.ts.map +1 -1
- package/dist/runtime/subscribers.js.map +1 -1
- package/dist/runtime/subscribers.test.js +8 -14
- package/dist/runtime/subscribers.test.js.map +1 -1
- package/dist/service.d.ts +5 -8
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +44 -65
- package/dist/service.js.map +1 -1
- package/dist/service.test.js +9 -9
- package/dist/service.test.js.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test-utils/conformance-adapter.d.ts +5 -5
- package/dist/test-utils/conformance-adapter.d.ts.map +1 -1
- package/dist/test-utils/conformance-adapter.js +26 -29
- package/dist/test-utils/conformance-adapter.js.map +1 -1
- package/dist/test-utils/fake-service.d.ts +4 -4
- package/dist/test-utils/fake-service.d.ts.map +1 -1
- package/dist/test-utils/fake-service.js +19 -10
- package/dist/test-utils/fake-service.js.map +1 -1
- package/dist/test-utils/ids.d.ts +2 -6
- package/dist/test-utils/ids.d.ts.map +1 -1
- package/dist/test-utils/ids.js +1 -2
- package/dist/test-utils/ids.js.map +1 -1
- package/dist/ws-client.d.ts +11 -89
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +56 -153
- package/dist/ws-client.js.map +1 -1
- package/dist/ws-client.test.js +35 -48
- package/dist/ws-client.test.js.map +1 -1
- package/package.json +3 -4
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -3
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/notification-types.types-check.d.ts +0 -2
- package/dist/runtime/notification-types.types-check.d.ts.map +0 -1
- package/dist/runtime/notification-types.types-check.js +0 -57
- package/dist/runtime/notification-types.types-check.js.map +0 -1
- package/dist/service.typed-bridge.test.d.ts +0 -2
- package/dist/service.typed-bridge.test.d.ts.map +0 -1
- package/dist/service.typed-bridge.test.js +0 -93
- package/dist/service.typed-bridge.test.js.map +0 -1
- package/dist/ws-client.typed-bridge.test.d.ts +0 -2
- package/dist/ws-client.typed-bridge.test.d.ts.map +0 -1
- package/dist/ws-client.typed-bridge.test.js +0 -105
- package/dist/ws-client.typed-bridge.test.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaskAuthorizeDispatch, type
|
|
1
|
+
import { TaskAuthorizeDispatch, type ParamsOf } from "@moltzap/protocol";
|
|
2
2
|
import { type PartitionableRequest } from "../app-callback-partition-key.js";
|
|
3
3
|
export declare const SESSION_A: string & import("effect/Brand").Brand<"TaskId">;
|
|
4
4
|
export declare const SESSION_B: string & import("effect/Brand").Brand<"TaskId">;
|
|
@@ -17,6 +17,6 @@ export declare const conversationIdForIndex: (index: number) => string & import(
|
|
|
17
17
|
* envelope, the params layout — because werewolf's dispatch state
|
|
18
18
|
* machine consumes it unchanged.
|
|
19
19
|
*/
|
|
20
|
-
export declare function authorizeDispatchParams(taskId?: string & import("effect/Brand").Brand<"TaskId">, conv?: string & import("effect/Brand").Brand<"ConversationId">):
|
|
20
|
+
export declare function authorizeDispatchParams(taskId?: string & import("effect/Brand").Brand<"TaskId">, conv?: string & import("effect/Brand").Brand<"ConversationId">): ParamsOf<typeof TaskAuthorizeDispatch>;
|
|
21
21
|
export declare function authorizeDispatch(id: string, taskId?: string & import("effect/Brand").Brand<"TaskId">, conv?: string & import("effect/Brand").Brand<"ConversationId">): PartitionableRequest;
|
|
22
22
|
//# sourceMappingURL=app-callback-test-requests.d.ts.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"app-callback-test-requests.d.ts","sourceRoot":"","sources":["../../../src/internal/__tests__/app-callback-test-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAErB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,eAAO,MAAM,SAAS,iDAAqD,CAAC;AAC5E,eAAO,MAAM,SAAS,iDAAqD,CAAC;AAC5E,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;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,kDAAY,EAClB,IAAI,0DAAS,GACZ,QAAQ,CAAC,OAAO,qBAAqB,CAAC,CAaxC;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,MAAM,kDAAY,EAClB,IAAI,0DAAS,GACZ,oBAAoB,CAQtB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TaskAuthorizeDispatch, } from "@moltzap/protocol";
|
|
2
|
+
import { agentId, conversationId, messageId, taskId as makeTaskId, } from "@moltzap/protocol/testing";
|
|
2
3
|
import {} from "../app-callback-partition-key.js";
|
|
3
4
|
export const SESSION_A = makeTaskId("11111111-1111-4111-8111-111111111111");
|
|
4
5
|
export const SESSION_B = makeTaskId("22222222-2222-4222-8222-222222222222");
|
|
@@ -35,7 +36,7 @@ export function authorizeDispatchParams(taskId = SESSION_A, conv = CONV_X) {
|
|
|
35
36
|
export function authorizeDispatch(id, taskId = SESSION_A, conv = CONV_X) {
|
|
36
37
|
const params = authorizeDispatchParams(taskId, conv);
|
|
37
38
|
return {
|
|
38
|
-
id:
|
|
39
|
+
id: id,
|
|
39
40
|
definition: TaskAuthorizeDispatch,
|
|
40
41
|
params,
|
|
41
42
|
partition: { taskId, conversationId: conv },
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"app-callback-test-requests.js","sourceRoot":"","sources":["../../../src/internal/__tests__/app-callback-test-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAGtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,OAAO,EACP,cAAc,EACd,SAAS,EACT,MAAM,IAAI,UAAU,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAA6B,MAAM,kCAAkC,CAAC;AAE7E,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,sCAAsC,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,sCAAsC,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC,sCAAsC,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC,sCAAsC,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC,sCAAsC,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,sCAAsC,CAAC,CAAC;AAC3E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,EAAE,CACtD,cAAc,CACZ,2BAA2B,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAC/E,CAAC;AAEJ;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAM,GAAG,SAAS,EAClB,IAAI,GAAG,MAAM;IAEb,OAAO;QACL,MAAM;QACN,KAAK,EAAE,UAAU;QACjB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;QACnD,OAAO,EAAE;YACP,EAAE,EAAE,SAAS;YACb,aAAa,EAAE,OAAO;YACtB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACzC;QACD,OAAO,EAAE,CAAC;KACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,EAAU,EACV,MAAM,GAAG,SAAS,EAClB,IAAI,GAAG,MAAM;IAEb,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrD,OAAO;QACL,EAAE,EAAE,EAAe;QACnB,UAAU,EAAE,qBAAqB;QACjC,MAAM;QACN,SAAS,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonRpcId } from "@moltzap/protocol";
|
|
2
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 & {
|
|
3
3
|
readonly _tag: "PartitionLimitError";
|
|
4
4
|
} & Readonly<A>;
|
|
@@ -16,7 +16,7 @@ export declare class PartitionLimitError extends PartitionLimitError_base<{
|
|
|
16
16
|
readonly key: string;
|
|
17
17
|
readonly activePartitions: number;
|
|
18
18
|
readonly maxPartitions: number;
|
|
19
|
-
readonly requestId:
|
|
19
|
+
readonly requestId: JsonRpcId;
|
|
20
20
|
}> {
|
|
21
21
|
}
|
|
22
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 & {
|
|
@@ -35,7 +35,7 @@ declare const PartitionQueueFullError_base: new <A extends Record<string, any> =
|
|
|
35
35
|
export declare class PartitionQueueFullError extends PartitionQueueFullError_base<{
|
|
36
36
|
readonly key: string;
|
|
37
37
|
readonly capacity: number;
|
|
38
|
-
readonly requestId:
|
|
38
|
+
readonly requestId: JsonRpcId;
|
|
39
39
|
}> {
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
@@ -1 +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,
|
|
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,SAAS,EAAE,MAAM,mBAAmB,CAAC;;;;AAEnD;;;;;;;;;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,SAAS,CAAC;CAC/B,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,SAAS,CAAC;CAC/B,CAAC;CAAG;AAEL;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,uBAAuB,CAAC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* rejected before a request can enter the dispatcher.
|
|
13
13
|
*/
|
|
14
14
|
import { Brand } from "effect";
|
|
15
|
-
import { type AnyTaskCallbackRpcDefinition, type DecodedRpcRequest, type
|
|
15
|
+
import { type AnyTaskCallbackRpcDefinition, type DecodedRpcRequest, type JsonRpcId } from "@moltzap/protocol";
|
|
16
16
|
/**
|
|
17
17
|
* Branded partition-key string. Constructed only by `extractPartitionKey`.
|
|
18
18
|
* Format is opaque to consumers; equality is value equality.
|
|
@@ -36,7 +36,7 @@ export interface AppCallbackPartitionRoute {
|
|
|
36
36
|
* app-callback descriptor and validated params against that descriptor.
|
|
37
37
|
*/
|
|
38
38
|
export type PartitionableRequest = DecodedRpcRequest<AnyTaskCallbackRpcDefinition> & {
|
|
39
|
-
readonly id:
|
|
39
|
+
readonly id: JsonRpcId;
|
|
40
40
|
readonly partition: AppCallbackPartitionRoute;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
@@ -1 +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,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,
|
|
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,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,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;AAwBL,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC9B,iBAAiB,CAAC,4BAA4B,CAAC,GAAG;IAChD,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;CAC/C,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,YAAY,CAId;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,GAAG;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,4BAA4B,CAAC;CACnD,CA6BA"}
|
package/dist/runtime/errors.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare const MalformedFrameError_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 & {
|
|
3
|
-
readonly _tag: "MalformedFrameError";
|
|
4
|
-
} & Readonly<A>;
|
|
5
|
-
/** Inbound frame failed to parse as JSON or did not match the expected shape. */
|
|
6
|
-
export declare class MalformedFrameError extends MalformedFrameError_base<{
|
|
7
|
-
readonly raw: string;
|
|
8
|
-
readonly cause?: unknown;
|
|
9
|
-
}> {
|
|
10
|
-
}
|
|
1
|
+
export { MalformedFrameError } from "@moltzap/protocol";
|
|
11
2
|
declare const AgentNotFoundError_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 & {
|
|
12
3
|
readonly _tag: "AgentNotFoundError";
|
|
13
4
|
} & Readonly<A>;
|
|
@@ -26,9 +17,8 @@ declare const DuplicateServerRpcHandlerError_base: new <A extends Record<string,
|
|
|
26
17
|
* forces the duplicate registration to surface at the call site.
|
|
27
18
|
*/
|
|
28
19
|
export declare class DuplicateServerRpcHandlerError extends DuplicateServerRpcHandlerError_base<{
|
|
29
|
-
readonly method:
|
|
20
|
+
readonly method: string;
|
|
30
21
|
}> {
|
|
31
22
|
get message(): string;
|
|
32
23
|
}
|
|
33
|
-
export {};
|
|
34
24
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;;;;AAExD,+CAA+C;AAC/C,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED;;;;GAIG;AACH,qBAAa,8BAA+B,SAAQ,oCAElD;IACA,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF"}
|
package/dist/runtime/errors.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
// `MalformedFrameError` is now protocol-side (`@moltzap/protocol`); both
|
|
3
|
+
// client and server share the same class. Re-exported here for the
|
|
4
|
+
// existing client-package import surface.
|
|
5
|
+
export { MalformedFrameError } from "@moltzap/protocol";
|
|
5
6
|
/** A name→agent lookup returned no results. */
|
|
6
7
|
export class AgentNotFoundError extends Data.TaggedError("AgentNotFoundError") {
|
|
7
8
|
get message() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,yEAAyE;AACzE,mEAAmE;AACnE,0CAA0C;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,+CAA+C;AAC/C,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAE3E;IACA,IAAa,OAAO;QAClB,OAAO,oBAAoB,IAAI,CAAC,SAAS,EAAE,CAAC;IAC9C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,8BAA+B,SAAQ,IAAI,CAAC,WAAW,CAClE,gCAAgC,CAGhC;IACA,IAAa,OAAO;QAClB,OAAO,qDAAqD,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5E,CAAC;CACF"}
|
package/dist/runtime/frame.d.ts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import { MalformedFrameError } from "./errors.js";
|
|
2
|
+
import { MalformedFrameError, type AnyTaskCallbackRpcDefinition, type AnyNotificationDefinition, type DecodedNotification, type DecodedResponseSuccess, type DecodedResponseError, type JsonRpcId, type ParamsOf } from "@moltzap/protocol";
|
|
4
3
|
import { type AppCallbackPartitionRoute } from "../internal/app-callback-partition-key.js";
|
|
5
|
-
export type { DecodedNotification
|
|
6
|
-
/** Decoded response frame —
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly id: JsonRpcStringId;
|
|
10
|
-
readonly result?: unknown;
|
|
11
|
-
readonly error?: Extract<ResponseFrame, {
|
|
12
|
-
error: unknown;
|
|
13
|
-
}>["error"];
|
|
14
|
-
}
|
|
4
|
+
export type { DecodedNotification };
|
|
5
|
+
/** Decoded response frame — XOR success | error, mirrors the protocol-level
|
|
6
|
+
* discriminated arms. */
|
|
7
|
+
export type DecodedResponse = DecodedResponseSuccess | DecodedResponseError;
|
|
15
8
|
/**
|
|
16
9
|
* Decoded server-initiated (taskCallback) request frame. The client
|
|
17
10
|
* routes these to its per-method handler registry; the server is the
|
|
18
11
|
* originator and awaits a matching JSON-RPC response with the same id.
|
|
19
12
|
*
|
|
20
|
-
*
|
|
21
|
-
* group retired (3 deletions + the rename of `apps/onBeforeDispatch` →
|
|
22
|
-
* `task/authorizeDispatch`). The dispatch shape and routing remain
|
|
23
|
-
* unchanged; only the group name moved.
|
|
13
|
+
* Carries the partition route alongside the protocol-level decoded request.
|
|
24
14
|
*/
|
|
25
|
-
export type DecodedServerRequest<D extends AnyTaskCallbackRpcDefinition = AnyTaskCallbackRpcDefinition> =
|
|
15
|
+
export type DecodedServerRequest<D extends AnyTaskCallbackRpcDefinition = AnyTaskCallbackRpcDefinition> = {
|
|
26
16
|
readonly _tag: "ServerRequest";
|
|
17
|
+
readonly id: JsonRpcId;
|
|
18
|
+
readonly definition: D;
|
|
19
|
+
readonly params: ParamsOf<D>;
|
|
27
20
|
readonly partition: AppCallbackPartitionRoute;
|
|
28
21
|
};
|
|
29
|
-
export type DecodedFrame = DecodedResponse |
|
|
22
|
+
export type DecodedFrame = DecodedResponse | DecodedNotification<AnyNotificationDefinition> | DecodedServerRequest;
|
|
30
23
|
export declare const splitRawFrames: (raw: string) => Effect.Effect<ReadonlyArray<string>, MalformedFrameError>;
|
|
31
24
|
/**
|
|
32
25
|
* Central typed inbound frame decoder. JSON.parse + shape validation via the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/runtime/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAEL,
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/runtime/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAEL,mBAAmB,EAEnB,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EAEzB,KAAK,SAAS,EACd,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAE3F,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC;yBACyB;AACzB,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,CAC9B,CAAC,SAAS,4BAA4B,GAAG,4BAA4B,IACnE;IACF,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,eAAe,GACf,mBAAmB,CAAC,yBAAyB,CAAC,GAC9C,oBAAoB,CAAC;AA8CzB,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAsEvD,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,mBAAmB,CA2B7D,CAAC"}
|
package/dist/runtime/frame.js
CHANGED
|
@@ -1,60 +1,28 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import { MalformedFrameError } from "./errors.js";
|
|
2
|
+
import { decodeServerInbound, MalformedFrameError, TaskAuthorizeDispatch, } from "@moltzap/protocol";
|
|
4
3
|
import {} from "../internal/app-callback-partition-key.js";
|
|
5
4
|
const isFramePadding = (char) => char === "\u0000" || char === "\ufeff" || /\s/u.test(char);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return Effect.succeed(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return decodeRpcRequest(taskCallbackRpcGroup, parsed).pipe(Effect.mapError((cause) => new MalformedFrameError({ raw, cause })), Effect.flatMap((request) => appCallbackPartitionRoute(request).pipe(Effect.map((partition) => ({
|
|
21
|
-
_tag: "ServerRequest",
|
|
22
|
-
...request,
|
|
23
|
-
partition,
|
|
24
|
-
})))));
|
|
25
|
-
}
|
|
26
|
-
if (validators.notificationFrame(parsed)) {
|
|
27
|
-
return toDecodedNotification(parsed);
|
|
28
|
-
}
|
|
29
|
-
return Effect.fail(new MalformedFrameError({ raw }));
|
|
30
|
-
};
|
|
31
|
-
const toDecodedNotification = (parsed) => {
|
|
32
|
-
// Opacity contract (`delivery/payload-opacity-client`,
|
|
33
|
-
// `boundary/schema-exhaustive-fuzz-client`): no payload validation
|
|
34
|
-
// here. `_tag` and `definition` attach non-enumerably so the
|
|
35
|
-
// decoded value still satisfies `validators.notificationFrame`'s
|
|
36
|
-
// strict `additionalProperties: false`. Unknown methods (no
|
|
37
|
-
// descriptor) emit `UnknownDecodedNotification`; production typed
|
|
38
|
-
// handlers exclude that branch via the `definition` discriminator.
|
|
39
|
-
const definition = notificationGroup.byName.get(parsed.method);
|
|
40
|
-
Object.defineProperty(parsed, "_tag", {
|
|
41
|
-
value: "Notification",
|
|
42
|
-
enumerable: false,
|
|
43
|
-
});
|
|
44
|
-
if (definition !== undefined) {
|
|
45
|
-
Object.defineProperty(parsed, "definition", {
|
|
46
|
-
value: definition,
|
|
47
|
-
enumerable: false,
|
|
48
|
-
});
|
|
49
|
-
return Effect.succeed(parsed);
|
|
50
|
-
}
|
|
51
|
-
return Effect.succeed(parsed);
|
|
5
|
+
const liftServerInbound = (decoded, raw) => {
|
|
6
|
+
if (decoded._tag === "ResponseSuccess")
|
|
7
|
+
return Effect.succeed(decoded);
|
|
8
|
+
if (decoded._tag === "ResponseError")
|
|
9
|
+
return Effect.succeed(decoded);
|
|
10
|
+
if (decoded._tag === "Notification")
|
|
11
|
+
return Effect.succeed(decoded);
|
|
12
|
+
return appCallbackPartitionRoute(decoded.definition, decoded.params).pipe(Effect.map((partition) => ({
|
|
13
|
+
_tag: "ServerRequest",
|
|
14
|
+
id: decoded.id,
|
|
15
|
+
definition: decoded.definition,
|
|
16
|
+
params: decoded.params,
|
|
17
|
+
partition,
|
|
18
|
+
})), Effect.mapError((cause) => new MalformedFrameError({ raw, cause })));
|
|
52
19
|
};
|
|
53
|
-
const appCallbackPartitionRoute = (
|
|
54
|
-
if (
|
|
20
|
+
const appCallbackPartitionRoute = (definition, params) => {
|
|
21
|
+
if (definition === TaskAuthorizeDispatch &&
|
|
22
|
+
TaskAuthorizeDispatch.validateParams(params)) {
|
|
55
23
|
return Effect.succeed({
|
|
56
|
-
taskId:
|
|
57
|
-
conversationId:
|
|
24
|
+
taskId: params.taskId,
|
|
25
|
+
conversationId: params.conversationId,
|
|
58
26
|
});
|
|
59
27
|
}
|
|
60
28
|
return Effect.fail(new MalformedFrameError({
|
|
@@ -139,7 +107,9 @@ export const decodeFrames = (raw) => Effect.gen(function* () {
|
|
|
139
107
|
catch (err) {
|
|
140
108
|
return yield* Effect.fail(new MalformedFrameError({ raw: frameText, cause: err }));
|
|
141
109
|
}
|
|
142
|
-
const decoded = yield*
|
|
110
|
+
const decoded = yield* decodeServerInbound(parsed).pipe(Effect.flatMap((d) => liftServerInbound(d, frameText)), Effect.mapError((cause) => cause instanceof MalformedFrameError
|
|
111
|
+
? cause
|
|
112
|
+
: new MalformedFrameError({ raw: frameText, cause })));
|
|
143
113
|
decodedFrames.push(decoded);
|
|
144
114
|
}
|
|
145
115
|
return decodedFrames;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/runtime/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/runtime/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GAStB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAkC,MAAM,2CAA2C,CAAC;AA8B3F,MAAM,cAAc,GAAG,CAAC,IAAY,EAAW,EAAE,CAC/C,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE7D,MAAM,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AI,mBAAmB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CACxD,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,IAAI,CACrD,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EACtD,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,KAAK,YAAY,mBAAmB;YAClC,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,mBAAmB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACvD,CACF,CAAC;QACF,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
1
|
+
import { Effect, Exit } from "effect";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { MessageReceivedNotificationDefinition
|
|
3
|
+
import { MessageReceivedNotificationDefinition } from "@moltzap/protocol";
|
|
4
|
+
import { agentId, conversationId, messageId } from "@moltzap/protocol/testing";
|
|
4
5
|
import { decodeFrames } from "./frame.js";
|
|
6
|
+
import { MalformedFrameError } from "./errors.js";
|
|
5
7
|
const TEST_MESSAGE = {
|
|
6
8
|
id: messageId("11111111-1111-4111-8111-111111111111"),
|
|
7
9
|
conversationId: conversationId("22222222-2222-4222-8222-222222222222"),
|
|
@@ -11,7 +13,7 @@ const TEST_MESSAGE = {
|
|
|
11
13
|
};
|
|
12
14
|
describe("decodeFrames", () => {
|
|
13
15
|
it("decodes padded chunks that contain both a notification and a response", async () => {
|
|
14
|
-
const raw = JSON.stringify(
|
|
16
|
+
const raw = JSON.stringify(MessageReceivedNotificationDefinition.encode({
|
|
15
17
|
message: TEST_MESSAGE,
|
|
16
18
|
})) +
|
|
17
19
|
"\u0000\n" +
|
|
@@ -28,19 +30,17 @@ describe("decodeFrames", () => {
|
|
|
28
30
|
params: { message: TEST_MESSAGE },
|
|
29
31
|
});
|
|
30
32
|
expect(decoded[1]).toMatchObject({
|
|
31
|
-
_tag: "
|
|
33
|
+
_tag: "ResponseSuccess",
|
|
32
34
|
id: "rpc-7",
|
|
33
35
|
result: { ok: true },
|
|
34
36
|
});
|
|
35
37
|
});
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
// `{taskId, conversations, closedBy: {agentId, ownerId}}`.
|
|
43
|
-
it("attaches definition for known methods so subscribers can reject stale `task/closed` payload", async () => {
|
|
38
|
+
// S9 fail-close: stale shapes are rejected at the wire boundary.
|
|
39
|
+
// Pre-Phase-7 `task/closed` carrying `sessionId` instead of
|
|
40
|
+
// `{taskId, conversations, closedBy: {agentId, ownerId}}` decodes to
|
|
41
|
+
// `MalformedFrameError`; subscribers no longer need to defend
|
|
42
|
+
// against drift downstream because the decoder fails closed.
|
|
43
|
+
it("fail-closes stale `task/closed` payload at the wire boundary", async () => {
|
|
44
44
|
const stale = JSON.stringify({
|
|
45
45
|
jsonrpc: "2.0",
|
|
46
46
|
method: "task/closed",
|
|
@@ -49,28 +49,22 @@ describe("decodeFrames", () => {
|
|
|
49
49
|
closedBy: "33333333-3333-4333-8333-333333333333",
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
|
-
const
|
|
53
|
-
expect(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
conversations: { main: "22222222-2222-4222-8222-222222222222" },
|
|
69
|
-
closedBy: {
|
|
70
|
-
agentId: "33333333-3333-4333-8333-333333333333",
|
|
71
|
-
ownerId: "owner-1",
|
|
72
|
-
},
|
|
73
|
-
})).toBe(true);
|
|
52
|
+
const exit = await Effect.runPromiseExit(decodeFrames(stale));
|
|
53
|
+
expect(Exit.isFailure(exit)).toBe(true);
|
|
54
|
+
if (Exit.isFailure(exit)) {
|
|
55
|
+
const error = exit.cause._tag === "Fail" ? exit.cause.error : null;
|
|
56
|
+
expect(error).toBeInstanceOf(MalformedFrameError);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
// S9 also rejects unknown notification methods at the wire boundary.
|
|
60
|
+
it("fail-closes unknown notification method", async () => {
|
|
61
|
+
const stranger = JSON.stringify({
|
|
62
|
+
jsonrpc: "2.0",
|
|
63
|
+
method: "some/unregistered-method",
|
|
64
|
+
params: {},
|
|
65
|
+
});
|
|
66
|
+
const exit = await Effect.runPromiseExit(decodeFrames(stranger));
|
|
67
|
+
expect(Exit.isFailure(exit)).toBe(true);
|
|
74
68
|
});
|
|
75
69
|
});
|
|
76
70
|
//# sourceMappingURL=frame.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.test.js","sourceRoot":"","sources":["../../src/runtime/frame.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"frame.test.js","sourceRoot":"","sources":["../../src/runtime/frame.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qCAAqC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,YAAY,E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AAC,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* `register`, `dispatch`, and `closeAll` are `Effect<T, never>`.
|
|
31
31
|
*/
|
|
32
32
|
import { Brand, Effect } from "effect";
|
|
33
|
-
import type {
|
|
33
|
+
import type { AnyNotificationDefinition, DecodedNotification } from "@moltzap/protocol";
|
|
34
34
|
interface FilterableNotificationFrame {
|
|
35
35
|
readonly method: string;
|
|
36
36
|
readonly params?: unknown;
|
|
@@ -82,13 +82,10 @@ export interface NotificationSubscription {
|
|
|
82
82
|
* dispatch fiber. Must not throw — throws are caught by the registry,
|
|
83
83
|
* logged via the injected logger, and swallowed.
|
|
84
84
|
*
|
|
85
|
-
* The frame
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* `params` is genuinely opaque here — handlers that need a typed
|
|
90
|
-
* payload must validate themselves (`frame.definition?.validateParams`)
|
|
91
|
-
* or live behind the typed-handler bridge in `service.handleNotification`.
|
|
85
|
+
* The frame is a known-descriptor `DecodedNotification` (post-S9
|
|
86
|
+
* fail-close: malformed / unknown-method frames are rejected before
|
|
87
|
+
* dispatch). Handlers receive validated `params` typed as
|
|
88
|
+
* `NotificationParamsOf<D>` for the matching definition.
|
|
92
89
|
*
|
|
93
90
|
* Returning an `Effect` (not a plain `void`) lets handlers compose with
|
|
94
91
|
* Effect-native downstream code without an extra runSync shim. The
|
|
@@ -97,7 +94,7 @@ export interface NotificationSubscription {
|
|
|
97
94
|
* handler on subscription A does not reorder frames seen by
|
|
98
95
|
* subscription B across frames.
|
|
99
96
|
*/
|
|
100
|
-
export type SubscriberHandler = (frame:
|
|
97
|
+
export type SubscriberHandler = (frame: DecodedNotification<AnyNotificationDefinition>) => Effect.Effect<void, never>;
|
|
101
98
|
/**
|
|
102
99
|
* Subscriber registry. One instance per `MoltZapWsClient`, created at
|
|
103
100
|
* construction time and owned by the client. Not exported from the
|
|
@@ -120,7 +117,7 @@ export interface SubscriberRegistry {
|
|
|
120
117
|
* live-subscription list at the start of dispatch so
|
|
121
118
|
* unsubscribe-during-dispatch observes next-frame semantics (OQ-3 A).
|
|
122
119
|
*
|
|
123
|
-
* Frames are pre-validation (`
|
|
120
|
+
* Frames are pre-validation (`DecodedNotification<AnyNotificationDefinition>` union) — the
|
|
124
121
|
* type-system contract that subscribers see RAW frames, not the lifted
|
|
125
122
|
* `DecodedNotification<D>` shape that typed handlers see.
|
|
126
123
|
*
|
|
@@ -128,7 +125,7 @@ export interface SubscriberRegistry {
|
|
|
128
125
|
* handlers block later subscriptions for this frame but never
|
|
129
126
|
* reorder frame N relative to frame N+1.
|
|
130
127
|
*/
|
|
131
|
-
readonly dispatch: (frame:
|
|
128
|
+
readonly dispatch: (frame: DecodedNotification<AnyNotificationDefinition>) => Effect.Effect<void, never>;
|
|
132
129
|
/**
|
|
133
130
|
* Drop every live subscription. Called from `MoltZapWsClient.close`
|
|
134
131
|
* so handlers stop firing once the client is torn down. Idempotent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribers.d.ts","sourceRoot":"","sources":["../../src/runtime/subscribers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"subscribers.d.ts","sourceRoot":"","sources":["../../src/runtime/subscribers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,UAAU,2BAA2B;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,Q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CAAC;CAC/C;AAcD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CAC1D,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CAAC,CA8C3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAmBT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribers.js","sourceRoot":"","sources":["../../src/runtime/subscribers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"subscribers.js","sourceRoot":"","sources":["../../src/runtime/subscribers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAa5C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,EAAkB,CAAC;AAmH9D,SAAS,0BAA0B,CACjC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAEtC;IACC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAkC,EAAE,CAAC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C,CAAC;IACD,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,gBAAgB,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,MAAM,CAAC,cAAc;YAAE,OAAO,KAAK,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { describe, expect, it, vi } from "vitest";
|
|
18
18
|
import { Effect, Ref } from "effect";
|
|
19
|
-
import {
|
|
19
|
+
import { ConversationArchivedNotificationDefinition, } from "@moltzap/protocol";
|
|
20
|
+
import { agentId, conversationId, taskId, TaskFailedNotificationDefinition, } from "@moltzap/protocol/testing";
|
|
20
21
|
import { makeSubscriberRegistry, matchesFilter } from "./subscribers.js";
|
|
21
22
|
const TASK_ID = taskId("11111111-1111-4111-8111-111111111111");
|
|
22
23
|
const CONV_1 = conversationId("22222222-2222-4222-8222-222222222222");
|
|
@@ -27,25 +28,18 @@ const filterableNotification = (method, params) => ({
|
|
|
27
28
|
params,
|
|
28
29
|
});
|
|
29
30
|
const decodedNotification = (definition, params) => {
|
|
30
|
-
// Construct a
|
|
31
|
+
// Construct a DecodedNotification<D> directly from the typed
|
|
31
32
|
// descriptor + params — bypassing the wire decoder is intentional
|
|
32
33
|
// for test fixtures so the result type stays narrow to D rather than
|
|
33
|
-
// collapsing to the group's union.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const decoded = {
|
|
39
|
-
...frame,
|
|
34
|
+
// collapsing to the group's union.
|
|
35
|
+
const frame = definition.encode(params);
|
|
36
|
+
return {
|
|
37
|
+
_tag: "Notification",
|
|
38
|
+
jsonrpc: frame.jsonrpc,
|
|
40
39
|
definition,
|
|
41
40
|
method: definition.name,
|
|
42
41
|
params,
|
|
43
42
|
};
|
|
44
|
-
Object.defineProperty(decoded, "_tag", {
|
|
45
|
-
value: "Notification",
|
|
46
|
-
enumerable: false,
|
|
47
|
-
});
|
|
48
|
-
return decoded;
|
|
49
43
|
};
|
|
50
44
|
const taskFailedNotification = () => decodedNotification(TaskFailedNotificationDefinition, {
|
|
51
45
|
taskId: TASK_ID,
|