@cello-protocol/daemon 0.0.228 → 0.0.230

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.
Files changed (48) hide show
  1. package/dist/channel-collect-tick.d.ts +36 -0
  2. package/dist/channel-collect-tick.d.ts.map +1 -0
  3. package/dist/channel-collect-tick.js +133 -0
  4. package/dist/channel-collect-tick.js.map +1 -0
  5. package/dist/channel-collector.d.ts +99 -0
  6. package/dist/channel-collector.d.ts.map +1 -0
  7. package/dist/channel-collector.js +249 -0
  8. package/dist/channel-collector.js.map +1 -0
  9. package/dist/channel-config-store.d.ts +33 -0
  10. package/dist/channel-config-store.d.ts.map +1 -0
  11. package/dist/channel-config-store.js +61 -0
  12. package/dist/channel-config-store.js.map +1 -0
  13. package/dist/channel-inbox-store.d.ts +46 -0
  14. package/dist/channel-inbox-store.d.ts.map +1 -0
  15. package/dist/channel-inbox-store.js +88 -0
  16. package/dist/channel-inbox-store.js.map +1 -0
  17. package/dist/channel-log-store.d.ts +14 -0
  18. package/dist/channel-log-store.d.ts.map +1 -1
  19. package/dist/channel-log-store.js +58 -0
  20. package/dist/channel-log-store.js.map +1 -1
  21. package/dist/channel-publish-handlers.d.ts +42 -0
  22. package/dist/channel-publish-handlers.d.ts.map +1 -0
  23. package/dist/channel-publish-handlers.js +212 -0
  24. package/dist/channel-publish-handlers.js.map +1 -0
  25. package/dist/channel-publish-wiring.d.ts +41 -0
  26. package/dist/channel-publish-wiring.d.ts.map +1 -0
  27. package/dist/channel-publish-wiring.js +124 -0
  28. package/dist/channel-publish-wiring.js.map +1 -0
  29. package/dist/channel-publisher.d.ts +189 -0
  30. package/dist/channel-publisher.d.ts.map +1 -0
  31. package/dist/channel-publisher.js +394 -0
  32. package/dist/channel-publisher.js.map +1 -0
  33. package/dist/channel-relay-client.d.ts +88 -0
  34. package/dist/channel-relay-client.d.ts.map +1 -0
  35. package/dist/channel-relay-client.js +180 -0
  36. package/dist/channel-relay-client.js.map +1 -0
  37. package/dist/channel-subscription-store.d.ts +66 -0
  38. package/dist/channel-subscription-store.d.ts.map +1 -0
  39. package/dist/channel-subscription-store.js +109 -0
  40. package/dist/channel-subscription-store.js.map +1 -0
  41. package/dist/daemon.d.ts.map +1 -1
  42. package/dist/daemon.js +14 -0
  43. package/dist/daemon.js.map +1 -1
  44. package/dist/gateway-config-handlers.d.ts +2 -2
  45. package/dist/gateway-config-handlers.d.ts.map +1 -1
  46. package/dist/gateway-config-handlers.js +37 -12
  47. package/dist/gateway-config-handlers.js.map +1 -1
  48. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-publish-handlers.js","sourceRoot":"","sources":["../src/channel-publish-handlers.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,yBAAyB,EAAsB,MAAM,2BAA2B,CAAC;AAmB1F,SAAS,SAAS,CAAC,IAAwB,EAAE,MAA2C,EAAE,YAAoB;IAE5G,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,OAAO,CAAuB,CAAC,CAAC;IAClG,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE;gBACN,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB;gBACrC,QAAQ,EAAE,yEAAyE;aACpF;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,WAAW,CAAC,MAA2C;IAE9D,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;IAChC,8FAA8F;IAC9F,wEAAwE;IACxE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9D,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE;gBACN,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AAM,GAAG,GAAgD,EAAE,CAAC;QAC5D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC1F,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * M16 018-PUBCOLLECT — everything the channel publishing verbs need, assembled in one place.
