Skip to content

Commit fe8eef2

Browse files
author
hsliu_ustc
committed
Bind held sends and their decisions to the owning human (#52)
A held send was decidable by anyone who could reach the decide endpoint: the record carried no owner, no request binding, and no origin, so 'my owner approved' in the message text was as good as an approval, and one member could decide another's queued send on a multi-member host. Holds now stamp server-derived provenance: the sender Bot's owner, a sha256 over the request content, and the origin (via/hop/audience). flybot/decide passes authz for any signed-in member, and hooks binds the decision to the sender Bot's owner's session (bot/forbidden otherwise, bot/unauthorized without a session; a body actorId grants nothing). Releasing revalidates: a changed request, a deleted sender or target Bot, a Bot that changed owners, or a demoted Chief marks the record stale instead of dispatching; deleteBot and setMain invalidate affected holds eagerly. Under enforcement the pending list shows a member only their own holds, and the approval card shows who sent the request and when it was relayed. Legacy records without the version stamp keep working and only miss the tamper check. Team mode stays disabled; this is the held-send half of approval binding (docs/subsystems/team.md gate 3). social/decide-approval stays a deployment-wide plugin write. Fixes #52 Reviewed-queued: independent review pending on this tip.
1 parent 811df19 commit fe8eef2

20 files changed

Lines changed: 932 additions & 388 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to FlyBot (earlier: DS Bot) are listed here. The format foll
1010

1111
### Added
1212

13+
- **Held sends are bound to their owner.** An approval card shows who sent the request (and when it was relayed between Bots); only the sender Bot's owner can approve, reject, or retry it, the list shows you only your own holds, and a decision is voided safely (`stale`, never sent) when the request changed after it was held or the Bot / Chief authority behind it is gone. ([#52](https://github.com/ThinkFlowLab/FlyBot/issues/52))
1314
- **Remove a friend's Bot** from Friends' Bots hides it on this install, takes it out of rooms, and does not unfriend. It reappears only if it is granted again. Held Bot replies show in the chat as **Waiting for approval** (owner: Approve / Reject / Auto-send; others: waiting for the owner). ([#90](https://github.com/ThinkFlowLab/FlyBot/issues/90))
1415
- **Face-to-face join registers a Bot for that room only** when it has no identity yet. `@flybot/social` calls the same `add_home_member` path used for invites, then joins. The identity is not polled, not listed for friends, and is revoked with `remove_home_member` when you leave the last face room or the room closes. A failed join that created one is revoked too so retry is clean. ([#83](https://github.com/ThinkFlowLab/FlyBot/issues/83), [#89](https://github.com/ThinkFlowLab/FlyBot/issues/89), [#90](https://github.com/ThinkFlowLab/FlyBot/issues/90))
1516
- **Face-to-face group.** In Friends' Bots, **Join with a number** takes the same 6-digit number as the people next to you and which of your Bots to bring (default: first). Joining is direct — no preview. The room opens as a normal group with the full member list as `<Bot> · <owner>'s Bot` (owner badges from #82), one-click **Leave**, and **Start chat** (voids the number; a 10-minute countdown while it is still a candidate). Joins, leaves, start, and peer messages render as system / attributed lines; Bot replies go through Bot Social (`pending_approval` uses the existing Approve / Reject queue). **Auto-send my Bot's room messages** in the room header (and **Approve and always auto-send in this room** / **Turn on auto-send** on a waiting draft) is one click onto `auto_approve_face_rooms`; default off, easy to turn off again. Peer text is fenced. ([#83](https://github.com/ThinkFlowLab/FlyBot/issues/83))

‎core/client.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ var ZH = {
107107
"Bot tree": "Bot 树",
108108
"no longer shared": "已不再共享",
109109
"Messages waiting for your approval": "等你批准的消息",
110+
"Sent by {sender}": "由 {sender} 发送",
111+
"Sent by {sender} · delegated": "由 {sender} 发送 · 委托转达",
110112
"Not sent to {to} · {reason}": "未发给 {to} · {reason}",
111113
"Message to {to} · {reason}": "发给 {to} 的消息 · {reason}",
112114
failed: "失败",
@@ -1423,11 +1425,17 @@ function FlyBotApprovals() {
14231425
pending.map((approval) => {
14241426
const custom = entries2.find((entry) => entry.policy === void 0 || entry.policy === approval.by);
14251427
if (custom) return (0, import_react.createElement)("div", { key: approval.id }, (0, import_react.createElement)(Safe, { entry: custom, props: { approval, decide: (decision) => decide(approval.id, decision), call: call2 } }));
1426-
const to = typeof approval.request.to === "object" ? approval.request.to.handle : approval.request.to;
1428+
const to = approval.targetName ?? (typeof approval.request.to === "object" ? approval.request.to.handle : approval.request.to);
14271429
return (0, import_react.createElement)(
14281430
"div",
14291431
{ key: approval.id, className: "bt-flybot-approval" },
14301432
(0, import_react.createElement)("div", { className: "bt-flybot-approval-head" }, approval.status === "failed" ? t("Not sent to {to} · {reason}", { to, reason: approval.error ?? t("failed") }) : t("Message to {to} · {reason}", { to, reason: approval.reason })),
1433+
// Where the request came from (#52): the sending Bot, and when it was relayed.
1434+
approval.senderName !== void 0 ? (0, import_react.createElement)(
1435+
"div",
1436+
{ className: "bt-flybot-approval-origin" },
1437+
approval.request.hop > 0 ? t("Sent by {sender} · delegated", { sender: approval.senderName }) : t("Sent by {sender}", { sender: approval.senderName })
1438+
) : null,
14311439
(0, import_react.createElement)("div", { className: "bt-flybot-approval-text" }, approval.request.text),
14321440
approval.request.attachments?.length ? (0, import_react.createElement)("ul", { className: "bt-flybot-approval-files", "aria-label": t("Attached files") }, approval.request.attachments.map((file, index) => (0, import_react.createElement)("li", { key: index, title: file.path ?? file.name }, `${file.name} · ${fileSize(file.size)}`, file.path ? (0, import_react.createElement)("div", { className: "bt-flybot-approval-path" }, file.path) : null))) : null,
14331441
(0, import_react.createElement)(
@@ -1453,6 +1461,7 @@ var FLYBOT_CSS = `
14531461
.bt-flybot-approval-error { color: var(--bt-danger, #d33); font-size: 12px; }
14541462
.bt-flybot-approval { background: var(--bt-card, #fff); border: 1px solid var(--bt-line, rgba(0,0,0,.12)); border-radius: 10px; padding: 10px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 13px; }
14551463
.bt-flybot-approval-head { font-weight: 600; margin-bottom: 4px; }
1464+
.bt-flybot-approval-origin { font-size: 12px; opacity: .7; margin-bottom: 4px; }
14561465
.bt-flybot-approval-text { white-space: pre-wrap; max-height: 120px; overflow: auto; margin-bottom: 8px; }
14571466
.bt-flybot-approval-path { font-family: ui-monospace, monospace; font-size: 11px; opacity: .7; overflow-wrap: anywhere; }
14581467
.bt-flybot-approval-actions { display: flex; gap: 8px; justify-content: flex-end; }

‎core/src/client/flybot-slots.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ export function FlyBotApprovals() {
133133
pending.map((approval) => {
134134
const custom = entries.find(entry => entry.policy === undefined || entry.policy === approval.by)
135135
if (custom) return h('div', { key: approval.id }, h(Safe, { entry: custom, props: { approval, decide: decision => decide(approval.id, decision), call } }))
136-
const to = typeof approval.request.to === 'object' ? approval.request.to.handle : approval.request.to
136+
const to = approval.targetName ?? (typeof approval.request.to === 'object' ? approval.request.to.handle : approval.request.to)
137137
return h('div', { key: approval.id, className: 'bt-flybot-approval' },
138138
h('div', { className: 'bt-flybot-approval-head' }, approval.status === 'failed' ? t('Not sent to {to} · {reason}', { to, reason: approval.error ?? t('failed') }) : t('Message to {to} · {reason}', { to, reason: approval.reason })),
139+
// Where the request came from (#52): the sending Bot, and when it was relayed.
140+
approval.senderName !== undefined ? h('div', { className: 'bt-flybot-approval-origin' },
141+
approval.request.hop > 0 ? t('Sent by {sender} · delegated', { sender: approval.senderName }) : t('Sent by {sender}', { sender: approval.senderName })) : null,
139142
h('div', { className: 'bt-flybot-approval-text' }, approval.request.text),
140143
approval.request.attachments?.length
141144
? h('ul', { className: 'bt-flybot-approval-files', 'aria-label': t('Attached files') }, approval.request.attachments.map((file, index) =>
@@ -161,6 +164,7 @@ export const FLYBOT_CSS = `
161164
.bt-flybot-approval-error { color: var(--bt-danger, #d33); font-size: 12px; }
162165
.bt-flybot-approval { background: var(--bt-card, #fff); border: 1px solid var(--bt-line, rgba(0,0,0,.12)); border-radius: 10px; padding: 10px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 13px; }
163166
.bt-flybot-approval-head { font-weight: 600; margin-bottom: 4px; }
167+
.bt-flybot-approval-origin { font-size: 12px; opacity: .7; margin-bottom: 4px; }
164168
.bt-flybot-approval-text { white-space: pre-wrap; max-height: 120px; overflow: auto; margin-bottom: 8px; }
165169
.bt-flybot-approval-path { font-family: ui-monospace, monospace; font-size: 11px; opacity: .7; overflow-wrap: anywhere; }
166170
.bt-flybot-approval-actions { display: flex; gap: 8px; justify-content: flex-end; }

‎core/src/client/i18n.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const ZH = {
7171
'Bot tree': 'Bot 树',
7272
'no longer shared': '已不再共享',
7373
'Messages waiting for your approval': '等你批准的消息',
74+
'Sent by {sender}': '由 {sender} 发送',
75+
'Sent by {sender} · delegated': '由 {sender} 发送 · 委托转达',
7476
'Not sent to {to} · {reason}': '未发给 {to} · {reason}',
7577
'Message to {to} · {reason}': '发给 {to} 的消息 · {reason}',
7678
failed: '失败',

‎core/src/host/authz.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ export function install(rt) {
203203
// owners, so they follow the shared rule.
204204
if (ep.startsWith('flybot/')) {
205205
if (rt.flybotIsRead?.(ep.slice('flybot/'.length)) === true) return ALLOW
206+
// Held-send decisions are per-owner enforced in hooks.js — the approval belongs
207+
// to the sender Bot's owner — so deciding does not follow the shared rule (#52).
208+
if (ep === 'flybot/decide') return ALLOW
206209
if (!alone()) return deny('bot/blocked-shared', 'This plugin endpoint cannot be scoped per owner yet, so it is unavailable while the team has more than one member')
207210
return ALLOW
208211
}

‎core/src/host/channel.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,9 @@ export function install(rt) {
411411
return ok(removed)
412412
}
413413
default:
414-
// FlyBot plugins' endpoints (src/host/hooks.js).
415-
if (endpoint.startsWith('flybot/')) return ok(await rt.flybotEndpoint(endpoint.slice('flybot/'.length), body))
414+
// FlyBot plugins' endpoints (src/host/hooks.js). The actor rides along so
415+
// owner-checked endpoints (held-send decisions) can bind it (#52).
416+
if (endpoint.startsWith('flybot/')) return ok(await rt.flybotEndpoint(endpoint.slice('flybot/'.length), body, { actor }))
416417
return fail(`Unknown endpoint ${endpoint}`, 'bot/not-found')
417418
}
418419
} catch (error) {

0 commit comments

Comments
 (0)