hivedesk 0.1.1 → 0.2.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 +18 -0
- package/FIRST-RUN.md +14 -0
- package/PROTOCOL.md +16 -3
- package/README.md +45 -5
- package/assets/illustrations/hive-city.svg +113 -0
- package/assets/video-poster.webp +0 -0
- package/i18n/README.pt-BR.md +39 -5
- package/i18n/de.json +174 -0
- package/i18n/en.json +174 -0
- package/i18n/es.json +174 -0
- package/i18n/fr.json +174 -0
- package/i18n/it.json +174 -0
- package/i18n/ja.json +174 -0
- package/i18n/ko.json +174 -0
- package/i18n/pt-BR.json +174 -0
- package/i18n/ru.json +174 -0
- package/i18n/zh-CN.json +174 -0
- package/package.json +1 -1
- package/src/bus.js +7 -1
- package/src/city/demo.js +75 -0
- package/src/city/hops.js +95 -0
- package/src/city/index.js +1507 -0
- package/src/city/router.js +53 -0
- package/src/city/state.js +313 -0
- package/src/city/store.js +91 -0
- package/src/cli.js +3 -0
- package/src/crew/engine.js +40 -3
- package/src/demo.js +30 -2
- package/src/index.js +23 -2
- package/src/server.js +4 -1
- package/ui/city/city.css +204 -0
- package/ui/city/city.js +933 -0
- package/ui/city/collab.js +64 -0
- package/ui/city/layout.js +142 -0
- package/ui/city/mock.js +358 -0
- package/ui/city/model.js +195 -0
- package/ui/city/scene.js +2033 -0
- package/ui/js/main.js +3 -1
- package/ui/lend/collab/roles.js +8 -2
- package/ui/office/office.js +51 -21
- package/ui/office/scene.js +3 -0
- package/ui/screenshots/city-agent-card-1440.png +0 -0
- package/ui/screenshots/city-agent-card-1920.png +0 -0
- package/ui/screenshots/city-bridge-gpu-borrow-1440.png +0 -0
- package/ui/screenshots/city-bridge-gpu-borrow-1920.png +0 -0
- package/ui/screenshots/city-friend-rising-1440.png +0 -0
- package/ui/screenshots/city-friend-rising-1920.png +0 -0
- package/ui/screenshots/city-overview-1440.png +0 -0
- package/ui/screenshots/city-overview-1920.png +0 -0
- package/ui/screenshots/city-review-room-1440.png +0 -0
- package/ui/screenshots/city-review-room-1920.png +0 -0
package/ui/js/main.js
CHANGED
|
@@ -33,7 +33,8 @@ import { beeAvatar } from './bees.js';
|
|
|
33
33
|
import { openHire } from './widgets/hire.js';
|
|
34
34
|
import { shortModel } from './brainstate.js';
|
|
35
35
|
import * as act from './actions.js';
|
|
36
|
-
import { initOffice } from '../office/office.js';
|
|
36
|
+
import { initOffice, addView, setMode, getMode } from '../office/office.js';
|
|
37
|
+
import { initCity } from '../city/city.js';
|
|
37
38
|
import * as i18n from './i18n.js';
|
|
38
39
|
import { t } from './i18n.js';
|
|
39
40
|
import * as tooltip from './tooltip.js';
|
|
@@ -307,6 +308,7 @@ notifyMod.init();
|
|
|
307
308
|
topbar.init(bar);
|
|
308
309
|
dock.init(dockEl, desktopMenu);
|
|
309
310
|
initOffice({ desk, barRight: bar.querySelector('.bar-right'), addDockItem: dock.addDockItem });
|
|
311
|
+
initCity({ desk, addDockItem: dock.addDockItem, office: { addView, setMode, getMode } });
|
|
310
312
|
menu.provide(desk, (target) => {
|
|
311
313
|
const win = target.closest?.('.win');
|
|
312
314
|
if (win) return windowMenu(win.dataset.id);
|
package/ui/lend/collab/roles.js
CHANGED
|
@@ -12,8 +12,12 @@ export const ROLES = Object.freeze(['viewer', 'collaborator', 'host']);
|
|
|
12
12
|
export const GUEST_ROLES = Object.freeze(['viewer', 'collaborator']);
|
|
13
13
|
|
|
14
14
|
const READ = ['ping', 'events.since', 'replay.at', 'replay.marks', 'files.list', 'files.read', 'playbook.list'];
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// Hive City (CITY-PROTOCOL.md): everyone can see the city, bring a building and its agents, and lend or
|
|
16
|
+
// borrow a GPU; collaborators can also put tasks on the board. The host engine checks ownership again.
|
|
17
|
+
const CITY_VIEWER = ['city.state', 'city.sync', 'city.presence', 'city.machine.join', 'city.machine.update', 'city.machine.leave', 'city.agent.update', 'city.borrow.request', 'city.borrow.answer', 'city.borrow.stop'];
|
|
18
|
+
const CITY_COLLABORATOR = ['city.task.create', 'city.task.assign', 'city.task.move', 'city.task.approve', 'city.task.reject', 'city.task.retry', 'city.task.cancel', 'city.agent.move', 'city.agent.retire', 'city.agent.wake'];
|
|
19
|
+
const VIEWER = new Set([...READ, 'chat.send', ...CITY_VIEWER]);
|
|
20
|
+
const COLLABORATOR = new Set([...VIEWER, 'job.create', 'job.cancel', 'approval.resolve', 'task.retry', 'task.reassign', 'task.cancel', 'files.write', ...CITY_COLLABORATOR]);
|
|
17
21
|
|
|
18
22
|
export class PermissionError extends Error {
|
|
19
23
|
constructor(message) {
|
|
@@ -60,6 +64,8 @@ export function checkCommand(guest, type, data = {}) {
|
|
|
60
64
|
case 'approval.resolve':
|
|
61
65
|
return { type, data: { approvalId: short(d.approvalId, 80), approved: !!d.approved, note: `${guest.name}${d.note ? `: ${short(d.note, 300)}` : ''}` } };
|
|
62
66
|
default:
|
|
67
|
+
// City commands carry who sent them, so the host engine can apply "the owner wins". Any as sent by the guest is replaced.
|
|
68
|
+
if (type.startsWith('city.')) return { type, data: { ...d, as: { id: guest.id, name: guest.name } } };
|
|
63
69
|
return { type, data: d };
|
|
64
70
|
}
|
|
65
71
|
}
|
package/ui/office/office.js
CHANGED
|
@@ -15,7 +15,7 @@ import { OfficeScene, levelOf, doneCount, dayPhase } from './scene.js';
|
|
|
15
15
|
import * as audio from './audio.js';
|
|
16
16
|
import { openWidget, openPip, pipSupported } from './popout.js';
|
|
17
17
|
|
|
18
|
-
const VIEW_KEY = 'hivedesk.view';
|
|
18
|
+
const VIEW_KEY = 'hivedesk.view.v2'; // v2: City became the default home in 0.2.0
|
|
19
19
|
const MODE_LABEL = {
|
|
20
20
|
idle: 'Idle', sleep: 'Napping (idle)', type: 'Typing', plan: 'Planning on the board', wait: 'In the queue for the model',
|
|
21
21
|
stuck: 'Waiting for your approval', test: 'Running checks', read: 'Reading files', error: 'Error', celebrate: 'Celebrating',
|
|
@@ -123,12 +123,15 @@ export function initOffice({ desk, barRight, addDockItem }) {
|
|
|
123
123
|
if (e.key === 'Escape' && drag) cancelDrag();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
// City is the default home when it is registered (ui/city/); Office and Desktop stay one click away.
|
|
127
|
+
let start = 'city';
|
|
128
|
+
try { start = localStorage.getItem(VIEW_KEY) || 'city'; } catch { /* ignore */ }
|
|
128
129
|
const q = new URLSearchParams(location.search).get('view');
|
|
129
|
-
if (q
|
|
130
|
+
if (q) start = q;
|
|
130
131
|
// wait for the first layout of the windows before hiding them
|
|
131
|
-
|
|
132
|
+
net.on('hello', once(() => requestAnimationFrame(() => {
|
|
133
|
+
if (start === 'office' || views.has(start)) setMode(start, { quiet: true });
|
|
134
|
+
})));
|
|
132
135
|
paintSeg();
|
|
133
136
|
setInterval(() => { if (mode === 'office') paintClock(); }, 20000);
|
|
134
137
|
}
|
|
@@ -137,16 +140,45 @@ function once(fn) { let done = false; return (...a) => { if (!done) { done = tru
|
|
|
137
140
|
|
|
138
141
|
export function getMode() { return mode; }
|
|
139
142
|
|
|
143
|
+
/* Other full screen views next to Office and Desktop (the City registers here). */
|
|
144
|
+
const views = new Map();
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Adds a view to the toggle. `enter({ quiet })` shows it; `leave({ quiet, done })` hides it and
|
|
148
|
+
* calls done when it is gone. `first` puts it at the start of the toggle.
|
|
149
|
+
* @param {{ id: string, labelKey: string, titleKey?: string, glyph: () => Node, enter: Function, leave: Function, first?: boolean }} v
|
|
150
|
+
*/
|
|
151
|
+
export function addView(v) {
|
|
152
|
+
views.set(v.id, v);
|
|
153
|
+
const b = h('button', { type: 'button', dataset: { v: v.id }, tip: v.titleKey, on: { click: () => setMode(v.id) } }, v.glyph(), h('span', { tx: v.labelKey }));
|
|
154
|
+
if (v.first) seg.prepend(b); else seg.append(b);
|
|
155
|
+
seg.dataset.tour = 'office';
|
|
156
|
+
paintSeg();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const isScene = (m) => m === 'office' || views.has(m);
|
|
160
|
+
|
|
140
161
|
export function setMode(next, { quiet = false } = {}) {
|
|
141
|
-
if (next === mode) return;
|
|
162
|
+
if (next === mode || !(next === 'desktop' || isScene(next))) return;
|
|
163
|
+
const prev = mode;
|
|
142
164
|
mode = next;
|
|
143
165
|
try { localStorage.setItem(VIEW_KEY, mode); } catch { /* ignore */ }
|
|
144
166
|
paintSeg();
|
|
145
|
-
if (
|
|
146
|
-
// tuck the open windows into the dock, and bring them back
|
|
167
|
+
if (isScene(next) && !isScene(prev)) {
|
|
168
|
+
// tuck the open windows into the dock, and bring them back on the desktop
|
|
147
169
|
hiddenWins = wm.list().filter((w) => !w.min).map((w) => w.id);
|
|
148
170
|
for (const id of hiddenWins) wm.minimize(id);
|
|
149
171
|
deskEl.classList.add('of-on');
|
|
172
|
+
}
|
|
173
|
+
const toDesk = () => {
|
|
174
|
+
if (mode !== 'desktop') return;
|
|
175
|
+
deskEl.classList.remove('of-on');
|
|
176
|
+
for (const id of hiddenWins) if (wm.get(id)?.min) wm.restore(id);
|
|
177
|
+
hiddenWins = [];
|
|
178
|
+
};
|
|
179
|
+
if (views.has(prev)) views.get(prev).leave({ quiet: quiet || isScene(next), done: toDesk });
|
|
180
|
+
if (views.has(next)) { if (prev === 'office') leaveOffice(true, () => {}); views.get(next).enter({ quiet }); return; }
|
|
181
|
+
if (mode === 'office') {
|
|
150
182
|
layer.hidden = false;
|
|
151
183
|
scene.resize(layer.clientWidth, layer.clientHeight);
|
|
152
184
|
scene.reset();
|
|
@@ -154,19 +186,17 @@ export function setMode(next, { quiet = false } = {}) {
|
|
|
154
186
|
audio.setActive(true);
|
|
155
187
|
paintHud();
|
|
156
188
|
if (!quiet && !reducedMotion()) layer.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 260, easing: 'ease-out' });
|
|
157
|
-
} else
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
else layer.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 180, easing: 'ease-in' }).onfinish = done;
|
|
169
|
-
}
|
|
189
|
+
} else if (prev === 'office') leaveOffice(quiet, toDesk);
|
|
190
|
+
else toDesk();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function leaveOffice(quiet, after) {
|
|
194
|
+
scene.stop();
|
|
195
|
+
audio.setActive(false);
|
|
196
|
+
hideTip();
|
|
197
|
+
const done = () => { layer.hidden = true; after(); };
|
|
198
|
+
if (reducedMotion() || quiet) done();
|
|
199
|
+
else layer.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 180, easing: 'ease-in' }).onfinish = done;
|
|
170
200
|
}
|
|
171
201
|
|
|
172
202
|
function paintSeg() {
|
package/ui/office/scene.js
CHANGED
|
@@ -1841,3 +1841,6 @@ function drawNoteIcon(ctx, x, y, s, fill, strip) {
|
|
|
1841
1841
|
ctx.fillStyle = 'rgba(43,29,18,.45)'; ctx.fillRect(-s * 0.36, -s * 0.12, s * 0.7, s * 0.07); ctx.fillRect(-s * 0.36, s * 0.04, s * 0.5, s * 0.07);
|
|
1842
1842
|
ctx.restore();
|
|
1843
1843
|
}
|
|
1844
|
+
|
|
1845
|
+
// Shared with the City scene (ui/city/scene.js), which reuses the Office art.
|
|
1846
|
+
export { roundRect, hexPath, hexScreen, wrap, drawNameTag, drawBubble, drawPill, iconClock, iconCheck, iconX, iconDots, iconMag, iconFlask, iconQuestion, iconPause, drawNoteIcon, drawParcel, mixHex, shade, alpha, rgb, goldenFactor };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|