3
+ *
4
+ * ⚠️ The publisher is built PER CHANNEL AGENT and only when its key is loaded — a channel is an
5
+ * agent whose key this daemon holds, and a publisher without one could sign nothing. `null` makes
6
+ * the verb answer `channel_unknown`, which is the truth: this daemon does not publish for it.
7
+ *
8
+ * Order 017's own wiring gap is why this module is registered in the same commit as the handlers it
9
+ * serves: a handler nothing calls is a feature that does not exist, and `startup-ordering.test.ts`
10
+ * is what caught exactly that here.
11
+ */
12
+ import type { DaemonDatabase } from "./sqlcipher-db.js";
13
+ import type { Logger } from "./types.js";
14
+ import type { CelloNode } from "@cello-protocol/transport";
15
+ import type { KeyProvider } from "@cello-protocol/crypto";
16
+ import type { ScreenContext, ScreenVerdict } from "@cello-protocol/gateway";
17
+ type Handler = (params: Record<string, unknown> | undefined, connectionId: string) => Promise<unknown>;
18
+ export interface ChannelPublishWiringDeps {
19
+ handlers: Map<string, Handler>;
20
+ logger: Logger;
21
+ getDb: () => DaemonDatabase;
22
+ getNode: () => CelloNode | null;
23
+ screenOutbound: (content: Uint8Array, ctx: ScreenContext) => Promise<ScreenVerdict>;
24
+ /** Every agent this daemon loaded, read per lookup so one added after boot is publishable. */
25
+ loadedAgents: ReadonlyArray<{
26
+ pubkey: string;
27
+ keyProvider: KeyProvider;
28
+ }>;
29
+ keyProviders: Map<string, KeyProvider>;
30
+ resolveCurrentAgent: (connectionId: string, explicitAgent?: string) => string | null;
31
+ /**
32
+ * Online AND not explicitly switched off — the same pair every other background loop here reads.
33
+ * Collecting for an agent the operator switched off is the kill switch failing to switch off.
34
+ */
35
+ isAgentOnline: (agentId: string) => boolean;
36
+ }
37
+ export declare function wireChannelPublishing(deps: ChannelPublishWiringDeps): {
38
+ stop: () => void;
39
+ };
40
+ export {};
41
+ //# sourceMappingURL=channel-publish-wiring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-publish-wiring.d.ts","sourceRoot":"","sources":["../src/channel-publish-wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAW5E,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvG,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,OAAO,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpF,8FAA8F;IAC9F,YAAY,EAAE,aAAa,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAC1E,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,mBAAmB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACrF;;;OAGG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,wBAAwB,GAAG;IAAE,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,CAwH1F"}
@@ -0,0 +1,124 @@
1
+ import { registerChannelPublishHandlers } from "./channel-publish-handlers.js";
2
+ import { ChannelPublisher } from "./channel-publisher.js";
3
+ import { ChannelLogStore } from "./channel-log-store.js";
4
+ import { ChannelConfigStore } from "./channel-config-store.js";
5
+ import { ChannelRelayClient } from "./channel-relay-client.js";
6
+ import { ChannelCollector } from "./channel-collector.js";
7
+ import { ChannelSubscriptionStore } from "./channel-subscription-store.js";
8
+ import { ChannelInboxStore } from "./channel-inbox-store.js";
9
+ import { createChannelCollectTicker } from "./channel-collect-tick.js";
10
+ export function wireChannelPublishing(deps) {
11
+ const { logger, keyProviders } = deps;
12
+ const log = new ChannelLogStore(deps.getDb(), logger);
13
+ const config = new ChannelConfigStore(deps.getDb(), logger);
14
+ const relay = new ChannelRelayClient({ getNode: deps.getNode, logger });
15
+ /**
16
+ * The channel key is looked up BY PUBKEY, because that is what a post is signed with and what a
17
+ * subscriber verifies against — the agent NAME is a display label and may be reused.
18
+ */
19
+ const channelKeyByPubkey = (channelHex) => {
20
+ const want = channelHex.toLowerCase();
21
+ const match = deps.loadedAgents.find((a) => a.pubkey.toLowerCase() === want);
22
+ return match ? match.keyProvider : null;
23
+ };
24
+ const buildPublisher = (agentName) => {
25
+ if (!keyProviders.has(agentName))
26
+ return null;
27
+ return new ChannelPublisher({
28
+ logger,
29
+ log,
30
+ deposit: (addr, req) => relay.deposit(addr, { post_cbor: req.post_cbor }),
31
+ depositInfo: (addr, req) => relay.depositInfo(addr, { info_cbor: req.info_cbor }),
32
+ prune: (addr, req) => relay.prune(addr, {
33
+ channel_pubkey: Buffer.from(req.channelHex, "hex"),
34
+ through_seq: req.throughSeq,
35
+ time_ms: req.timeMs,
36
+ signature: req.signature,
37
+ }),
38
+ relayHead: (addr, channelHex) => relay.head(addr, Buffer.from(channelHex, "hex")),
39
+ // The screen has no session to name, so it names what it IS screening. Borrowing a session id
40
+ // would file channel posts in another conversation's governance history.
41
+ screenOutbound: (bytes, ctx) => deps.screenOutbound(bytes, {
42
+ direction: "outbound",
43
+ agentName: ctx.agentName,
44
+ sessionId: `channel:${agentName}`,
45
+ ...(ctx.correlationId !== undefined ? { correlationId: ctx.correlationId } : {}),
46
+ }),
47
+ getChannelKey: channelKeyByPubkey,
48
+ getAgentKey: (name) => keyProviders.get(name) ?? null,
49
+ /**
50
+ * ⚠️ **THERE IS NO GROUP KEY UNTIL 019**, so a private channel REFUSES to publish rather than
51
+ * depositing a body that looks encrypted and is not. Publishing plaintext under an `access`
52
+ * that promises members-only would put the operator's content on two relays under a claim
53
+ * this code cannot keep — the one failure the whole encrypt step exists to prevent.
54
+ */
55
+ encryptBody: () => Promise.reject(new Error("channel_group_key_unavailable")),
56
+ channelInfo: (channelHex) => config.get(channelHex),
57
+ });
58
+ };
59
+ registerChannelPublishHandlers({
60
+ handlers: deps.handlers,
61
+ logger,
62
+ resolveCurrentAgent: deps.resolveCurrentAgent,
63
+ getPublisher: buildPublisher,
64
+ setChannelConfig: (agentName, channelHex, cfg) => {
65
+ // The channel key must be one this daemon HOLDS. Recording relays for a channel we cannot
66
+ // sign for would leave every later verb failing on a key lookup, which describes neither the
67
+ // mistake nor how to correct it.
68
+ if (channelKeyByPubkey(channelHex) === null) {
69
+ return {
70
+ ok: false, reason: "channel_key_not_held",
71
+ guidance: "This daemon does not hold that channel's key. A channel is an agent — create it with 'cello create-agent' and use its public key here.",
72
+ };
73
+ }
74
+ if (!keyProviders.has(agentName)) {
75
+ return { ok: false, reason: "no_such_agent", guidance: `${agentName} is not an agent this daemon holds.` };
76
+ }
77
+ config.set(channelHex, cfg, Date.now());
78
+ return { ok: true };
79
+ },
80
+ });
81
+ /**
82
+ * ⚠️ THE SUBSCRIBER HALF, AND IT NEEDS A SCHEDULE TO EXIST AT ALL. There is no inbound event for a
83
+ * channel post — the relay holds a queue and waits to be asked — so a collector nobody calls is a
84
+ * subscriber who receives nothing while every component reports healthy.
85
+ */
86
+ const subscriptions = new ChannelSubscriptionStore(deps.getDb(), logger);
87
+ const inbox = new ChannelInboxStore(deps.getDb(), logger);
88
+ const collector = new ChannelCollector({
89
+ logger,
90
+ subscriptions,
91
+ inbox,
92
+ fetch: (addr, req) => relay.fetch(addr, req),
93
+ /**
94
+ * ⚠️ **PUBLIC CHANNELS ONLY, UNTIL 019.** `undefined` means "send no auth", which is correct for
95
+ * a public channel and correct nowhere else: 019 owns the fetch key. A non-public channel is
96
+ * refused by the RELAY rather than silently fetched — the failure is visible and belongs to the
97
+ * side that can check it.
98
+ */
99
+ fetchAuth: () => Promise.resolve(undefined),
100
+ // The reader count is best-effort and never affects delivery, so declaring nothing costs only
101
+ // the publisher's view of how many read a post. 019 records the membership this reads from.
102
+ localAgentKeys: () => [],
103
+ /**
104
+ * ⚠️ NOT IMPLEMENTED, AND IT SAYS SO. Asking the publisher to re-deposit needs a session to the
105
+ * publishing agent, which is 019's join path. Until then the OTHER RELAY is the whole repair —
106
+ * `repairGaps` tries that first and usually closes the gap there. A silent no-op would let a
107
+ * permanent gap look like one still being worked on.
108
+ */
109
+ requestRepair: (_agentId, channelHex, from, to) => {
110
+ logger.warn("channel.repair.unavailable", {
111
+ channel_pubkey: channelHex, from, to,
112
+ impact: "neither relay holds these posts; asking the publisher directly needs the join path (019)",
113
+ });
114
+ return Promise.resolve();
115
+ },
116
+ });
117
+ const ticker = createChannelCollectTicker({
118
+ logger, collector, subscriptions,
119
+ isAgentOnline: deps.isAgentOnline,
120
+ });
121
+ ticker.start();
122
+ return { stop: () => { ticker.stop(); } };
123
+ }
124
+ //# sourceMappingURL=channel-publish-wiring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-publish-wiring.js","sourceRoot":"","sources":["../src/channel-publish-wiring.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAqBvE,MAAM,UAAU,qBAAqB,CAAC,IAA8B;IAClE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEtC,MAAM,GAAG,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,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AM,EAAE,0FAA0F;aACnG,CAAC,CAAC;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,0BAA0B,CAAC;QACxC,MAAM,EAAE,SAAS,EAAE,aAAa;QAChC,aAAa,EAAE,IAAI,CAAC,aAAa;KAClC,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * ChannelPublisher — M16 018-PUBCOLLECT, the publishing half.
3
+ *
4
+ * A channel publishes through **two relays of its own choosing**, so one being down does not stop
5
+ * delivery. Nothing coordinates them: each holds its own queue, and the subscriber takes the union.
6
+ *
7
+ * ─── The order of operations, and why it is not negotiable ───────────────────────────────────
8
+ *
9
+ * 1. screen the title and body — refuse, never warn-and-send
10
+ * 2. encrypt the body (unless public)
11
+ * 3. take the next number, sign with BOTH keys
12
+ * 4. APPEND TO THE LOG
13
+ * 5. deposit on both relays, store each receipt
14
+ *
15
+ * ⚠️ **STEP 4 IS BEFORE STEP 5, AND THAT IS THE WHOLE DESIGN.** A post that reached a relay but not
16
+ * the log is invisible to its own publisher: it cannot be resent to a relay that lost it, cannot be
17
+ * pruned, and cannot be proved. The log is the durable copy; the network is the optimistic part.
18
+ * `resendMissing` exists precisely because the log outlives any relay's memory.
19
+ *
20
+ * ⚠️ **ONE RELAY FAILING IS NOT A FAILED PUBLISH.** Treating it as one would make a two-relay design
21
+ * strictly less available than a single-relay design, which inverts the reason for having two.
22
+ * Both failing gives `no_relay_accepted` — and the post STAYS in the log, because the next attempt
23
+ * has to send the same signed bytes rather than a new post at a new number.
24
+ */
25
+ import type { Logger } from "./types.js";
26
+ import type { KeyProvider } from "@cello-protocol/crypto";
27
+ import { type ChannelAccess } from "@cello-protocol/protocol-types";
28
+ import { ChannelLogStore } from "./channel-log-store.js";
29
+ /** How the publisher reaches a relay. The transport is the caller's; this owns the decisions. */
30
+ export type RelayDepositSeam = (relay: string, req: {
31
+ post_cbor: Uint8Array;
32
+ }) => Promise<{
33
+ ok: true;
34
+ receipt_cbor: Uint8Array;
35
+ } | {
36
+ ok: false;
37
+ reason: string;
38
+ skew_ms?: number;
39
+ }>;
40
+ /** Deposit the channel's info record. Separate from a post: it carries no sequence and no receipt. */
41
+ export type RelayInfoDepositSeam = (relay: string, req: {
42
+ info_cbor: Uint8Array;
43
+ }) => Promise<{
44
+ ok: true;
45
+ } | {
46
+ ok: false;
47
+ reason: string;
48
+ }>;
49
+ /** Ask a relay to drop everything through a post number, oldest end only. */
50
+ export type RelayPruneSeam = (relay: string, req: {
51
+ channelHex: string;
52
+ throughSeq: number;
53
+ timeMs: number;
54
+ signature: Uint8Array;
55
+ }) => Promise<{
56
+ ok: true;
57
+ dropped?: number;
58
+ } | {
59
+ ok: false;
60
+ reason: string;
61
+ }>;
62
+ export type ScreenVerdict = {
63
+ disposition: "allow" | "block" | "warn" | "redact";
64
+ reason?: string;
65
+ };
66
+ /**
67
+ * Gap between deposits during a refill, so a long backlog stays under the relay's per-publisher
68
+ * rate limit. Only `resendMissing` paces — an ordinary publish is two deposits and pacing it would
69
+ * add latency to every post to protect against a burst that cannot happen.
70
+ */
71
+ export declare const DEFAULT_RESEND_PACE_MS = 50;
72
+ export interface ChannelPublisherOptions {
73
+ logger: Logger;
74
+ log: ChannelLogStore;
75
+ deposit: RelayDepositSeam;
76
+ depositInfo: RelayInfoDepositSeam;
77
+ /**
78
+ * Optional ONLY so a caller that cannot prune says so: an absent seam reports each relay as
79
+ * `relay_prune_unavailable`, never as a successful prune.
80
+ */
81
+ prune?: RelayPruneSeam;
82
+ /**
83
+ * Where a relay's queue begins and ends. Optional: without it `resendMissing` re-sends everything
84
+ * logged, which is correct but chattier. See the note at its use for why a RECEIPT is not the
85
+ * right question to ask.
86
+ */
87
+ relayHead?: (relay: string, channelHex: string) => Promise<{
88
+ first_held_seq: number | null;
89
+ last_seq: number | null;
90
+ }>;
91
+ screenOutbound: (bytes: Uint8Array, ctx: {
92
+ agentName: string;
93
+ correlationId?: string;
94
+ }) => Promise<ScreenVerdict>;
95
+ getChannelKey: (channelHex: string) => KeyProvider | null;
96
+ getAgentKey: (agentName: string) => KeyProvider | null;
97
+ /** 019 owns the group key; the publisher must not be able to tell what this does. */
98
+ encryptBody: (plaintext: Uint8Array, channelHex: string) => Promise<Uint8Array>;
99
+ /** Overridable so a test can refill without waiting; production takes the default. */
100
+ resendPaceMs?: number;
101
+ channelInfo: (channelHex: string) => {
102
+ access: ChannelAccess;
103
+ relays: string[];
104
+ guidance: string;
105
+ retention_seconds: number;
106
+ } | null;
107
+ now?: () => number;
108
+ }
109
+ export type PublishRefusal = "blocked_by_screen" | "channel_unknown" | "key_unavailable" | "no_relay_accepted" | "post_invalid";
110
+ export interface DepositOutcome {
111
+ relay: string;
112
+ /** Did this relay TAKE the post. Nothing else belongs in this flag — see `receipt_unfiled`. */
113
+ ok: boolean;
114
+ reason?: string;
115
+ /** What the relay said our clock is off by, carried so the correction can use the largest. */
116
+ skew_ms?: number;
117
+ /**
118
+ * The relay took the post and its receipt could not be filed (unverifiable, or naming bytes this
119
+ * log does not hold). SEPARATE FROM `ok` on purpose: folding it in reported a post that is safely
120
+ * on two relays as `no_relay_accepted`, and sent the operator to resend something already there.
121
+ */
122
+ receipt_unfiled?: string;
123
+ }
124
+ export type PublishResult = {
125
+ ok: true;
126
+ seq: number;
127
+ deposited: DepositOutcome[];
128
+ } | {
129
+ ok: false;
130
+ reason: PublishRefusal;
131
+ detail?: string;
132
+ seq?: number;
133
+ deposited?: DepositOutcome[];
134
+ };
135
+ export declare class ChannelPublisher {
136
+ #private;
137
+ constructor(opts: ChannelPublisherOptions);
138
+ publish(agentName: string, channelHex: string, title: string, body: string, correlationId?: string): Promise<PublishResult>;
139
+ /**
140
+ * Re-deposit everything a relay has not receipted, oldest first.
141
+ *
142
+ * This is what refills a relay that lost content and what fills a newly added one — the same path,
143
+ * which is why it is exercised by ordinary operation rather than only by a crash.
144
+ */
145
+ resendMissing(agentName: string, channelHex: string, relay: string, correlationId?: string): Promise<{
146
+ deposited: number;
147
+ }>;
148
+ /**
149
+ * Prune the log, then tell both relays to drop the same range.
150
+ *
151
+ * ⚠️ **EACH RELAY'S OUTCOME IS THE ONE IT GAVE.** This used to report `ok: true` for every relay
152
+ * without contacting any of them, so an operator pruning 500 posts was shown two successful
153
+ * relays while both still held and served every post. A relay that is down is `ok: false` with its
154
+ * reason, and its copy survives until its own retention sweeps it — which is what retention is for.
155
+ */
156
+ pruneChannel(agentName: string, channelHex: string, throughSeq: number, correlationId?: string): Promise<{
157
+ pruned: number;
158
+ relays: Array<{
159
+ relay: string;
160
+ ok: boolean;
161
+ reason?: string;
162
+ }>;
163
+ }>;
164
+ /**
165
+ * Sign and deposit the channel's info record. Only the CHANNEL key signs it.
166
+ *
167
+ * ⚠️ **THE DEPOSIT IS THE POINT, NOT THE SIGNATURE.** The record is the only way a subscriber
168
+ * learns a channel's relays, access and admin key. This used to sign it, log
169
+ * `channel.info.published` and return the bytes to the caller without contacting a relay — so an
170
+ * operator was told their channel was published while no one could find it. The event now names
171
+ * only the relays that actually took it.
172
+ */
173
+ publishInfo(agentName: string, channelHex: string, correlationId?: string): Promise<{
174
+ ok: true;
175
+ info_cbor: Uint8Array;
176
+ relays: Array<{
177
+ relay: string;
178
+ ok: boolean;
179
+ reason?: string;
180
+ }>;
181
+ } | {
182
+ ok: false;
183
+ reason: PublishRefusal;
184
+ detail?: string;
185
+ }>;
186
+ /** The relays this channel publishes to, so a caller can refill all of them without naming one. */
187
+ relaysFor(channelHex: string): string[];
188
+ }
189
+ //# sourceMappingURL=channel-publisher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-publisher.d.ts","sourceRoot":"","sources":["../src/channel-publisher.ts"],"names":[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