@moltzap/client 2026.511.1 → 2026.518.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/auth.d.ts +12 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +67 -29
- package/dist/auth.js.map +1 -1
- package/dist/auth.test.js +113 -76
- package/dist/auth.test.js.map +1 -1
- package/dist/channel-core-context.test.d.ts +2 -0
- package/dist/channel-core-context.test.d.ts.map +1 -0
- package/dist/channel-core-context.test.js +334 -0
- package/dist/channel-core-context.test.js.map +1 -0
- package/dist/channel-core-dispatch.test.d.ts +2 -0
- package/dist/channel-core-dispatch.test.d.ts.map +1 -0
- package/dist/channel-core-dispatch.test.js +550 -0
- package/dist/channel-core-dispatch.test.js.map +1 -0
- package/dist/channel-core-enrichment.d.ts +8 -0
- package/dist/channel-core-enrichment.d.ts.map +1 -0
- package/dist/channel-core-enrichment.js +134 -0
- package/dist/channel-core-enrichment.js.map +1 -0
- package/dist/channel-core-errors.d.ts +20 -0
- package/dist/channel-core-errors.d.ts.map +1 -0
- package/dist/channel-core-errors.js +12 -0
- package/dist/channel-core-errors.js.map +1 -0
- package/dist/channel-core-test-support.d.ts +48 -0
- package/dist/channel-core-test-support.d.ts.map +1 -0
- package/dist/channel-core-test-support.js +111 -0
- package/dist/channel-core-test-support.js.map +1 -0
- package/dist/channel-core.d.ts +30 -7
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +214 -237
- package/dist/channel-core.js.map +1 -1
- package/dist/channel-core.test.js +216 -1082
- package/dist/channel-core.test.js.map +1 -1
- package/dist/cli/__tests__/cli-multi-agent.int.test.js +129 -23
- package/dist/cli/__tests__/cli-multi-agent.int.test.js.map +1 -1
- package/dist/cli/commands/conversations-v2.test.js +64 -54
- package/dist/cli/commands/conversations-v2.test.js.map +1 -1
- package/dist/cli/commands/conversations.d.ts +5 -5
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +43 -36
- package/dist/cli/commands/conversations.js.map +1 -1
- package/dist/cli/commands/messages.d.ts +4 -4
- package/dist/cli/commands/messages.d.ts.map +1 -1
- package/dist/cli/commands/messages.js +4 -4
- package/dist/cli/commands/messages.js.map +1 -1
- package/dist/cli/commands/messages.test.js +61 -49
- package/dist/cli/commands/messages.test.js.map +1 -1
- package/dist/cli/commands/ping.d.ts +0 -9
- package/dist/cli/commands/ping.d.ts.map +1 -1
- package/dist/cli/commands/ping.js +1 -1
- package/dist/cli/commands/ping.js.map +1 -1
- package/dist/cli/commands/presence.d.ts +1 -1
- package/dist/cli/commands/presence.js +1 -1
- package/dist/cli/commands/register.d.ts +2 -2
- package/dist/cli/commands/register.d.ts.map +1 -1
- package/dist/cli/commands/register.js +98 -77
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/register.test.js +63 -39
- package/dist/cli/commands/register.test.js.map +1 -1
- package/dist/cli/commands/send.d.ts +6 -6
- package/dist/cli/commands/send.js +6 -6
- package/dist/cli/commands/send.test.js +32 -28
- package/dist/cli/commands/send.test.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +3 -4
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config.d.ts +0 -2
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +86 -76
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/config.test.js +80 -42
- package/dist/cli/config.test.js.map +1 -1
- package/dist/cli/index.d.ts +1 -16
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +50 -113
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/process-argv.d.ts +2 -0
- package/dist/cli/process-argv.d.ts.map +1 -0
- package/dist/cli/process-argv.js +2 -0
- package/dist/cli/process-argv.js.map +1 -0
- package/dist/cli/profile.d.ts +3 -10
- package/dist/cli/profile.d.ts.map +1 -1
- package/dist/cli/profile.js +105 -104
- package/dist/cli/profile.js.map +1 -1
- package/dist/cli/profile.test.js +338 -232
- package/dist/cli/profile.test.js.map +1 -1
- package/dist/cli/runtime.d.ts +5 -17
- package/dist/cli/runtime.d.ts.map +1 -1
- package/dist/cli/runtime.js +6 -59
- package/dist/cli/runtime.js.map +1 -1
- package/dist/cli/socket-client.d.ts +10 -15
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +74 -89
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts +9 -5
- package/dist/cli/transport.d.ts.map +1 -1
- package/dist/cli/transport.js +45 -42
- package/dist/cli/transport.js.map +1 -1
- package/dist/cli/transport.test.js +227 -133
- package/dist/cli/transport.test.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/local-daemon-rpc.d.ts +13 -0
- package/dist/local-daemon-rpc.d.ts.map +1 -0
- package/dist/local-daemon-rpc.js +17 -0
- package/dist/local-daemon-rpc.js.map +1 -0
- package/dist/local-paths.d.ts +7 -0
- package/dist/local-paths.d.ts.map +1 -0
- package/dist/local-paths.js +20 -0
- package/dist/local-paths.js.map +1 -0
- package/dist/runtime/close-info.d.ts +3 -12
- package/dist/runtime/close-info.d.ts.map +1 -1
- package/dist/runtime/close-info.js +28 -39
- package/dist/runtime/close-info.js.map +1 -1
- package/dist/runtime/close-info.test.js +77 -70
- package/dist/runtime/close-info.test.js.map +1 -1
- package/dist/runtime/errors.test.js +42 -28
- package/dist/runtime/errors.test.js.map +1 -1
- package/dist/runtime/frame.d.ts +4 -31
- package/dist/runtime/frame.d.ts.map +1 -1
- package/dist/runtime/frame.js +7 -116
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/frame.test.js +41 -54
- package/dist/runtime/frame.test.js.map +1 -1
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +7 -11
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/local-history.d.ts +67 -0
- package/dist/runtime/local-history.d.ts.map +1 -0
- package/dist/runtime/local-history.js +77 -0
- package/dist/runtime/local-history.js.map +1 -0
- package/dist/runtime/local-service-commands.d.ts +19 -0
- package/dist/runtime/local-service-commands.d.ts.map +1 -1
- package/dist/runtime/local-service-commands.js +23 -0
- package/dist/runtime/local-service-commands.js.map +1 -1
- package/dist/runtime/local-socket-server.d.ts +20 -0
- package/dist/runtime/local-socket-server.d.ts.map +1 -0
- package/dist/runtime/local-socket-server.js +94 -0
- package/dist/runtime/local-socket-server.js.map +1 -0
- package/dist/runtime/refs.d.ts +1 -1
- package/dist/runtime/refs.js +1 -1
- package/dist/runtime/runtime.test.js +29 -21
- package/dist/runtime/runtime.test.js.map +1 -1
- package/dist/runtime/service-helpers.d.ts +32 -0
- package/dist/runtime/service-helpers.d.ts.map +1 -0
- package/dist/runtime/service-helpers.js +85 -0
- package/dist/runtime/service-helpers.js.map +1 -0
- package/dist/runtime/subscribers.d.ts +13 -17
- package/dist/runtime/subscribers.d.ts.map +1 -1
- package/dist/runtime/subscribers.js +37 -32
- package/dist/runtime/subscribers.js.map +1 -1
- package/dist/runtime/subscribers.test.js +139 -131
- package/dist/runtime/subscribers.test.js.map +1 -1
- package/dist/service-socket-path.test.d.ts +2 -0
- package/dist/service-socket-path.test.d.ts.map +1 -0
- package/dist/service-socket-path.test.js +87 -0
- package/dist/service-socket-path.test.js.map +1 -0
- package/dist/service.d.ts +23 -20
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +192 -340
- package/dist/service.js.map +1 -1
- package/dist/service.test.js +652 -653
- package/dist/service.test.js.map +1 -1
- package/dist/test/index.d.ts +30 -14
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +25 -21
- package/dist/test/index.js.map +1 -1
- package/dist/test-utils/channel-service-fixture.d.ts +1 -0
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js +139 -98
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/conformance-adapter.d.ts.map +1 -1
- package/dist/test-utils/conformance-adapter.js +145 -124
- package/dist/test-utils/conformance-adapter.js.map +1 -1
- package/dist/test-utils/fake-service.d.ts.map +1 -1
- package/dist/test-utils/fake-service.js +3 -3
- package/dist/test-utils/fake-service.js.map +1 -1
- package/dist/test-utils/index.d.ts +25 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +25 -8
- package/dist/test-utils/index.js.map +1 -1
- package/dist/ws-client-test-support.d.ts +180 -0
- package/dist/ws-client-test-support.d.ts.map +1 -0
- package/dist/ws-client-test-support.js +399 -0
- package/dist/ws-client-test-support.js.map +1 -0
- package/dist/ws-client.d.ts +59 -32
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +272 -321
- package/dist/ws-client.js.map +1 -1
- package/dist/ws-client.test.js +388 -800
- package/dist/ws-client.test.js.map +1 -1
- package/package.json +14 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.test.js","sourceRoot":"","sources":["../../src/runtime/errors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.test.js","sourceRoot":"","sources":["../../src/runtime/errors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAA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AC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/runtime/frame.d.ts
CHANGED
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { MalformedFrameError, type
|
|
3
|
-
export type { DecodedNotification };
|
|
4
|
-
/** Decoded response frame — XOR success | error, mirrors the protocol-level
|
|
5
|
-
* discriminated arms. */
|
|
6
|
-
export type DecodedResponse = DecodedResponseSuccess | DecodedResponseError;
|
|
2
|
+
import { MalformedFrameError, type DecodedServerInbound } from "@moltzap/protocol";
|
|
7
3
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* originator and awaits a matching JSON-RPC response with the same id.
|
|
11
|
-
*
|
|
12
|
-
* The `D extends AnyTaskCallbackRpcDefinition ? ... : never` distribution
|
|
13
|
-
* is load-bearing: when the union widens (e.g. a future task-callback
|
|
14
|
-
* descriptor lands alongside `DispatchAuthorize`), the per-arm pairing
|
|
15
|
-
* of `{definition, params}` must stay distinct so downstream consumers
|
|
16
|
-
* see a discriminated union, not a merged
|
|
17
|
-
* `{Definition, params: ParamsA | ParamsB}` shape that conflates
|
|
18
|
-
* incompatible param schemas.
|
|
4
|
+
* Decode one WebSocket message. WebSocket message boundaries are the frame
|
|
5
|
+
* boundary here; JSON-RPC shape validation stays in `@moltzap/protocol`.
|
|
19
6
|
*/
|
|
20
|
-
export
|
|
21
|
-
readonly _tag: "ServerRequest";
|
|
22
|
-
readonly id: JsonRpcId;
|
|
23
|
-
readonly definition: D;
|
|
24
|
-
readonly params: ParamsOf<D>;
|
|
25
|
-
} : never;
|
|
26
|
-
export type DecodedFrame = DecodedResponse | DecodedNotification<AnyNotificationDefinition> | DecodedServerRequest;
|
|
27
|
-
export declare const splitRawFrames: (raw: string) => Effect.Effect<ReadonlyArray<string>, MalformedFrameError>;
|
|
28
|
-
/**
|
|
29
|
-
* Central typed inbound frame decoder. JSON.parse + shape validation via the
|
|
30
|
-
* protocol's pre-compiled AJV validators. The raw socket chunk may contain
|
|
31
|
-
* padding bytes or more than one JSON object; split and validate each object
|
|
32
|
-
* before handing frames to the client runtime.
|
|
33
|
-
*/
|
|
34
|
-
export declare const decodeFrames: (raw: string) => Effect.Effect<ReadonlyArray<DecodedFrame>, MalformedFrameError>;
|
|
7
|
+
export declare const decodeFrames: (raw: string) => Effect.Effect<ReadonlyArray<DecodedServerInbound>, MalformedFrameError>;
|
|
35
8
|
//# sourceMappingURL=frame.d.ts.map
|
|
@@ -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,
|
|
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,EACnB,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAQ3B;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,mBAAmB,CAKtE,CAAC"}
|
package/dist/runtime/frame.js
CHANGED
|
@@ -1,121 +1,12 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { decodeServerInbound,
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return Effect.succeed(decoded);
|
|
7
|
-
if (decoded._tag === "ResponseError")
|
|
8
|
-
return Effect.succeed(decoded);
|
|
9
|
-
if (decoded._tag === "Notification")
|
|
10
|
-
return Effect.succeed(decoded);
|
|
11
|
-
return liftAppCallbackRequest(decoded, raw);
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Per-descriptor lift of an app-callback request to a typed
|
|
15
|
-
* `DecodedServerRequest`. Each branch is guarded by the descriptor's
|
|
16
|
-
* `validateParams` predicate so `decoded.definition` + `decoded.params`
|
|
17
|
-
* narrow together, preserving the per-arm pairing required by the
|
|
18
|
-
* distributive `DecodedServerRequest<D>` type. Adding a new
|
|
19
|
-
* task-callback descriptor adds one branch here.
|
|
20
|
-
*/
|
|
21
|
-
const liftAppCallbackRequest = (decoded, raw) => {
|
|
22
|
-
if (decoded.definition === DispatchAuthorize &&
|
|
23
|
-
DispatchAuthorize.validateParams(decoded.params)) {
|
|
24
|
-
return Effect.succeed({
|
|
25
|
-
_tag: "ServerRequest",
|
|
26
|
-
id: decoded.id,
|
|
27
|
-
definition: DispatchAuthorize,
|
|
28
|
-
params: decoded.params,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return Effect.fail(new MalformedFrameError({
|
|
32
|
-
raw,
|
|
33
|
-
cause: "unroutable task-callback request descriptor",
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
36
|
-
export const splitRawFrames = (raw) => Effect.try({
|
|
37
|
-
try: () => {
|
|
38
|
-
const frames = [];
|
|
39
|
-
let start = -1;
|
|
40
|
-
let depth = 0;
|
|
41
|
-
let inString = false;
|
|
42
|
-
let escaped = false;
|
|
43
|
-
for (let index = 0; index < raw.length; index += 1) {
|
|
44
|
-
const char = raw[index];
|
|
45
|
-
if (start === -1) {
|
|
46
|
-
if (isFramePadding(char)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (char !== "{") {
|
|
50
|
-
throw new MalformedFrameError({ raw });
|
|
51
|
-
}
|
|
52
|
-
start = index;
|
|
53
|
-
depth = 1;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (inString) {
|
|
57
|
-
if (escaped) {
|
|
58
|
-
escaped = false;
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if (char === "\\") {
|
|
62
|
-
escaped = true;
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (char === '"') {
|
|
66
|
-
inString = false;
|
|
67
|
-
}
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (char === '"') {
|
|
71
|
-
inString = true;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (char === "{") {
|
|
75
|
-
depth += 1;
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (char !== "}") {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
depth -= 1;
|
|
82
|
-
if (depth !== 0) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
frames.push(raw.slice(start, index + 1));
|
|
86
|
-
start = -1;
|
|
87
|
-
}
|
|
88
|
-
if (start !== -1 || frames.length === 0) {
|
|
89
|
-
throw new MalformedFrameError({ raw });
|
|
90
|
-
}
|
|
91
|
-
return frames;
|
|
92
|
-
},
|
|
93
|
-
catch: (cause) => cause instanceof MalformedFrameError
|
|
94
|
-
? cause
|
|
95
|
-
: new MalformedFrameError({ raw, cause }),
|
|
2
|
+
import { decodeServerInbound, MalformedFrameError, } from "@moltzap/protocol";
|
|
3
|
+
const parseFrame = (raw) => Effect.try({
|
|
4
|
+
try: () => JSON.parse(raw),
|
|
5
|
+
catch: (cause) => new MalformedFrameError({ raw, cause }),
|
|
96
6
|
});
|
|
97
7
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* padding bytes or more than one JSON object; split and validate each object
|
|
101
|
-
* before handing frames to the client runtime.
|
|
8
|
+
* Decode one WebSocket message. WebSocket message boundaries are the frame
|
|
9
|
+
* boundary here; JSON-RPC shape validation stays in `@moltzap/protocol`.
|
|
102
10
|
*/
|
|
103
|
-
export const decodeFrames = (raw) => Effect.
|
|
104
|
-
const frameTexts = yield* splitRawFrames(raw);
|
|
105
|
-
const decodedFrames = [];
|
|
106
|
-
for (const frameText of frameTexts) {
|
|
107
|
-
let parsed;
|
|
108
|
-
try {
|
|
109
|
-
parsed = JSON.parse(frameText);
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
return yield* Effect.fail(new MalformedFrameError({ raw: frameText, cause: err }));
|
|
113
|
-
}
|
|
114
|
-
const decoded = yield* decodeServerInbound(parsed).pipe(Effect.flatMap((d) => liftServerInbound(d, frameText)), Effect.mapError((cause) => cause instanceof MalformedFrameError
|
|
115
|
-
? cause
|
|
116
|
-
: new MalformedFrameError({ raw: frameText, cause })));
|
|
117
|
-
decodedFrames.push(decoded);
|
|
118
|
-
}
|
|
119
|
-
return decodedFrames;
|
|
120
|
-
});
|
|
11
|
+
export const decodeFrames = (raw) => parseFrame(raw).pipe(Effect.flatMap(decodeServerInbound), Effect.map((decoded) => [decoded]), Effect.withSpan("decodeFrames"));
|
|
121
12
|
//# sourceMappingURL=frame.js.map
|
|
@@ -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,mBAAmB,EACnB,
|
|
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,GAEpB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,UAAU,GAAG,CAAC,GAAW,EAA+C,EAAE,CAC9E,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY;IACrC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEL;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAW,EAC8D,EAAE,CAC3E,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAClB,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EACnC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAClC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAChC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Exit } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
3
|
import { MessageReceivedNotificationDefinition } from "@moltzap/protocol";
|
|
4
4
|
import { agentId, conversationId, messageId } from "@moltzap/protocol/testing";
|
|
5
5
|
import { decodeFrames } from "./frame.js";
|
|
@@ -11,60 +11,47 @@ const TEST_MESSAGE = {
|
|
|
11
11
|
parts: [{ type: "text", text: "hello" }],
|
|
12
12
|
createdAt: "2026-05-03T00:00:00.000Z",
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
const decoded = await Effect.runPromise(decodeFrames(raw));
|
|
26
|
-
expect(decoded).toHaveLength(2);
|
|
27
|
-
expect(decoded[0]).toMatchObject({
|
|
28
|
-
_tag: "Notification",
|
|
29
|
-
method: MessageReceivedNotificationDefinition.name,
|
|
30
|
-
params: { message: TEST_MESSAGE },
|
|
31
|
-
});
|
|
32
|
-
expect(decoded[1]).toMatchObject({
|
|
33
|
-
_tag: "ResponseSuccess",
|
|
34
|
-
id: "rpc-7",
|
|
35
|
-
result: { ok: true },
|
|
36
|
-
});
|
|
14
|
+
it("decodes one WebSocket notification message", () => Effect.runPromise(Effect.gen(function* () {
|
|
15
|
+
const raw = JSON.stringify(MessageReceivedNotificationDefinition.encode({
|
|
16
|
+
message: TEST_MESSAGE,
|
|
17
|
+
}));
|
|
18
|
+
const decoded = yield* decodeFrames(raw);
|
|
19
|
+
expect(decoded).toHaveLength(1);
|
|
20
|
+
expect(decoded[0]).toMatchObject({
|
|
21
|
+
_tag: "Notification",
|
|
22
|
+
method: MessageReceivedNotificationDefinition.name,
|
|
23
|
+
params: { message: TEST_MESSAGE },
|
|
37
24
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
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
|
-
}
|
|
25
|
+
})));
|
|
26
|
+
// S9 fail-close: stale shapes are rejected at the wire boundary.
|
|
27
|
+
// Pre-Phase-7 `task/closed` carrying `sessionId` instead of
|
|
28
|
+
// `{taskId, conversations, closedBy: {agentId, ownerId}}` decodes to
|
|
29
|
+
// `MalformedFrameError`; subscribers no longer need to defend
|
|
30
|
+
// against drift downstream because the decoder fails closed.
|
|
31
|
+
it("fail-closes stale `task/closed` payload at the wire boundary", () => Effect.runPromise(Effect.gen(function* () {
|
|
32
|
+
const stale = JSON.stringify({
|
|
33
|
+
jsonrpc: "2.0",
|
|
34
|
+
method: "task/closed",
|
|
35
|
+
params: {
|
|
36
|
+
sessionId: "11111111-1111-4111-8111-111111111111",
|
|
37
|
+
closedBy: "33333333-3333-4333-8333-333333333333",
|
|
38
|
+
},
|
|
58
39
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
const exit = yield* Effect.exit(decodeFrames(stale));
|
|
41
|
+
expect(Exit.isFailure(exit)).toBe(true);
|
|
42
|
+
if (Exit.isFailure(exit)) {
|
|
43
|
+
const error = exit.cause._tag === "Fail" ? exit.cause.error : null;
|
|
44
|
+
expect(error).toBeInstanceOf(MalformedFrameError);
|
|
45
|
+
}
|
|
46
|
+
})));
|
|
47
|
+
// S9 also rejects unknown notification methods at the wire boundary.
|
|
48
|
+
it("fail-closes unknown notification method", () => Effect.runPromise(Effect.gen(function* () {
|
|
49
|
+
const stranger = JSON.stringify({
|
|
50
|
+
jsonrpc: "2.0",
|
|
51
|
+
method: "some/unregistered-method",
|
|
52
|
+
params: {},
|
|
68
53
|
});
|
|
69
|
-
|
|
54
|
+
const exit = yield* Effect.exit(decodeFrames(stranger));
|
|
55
|
+
expect(Exit.isFailure(exit)).toBe(true);
|
|
56
|
+
})));
|
|
70
57
|
//# 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,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,
|
|
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,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,qCAAqC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE,SAAS,CAAC,sCAAsC,CAAC;I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,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACnE,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;IACpD,CAAC;AACH,CAAC,CAAC,CACH,CAAC,CAAC;AAEL,qEAAqE;AACrE,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE,CACjD,MAAM,CAAC,UAAU,CACf,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,EAAE;KACX,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC,CAAC,CACH,CAAC,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Local-service IPC primitives and runtime helpers for the client CLI.
|
|
3
|
+
*
|
|
4
|
+
* The public surface is intentionally narrow: command definitions for the
|
|
5
|
+
* local daemon socket and the subscription filter type consumed by status and
|
|
6
|
+
* conformance adapters.
|
|
7
|
+
*/
|
|
1
8
|
export { LocalServiceCommands } from "./local-service-commands.js";
|
|
2
9
|
export type { LocalServiceCommand } from "./local-service-commands.js";
|
|
3
10
|
export type { SubscriptionFilter } from "./subscribers.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// local daemon.
|
|
9
|
-
// - SubscriptionFilter — the structural filter type used by callers
|
|
10
|
-
// building cross-conversation subscriptions (the cli's status command
|
|
11
|
-
// and the conformance adapter both consume it as a type-only import).
|
|
1
|
+
/**
|
|
2
|
+
* @file Local-service IPC primitives and runtime helpers for the client CLI.
|
|
3
|
+
*
|
|
4
|
+
* The public surface is intentionally narrow: command definitions for the
|
|
5
|
+
* local daemon socket and the subscription filter type consumed by status and
|
|
6
|
+
* conformance adapters.
|
|
7
|
+
*/
|
|
12
8
|
export { LocalServiceCommands } from "./local-service-commands.js";
|
|
13
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Message } from "@moltzap/protocol";
|
|
2
|
+
import { Effect, HashMap, ParseResult, Schema } from "effect";
|
|
3
|
+
declare const HistoryRequestSchema: Schema.Struct<{
|
|
4
|
+
conversationId: Schema.filter<typeof Schema.String>;
|
|
5
|
+
limit: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
6
|
+
default: () => number;
|
|
7
|
+
}>;
|
|
8
|
+
sessionKey: Schema.optional<typeof Schema.String>;
|
|
9
|
+
}>;
|
|
10
|
+
declare const HistoryMessageSummarySchema: Schema.Struct<{
|
|
11
|
+
id: typeof Schema.String;
|
|
12
|
+
senderId: typeof Schema.String;
|
|
13
|
+
senderName: typeof Schema.String;
|
|
14
|
+
isOwn: typeof Schema.Boolean;
|
|
15
|
+
text: typeof Schema.String;
|
|
16
|
+
createdAt: typeof Schema.String;
|
|
17
|
+
isNew: typeof Schema.Boolean;
|
|
18
|
+
}>;
|
|
19
|
+
declare const HistoryResponseSchema: Schema.Struct<{
|
|
20
|
+
messages: Schema.Array$<Schema.Struct<{
|
|
21
|
+
id: typeof Schema.String;
|
|
22
|
+
senderId: typeof Schema.String;
|
|
23
|
+
senderName: typeof Schema.String;
|
|
24
|
+
isOwn: typeof Schema.Boolean;
|
|
25
|
+
text: typeof Schema.String;
|
|
26
|
+
createdAt: typeof Schema.String;
|
|
27
|
+
isNew: typeof Schema.Boolean;
|
|
28
|
+
}>>;
|
|
29
|
+
hasMore: typeof Schema.Boolean;
|
|
30
|
+
conversationMeta: Schema.optional<Schema.Struct<{
|
|
31
|
+
id: typeof Schema.String;
|
|
32
|
+
type: Schema.Literal<["dm", "group"]>;
|
|
33
|
+
name: Schema.optional<typeof Schema.String>;
|
|
34
|
+
createdBy: typeof Schema.String;
|
|
35
|
+
metadata: Schema.optional<Schema.Struct<{
|
|
36
|
+
tags: Schema.optional<Schema.Array$<Schema.Record$<typeof Schema.String, typeof Schema.String>>>;
|
|
37
|
+
}>>;
|
|
38
|
+
lastMessageTimestamp: Schema.optional<typeof Schema.String>;
|
|
39
|
+
createdAt: typeof Schema.String;
|
|
40
|
+
updatedAt: typeof Schema.String;
|
|
41
|
+
}>>;
|
|
42
|
+
newCount: Schema.filter<Schema.filter<typeof Schema.Number>>;
|
|
43
|
+
}>;
|
|
44
|
+
export type HistoryRequestInput = Schema.Schema.Encoded<typeof HistoryRequestSchema>;
|
|
45
|
+
export type HistoryRequest = Schema.Schema.Type<typeof HistoryRequestSchema>;
|
|
46
|
+
export type HistoryMessageSummary = Schema.Schema.Type<typeof HistoryMessageSummarySchema>;
|
|
47
|
+
export type HistoryResponse = Schema.Schema.Type<typeof HistoryResponseSchema>;
|
|
48
|
+
interface FormatHistoryMessageOptions {
|
|
49
|
+
readonly agentNames: HashMap.HashMap<string, string>;
|
|
50
|
+
readonly ownAgentId: string | undefined;
|
|
51
|
+
readonly lastReadIds: ReadonlySet<string>;
|
|
52
|
+
readonly hasSessionKey: boolean;
|
|
53
|
+
}
|
|
54
|
+
declare const HistoryRequestInputError_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 & {
|
|
55
|
+
readonly _tag: "HistoryRequestInputError";
|
|
56
|
+
} & Readonly<A>;
|
|
57
|
+
export declare class HistoryRequestInputError extends HistoryRequestInputError_base<{
|
|
58
|
+
readonly message: string;
|
|
59
|
+
readonly cause: unknown;
|
|
60
|
+
}> {
|
|
61
|
+
}
|
|
62
|
+
export declare const decodeHistoryResponse: (value: unknown) => Effect.Effect<HistoryResponse, ParseResult.ParseError>;
|
|
63
|
+
export declare function decodeHistoryRequest(params: unknown): Effect.Effect<HistoryRequest, HistoryRequestInputError>;
|
|
64
|
+
export declare function formatHistoryMessage(message: Message, options: FormatHistoryMessageOptions): HistoryMessageSummary;
|
|
65
|
+
export declare function lastReadIdsForSession(lastReadMap: HashMap.HashMap<string, HashMap.HashMap<string, ReadonlySet<string>>>, request: HistoryRequest): ReadonlySet<string>;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=local-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-history.d.ts","sourceRoot":"","sources":["../../src/runtime/local-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAQ,MAAM,EAAE,OAAO,EAAU,WAAW,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAW5E,QAAA,MAAM,oBAAoB;;;;;;EAMxB,CAAC;AAEH,QAAA,MAAM,2BAA2B;;;;;;;;EAQ/B,CAAC;AAwBH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAKzB,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CACrD,OAAO,oBAAoB,CAC5B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAC7E,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACpD,OAAO,2BAA2B,CACnC,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE/E,UAAU,2BAA2B;IACnC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;;;;AAED,qBAAa,wBAAyB,SAAQ,8BAE5C;IACA,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;CAAG;AAUL,eAAO,MAAM,qBAAqB,GAChC,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,WAAW,CAAC,UAAU,CACJ,CAAC;AAErD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,GACd,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,wBAAwB,CAAC,CASzD;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,2BAA2B,GACnC,qBAAqB,CAevB;AAED,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,OAAO,CAAC,OAAO,CAC1B,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAC7C,EACD,OAAO,EAAE,cAAc,GACtB,WAAW,CAAC,MAAM,CAAC,CAQrB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Data, Effect, HashMap, Option, ParseResult, Schema } from "effect";
|
|
2
|
+
import { renderPart } from "./service-helpers.js";
|
|
3
|
+
const DEFAULT_HISTORY_LIMIT = 10;
|
|
4
|
+
const MAX_HISTORY_LIMIT = 100;
|
|
5
|
+
const HistoryLimit = Schema.Number.pipe(Schema.int(), Schema.between(1, MAX_HISTORY_LIMIT));
|
|
6
|
+
const HistoryRequestSchema = Schema.Struct({
|
|
7
|
+
conversationId: Schema.String.pipe(Schema.minLength(1)),
|
|
8
|
+
limit: Schema.optionalWith(HistoryLimit, {
|
|
9
|
+
default: () => DEFAULT_HISTORY_LIMIT,
|
|
10
|
+
}),
|
|
11
|
+
sessionKey: Schema.optional(Schema.String),
|
|
12
|
+
});
|
|
13
|
+
const HistoryMessageSummarySchema = Schema.Struct({
|
|
14
|
+
id: Schema.String,
|
|
15
|
+
senderId: Schema.String,
|
|
16
|
+
senderName: Schema.String,
|
|
17
|
+
isOwn: Schema.Boolean,
|
|
18
|
+
text: Schema.String,
|
|
19
|
+
createdAt: Schema.String,
|
|
20
|
+
isNew: Schema.Boolean,
|
|
21
|
+
});
|
|
22
|
+
const ConversationMetadataSchema = Schema.Struct({
|
|
23
|
+
tags: Schema.optional(Schema.Array(Schema.Record({
|
|
24
|
+
key: Schema.String,
|
|
25
|
+
value: Schema.String,
|
|
26
|
+
}))),
|
|
27
|
+
});
|
|
28
|
+
const HistoryConversationMetaSchema = Schema.Struct({
|
|
29
|
+
id: Schema.String,
|
|
30
|
+
type: Schema.Literal("dm", "group"),
|
|
31
|
+
name: Schema.optional(Schema.String),
|
|
32
|
+
createdBy: Schema.String,
|
|
33
|
+
metadata: Schema.optional(ConversationMetadataSchema),
|
|
34
|
+
lastMessageTimestamp: Schema.optional(Schema.String),
|
|
35
|
+
createdAt: Schema.String,
|
|
36
|
+
updatedAt: Schema.String,
|
|
37
|
+
});
|
|
38
|
+
const HistoryResponseSchema = Schema.Struct({
|
|
39
|
+
messages: Schema.Array(HistoryMessageSummarySchema),
|
|
40
|
+
hasMore: Schema.Boolean,
|
|
41
|
+
conversationMeta: Schema.optional(HistoryConversationMetaSchema),
|
|
42
|
+
newCount: Schema.Number.pipe(Schema.int(), Schema.nonNegative()),
|
|
43
|
+
});
|
|
44
|
+
export class HistoryRequestInputError extends Data.TaggedError("HistoryRequestInputError") {
|
|
45
|
+
}
|
|
46
|
+
const formatParseError = (error) => ParseResult.TreeFormatter.formatErrorSync(error);
|
|
47
|
+
const formatParseCause = (cause) => ParseResult.isParseError(cause) ? formatParseError(cause) : String(cause);
|
|
48
|
+
const decodeHistoryRequestSync = Schema.decodeUnknownSync(HistoryRequestSchema);
|
|
49
|
+
export const decodeHistoryResponse = (value) => Schema.decodeUnknown(HistoryResponseSchema)(value);
|
|
50
|
+
export function decodeHistoryRequest(params) {
|
|
51
|
+
return Effect.try({
|
|
52
|
+
try: () => decodeHistoryRequestSync(params),
|
|
53
|
+
catch: (cause) => new HistoryRequestInputError({
|
|
54
|
+
message: `invalid history request: ${formatParseCause(cause)}`,
|
|
55
|
+
cause,
|
|
56
|
+
}),
|
|
57
|
+
}).pipe(Effect.withSpan("decodeHistoryRequest"));
|
|
58
|
+
}
|
|
59
|
+
export function formatHistoryMessage(message, options) {
|
|
60
|
+
const senderName = Option.getOrElse(HashMap.get(options.agentNames, message.senderId), () => message.senderId);
|
|
61
|
+
const isOwn = message.senderId === options.ownAgentId;
|
|
62
|
+
return {
|
|
63
|
+
id: message.id,
|
|
64
|
+
senderId: message.senderId,
|
|
65
|
+
senderName: isOwn ? "you" : senderName,
|
|
66
|
+
isOwn,
|
|
67
|
+
text: message.parts.map(renderPart).join(" "),
|
|
68
|
+
createdAt: message.createdAt,
|
|
69
|
+
isNew: options.hasSessionKey ? !options.lastReadIds.has(message.id) : false,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function lastReadIdsForSession(lastReadMap, request) {
|
|
73
|
+
if (request.sessionKey === undefined)
|
|
74
|
+
return new Set();
|
|
75
|
+
return Option.getOrElse(Option.flatMap(HashMap.get(lastReadMap, request.sessionKey), (perConv) => HashMap.get(perConv, request.conversationId)), () => new Set());
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=local-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-history.js","sourceRoot":"","sources":["../../src/runtime/local-history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACrC,MAAM,CAAC,GAAG,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MAAM,CAAC,SAAS,CACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CACvE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAC7C,EACD,GAAG,EAAE,CAAC,IAAI,GAAG,EAAiC,CAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
import { Effect, ParseResult } from "effect";
|
|
2
|
+
import { type HistoryRequestInput, type HistoryResponse } from "./local-history.js";
|
|
1
3
|
export declare const LocalServiceCommands: {
|
|
2
4
|
readonly Ping: "ping";
|
|
3
5
|
readonly Status: "status";
|
|
4
6
|
readonly History: "history";
|
|
5
7
|
};
|
|
6
8
|
export type LocalServiceCommand = (typeof LocalServiceCommands)[keyof typeof LocalServiceCommands];
|
|
9
|
+
interface LocalServicePingResult {
|
|
10
|
+
readonly ok: boolean;
|
|
11
|
+
readonly agentId?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface LocalServiceStatusResult {
|
|
14
|
+
readonly agentId?: string | undefined;
|
|
15
|
+
readonly connected: boolean;
|
|
16
|
+
readonly conversations: number;
|
|
17
|
+
}
|
|
18
|
+
export interface LocalServiceResults {
|
|
19
|
+
readonly [LocalServiceCommands.Ping]: LocalServicePingResult;
|
|
20
|
+
readonly [LocalServiceCommands.Status]: LocalServiceStatusResult;
|
|
21
|
+
readonly [LocalServiceCommands.History]: HistoryResponse;
|
|
22
|
+
}
|
|
23
|
+
export type LocalServiceParams<C extends LocalServiceCommand> = C extends typeof LocalServiceCommands.History ? HistoryRequestInput : undefined;
|
|
24
|
+
export declare function decodeLocalServiceResult<C extends LocalServiceCommand>(command: C, result: unknown): Effect.Effect<LocalServiceResults[C], ParseResult.ParseError>;
|
|
25
|
+
export {};
|
|
7
26
|
//# sourceMappingURL=local-service-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-service-commands.d.ts","sourceRoot":"","sources":["../../src/runtime/local-service-commands.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"local-service-commands.d.ts","sourceRoot":"","sources":["../../src/runtime/local-service-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAU,MAAM,QAAQ,CAAC;AACrD,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAEnE,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,UAAU,wBAAwB;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC7D,QAAQ,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,wBAAwB,CAAC;IACjE,QAAQ,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;CAC1D;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,mBAAmB,IAC1D,CAAC,SAAS,OAAO,oBAAoB,CAAC,OAAO,GACzC,mBAAmB,GACnB,SAAS,CAAC;AAgBhB,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,mBAAmB,EACpE,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,OAAO,GACd,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAkB/D"}
|
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
import { Effect, ParseResult, Schema } from "effect";
|
|
2
|
+
import { decodeHistoryResponse, } from "./local-history.js";
|
|
1
3
|
export const LocalServiceCommands = {
|
|
2
4
|
Ping: "ping",
|
|
3
5
|
Status: "status",
|
|
4
6
|
History: "history",
|
|
5
7
|
};
|
|
8
|
+
const LocalServicePingResultSchema = Schema.Struct({
|
|
9
|
+
ok: Schema.Boolean,
|
|
10
|
+
agentId: Schema.optional(Schema.String),
|
|
11
|
+
});
|
|
12
|
+
const LocalServiceStatusResultSchema = Schema.Struct({
|
|
13
|
+
agentId: Schema.optional(Schema.String),
|
|
14
|
+
connected: Schema.Boolean,
|
|
15
|
+
conversations: Schema.Number.pipe(Schema.int(), Schema.nonNegative()),
|
|
16
|
+
});
|
|
17
|
+
const decodePingResult = Schema.decodeUnknown(LocalServicePingResultSchema);
|
|
18
|
+
const decodeStatusResult = Schema.decodeUnknown(LocalServiceStatusResultSchema);
|
|
19
|
+
export function decodeLocalServiceResult(command, result) {
|
|
20
|
+
switch (command) {
|
|
21
|
+
case LocalServiceCommands.Ping:
|
|
22
|
+
return decodePingResult(result);
|
|
23
|
+
case LocalServiceCommands.Status:
|
|
24
|
+
return decodeStatusResult(result);
|
|
25
|
+
case LocalServiceCommands.History:
|
|
26
|
+
return decodeHistoryResponse(result);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
6
29
|
//# sourceMappingURL=local-service-commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-service-commands.js","sourceRoot":"","sources":["../../src/runtime/local-service-commands.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"local-service-commands.js","sourceRoot":"","sources":["../../src/runtime/local-service-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC;AA2BX,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,EAAE,EAAE,MAAM,CAAC,OAAO;IAClB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC,OAAO;IACzB,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;CACtE,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,MAAM,CAAC,aAAa,CAAC,4BAA4B,CAAC,CAAC;AAC5E,MAAM,kBAAkB,GAAG,MAAM,CAAC,aAAa,CAAC,8BAA8B,CAAC,CAAC;AAEhF,MAAM,UAAU,wBAAwB,CACtC,OAAU,EACV,MAAe;IAEf,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,oBAAoB,CAAC,IAAI;YAC5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