@moltzap/client 2026.802.0 → 2026.803.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/bounded-map.d.ts +3 -3
- package/dist/bounded-map.js +3 -3
- package/dist/channel-base/index.d.ts +3 -7
- package/dist/channel-base/index.d.ts.map +1 -1
- package/dist/channel-base/index.js +2 -6
- package/dist/channel-base/index.js.map +1 -1
- package/dist/channel-base/reply-guard.d.ts +52 -0
- package/dist/channel-base/reply-guard.d.ts.map +1 -0
- package/dist/channel-base/reply-guard.js +78 -0
- package/dist/channel-base/reply-guard.js.map +1 -0
- package/dist/channel-core-test-support.d.ts +5 -27
- package/dist/channel-core-test-support.d.ts.map +1 -1
- package/dist/channel-core-test-support.js +2 -90
- package/dist/channel-core-test-support.js.map +1 -1
- package/dist/channel-core.d.ts +130 -248
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +169 -526
- package/dist/channel-core.js.map +1 -1
- package/dist/cli/commands/start.d.ts +1 -5
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +0 -3
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/local-daemon-rpc.d.ts +12 -195
- package/dist/local-daemon-rpc.d.ts.map +1 -1
- package/dist/local-daemon-rpc.js +1 -5
- package/dist/local-daemon-rpc.js.map +1 -1
- package/dist/notification/__tests__/subscribe-signatures.types-check.d.ts +14 -14
- package/dist/notification/__tests__/subscribe-signatures.types-check.d.ts.map +1 -1
- package/dist/notification/__tests__/subscribe-signatures.types-check.js +5 -5
- package/dist/notification/__tests__/subscribe-signatures.types-check.js.map +1 -1
- package/dist/service-local-daemon.d.ts +1 -1
- package/dist/service-local-daemon.d.ts.map +1 -1
- package/dist/service-local-daemon.js +2 -4
- package/dist/service-local-daemon.js.map +1 -1
- package/dist/service.d.ts +4 -25
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +7 -44
- package/dist/service.js.map +1 -1
- package/dist/test-utils/channel-service-fixture.d.ts +1 -3
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js +2 -22
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/ids.d.ts +0 -13
- package/dist/test-utils/ids.d.ts.map +1 -1
- package/dist/test-utils/ids.js +1 -16
- package/dist/test-utils/ids.js.map +1 -1
- package/dist/test-utils/index.d.ts +1 -1
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/app-client.d.ts +0 -5
- package/dist/app-client.d.ts.map +0 -1
- package/dist/app-client.js +0 -3
- package/dist/app-client.js.map +0 -1
- package/dist/channel-base/lease-guard.d.ts +0 -31
- package/dist/channel-base/lease-guard.d.ts.map +0 -1
- package/dist/channel-base/lease-guard.js +0 -44
- package/dist/channel-base/lease-guard.js.map +0 -1
- package/dist/channel-base/lease-store.d.ts +0 -48
- package/dist/channel-base/lease-store.d.ts.map +0 -1
- package/dist/channel-base/lease-store.js +0 -77
- package/dist/channel-base/lease-store.js.map +0 -1
- package/dist/channel-base/lease.d.ts +0 -96
- package/dist/channel-base/lease.d.ts.map +0 -1
- package/dist/channel-base/lease.js +0 -106
- package/dist/channel-base/lease.js.map +0 -1
package/dist/bounded-map.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Bounded insertion-ordered map backing the client's per-key caches.
|
|
3
3
|
*
|
|
4
|
-
* The service dedup window
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The service dedup window and channel adapters' own per-host tables need the
|
|
5
|
+
* same fixed-capacity store. It sits at the package root rather than in
|
|
6
|
+
* `channel-base/` because
|
|
7
7
|
* that barrel re-exports the root modules, so owning it there would close a
|
|
8
8
|
* folder cycle; `channel-base` re-exports it for adapters instead.
|
|
9
9
|
*/
|
package/dist/bounded-map.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Bounded insertion-ordered map backing the client's per-key caches.
|
|
3
3
|
*
|
|
4
|
-
* The service dedup window
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The service dedup window and channel adapters' own per-host tables need the
|
|
5
|
+
* same fixed-capacity store. It sits at the package root rather than in
|
|
6
|
+
* `channel-base/` because
|
|
7
7
|
* that barrel re-exports the root modules, so owning it there would close a
|
|
8
8
|
* folder cycle; `channel-base` re-exports it for adapters instead.
|
|
9
9
|
*/
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/** @file Shared channel-adapter primitives for `@moltzap/client/channel-base`. */
|
|
2
2
|
/** Re-exports the public API from `../bounded-map.js`. */
|
|
3
3
|
export { BoundedMap } from "../bounded-map.js";
|
|
4
|
-
/** Re-exports the public API from `./
|
|
5
|
-
export {
|
|
6
|
-
/** Re-exports the public API from `./lease-store.js`. */
|
|
7
|
-
export { LeaseStore } from "./lease-store.js";
|
|
8
|
-
/** Re-exports the public API from `./lease-guard.js`. */
|
|
9
|
-
export { LeaseGuard } from "./lease-guard.js";
|
|
4
|
+
/** Re-exports the public API from `./reply-guard.js`. */
|
|
5
|
+
export { ReplyGuard } from "./reply-guard.js";
|
|
10
6
|
/** Re-exports the public API from `./format-cross-conv.js`. */
|
|
11
7
|
export { formatCrossConv, type CrossConvFormatter, type CrossConvMarkup, } from "./format-cross-conv.js";
|
|
12
8
|
/** Re-exports the public API from `./format-group-block.js`. */
|
|
13
9
|
export { formatGroupBlock, getGroupFields, type GroupFields, type GroupFormatter, } from "./format-group-block.js";
|
|
14
10
|
/** Re-exports the public API from `../channel-core.js`. */
|
|
15
|
-
export { MoltZapChannelCore, type ChannelCoreOptions, type ChannelService, type ContextBlocks, type
|
|
11
|
+
export { MoltZapChannelCore, type ChannelCoreOptions, type ChannelService, type ContextBlocks, type EnrichedConversationMeta, type EnrichedInboundMessage, type EnrichedSender, type InboundHandler, type InboundInterceptDecision, type InboundInterceptor, } from "../channel-core.js";
|
|
16
12
|
/** Re-exports the public API from `../service.js`. */
|
|
17
13
|
export { sanitizeForSystemReminder, type CrossConversationEntry, type CrossConvMessage, } from "../service.js";
|
|
18
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channel-base/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channel-base/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,+DAA+D;AAC/D,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC;AAEhC,gEAAgE;AAChE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AAEjC,2DAA2D;AAC3D,OAAO,EACL,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAE5B,sDAAsD;AACtD,OAAO,EACL,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC"}
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
// Channel adapters import per-key store primitives through channel-base.
|
|
3
3
|
/** Re-exports the public API from `../bounded-map.js`. */
|
|
4
4
|
export { BoundedMap } from "../bounded-map.js";
|
|
5
|
-
/** Re-exports the public API from `./
|
|
6
|
-
export {
|
|
7
|
-
/** Re-exports the public API from `./lease-store.js`. */
|
|
8
|
-
export { LeaseStore } from "./lease-store.js";
|
|
9
|
-
/** Re-exports the public API from `./lease-guard.js`. */
|
|
10
|
-
export { LeaseGuard } from "./lease-guard.js";
|
|
5
|
+
/** Re-exports the public API from `./reply-guard.js`. */
|
|
6
|
+
export { ReplyGuard } from "./reply-guard.js";
|
|
11
7
|
/** Re-exports the public API from `./format-cross-conv.js`. */
|
|
12
8
|
export { formatCrossConv, } from "./format-cross-conv.js";
|
|
13
9
|
/** Re-exports the public API from `./format-group-block.js`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channel-base/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channel-base/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,+DAA+D;AAC/D,OAAO,EACL,eAAe,GAGhB,MAAM,wBAAwB,CAAC;AAEhC,gEAAgE;AAChE,OAAO,EACL,gBAAgB,EAChB,cAAc,GAGf,MAAM,yBAAyB,CAAC;AAEjC,2DAA2D;AAC3D,OAAO,EACL,kBAAkB,GAUnB,MAAM,oBAAoB,CAAC;AAE5B,sDAAsD;AACtD,OAAO,EACL,yBAAyB,GAG1B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel-base `ReplyGuard` — per-turn single-shot duplicate-reply detection.
|
|
3
|
+
*
|
|
4
|
+
* One `ReplyGuard` instance per inbound turn (created inside the deliver
|
|
5
|
+
* wrapper). This is the only enforcement of "one final reply per inbound
|
|
6
|
+
* turn": the server accepts every well-formed send, so a runtime that
|
|
7
|
+
* delivers twice would otherwise double-post.
|
|
8
|
+
*
|
|
9
|
+
* The send a guard protects is asynchronous, so a bare consumed check is a
|
|
10
|
+
* race: two concurrent delivers can both observe "not consumed" before
|
|
11
|
+
* either send completes. `begin()` therefore claims the guard in one
|
|
12
|
+
* synchronous step BEFORE the send; `consume()` stamps after a successful
|
|
13
|
+
* send; `abort()` reopens the guard after a failed send so a retried
|
|
14
|
+
* deliver can still go through. A deliver arriving while another is
|
|
15
|
+
* mid-send is a duplicate, not a queued retry.
|
|
16
|
+
*/
|
|
17
|
+
import { Effect, Option } from "effect";
|
|
18
|
+
/** Implements reply guard. */
|
|
19
|
+
export declare class ReplyGuard {
|
|
20
|
+
private consumedAtMillis;
|
|
21
|
+
private inFlight;
|
|
22
|
+
/**
|
|
23
|
+
* Claim the guard for one send attempt. `true` exactly once per open
|
|
24
|
+
* window: `false` when the guard is already consumed OR another send is
|
|
25
|
+
* mid-flight. The claim is taken synchronously, so concurrent callers
|
|
26
|
+
* cannot both win.
|
|
27
|
+
* @returns Whether this caller owns the send attempt.
|
|
28
|
+
*/
|
|
29
|
+
begin(): Effect.Effect<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Reopen the guard after a failed send so a retried deliver can claim it
|
|
32
|
+
* again. No-op when the guard is already consumed.
|
|
33
|
+
* @returns Completion of the reopen.
|
|
34
|
+
*/
|
|
35
|
+
abort(): Effect.Effect<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns `true` on first call (transitions internal state from
|
|
38
|
+
* "not-consumed" to "consumed-at-now") and releases any in-flight claim;
|
|
39
|
+
* returns `false` on every later call. Reads `Clock.currentTimeMillis`
|
|
40
|
+
* inside the Effect on first call.
|
|
41
|
+
* @returns The ts result.
|
|
42
|
+
*/
|
|
43
|
+
consume(): Effect.Effect<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* `Option.none` before the first `consume`; `Option.some(epochMs)` after,
|
|
46
|
+
* where `epochMs` is the value Clock returned at the first-consume moment.
|
|
47
|
+
* Idempotent on second-and-later reads.
|
|
48
|
+
* @returns The consumed at result.
|
|
49
|
+
*/
|
|
50
|
+
get consumedAt(): Effect.Effect<Option.Option<number>>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=reply-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply-guard.d.ts","sourceRoot":"","sources":["../../src/channel-base/reply-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAS,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,8BAA8B;AAC9B,qBAAa,UAAU;IACrB,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;;;OAMG;IACH,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAQ9B;IAED;;;;OAIG;IACH,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAI3B;IAED;;;;;;OAMG;IACH,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAYhC;IAED;;;;;OAKG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAMrD;CACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel-base `ReplyGuard` — per-turn single-shot duplicate-reply detection.
|
|
3
|
+
*
|
|
4
|
+
* One `ReplyGuard` instance per inbound turn (created inside the deliver
|
|
5
|
+
* wrapper). This is the only enforcement of "one final reply per inbound
|
|
6
|
+
* turn": the server accepts every well-formed send, so a runtime that
|
|
7
|
+
* delivers twice would otherwise double-post.
|
|
8
|
+
*
|
|
9
|
+
* The send a guard protects is asynchronous, so a bare consumed check is a
|
|
10
|
+
* race: two concurrent delivers can both observe "not consumed" before
|
|
11
|
+
* either send completes. `begin()` therefore claims the guard in one
|
|
12
|
+
* synchronous step BEFORE the send; `consume()` stamps after a successful
|
|
13
|
+
* send; `abort()` reopens the guard after a failed send so a retried
|
|
14
|
+
* deliver can still go through. A deliver arriving while another is
|
|
15
|
+
* mid-send is a duplicate, not a queued retry.
|
|
16
|
+
*/
|
|
17
|
+
import { Clock, Effect, Option } from "effect";
|
|
18
|
+
/** Implements reply guard. */
|
|
19
|
+
export class ReplyGuard {
|
|
20
|
+
consumedAtMillis = null;
|
|
21
|
+
inFlight = false;
|
|
22
|
+
/**
|
|
23
|
+
* Claim the guard for one send attempt. `true` exactly once per open
|
|
24
|
+
* window: `false` when the guard is already consumed OR another send is
|
|
25
|
+
* mid-flight. The claim is taken synchronously, so concurrent callers
|
|
26
|
+
* cannot both win.
|
|
27
|
+
* @returns Whether this caller owns the send attempt.
|
|
28
|
+
*/
|
|
29
|
+
begin() {
|
|
30
|
+
return Effect.sync(() => {
|
|
31
|
+
if (this.consumedAtMillis !== null || this.inFlight) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
this.inFlight = true;
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reopen the guard after a failed send so a retried deliver can claim it
|
|
40
|
+
* again. No-op when the guard is already consumed.
|
|
41
|
+
* @returns Completion of the reopen.
|
|
42
|
+
*/
|
|
43
|
+
abort() {
|
|
44
|
+
return Effect.sync(() => {
|
|
45
|
+
this.inFlight = false;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns `true` on first call (transitions internal state from
|
|
50
|
+
* "not-consumed" to "consumed-at-now") and releases any in-flight claim;
|
|
51
|
+
* returns `false` on every later call. Reads `Clock.currentTimeMillis`
|
|
52
|
+
* inside the Effect on first call.
|
|
53
|
+
* @returns The ts result.
|
|
54
|
+
*/
|
|
55
|
+
consume() {
|
|
56
|
+
return Effect.gen(function* () {
|
|
57
|
+
if (this.consumedAtMillis !== null) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const ts = yield* Clock.currentTimeMillis;
|
|
61
|
+
this.consumedAtMillis = ts;
|
|
62
|
+
this.inFlight = false;
|
|
63
|
+
return true;
|
|
64
|
+
}.bind(this));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `Option.none` before the first `consume`; `Option.some(epochMs)` after,
|
|
68
|
+
* where `epochMs` is the value Clock returned at the first-consume moment.
|
|
69
|
+
* Idempotent on second-and-later reads.
|
|
70
|
+
* @returns The consumed at result.
|
|
71
|
+
*/
|
|
72
|
+
get consumedAt() {
|
|
73
|
+
return Effect.sync(() => this.consumedAtMillis === null
|
|
74
|
+
? Option.none()
|
|
75
|
+
: Option.some(this.consumedAtMillis));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=reply-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply-guard.js","sourceRoot":"","sources":["../../src/channel-base/reply-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,8BAA8B;AAC9B,MAAM,OAAO,UAAU;IACb,gBAAgB,GAAkB,IAAI,CAAC;IACvC,QAAQ,GAAG,KAAK,CAAC;IAEzB;;;;;;OAMG;IACH,KAAK;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACpD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,OAAO;QACL,OAAO,MAAM,CAAC,GAAG,CACf,QAAQ,CAAC;YACP,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;YAC1C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,IAAI,UAAU;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CACtB,IAAI,CAAC,gBAAgB,KAAK,IAAI;YAC5B,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;YACf,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CACvC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { ForbiddenError } from "@moltzap/protocol/rpc";
|
|
2
|
-
import type { LeaseId } from "@moltzap/protocol/message/dispatch";
|
|
3
1
|
import type { Message } from "@moltzap/protocol/message";
|
|
4
2
|
import type { AgentId } from "@moltzap/protocol/identity";
|
|
5
3
|
import type { ConversationId, MessageId } from "@moltzap/protocol/conversation";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { buildMessage, createFakeChannelService, flushDispatchChainEffect, testLeaseId, type FakeChannelService } from "./test-utils/index.js";
|
|
4
|
+
import { MoltZapChannelCore, type ChannelService, type EnrichedInboundMessage, type InboundInterceptDecision } from "./channel-core.js";
|
|
5
|
+
import type { CrossConversationEntry } from "./service.js";
|
|
6
|
+
import { buildMessage, createFakeChannelService, flushDispatchChainEffect, type FakeChannelService } from "./test-utils/index.js";
|
|
10
7
|
/** Re-exports the public API from `current module`. */
|
|
11
|
-
export { MoltZapChannelCore,
|
|
8
|
+
export { MoltZapChannelCore, buildMessage, createFakeChannelService, flushDispatchChainEffect, };
|
|
12
9
|
/** Re-exports the public API from `current module`. */
|
|
13
|
-
export type {
|
|
14
|
-
/** Provides the stuck message lease timeout ms runtime value. */
|
|
15
|
-
export declare const STUCK_MESSAGE_LEASE_TIMEOUT_MS = 50;
|
|
10
|
+
export type { CrossConversationEntry, EnrichedInboundMessage, FakeChannelService, InboundInterceptDecision, Message, };
|
|
16
11
|
/** Provides the effect test runtime value. */
|
|
17
12
|
export declare const effectTest: import("@effect/vitest").Vitest.Tester<import("effect/TestServices").TestServices>;
|
|
18
13
|
/** Provides the alice cached name runtime value. */
|
|
@@ -27,14 +22,6 @@ export declare const CAPTION_TEXT = "caption";
|
|
|
27
22
|
export declare const FIRST_TEXT = "first";
|
|
28
23
|
/** Provides the second text runtime value. */
|
|
29
24
|
export declare const SECOND_TEXT = "second";
|
|
30
|
-
/** Provides the time to vote text runtime value. */
|
|
31
|
-
export declare const TIME_TO_VOTE_TEXT = "Time to vote";
|
|
32
|
-
/** Provides the after marker text runtime value. */
|
|
33
|
-
export declare const AFTER_MARKER_TEXT = "after marker";
|
|
34
|
-
/** Provides the old discussion text runtime value. */
|
|
35
|
-
export declare const OLD_DISCUSSION_TEXT = "old discussion";
|
|
36
|
-
/** Provides the marker lease id runtime value. */
|
|
37
|
-
export declare const MARKER_LEASE_ID: LeaseId;
|
|
38
25
|
/** Provides the devs group name runtime value. */
|
|
39
26
|
export declare const DEVS_GROUP_NAME = "devs";
|
|
40
27
|
/** Provides the first visit text runtime value. */
|
|
@@ -47,21 +34,12 @@ export declare class TestInboundHandlerError extends TestInboundHandlerError_bas
|
|
|
47
34
|
readonly message: string;
|
|
48
35
|
}> {
|
|
49
36
|
}
|
|
50
|
-
type AdmissionRequest = DispatchAdmissionRequest;
|
|
51
|
-
/**
|
|
52
|
-
* Executes the install admission operation.
|
|
53
|
-
* @param fake Value supplied to the operation.
|
|
54
|
-
* @param decide Value supplied to the operation.
|
|
55
|
-
*/
|
|
56
|
-
export declare function installAdmission(fake: FakeChannelService, decide: (request: AdmissionRequest) => Effect.Effect<DispatchAdmissionDecision, ServiceRpcError>): void;
|
|
57
37
|
/** Provides the agent runtime value. */
|
|
58
38
|
export declare const agent: (agentLabel: string) => AgentId;
|
|
59
39
|
/** Provides the conversation runtime value. */
|
|
60
40
|
export declare const conversation: (conversationLabel: string) => ConversationId;
|
|
61
41
|
/** Provides the message runtime value. */
|
|
62
42
|
export declare const message: (messageLabel: string) => MessageId;
|
|
63
|
-
/** Re-exports the public API from `current module`. */
|
|
64
|
-
export { testLeaseId };
|
|
65
43
|
/**
|
|
66
44
|
* Provides the participant runtime value.
|
|
67
45
|
* @param agentLabel Value supplied to the operation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-core-test-support.d.ts","sourceRoot":"","sources":["../src/channel-core-test-support.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"channel-core-test-support.d.ts","sourceRoot":"","sources":["../src/channel-core-test-support.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4B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B,CAAC;AAClE,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,cACtC,CAAC;AACrB,0CAA0C;AAC1C,eAAO,MAAM,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,SAAyB,CAAC;AAC1E;;;;GAIG;AACH,eAAO,MAAM,WAAW,eAAgB,MAAM,KAAG,MACnB,CAAC;AAE/B,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,EAAE,CAAC;CAC5C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,kBAAkB,CAU7D;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CACpC,CAUA;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAKxE"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { it as effectIt } from "@effect/vitest";
|
|
2
|
-
import { ForbiddenError } from "@moltzap/protocol/rpc";
|
|
3
2
|
import { Data, Effect } from "effect";
|
|
4
3
|
import { MoltZapChannelCore, } from "./channel-core.js";
|
|
5
|
-
import { buildMessage, createFakeChannelService, flushDispatchChainEffect, testAgentId, testConversationId,
|
|
4
|
+
import { buildMessage, createFakeChannelService, flushDispatchChainEffect, testAgentId, testConversationId, testMessageId, } from "./test-utils/index.js";
|
|
6
5
|
/** Re-exports the public API from `current module`. */
|
|
7
|
-
export { MoltZapChannelCore,
|
|
8
|
-
/** Provides the stuck message lease timeout ms runtime value. */
|
|
9
|
-
export const STUCK_MESSAGE_LEASE_TIMEOUT_MS = 50;
|
|
6
|
+
export { MoltZapChannelCore, buildMessage, createFakeChannelService, flushDispatchChainEffect, };
|
|
10
7
|
/** Provides the effect test runtime value. */
|
|
11
8
|
export const effectTest = effectIt.effect;
|
|
12
9
|
/** Provides the alice cached name runtime value. */
|
|
@@ -21,14 +18,6 @@ export const CAPTION_TEXT = "caption";
|
|
|
21
18
|
export const FIRST_TEXT = "first";
|
|
22
19
|
/** Provides the second text runtime value. */
|
|
23
20
|
export const SECOND_TEXT = "second";
|
|
24
|
-
/** Provides the time to vote text runtime value. */
|
|
25
|
-
export const TIME_TO_VOTE_TEXT = "Time to vote";
|
|
26
|
-
/** Provides the after marker text runtime value. */
|
|
27
|
-
export const AFTER_MARKER_TEXT = "after marker";
|
|
28
|
-
/** Provides the old discussion text runtime value. */
|
|
29
|
-
export const OLD_DISCUSSION_TEXT = "old discussion";
|
|
30
|
-
/** Provides the marker lease id runtime value. */
|
|
31
|
-
export const MARKER_LEASE_ID = testLeaseId("lease-marker");
|
|
32
21
|
/** Provides the devs group name runtime value. */
|
|
33
22
|
export const DEVS_GROUP_NAME = "devs";
|
|
34
23
|
/** Provides the first visit text runtime value. */
|
|
@@ -36,89 +25,12 @@ export const FIRST_VISIT_TEXT = "first visit";
|
|
|
36
25
|
/** Reports test inbound handler failures. */
|
|
37
26
|
export class TestInboundHandlerError extends Data.TaggedError("TestInboundHandlerError") {
|
|
38
27
|
}
|
|
39
|
-
const FALLBACK_RECEIVED_AT = "1970-01-01T00:00:00.000Z";
|
|
40
|
-
const LEASE_MOCK_PREFIX = "lease-mock";
|
|
41
|
-
const DISPATCH_MOCK_PREFIX = "dispatch-mock";
|
|
42
|
-
const admissionRequest = (params) => {
|
|
43
|
-
const message = {
|
|
44
|
-
id: /* Safe because the surrounding invariant establishes this asserted shape. */ params.messageId,
|
|
45
|
-
conversationId:
|
|
46
|
-
/* Safe because the surrounding invariant establishes this asserted shape. */ params.conversationId,
|
|
47
|
-
senderId:
|
|
48
|
-
/* Safe because the surrounding invariant establishes this asserted shape. */ params.senderAgentId,
|
|
49
|
-
parts:
|
|
50
|
-
/* Safe because admission fixtures establish nonempty protocol message parts before this adapter runs. */ (params.parts ??
|
|
51
|
-
[]),
|
|
52
|
-
createdAt: params.receivedAt ?? FALLBACK_RECEIVED_AT,
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
message,
|
|
56
|
-
conversationId: params.conversationId,
|
|
57
|
-
senderAgentId: params.senderAgentId,
|
|
58
|
-
attempt: params.attempt ?? 0,
|
|
59
|
-
receivedAt: params.receivedAt ?? FALLBACK_RECEIVED_AT,
|
|
60
|
-
pending:
|
|
61
|
-
/* Safe because the surrounding invariant establishes this asserted shape. */ (params.pending ??
|
|
62
|
-
[]),
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
const grantVerdict = (decision) => ({
|
|
66
|
-
decision: "grant",
|
|
67
|
-
...(decision.leaseId !== undefined ? { leaseId: decision.leaseId } : {}),
|
|
68
|
-
...(decision.leaseTimeoutMs !== undefined
|
|
69
|
-
? { leaseTimeoutMs: decision.leaseTimeoutMs }
|
|
70
|
-
: {}),
|
|
71
|
-
...(decision.dispatchMessageId !== undefined
|
|
72
|
-
? { dispatchMessageId: decision.dispatchMessageId }
|
|
73
|
-
: {}),
|
|
74
|
-
});
|
|
75
|
-
const holdOrDenyVerdict = (decision) => ({
|
|
76
|
-
decision: decision._tag,
|
|
77
|
-
...(decision.reason !== undefined ? { reason: decision.reason } : {}),
|
|
78
|
-
});
|
|
79
|
-
const releaseVerdict = (decision) => {
|
|
80
|
-
if (decision._tag === "grant") {
|
|
81
|
-
return grantVerdict(decision);
|
|
82
|
-
}
|
|
83
|
-
return holdOrDenyVerdict(decision);
|
|
84
|
-
};
|
|
85
|
-
const releaseFrame = (decision, leaseId, dispatchId) => ({
|
|
86
|
-
dispatchId,
|
|
87
|
-
leaseId,
|
|
88
|
-
verdict: releaseVerdict(decision),
|
|
89
|
-
...(decision._tag === "grant" && decision.leaseTimeoutMs !== undefined
|
|
90
|
-
? { leaseTimeoutMs: decision.leaseTimeoutMs }
|
|
91
|
-
: {}),
|
|
92
|
-
});
|
|
93
|
-
const leaseIdForDecision = (decision, counter) => decision._tag === "grant" && decision.leaseId !== undefined
|
|
94
|
-
? decision.leaseId
|
|
95
|
-
: testLeaseId(LEASE_MOCK_PREFIX + "-" + counter.toString());
|
|
96
|
-
const dispatchIdForCounter = (counter) => DISPATCH_MOCK_PREFIX + "-" + counter.toString();
|
|
97
|
-
/**
|
|
98
|
-
* Executes the install admission operation.
|
|
99
|
-
* @param fake Value supplied to the operation.
|
|
100
|
-
* @param decide Value supplied to the operation.
|
|
101
|
-
*/
|
|
102
|
-
export function installAdmission(fake, decide) {
|
|
103
|
-
let counter = 0;
|
|
104
|
-
fake.service.requestDispatch = (params) => decide(admissionRequest(params)).pipe(Effect.map((decision) => {
|
|
105
|
-
counter += 1;
|
|
106
|
-
const leaseId = leaseIdForDecision(decision, counter);
|
|
107
|
-
const dispatchId = dispatchIdForCounter(counter);
|
|
108
|
-
queueMicrotask(() => {
|
|
109
|
-
fake.emit.dispatchRelease(releaseFrame(decision, leaseId, dispatchId));
|
|
110
|
-
});
|
|
111
|
-
return { leaseId, dispatchId };
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
28
|
/** Provides the agent runtime value. */
|
|
115
29
|
export const agent = testAgentId;
|
|
116
30
|
/** Provides the conversation runtime value. */
|
|
117
31
|
export const conversation = testConversationId;
|
|
118
32
|
/** Provides the message runtime value. */
|
|
119
33
|
export const message = testMessageId;
|
|
120
|
-
/** Re-exports the public API from `current module`. */
|
|
121
|
-
export { testLeaseId };
|
|
122
34
|
/**
|
|
123
35
|
* Provides the participant runtime value.
|
|
124
36
|
* @param agentLabel Value supplied to the operation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-core-test-support.js","sourceRoot":"","sources":["../src/channel-core-test-support.ts"],"names":[],"mappings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