@moltzap/client 2026.529.0 → 2026.717.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/agent-client.d.ts +2 -65
- package/dist/agent-client.d.ts.map +1 -1
- package/dist/agent-client.js +1 -286
- package/dist/agent-client.js.map +1 -1
- package/dist/app-client.d.ts +3 -0
- package/dist/app-client.d.ts.map +1 -0
- package/dist/app-client.js +2 -0
- package/dist/app-client.js.map +1 -0
- package/dist/auth.d.ts +6 -15
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +12 -16
- package/dist/auth.js.map +1 -1
- package/dist/channel-base/format-cross-conv.d.ts +10 -15
- package/dist/channel-base/format-cross-conv.d.ts.map +1 -1
- package/dist/channel-base/format-cross-conv.js +10 -15
- package/dist/channel-base/format-cross-conv.js.map +1 -1
- package/dist/channel-base/format-group-block.d.ts +8 -10
- package/dist/channel-base/format-group-block.d.ts.map +1 -1
- package/dist/channel-base/format-group-block.js +8 -10
- package/dist/channel-base/format-group-block.js.map +1 -1
- package/dist/channel-base/index.d.ts +3 -62
- package/dist/channel-base/index.d.ts.map +1 -1
- package/dist/channel-base/index.js +2 -65
- package/dist/channel-base/index.js.map +1 -1
- package/dist/channel-base/lease-guard.d.ts +0 -2
- package/dist/channel-base/lease-guard.d.ts.map +1 -1
- package/dist/channel-base/lease-guard.js +0 -2
- package/dist/channel-base/lease-guard.js.map +1 -1
- package/dist/channel-base/lease-store.d.ts +2 -3
- package/dist/channel-base/lease-store.d.ts.map +1 -1
- package/dist/channel-base/lease-store.js +2 -3
- package/dist/channel-base/lease-store.js.map +1 -1
- package/dist/channel-base/lease.d.ts +25 -31
- package/dist/channel-base/lease.d.ts.map +1 -1
- package/dist/channel-base/lease.js +29 -45
- package/dist/channel-base/lease.js.map +1 -1
- package/dist/channel-core-enrichment.d.ts +1 -1
- package/dist/channel-core-enrichment.d.ts.map +1 -1
- package/dist/channel-core-test-support.d.ts +17 -11
- package/dist/channel-core-test-support.d.ts.map +1 -1
- package/dist/channel-core-test-support.js +5 -6
- package/dist/channel-core-test-support.js.map +1 -1
- package/dist/channel-core.d.ts +24 -29
- package/dist/channel-core.d.ts.map +1 -1
- package/dist/channel-core.js +18 -42
- package/dist/channel-core.js.map +1 -1
- package/dist/cli/commands/agents.d.ts +3 -6
- package/dist/cli/commands/agents.d.ts.map +1 -1
- package/dist/cli/commands/agents.js +14 -50
- package/dist/cli/commands/agents.js.map +1 -1
- package/dist/cli/commands/contacts.d.ts +5 -6
- package/dist/cli/commands/contacts.d.ts.map +1 -1
- package/dist/cli/commands/contacts.js +15 -43
- package/dist/cli/commands/contacts.js.map +1 -1
- package/dist/cli/commands/conversations.d.ts +8 -18
- package/dist/cli/commands/conversations.d.ts.map +1 -1
- package/dist/cli/commands/conversations.js +14 -65
- package/dist/cli/commands/conversations.js.map +1 -1
- package/dist/cli/commands/messages.d.ts +13 -35
- package/dist/cli/commands/messages.d.ts.map +1 -1
- package/dist/cli/commands/messages.js +21 -46
- package/dist/cli/commands/messages.js.map +1 -1
- package/dist/cli/commands/register.d.ts +10 -12
- package/dist/cli/commands/register.d.ts.map +1 -1
- package/dist/cli/commands/register.js +47 -133
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/send.d.ts +23 -36
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +25 -72
- package/dist/cli/commands/send.js.map +1 -1
- package/dist/cli/commands/start.d.ts +10 -124
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +28 -510
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.d.ts +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +8 -9
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/test-transport.d.ts +12 -5
- package/dist/cli/commands/test-transport.d.ts.map +1 -1
- package/dist/cli/commands/test-transport.js +15 -15
- package/dist/cli/commands/test-transport.js.map +1 -1
- package/dist/cli/index.js +13 -40
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/output.d.ts +4 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +9 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/socket-client.d.ts +7 -14
- package/dist/cli/socket-client.d.ts.map +1 -1
- package/dist/cli/socket-client.js +15 -38
- package/dist/cli/socket-client.js.map +1 -1
- package/dist/cli/transport.d.ts +53 -116
- package/dist/cli/transport.d.ts.map +1 -1
- package/dist/cli/transport.js +45 -295
- package/dist/cli/transport.js.map +1 -1
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +35 -0
- package/dist/config.js.map +1 -0
- package/dist/config.test-utils.d.ts +13 -0
- package/dist/config.test-utils.d.ts.map +1 -0
- package/dist/config.test-utils.js +46 -0
- package/dist/config.test-utils.js.map +1 -0
- package/dist/index.d.ts +3 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -12
- package/dist/index.js.map +1 -1
- package/dist/local-daemon-rpc.d.ts +259 -8
- package/dist/local-daemon-rpc.d.ts.map +1 -1
- package/dist/local-daemon-rpc.js +189 -12
- package/dist/local-daemon-rpc.js.map +1 -1
- package/dist/{runtime/local-history.d.ts → local-history.d.ts} +16 -21
- package/dist/local-history.d.ts.map +1 -0
- package/dist/{runtime/local-history.js → local-history.js} +16 -21
- package/dist/local-history.js.map +1 -0
- package/dist/local-paths.d.ts +0 -2
- package/dist/local-paths.d.ts.map +1 -1
- package/dist/local-paths.js +0 -4
- package/dist/local-paths.js.map +1 -1
- package/dist/local-socket-server.d.ts +22 -0
- package/dist/local-socket-server.d.ts.map +1 -0
- package/dist/{runtime/local-socket-server.js → local-socket-server.js} +4 -9
- package/dist/local-socket-server.js.map +1 -0
- package/dist/message-rendering.d.ts +3 -0
- package/dist/message-rendering.d.ts.map +1 -0
- package/dist/message-rendering.js +7 -0
- package/dist/message-rendering.js.map +1 -0
- package/dist/notification/__tests__/{snapshot-semantics.types-check.d.ts → subscribe-signatures.types-check.d.ts} +1 -1
- package/dist/notification/__tests__/subscribe-signatures.types-check.d.ts.map +1 -0
- package/dist/notification/__tests__/subscribe-signatures.types-check.js +55 -0
- package/dist/notification/__tests__/subscribe-signatures.types-check.js.map +1 -0
- package/dist/notification/errors.d.ts +18 -6
- package/dist/notification/errors.d.ts.map +1 -1
- package/dist/notification/errors.js +13 -15
- package/dist/notification/errors.js.map +1 -1
- package/dist/notification/index.d.ts +5 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js +5 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/notification/stream.d.ts +33 -49
- package/dist/notification/stream.d.ts.map +1 -1
- package/dist/notification/stream.js +33 -76
- package/dist/notification/stream.js.map +1 -1
- package/dist/pagination.d.ts +20 -10
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +8 -9
- package/dist/pagination.js.map +1 -1
- package/dist/profile.d.ts +92 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +149 -0
- package/dist/profile.js.map +1 -0
- package/dist/refs.d.ts.map +1 -0
- package/dist/refs.js.map +1 -0
- package/dist/service-archive-purge.d.ts +2 -1
- package/dist/service-archive-purge.d.ts.map +1 -1
- package/dist/service-archive-purge.js.map +1 -1
- package/dist/{runtime/service-helpers.d.ts → service-helpers.d.ts} +5 -11
- package/dist/service-helpers.d.ts.map +1 -0
- package/dist/{runtime/service-helpers.js → service-helpers.js} +2 -9
- package/dist/service-helpers.js.map +1 -0
- package/dist/service-local-daemon.d.ts +22 -0
- package/dist/service-local-daemon.d.ts.map +1 -0
- package/dist/service-local-daemon.js +185 -0
- package/dist/service-local-daemon.js.map +1 -0
- package/dist/service.d.ts +65 -57
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +205 -156
- package/dist/service.js.map +1 -1
- package/dist/test-utils/channel-service-fixture.d.ts +3 -2
- package/dist/test-utils/channel-service-fixture.d.ts.map +1 -1
- package/dist/test-utils/channel-service-fixture.js.map +1 -1
- package/dist/test-utils/fake-service.d.ts +26 -18
- package/dist/test-utils/fake-service.d.ts.map +1 -1
- package/dist/test-utils/fake-service.js +28 -42
- package/dist/test-utils/fake-service.js.map +1 -1
- package/dist/test-utils/ids.d.ts +3 -1
- package/dist/test-utils/ids.d.ts.map +1 -1
- package/dist/test-utils/ids.js.map +1 -1
- package/dist/test-utils/index.d.ts +9 -2
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +8 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/standalone-provisioning.d.ts +17 -0
- package/dist/test-utils/standalone-provisioning.d.ts.map +1 -0
- package/dist/test-utils/standalone-provisioning.js +14 -0
- package/dist/test-utils/standalone-provisioning.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +39 -17
- package/dist/auth.test.d.ts +0 -2
- package/dist/auth.test.d.ts.map +0 -1
- package/dist/auth.test.js +0 -121
- package/dist/auth.test.js.map +0 -1
- package/dist/channel-core-context.test.d.ts +0 -2
- package/dist/channel-core-context.test.d.ts.map +0 -1
- package/dist/channel-core-context.test.js +0 -342
- package/dist/channel-core-context.test.js.map +0 -1
- package/dist/channel-core-dispatch.test.d.ts +0 -2
- package/dist/channel-core-dispatch.test.d.ts.map +0 -1
- package/dist/channel-core-dispatch.test.js +0 -557
- package/dist/channel-core-dispatch.test.js.map +0 -1
- package/dist/channel-core.test.d.ts +0 -2
- package/dist/channel-core.test.d.ts.map +0 -1
- package/dist/channel-core.test.js +0 -232
- package/dist/channel-core.test.js.map +0 -1
- package/dist/cli/__tests__/cli-multi-agent.int.test.d.ts +0 -2
- package/dist/cli/__tests__/cli-multi-agent.int.test.d.ts.map +0 -1
- package/dist/cli/__tests__/cli-multi-agent.int.test.js +0 -132
- package/dist/cli/__tests__/cli-multi-agent.int.test.js.map +0 -1
- package/dist/cli/commands/invite.d.ts +0 -7
- package/dist/cli/commands/invite.d.ts.map +0 -1
- package/dist/cli/commands/invite.js +0 -11
- package/dist/cli/commands/invite.js.map +0 -1
- package/dist/cli/commands/messages.test.d.ts +0 -2
- package/dist/cli/commands/messages.test.d.ts.map +0 -1
- package/dist/cli/commands/messages.test.js +0 -99
- package/dist/cli/commands/messages.test.js.map +0 -1
- package/dist/cli/commands/ping.d.ts +0 -7
- package/dist/cli/commands/ping.d.ts.map +0 -1
- package/dist/cli/commands/ping.js +0 -37
- package/dist/cli/commands/ping.js.map +0 -1
- package/dist/cli/commands/register.test.d.ts +0 -2
- package/dist/cli/commands/register.test.d.ts.map +0 -1
- package/dist/cli/commands/register.test.js +0 -91
- package/dist/cli/commands/register.test.js.map +0 -1
- package/dist/cli/commands/send.test.d.ts +0 -2
- package/dist/cli/commands/send.test.d.ts.map +0 -1
- package/dist/cli/commands/send.test.js +0 -59
- package/dist/cli/commands/send.test.js.map +0 -1
- package/dist/cli/commands/start.test.d.ts +0 -2
- package/dist/cli/commands/start.test.d.ts.map +0 -1
- package/dist/cli/commands/start.test.js +0 -624
- package/dist/cli/commands/start.test.js.map +0 -1
- package/dist/cli/commands/whoami.d.ts +0 -8
- package/dist/cli/commands/whoami.d.ts.map +0 -1
- package/dist/cli/commands/whoami.js +0 -28
- package/dist/cli/commands/whoami.js.map +0 -1
- package/dist/cli/config.d.ts +0 -66
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -148
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/config.test.d.ts +0 -2
- package/dist/cli/config.test.d.ts.map +0 -1
- package/dist/cli/config.test.js +0 -89
- package/dist/cli/config.test.js.map +0 -1
- package/dist/cli/http-client.d.ts +0 -17
- package/dist/cli/http-client.d.ts.map +0 -1
- package/dist/cli/http-client.js +0 -38
- package/dist/cli/http-client.js.map +0 -1
- package/dist/cli/profile.d.ts +0 -126
- package/dist/cli/profile.d.ts.map +0 -1
- package/dist/cli/profile.js +0 -231
- package/dist/cli/profile.js.map +0 -1
- package/dist/cli/profile.test.d.ts +0 -2
- package/dist/cli/profile.test.d.ts.map +0 -1
- package/dist/cli/profile.test.js +0 -369
- package/dist/cli/profile.test.js.map +0 -1
- package/dist/cli/transport.test.d.ts +0 -2
- package/dist/cli/transport.test.d.ts.map +0 -1
- package/dist/cli/transport.test.js +0 -312
- package/dist/cli/transport.test.js.map +0 -1
- package/dist/notification/__tests__/filter-equivalence.test.d.ts +0 -2
- package/dist/notification/__tests__/filter-equivalence.test.d.ts.map +0 -1
- package/dist/notification/__tests__/filter-equivalence.test.js +0 -123
- package/dist/notification/__tests__/filter-equivalence.test.js.map +0 -1
- package/dist/notification/__tests__/snapshot-semantics.test.d.ts +0 -2
- package/dist/notification/__tests__/snapshot-semantics.test.d.ts.map +0 -1
- package/dist/notification/__tests__/snapshot-semantics.test.js +0 -261
- package/dist/notification/__tests__/snapshot-semantics.test.js.map +0 -1
- package/dist/notification/__tests__/snapshot-semantics.types-check.d.ts.map +0 -1
- package/dist/notification/__tests__/snapshot-semantics.types-check.js +0 -62
- package/dist/notification/__tests__/snapshot-semantics.types-check.js.map +0 -1
- package/dist/pagination.test.d.ts +0 -2
- package/dist/pagination.test.d.ts.map +0 -1
- package/dist/pagination.test.js +0 -72
- package/dist/pagination.test.js.map +0 -1
- package/dist/runtime/close-info.d.ts +0 -84
- package/dist/runtime/close-info.d.ts.map +0 -1
- package/dist/runtime/close-info.js +0 -102
- package/dist/runtime/close-info.js.map +0 -1
- package/dist/runtime/close-info.test.d.ts +0 -2
- package/dist/runtime/close-info.test.d.ts.map +0 -1
- package/dist/runtime/close-info.test.js +0 -109
- package/dist/runtime/close-info.test.js.map +0 -1
- package/dist/runtime/errors.d.ts +0 -11
- package/dist/runtime/errors.d.ts.map +0 -1
- package/dist/runtime/errors.js +0 -41
- package/dist/runtime/errors.js.map +0 -1
- package/dist/runtime/errors.test.d.ts +0 -2
- package/dist/runtime/errors.test.d.ts.map +0 -1
- package/dist/runtime/errors.test.js +0 -79
- package/dist/runtime/errors.test.js.map +0 -1
- package/dist/runtime/frame.d.ts +0 -8
- package/dist/runtime/frame.d.ts.map +0 -1
- package/dist/runtime/frame.js +0 -12
- package/dist/runtime/frame.js.map +0 -1
- package/dist/runtime/frame.test.d.ts +0 -2
- package/dist/runtime/frame.test.d.ts.map +0 -1
- package/dist/runtime/frame.test.js +0 -59
- package/dist/runtime/frame.test.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -10
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -9
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/local-history.d.ts.map +0 -1
- package/dist/runtime/local-history.js.map +0 -1
- package/dist/runtime/local-service-commands.d.ts +0 -26
- package/dist/runtime/local-service-commands.d.ts.map +0 -1
- package/dist/runtime/local-service-commands.js +0 -29
- package/dist/runtime/local-service-commands.js.map +0 -1
- package/dist/runtime/local-socket-server.d.ts +0 -20
- package/dist/runtime/local-socket-server.d.ts.map +0 -1
- package/dist/runtime/local-socket-server.js.map +0 -1
- package/dist/runtime/refs.d.ts.map +0 -1
- package/dist/runtime/refs.js.map +0 -1
- package/dist/runtime/runtime.test.d.ts +0 -2
- package/dist/runtime/runtime.test.d.ts.map +0 -1
- package/dist/runtime/runtime.test.js +0 -37
- package/dist/runtime/runtime.test.js.map +0 -1
- package/dist/runtime/service-helpers.d.ts.map +0 -1
- package/dist/runtime/service-helpers.js.map +0 -1
- package/dist/runtime/service-teardown.d.ts +0 -5
- package/dist/runtime/service-teardown.d.ts.map +0 -1
- package/dist/runtime/service-teardown.js +0 -36
- package/dist/runtime/service-teardown.js.map +0 -1
- package/dist/runtime/service-teardown.test.d.ts +0 -2
- package/dist/runtime/service-teardown.test.d.ts.map +0 -1
- package/dist/runtime/service-teardown.test.js +0 -80
- package/dist/runtime/service-teardown.test.js.map +0 -1
- package/dist/runtime/subscribers.d.ts +0 -152
- package/dist/runtime/subscribers.d.ts.map +0 -1
- package/dist/runtime/subscribers.js +0 -222
- package/dist/runtime/subscribers.js.map +0 -1
- package/dist/service-socket-path.test.d.ts +0 -2
- package/dist/service-socket-path.test.d.ts.map +0 -1
- package/dist/service-socket-path.test.js +0 -87
- package/dist/service-socket-path.test.js.map +0 -1
- package/dist/service.test.d.ts +0 -2
- package/dist/service.test.d.ts.map +0 -1
- package/dist/service.test.js +0 -796
- package/dist/service.test.js.map +0 -1
- package/dist/test/index.d.ts +0 -47
- package/dist/test/index.d.ts.map +0 -1
- package/dist/test/index.js +0 -39
- package/dist/test/index.js.map +0 -1
- package/dist/test-utils/conformance-adapter.d.ts +0 -40
- package/dist/test-utils/conformance-adapter.d.ts.map +0 -1
- package/dist/test-utils/conformance-adapter.js +0 -250
- package/dist/test-utils/conformance-adapter.js.map +0 -1
- package/dist/tm-client-test-support.d.ts +0 -184
- package/dist/tm-client-test-support.d.ts.map +0 -1
- package/dist/tm-client-test-support.js +0 -466
- package/dist/tm-client-test-support.js.map +0 -1
- package/dist/tm-client.d.ts +0 -269
- package/dist/tm-client.d.ts.map +0 -1
- package/dist/tm-client.js +0 -518
- package/dist/tm-client.js.map +0 -1
- package/dist/tm-client.test.d.ts +0 -2
- package/dist/tm-client.test.d.ts.map +0 -1
- package/dist/tm-client.test.js +0 -490
- package/dist/tm-client.test.js.map +0 -1
- /package/dist/{runtime/refs.d.ts → refs.d.ts} +0 -0
- /package/dist/{runtime/refs.js → refs.js} +0 -0
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
/* eslint-disable jsdoc/text-escaping -- JSDoc references to generic types like `Stream.async<DecodedNotification<D>>` use the natural angle-bracket form (TS source style) inside backtick-fenced code spans; the lint rule's pre-render check fires false positives on these multi-line spans. Matches the precedent in filter-equivalence.test.ts. */
|
|
2
1
|
/**
|
|
3
2
|
* Stream-returning constructors for `MoltZapAgentClient.subscribe` and
|
|
4
|
-
* `MoltZapAgentClient.subscribeAll
|
|
3
|
+
* `MoltZapAgentClient.subscribeAll`.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* additional per-sub cancelled-flag check (architect plan §3).
|
|
5
|
+
* `Stream.async` cancellation drives the registry-stored `unregister`
|
|
6
|
+
* finalizer. The registry's `dispatch` snapshots `subsRef` at iteration
|
|
7
|
+
* start, so the snapshot semantic holds by Ref atomicity without a
|
|
8
|
+
* per-sub cancelled-flag check.
|
|
11
9
|
*
|
|
12
|
-
* Stream construction uses `Stream.async
|
|
13
|
-
* with the registry storing typed callback references — NOT
|
|
14
|
-
* `Take` items combined with `Stream.fromQueue`/`Stream.flattenTake`,
|
|
15
|
-
* which
|
|
16
|
-
*
|
|
17
|
-
* the typed failure to the consumer (architect plan §3.2, codex r4).
|
|
10
|
+
* Stream construction uses `Stream.async<NotificationParamsOf<D>,
|
|
11
|
+
* NotConnectedError>` with the registry storing typed callback references — NOT
|
|
12
|
+
* `Queue` of `Take` items combined with `Stream.fromQueue`/`Stream.flattenTake`,
|
|
13
|
+
* which is racy under `Queue.offer(Take.fail); Queue.shutdown` and does not
|
|
14
|
+
* reliably propagate the typed failure to the consumer.
|
|
18
15
|
*
|
|
19
|
-
* Stream lifecycle
|
|
16
|
+
* Stream lifecycle:
|
|
20
17
|
* 1. `subscribe(def)` returns a Stream value. Pure; no I/O, no scope.
|
|
21
18
|
* 2. Materialization opens the `Stream.async` source: `registry.register`
|
|
22
19
|
* runs synchronously, callbacks are installed; consumer pulls suspend
|
|
@@ -24,37 +21,25 @@
|
|
|
24
21
|
* 3. Pre-`connect()` consumer pulls suspend inside `Stream.async`'s
|
|
25
22
|
* internal queue. No `NotConnectedError` until terminal close.
|
|
26
23
|
* 4. Reconnect leaves registry callbacks intact; `subsRef` survives
|
|
27
|
-
* transient disconnects
|
|
24
|
+
* transient disconnects. **Reconnect-window
|
|
25
|
+
* frame loss:** any server-originated notification frame that the
|
|
26
|
+
* transport drops while disconnected (between the socket dying and
|
|
27
|
+
* the reconnect `hello` completing) is NOT replayed — the Stream API
|
|
28
|
+
* has no buffering or gap-fill across the reconnect window, so such
|
|
29
|
+
* frames are silently lost to the consumer. Subscriptions resume
|
|
30
|
+
* receiving frames that arrive AFTER reconnect; there is no error or
|
|
31
|
+
* sentinel marking the gap.
|
|
28
32
|
* 5. `MoltZapAgentClient.close` invokes `SubscriberRegistry.closeAll`, which
|
|
29
33
|
* calls each live `sub.onClose(new NotConnectedError(...))`. Each
|
|
30
34
|
* `Stream.async`-backed consumer fails with `NotConnectedError`
|
|
31
35
|
* via `emit.fail` deterministically (no Queue/shutdown race).
|
|
32
36
|
*/
|
|
33
|
-
import {
|
|
34
|
-
import {} from "@moltzap/protocol";
|
|
37
|
+
import { Stream } from "effect";
|
|
38
|
+
import { notificationSubscribe, notificationSubscribeAll, } from "@moltzap/protocol/rpc";
|
|
35
39
|
export function subscribe(registry, definition, refinement) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// invoke as the cancellation finalizer. #ignore-sloppy-code[async-keyword]: comment references `Stream.async`, not a function modifier
|
|
40
|
-
//
|
|
41
|
-
// `register` is `Effect<SubscriptionHandle, never>`; `runSync` is safe
|
|
42
|
-
// because the registry mutates an in-memory `Ref` and never yields.
|
|
43
|
-
const handle = Effect.runSync(registry.register(definition, refinement, {
|
|
44
|
-
onFrame: (frame) => Effect.sync(() => {
|
|
45
|
-
emit.single(frame);
|
|
46
|
-
}),
|
|
47
|
-
onClose: (cause) => Effect.sync(() => {
|
|
48
|
-
emit.fail(cause);
|
|
49
|
-
}),
|
|
50
|
-
}));
|
|
51
|
-
// Per P3 issue #613: use `Effect.suspend` to defer running `unregister`
|
|
52
|
-
// to whenever the Stream's runtime invokes the finalizer Effect. This
|
|
53
|
-
// is future-proof if `unregister` ever grows yielded effects (e.g.
|
|
54
|
-
// flushing a queue); the `Effect.sync(() => Effect.runSync(handle.unregister))`
|
|
55
|
-
// form would force-eager-evaluate as sync.
|
|
56
|
-
return Effect.suspend(() => handle.unregister);
|
|
57
|
-
});
|
|
40
|
+
if (refinement === undefined)
|
|
41
|
+
return notificationSubscribe(registry, definition);
|
|
42
|
+
return notificationSubscribe(registry, definition, refinement);
|
|
58
43
|
}
|
|
59
44
|
/**
|
|
60
45
|
* Broad-union escape hatch. The only intended in-tree consumer is
|
|
@@ -63,44 +48,16 @@ export function subscribe(registry, definition, refinement) {
|
|
|
63
48
|
* narrowing is intentionally lost; callers wanting typed payloads use
|
|
64
49
|
* `subscribe(def, refinement?)`.
|
|
65
50
|
*
|
|
66
|
-
* The
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* Implementation: the registry has no native "match all" subscription
|
|
73
|
-
* shape (intentional — `subscribe<D>` is per-definition). To preserve
|
|
74
|
-
* the registry's typed dispatch surface, `subscribeAll` constructs a
|
|
75
|
-
* Stream that taps the registry via a per-arrival path: registering
|
|
76
|
-
* once with a sentinel definition would require a registry-level "match
|
|
77
|
-
* any" capability we deliberately avoid (would complicate the typed
|
|
78
|
-
* dispatch in subscribers.ts). Instead, the dispatcher feeds every
|
|
79
|
-
* frame to `subscribeAll`'s emit via a dedicated `subscribeAllRef`
|
|
80
|
-
* callback list maintained alongside `subsRef`.
|
|
81
|
-
*
|
|
82
|
-
* Architect-mandated code shape: per spec Goal #2 / plan §5.3, the
|
|
83
|
-
* surface returns a Stream value. Implementation passes the literal
|
|
84
|
-
* `AnyNotificationDefinition` sentinel via the registry's broad-union
|
|
85
|
-
* channel — see `notification/stream.ts → subscribeAllStream` below
|
|
86
|
-
* which registers via a new `SubscriberRegistry.registerAll` helper.
|
|
87
|
-
*
|
|
88
|
-
* To keep the registry minimal we route `subscribeAll` through a thin
|
|
89
|
-
* wrapper that the registry exposes as `registerAll(callbacks)` —
|
|
90
|
-
* identical lifecycle to `register(def, …)` but with no definition
|
|
91
|
-
* match (the dispatcher hits these callbacks for every inbound frame).
|
|
51
|
+
* The registry has no "match all" subscription shape (`subscribe<D>` is
|
|
52
|
+
* per-definition). `subscribeAll` instead registers via
|
|
53
|
+
* `SubscriberRegistry.registerAll`, whose callbacks the dispatcher hits
|
|
54
|
+
* for every inbound frame regardless of definition. Same lifecycle as
|
|
55
|
+
* `register(def, …)`, no definition match.
|
|
92
56
|
*/
|
|
93
57
|
export function subscribeAll(registry, refinement) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}),
|
|
99
|
-
onClose: (cause) => Effect.sync(() => {
|
|
100
|
-
emit.fail(cause);
|
|
101
|
-
}),
|
|
102
|
-
}));
|
|
103
|
-
return Effect.suspend(() => handle.unregister);
|
|
104
|
-
});
|
|
58
|
+
if (refinement === undefined) {
|
|
59
|
+
return notificationSubscribeAll(registry);
|
|
60
|
+
}
|
|
61
|
+
return notificationSubscribeAll(registry, (delivery) => refinement(delivery.definition, delivery.params));
|
|
105
62
|
}
|
|
106
63
|
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/notification/stream.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/notification/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAGL,qBAAqB,EACrB,wBAAwB,GAGzB,MAAM,uBAAuB,CAAC;AAmC/B,MAAM,UAAU,SAAS,CACvB,QAGC,EACD,UAAa,EACb,UAAyD;IAEzD,IAAI,UAAU,KAAK,SAAS;QAC1B,OAAO,qBAAqB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACrD,OAAO,qBAAqB,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAC1B,QAGC,EACD,UAGY;IAEZ,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,wBAAwB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CACrD,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CACjD,CAAC;AACJ,CAAC"}
|
package/dist/pagination.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Generic drainer for the cursor-paginated list RPCs.
|
|
3
3
|
*
|
|
4
|
-
* The list RPCs (`contacts/list`, `agents/list`, `task/list`,
|
|
4
|
+
* The list RPCs (`agent/identity/contacts/list`, `agent/identity/agents/list`, `agent/task/list`, ...) return a
|
|
5
5
|
* bounded page plus an opaque `nextCursor`. A consumer that needs the
|
|
6
6
|
* COMPLETE set must page through every cursor. {@link drainPaginatedList}
|
|
7
|
-
* does exactly that for
|
|
8
|
-
*
|
|
7
|
+
* does exactly that for descriptor-based RPC calls, with the caller supplying
|
|
8
|
+
* the descriptor-specific page params and row/cursor accessors.
|
|
9
9
|
*
|
|
10
10
|
* Lives in `@moltzap/client` because the logic is wire-generic: any
|
|
11
11
|
* channel or CLI that drains a list RPC reuses it (openclaw's directory
|
|
12
12
|
* is the first consumer).
|
|
13
13
|
*/
|
|
14
|
-
import type {
|
|
14
|
+
import type { ClientDefinitionPayload, ClientDefinitionSuccess, ClientRpcDefinition } from "@moltzap/protocol/socket";
|
|
15
15
|
import { Effect } from "effect";
|
|
16
16
|
declare const NonAdvancingCursorError_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
17
|
readonly _tag: "NonAdvancingCursorError";
|
|
@@ -33,13 +33,23 @@ export declare class NonAdvancingCursorError extends NonAdvancingCursorError_bas
|
|
|
33
33
|
* channel `E` so the helper stays decoupled from any one client's error
|
|
34
34
|
* union.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
type ClientDescriptor = ClientRpcDefinition & {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
};
|
|
39
|
+
export type SendRpcFn<E, Definition extends ClientDescriptor> = (definition: Definition, params: ClientDefinitionPayload<Definition>) => Effect.Effect<ClientDefinitionSuccess<Definition>, E>;
|
|
40
|
+
export interface DrainPaginatedListOptions<E, D extends ClientDescriptor, Row, Cursor extends string> {
|
|
41
|
+
readonly sendRpc: SendRpcFn<E, D>;
|
|
42
|
+
readonly definition: D;
|
|
43
|
+
readonly paramsForCursor: (cursor: Cursor | undefined) => ClientDefinitionPayload<D>;
|
|
44
|
+
readonly rowsForPage: (page: ClientDefinitionSuccess<D>) => ReadonlyArray<Row>;
|
|
45
|
+
readonly nextCursorForPage: (page: ClientDefinitionSuccess<D>) => Cursor | undefined;
|
|
46
|
+
}
|
|
37
47
|
/**
|
|
38
|
-
* Drain every page of a cursor-paginated list RPC
|
|
39
|
-
* `
|
|
40
|
-
*
|
|
41
|
-
*
|
|
48
|
+
* Drain every page of a cursor-paginated list RPC, echoing the opaque
|
|
49
|
+
* `nextCursor` back as the next page's `cursor`. Fails with
|
|
50
|
+
* {@link NonAdvancingCursorError} if the server returns a cursor it already
|
|
51
|
+
* emitted (cycle guard).
|
|
42
52
|
*/
|
|
43
|
-
export declare function drainPaginatedList<E, D extends
|
|
53
|
+
export declare function drainPaginatedList<E, D extends ClientDescriptor, Row, Cursor extends string>({ sendRpc, definition, paramsForCursor, rowsForPage, nextCursorForPage, }: DrainPaginatedListOptions<E, D, Row, Cursor>): Effect.Effect<ReadonlyArray<Row>, E | NonAdvancingCursorError>;
|
|
44
54
|
export {};
|
|
45
55
|
//# sourceMappingURL=pagination.d.ts.map
|
package/dist/pagination.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"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B,EAAE,CAC1B,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAC7B,MAAM,GAAG,SAAS,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EACD,CAAC,SAAS,gBAAgB,EAC1B,GAAG,EACH,MAAM,SAAS,MAAM,EACrB,EACA,OAAO,EACP,UAAU,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,GAClB,EAAE,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAC7D,aAAa,CAAC,GAAG,CAAC,EAClB,CAAC,GAAG,uBAAuB,CAC5B,CAwBA"}
|
package/dist/pagination.js
CHANGED
|
@@ -11,12 +11,12 @@ export class NonAdvancingCursorError extends Data.TaggedError("NonAdvancingCurso
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Drain every page of a cursor-paginated list RPC
|
|
15
|
-
* `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* Drain every page of a cursor-paginated list RPC, echoing the opaque
|
|
15
|
+
* `nextCursor` back as the next page's `cursor`. Fails with
|
|
16
|
+
* {@link NonAdvancingCursorError} if the server returns a cursor it already
|
|
17
|
+
* emitted (cycle guard).
|
|
18
18
|
*/
|
|
19
|
-
export function drainPaginatedList(sendRpc, definition,
|
|
19
|
+
export function drainPaginatedList({ sendRpc, definition, paramsForCursor, rowsForPage, nextCursorForPage, }) {
|
|
20
20
|
return Effect.gen(function* () {
|
|
21
21
|
const acc = [];
|
|
22
22
|
// Cycle guard, not a page cap: a repeated cursor means the server is
|
|
@@ -25,11 +25,10 @@ export function drainPaginatedList(sendRpc, definition, collectionKey) {
|
|
|
25
25
|
let cursor;
|
|
26
26
|
let more = true;
|
|
27
27
|
while (more) {
|
|
28
|
-
const params = (cursor
|
|
28
|
+
const params = paramsForCursor(cursor);
|
|
29
29
|
const page = yield* sendRpc(definition, params);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const nextCursor = page.nextCursor;
|
|
30
|
+
acc.push(...rowsForPage(page));
|
|
31
|
+
const nextCursor = nextCursorForPage(page);
|
|
33
32
|
if (nextCursor !== undefined && seenCursors.has(nextCursor)) {
|
|
34
33
|
return yield* Effect.fail(new NonAdvancingCursorError({ method: definition.name }));
|
|
35
34
|
}
|
package/dist/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,IAAI,CAAC,WAAW,CAC3D,yBAAyB,CAGzB;IACA,IAAa,OAAO;QAClB,OAAO,yBAAyB,IAAI,CAAC,MAAM,qCAAqC,CAAC;IACnF,CAAC;CACF;AAkCD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAKhC,EACA,OAAO,EACP,UAAU,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,GAC4B;IAI7C,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,GAAG,GAAU,EAAE,CAAC;QACtB,qEAAqE;QACrE,yDAAyD;QACzD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QACtC,IAAI,MAA0B,CAAC;QAC/B,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAChD,GAAG,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/B,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,UAAU,KAAK,SAAS,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC5D,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CACzD,CAAC;YACJ,CAAC;YACD,IAAI,UAAU,KAAK,SAAS;gBAAE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC1D,MAAM,GAAG,UAAU,CAAC;YACpB,IAAI,GAAG,UAAU,KAAK,SAAS,CAAC;QAClC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { AgentId } from "@moltzap/protocol/identity";
|
|
3
|
+
import { AgentKey } from "@moltzap/protocol/identity";
|
|
4
|
+
export declare const ProfileName: Schema.brand<Schema.filter<typeof Schema.String>, "ProfileName">;
|
|
5
|
+
/**
|
|
6
|
+
* Branded profile name shared by profile lookup and CLI registration.
|
|
7
|
+
*/
|
|
8
|
+
export type ProfileName = Schema.Schema.Type<typeof ProfileName>;
|
|
9
|
+
declare const ProfileRecordSchema: Schema.Struct<{
|
|
10
|
+
agentId: Schema.Schema<AgentId, string, never>;
|
|
11
|
+
apiKey: Schema.Schema<AgentKey, string, never>;
|
|
12
|
+
agentName: typeof Schema.String;
|
|
13
|
+
}>;
|
|
14
|
+
/** One profile's persisted auth record. */
|
|
15
|
+
export type ProfileRecord = Schema.Schema.Type<typeof ProfileRecordSchema>;
|
|
16
|
+
/** Named profile view of config.json. */
|
|
17
|
+
export interface LayeredConfig {
|
|
18
|
+
readonly profiles: ReadonlyMap<ProfileName, ProfileRecord>;
|
|
19
|
+
}
|
|
20
|
+
/** Exhaustive error union for the profile surface. */
|
|
21
|
+
export type ProfileError = ProfileNotFoundError | ProfileInvalidNameError | ProfileConfigReadError | ProfileConfigWriteError;
|
|
22
|
+
declare const ProfileNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
23
|
+
readonly _tag: "ProfileNotFoundError";
|
|
24
|
+
} & Readonly<A>;
|
|
25
|
+
export declare class ProfileNotFoundError extends ProfileNotFoundError_base<{
|
|
26
|
+
readonly name: string;
|
|
27
|
+
}> {
|
|
28
|
+
}
|
|
29
|
+
declare const ProfileInvalidNameError_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 & {
|
|
30
|
+
readonly _tag: "ProfileInvalidNameError";
|
|
31
|
+
} & Readonly<A>;
|
|
32
|
+
export declare class ProfileInvalidNameError extends ProfileInvalidNameError_base<{
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
}> {
|
|
36
|
+
}
|
|
37
|
+
declare const ProfileConfigReadError_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 & {
|
|
38
|
+
readonly _tag: "ProfileConfigReadError";
|
|
39
|
+
} & Readonly<A>;
|
|
40
|
+
export declare class ProfileConfigReadError extends ProfileConfigReadError_base<{
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly cause: unknown;
|
|
43
|
+
}> {
|
|
44
|
+
}
|
|
45
|
+
declare const ProfileConfigWriteError_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 & {
|
|
46
|
+
readonly _tag: "ProfileConfigWriteError";
|
|
47
|
+
} & Readonly<A>;
|
|
48
|
+
export declare class ProfileConfigWriteError extends ProfileConfigWriteError_base<{
|
|
49
|
+
readonly path: string;
|
|
50
|
+
readonly cause: unknown;
|
|
51
|
+
}> {
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse and brand a raw profile name. Rejects the empty string and any
|
|
55
|
+
* string that fails NAME_PATTERN.
|
|
56
|
+
*/
|
|
57
|
+
export declare const parseProfileName: (raw: string) => Effect.Effect<ProfileName, ProfileInvalidNameError>;
|
|
58
|
+
/**
|
|
59
|
+
* Load the full layered config view. Missing file resolves to an empty
|
|
60
|
+
* view; malformed file surfaces as ProfileConfigReadError. No silent
|
|
61
|
+
* defaults on parse error.
|
|
62
|
+
*
|
|
63
|
+
* The file schema is strict: stale fields and malformed profile entries fail
|
|
64
|
+
* decode instead of being silently ignored.
|
|
65
|
+
*/
|
|
66
|
+
export declare const loadLayeredConfig: Effect.Effect<LayeredConfig, ProfileConfigReadError>;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a named profile record. CLI transport selection uses only
|
|
69
|
+
* `agentId`; daemon startup consumes the redacted `apiKey`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const resolveProfileRecord: (name: ProfileName) => Effect.Effect<ProfileRecord, ProfileNotFoundError | ProfileConfigReadError>;
|
|
72
|
+
/**
|
|
73
|
+
* Persist a new profile record under `profiles.<name>`.
|
|
74
|
+
*/
|
|
75
|
+
export declare const writeProfile: (name: ProfileName, record: ProfileRecord) => Effect.Effect<void, ProfileConfigWriteError | ProfileConfigReadError>;
|
|
76
|
+
/**
|
|
77
|
+
* `--no-persist` contract for `moltzap register`: no file under
|
|
78
|
+
* `$HOME/.moltzap/` is created or modified. Returns the record so the caller
|
|
79
|
+
* can print it; does no I/O under that tree.
|
|
80
|
+
*
|
|
81
|
+
* The register command invokes either `writeProfile` (default) or
|
|
82
|
+
* `emitNoPersist` (when the flag is set). The register handler never calls
|
|
83
|
+
* both paths on the same invocation.
|
|
84
|
+
*
|
|
85
|
+
* The register command pipes the returned record through the printer,
|
|
86
|
+
* which writes non-secret registration details to stdout.
|
|
87
|
+
*/
|
|
88
|
+
export declare const emitNoPersist: (record: ProfileRecord) => Effect.Effect<{
|
|
89
|
+
readonly record: ProfileRecord;
|
|
90
|
+
}, never>;
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAQA,OAAO,EAAQ,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAiBtD,eAAO,MAAM,WAAW,kEAGvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAEjE,QAAA,MAAM,mBAAmB;;;;EAIvB,CAAC;AAEH,2CAA2C;AAC3C,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAe3E,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;CAC5D;AAID,sDAAsD;AACtD,MAAM,MAAM,YAAY,GACpB,oBAAoB,GACpB,uBAAuB,GACvB,sBAAsB,GACtB,uBAAuB,CAAC;;;;AAE5B,qBAAa,oBAAqB,SAAQ,0BAExC;IACA,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;CAAG;;;;AAEL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
|
4
|
+
* Named profiles live under a top-level `profiles` key. There is no singleton
|
|
5
|
+
* credential fallback; every persisted identity is selected by profile name.
|
|
6
|
+
*/
|
|
7
|
+
import { FileSystem } from "@effect/platform";
|
|
8
|
+
import { NodeFileSystem } from "@effect/platform-node";
|
|
9
|
+
import { Data, Effect, Either, Schema } from "effect";
|
|
10
|
+
import { AgentId } from "@moltzap/protocol/identity";
|
|
11
|
+
import { AgentKey } from "@moltzap/protocol/identity";
|
|
12
|
+
import { getMoltZapConfigDir, getMoltZapConfigPath } from "./local-paths.js";
|
|
13
|
+
// ─── Branded names ─────────────────────────────────────────────────────────
|
|
14
|
+
const NAME_PATTERN = /^[a-z0-9][a-z0-9-]{1,30}[a-z0-9]$/;
|
|
15
|
+
const PROFILE_NAME_REASON = "must be 3-32 chars, lowercase alphanumeric and hyphens, cannot start or end with a hyphen";
|
|
16
|
+
const CONFIG_FILE_MODE = 0o600;
|
|
17
|
+
const JSON_INDENT_SPACES = 2;
|
|
18
|
+
const getConfigDir = getMoltZapConfigDir;
|
|
19
|
+
const getConfigFilePathSync = getMoltZapConfigPath;
|
|
20
|
+
const STRICT_PARSE_OPTIONS = { onExcessProperty: "error" };
|
|
21
|
+
// ─── Records ───────────────────────────────────────────────────────────────
|
|
22
|
+
export const ProfileName = Schema.String.pipe(Schema.pattern(NAME_PATTERN), Schema.brand("ProfileName"));
|
|
23
|
+
const ProfileRecordSchema = Schema.Struct({
|
|
24
|
+
agentId: AgentId,
|
|
25
|
+
apiKey: AgentKey,
|
|
26
|
+
agentName: Schema.String,
|
|
27
|
+
});
|
|
28
|
+
const ProfileMapSchema = Schema.Record({
|
|
29
|
+
key: ProfileName,
|
|
30
|
+
value: ProfileRecordSchema,
|
|
31
|
+
});
|
|
32
|
+
const ProfileFileSchema = Schema.Struct({
|
|
33
|
+
profiles: Schema.optional(ProfileMapSchema),
|
|
34
|
+
});
|
|
35
|
+
const ProfileFileTextSchema = Schema.parseJson(ProfileFileSchema, {
|
|
36
|
+
space: JSON_INDENT_SPACES,
|
|
37
|
+
});
|
|
38
|
+
export class ProfileNotFoundError extends Data.TaggedError("ProfileNotFoundError") {
|
|
39
|
+
}
|
|
40
|
+
export class ProfileInvalidNameError extends Data.TaggedError("ProfileInvalidNameError") {
|
|
41
|
+
}
|
|
42
|
+
export class ProfileConfigReadError extends Data.TaggedError("ProfileConfigReadError") {
|
|
43
|
+
}
|
|
44
|
+
export class ProfileConfigWriteError extends Data.TaggedError("ProfileConfigWriteError") {
|
|
45
|
+
}
|
|
46
|
+
// ─── Public API ────────────────────────────────────────────────────────────
|
|
47
|
+
/**
|
|
48
|
+
* Parse and brand a raw profile name. Rejects the empty string and any
|
|
49
|
+
* string that fails NAME_PATTERN.
|
|
50
|
+
*/
|
|
51
|
+
export const parseProfileName = (raw) => {
|
|
52
|
+
return Schema.decodeUnknown(ProfileName)(raw).pipe(Effect.catchTag("ParseError", () => Effect.fail(new ProfileInvalidNameError({
|
|
53
|
+
name: raw,
|
|
54
|
+
reason: raw.length === 0 ? "empty string" : PROFILE_NAME_REASON,
|
|
55
|
+
}))));
|
|
56
|
+
};
|
|
57
|
+
const readProfileFileText = (configPath) => FileSystem.FileSystem.pipe(Effect.flatMap((fileSystem) => fileSystem
|
|
58
|
+
.exists(configPath)
|
|
59
|
+
.pipe(Effect.flatMap((exists) => exists
|
|
60
|
+
? fileSystem.readFileString(configPath, "utf-8")
|
|
61
|
+
: Effect.succeed(null)))), Effect.provide(NodeFileSystem.layer), Effect.either, Effect.flatMap(Either.match({
|
|
62
|
+
onLeft: (cause) => Effect.fail(new ProfileConfigReadError({ path: configPath, cause })),
|
|
63
|
+
onRight: (value) => Effect.succeed(value),
|
|
64
|
+
})));
|
|
65
|
+
const decodeProfileFileText = (configPath, text) => Schema.decodeUnknown(ProfileFileTextSchema, STRICT_PARSE_OPTIONS)(text).pipe(Effect.either, Effect.flatMap(Either.match({
|
|
66
|
+
onLeft: (cause) => Effect.fail(new ProfileConfigReadError({ path: configPath, cause })),
|
|
67
|
+
onRight: Effect.succeed,
|
|
68
|
+
})));
|
|
69
|
+
const readProfileFile = () => Effect.gen(function* () {
|
|
70
|
+
const configPath = getConfigFilePathSync();
|
|
71
|
+
const text = yield* readProfileFileText(configPath);
|
|
72
|
+
if (text === null) {
|
|
73
|
+
return { file: {}, existed: false };
|
|
74
|
+
}
|
|
75
|
+
const file = yield* decodeProfileFileText(configPath, text);
|
|
76
|
+
return { file, existed: true };
|
|
77
|
+
});
|
|
78
|
+
function profilesFromFile(file) {
|
|
79
|
+
return new Map(Object.entries(file.profiles ?? {}));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Load the full layered config view. Missing file resolves to an empty
|
|
83
|
+
* view; malformed file surfaces as ProfileConfigReadError. No silent
|
|
84
|
+
* defaults on parse error.
|
|
85
|
+
*
|
|
86
|
+
* The file schema is strict: stale fields and malformed profile entries fail
|
|
87
|
+
* decode instead of being silently ignored.
|
|
88
|
+
*/
|
|
89
|
+
export const loadLayeredConfig = Effect.gen(function* () {
|
|
90
|
+
const { file } = yield* readProfileFile();
|
|
91
|
+
return {
|
|
92
|
+
profiles: profilesFromFile(file),
|
|
93
|
+
};
|
|
94
|
+
}).pipe(Effect.withSpan("loadLayeredConfig"));
|
|
95
|
+
/**
|
|
96
|
+
* Resolve a named profile record. CLI transport selection uses only
|
|
97
|
+
* `agentId`; daemon startup consumes the redacted `apiKey`.
|
|
98
|
+
*/
|
|
99
|
+
export const resolveProfileRecord = (name) => Effect.gen(function* () {
|
|
100
|
+
const layered = yield* loadLayeredConfig;
|
|
101
|
+
const found = layered.profiles.get(name);
|
|
102
|
+
if (found === undefined) {
|
|
103
|
+
return yield* Effect.fail(new ProfileNotFoundError({ name }));
|
|
104
|
+
}
|
|
105
|
+
return found;
|
|
106
|
+
}).pipe(Effect.withSpan("resolveProfileRecord"));
|
|
107
|
+
function nextProfileFile(file, name, record) {
|
|
108
|
+
return {
|
|
109
|
+
profiles: {
|
|
110
|
+
...file.profiles,
|
|
111
|
+
[name]: record,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const encodeProfileFileText = (configPath, file) => Schema.encode(ProfileFileTextSchema, STRICT_PARSE_OPTIONS)(file).pipe(Effect.either, Effect.flatMap(Either.match({
|
|
116
|
+
onLeft: (cause) => Effect.fail(new ProfileConfigWriteError({ path: configPath, cause })),
|
|
117
|
+
onRight: Effect.succeed,
|
|
118
|
+
})));
|
|
119
|
+
const writeProfileFile = (next) => {
|
|
120
|
+
const configDir = getConfigDir();
|
|
121
|
+
const configPath = getConfigFilePathSync();
|
|
122
|
+
return FileSystem.FileSystem.pipe(Effect.flatMap((fileSystem) => encodeProfileFileText(configPath, next).pipe(Effect.flatMap((text) => fileSystem.makeDirectory(configDir, { recursive: true }).pipe(Effect.zipRight(fileSystem.writeFileString(configPath, `${text}\n`, {
|
|
123
|
+
mode: CONFIG_FILE_MODE,
|
|
124
|
+
})))))), Effect.provide(NodeFileSystem.layer), Effect.either, Effect.flatMap(Either.match({
|
|
125
|
+
onLeft: (cause) => Effect.fail(new ProfileConfigWriteError({ path: configPath, cause })),
|
|
126
|
+
onRight: (value) => Effect.succeed(value),
|
|
127
|
+
})));
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Persist a new profile record under `profiles.<name>`.
|
|
131
|
+
*/
|
|
132
|
+
export const writeProfile = (name, record) => Effect.gen(function* () {
|
|
133
|
+
const { file } = yield* readProfileFile();
|
|
134
|
+
yield* writeProfileFile(nextProfileFile(file, name, record));
|
|
135
|
+
}).pipe(Effect.withSpan("writeProfile"));
|
|
136
|
+
/**
|
|
137
|
+
* `--no-persist` contract for `moltzap register`: no file under
|
|
138
|
+
* `$HOME/.moltzap/` is created or modified. Returns the record so the caller
|
|
139
|
+
* can print it; does no I/O under that tree.
|
|
140
|
+
*
|
|
141
|
+
* The register command invokes either `writeProfile` (default) or
|
|
142
|
+
* `emitNoPersist` (when the flag is set). The register handler never calls
|
|
143
|
+
* both paths on the same invocation.
|
|
144
|
+
*
|
|
145
|
+
* The register command pipes the returned record through the printer,
|
|
146
|
+
* which writes non-secret registration details to stdout.
|
|
147
|
+
*/
|
|
148
|
+
export const emitNoPersist = (record) => Effect.succeed({ record });
|
|
149
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,8EAA8E;AAE9E,MAAM,YAAY,GAAG,mCAAmC,CAAC;AACzD,MAAM,mBAAmB,GACvB,2FAA2F,CAAC;AAE9F,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD,MAAM,oBAAoB,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAW,CAAC;AAEpE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAC3C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAC5B,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAC5B,CAAC;AAOF,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,OAAO;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s.d.ts","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAU,GAAG,EAAE,MAAM,QAAQ,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAG,CAAiC,CAAC;AAEhF,6EAA6E;AAC7E,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,CAAC,EACxB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EACxB,KAAK,CAAC,EACN,MAAM,MAAM,CAAC,KACZ,CAAgD,CAAC"}
|
package/dist/refs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,GAAe,EAAK,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAEhF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,CAAwB,EACxB,GAAM,EACN,IAAa,EACV,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HashMap } from "effect";
|
|
2
|
-
import type { ConversationId
|
|
2
|
+
import type { ConversationId } from "@moltzap/protocol/conversation";
|
|
3
|
+
import type { TaskId } from "@moltzap/protocol/task";
|
|
3
4
|
/**
|
|
4
5
|
* Helpers extracted from `service.ts → markConversationArchived` to keep
|
|
5
6
|
* the function under the 50-line ESLint cap and the file under the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-archive-purge.d.ts","sourceRoot":"","sources":["../src/service-archive-purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-archive-purge.d.ts","sourceRoot":"","sources":["../src/service-archive-purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;GAIG;AAEH,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,OAAO,CAAC,OAAO,CAChB,MAAM,EACN;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;CAAE,CACrE,EACD,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,OAAO,CAChB,MAAM,EACN;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;CAAE,CACrE,CAWA;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC/D,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAY1D;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAC5E,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAavE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-archive-purge.js","sourceRoot":"","sources":["../src/service-archive-purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"service-archive-purge.js","sourceRoot":"","sources":["../src/service-archive-purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAIjC;;;;GAIG;AAEH,MAAM,UAAU,sBAAsB,CACpC,CAGC,EACD,cAA8B;IAK9B,IAAI,IAAI,GAAG,OAAO,CAAC,KAAK,EAGrB,CAAC;IACJ,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc,EAAE,CAAC;YAC5C,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,KAA+D,EAC/D,cAA8B;IAE9B,IAAI,IAAI,GAAG,OAAO,CAAC,KAAK,EAA2C,CAAC;IACpE,KAAK,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;YAClC,IAAI,GAAG,OAAO,CAAC,GAAG,CAChB,IAAI,EACJ,UAAU,EACV,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CACxC,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAA4E,EAC5E,cAA8B;IAE9B,IAAI,IAAI,GAAG,OAAO,CAAC,KAAK,EAGrB,CAAC;IACJ,KAAK,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,IAAI,GAAG,OAAO,CAAC,GAAG,CAChB,IAAI,EACJ,UAAU,EACV,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CACxC,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { NotificationDelivery } from "@moltzap/protocol/rpc";
|
|
2
|
+
import type { AnyNotificationDefinition } from "@moltzap/protocol/socket/catalog";
|
|
3
|
+
import type { Message } from "@moltzap/protocol/message";
|
|
2
4
|
import { HashMap } from "effect";
|
|
3
|
-
import type { ConversationMeta, CrossConversationEntry } from "
|
|
4
|
-
declare const ServiceInputError_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 & {
|
|
5
|
-
readonly _tag: "ServiceInputError";
|
|
6
|
-
} & Readonly<A>;
|
|
7
|
-
export declare class ServiceInputError extends ServiceInputError_base<{
|
|
8
|
-
readonly message: string;
|
|
9
|
-
}> {
|
|
10
|
-
}
|
|
5
|
+
import type { ConversationMeta, CrossConversationEntry } from "./service.js";
|
|
11
6
|
export interface CrossConvState {
|
|
12
7
|
readonly messagesMap: HashMap.HashMap<string, ReadonlyArray<Message>>;
|
|
13
8
|
readonly conversationsMap: HashMap.HashMap<string, ConversationMeta>;
|
|
@@ -23,10 +18,9 @@ interface BuiltContextEntries {
|
|
|
23
18
|
readonly entries: CrossConversationEntry[];
|
|
24
19
|
readonly pendingAdvances: ReadonlyArray<readonly [string, string]>;
|
|
25
20
|
}
|
|
26
|
-
export declare const renderPart: (part: Part) => string;
|
|
27
21
|
export declare function newMessagesForConversation(convId: string, messages: ReadonlyArray<Message>, viewMarkers: HashMap.HashMap<string, string>, currentConvId: string): ReadonlyArray<Message>;
|
|
28
22
|
export declare function makeContextCandidate(convId: string, newMsgs: ReadonlyArray<Message>): ContextCandidate;
|
|
29
23
|
export declare function buildContextEntries(candidates: ReadonlyArray<ContextCandidate>, state: CrossConvState, maxMessagesPerConv: number): BuiltContextEntries;
|
|
30
|
-
export declare function notificationTraceRecord(notification:
|
|
24
|
+
export declare function notificationTraceRecord(notification: NotificationDelivery<AnyNotificationDefinition>, agentId: string | undefined): Record<string, unknown>;
|
|
31
25
|
export {};
|
|
32
26
|
//# sourceMappingURL=service-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-helpers.d.ts","sourceRoot":"","sources":["../src/service-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAU,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAM7E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACrE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC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./message-rendering.js";
|
|
3
3
|
import { getOr } from "./refs.js";
|
|
4
4
|
const MILLISECONDS_PER_MINUTE = 60_000;
|
|
5
|
-
export class ServiceInputError extends Data.TaggedError("ServiceInputError") {
|
|
6
|
-
}
|
|
7
5
|
const isPlainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
6
|
const recordOrEmpty = (value) => isPlainRecord(value) ? value : {};
|
|
9
7
|
const recordProperty = (record, key) => {
|
|
@@ -14,11 +12,6 @@ const stringProperty = (record, key) => {
|
|
|
14
12
|
const value = record[key];
|
|
15
13
|
return typeof value === "string" ? value : undefined;
|
|
16
14
|
};
|
|
17
|
-
export const renderPart = Match.type().pipe(Match.discriminatorsExhaustive("type")({
|
|
18
|
-
text: (text) => text.text,
|
|
19
|
-
image: () => "[image]",
|
|
20
|
-
file: (file) => `[file: ${file.name}]`,
|
|
21
|
-
}));
|
|
22
15
|
export function newMessagesForConversation(convId, messages, viewMarkers, currentConvId) {
|
|
23
16
|
if (convId === currentConvId || messages.length === 0)
|
|
24
17
|
return [];
|