@moltzap/client 2026.802.0 → 2026.804.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 +1 -7
- package/dist/channel-base/index.d.ts.map +1 -1
- package/dist/channel-base/index.js +0 -6
- package/dist/channel-base/index.js.map +1 -1
- 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 +156 -248
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +195 -525
- 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/harness/client-runtime.d.ts +24 -0
- package/dist/harness/client-runtime.d.ts.map +1 -0
- package/dist/harness/client-runtime.js +107 -0
- package/dist/harness/client-runtime.js.map +1 -0
- package/dist/harness/index.d.ts +5 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +5 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/runtime.d.ts +149 -0
- package/dist/harness/runtime.d.ts.map +1 -0
- package/dist/harness/runtime.js +68 -0
- package/dist/harness/runtime.js.map +1 -0
- package/dist/harness-client.d.ts +43 -0
- package/dist/harness-client.d.ts.map +1 -0
- package/dist/harness-client.js +21 -0
- package/dist/harness-client.js.map +1 -0
- package/dist/harness-mcp-server.d.ts.map +1 -1
- package/dist/harness-mcp-server.js +107 -17
- package/dist/harness-mcp-server.js.map +1 -1
- package/dist/harness-mcp-subscription.d.ts +21 -0
- package/dist/harness-mcp-subscription.d.ts.map +1 -0
- package/dist/harness-mcp-subscription.js +324 -0
- package/dist/harness-mcp-subscription.js.map +1 -0
- package/dist/harness-mcp-wire.d.ts +9 -2
- package/dist/harness-mcp-wire.d.ts.map +1 -1
- package/dist/harness-mcp-wire.js +41 -10
- package/dist/harness-mcp-wire.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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/moltzapd.d.ts +2 -1
- package/dist/moltzapd.d.ts.map +1 -1
- package/dist/moltzapd.js +19 -5
- package/dist/moltzapd.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 +8 -4
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moltzap/client",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.804.0",
|
|
4
4
|
"description": "MoltZap client service — connection, conversation state, and cross-conversation context",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"types": "./dist/auth.d.ts",
|
|
34
34
|
"import": "./dist/auth.js"
|
|
35
35
|
},
|
|
36
|
+
"./harness-client": {
|
|
37
|
+
"types": "./dist/harness-client.d.ts",
|
|
38
|
+
"import": "./dist/harness-client.js"
|
|
39
|
+
},
|
|
36
40
|
"./pagination": {
|
|
37
41
|
"types": "./dist/pagination.d.ts",
|
|
38
42
|
"import": "./dist/pagination.js"
|
|
@@ -75,21 +79,21 @@
|
|
|
75
79
|
"@effect/printer-ansi": "^0.50.0",
|
|
76
80
|
"@effect/rpc": "^0.76.0",
|
|
77
81
|
"@effect/typeclass": "^0.41.0",
|
|
82
|
+
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
|
78
83
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
79
84
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
80
85
|
"effect": "^3.22.0",
|
|
81
|
-
"@moltzap/protocol": "2026.
|
|
86
|
+
"@moltzap/protocol": "2026.804.0"
|
|
82
87
|
},
|
|
83
88
|
"devDependencies": {
|
|
84
89
|
"@effect/vitest": "^0.30.0",
|
|
85
|
-
"@modelcontextprotocol/client": "2.0.0-beta.5",
|
|
86
90
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
87
91
|
"eslint": "^9",
|
|
88
92
|
"fast-check": "^3.23.1",
|
|
89
93
|
"tsx": "^4.19.0",
|
|
90
94
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
91
95
|
"vitest": "^3.2.0",
|
|
92
|
-
"@moltzap/server-core": "2026.
|
|
96
|
+
"@moltzap/server-core": "2026.804.0"
|
|
93
97
|
},
|
|
94
98
|
"scripts": {
|
|
95
99
|
"build": "nx run @moltzap/client:build",
|
package/dist/app-client.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Re-exports the public API from `@moltzap/protocol/socket`. */
|
|
2
|
-
export { MoltZapAppClient } from "@moltzap/protocol/socket";
|
|
3
|
-
/** Re-exports the public API from `@moltzap/protocol/socket`. */
|
|
4
|
-
export type { AppCallbackContext, AppClientOptions, RpcCallOptions, } from "@moltzap/protocol/socket";
|
|
5
|
-
//# sourceMappingURL=app-client.d.ts.map
|
package/dist/app-client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-client.d.ts","sourceRoot":"","sources":["../src/app-client.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,iEAAiE;AACjE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACf,MAAM,0BAA0B,CAAC"}
|
package/dist/app-client.js
DELETED
package/dist/app-client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-client.js","sourceRoot":"","sources":["../src/app-client.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel-base `LeaseGuard` — per-dispatch single-shot client-side dup-reply
|
|
3
|
-
* detection.
|
|
4
|
-
*
|
|
5
|
-
* One `LeaseGuard` instance per inbound message (created inside the deliver
|
|
6
|
-
* wrapper); `consume()` returns true exactly once, false on every subsequent
|
|
7
|
-
* call.
|
|
8
|
-
*
|
|
9
|
-
* Backed by a private `number | null` field that records
|
|
10
|
-
* `Clock.currentTimeMillis` on the first consume.
|
|
11
|
-
*/
|
|
12
|
-
import { Effect, Option } from "effect";
|
|
13
|
-
/** Implements lease guard. */
|
|
14
|
-
export declare class LeaseGuard {
|
|
15
|
-
private consumedAtMillis;
|
|
16
|
-
/**
|
|
17
|
-
* Returns `true` on first call (transitions internal state from
|
|
18
|
-
* "not-consumed" to "consumed-at-now"); returns `false` on every later
|
|
19
|
-
* call. Reads `Clock.currentTimeMillis` inside the Effect on first call.
|
|
20
|
-
* @returns The ts result.
|
|
21
|
-
*/
|
|
22
|
-
consume(): Effect.Effect<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* `Option.none` before the first `consume`; `Option.some(epochMs)` after,
|
|
25
|
-
* where `epochMs` is the value Clock returned at the first-consume moment.
|
|
26
|
-
* Idempotent on second-and-later reads.
|
|
27
|
-
* @returns The consumed at result.
|
|
28
|
-
*/
|
|
29
|
-
get consumedAt(): Effect.Effect<Option.Option<number>>;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=lease-guard.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lease-guard.d.ts","sourceRoot":"","sources":["../../src/channel-base/lease-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAS,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,8BAA8B;AAC9B,qBAAa,UAAU;IACrB,OAAO,CAAC,gBAAgB,CAAuB;IAE/C;;;;;OAKG;IACH,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAWhC;IAED;;;;;OAKG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAMrD;CACF"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel-base `LeaseGuard` — per-dispatch single-shot client-side dup-reply
|
|
3
|
-
* detection.
|
|
4
|
-
*
|
|
5
|
-
* One `LeaseGuard` instance per inbound message (created inside the deliver
|
|
6
|
-
* wrapper); `consume()` returns true exactly once, false on every subsequent
|
|
7
|
-
* call.
|
|
8
|
-
*
|
|
9
|
-
* Backed by a private `number | null` field that records
|
|
10
|
-
* `Clock.currentTimeMillis` on the first consume.
|
|
11
|
-
*/
|
|
12
|
-
import { Clock, Effect, Option } from "effect";
|
|
13
|
-
/** Implements lease guard. */
|
|
14
|
-
export class LeaseGuard {
|
|
15
|
-
consumedAtMillis = null;
|
|
16
|
-
/**
|
|
17
|
-
* Returns `true` on first call (transitions internal state from
|
|
18
|
-
* "not-consumed" to "consumed-at-now"); returns `false` on every later
|
|
19
|
-
* call. Reads `Clock.currentTimeMillis` inside the Effect on first call.
|
|
20
|
-
* @returns The ts result.
|
|
21
|
-
*/
|
|
22
|
-
consume() {
|
|
23
|
-
return Effect.gen(function* () {
|
|
24
|
-
if (this.consumedAtMillis !== null) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
const ts = yield* Clock.currentTimeMillis;
|
|
28
|
-
this.consumedAtMillis = ts;
|
|
29
|
-
return true;
|
|
30
|
-
}.bind(this));
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* `Option.none` before the first `consume`; `Option.some(epochMs)` after,
|
|
34
|
-
* where `epochMs` is the value Clock returned at the first-consume moment.
|
|
35
|
-
* Idempotent on second-and-later reads.
|
|
36
|
-
* @returns The consumed at result.
|
|
37
|
-
*/
|
|
38
|
-
get consumedAt() {
|
|
39
|
-
return Effect.sync(() => this.consumedAtMillis === null
|
|
40
|
-
? Option.none()
|
|
41
|
-
: Option.some(this.consumedAtMillis));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=lease-guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lease-guard.js","sourceRoot":"","sources":["../../src/channel-base/lease-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,8BAA8B;AAC9B,MAAM,OAAO,UAAU;IACb,gBAAgB,GAAkB,IAAI,CAAC;IAE/C;;;;;OAKG;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,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,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel-base `LeaseStore` — generic per-key payload tracker.
|
|
3
|
-
*
|
|
4
|
-
* Nanoclaw uses a string-keyed, string-valued store (keyed by JID, payload
|
|
5
|
-
* is the dispatchLeaseId string). The deliberate "keep stale entry to trigger
|
|
6
|
-
* server CONSUMED rejection on retry" semantic uses `peek` (read-only).
|
|
7
|
-
*
|
|
8
|
-
* The class wraps a private `Map`; Effect wrappers are for caller-side
|
|
9
|
-
* composition. Single-threaded by construction — one instance lives per
|
|
10
|
-
* channel runtime, accessed from the host event loop.
|
|
11
|
-
*/
|
|
12
|
-
import { Effect, Option } from "effect";
|
|
13
|
-
/** Implements lease store. */
|
|
14
|
-
export declare class LeaseStore<HostKey, T> {
|
|
15
|
-
private readonly entries;
|
|
16
|
-
/**
|
|
17
|
-
* Overwrite-on-newer-inbound. Last-write-wins.
|
|
18
|
-
* @param key Value supplied to the operation.
|
|
19
|
-
* @param payload Value supplied to the operation.
|
|
20
|
-
* @returns The existing result.
|
|
21
|
-
*/
|
|
22
|
-
remember(key: HostKey, payload: T): Effect.Effect<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Read-only lookup. Does NOT delete. Nanoclaw uses this for the
|
|
25
|
-
* stale-entry-on-retry semantic at `MoltZapChannel.sendMessage`.
|
|
26
|
-
* @param key Value supplied to the operation.
|
|
27
|
-
* @returns The existing result.
|
|
28
|
-
*/
|
|
29
|
-
peek(key: HostKey): Effect.Effect<Option.Option<T>>;
|
|
30
|
-
/**
|
|
31
|
-
* Read-and-delete. `Option.none` if absent (no throw).
|
|
32
|
-
* @param key Value supplied to the operation.
|
|
33
|
-
* @returns The existing result.
|
|
34
|
-
*/
|
|
35
|
-
consume(key: HostKey): Effect.Effect<Option.Option<T>>;
|
|
36
|
-
/**
|
|
37
|
-
* Clears one key (when provided) or the whole store.
|
|
38
|
-
* @param key Value supplied to the operation.
|
|
39
|
-
* @returns The clear result.
|
|
40
|
-
*/
|
|
41
|
-
clear(key?: HostKey): Effect.Effect<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Entry count.
|
|
44
|
-
* @returns The size result.
|
|
45
|
-
*/
|
|
46
|
-
get size(): Effect.Effect<number>;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=lease-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lease-store.d.ts","sourceRoot":"","sources":["../../src/channel-base/lease-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,8BAA8B;AAC9B,qBAAa,UAAU,CAAC,OAAO,EAAE,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAItD;IAED;;;;;OAKG;IACH,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAKlD;IAED;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CASrD;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAQxC;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAEhC;CACF"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel-base `LeaseStore` — generic per-key payload tracker.
|
|
3
|
-
*
|
|
4
|
-
* Nanoclaw uses a string-keyed, string-valued store (keyed by JID, payload
|
|
5
|
-
* is the dispatchLeaseId string). The deliberate "keep stale entry to trigger
|
|
6
|
-
* server CONSUMED rejection on retry" semantic uses `peek` (read-only).
|
|
7
|
-
*
|
|
8
|
-
* The class wraps a private `Map`; Effect wrappers are for caller-side
|
|
9
|
-
* composition. Single-threaded by construction — one instance lives per
|
|
10
|
-
* channel runtime, accessed from the host event loop.
|
|
11
|
-
*/
|
|
12
|
-
import { Effect, Option } from "effect";
|
|
13
|
-
/** Implements lease store. */
|
|
14
|
-
export class LeaseStore {
|
|
15
|
-
entries = new Map();
|
|
16
|
-
/**
|
|
17
|
-
* Overwrite-on-newer-inbound. Last-write-wins.
|
|
18
|
-
* @param key Value supplied to the operation.
|
|
19
|
-
* @param payload Value supplied to the operation.
|
|
20
|
-
* @returns The existing result.
|
|
21
|
-
*/
|
|
22
|
-
remember(key, payload) {
|
|
23
|
-
return Effect.sync(() => {
|
|
24
|
-
this.entries.set(key, payload);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Read-only lookup. Does NOT delete. Nanoclaw uses this for the
|
|
29
|
-
* stale-entry-on-retry semantic at `MoltZapChannel.sendMessage`.
|
|
30
|
-
* @param key Value supplied to the operation.
|
|
31
|
-
* @returns The existing result.
|
|
32
|
-
*/
|
|
33
|
-
peek(key) {
|
|
34
|
-
return Effect.sync(() => {
|
|
35
|
-
const existing = this.entries.get(key);
|
|
36
|
-
return existing === undefined ? Option.none() : Option.some(existing);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Read-and-delete. `Option.none` if absent (no throw).
|
|
41
|
-
* @param key Value supplied to the operation.
|
|
42
|
-
* @returns The existing result.
|
|
43
|
-
*/
|
|
44
|
-
consume(key) {
|
|
45
|
-
return Effect.sync(() => {
|
|
46
|
-
const existing = this.entries.get(key);
|
|
47
|
-
if (existing === undefined) {
|
|
48
|
-
return Option.none();
|
|
49
|
-
}
|
|
50
|
-
this.entries.delete(key);
|
|
51
|
-
return Option.some(existing);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Clears one key (when provided) or the whole store.
|
|
56
|
-
* @param key Value supplied to the operation.
|
|
57
|
-
* @returns The clear result.
|
|
58
|
-
*/
|
|
59
|
-
clear(key) {
|
|
60
|
-
return Effect.sync(() => {
|
|
61
|
-
if (key === undefined) {
|
|
62
|
-
this.entries.clear();
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.entries.delete(key);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Entry count.
|
|
71
|
-
* @returns The size result.
|
|
72
|
-
*/
|
|
73
|
-
get size() {
|
|
74
|
-
return Effect.sync(() => this.entries.size);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=lease-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lease-store.js","sourceRoot":"","sources":["../../src/channel-base/lease-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,8BAA8B;AAC9B,MAAM,OAAO,UAAU;IACJ,OAAO,GAAG,IAAI,GAAG,EAAc,CAAC;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,GAAY,EAAE,OAAU;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,GAAY;QACf,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACvC,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,GAAY;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACvC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;YACvB,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAa;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel-base lease primitives.
|
|
3
|
-
*
|
|
4
|
-
* Public surface:
|
|
5
|
-
* - `LeaseAlreadyConsumed`: canonical tagged error class. One definition site
|
|
6
|
-
* across both channels (openclaw, nanoclaw).
|
|
7
|
-
* - `projectLeaseInvalid`: predicate that narrows a `ForbiddenError` to
|
|
8
|
-
* `LeaseAlreadyConsumed` when the server's wire-error payload matches the
|
|
9
|
-
* single-use-lease shape (`data.reason === "LeaseInvalid"`).
|
|
10
|
-
* - `catchLeaseInvalid`: Effect-pipe convenience that runs the projection over
|
|
11
|
-
* a `ForbiddenError` with `Clock.currentTimeMillis` threaded into the
|
|
12
|
-
* projector as `consumedAt`.
|
|
13
|
-
*/
|
|
14
|
-
import { Effect } from "effect";
|
|
15
|
-
import { ForbiddenError } from "@moltzap/protocol/rpc";
|
|
16
|
-
declare const LeaseAlreadyConsumed_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 & {
|
|
17
|
-
readonly _tag: "LeaseAlreadyConsumed";
|
|
18
|
-
} & Readonly<A>;
|
|
19
|
-
/**
|
|
20
|
-
* The dispatch lease is already consumed (the server mapped a second
|
|
21
|
-
* `agent/message/send` on the same lease to `ForbiddenError(data.reason:
|
|
22
|
-
* "LeaseInvalid")`).
|
|
23
|
-
*
|
|
24
|
-
* Construction is **only** via `projectLeaseInvalid` (or `catchLeaseInvalid`).
|
|
25
|
-
* `cause` is the verbatim wire error so hosts can inspect the payload without
|
|
26
|
-
* re-fetching; `consumedAt` is `Clock.currentTimeMillis` at projection time;
|
|
27
|
-
* `message` is derived from `cause.message`.
|
|
28
|
-
*/
|
|
29
|
-
export declare class LeaseAlreadyConsumed extends LeaseAlreadyConsumed_base<{
|
|
30
|
-
readonly leaseId: string;
|
|
31
|
-
readonly consumedAt: number;
|
|
32
|
-
readonly cause: ForbiddenError;
|
|
33
|
-
readonly message: string;
|
|
34
|
-
}> {
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Named alias for the error channel produced by `catchLeaseInvalid` over an
|
|
38
|
-
* effect with residual error `E`. Equivalent to
|
|
39
|
-
* `LeaseAlreadyConsumed | ForbiddenError | E`, named so consumers can
|
|
40
|
-
* reference the union directly.
|
|
41
|
-
*/
|
|
42
|
-
export type LeaseInvalidProjectionError<E> = LeaseAlreadyConsumed | ForbiddenError | E;
|
|
43
|
-
/**
|
|
44
|
-
* Project an `ForbiddenError` to `LeaseAlreadyConsumed` if it matches the
|
|
45
|
-
* lease-invalid wire shape; otherwise return the original error unchanged.
|
|
46
|
-
*
|
|
47
|
-
* Predicate: `err.data.reason === "LeaseInvalid"`.
|
|
48
|
-
*
|
|
49
|
-
* The wire code (-32001 / generic Forbidden) is intentionally NOT part of
|
|
50
|
-
* the predicate because the code is too generic to discriminate on alone.
|
|
51
|
-
*
|
|
52
|
-
* `ctx.leaseId` (optional) is the lease the caller just sent. Caller-supplied
|
|
53
|
-
* because the server's `ForbiddenError.data` shape does NOT carry leaseId.
|
|
54
|
-
* Falls back to `"(unknown)"` when omitted.
|
|
55
|
-
*
|
|
56
|
-
* `ctx.consumedAt` (required) is the epoch ms to stamp on the resulting
|
|
57
|
-
* `LeaseAlreadyConsumed.consumedAt`. Required because `LeaseAlreadyConsumed`
|
|
58
|
-
* requires it and this function is synchronous (no Clock access). Callers
|
|
59
|
-
* either pass `Date.now()` directly or use `catchLeaseInvalid` which reads
|
|
60
|
-
* `Clock.currentTimeMillis` inside the Effect.
|
|
61
|
-
* @param err Value supplied to the operation.
|
|
62
|
-
* @param ctx Context for the operation.
|
|
63
|
-
* @param ctx.leaseId Value supplied to the operation.
|
|
64
|
-
* @param ctx.consumedAt Value supplied to the operation.
|
|
65
|
-
* @returns The project lease invalid result.
|
|
66
|
-
*/
|
|
67
|
-
export declare function projectLeaseInvalid(err: ForbiddenError, ctx: {
|
|
68
|
-
readonly leaseId?: string;
|
|
69
|
-
readonly consumedAt: number;
|
|
70
|
-
}): LeaseAlreadyConsumed | ForbiddenError;
|
|
71
|
-
/**
|
|
72
|
-
* Effect-pipe convenience: catches `ForbiddenError` and runs
|
|
73
|
-
* `projectLeaseInvalid` on each instance. Reads `Clock.currentTimeMillis`
|
|
74
|
-
* inside the catch and passes the result to `projectLeaseInvalid` as
|
|
75
|
-
* `consumedAt`. Matching errors are surfaced as the typed
|
|
76
|
-
* `LeaseAlreadyConsumed` on the failure channel; non-matching errors are
|
|
77
|
-
* re-raised unchanged so downstream `mapError`s see the original
|
|
78
|
-
* `ForbiddenError`.
|
|
79
|
-
*
|
|
80
|
-
* Use at every channel's outbound `core.sendReply(...)` boundary:.
|
|
81
|
-
*
|
|
82
|
-
* ```ts
|
|
83
|
-
* core.sendReply(conv, text, { dispatchLeaseId: leaseId }).pipe(
|
|
84
|
-
* catchLeaseInvalid({ leaseId }),
|
|
85
|
-
* // ... per-channel surfacing
|
|
86
|
-
* )
|
|
87
|
-
* ```
|
|
88
|
-
* @param ctx Context for the operation.
|
|
89
|
-
* @param ctx.leaseId Value supplied to the operation.
|
|
90
|
-
* @returns The catch lease invalid result.
|
|
91
|
-
*/
|
|
92
|
-
export declare function catchLeaseInvalid<A, E2, R>(ctx?: {
|
|
93
|
-
readonly leaseId?: string;
|
|
94
|
-
}): (eff: Effect.Effect<A, ForbiddenError | E2, R>) => Effect.Effect<A, LeaseInvalidProjectionError<E2>, R>;
|
|
95
|
-
export {};
|
|
96
|
-
//# sourceMappingURL=lease.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../../src/channel-base/lease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;;;;AAEvD;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,SAAQ,0BAExC;IACA,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,CAAC,CAAC,IACrC,oBAAoB,GACpB,cAAc,GACd,CAAC,CAAC;AAcN;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC9D,oBAAoB,GAAG,cAAc,CAUvC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,CACF,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,EAAE,EAAE,CAAC,CAAC,KAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,2BAA2B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAmBxD"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel-base lease primitives.
|
|
3
|
-
*
|
|
4
|
-
* Public surface:
|
|
5
|
-
* - `LeaseAlreadyConsumed`: canonical tagged error class. One definition site
|
|
6
|
-
* across both channels (openclaw, nanoclaw).
|
|
7
|
-
* - `projectLeaseInvalid`: predicate that narrows a `ForbiddenError` to
|
|
8
|
-
* `LeaseAlreadyConsumed` when the server's wire-error payload matches the
|
|
9
|
-
* single-use-lease shape (`data.reason === "LeaseInvalid"`).
|
|
10
|
-
* - `catchLeaseInvalid`: Effect-pipe convenience that runs the projection over
|
|
11
|
-
* a `ForbiddenError` with `Clock.currentTimeMillis` threaded into the
|
|
12
|
-
* projector as `consumedAt`.
|
|
13
|
-
*/
|
|
14
|
-
import { Clock, Data, Effect } from "effect";
|
|
15
|
-
import { ForbiddenError } from "@moltzap/protocol/rpc";
|
|
16
|
-
/**
|
|
17
|
-
* The dispatch lease is already consumed (the server mapped a second
|
|
18
|
-
* `agent/message/send` on the same lease to `ForbiddenError(data.reason:
|
|
19
|
-
* "LeaseInvalid")`).
|
|
20
|
-
*
|
|
21
|
-
* Construction is **only** via `projectLeaseInvalid` (or `catchLeaseInvalid`).
|
|
22
|
-
* `cause` is the verbatim wire error so hosts can inspect the payload without
|
|
23
|
-
* re-fetching; `consumedAt` is `Clock.currentTimeMillis` at projection time;
|
|
24
|
-
* `message` is derived from `cause.message`.
|
|
25
|
-
*/
|
|
26
|
-
export class LeaseAlreadyConsumed extends Data.TaggedError("LeaseAlreadyConsumed") {
|
|
27
|
-
}
|
|
28
|
-
const LEASE_ID_FALLBACK = "(unknown)";
|
|
29
|
-
function isLeaseInvalidData(data) {
|
|
30
|
-
if (typeof data !== "object" || data === null) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
const reason =
|
|
34
|
-
/* Safe because the surrounding invariant establishes this asserted shape. */
|
|
35
|
-
data.reason;
|
|
36
|
-
return reason === "LeaseInvalid";
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Project an `ForbiddenError` to `LeaseAlreadyConsumed` if it matches the
|
|
40
|
-
* lease-invalid wire shape; otherwise return the original error unchanged.
|
|
41
|
-
*
|
|
42
|
-
* Predicate: `err.data.reason === "LeaseInvalid"`.
|
|
43
|
-
*
|
|
44
|
-
* The wire code (-32001 / generic Forbidden) is intentionally NOT part of
|
|
45
|
-
* the predicate because the code is too generic to discriminate on alone.
|
|
46
|
-
*
|
|
47
|
-
* `ctx.leaseId` (optional) is the lease the caller just sent. Caller-supplied
|
|
48
|
-
* because the server's `ForbiddenError.data` shape does NOT carry leaseId.
|
|
49
|
-
* Falls back to `"(unknown)"` when omitted.
|
|
50
|
-
*
|
|
51
|
-
* `ctx.consumedAt` (required) is the epoch ms to stamp on the resulting
|
|
52
|
-
* `LeaseAlreadyConsumed.consumedAt`. Required because `LeaseAlreadyConsumed`
|
|
53
|
-
* requires it and this function is synchronous (no Clock access). Callers
|
|
54
|
-
* either pass `Date.now()` directly or use `catchLeaseInvalid` which reads
|
|
55
|
-
* `Clock.currentTimeMillis` inside the Effect.
|
|
56
|
-
* @param err Value supplied to the operation.
|
|
57
|
-
* @param ctx Context for the operation.
|
|
58
|
-
* @param ctx.leaseId Value supplied to the operation.
|
|
59
|
-
* @param ctx.consumedAt Value supplied to the operation.
|
|
60
|
-
* @returns The project lease invalid result.
|
|
61
|
-
*/
|
|
62
|
-
export function projectLeaseInvalid(err, ctx) {
|
|
63
|
-
if (!isLeaseInvalidData(err.data)) {
|
|
64
|
-
return err;
|
|
65
|
-
}
|
|
66
|
-
return new LeaseAlreadyConsumed({
|
|
67
|
-
leaseId: ctx.leaseId ?? LEASE_ID_FALLBACK,
|
|
68
|
-
consumedAt: ctx.consumedAt,
|
|
69
|
-
cause: err,
|
|
70
|
-
message: err.message,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Effect-pipe convenience: catches `ForbiddenError` and runs
|
|
75
|
-
* `projectLeaseInvalid` on each instance. Reads `Clock.currentTimeMillis`
|
|
76
|
-
* inside the catch and passes the result to `projectLeaseInvalid` as
|
|
77
|
-
* `consumedAt`. Matching errors are surfaced as the typed
|
|
78
|
-
* `LeaseAlreadyConsumed` on the failure channel; non-matching errors are
|
|
79
|
-
* re-raised unchanged so downstream `mapError`s see the original
|
|
80
|
-
* `ForbiddenError`.
|
|
81
|
-
*
|
|
82
|
-
* Use at every channel's outbound `core.sendReply(...)` boundary:.
|
|
83
|
-
*
|
|
84
|
-
* ```ts
|
|
85
|
-
* core.sendReply(conv, text, { dispatchLeaseId: leaseId }).pipe(
|
|
86
|
-
* catchLeaseInvalid({ leaseId }),
|
|
87
|
-
* // ... per-channel surfacing
|
|
88
|
-
* )
|
|
89
|
-
* ```
|
|
90
|
-
* @param ctx Context for the operation.
|
|
91
|
-
* @param ctx.leaseId Value supplied to the operation.
|
|
92
|
-
* @returns The catch lease invalid result.
|
|
93
|
-
*/
|
|
94
|
-
export function catchLeaseInvalid(ctx) {
|
|
95
|
-
// `Effect.catchIf` with an `instanceof` refinement handles only the
|
|
96
|
-
// `ForbiddenError` arm; the `E2` residual flows through untouched as
|
|
97
|
-
// `Exclude<ForbiddenError | E2, ForbiddenError>`, so there is no cast on the
|
|
98
|
-
// residual error channel. `catchTag("ForbiddenError", ...)` cannot be used:
|
|
99
|
-
// when `E2` is unconstrained, TS conservatively assumes it could carry
|
|
100
|
-
// `_tag: "ForbiddenError"`, which would widen the matched arm.
|
|
101
|
-
return Effect.catchIf((err) => err instanceof ForbiddenError, (err) => Effect.flatMap(Clock.currentTimeMillis, (consumedAt) => Effect.fail(projectLeaseInvalid(err, {
|
|
102
|
-
...(ctx?.leaseId !== undefined ? { leaseId: ctx.leaseId } : {}),
|
|
103
|
-
consumedAt,
|
|
104
|
-
}))));
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=lease.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lease.js","sourceRoot":"","sources":["../../src/channel-base/lease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CACxD,sBAAsB,CAMtB;CAAG;AAaL,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAEtC,SAAS,kBAAkB,CAAC,IAAa;IACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM;IACV,6EAA6E;IAC5E,IAAsC,CAAC,MAAM,CAAC;IACjD,OAAO,MAAM,KAAK,cAAc,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAmB,EACnB,GAA+D;IAE/D,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,IAAI,oBAAoB,CAAC;QAC9B,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,iBAAiB;QACzC,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,iBAAiB,CAAW,GAE3C;IAGC,oEAAoE;IACpE,qEAAqE;IACrE,6EAA6E;IAC7E,4EAA4E;IAC5E,uEAAuE;IACvE,+DAA+D;IAC/D,OAAO,MAAM,CAAC,OAAO,CACnB,CAAC,GAAG,EAAyB,EAAE,CAAC,GAAG,YAAY,cAAc,EAC7D,CAAC,GAAG,EAAE,EAAE,CACN,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CACrD,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,GAAG,EAAE;QACvB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,UAAU;KACX,CAAC,CACH,CACF,CACJ,CAAC;AACJ,CAAC"}
|