hivedesk 1.0.2 → 1.1.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/CHANGELOG.md +12 -0
- package/README.md +5 -6
- package/desktop/README.md +0 -3
- package/desktop/release-notes/1.1.0.json +12 -0
- package/i18n/README.pt-BR.md +5 -6
- package/i18n/de.json +7 -31
- package/i18n/en.json +7 -31
- package/i18n/es.json +7 -31
- package/i18n/fr.json +7 -31
- package/i18n/it.json +7 -31
- package/i18n/ja.json +7 -31
- package/i18n/ko.json +7 -31
- package/i18n/parts/s2-p2p.de.json +5 -15
- package/i18n/parts/s2-p2p.en.json +5 -15
- package/i18n/parts/s2-p2p.es.json +5 -15
- package/i18n/parts/s2-p2p.fr.json +5 -15
- package/i18n/parts/s2-p2p.it.json +5 -15
- package/i18n/parts/s2-p2p.ja.json +5 -15
- package/i18n/parts/s2-p2p.ko.json +5 -15
- package/i18n/parts/s2-p2p.pt-BR.json +5 -15
- package/i18n/parts/s2-p2p.ru.json +5 -15
- package/i18n/parts/s2-p2p.zh-CN.json +5 -15
- package/i18n/pt-BR.json +7 -31
- package/i18n/ru.json +7 -31
- package/i18n/zh-CN.json +7 -31
- package/package.json +1 -1
- package/src/city/membership.js +1 -1
- package/src/extensions/engine-hook.js +1 -1
- package/src/lend/index.js +4 -3
- package/src/p2p/city-port.js +2 -2
- package/src/p2p/cli.js +31 -38
- package/src/p2p/engine.js +1 -1
- package/src/p2p/node.js +25 -8
- package/ui/js/widgets/lend.js +2 -2
- package/ui/lend/collab/client.js +9 -27
- package/ui/lend/collab/frames.js +1 -1
- package/ui/lend/collab/panel.js +8 -20
- package/ui/lend/collab/session.js +1 -1
- package/ui/lend/core/frames.js +1 -1
- package/ui/lend/core/session.js +37 -44
- package/ui/lend/join-window.js +8 -21
- package/ui/lend/lend-screen.js +14 -29
- package/ui/lend/lend.css +0 -2
- package/ui/lend/p2p-model.js +8 -19
- package/ui/lend/p2p-screen.js +21 -43
- package/ui/lend/p2p-text.js +4 -14
- package/ui/lend/text.js +1 -6
- package/ui/lend/view.js +1 -1
package/i18n/zh-CN.json
CHANGED
|
@@ -1058,8 +1058,6 @@
|
|
|
1058
1058
|
"collab.avatarTip": "{name},{role}",
|
|
1059
1059
|
"collab.avatarTipFile": "{name},{role},在 {file}",
|
|
1060
1060
|
"collab.color": "你的颜色",
|
|
1061
|
-
"collab.confirmHelp": "互相读出这些单词。它们必须一致,顺序也相同。",
|
|
1062
|
-
"collab.confirmTitle": "核对确认单词",
|
|
1063
1061
|
"collab.copyLink": "复制链接",
|
|
1064
1062
|
"collab.ended": "会话已结束:{reason}",
|
|
1065
1063
|
"collab.expired": "这些单词已过期。",
|
|
@@ -1080,10 +1078,7 @@
|
|
|
1080
1078
|
"collab.lendingBrain": "你的模型正在为主持人的团队轮流工作。只传输提示词和回答。",
|
|
1081
1079
|
"collab.lentBrain": "出借了模型",
|
|
1082
1080
|
"collab.loadFail": "“一起写代码”未能加载:{error}",
|
|
1083
|
-
"collab.match": "一致",
|
|
1084
|
-
"collab.mismatch": "单词不一致,所以连接已关闭。",
|
|
1085
1081
|
"collab.name": "你的名字",
|
|
1086
|
-
"collab.noMatch": "不一致",
|
|
1087
1082
|
"collab.pal.open": "一起写代码:分享或加入会话",
|
|
1088
1083
|
"collab.people": "此会话中的人",
|
|
1089
1084
|
"collab.remove": "移出",
|
|
@@ -1097,7 +1092,7 @@
|
|
|
1097
1092
|
"collab.stopShare": "停止分享",
|
|
1098
1093
|
"collab.title": "一起写代码",
|
|
1099
1094
|
"collab.viewerNote": "作为观看者,你可以观看和聊天。主持人可以把你设为协作者。",
|
|
1100
|
-
"collab.waitWelcome": "
|
|
1095
|
+
"collab.waitWelcome": "已连接。正在打开共享会话...",
|
|
1101
1096
|
"collab.waiting": "等待有人输入这些单词...",
|
|
1102
1097
|
"collab.word": "第 {n} 个单词",
|
|
1103
1098
|
"collab.you": "你",
|
|
@@ -1905,12 +1900,6 @@
|
|
|
1905
1900
|
"lend.borrow.stop": "断开连接",
|
|
1906
1901
|
"lend.borrow.using": "正在使用 {who}",
|
|
1907
1902
|
"lend.borrow.usingModel": "正在使用 {who}({model})",
|
|
1908
|
-
"lend.confirm.help": "你的朋友也会看到六个词。互相读给对方听,它们必须相同,且顺序一致。",
|
|
1909
|
-
"lend.confirm.mismatch": "这些词不一致,连接已关闭。可能有其他人看到了你的词。请重新生成。",
|
|
1910
|
-
"lend.confirm.no": "不一致",
|
|
1911
|
-
"lend.confirm.title": "核对确认词",
|
|
1912
|
-
"lend.confirm.waitFriend": "正在等待朋友也核对这些词...",
|
|
1913
|
-
"lend.confirm.yes": "一致",
|
|
1914
1903
|
"lend.copied": "已复制",
|
|
1915
1904
|
"lend.copyLink": "复制链接",
|
|
1916
1905
|
"lend.copyWords": "复制词语",
|
|
@@ -1927,10 +1916,10 @@
|
|
|
1927
1916
|
"lend.core.lendingStopped": "借出已停止",
|
|
1928
1917
|
"lend.core.noAnswer": "朋友无法回答",
|
|
1929
1918
|
"lend.core.noBrain": "没有可借出的本地模型",
|
|
1919
|
+
"lend.core.noHello": "在 hello 之前收到了帧",
|
|
1930
1920
|
"lend.core.noMessages": "请求至少需要一条消息",
|
|
1931
1921
|
"lend.core.noModel": "没有就绪的本地模型",
|
|
1932
1922
|
"lend.core.noText": "回答需要包含文本",
|
|
1933
|
-
"lend.core.notConfirmed": "在核对确认词之前就收到了帧",
|
|
1934
1923
|
"lend.core.notLending": "此 hivedesk 未使用 --lend 启动",
|
|
1935
1924
|
"lend.core.notText": "帧必须是文本",
|
|
1936
1925
|
"lend.core.promptTooLong": "提示词有 {chars} 个字符,上限为 {limit}",
|
|
@@ -1960,6 +1949,7 @@
|
|
|
1960
1949
|
"lend.join.incomplete": "请输入全部六个词。把整句或链接粘贴到任意一个框中,即可填满所有框。",
|
|
1961
1950
|
"lend.join.knocking": "正在寻找朋友的电脑...",
|
|
1962
1951
|
"lend.join.lead": "你的朋友运行 \"npx hivedesk --lend\" 后会得到六个词。在这里输入它们、粘贴链接或扫描二维码。之后对方的模型就会轮流为你的团队工作。",
|
|
1952
|
+
"lend.join.opening": "已连接。正在添加朋友的电脑...",
|
|
1963
1953
|
"lend.join.scan": "扫描二维码",
|
|
1964
1954
|
"lend.join.scanStop": "关闭摄像头",
|
|
1965
1955
|
"lend.join.timeout": "朋友的电脑没有响应。请检查这些词,并确认对方的借出界面仍处于打开状态。",
|
|
@@ -1996,32 +1986,26 @@
|
|
|
1996
1986
|
"lend.p2p.cpu": "CPU",
|
|
1997
1987
|
"lend.p2p.cpuLoad": "负载上限(百分比)",
|
|
1998
1988
|
"lend.p2p.cpuThreads": "线程数",
|
|
1999
|
-
"lend.p2p.
|
|
2000
|
-
"lend.p2p.formHelp": "在你接受某人之前,不会共享任何东西。每一项都有自己的限额,每次授权都会按时结束,或在你停止时结束。",
|
|
1989
|
+
"lend.p2p.formHelp": "先选择要借出的内容,再生成词语。使用这些词语的人会立即获得这些内容,且仅限于此。每一项都有自己的上限,每项授权都会按时结束,或在你停止时结束。",
|
|
2001
1990
|
"lend.p2p.formTitle": "你要借出的资源",
|
|
2002
1991
|
"lend.p2p.gpu": "GPU",
|
|
2003
1992
|
"lend.p2p.gpuVram": "VRAM 上限(GB)",
|
|
2004
|
-
"lend.p2p.join.accepted": "
|
|
1993
|
+
"lend.p2p.join.accepted": "已连接到 {name}。你可以使用:",
|
|
2005
1994
|
"lend.p2p.join.failed.refused": "那台电脑拒绝了连接。",
|
|
2006
1995
|
"lend.p2p.join.failed.timeout": "没有人及时回应。",
|
|
2007
1996
|
"lend.p2p.join.failed.words": "这些词无效。它们只能使用一次,且只在 10 分钟内有效,请向朋友要新的词。",
|
|
2008
1997
|
"lend.p2p.join.handshake": "正在核对词语...",
|
|
2009
1998
|
"lend.p2p.join.hostFingerprint": "对方的指纹:{words}",
|
|
2010
1999
|
"lend.p2p.join.meeting": "正在通过中继与朋友会合...",
|
|
2011
|
-
"lend.p2p.join.refused": "
|
|
2012
|
-
"lend.p2p.join.refusedMismatch": "朋友看到的是另一组词,所以连接被拒绝。可能有其他人拿到了这些词,请向朋友要新的词。",
|
|
2013
|
-
"lend.p2p.join.sas": "把这六个词读给朋友听。只有对方屏幕上显示相同的词,对方才会接受。",
|
|
2000
|
+
"lend.p2p.join.refused": "朋友的电脑没有让你进入。",
|
|
2014
2001
|
"lend.p2p.join.start": "加入",
|
|
2015
|
-
"lend.p2p.
|
|
2002
|
+
"lend.p2p.joined": "{name} 已连接,可以使用你选择的内容。请为其他人生成新的词语。",
|
|
2016
2003
|
"lend.p2p.left": "剩余 {n} 分钟",
|
|
2017
2004
|
"lend.p2p.lendingTitle": "正在借出",
|
|
2018
2005
|
"lend.p2p.makeWords": "生成词语",
|
|
2019
|
-
"lend.p2p.match": "一致:借出",
|
|
2020
2006
|
"lend.p2p.minutes": "借出时长",
|
|
2021
2007
|
"lend.p2p.minutesN": "{n} 分钟",
|
|
2022
|
-
"lend.p2p.mismatch": "这些词不一致,所以没有让任何人进入。请生成新词后再试一次。",
|
|
2023
2008
|
"lend.p2p.modelDownload": "允许下载模型",
|
|
2024
|
-
"lend.p2p.noMatch": "不一致",
|
|
2025
2009
|
"lend.p2p.nobody": "目前没有人借用这台电脑。",
|
|
2026
2010
|
"lend.p2p.nothing": "请打开 GPU 或 CPU 后再借出。",
|
|
2027
2011
|
"lend.p2p.offering": "这些词提供:",
|
|
@@ -2029,11 +2013,7 @@
|
|
|
2029
2013
|
"lend.p2p.online": "在线",
|
|
2030
2014
|
"lend.p2p.ram": "RAM",
|
|
2031
2015
|
"lend.p2p.ramGB": "RAM 上限(GB)",
|
|
2032
|
-
"lend.p2p.request": "{name} 想借用这台电脑",
|
|
2033
|
-
"lend.p2p.requestKnown": "{name} 想再次借用这台电脑",
|
|
2034
2016
|
"lend.p2p.revoke": "撤销",
|
|
2035
|
-
"lend.p2p.sasHelp": "请朋友读出他屏幕上的六个词。只有每个词都相同时才接受。",
|
|
2036
|
-
"lend.p2p.sasQuestion": "这些词和对方屏幕上的一致吗?",
|
|
2037
2017
|
"lend.p2p.stopAll": "停止向所有人借出",
|
|
2038
2018
|
"lend.p2p.storage": "存储空间",
|
|
2039
2019
|
"lend.p2p.storageGB": "存储空间上限(GB)",
|
|
@@ -3191,10 +3171,6 @@
|
|
|
3191
3171
|
"tip.hire.tool.run.title": "运行命令",
|
|
3192
3172
|
"tip.hire.tool.write.help": "允许工作者在工作区中创建或覆盖文件。",
|
|
3193
3173
|
"tip.hire.tool.write.title": "写入文件",
|
|
3194
|
-
"tip.lend.confirmNo.help": "立即关闭连接,其他人无法使用。",
|
|
3195
|
-
"tip.lend.confirmNo.title": "词语不一致",
|
|
3196
|
-
"tip.lend.confirmYes.help": "确认你们双方看到的六个词相同且顺序一致。",
|
|
3197
|
-
"tip.lend.confirmYes.title": "词语一致",
|
|
3198
3174
|
"tip.lend.copyLink.help": "复制一个链接,可在朋友那边自动填好六个词。",
|
|
3199
3175
|
"tip.lend.copyLink.title": "复制链接",
|
|
3200
3176
|
"tip.lend.copyWords.help": "复制这六个词,方便发送给朋友。",
|
package/package.json
CHANGED
package/src/city/membership.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// a replica of that CityState from the `city.event` frames, and offers it to this
|
|
12
12
|
// engine's own window (live frame `city.remote`, commands city.remote.*).
|
|
13
13
|
//
|
|
14
|
-
// The p2p facade this adapter needs (
|
|
14
|
+
// The p2p facade this adapter needs (src/p2p/city-port.js provides it):
|
|
15
15
|
// p2p.peerId this engine's PeerId
|
|
16
16
|
// p2p.on(name, fn) -> off 'session.open' ({ peerId, sessionId, via }), 'session.closed' ({ peerId, reason }),
|
|
17
17
|
// 'grants.changed' ({ peerId })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Adds extension tools to the engine's tool table so workers can call them through the normal
|
|
2
2
|
// ToolBox (events, the allowed tools list per worker, approval mode for destructive tools).
|
|
3
|
-
// When the engine grows `toolbox.registerTool(name, def, handler)`
|
|
3
|
+
// When the engine grows `toolbox.registerTool(name, def, handler)` that is
|
|
4
4
|
// used; until then the shared TOOLS table and ALL_TOOLS list are extended in place.
|
|
5
5
|
import { TOOLS, ALL_TOOLS } from '../tools/index.js';
|
|
6
6
|
|
package/src/lend/index.js
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
// It also loads Code together (src/collab/), which adds files.write for the Code editor.
|
|
15
15
|
// 1.0: it attaches the P2P control plane (src/p2p/engine.js, the p2p.* commands) and adds the
|
|
16
16
|
// grant based lending of src/lend/share.js:
|
|
17
|
-
// lend.offer an invite that offers the compute capabilities of the Lend form
|
|
18
|
-
//
|
|
17
|
+
// lend.offer an invite that offers the compute capabilities of the Lend form and grants
|
|
18
|
+
// them to whoever uses the words, at once (the form is the lender's decision)
|
|
19
|
+
// lend.accept accept a join request with the form's capabilities (invites made before 1.1)
|
|
19
20
|
// lend.revoke revoke every compute grant of one peer
|
|
20
21
|
// lend.stop also revokes every compute grant of every peer (the real Stop)
|
|
21
22
|
// On the host nothing is needed here: the remote brain rides the engine's brain.attach,
|
|
@@ -147,7 +148,7 @@ export default function register(ctx) {
|
|
|
147
148
|
server?.command?.('lend.offer', async (data) => {
|
|
148
149
|
const caps = lendCaps(data?.form);
|
|
149
150
|
if (!caps.length) throw Object.assign(new Error('Turn on the GPU or the CPU to lend'), { code: 'bad_request' });
|
|
150
|
-
const invite = await p2p.node().createInvite({ caps, minutes: data?.minutes });
|
|
151
|
+
const invite = await p2p.node().createInvite({ caps, minutes: data?.minutes, answer: lendAnswer(data?.form) });
|
|
151
152
|
return { ...invite, form: readLendForm(data?.form) };
|
|
152
153
|
});
|
|
153
154
|
server?.command?.('lend.accept', (data) => {
|
package/src/p2p/city-port.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The p2p facade of the City membership adapter (src/city/membership.js
|
|
2
|
-
//
|
|
1
|
+
// The p2p facade of the City membership adapter (src/city/membership.js)
|
|
2
|
+
// over this engine's P2PNode:
|
|
3
3
|
// peerId this engine's PeerId
|
|
4
4
|
// on(name, fn) -> off 'session.open' { peerId, sessionId, via: 'invite' | 'known' },
|
|
5
5
|
// 'session.closed' { peerId, reason }, 'grants.changed' { peerId }
|
package/src/p2p/cli.js
CHANGED
|
@@ -83,24 +83,17 @@ const lanAddress = (v) => {
|
|
|
83
83
|
return s.includes(':') ? { host: s.slice(0, s.lastIndexOf(':')), port: Number(s.slice(s.lastIndexOf(':') + 1)) } : { host: s, port: LAN_PORT };
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!yes(match)) return { accept: false, sasMatches: false };
|
|
94
|
-
const caps = [];
|
|
95
|
-
for (const tog of request.toggles) {
|
|
96
|
-
const def = tog.on ? 'Y/n' : 'y/N';
|
|
97
|
-
const a = await t.ask(` allow ${tog.capability.name}${tog.capability.limits ? ' ' + JSON.stringify(tog.capability.limits) : ''} for ${tog.minutes} minutes? [${def}]`);
|
|
98
|
-
if (a ? yes(a) : tog.on) caps.push({ capability: tog.capability, minutes: tog.minutes });
|
|
99
|
-
}
|
|
100
|
-
const ok = await t.ask(`Accept "${request.peer.name}" with ${caps.length ? caps.map((c) => c.capability.name).join(', ') : 'nothing'}? [y/N]`);
|
|
101
|
-
return yes(ok) ? { accept: true, sasMatches: true, caps } : { accept: false, sasMatches: true, reason: 'refused' };
|
|
86
|
+
/**
|
|
87
|
+
* What the words grant, decided when they are made: See the City, plus every --caps capability.
|
|
88
|
+
* Whoever uses the words gets exactly this at once; nobody is asked again.
|
|
89
|
+
*/
|
|
90
|
+
export function inviteAnswer(caps) {
|
|
91
|
+
const names = new Set(['city.view', ...caps.map((c) => c.name)]);
|
|
92
|
+
return [...names].map((name) => ({ capability: caps.find((c) => c.name === name) || { name } }));
|
|
102
93
|
}
|
|
103
94
|
|
|
95
|
+
const grantsLine = (names) => (names.length ? names.join(', ') : 'nothing');
|
|
96
|
+
|
|
104
97
|
const NEEDS_WINDOW = 'Pairing through the public relays runs in the hivedesk window for now (the Lend screen, or "hivedesk --join <words>"). From a terminal, pair on the same network with --lan.';
|
|
105
98
|
|
|
106
99
|
/** hivedesk invite [--caps a,b] [--minutes 10] --lan <address>[:port] */
|
|
@@ -119,20 +112,24 @@ export async function runInvite(argv, o) {
|
|
|
119
112
|
const engine = o.engine === undefined ? await engineClient(o) : o.engine;
|
|
120
113
|
if (engine) {
|
|
121
114
|
const l = await engine.call('p2p.lan.listen', { host, port });
|
|
122
|
-
const
|
|
115
|
+
const answer = inviteAnswer(caps);
|
|
116
|
+
const inv = await engine.call('p2p.invite.create', { caps, minutes, answer });
|
|
123
117
|
t.out(`Invite words: ${inv.words.join(' ')}`);
|
|
124
118
|
t.out(`On the other machine: hivedesk join "${inv.words.join(' ')}" --lan ${host === '0.0.0.0' ? '<this address>' : host}:${l.port}`);
|
|
119
|
+
t.out(`Whoever uses them gets: ${grantsLine(answer.map((c) => c.capability.name))}.`);
|
|
125
120
|
t.out(`The words work once and expire at ${inv.expiresAt}. Waiting...`);
|
|
126
121
|
const end = Date.parse(inv.expiresAt);
|
|
127
122
|
while (Date.now() < end) {
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
t.out(r.accepted ? 'Accepted. They are a known peer now.' : 'Refused.');
|
|
133
|
-
return r.accepted ? 0 : 1;
|
|
123
|
+
const mine = (await engine.call('p2p.invite.list')).invites.find((x) => x.id === inv.inviteId);
|
|
124
|
+
if (mine && mine.state === 'used') {
|
|
125
|
+
t.out('Joined. They are a known peer now; `hivedesk peers --revoke` takes it back.');
|
|
126
|
+
return 0;
|
|
134
127
|
}
|
|
135
|
-
|
|
128
|
+
if (mine && mine.state === 'burned') {
|
|
129
|
+
t.out('Someone tried with the wrong words; the invite is burned. Make a new one.');
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
136
133
|
}
|
|
137
134
|
t.out('The invite expired.');
|
|
138
135
|
return 1;
|
|
@@ -140,9 +137,11 @@ export async function runInvite(argv, o) {
|
|
|
140
137
|
const node = new P2PNode({ home: o.home, name: a.name, ...(o.nodeOptions || {}) }).start();
|
|
141
138
|
const lan = await listenLan({ host, port, onConnection: (c) => node.accept(c) });
|
|
142
139
|
try {
|
|
143
|
-
const
|
|
140
|
+
const answer = inviteAnswer(caps);
|
|
141
|
+
const inv = await node.createInvite({ caps, minutes, answer });
|
|
144
142
|
t.out(`Invite words: ${inv.words.join(' ')}`);
|
|
145
143
|
t.out(`On the other machine: hivedesk join "${inv.words.join(' ')}" --lan ${host === '0.0.0.0' ? '<this address>' : host}:${lan.port}`);
|
|
144
|
+
t.out(`Whoever uses them gets: ${grantsLine(answer.map((c) => c.capability.name))}.`);
|
|
146
145
|
t.out(`Your fingerprint: ${node.identity.fingerprint.words.join(' ')}`);
|
|
147
146
|
t.out(`The words work once and expire at ${inv.expiresAt}. Waiting...`);
|
|
148
147
|
const outcome = await new Promise((resolve) => {
|
|
@@ -151,20 +150,18 @@ export async function runInvite(argv, o) {
|
|
|
151
150
|
clearTimeout(timer);
|
|
152
151
|
resolve('burned');
|
|
153
152
|
});
|
|
154
|
-
node.once('join.
|
|
153
|
+
node.once('join.decided', (d) => {
|
|
155
154
|
clearTimeout(timer);
|
|
156
|
-
resolve(
|
|
155
|
+
resolve(d);
|
|
157
156
|
});
|
|
158
157
|
});
|
|
159
158
|
if (outcome === 'expired' || outcome === 'burned') {
|
|
160
159
|
t.out(outcome === 'expired' ? 'The invite expired.' : 'Someone tried with the wrong words; the invite is burned. Make a new one.');
|
|
161
160
|
return 1;
|
|
162
161
|
}
|
|
163
|
-
|
|
164
|
-
const r = node.answerJoin(outcome.requestId, answer);
|
|
165
|
-
t.out(r.accepted ? 'Accepted. They are a known peer now; standing grants apply when you both run hivedesk.' : 'Refused.');
|
|
162
|
+
t.out(outcome.accepted ? `"${outcome.name}" joined with ${grantsLine(outcome.grants.map((g) => g.capability.name))}. They are a known peer now; standing grants apply when you both run hivedesk.` : 'Refused.');
|
|
166
163
|
await new Promise((res) => setTimeout(res, 300));
|
|
167
|
-
return
|
|
164
|
+
return outcome.accepted ? 0 : 1;
|
|
168
165
|
} finally {
|
|
169
166
|
await lan.close();
|
|
170
167
|
await node.close();
|
|
@@ -194,18 +191,14 @@ export async function runJoin(argv, o) {
|
|
|
194
191
|
}
|
|
195
192
|
const requestedCaps = capsArg(a.caps);
|
|
196
193
|
const engine = o.engine === undefined ? await engineClient(o) : o.engine;
|
|
197
|
-
const show = (
|
|
198
|
-
t.out(`Host: "${host.name}", fingerprint ${host.fingerprint.words.join(' ')}`);
|
|
199
|
-
t.out(`Check words: ${sas.join(' ')}`);
|
|
200
|
-
t.out('Read them to the host. They accept only if their screen shows the same words.');
|
|
201
|
-
};
|
|
194
|
+
const show = (host) => t.out(`Host: "${host.name}", fingerprint ${host.fingerprint.words.join(' ')}`);
|
|
202
195
|
if (engine) {
|
|
203
196
|
let s = await engine.call('p2p.join', { words, via: 'lan', address: a.lan, requestedCaps, name: a.name });
|
|
204
197
|
if (s.phase === 'failed') {
|
|
205
198
|
t.out(s.reason === 'words' ? 'The words did not work (wrong, used or expired).' : `Join failed: ${s.reason}`);
|
|
206
199
|
return 1;
|
|
207
200
|
}
|
|
208
|
-
show(s.
|
|
201
|
+
show(s.host);
|
|
209
202
|
while (s.phase === 'sas') {
|
|
210
203
|
await new Promise((r) => setTimeout(r, 1000));
|
|
211
204
|
s = await engine.call('p2p.join.status', { joinId: s.joinId });
|
|
@@ -222,7 +215,7 @@ export async function runJoin(argv, o) {
|
|
|
222
215
|
t.out(err.code === 'words' ? 'The words did not work (wrong, used or expired).' : `Join failed: ${err.message}`);
|
|
223
216
|
return 1;
|
|
224
217
|
}
|
|
225
|
-
show(handle.
|
|
218
|
+
show(handle.host);
|
|
226
219
|
const d = await handle.decision;
|
|
227
220
|
t.out(d.accepted ? `Accepted with ${d.grants.map((g) => g.capability.name).join(', ') || 'nothing'}.` : `Not accepted: ${d.reason}.`);
|
|
228
221
|
return d.accepted ? 0 : 1;
|
package/src/p2p/engine.js
CHANGED
|
@@ -141,7 +141,7 @@ export function attachP2P(ctx) {
|
|
|
141
141
|
return { ...n.info(), lan: lan ? { port: lan.port, host: lan.host } : null };
|
|
142
142
|
},
|
|
143
143
|
'p2p.invite.create': async (d) => {
|
|
144
|
-
const inv = await getNode().createInvite({ caps: d.caps, minutes: d.minutes, origin: USER });
|
|
144
|
+
const inv = await getNode().createInvite({ caps: d.caps, minutes: d.minutes, origin: USER, answer: Array.isArray(d.answer) ? d.answer : undefined });
|
|
145
145
|
return inv;
|
|
146
146
|
},
|
|
147
147
|
'p2p.invite.cancel': (d) => ({ cancelled: getNode().cancelInvite(String(d.inviteId || '')) }),
|
package/src/p2p/node.js
CHANGED
|
@@ -137,12 +137,18 @@ export class P2PNode extends EventEmitter {
|
|
|
137
137
|
|
|
138
138
|
// ------------------------------------------------------------------ invites (host)
|
|
139
139
|
|
|
140
|
-
/**
|
|
141
|
-
|
|
140
|
+
/**
|
|
141
|
+
* A new invite. Returns { inviteId, words, expiresAt, offeredCaps, autoAccept, rendezvous: { topic, seal } }.
|
|
142
|
+
* answer: the grants the person chose up front ([{ capability, minutes?, scope? }], as in
|
|
143
|
+
* answerJoin). With it, whoever completes the handshake with these words is let in at once with
|
|
144
|
+
* exactly those grants: the words are the decision, so nobody is asked again.
|
|
145
|
+
*/
|
|
146
|
+
async createInvite({ caps = [], minutes, origin = USER, answer } = {}) {
|
|
142
147
|
if (origin.kind !== 'user') throw new CapError('forbidden', 'only a person makes an invite');
|
|
143
148
|
const inv = await this.invites.create({ minutes, offeredCaps: caps });
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
if (Array.isArray(answer)) inv.answer = answer.slice(0, 16);
|
|
150
|
+
this._audit({ type: 'invite.created', inviteId: inv.id, expiresAt: new Date(inv.expiresAt).toISOString(), offered: inv.offeredCaps.map((c) => c.name), ...(inv.answer ? { autoAccept: true } : {}) });
|
|
151
|
+
return { inviteId: inv.id, words: [...inv.words], expiresAt: new Date(inv.expiresAt).toISOString(), offeredCaps: inv.offeredCaps, autoAccept: !!inv.answer, rendezvous: { topic: inv.topic, seal: b64u(inv.seal) } };
|
|
146
152
|
}
|
|
147
153
|
|
|
148
154
|
cancelInvite(inviteId) {
|
|
@@ -219,9 +225,14 @@ export class P2PNode extends EventEmitter {
|
|
|
219
225
|
createdAt: this.now(),
|
|
220
226
|
expiresAt: this.now() + this.decisionMs,
|
|
221
227
|
};
|
|
222
|
-
this.joinRequests.set(request.id, request);
|
|
223
228
|
const audit = this._audit({ type: 'join.requested', requestId: request.id, peerId: r.guest.peerId, name: r.name, requested: r.requestedCaps.map((c) => c.name) });
|
|
224
229
|
request.auditHash = audit.hash;
|
|
230
|
+
if (inv.answer) {
|
|
231
|
+
// The person chose the grants when making the words: the guest is in now.
|
|
232
|
+
this._decide(request, rec, { accept: true, caps: inv.answer }, USER, { auto: true });
|
|
233
|
+
return rec.session;
|
|
234
|
+
}
|
|
235
|
+
this.joinRequests.set(request.id, request);
|
|
225
236
|
this.emit('join.request', this.joinDialog(request));
|
|
226
237
|
return rec.session;
|
|
227
238
|
}
|
|
@@ -372,12 +383,18 @@ export class P2PNode extends EventEmitter {
|
|
|
372
383
|
const rec = this.sessions.get(req.sessionId);
|
|
373
384
|
if (accept && sasMatches !== true) throw new CapError('sas_unconfirmed', 'compare the six words with the other screen first');
|
|
374
385
|
this.joinRequests.delete(requestId);
|
|
386
|
+
return this._decide(req, rec, { accept, caps, reason: sasMatches === false ? 'sas_mismatch' : reason }, origin);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** Lets a join request in with caps, or refuses it. auto: decided by an invite made with an answer. */
|
|
390
|
+
_decide(req, rec, { accept, caps = [], reason }, origin, { auto = false } = {}) {
|
|
391
|
+
const requestId = req.id;
|
|
375
392
|
if (!rec || rec.session.state !== 'open') {
|
|
376
393
|
this._audit({ type: 'join.lost', requestId, peerId: req.peer.peerId });
|
|
377
394
|
throw new CapError('not_found', 'the guest is gone');
|
|
378
395
|
}
|
|
379
396
|
if (!accept) {
|
|
380
|
-
const why =
|
|
397
|
+
const why = typeof reason === 'string' ? reason.slice(0, 120) : 'refused';
|
|
381
398
|
rec.session.send('join.refuse', { reason: why });
|
|
382
399
|
this._audit({ type: 'join.refused', requestId, peerId: req.peer.peerId, reason: why });
|
|
383
400
|
this.emit('join.decided', { requestId, peerId: req.peer.peerId, accepted: false, reason: why });
|
|
@@ -393,11 +410,11 @@ export class P2PNode extends EventEmitter {
|
|
|
393
410
|
this._storeGrant(g, rec);
|
|
394
411
|
grants.push(g);
|
|
395
412
|
}
|
|
396
|
-
const audit = this._audit({ type: 'join.accepted', requestId, peerId: req.peer.peerId, sas: true, grants: grants.map((g) => ({ id: g.id, name: g.capability.name, expiresAt: g.expiresAt, scope: g.scope })) });
|
|
413
|
+
const audit = this._audit({ type: 'join.accepted', requestId, peerId: req.peer.peerId, ...(auto ? { auto: true } : { sas: true }), grants: grants.map((g) => ({ id: g.id, name: g.capability.name, expiresAt: g.expiresAt, scope: g.scope })) });
|
|
397
414
|
rec.session.send('join.accept', { grants: grants.map(grantForWire), cityId: this.opts.cityId, machineId: this.opts.machineId });
|
|
398
415
|
rec.session.send('audit.ref', { entryHash: audit.hash, type: 'join.accepted' });
|
|
399
416
|
this._online(rec);
|
|
400
|
-
this.emit('join.decided', { requestId, peerId: req.peer.peerId, accepted: true, grants: grants.map(grantForWire) });
|
|
417
|
+
this.emit('join.decided', { requestId, peerId: req.peer.peerId, name: req.name, accepted: true, auto, grants: grants.map(grantForWire) });
|
|
401
418
|
for (const g of grants) this.emit('grant.created', grantForWire(g));
|
|
402
419
|
return { accepted: true, grants: grants.map(grantForWire) };
|
|
403
420
|
}
|
package/ui/js/widgets/lend.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Window types for Lend your PC. The content lives in ui/lend/ (owned by the lend module
|
|
2
|
-
//
|
|
1
|
+
// Window types for Lend your PC. The content lives in ui/lend/ (owned by the lend module):
|
|
2
|
+
// this file only hosts it in the window manager.
|
|
3
3
|
// lend "Use a friend's PC" (the host side), from lendWindow.mount(el)
|
|
4
4
|
// lending the full Lend screen, shown when this hivedesk runs with --lend
|
|
5
5
|
|
package/ui/lend/collab/client.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// solo no session; documents load from and save to this PC's engine
|
|
4
4
|
// host this desktop shares its session; guests join with six words
|
|
5
5
|
// guest this desktop shows a host's session (ui/js/net.js useRemote)
|
|
6
|
-
// Pairing is the Lend your PC pairing (six words, QR code or link
|
|
7
|
-
//
|
|
6
|
+
// Pairing is the Lend your PC pairing (six words, QR code or link; whoever uses the words is in,
|
|
7
|
+
// with nothing to confirm) with the collab frames.
|
|
8
8
|
|
|
9
9
|
import { Emitter } from '../core/emitter.js';
|
|
10
10
|
import { LendJoin, LendOffer } from '../core/session.js';
|
|
@@ -71,7 +71,6 @@ class LendOverCollab extends Emitter {
|
|
|
71
71
|
if (this.closed) throw new Error('closed');
|
|
72
72
|
this.sendLend(normalizeFrame(f));
|
|
73
73
|
}
|
|
74
|
-
confirmLocal() {}
|
|
75
74
|
stop(reason = 'stopped') {
|
|
76
75
|
if (this.closed) return;
|
|
77
76
|
try {
|
|
@@ -94,7 +93,7 @@ class Collab extends Emitter {
|
|
|
94
93
|
this.mode = 'solo';
|
|
95
94
|
this.host = null;
|
|
96
95
|
this.guest = null;
|
|
97
|
-
this.pending = []; // host:
|
|
96
|
+
this.pending = []; // host: the invites made (waiting, joined, closed, expired or failed)
|
|
98
97
|
this.profile = loadProfile();
|
|
99
98
|
this.solo = null;
|
|
100
99
|
this.lends = new Map(); // guest id -> { peer, bridge } on the host
|
|
@@ -206,12 +205,11 @@ class Collab extends Emitter {
|
|
|
206
205
|
async invite() {
|
|
207
206
|
const host = this.startHosting();
|
|
208
207
|
const offer = new LendOffer(PAIR());
|
|
209
|
-
const entry = { offer, words: null,
|
|
208
|
+
const entry = { offer, words: null, peer: null, record: null, state: 'waiting' };
|
|
210
209
|
this.pending.push(entry);
|
|
211
|
-
offer.on('connected', (peer
|
|
210
|
+
offer.on('connected', (peer) => {
|
|
212
211
|
entry.peer = peer;
|
|
213
|
-
entry.
|
|
214
|
-
entry.state = 'confirm';
|
|
212
|
+
entry.state = 'opening';
|
|
215
213
|
entry.record = host.addGuest(peer);
|
|
216
214
|
peer.on('close', () => {
|
|
217
215
|
entry.state = 'closed';
|
|
@@ -237,17 +235,6 @@ class Collab extends Emitter {
|
|
|
237
235
|
return entry;
|
|
238
236
|
}
|
|
239
237
|
|
|
240
|
-
/** The host checked the confirmation words of a waiting guest. */
|
|
241
|
-
confirmGuest(entry, ok) {
|
|
242
|
-
if (!entry.peer) return;
|
|
243
|
-
if (ok) entry.peer.confirmLocal();
|
|
244
|
-
else {
|
|
245
|
-
entry.peer.stop('The confirmation words did not match');
|
|
246
|
-
entry.state = 'mismatch';
|
|
247
|
-
}
|
|
248
|
-
this.emit('invites');
|
|
249
|
-
}
|
|
250
|
-
|
|
251
238
|
stopHosting(reason) {
|
|
252
239
|
if (!this.host) return;
|
|
253
240
|
for (const e of this.pending) e.offer.stop();
|
|
@@ -294,7 +281,7 @@ class Collab extends Emitter {
|
|
|
294
281
|
|
|
295
282
|
/* ---------- guest ---------- */
|
|
296
283
|
|
|
297
|
-
/** Knocks with six words. Resolves once the WebRTC link is open with { guest,
|
|
284
|
+
/** Knocks with six words. Resolves once the WebRTC link is open with { guest, peer }. */
|
|
298
285
|
join(words) {
|
|
299
286
|
if (this.mode === 'host') throw new Error('Stop sharing your session first');
|
|
300
287
|
this.leave();
|
|
@@ -303,7 +290,7 @@ class Collab extends Emitter {
|
|
|
303
290
|
this.joining = join;
|
|
304
291
|
join.on('timeout', () => reject(Object.assign(new Error('The host did not answer. Check the words and that the host still shows them.'), { code: 'timeout' })));
|
|
305
292
|
join.on('failed', (reason) => reject(Object.assign(new Error(String(reason)), { code: 'failed' })));
|
|
306
|
-
join.on('connected', (peer
|
|
293
|
+
join.on('connected', (peer) => {
|
|
307
294
|
const guest = new CollabGuest({ peer, name: this.profile.name || 'Guest', color: this.profile.color });
|
|
308
295
|
this.guest = guest;
|
|
309
296
|
guest.on('welcome', () => this._welcomed());
|
|
@@ -312,17 +299,12 @@ class Collab extends Emitter {
|
|
|
312
299
|
guest.on('presence', (p) => this.emit('presence', p));
|
|
313
300
|
guest.on('lend', (raw) => this.lender?.peer.receive(raw));
|
|
314
301
|
guest.on('closed', (reason) => this._guestClosed(reason));
|
|
315
|
-
resolve({ guest,
|
|
302
|
+
resolve({ guest, peer });
|
|
316
303
|
});
|
|
317
304
|
join.start(words).catch(reject);
|
|
318
305
|
});
|
|
319
306
|
}
|
|
320
307
|
|
|
321
|
-
confirmHost(peer, ok) {
|
|
322
|
-
if (ok) peer.confirmLocal();
|
|
323
|
-
else peer.stop('The confirmation words did not match');
|
|
324
|
-
}
|
|
325
|
-
|
|
326
308
|
async _welcomed() {
|
|
327
309
|
const guest = this.guest;
|
|
328
310
|
const transport = {
|
package/ui/lend/collab/frames.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code together frames on the data channel between the host and one guest.
|
|
2
2
|
//
|
|
3
3
|
// hello both { t, v, role: 'host' | 'guest', name, color }
|
|
4
|
-
// confirm both { t } the
|
|
4
|
+
// confirm both { t } sent once after the hello, for apps before 1.1 (ignored)
|
|
5
5
|
// welcome host { t, you: { id, role }, hello } hello is the host engine's hello frame
|
|
6
6
|
// engine host { t, frame } an engine event or live frame, relayed
|
|
7
7
|
// peers host { t, peers: [{ id, name, color, role, file? }] }
|
package/ui/lend/collab/panel.js
CHANGED
|
@@ -22,10 +22,6 @@ export const T = {
|
|
|
22
22
|
get you() { return tc('you'); },
|
|
23
23
|
get waiting() { return tc('waiting'); },
|
|
24
24
|
get inviteHelp() { return tc('inviteHelp'); },
|
|
25
|
-
get confirmTitle() { return tc('confirmTitle'); },
|
|
26
|
-
get confirmHelp() { return tc('confirmHelp'); },
|
|
27
|
-
get match() { return tc('match'); },
|
|
28
|
-
get noMatch() { return tc('noMatch'); },
|
|
29
25
|
get joinTitle() { return tc('joinTitle'); },
|
|
30
26
|
get join() { return tc('join'); },
|
|
31
27
|
get joinHelp() { return tc('joinHelp'); },
|
|
@@ -40,7 +36,6 @@ export const T = {
|
|
|
40
36
|
get lentBrain() { return tc('lentBrain'); },
|
|
41
37
|
get expired() { return tc('expired'); },
|
|
42
38
|
get failed() { return tc('failed'); },
|
|
43
|
-
get mismatch() { return tc('mismatch'); },
|
|
44
39
|
get copyLink() { return tc('copyLink'); },
|
|
45
40
|
get guestTag() { return tc('guestTag'); },
|
|
46
41
|
get sharingTag() { return tc('sharingTag'); },
|
|
@@ -113,7 +108,7 @@ export function mountCollab(root, { initial = '' } = {}) {
|
|
|
113
108
|
root.classList.add('collab-panel', 'lend-join');
|
|
114
109
|
const offs = [];
|
|
115
110
|
const on = (type, fn) => offs.push(collab.on(type, fn));
|
|
116
|
-
let guestState = { phase: 'form',
|
|
111
|
+
let guestState = { phase: 'form', peer: null, error: '' };
|
|
117
112
|
|
|
118
113
|
const render = () => {
|
|
119
114
|
root.dataset.mode = collab.mode;
|
|
@@ -134,9 +129,10 @@ export function mountCollab(root, { initial = '' } = {}) {
|
|
|
134
129
|
guestState = { phase: 'knocking', words };
|
|
135
130
|
renderGuestProgress();
|
|
136
131
|
try {
|
|
137
|
-
const {
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
const { peer } = await collab.join(words);
|
|
133
|
+
// The host's welcome follows on its own; guestJoined() takes over then.
|
|
134
|
+
guestState = { phase: 'opening', peer };
|
|
135
|
+
if (collab.mode !== 'guest') renderGuestProgress();
|
|
140
136
|
} catch (e) {
|
|
141
137
|
guestState = { phase: 'form', error: e.message };
|
|
142
138
|
render();
|
|
@@ -153,12 +149,7 @@ export function mountCollab(root, { initial = '' } = {}) {
|
|
|
153
149
|
function renderGuestProgress() {
|
|
154
150
|
const box = h('section', { class: 'lend-card', dataset: { phase: guestState.phase } });
|
|
155
151
|
if (guestState.phase === 'knocking') box.append(wordGrid(guestState.words), h('p', { class: 'lend-status', text: T.knocking }));
|
|
156
|
-
if (guestState.phase === '
|
|
157
|
-
const wait = h('p', { class: 'lend-muted', text: T.waitWelcome, hidden: true });
|
|
158
|
-
const yes = h('button', { class: 'lend-btn is-primary', type: 'button', text: T.match, dataset: { act: 'confirm' }, on: { click: () => { collab.confirmHost(guestState.peer, true); yes.disabled = true; wait.hidden = false; } } });
|
|
159
|
-
const no = h('button', { class: 'lend-btn', type: 'button', text: T.noMatch, on: { click: () => { collab.confirmHost(guestState.peer, false); guestState = { phase: 'form', error: T.mismatch }; render(); } } });
|
|
160
|
-
box.append(h('h3', { text: T.confirmTitle }), h('p', { text: T.confirmHelp }), wordGrid(guestState.confirm, 'is-confirm'), h('div', { class: 'lend-row' }, yes, no), wait);
|
|
161
|
-
}
|
|
152
|
+
if (guestState.phase === 'opening') box.append(h('p', { class: 'lend-status', text: T.waitWelcome }));
|
|
162
153
|
clear(root).append(h('header', { class: 'lend-head is-small' }, h('div', null, h('h2', { text: T.joinTitle }))), box);
|
|
163
154
|
root.dataset.phase = guestState.phase;
|
|
164
155
|
}
|
|
@@ -184,11 +175,8 @@ export function mountCollab(root, { initial = '' } = {}) {
|
|
|
184
175
|
const link = collabLink(entry.words);
|
|
185
176
|
const copyBtn = h('button', { class: 'lend-btn', type: 'button', text: T.copyLink, on: { click: () => copyText(link, copyBtn) } });
|
|
186
177
|
card.append(h('div', { class: 'lend-share' }, h('div', { class: 'lend-share-words' }, wordGrid(entry.words, 'is-big collab-invite-words'), h('p', { class: 'lend-muted', text: T.inviteHelp }), h('div', { class: 'lend-row' }, copyBtn), h('input', { class: 'lend-link', value: link, readOnly: true }), h('p', { class: 'lend-status', text: T.waiting })), qrNode(link, T.title)));
|
|
187
|
-
} else if (entry.state === '
|
|
188
|
-
card.append(h('
|
|
189
|
-
h('div', { class: 'lend-row' }, h('button', { class: 'lend-btn is-primary', type: 'button', text: T.match, dataset: { act: 'confirm-guest' }, on: { click: () => collab.confirmGuest(entry, true) } }), h('button', { class: 'lend-btn', type: 'button', text: T.noMatch, on: { click: () => collab.confirmGuest(entry, false) } })));
|
|
190
|
-
} else if (entry.state === 'expired' || entry.state === 'failed' || entry.state === 'mismatch') {
|
|
191
|
-
card.append(h('p', { class: 'lend-error', text: entry.state === 'expired' ? T.expired : entry.state === 'mismatch' ? T.mismatch : T.failed }));
|
|
178
|
+
} else if (entry.state === 'expired' || entry.state === 'failed') {
|
|
179
|
+
card.append(h('p', { class: 'lend-error', text: entry.state === 'expired' ? T.expired : T.failed }));
|
|
192
180
|
} else return null;
|
|
193
181
|
return card;
|
|
194
182
|
}
|
|
@@ -58,7 +58,7 @@ export class CollabHost extends Emitter {
|
|
|
58
58
|
return [pub(this.me), ...[...this.guests.values()].filter((g) => g.welcomed).map(pub)];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/** Adds a guest connected over a
|
|
61
|
+
/** Adds a guest connected over a peer; the welcome goes out once its hello arrives. Returns the guest record. */
|
|
62
62
|
addGuest(peer, { role = 'viewer' } = {}) {
|
|
63
63
|
const g = { id: `g${++this.nextGuest}`, name: 'Guest', color: '#7fc98f', role, peer, file: null, sel: [], welcomed: false, queue: [], docs: new Set() };
|
|
64
64
|
this.guests.set(g.id, g);
|
package/ui/lend/core/frames.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the friend (who lends one). Only model prompts and completions travel, nothing else:
|
|
3
3
|
//
|
|
4
4
|
// hello both { t, v, role: 'lender' | 'host', label, model?, ctx?, limits? }
|
|
5
|
-
// confirm both { t }
|
|
5
|
+
// confirm both { t } sent once after the hello, for apps before 1.1 (ignored)
|
|
6
6
|
// req host { t, id, messages, options: { schema?, maxTokens?, temperature? } }
|
|
7
7
|
// tok lender { t, id, text } optional streamed text for a pending req
|
|
8
8
|
// res lender { t, id, ok: true, result } or { t, id, ok: false, error: { code, message } }
|