@fabric-harness/channels 0.17.3 → 0.18.2
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/README.md +84 -0
- package/dist/buzz-decisions.d.ts +174 -0
- package/dist/buzz-decisions.d.ts.map +1 -0
- package/dist/buzz-decisions.js +209 -0
- package/dist/buzz-decisions.js.map +1 -0
- package/dist/buzz-kinds.d.ts +34 -0
- package/dist/buzz-kinds.d.ts.map +1 -0
- package/dist/buzz-kinds.js +34 -0
- package/dist/buzz-kinds.js.map +1 -0
- package/dist/buzz-tail.d.ts +113 -0
- package/dist/buzz-tail.d.ts.map +1 -0
- package/dist/buzz-tail.js +305 -0
- package/dist/buzz-tail.js.map +1 -0
- package/dist/buzz.d.ts +166 -0
- package/dist/buzz.d.ts.map +1 -0
- package/dist/buzz.js +340 -0
- package/dist/buzz.js.map +1 -0
- package/dist/compatibility.d.ts +7 -0
- package/dist/compatibility.d.ts.map +1 -1
- package/dist/compatibility.js +1 -0
- package/dist/compatibility.js.map +1 -1
- package/package.json +15 -2
package/README.md
CHANGED
|
@@ -40,4 +40,88 @@ export default createAgent(({ id }) => {
|
|
|
40
40
|
});
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
## Buzz (preview)
|
|
44
|
+
|
|
45
|
+
[Buzz](https://github.com/block/buzz) is a self-hostable Nostr-based workspace where humans and
|
|
46
|
+
agents share channels. Unlike webhook vendors, Buzz pushes over a NIP-01 WebSocket, so ingress uses
|
|
47
|
+
the `buzz-tail` transport shim: it holds a NIP-42-authenticated subscription and forwards events to
|
|
48
|
+
the channel's `/events` route inside a timestamped `X-Fabric-Signature: v1=` HMAC envelope (same
|
|
49
|
+
route a future Buzz workflow `call_webhook` egress can target). The handler additionally verifies
|
|
50
|
+
each inner event's Schnorr signature, so the acting `actor` is the cryptographically proven author
|
|
51
|
+
pubkey. Requires `nostr-tools` (declared dependency; the only non-Fetch/WebCrypto adapter, hence
|
|
52
|
+
`status: preview` + `sdk: nostr-tools` in the compatibility contract).
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// .fabricharness/channels/buzz.ts
|
|
56
|
+
import { buzzPublicKey, createBuzzChannel } from '@fabric-harness/channels/buzz';
|
|
57
|
+
import { receiptStore } from '../state/buzz-receipts.js';
|
|
58
|
+
|
|
59
|
+
const channels = ['gtm-pipeline'];
|
|
60
|
+
|
|
61
|
+
export const channel = createBuzzChannel({
|
|
62
|
+
agent: 'assistant',
|
|
63
|
+
sharedSecret: process.env.BUZZ_ENVELOPE_SECRET!,
|
|
64
|
+
selfPubkey: buzzPublicKey(process.env.BUZZ_PRIVATE_KEY!),
|
|
65
|
+
community: 'acme',
|
|
66
|
+
channels,
|
|
67
|
+
decisionReceiptStore: receiptStore,
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
// tail process (Node >= 22), co-deployed with the app
|
|
73
|
+
import { startBuzzTail } from '@fabric-harness/channels/buzz-tail';
|
|
74
|
+
|
|
75
|
+
const channels = ['gtm-pipeline'];
|
|
76
|
+
|
|
77
|
+
startBuzzTail({
|
|
78
|
+
relayUrl: process.env.BUZZ_RELAY_URL!,
|
|
79
|
+
secretKey: process.env.BUZZ_PRIVATE_KEY!,
|
|
80
|
+
community: 'acme', // must equal the channel's server-owned community
|
|
81
|
+
channels, // same server-owned channel allowlist used by createBuzzChannel
|
|
82
|
+
forwardUrl: 'https://app/channels/buzz/events',
|
|
83
|
+
sharedSecret: process.env.BUZZ_ENVELOPE_SECRET!,
|
|
84
|
+
cursorStore, // REQUIRED and must be durable (file/db) — plan D15; a ~5-line
|
|
85
|
+
// file-backed implementation of BuzzCursorStore suffices on Node
|
|
86
|
+
onDeadLetter: (event, reason, status) => reconcileLater(event, reason, status),
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The tail is a durable consumer, not a best-effort reconnect loop: it persists a
|
|
91
|
+
cursor (advanced only after a 2xx forward or recorded dead-letter), backfills
|
|
92
|
+
over HTTP `POST /query` from `cursor - overlap` on every (re)start, forwards in
|
|
93
|
+
order with retry classification (408/429/5xx/network retry with bounded
|
|
94
|
+
backoff; other 4xx dead-letter to `onDeadLetter` for reconciliation), answers
|
|
95
|
+
NIP-42 challenges including `OK` acknowledgement and `CLOSED` re-subscription,
|
|
96
|
+
and drains + persists on `close()`. The channel route derives the tenant from
|
|
97
|
+
its own `community` option (server-owned configuration) and refuses envelopes
|
|
98
|
+
claiming any other community with 403 — the tenant is never taken from the
|
|
99
|
+
event or envelope.
|
|
100
|
+
|
|
101
|
+
Outbound tools: `postInBuzzChannel`, `replyInBuzzThread`, `addBuzzReaction`. The tail
|
|
102
|
+
also enforces NIP-11 at connect (`requiredNips`, default `[1, 42]`) and refuses relays
|
|
103
|
+
that do not advertise them; `probeBuzzRelay` is exported for standalone detection.
|
|
104
|
+
|
|
105
|
+
**Decisions are deterministic and model-free** (`@fabric-harness/channels/buzz-decisions`,
|
|
106
|
+
plan D14): `postBuzzDecisionCard` renders the canonical card from request data (never
|
|
107
|
+
agent prose) and stores a **card receipt** binding `(community, channel, cardEventId)` to
|
|
108
|
+
`(approvalRequestId, requestVersion, parametersHash, options, expiry)`. The
|
|
109
|
+
`createBuzzDecisionBridge` resolves a signed reaction through the receipt store and a
|
|
110
|
+
fixed emoji table (`👍/✅/+ → approve`, `👎/❌/- → reject`) into exactly one
|
|
111
|
+
decision candidate carrying the attested Nostr identity and source-event proof; unmapped
|
|
112
|
+
emoji surface for audit, free-form replies resolve to **edit proposals** that require
|
|
113
|
+
structured confirmation, and everything else is ordinary conversation. The bridge
|
|
114
|
+
performs zero authorization and signals nothing — the vertical's governed decision
|
|
115
|
+
action owns binding resolution, capability, validation, and the decision transaction.
|
|
116
|
+
Stock Buzz Desktop emits NIP-25 reactions with an `e` target and no `h` channel tag. To
|
|
117
|
+
support that shape, give `createBuzzChannel` the same durable receipt store used by
|
|
118
|
+
`postBuzzDecisionCard` plus an explicit `channels` allowlist. The route derives the
|
|
119
|
+
channel only when the reaction has one target and exactly one receipt matches it inside
|
|
120
|
+
that allowlist. Missing, malformed, cross-channel, and ambiguous matches are ignored;
|
|
121
|
+
receipt-store failures fail the forward so the durable tail retries. Receipt correlation
|
|
122
|
+
only recovers transport scope: the normal governed identity, membership, expiry,
|
|
123
|
+
request-version, parameter-hash, and compare-and-swap checks remain mandatory downstream.
|
|
124
|
+
Vendored kind constants are guarded by `scripts/sync-buzz-kinds.mjs` against a Buzz
|
|
125
|
+
checkout's `buzz-core/src/kind.rs`.
|
|
126
|
+
|
|
43
127
|
See [`docs/channels-design.md`](../../docs/channels-design.md).
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { ToolDef } from '@fabric-harness/sdk/channel';
|
|
2
|
+
import type { BuzzPostConfig, BuzzThreadRef } from './buzz.js';
|
|
3
|
+
/**
|
|
4
|
+
* Deterministic, model-free decision surface for Buzz (Fabric Buzz
|
|
5
|
+
* Collaboration Plan D14; B1-H items 5–6).
|
|
6
|
+
*
|
|
7
|
+
* A signed reaction is mapped by trusted code from
|
|
8
|
+
* `(community, channel, targetEventId)` to exactly one immutable
|
|
9
|
+
* ApprovalRequest via a **card receipt** stored when the card was posted. A
|
|
10
|
+
* model may explain or acknowledge the result; it never selects the request,
|
|
11
|
+
* choice, principal, edits, or parameters. Free-form replies to a card are
|
|
12
|
+
* **edit proposals** — never approvals — until validated and explicitly
|
|
13
|
+
* confirmed through a structured decision path.
|
|
14
|
+
*
|
|
15
|
+
* Layering: this module performs zero authorization and signals nothing. It
|
|
16
|
+
* resolves candidates; the vertical's governed decision action (plan A2)
|
|
17
|
+
* resolves identity bindings, checks capability, validates choice/expiry/
|
|
18
|
+
* edits, and owns the decision transaction + signal outbox.
|
|
19
|
+
*/
|
|
20
|
+
export interface BuzzDecisionCardInput {
|
|
21
|
+
approvalRequestId: string;
|
|
22
|
+
/** Version of the ApprovalRequest this card was rendered from. */
|
|
23
|
+
requestVersion: number;
|
|
24
|
+
proposedActionId: string;
|
|
25
|
+
/** `sha256:<hex>` pin of the proposed parameters. */
|
|
26
|
+
proposedParametersHash: string;
|
|
27
|
+
/** Canonical title derived from action/evidence data — not agent prose. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** Canonical summary derived from action/evidence data — not agent prose. */
|
|
30
|
+
summary: string;
|
|
31
|
+
options: ReadonlyArray<'approve' | 'reject' | 'approve-with-edits'>;
|
|
32
|
+
/** ISO-8601 expiry of the request. */
|
|
33
|
+
expiresAt: string;
|
|
34
|
+
/**
|
|
35
|
+
* The ONLY link a card may carry: the governed vertical surface holding the
|
|
36
|
+
* full record (threat model T13/§2 — C2+ payloads stay linked, never posted).
|
|
37
|
+
*/
|
|
38
|
+
detailsUrl?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Render the canonical decision card. Pure and deterministic: identical input
|
|
42
|
+
* yields byte-identical content and tags. The card's human-readable content is
|
|
43
|
+
* informational; all authority derives from the stored receipt, never from
|
|
44
|
+
* parsing this text back.
|
|
45
|
+
*/
|
|
46
|
+
export declare function renderBuzzDecisionCard(input: BuzzDecisionCardInput): {
|
|
47
|
+
content: string;
|
|
48
|
+
tags: string[][];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The binding between a posted card and its ApprovalRequest (plan §4 step 2).
|
|
52
|
+
* Stored by the trusted renderer beside the request; the bridge resolves
|
|
53
|
+
* reactions through it and through nothing else.
|
|
54
|
+
*/
|
|
55
|
+
export interface BuzzCardReceipt {
|
|
56
|
+
approvalRequestId: string;
|
|
57
|
+
requestVersion: number;
|
|
58
|
+
proposedParametersHash: string;
|
|
59
|
+
relayUrl: string;
|
|
60
|
+
community: string;
|
|
61
|
+
channelId: string;
|
|
62
|
+
/** Relay-assigned id of the posted card event. */
|
|
63
|
+
cardEventId: string;
|
|
64
|
+
options: BuzzDecisionCardInput['options'];
|
|
65
|
+
expiresAt: string;
|
|
66
|
+
postedAt: string;
|
|
67
|
+
}
|
|
68
|
+
/** Durable receipt persistence — implement on the vertical's store. */
|
|
69
|
+
export interface BuzzCardReceiptStore {
|
|
70
|
+
save(receipt: BuzzCardReceipt): Promise<void>;
|
|
71
|
+
findByCardEvent(community: string, channelId: string, cardEventId: string): Promise<BuzzCardReceipt | undefined>;
|
|
72
|
+
}
|
|
73
|
+
/** Test/development receipt store. Not durable — never use in production. */
|
|
74
|
+
export declare function inMemoryBuzzCardReceiptStore(): BuzzCardReceiptStore & {
|
|
75
|
+
all(): BuzzCardReceipt[];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Outbound tool: render and post the canonical decision card, then persist the
|
|
79
|
+
* card receipt. Returns the receipt. Posting a card grants nothing by itself.
|
|
80
|
+
* Supersedes `postBuzzDecisionRequest` (deprecated).
|
|
81
|
+
*/
|
|
82
|
+
export declare function postBuzzDecisionCard(ref: BuzzThreadRef, config: BuzzPostConfig & {
|
|
83
|
+
receiptStore: BuzzCardReceiptStore;
|
|
84
|
+
now?: () => number;
|
|
85
|
+
}): ToolDef<BuzzDecisionCardInput, BuzzCardReceipt>;
|
|
86
|
+
/**
|
|
87
|
+
* Fixed reaction→choice table (D14). NIP-25 `+`/`-` are included alongside
|
|
88
|
+
* the emoji the card legend shows. Anything else on a card is `unmapped` —
|
|
89
|
+
* surfaced for audit, never guessed.
|
|
90
|
+
*/
|
|
91
|
+
export declare const BUZZ_DECISION_EMOJI: Readonly<Record<string, 'approve' | 'reject'>>;
|
|
92
|
+
/** Normalized reaction input as dispatched by the Buzz channel route. */
|
|
93
|
+
export interface BuzzReactionInput {
|
|
94
|
+
type: 'buzz.reaction';
|
|
95
|
+
emoji: string;
|
|
96
|
+
targetEventId?: string;
|
|
97
|
+
eventId: string;
|
|
98
|
+
pubkey: string;
|
|
99
|
+
channelId: string;
|
|
100
|
+
}
|
|
101
|
+
/** Normalized message input as dispatched by the Buzz channel route. */
|
|
102
|
+
export interface BuzzMessageInput {
|
|
103
|
+
type: 'buzz.message';
|
|
104
|
+
text: string;
|
|
105
|
+
eventId: string;
|
|
106
|
+
pubkey: string;
|
|
107
|
+
channelId: string;
|
|
108
|
+
rootEventId: string;
|
|
109
|
+
tags?: string[][];
|
|
110
|
+
}
|
|
111
|
+
export interface BuzzDecisionCandidate {
|
|
112
|
+
approvalRequestId: string;
|
|
113
|
+
requestVersion: number;
|
|
114
|
+
proposedParametersHash: string;
|
|
115
|
+
choice: 'approve' | 'reject';
|
|
116
|
+
community: string;
|
|
117
|
+
channelId: string;
|
|
118
|
+
cardEventId: string;
|
|
119
|
+
/** Source-event proof: the signed reaction the channel route verified. */
|
|
120
|
+
reactionEventId: string;
|
|
121
|
+
/** Candidate identity — the governed action resolves the binding (D7). */
|
|
122
|
+
attestedIdentity: {
|
|
123
|
+
namespace: 'nostr';
|
|
124
|
+
externalId: string;
|
|
125
|
+
signatureRef: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export interface BuzzEditProposal {
|
|
129
|
+
approvalRequestId: string;
|
|
130
|
+
requestVersion: number;
|
|
131
|
+
community: string;
|
|
132
|
+
channelId: string;
|
|
133
|
+
cardEventId: string;
|
|
134
|
+
proposalEventId: string;
|
|
135
|
+
/** Free-form text — a PROPOSAL only; never an approval (D14). */
|
|
136
|
+
text: string;
|
|
137
|
+
attestedIdentity: {
|
|
138
|
+
namespace: 'nostr';
|
|
139
|
+
externalId: string;
|
|
140
|
+
signatureRef: string;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export type BuzzDecisionResolution = {
|
|
144
|
+
kind: 'decision-candidate';
|
|
145
|
+
candidate: BuzzDecisionCandidate;
|
|
146
|
+
} | {
|
|
147
|
+
kind: 'edit-proposal';
|
|
148
|
+
proposal: BuzzEditProposal;
|
|
149
|
+
} | {
|
|
150
|
+
kind: 'unmapped-emoji';
|
|
151
|
+
emoji: string;
|
|
152
|
+
cardEventId: string;
|
|
153
|
+
approvalRequestId: string;
|
|
154
|
+
pubkey: string;
|
|
155
|
+
} | {
|
|
156
|
+
kind: 'not-a-decision';
|
|
157
|
+
};
|
|
158
|
+
export interface BuzzDecisionBridgeOptions {
|
|
159
|
+
/** Server-owned community — must equal the channel's (plan D7). */
|
|
160
|
+
community: string;
|
|
161
|
+
receiptStore: BuzzCardReceiptStore;
|
|
162
|
+
/** Override the fixed emoji table (still a fixed table — never a model). */
|
|
163
|
+
emojiMap?: Readonly<Record<string, 'approve' | 'reject'>>;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The deterministic decision bridge (plan §4 steps 4–5). Pure lookup + fixed
|
|
167
|
+
* tables; no clock, no model, no authorization. Returns what the event *is* —
|
|
168
|
+
* the vertical's governed action decides what happens.
|
|
169
|
+
*/
|
|
170
|
+
export declare function createBuzzDecisionBridge(options: BuzzDecisionBridgeOptions): {
|
|
171
|
+
resolveReaction: (reaction: BuzzReactionInput) => Promise<BuzzDecisionResolution>;
|
|
172
|
+
resolveReply: (message: BuzzMessageInput) => Promise<BuzzDecisionResolution>;
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=buzz-decisions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buzz-decisions.d.ts","sourceRoot":"","sources":["../src/buzz-decisions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAI3D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,E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';
|
|
4
|
+
const OPTION_LEGEND = {
|
|
5
|
+
approve: 'approve 👍',
|
|
6
|
+
reject: 'reject 👎',
|
|
7
|
+
'approve-with-edits': 'reply with edits (proposal — requires confirmation)',
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Render the canonical decision card. Pure and deterministic: identical input
|
|
11
|
+
* yields byte-identical content and tags. The card's human-readable content is
|
|
12
|
+
* informational; all authority derives from the stored receipt, never from
|
|
13
|
+
* parsing this text back.
|
|
14
|
+
*/
|
|
15
|
+
export function renderBuzzDecisionCard(input) {
|
|
16
|
+
// Threat model T13: the governed-surface link is the only URL a card may
|
|
17
|
+
// carry. Canonical fields that smuggle links (a compromised upstream, a
|
|
18
|
+
// template injection) are refused outright rather than rendered.
|
|
19
|
+
for (const [field, value] of [
|
|
20
|
+
['title', input.title],
|
|
21
|
+
['summary', input.summary],
|
|
22
|
+
['proposedActionId', input.proposedActionId],
|
|
23
|
+
]) {
|
|
24
|
+
if (/[a-z][a-z0-9+.-]*:\/\//i.test(value)) {
|
|
25
|
+
throw new Error(`decision card ${field} must not contain URLs; use detailsUrl`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const legend = input.options.map((option) => OPTION_LEGEND[option]).join(' · ');
|
|
29
|
+
const content = [
|
|
30
|
+
`**${input.title}**`,
|
|
31
|
+
'',
|
|
32
|
+
input.summary,
|
|
33
|
+
'',
|
|
34
|
+
`action: \`${input.proposedActionId}\``,
|
|
35
|
+
`parameters: \`${input.proposedParametersHash}\``,
|
|
36
|
+
`expires: ${input.expiresAt}`,
|
|
37
|
+
...(input.detailsUrl ? ['', `details: ${input.detailsUrl}`] : []),
|
|
38
|
+
'',
|
|
39
|
+
`_${legend}_`,
|
|
40
|
+
].join('\n');
|
|
41
|
+
const tags = [
|
|
42
|
+
['decision', input.approvalRequestId],
|
|
43
|
+
['decision-version', String(input.requestVersion)],
|
|
44
|
+
['decision-params', input.proposedParametersHash],
|
|
45
|
+
['decision-expires', input.expiresAt],
|
|
46
|
+
];
|
|
47
|
+
return { content, tags };
|
|
48
|
+
}
|
|
49
|
+
/** Test/development receipt store. Not durable — never use in production. */
|
|
50
|
+
export function inMemoryBuzzCardReceiptStore() {
|
|
51
|
+
const receipts = [];
|
|
52
|
+
return {
|
|
53
|
+
async save(receipt) {
|
|
54
|
+
receipts.push(receipt);
|
|
55
|
+
},
|
|
56
|
+
async findByCardEvent(community, channelId, cardEventId) {
|
|
57
|
+
return receipts.find((receipt) => receipt.community === community && receipt.channelId === channelId && receipt.cardEventId === cardEventId);
|
|
58
|
+
},
|
|
59
|
+
all() {
|
|
60
|
+
return receipts;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Outbound tool: render and post the canonical decision card, then persist the
|
|
66
|
+
* card receipt. Returns the receipt. Posting a card grants nothing by itself.
|
|
67
|
+
* Supersedes `postBuzzDecisionRequest` (deprecated).
|
|
68
|
+
*/
|
|
69
|
+
export function postBuzzDecisionCard(ref, config) {
|
|
70
|
+
return defineTool({
|
|
71
|
+
name: 'post_buzz_decision_card',
|
|
72
|
+
description: 'Post the canonical decision card for an ApprovalRequest into the Buzz channel and store its card receipt.',
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
additionalProperties: false,
|
|
76
|
+
properties: {
|
|
77
|
+
approvalRequestId: { type: 'string', minLength: 1 },
|
|
78
|
+
requestVersion: { type: 'integer', minimum: 0 },
|
|
79
|
+
proposedActionId: { type: 'string', minLength: 1 },
|
|
80
|
+
proposedParametersHash: { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' },
|
|
81
|
+
title: { type: 'string', minLength: 1 },
|
|
82
|
+
summary: { type: 'string', minLength: 1 },
|
|
83
|
+
options: {
|
|
84
|
+
type: 'array',
|
|
85
|
+
minItems: 1,
|
|
86
|
+
items: { enum: ['approve', 'reject', 'approve-with-edits'] },
|
|
87
|
+
},
|
|
88
|
+
expiresAt: { type: 'string', minLength: 1 },
|
|
89
|
+
detailsUrl: { type: 'string', minLength: 1 },
|
|
90
|
+
},
|
|
91
|
+
required: [
|
|
92
|
+
'approvalRequestId',
|
|
93
|
+
'requestVersion',
|
|
94
|
+
'proposedActionId',
|
|
95
|
+
'proposedParametersHash',
|
|
96
|
+
'title',
|
|
97
|
+
'summary',
|
|
98
|
+
'options',
|
|
99
|
+
'expiresAt',
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
metadata: { effect: 'write', provider: 'buzz', channel: 'buzz' },
|
|
103
|
+
execute: async (input) => {
|
|
104
|
+
const rendered = renderBuzzDecisionCard(input);
|
|
105
|
+
const result = await postSignedBuzzEvent(config, {
|
|
106
|
+
kind: BUZZ_KINDS.STREAM_MESSAGE,
|
|
107
|
+
content: rendered.content,
|
|
108
|
+
tags: [['h', ref.channelId], ...rendered.tags],
|
|
109
|
+
});
|
|
110
|
+
if (!result.event_id || result.accepted === false) {
|
|
111
|
+
throw new Error(`decision card post rejected: ${result.message ?? 'no event id returned'}`);
|
|
112
|
+
}
|
|
113
|
+
const receipt = {
|
|
114
|
+
approvalRequestId: input.approvalRequestId,
|
|
115
|
+
requestVersion: input.requestVersion,
|
|
116
|
+
proposedParametersHash: input.proposedParametersHash,
|
|
117
|
+
relayUrl: config.relayUrl,
|
|
118
|
+
community: ref.community,
|
|
119
|
+
channelId: ref.channelId,
|
|
120
|
+
cardEventId: result.event_id,
|
|
121
|
+
options: input.options,
|
|
122
|
+
expiresAt: input.expiresAt,
|
|
123
|
+
postedAt: new Date((config.now ?? (() => Date.now()))()).toISOString(),
|
|
124
|
+
};
|
|
125
|
+
await config.receiptStore.save(receipt);
|
|
126
|
+
return receipt;
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
// ── Deterministic bridge ──
|
|
131
|
+
/**
|
|
132
|
+
* Fixed reaction→choice table (D14). NIP-25 `+`/`-` are included alongside
|
|
133
|
+
* the emoji the card legend shows. Anything else on a card is `unmapped` —
|
|
134
|
+
* surfaced for audit, never guessed.
|
|
135
|
+
*/
|
|
136
|
+
export const BUZZ_DECISION_EMOJI = Object.freeze({
|
|
137
|
+
'👍': 'approve',
|
|
138
|
+
'✅': 'approve',
|
|
139
|
+
'+': 'approve',
|
|
140
|
+
'👎': 'reject',
|
|
141
|
+
'❌': 'reject',
|
|
142
|
+
'-': 'reject',
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* The deterministic decision bridge (plan §4 steps 4–5). Pure lookup + fixed
|
|
146
|
+
* tables; no clock, no model, no authorization. Returns what the event *is* —
|
|
147
|
+
* the vertical's governed action decides what happens.
|
|
148
|
+
*/
|
|
149
|
+
export function createBuzzDecisionBridge(options) {
|
|
150
|
+
const emojiMap = options.emojiMap ?? BUZZ_DECISION_EMOJI;
|
|
151
|
+
async function resolveReaction(reaction) {
|
|
152
|
+
if (!reaction.targetEventId)
|
|
153
|
+
return { kind: 'not-a-decision' };
|
|
154
|
+
const receipt = await options.receiptStore.findByCardEvent(options.community, reaction.channelId, reaction.targetEventId);
|
|
155
|
+
if (!receipt)
|
|
156
|
+
return { kind: 'not-a-decision' };
|
|
157
|
+
const choice = emojiMap[reaction.emoji.trim()];
|
|
158
|
+
if (!choice) {
|
|
159
|
+
return {
|
|
160
|
+
kind: 'unmapped-emoji',
|
|
161
|
+
emoji: reaction.emoji,
|
|
162
|
+
cardEventId: receipt.cardEventId,
|
|
163
|
+
approvalRequestId: receipt.approvalRequestId,
|
|
164
|
+
pubkey: reaction.pubkey,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
kind: 'decision-candidate',
|
|
169
|
+
candidate: {
|
|
170
|
+
approvalRequestId: receipt.approvalRequestId,
|
|
171
|
+
requestVersion: receipt.requestVersion,
|
|
172
|
+
proposedParametersHash: receipt.proposedParametersHash,
|
|
173
|
+
choice,
|
|
174
|
+
community: receipt.community,
|
|
175
|
+
channelId: receipt.channelId,
|
|
176
|
+
cardEventId: receipt.cardEventId,
|
|
177
|
+
reactionEventId: reaction.eventId,
|
|
178
|
+
attestedIdentity: { namespace: 'nostr', externalId: reaction.pubkey, signatureRef: reaction.eventId },
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async function resolveReply(message) {
|
|
183
|
+
// A reply targets a card when any `e` tag references the card event.
|
|
184
|
+
const referenced = (message.tags ?? [])
|
|
185
|
+
.filter((tag) => tag[0] === 'e' && typeof tag[1] === 'string')
|
|
186
|
+
.map((tag) => tag[1]);
|
|
187
|
+
for (const eventId of referenced) {
|
|
188
|
+
const receipt = await options.receiptStore.findByCardEvent(options.community, message.channelId, eventId);
|
|
189
|
+
if (receipt) {
|
|
190
|
+
return {
|
|
191
|
+
kind: 'edit-proposal',
|
|
192
|
+
proposal: {
|
|
193
|
+
approvalRequestId: receipt.approvalRequestId,
|
|
194
|
+
requestVersion: receipt.requestVersion,
|
|
195
|
+
community: receipt.community,
|
|
196
|
+
channelId: receipt.channelId,
|
|
197
|
+
cardEventId: receipt.cardEventId,
|
|
198
|
+
proposalEventId: message.eventId,
|
|
199
|
+
text: message.text,
|
|
200
|
+
attestedIdentity: { namespace: 'nostr', externalId: message.pubkey, signatureRef: message.eventId },
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { kind: 'not-a-decision' };
|
|
206
|
+
}
|
|
207
|
+
return { resolveReaction, resolveReply };
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=buzz-decisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buzz-decisions.js","sourceRoot":"","sources":["../src/buzz-decisions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AA4ChD,MAA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aACpC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;aAC7D,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAW,CAAC,CAAC;QAClC,KAAK,MAAM,OAAO,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC1G,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;oBACL,IAAI,EAAE,eAAe;oBACrB,QAAQ,EAAE;wBACR,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;wBAC5C,cAAc,EAAE,OAAO,CAAC,cAAc;wBACtC,SAAS,EAAE,OAAO,CAAC,SAAS;wBAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;wBAC5B,WAAW,EAAE,OAAO,CAAC,WAAW;wBAChC,eAAe,EAAE,OAAO,CAAC,OAAO;wBAChC,IAAI,EAAE,OAAO,CAAC,IAAI;wBAClB,gBAAgB,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE;qBACpG;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACpC,CAAC;IAED,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored Buzz event-kind constants.
|
|
3
|
+
*
|
|
4
|
+
* Buzz (block/buzz) defines every event kind as a compile-time constant in
|
|
5
|
+
* `crates/buzz-core/src/kind.rs` and its relay rejects unknown kinds at ingest.
|
|
6
|
+
* We vendor only the kinds this adapter touches and keep them honest with
|
|
7
|
+
* `scripts/sync-buzz-kinds.mjs`, which diffs this table against a Buzz checkout
|
|
8
|
+
* (the same convention Buzz uses for its own desktop and mobile clients).
|
|
9
|
+
*
|
|
10
|
+
* Key names mirror the Rust constants minus the `KIND_` prefix so the sync
|
|
11
|
+
* script can match them mechanically. Do not add kinds that are not consumed
|
|
12
|
+
* by the adapter — vendoring the whole registry just widens the drift surface.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BUZZ_KINDS: {
|
|
15
|
+
/** NIP-25 reaction — the decision-input event (👍 / 👎 on a request card). */
|
|
16
|
+
readonly REACTION: 7;
|
|
17
|
+
/** Stream (channel chat) message. */
|
|
18
|
+
readonly STREAM_MESSAGE: 9;
|
|
19
|
+
/** NIP-42 client authentication event. */
|
|
20
|
+
readonly AUTH: 22242;
|
|
21
|
+
/** NIP-43 relay membership list (published by `buzz-admin add-member`). */
|
|
22
|
+
readonly NIP43_MEMBERSHIP_LIST: 13534;
|
|
23
|
+
/** NIP-29 group (channel) metadata. */
|
|
24
|
+
readonly NIP29_GROUP_METADATA: 39000;
|
|
25
|
+
/** Forum post (long-form surface). */
|
|
26
|
+
readonly FORUM_POST: 45001;
|
|
27
|
+
/** Forum comment. */
|
|
28
|
+
readonly FORUM_COMMENT: 45003;
|
|
29
|
+
/** Buzz workflow approval grant. Not consumed by the adapter (durable gates
|
|
30
|
+
* live in Temporal) — vendored so the sync script guards the constant we
|
|
31
|
+
* reference in docs and refuse to depend on. */
|
|
32
|
+
readonly APPROVAL_GRANT: 46030;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=buzz-kinds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buzz-kinds.d.ts","sourceRoot":"","sources":["../src/buzz-kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU;IACrB,8EAA8E;;IAE9E,qCAAqC;;IAErC,0CAA0C;;IAE1C,2EAA2E;;IAE3E,uCAAuC;;IAEvC,sCAAsC;;IAEtC,qBAAqB;;IAErB;;oDAEgD;;CAExC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored Buzz event-kind constants.
|
|
3
|
+
*
|
|
4
|
+
* Buzz (block/buzz) defines every event kind as a compile-time constant in
|
|
5
|
+
* `crates/buzz-core/src/kind.rs` and its relay rejects unknown kinds at ingest.
|
|
6
|
+
* We vendor only the kinds this adapter touches and keep them honest with
|
|
7
|
+
* `scripts/sync-buzz-kinds.mjs`, which diffs this table against a Buzz checkout
|
|
8
|
+
* (the same convention Buzz uses for its own desktop and mobile clients).
|
|
9
|
+
*
|
|
10
|
+
* Key names mirror the Rust constants minus the `KIND_` prefix so the sync
|
|
11
|
+
* script can match them mechanically. Do not add kinds that are not consumed
|
|
12
|
+
* by the adapter — vendoring the whole registry just widens the drift surface.
|
|
13
|
+
*/
|
|
14
|
+
export const BUZZ_KINDS = {
|
|
15
|
+
/** NIP-25 reaction — the decision-input event (👍 / 👎 on a request card). */
|
|
16
|
+
REACTION: 7,
|
|
17
|
+
/** Stream (channel chat) message. */
|
|
18
|
+
STREAM_MESSAGE: 9,
|
|
19
|
+
/** NIP-42 client authentication event. */
|
|
20
|
+
AUTH: 22242,
|
|
21
|
+
/** NIP-43 relay membership list (published by `buzz-admin add-member`). */
|
|
22
|
+
NIP43_MEMBERSHIP_LIST: 13534,
|
|
23
|
+
/** NIP-29 group (channel) metadata. */
|
|
24
|
+
NIP29_GROUP_METADATA: 39000,
|
|
25
|
+
/** Forum post (long-form surface). */
|
|
26
|
+
FORUM_POST: 45001,
|
|
27
|
+
/** Forum comment. */
|
|
28
|
+
FORUM_COMMENT: 45003,
|
|
29
|
+
/** Buzz workflow approval grant. Not consumed by the adapter (durable gates
|
|
30
|
+
* live in Temporal) — vendored so the sync script guards the constant we
|
|
31
|
+
* reference in docs and refuse to depend on. */
|
|
32
|
+
APPROVAL_GRANT: 46030,
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=buzz-kinds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buzz-kinds.js","sourceRoot":"","sources":["../src/buzz-kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,8EAA8E;IAC9E,QAAQ,EAAE,CAAC;IACX,qCAAqC;IACrC,cAAc,EAAE,CAAC;IACjB,0CAA0C;IAC1C,IAAI,EAAE,KAAK;IACX,2EAA2E;IAC3E,qBAAqB,EAAE,KAAK;IAC5B,uCAAuC;IACvC,oBAAoB,EAAE,KAAK;IAC3B,sCAAsC;IACtC,UAAU,EAAE,KAAK;IACjB,qBAAqB;IACrB,aAAa,EAAE,KAAK;IACpB;;oDAEgD;IAChD,cAAc,EAAE,KAAK;CACb,CAAC"}
|