@moltzap/client 2026.503.4 → 2026.504.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channel-core.d.ts +1 -4
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +0 -9
- package/dist/channel-core.js.map +1 -1
- package/dist/channel-core.test.js +90 -71
- package/dist/channel-core.test.js.map +1 -1
- package/dist/cli/commands/agents.js +2 -2
- package/dist/cli/commands/agents.js.map +1 -1
- package/dist/cli/commands/apps.d.ts +2 -24
- package/dist/cli/commands/apps.d.ts.map +1 -1
- package/dist/cli/commands/apps.js +22 -47
- package/dist/cli/commands/apps.js.map +1 -1
- package/dist/cli/commands/apps.test.js +59 -72
- package/dist/cli/commands/apps.test.js.map +1 -1
- package/dist/cli/commands/contacts.d.ts +1 -5
- package/dist/cli/commands/contacts.d.ts.map +1 -1
- package/dist/cli/commands/contacts.js +11 -26
- package/dist/cli/commands/contacts.js.map +1 -1
- package/dist/cli/commands/conversations-v2.test.js +30 -26
- package/dist/cli/commands/conversations-v2.test.js.map +1 -1
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +48 -33
- 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 +11 -8
- package/dist/cli/commands/messages.js.map +1 -1
- package/dist/cli/commands/messages.test.js +28 -30
- package/dist/cli/commands/messages.test.js.map +1 -1
- package/dist/cli/commands/presence.d.ts.map +1 -1
- package/dist/cli/commands/presence.js +5 -4
- package/dist/cli/commands/presence.js.map +1 -1
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +20 -11
- package/dist/cli/commands/send.js.map +1 -1
- package/dist/cli/commands/send.test.js +11 -9
- package/dist/cli/commands/send.test.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/test-transport.d.ts +10 -0
- package/dist/cli/commands/test-transport.d.ts.map +1 -0
- package/dist/cli/commands/test-transport.js +29 -0
- package/dist/cli/commands/test-transport.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +0 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/socket-client.d.ts +9 -4
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +27 -12
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts +3 -2
- package/dist/cli/transport.d.ts.map +1 -1
- package/dist/cli/transport.js +6 -6
- package/dist/cli/transport.js.map +1 -1
- package/dist/cli/transport.test.js +4 -4
- package/dist/cli/transport.test.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/__tests__/app-callback-partition-key.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partition-key.test.d.ts.map +1 -0
- package/dist/internal/__tests__/app-callback-partition-key.test.js +33 -0
- package/dist/internal/__tests__/app-callback-partition-key.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-partition-worker.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partition-worker.test.d.ts.map +1 -0
- package/dist/internal/__tests__/{s2c-partition-worker.test.js → app-callback-partition-worker.test.js} +6 -9
- package/dist/internal/__tests__/app-callback-partition-worker.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.d.ts.map +1 -0
- package/dist/internal/__tests__/{s2c-partitioned-dispatcher-real-ws.test.js → app-callback-partitioned-dispatcher-real-ws.test.js} +69 -94
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher-real-ws.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.d.ts +2 -0
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.d.ts.map +1 -0
- package/dist/internal/__tests__/{s2c-partitioned-dispatcher.test.js → app-callback-partitioned-dispatcher.test.js} +35 -69
- package/dist/internal/__tests__/app-callback-partitioned-dispatcher.test.js.map +1 -0
- package/dist/internal/__tests__/app-callback-test-requests.d.ts +58 -0
- package/dist/internal/__tests__/app-callback-test-requests.d.ts.map +1 -0
- package/dist/internal/__tests__/app-callback-test-requests.js +124 -0
- package/dist/internal/__tests__/app-callback-test-requests.js.map +1 -0
- package/dist/internal/{s2c-dispatcher-errors.d.ts → app-callback-dispatcher-errors.d.ts} +5 -21
- package/dist/internal/app-callback-dispatcher-errors.d.ts.map +1 -0
- package/dist/internal/{s2c-dispatcher-errors.js → app-callback-dispatcher-errors.js} +3 -13
- package/dist/internal/app-callback-dispatcher-errors.js.map +1 -0
- package/dist/internal/app-callback-partition-key.d.ts +68 -0
- package/dist/internal/app-callback-partition-key.d.ts.map +1 -0
- package/dist/internal/app-callback-partition-key.js +90 -0
- package/dist/internal/app-callback-partition-key.js.map +1 -0
- package/dist/internal/{s2c-partition-worker.d.ts → app-callback-partition-worker.d.ts} +5 -5
- package/dist/internal/app-callback-partition-worker.d.ts.map +1 -0
- package/dist/internal/{s2c-partition-worker.js → app-callback-partition-worker.js} +5 -5
- package/dist/internal/app-callback-partition-worker.js.map +1 -0
- package/dist/internal/{s2c-partitioned-dispatcher.d.ts → app-callback-partitioned-dispatcher.d.ts} +9 -10
- package/dist/internal/app-callback-partitioned-dispatcher.d.ts.map +1 -0
- package/dist/internal/{s2c-partitioned-dispatcher.js → app-callback-partitioned-dispatcher.js} +12 -19
- package/dist/internal/app-callback-partitioned-dispatcher.js.map +1 -0
- package/dist/runtime/errors.d.ts +2 -28
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +0 -9
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/errors.test.js +2 -2
- package/dist/runtime/errors.test.js.map +1 -1
- package/dist/runtime/frame.d.ts +17 -18
- package/dist/runtime/frame.d.ts.map +1 -1
- package/dist/runtime/frame.js +86 -31
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/frame.test.js +15 -11
- package/dist/runtime/frame.test.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/local-service-commands.d.ts +7 -0
- package/dist/runtime/local-service-commands.d.ts.map +1 -0
- package/dist/runtime/local-service-commands.js +6 -0
- package/dist/runtime/local-service-commands.js.map +1 -0
- package/dist/runtime/runtime.test.js +1 -2
- package/dist/runtime/runtime.test.js.map +1 -1
- package/dist/runtime/subscribers.d.ts +34 -29
- package/dist/runtime/subscribers.d.ts.map +1 -1
- package/dist/runtime/subscribers.js +19 -19
- package/dist/runtime/subscribers.js.map +1 -1
- package/dist/runtime/subscribers.test.js +50 -31
- package/dist/runtime/subscribers.test.js.map +1 -1
- package/dist/service.d.ts +24 -39
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +165 -161
- package/dist/service.js.map +1 -1
- package/dist/service.test.js +111 -170
- package/dist/service.test.js.map +1 -1
- package/dist/test-utils/channel-service-fixture.d.ts +1 -2
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js +28 -20
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/conformance-adapter.d.ts +2 -2
- package/dist/test-utils/conformance-adapter.d.ts.map +1 -1
- package/dist/test-utils/conformance-adapter.js +33 -26
- package/dist/test-utils/conformance-adapter.js.map +1 -1
- package/dist/test-utils/fake-service.d.ts +14 -39
- package/dist/test-utils/fake-service.d.ts.map +1 -1
- package/dist/test-utils/fake-service.js +33 -39
- package/dist/test-utils/fake-service.js.map +1 -1
- package/dist/test-utils/ids.d.ts +9 -0
- package/dist/test-utils/ids.d.ts.map +1 -0
- package/dist/test-utils/ids.js +52 -0
- package/dist/test-utils/ids.js.map +1 -0
- package/dist/test-utils/index.d.ts +10 -2
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +12 -5
- package/dist/test-utils/index.js.map +1 -1
- package/dist/ws-client.d.ts +58 -64
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +151 -133
- package/dist/ws-client.js.map +1 -1
- package/dist/ws-client.test.js +157 -167
- package/dist/ws-client.test.js.map +1 -1
- package/package.json +3 -3
- package/dist/cli/commands/permissions.d.ts +0 -70
- package/dist/cli/commands/permissions.d.ts.map +0 -1
- package/dist/cli/commands/permissions.js +0 -100
- package/dist/cli/commands/permissions.js.map +0 -1
- package/dist/cli/commands/permissions.test.d.ts +0 -2
- package/dist/cli/commands/permissions.test.d.ts.map +0 -1
- package/dist/cli/commands/permissions.test.js +0 -127
- package/dist/cli/commands/permissions.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partition-key.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partition-key.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partition-key.test.js +0 -231
- package/dist/internal/__tests__/s2c-partition-key.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partition-worker.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partition-worker.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partition-worker.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher-real-ws.test.js.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.d.ts +0 -2
- package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.d.ts.map +0 -1
- package/dist/internal/__tests__/s2c-partitioned-dispatcher.test.js.map +0 -1
- package/dist/internal/s2c-dispatcher-errors.d.ts.map +0 -1
- package/dist/internal/s2c-dispatcher-errors.js.map +0 -1
- package/dist/internal/s2c-partition-key.d.ts +0 -79
- package/dist/internal/s2c-partition-key.d.ts.map +0 -1
- package/dist/internal/s2c-partition-key.js +0 -146
- package/dist/internal/s2c-partition-key.js.map +0 -1
- package/dist/internal/s2c-partition-worker.d.ts.map +0 -1
- package/dist/internal/s2c-partition-worker.js.map +0 -1
- package/dist/internal/s2c-partitioned-dispatcher.d.ts.map +0 -1
- package/dist/internal/s2c-partitioned-dispatcher.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AppsOnBeforeDispatch, AppsOnBeforeMessageDelivery, AppsOnClose, AppsOnJoin, AppsOnSessionActive, type Static } from "@moltzap/protocol";
|
|
2
|
+
import { type PartitionableRequest } from "../app-callback-partition-key.js";
|
|
3
|
+
export declare const SESSION_A = "11111111-1111-4111-8111-111111111111";
|
|
4
|
+
export declare const SESSION_B = "22222222-2222-4222-8222-222222222222";
|
|
5
|
+
export declare const CONV_X: string & import("effect/Brand").Brand<"ConversationId">;
|
|
6
|
+
export declare const CONV_Y: string & import("effect/Brand").Brand<"ConversationId">;
|
|
7
|
+
export declare const CONV_Z: string & import("effect/Brand").Brand<"ConversationId">;
|
|
8
|
+
export declare const AGENT_A: string & import("effect/Brand").Brand<"AgentId">;
|
|
9
|
+
export declare const MESSAGE_A: string & import("effect/Brand").Brand<"MessageId">;
|
|
10
|
+
export declare const conversationIdForIndex: (index: number) => string & import("effect/Brand").Brand<"ConversationId">;
|
|
11
|
+
export declare function beforeDispatchParams(sessionId?: string, conv?: string & import("effect/Brand").Brand<"ConversationId">): Static<typeof AppsOnBeforeDispatch.paramsSchema>;
|
|
12
|
+
export declare function beforeDispatch(id: string, sessionId?: string, conv?: string & import("effect/Brand").Brand<"ConversationId">): PartitionableRequest;
|
|
13
|
+
export declare function beforeMessageDeliveryParams(sessionId?: string, conv?: string & import("effect/Brand").Brand<"ConversationId">): Static<typeof AppsOnBeforeMessageDelivery.paramsSchema>;
|
|
14
|
+
export declare function beforeMessageDelivery(id: string, sessionId?: string, conv?: string & import("effect/Brand").Brand<"ConversationId">): PartitionableRequest;
|
|
15
|
+
export declare function onJoinParams(sessionId?: string): Static<typeof AppsOnJoin.paramsSchema>;
|
|
16
|
+
export declare function onJoin(id: string, sessionId?: string): PartitionableRequest;
|
|
17
|
+
export declare function onCloseParams(sessionId?: string): Static<typeof AppsOnClose.paramsSchema>;
|
|
18
|
+
export declare function onClose(id: string, sessionId?: string): PartitionableRequest;
|
|
19
|
+
export declare function onSessionActiveParams(sessionId?: string): Static<typeof AppsOnSessionActive.paramsSchema>;
|
|
20
|
+
export declare function onSessionActive(id: string, sessionId?: string): PartitionableRequest;
|
|
21
|
+
export declare const lifecycleRequests: readonly [{
|
|
22
|
+
readonly definition: import("@moltzap/protocol").RpcDefinition<"apps/onJoin", import("@sinclair/typebox").TObject<{
|
|
23
|
+
sessionId: import("@sinclair/typebox").TString;
|
|
24
|
+
appId: import("@sinclair/typebox").TString;
|
|
25
|
+
conversations: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
26
|
+
agent: import("@sinclair/typebox").TObject<{
|
|
27
|
+
agentId: import("@sinclair/typebox").TString & {
|
|
28
|
+
static: import("@moltzap/protocol").BrandedString<"AgentId">;
|
|
29
|
+
};
|
|
30
|
+
ownerId: import("@sinclair/typebox").TString;
|
|
31
|
+
}>;
|
|
32
|
+
}>, import("@sinclair/typebox").TObject<{}>>;
|
|
33
|
+
readonly request: (id: string, sessionId?: string) => PartitionableRequest;
|
|
34
|
+
}, {
|
|
35
|
+
readonly definition: import("@moltzap/protocol").RpcDefinition<"apps/onClose", import("@sinclair/typebox").TObject<{
|
|
36
|
+
sessionId: import("@sinclair/typebox").TString;
|
|
37
|
+
appId: import("@sinclair/typebox").TString;
|
|
38
|
+
conversations: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
39
|
+
closedBy: import("@sinclair/typebox").TObject<{
|
|
40
|
+
agentId: import("@sinclair/typebox").TString & {
|
|
41
|
+
static: import("@moltzap/protocol").BrandedString<"AgentId">;
|
|
42
|
+
};
|
|
43
|
+
ownerId: import("@sinclair/typebox").TString;
|
|
44
|
+
}>;
|
|
45
|
+
}>, import("@sinclair/typebox").TObject<{}>>;
|
|
46
|
+
readonly request: (id: string, sessionId?: string) => PartitionableRequest;
|
|
47
|
+
}, {
|
|
48
|
+
readonly definition: import("@moltzap/protocol").RpcDefinition<"apps/onSessionActive", import("@sinclair/typebox").TObject<{
|
|
49
|
+
sessionId: import("@sinclair/typebox").TString;
|
|
50
|
+
appId: import("@sinclair/typebox").TString;
|
|
51
|
+
conversations: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
52
|
+
admittedAgentIds: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString & {
|
|
53
|
+
static: import("@moltzap/protocol").BrandedString<"AgentId">;
|
|
54
|
+
}>;
|
|
55
|
+
}>, import("@sinclair/typebox").TObject<{}>>;
|
|
56
|
+
readonly request: (id: string, sessionId?: string) => PartitionableRequest;
|
|
57
|
+
}];
|
|
58
|
+
//# sourceMappingURL=app-callback-test-requests.d.ts.map
|
|
@@ -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,UAAU,EACV,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,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AM;EAGd,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { agentId, AppsOnBeforeDispatch, AppsOnBeforeMessageDelivery, AppsOnClose, AppsOnJoin, 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 onJoinParams(sessionId = SESSION_A) {
|
|
54
|
+
return {
|
|
55
|
+
sessionId,
|
|
56
|
+
appId: "test-app",
|
|
57
|
+
conversations: { main: CONV_X },
|
|
58
|
+
agent: { agentId: AGENT_A, ownerId: "owner-a" },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export function onJoin(id, sessionId = SESSION_A) {
|
|
62
|
+
return {
|
|
63
|
+
id: jsonRpcStringId(id),
|
|
64
|
+
definition: AppsOnJoin,
|
|
65
|
+
params: onJoinParams(sessionId),
|
|
66
|
+
partition: {
|
|
67
|
+
sessionId,
|
|
68
|
+
conversationId: LIFECYCLE_CONVERSATION_SENTINEL,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function onCloseParams(sessionId = SESSION_A) {
|
|
73
|
+
return {
|
|
74
|
+
sessionId,
|
|
75
|
+
appId: "test-app",
|
|
76
|
+
conversations: { main: CONV_X },
|
|
77
|
+
closedBy: { agentId: AGENT_A, ownerId: "owner-a" },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function onClose(id, sessionId = SESSION_A) {
|
|
81
|
+
return {
|
|
82
|
+
id: jsonRpcStringId(id),
|
|
83
|
+
definition: AppsOnClose,
|
|
84
|
+
params: onCloseParams(sessionId),
|
|
85
|
+
partition: {
|
|
86
|
+
sessionId,
|
|
87
|
+
conversationId: LIFECYCLE_CONVERSATION_SENTINEL,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function onSessionActiveParams(sessionId = SESSION_A) {
|
|
92
|
+
return {
|
|
93
|
+
sessionId,
|
|
94
|
+
appId: "test-app",
|
|
95
|
+
conversations: { main: CONV_X },
|
|
96
|
+
admittedAgentIds: [AGENT_A],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function onSessionActive(id, sessionId = SESSION_A) {
|
|
100
|
+
return {
|
|
101
|
+
id: jsonRpcStringId(id),
|
|
102
|
+
definition: AppsOnSessionActive,
|
|
103
|
+
params: onSessionActiveParams(sessionId),
|
|
104
|
+
partition: {
|
|
105
|
+
sessionId,
|
|
106
|
+
conversationId: LIFECYCLE_CONVERSATION_SENTINEL,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export const lifecycleRequests = [
|
|
111
|
+
{
|
|
112
|
+
definition: AppsOnJoin,
|
|
113
|
+
request: (id, sessionId = SESSION_A) => onJoin(id, sessionId),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
definition: AppsOnClose,
|
|
117
|
+
request: (id, sessionId = SESSION_A) => onClose(id, sessionId),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
definition: AppsOnSessionActive,
|
|
121
|
+
request: (id, sessionId = SESSION_A) => onSessionActive(id, sessionId),
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
//# 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,UAAU,EACV,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,sCAAsC,CAAC;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,sCAAsC,CAAC;AAChE,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,MAAM,UAAU,oBAAoB,CAClC,SAAS,GAAG,SAAS,EACrB,IAAI,GAAG,MAAM;IAEb,OAAO;QACL,SAAS;QACT,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,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AC,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,UAAU;QACtB,OAAO,EAAE,CAAC,EAAU,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC;KACtE;IACD;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
|
-
|
|
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:
|
|
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:
|
|
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 =
|
|
48
|
+
export type OfferRejected = PartitionLimitError | PartitionQueueFullError;
|
|
65
49
|
export {};
|
|
66
|
-
//# sourceMappingURL=
|
|
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
|
|
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
|
|
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=
|
|
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/onJoin`, `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/onJoin`, `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;;;;;;;;;;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AAM,UAAU,oBAAoB,CAAC,GAAiB;IAKpD,oEAAoE;IACpE,qEAAqE;IACrE,gEAAgE;IAChE,kEAAkE;IAClE,kCAAkC;IAClC,MAAM,KAAK,GAAG,GAAG,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 (`
|
|
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 "./
|
|
45
|
-
import type { PartitionKey, PartitionableRequest } from "./
|
|
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
|
|
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=
|
|
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,C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IACpC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,yDAAyD;IACzD,QAAQ,CAAC,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 (`
|
|
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 "./
|
|
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(`
|
|
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(`
|
|
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=
|
|
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,C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,SAAS,EAAE,OAAO,CAAC,EAAE;iBACtB,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEL,OAAO;YACL,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,KAAK;YACL,KAAK;YACL,SAAS;YACT,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAC/B,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAC9C;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;SACM,CAAC;IAC9B,CAAC,CAAC,EACF,MAAM,CAAC,KAAK,CACb,CAAC;AACJ,CAAC"}
|
package/dist/internal/{s2c-partitioned-dispatcher.d.ts → app-callback-partitioned-dispatcher.d.ts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Partitioned
|
|
2
|
+
* Partitioned appCallback dispatcher.
|
|
3
3
|
*
|
|
4
4
|
* Spec: moltzap#356.
|
|
5
5
|
*
|
|
6
|
-
* Replaces the single `Stream.runForEach(handler)` over `
|
|
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(
|
|
41
|
-
* `runFork(Fiber.interrupt(
|
|
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 "./
|
|
61
|
-
import { type PartitionKey, type PartitionableRequest } from "./
|
|
62
|
-
import { type PartitionHandler } from "./
|
|
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>>` (`
|
|
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=
|
|
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,aAAa,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC;AAED,4EAA4E;AAC5E,eAAO,MAAM,qCAAqC,EAAE,2BAMjD,CAAC;AAEJ;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE;QACtB,QAAQ,CAAC,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