paseo-office 0.2.0 → 0.2.1
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/OVERVIEW.md +27 -0
- package/README.md +65 -134
- package/client/action-button.tsx +4 -1
- package/client/activity-panel.tsx +6 -4
- package/client/agent-appearance.tsx +257 -0
- package/client/agent-card.tsx +2 -1
- package/client/agent-picker-text.ts +23 -4
- package/client/agent-picker.tsx +5 -8
- package/client/board-sheet.tsx +48 -16
- package/client/board-text.ts +12 -2
- package/client/brand.ts +1 -0
- package/client/chat-chrome.tsx +318 -0
- package/client/chat-compose-tools.tsx +314 -0
- package/client/chat-dictation.tsx +133 -0
- package/client/chat-more.tsx +119 -0
- package/client/chat-panel.tsx +401 -146
- package/client/chat-quick.tsx +198 -0
- package/client/chat-text.ts +25 -6
- package/client/column-sheet.tsx +93 -23
- package/client/conversation-model.ts +19 -5
- package/client/duty-sheet.tsx +321 -0
- package/client/duty-text.ts +20 -0
- package/client/fullscreen-header.tsx +28 -13
- package/client/fullscreen-theme.ts +38 -0
- package/client/host-details.tsx +269 -0
- package/client/host-styles.ts +129 -0
- package/client/host-switches.tsx +197 -73
- package/client/incidents-card.tsx +2 -1
- package/client/janitor-card.tsx +1 -1
- package/client/library-card.tsx +2 -1
- package/client/list-text.ts +8 -6
- package/client/lobby-board.tsx +73 -53
- package/client/machine-card.tsx +225 -85
- package/client/messenger-styles.ts +216 -0
- package/client/new-agent-form.tsx +153 -61
- package/client/new-agent-model.ts +2 -0
- package/client/notes-card.tsx +111 -83
- package/client/notes-days.tsx +1 -1
- package/client/office-brand-context.ts +44 -0
- package/client/office-column.tsx +2 -1
- package/client/office-keyboard.ts +79 -0
- package/client/office-link.ts +7 -1
- package/client/office-mark.tsx +29 -0
- package/client/office-modal.tsx +440 -0
- package/client/office-settings.tsx +75 -30
- package/client/office-state.ts +12 -2
- package/client/office-surface.tsx +591 -81
- package/client/pixel/actors.ts +2 -1
- package/client/pixel/art.ts +33 -19
- package/client/pixel/pixel-office.tsx +2 -2
- package/client/prompt-coach.tsx +152 -0
- package/client/qa-card.tsx +2 -1
- package/client/review-card.tsx +2 -1
- package/client/room-board.tsx +26 -2
- package/client/scene-picker.tsx +158 -0
- package/client/scene-previews.ts +10 -0
- package/client/session-pane.tsx +25 -5
- package/client/session-panel-detail.tsx +238 -0
- package/client/session-panel.tsx +222 -137
- package/client/session-styles.ts +224 -1
- package/client/session-transcript.tsx +243 -0
- package/client/sessions-panel.tsx +181 -22
- package/client/sessions-text.ts +18 -0
- package/client/settings-sections.tsx +126 -0
- package/client/sidebar-launcher.ts +29 -0
- package/client/ssh-hosts.tsx +331 -0
- package/client/ssh-metrics.ts +76 -0
- package/client/standup-card.tsx +2 -1
- package/client/structure-view.tsx +20 -3
- package/client/styles.ts +170 -62
- package/client/team-chat-preview.tsx +96 -0
- package/client/transcript-styles.ts +90 -0
- package/client/use-device-switch.ts +21 -12
- package/client/use-duty-actions.ts +43 -0
- package/client/use-group-photo.ts +48 -0
- package/client/use-new-agent.ts +4 -0
- package/client/use-street.ts +8 -0
- package/client/workspace-office-tools.tsx +102 -0
- package/client/workspace-overlay-route.web.ts +47 -0
- package/client/workspace-overlay.tsx +195 -0
- package/client/world/adapter.ts +37 -2
- package/client/world/escape.ts +58 -0
- package/client/world/use-world-feed.ts +6 -2
- package/client/world/workspace-dock.ts +6 -0
- package/client/world/world-api.ts +45 -4
- package/client/world/world-bridge-page.ts +14 -3
- package/client/world/world-bridge.ts +50 -5
- package/client/world/world-frame.web.ts +8 -0
- package/client/world/world-view-native.tsx +31 -10
- package/client/world/world-view-shared.ts +36 -7
- package/client/world/world-view.tsx +93 -21
- package/docs/office.md +148 -58
- package/index.client.tsx +13 -6
- package/index.server.ts +125 -9
- package/package.json +2 -1
- package/server/activity.ts +42 -19
- package/server/agent-tools.ts +11 -5
- package/server/board-service.ts +381 -10
- package/server/brand-logo.ts +34 -0
- package/server/chat-group.ts +83 -0
- package/server/chat-service.ts +406 -62
- package/server/chat-store.ts +1 -4
- package/server/directory.ts +22 -7
- package/server/duty-service.ts +230 -0
- package/server/group-photo.ts +39 -0
- package/server/home-departure.ts +47 -0
- package/server/hub.ts +43 -1
- package/server/live-ports.ts +114 -18
- package/server/lobby-pickup.ts +170 -0
- package/server/machine/details.ts +91 -0
- package/server/mention-queue.ts +14 -0
- package/server/office.ts +110 -6
- package/server/paths.ts +9 -0
- package/server/ssh/LICENSE.paseo +211 -0
- package/server/ssh/client.ts +401 -0
- package/server/ssh/discovery.ts +230 -0
- package/server/ssh/installed.ts +104 -0
- package/server/ssh/monitor.ts +104 -0
- package/server/ssh/pid-files.ts +194 -0
- package/server/ssh/read.ts +136 -0
- package/server/subagent-names.ts +4 -0
- package/server/words.generated.ts +1 -1
- package/server/world.generated.ts +1 -1
- package/shared/appearance.ts +43 -0
- package/shared/branding.ts +53 -0
- package/shared/chat-words.ts +2 -2
- package/shared/contracts.ts +135 -4
- package/shared/duties.ts +100 -0
- package/shared/host-details.ts +25 -0
- package/shared/lobby-assignment.ts +34 -0
- package/shared/model.ts +9 -1
- package/shared/names.ts +2 -0
- package/shared/settings.ts +14 -3
- package/shared/ssh.ts +34 -0
- package/shared/upstream/README.md +1 -3
- package/shared/upstream/chat-engine.d.ts +4 -0
- package/shared/upstream/prompt-coach.d.ts +6 -0
- package/shared/upstream/prompt-coach.js +178 -0
package/index.client.tsx
CHANGED
|
@@ -3,21 +3,28 @@ import type { PluginClientContext, PluginSidebarItemProps } from "@getpaseo/plug
|
|
|
3
3
|
import { SidebarRow } from "@getpaseo/plugin/client/ui";
|
|
4
4
|
import { OfficeSettings } from "./client/office-settings.js";
|
|
5
5
|
import { createOfficeSurface } from "./client/office-surface.js";
|
|
6
|
+
import { createSidebarLauncher } from "./client/sidebar-launcher.js";
|
|
6
7
|
|
|
7
8
|
const SCREEN_ID = "office";
|
|
8
9
|
const PANEL_ID = "office";
|
|
9
10
|
const ICON = "Building2";
|
|
10
11
|
|
|
11
|
-
function OfficeItem({ currentScreen, openScreen }: PluginSidebarItemProps) {
|
|
12
|
-
const open = useCallback(() => openScreen({ screenId: SCREEN_ID }), [openScreen]);
|
|
13
|
-
return <SidebarRow icon={ICON} active={currentScreen?.screenId === SCREEN_ID} onPress={open} />;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
12
|
// The sidebar item and the two Command Center items (the office, its settings) are the ways in;
|
|
17
13
|
// Settings > Sidebar can hide the sidebar item. The office's settings are a screen of the app's
|
|
18
14
|
// Settings.
|
|
19
15
|
export default function contribute(client: PluginClientContext) {
|
|
20
|
-
const
|
|
16
|
+
const launcher = createSidebarLauncher();
|
|
17
|
+
const Surface = createOfficeSurface(() => client.openSettings(SCREEN_ID), launcher);
|
|
18
|
+
function OfficeItem({ currentScreen, layout, openScreen }: PluginSidebarItemProps) {
|
|
19
|
+
const open = useCallback(() => {
|
|
20
|
+
if (layout.platform !== "web") {
|
|
21
|
+
openScreen({ screenId: SCREEN_ID });
|
|
22
|
+
} else if (!launcher.open()) {
|
|
23
|
+
openScreen({ screenId: SCREEN_ID, params: { layout: "fullscreen" } });
|
|
24
|
+
}
|
|
25
|
+
}, [layout.platform, openScreen]);
|
|
26
|
+
return <SidebarRow icon={ICON} active={currentScreen?.screenId === SCREEN_ID} onPress={open} />;
|
|
27
|
+
}
|
|
21
28
|
const removers = [
|
|
22
29
|
client.addScreen({ id: SCREEN_ID, title: "Office 3D", Component: Surface }),
|
|
23
30
|
client.addSettingsScreen({
|
package/index.server.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createLogoReader } from "./server/brand-logo.js";
|
|
2
|
+
import { hostBrand } from "./shared/branding.js";
|
|
1
3
|
import { createHash } from "node:crypto";
|
|
2
4
|
import { execCommand } from "@getpaseo/plugin/server";
|
|
3
5
|
import { createTenure, TenureLedgerSchema, type TenureLedger } from "./server/tenure.js";
|
|
@@ -8,7 +10,13 @@ import { streetSubscription } from "./shared/contracts.js";
|
|
|
8
10
|
import { createLifeFeed } from "./server/life-feed.js";
|
|
9
11
|
import { createLifeFile, createSaveQueue, type LifeFile } from "./server/life-store.js";
|
|
10
12
|
import { liftFile, tenureFile } from "./server/paths.js";
|
|
11
|
-
import {
|
|
13
|
+
import { createDepartureArchiver } from "./server/home-departure.js";
|
|
14
|
+
import {
|
|
15
|
+
lifeSubscription,
|
|
16
|
+
homeDepartureRpc,
|
|
17
|
+
tenureRpc,
|
|
18
|
+
type LifeEvent,
|
|
19
|
+
} from "./shared/contracts.js";
|
|
12
20
|
import { embeddedWorldWords, type WorldWords } from "./server/world-words.js";
|
|
13
21
|
import { homedir } from "node:os";
|
|
14
22
|
import { setTimeout as delay } from "node:timers/promises";
|
|
@@ -44,8 +52,12 @@ import {
|
|
|
44
52
|
liveScriptLogPorts,
|
|
45
53
|
liveSkillsPorts,
|
|
46
54
|
} from "./server/live-ports.js";
|
|
55
|
+
import { createSshMonitor } from "./server/ssh/monitor.js";
|
|
56
|
+
import { sshReadingRpc, sshServersRpc } from "./shared/ssh.js";
|
|
47
57
|
import { cleanUpAgent } from "./server/machine/cleanup.js";
|
|
48
58
|
import { liveCleanupPorts, liveMachinePorts } from "./server/machine/live-ports.js";
|
|
59
|
+
import { hostDetailsRpc, type HostSample } from "./shared/host-details.js";
|
|
60
|
+
import { readHostDetails, recordSample } from "./server/machine/details.js";
|
|
49
61
|
import { createMachineReader } from "./server/machine/machine.js";
|
|
50
62
|
import { createMachineWatch } from "./server/machine/watch.js";
|
|
51
63
|
import { nodeNotesFs, readMonthNotes } from "./server/notes-files.js";
|
|
@@ -57,11 +69,18 @@ import {
|
|
|
57
69
|
} from "./server/notes-schedule.js";
|
|
58
70
|
import { createNotesStore, createNotesWriter, type NotesStore } from "./server/notes-writer.js";
|
|
59
71
|
import { createLocalSchedules, type LocalSchedules } from "./server/local-schedules.js";
|
|
72
|
+
import {
|
|
73
|
+
DUTY_SCHEDULE,
|
|
74
|
+
createDutyService,
|
|
75
|
+
dutiesFileStore,
|
|
76
|
+
type DutiesFile,
|
|
77
|
+
} from "./server/duty-service.js";
|
|
60
78
|
import { createOffice } from "./server/office.js";
|
|
61
79
|
import { createPaseoHolder } from "./server/paseo-holder.js";
|
|
62
80
|
import {
|
|
63
81
|
boardsFile,
|
|
64
82
|
chatFile,
|
|
83
|
+
dutiesFile,
|
|
65
84
|
hostSkillFolders,
|
|
66
85
|
incidentsFile,
|
|
67
86
|
notesWriterFile,
|
|
@@ -75,6 +94,8 @@ import {
|
|
|
75
94
|
cleanupRpc,
|
|
76
95
|
clearDoneRpc,
|
|
77
96
|
deleteRpc,
|
|
97
|
+
dutiesSaveRpc,
|
|
98
|
+
dutyActedRpc,
|
|
78
99
|
incidentsDismissRpc,
|
|
79
100
|
janitorRpc,
|
|
80
101
|
machineSubscription,
|
|
@@ -86,6 +107,7 @@ import {
|
|
|
86
107
|
setWakesPausedRpc,
|
|
87
108
|
skillsRpc,
|
|
88
109
|
updateRpc,
|
|
110
|
+
worldLogoRpc,
|
|
89
111
|
worldRpc,
|
|
90
112
|
streetRpc,
|
|
91
113
|
worldWordsRpc,
|
|
@@ -105,6 +127,8 @@ export interface OfficePluginDeps {
|
|
|
105
127
|
chatStore: ChatStore;
|
|
106
128
|
tenureFile: LifeFile<TenureLedger>;
|
|
107
129
|
liftFile: LifeFile<LiftKept>;
|
|
130
|
+
/** The owner's duty list. */
|
|
131
|
+
dutiesFile: LifeFile<DutiesFile>;
|
|
108
132
|
/** The daemon's environment: the trackers' tokens are read from it. */
|
|
109
133
|
env: NodeJS.ProcessEnv;
|
|
110
134
|
clock: Clock;
|
|
@@ -134,6 +158,16 @@ export interface MachineHost {
|
|
|
134
158
|
sleep(ms: number): Promise<void>;
|
|
135
159
|
}
|
|
136
160
|
|
|
161
|
+
/** `zone`, or `hostTimeZone` when this host's Intl does not know it. */
|
|
162
|
+
function knownZone(zone: string, hostTimeZone: string): string {
|
|
163
|
+
try {
|
|
164
|
+
Intl.DateTimeFormat("en-US", { timeZone: zone });
|
|
165
|
+
return zone;
|
|
166
|
+
} catch {
|
|
167
|
+
return hostTimeZone;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
137
171
|
/** Why a turn did not complete, for the notes writer; null for one that did. */
|
|
138
172
|
function turnProblem(outcome: PluginTurnOutcome): string | null {
|
|
139
173
|
switch (outcome.kind) {
|
|
@@ -154,6 +188,7 @@ export function createOfficePlugin(
|
|
|
154
188
|
const { log } = deps;
|
|
155
189
|
const holder = createPaseoHolder();
|
|
156
190
|
const hub = createHub(liveHubPorts(holder, deps.clock, log));
|
|
191
|
+
hub.setBrand(hostBrand({}, deps.env));
|
|
157
192
|
const office = createOffice({
|
|
158
193
|
store: deps.store,
|
|
159
194
|
clock: deps.clock,
|
|
@@ -162,16 +197,23 @@ export function createOfficePlugin(
|
|
|
162
197
|
log,
|
|
163
198
|
});
|
|
164
199
|
|
|
200
|
+
const samples: HostSample[] = [];
|
|
201
|
+
const reader = createMachineReader({
|
|
202
|
+
procRoot: deps.machine.procRoot,
|
|
203
|
+
cgroupRoot: deps.machine.cgroupRoot,
|
|
204
|
+
platform: deps.machine.platform,
|
|
205
|
+
...liveMachinePorts(holder, () => deps.clock.now()),
|
|
206
|
+
});
|
|
165
207
|
const machine = createMachineWatch({
|
|
166
|
-
read
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}).read,
|
|
208
|
+
async read() {
|
|
209
|
+
const reading = await reader.read();
|
|
210
|
+
if (reading) recordSample(samples, reading);
|
|
211
|
+
return reading;
|
|
212
|
+
},
|
|
172
213
|
timers: deps.clock,
|
|
173
214
|
log,
|
|
174
215
|
});
|
|
216
|
+
const ssh = createSshMonitor(deps.env, homedir(), deps.machine.procRoot);
|
|
175
217
|
const cleanupPorts = {
|
|
176
218
|
procRoot: deps.machine.procRoot,
|
|
177
219
|
selfPid: deps.machine.selfPid,
|
|
@@ -227,6 +269,23 @@ export function createOfficePlugin(
|
|
|
227
269
|
changed: (state) => hub.setNotes({ ...state, scheduleError: notesSchedule.error() }),
|
|
228
270
|
log,
|
|
229
271
|
});
|
|
272
|
+
// The duty list, posted on the duty board at 08:00 in the notes' zone, and caught up at the
|
|
273
|
+
// start and at each save. A zone that cannot be read, or that Intl does not know, is the host's.
|
|
274
|
+
const duties = createDutyService({
|
|
275
|
+
file: deps.dutiesFile,
|
|
276
|
+
board: office,
|
|
277
|
+
schedules: deps.schedules,
|
|
278
|
+
zone: () =>
|
|
279
|
+
readHostSettings().then(
|
|
280
|
+
(values) => knownZone(notesTimeZone(values, deps.hostTimeZone), deps.hostTimeZone),
|
|
281
|
+
() => deps.hostTimeZone,
|
|
282
|
+
),
|
|
283
|
+
now: () => deps.clock.now(),
|
|
284
|
+
listed: (list) => office.setDuties(list),
|
|
285
|
+
changed: (state) => hub.setDuties(state),
|
|
286
|
+
log,
|
|
287
|
+
});
|
|
288
|
+
void duties.start();
|
|
230
289
|
// Every 5 minutes while a tracker is on; it follows the settings as the 8:00 schedule does.
|
|
231
290
|
const incidentsSchedule = createIncidentsSchedule({ schedules: deps.schedules, log });
|
|
232
291
|
// The check's last state, kept so a save that changes the schedule's error pushes it again.
|
|
@@ -307,12 +366,14 @@ export function createOfficePlugin(
|
|
|
307
366
|
// then the chat call waits, and a snapshot has no chat.
|
|
308
367
|
let chat: ChatService | null = null;
|
|
309
368
|
let stopWatching: (() => void) | null = null;
|
|
369
|
+
const chatPorts = liveChatPorts(holder);
|
|
310
370
|
async function startChat(): Promise<void> {
|
|
311
371
|
const service = await createChatService({
|
|
312
372
|
store: deps.chatStore,
|
|
373
|
+
lobbyPosts: office.lobbyPosts,
|
|
313
374
|
clock: deps.clock,
|
|
314
375
|
tr: chatT,
|
|
315
|
-
...
|
|
376
|
+
...chatPorts,
|
|
316
377
|
emit: (change) => hub.chatChange(change),
|
|
317
378
|
log,
|
|
318
379
|
});
|
|
@@ -323,14 +384,20 @@ export function createOfficePlugin(
|
|
|
323
384
|
const chatReady = startChat().catch((error: unknown) =>
|
|
324
385
|
log(`[office] chat unavailable: ${errorMessage(error)}`),
|
|
325
386
|
);
|
|
387
|
+
let agentToolsOn = false;
|
|
388
|
+
void holder.wait().then(() => office.setPickupEnabled(agentToolsOn));
|
|
326
389
|
// Neither schedule can follow settings it cannot read: both cards say why until a save is read.
|
|
327
390
|
function settingsUnreadable(reason: string): void {
|
|
391
|
+
agentToolsOn = false;
|
|
392
|
+
office.setPickupEnabled(false);
|
|
328
393
|
const message = `The office's settings cannot be read: ${reason}`;
|
|
329
394
|
log(`[office] ${message}`);
|
|
330
395
|
notesSchedule.fail(message);
|
|
331
396
|
incidentsSchedule.fail(message);
|
|
332
397
|
hub.setNotes({ ...writer.state(), scheduleError: notesSchedule.error() });
|
|
333
398
|
pushIncidents();
|
|
399
|
+
// The duty board's zone is then the host's, so its 8:00 run still comes.
|
|
400
|
+
void duties.settingsChanged();
|
|
334
401
|
}
|
|
335
402
|
async function followSettings(
|
|
336
403
|
state: PluginSettingsState<typeof officeHostSettings.schema>,
|
|
@@ -339,8 +406,12 @@ export function createOfficePlugin(
|
|
|
339
406
|
settingsUnreadable(state.error);
|
|
340
407
|
return;
|
|
341
408
|
}
|
|
409
|
+
hub.setBrand(hostBrand(state.values, deps.env));
|
|
410
|
+
agentToolsOn = state.values.agentTools;
|
|
411
|
+
office.setPickupEnabled(agentToolsOn && holder.held());
|
|
342
412
|
weather.settingsChanged(state.values);
|
|
343
413
|
await notesSchedule.sync(state.values);
|
|
414
|
+
await duties.settingsChanged();
|
|
344
415
|
// The writer reads the folder again, and its push carries the schedule's error with it.
|
|
345
416
|
await writer
|
|
346
417
|
.settingsChanged()
|
|
@@ -376,9 +447,18 @@ export function createOfficePlugin(
|
|
|
376
447
|
return hub.attach(context);
|
|
377
448
|
});
|
|
378
449
|
server.handle(streetRpc, () => guarded("street", () => deps.world.readStreet()));
|
|
450
|
+
const readLogo = createLogoReader();
|
|
451
|
+
server.handle(worldLogoRpc, async () => {
|
|
452
|
+
const current = await settings.read();
|
|
453
|
+
const url = hostBrand(current.status === "ready" ? current.values : {}, deps.env)?.logoUrl;
|
|
454
|
+
return url ? { url, data: await readLogo(url) } : null;
|
|
455
|
+
});
|
|
379
456
|
server.handle(worldRpc, () => guarded("world", () => deps.world.read()));
|
|
380
457
|
server.handle(worldWordsRpc, (input) => guarded("words", () => deps.words.read(input.language)));
|
|
381
458
|
// The readings stop with the last subscriber: nothing walks /proc while no office is open.
|
|
459
|
+
server.handle(sshServersRpc, (_input, context) => ssh.list(context.paseo));
|
|
460
|
+
server.handle(sshReadingRpc, ({ id }, context) => ssh.read(context.paseo, id));
|
|
461
|
+
server.handle(hostDetailsRpc, () => readHostDetails(deps.machine.procRoot, homedir(), samples));
|
|
382
462
|
server.handle(machineSubscription, (_input, context) => {
|
|
383
463
|
holder.remember(context.paseo);
|
|
384
464
|
return machine.attach(context);
|
|
@@ -439,6 +519,14 @@ export function createOfficePlugin(
|
|
|
439
519
|
holder.remember(context.paseo);
|
|
440
520
|
return guarded("pause", () => office.setWakesPaused(input.paused));
|
|
441
521
|
});
|
|
522
|
+
server.handle(dutiesSaveRpc, (input, context) => {
|
|
523
|
+
holder.remember(context.paseo);
|
|
524
|
+
return guarded("duties save", () => duties.save(input.duties));
|
|
525
|
+
});
|
|
526
|
+
server.handle(dutyActedRpc, (input, context) => {
|
|
527
|
+
holder.remember(context.paseo);
|
|
528
|
+
return guarded("duty acted", () => office.actDuty(input.id, input.agentId));
|
|
529
|
+
});
|
|
442
530
|
// The bell. A start never rejects: why none started is in the snapshot's notes.
|
|
443
531
|
server.handle(notesWriteRpc, (_input, context) => {
|
|
444
532
|
holder.remember(context.paseo);
|
|
@@ -472,6 +560,8 @@ export function createOfficePlugin(
|
|
|
472
560
|
}
|
|
473
561
|
await writer.start();
|
|
474
562
|
});
|
|
563
|
+
// The duty board's day: what is due is posted, and done duties of earlier days leave.
|
|
564
|
+
const stopDutyRuns = deps.schedules.handle(DUTY_SCHEDULE, (dueAt) => duties.sync(dueAt));
|
|
475
565
|
server.handle(incidentsDismissRpc, ({ ids }) =>
|
|
476
566
|
guarded("incidents dismiss", async () => ({ dismissed: await incidents.dismiss(ids) })),
|
|
477
567
|
);
|
|
@@ -504,6 +594,19 @@ export function createOfficePlugin(
|
|
|
504
594
|
});
|
|
505
595
|
});
|
|
506
596
|
server.handle(streetSubscription, (_input, context) => streets.attach(context));
|
|
597
|
+
const archiveDeparture = createDepartureArchiver(
|
|
598
|
+
() => hub.read(),
|
|
599
|
+
async () => {
|
|
600
|
+
const state = await settings.read();
|
|
601
|
+
return state.status === "ready" && state.values.archiveOnDeparture === true;
|
|
602
|
+
},
|
|
603
|
+
);
|
|
604
|
+
server.handle(homeDepartureRpc, (input, context) =>
|
|
605
|
+
guarded("home departure", async () => {
|
|
606
|
+
holder.remember(context.paseo);
|
|
607
|
+
return { archived: await archiveDeparture(context.paseo, input.agentId, input.idleSince) };
|
|
608
|
+
}),
|
|
609
|
+
);
|
|
507
610
|
server.handle(tenureRpc, async (input, context) => {
|
|
508
611
|
holder.remember(context.paseo);
|
|
509
612
|
return (await lifeReady)?.write(input) ?? { ok: false };
|
|
@@ -540,6 +643,16 @@ export function createOfficePlugin(
|
|
|
540
643
|
holder.remember(context.paseo);
|
|
541
644
|
office.noteAgent(agent);
|
|
542
645
|
office.turnEnded(agent.id);
|
|
646
|
+
if (outcome.kind === "completed" && turnId !== null) {
|
|
647
|
+
await office
|
|
648
|
+
.checkCompletion(
|
|
649
|
+
agent.id,
|
|
650
|
+
async () => (await chatPorts.readTurn(agent.id, turnId)).text,
|
|
651
|
+
)
|
|
652
|
+
.catch((error: unknown) =>
|
|
653
|
+
log(`[office] lobby completion check failed: ${errorMessage(error)}`),
|
|
654
|
+
);
|
|
655
|
+
}
|
|
543
656
|
await (
|
|
544
657
|
await lifeReady
|
|
545
658
|
)?.turnEnded(agent.id, async () => {
|
|
@@ -609,6 +722,7 @@ export function createOfficePlugin(
|
|
|
609
722
|
stopWatchingWeather();
|
|
610
723
|
weather.stop();
|
|
611
724
|
stopNotesRuns();
|
|
725
|
+
stopDutyRuns();
|
|
612
726
|
stopIncidentsRuns();
|
|
613
727
|
deps.schedules.stop();
|
|
614
728
|
for (const remove of removeHooks) remove();
|
|
@@ -619,7 +733,8 @@ export function createOfficePlugin(
|
|
|
619
733
|
for (const close of listeners.values()) close();
|
|
620
734
|
await Promise.all([tenureSaves.flush(), liftSaved]);
|
|
621
735
|
machine.stop();
|
|
622
|
-
|
|
736
|
+
await ssh.stop();
|
|
737
|
+
await office.stop();
|
|
623
738
|
// A chat still loading would start its clock after this stop.
|
|
624
739
|
await chatReady;
|
|
625
740
|
stopWatching?.();
|
|
@@ -642,6 +757,7 @@ export default function contribute(server: PluginServerContext): () => Promise<v
|
|
|
642
757
|
incidentsStore: createIncidentsStore({ file: incidentsFile(process.env, homedir()), log }),
|
|
643
758
|
tenureFile: createLifeFile(tenureFile(process.env, homedir()), TenureLedgerSchema),
|
|
644
759
|
liftFile: createLifeFile(liftFile(process.env, homedir()), LiftKeptSchema),
|
|
760
|
+
dutiesFile: dutiesFileStore(dutiesFile(process.env, homedir()), { now: () => Date.now(), log }),
|
|
645
761
|
chatStore: createChatStore({
|
|
646
762
|
file: chatFile(process.env, homedir()),
|
|
647
763
|
now: () => Date.now(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-office",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A community port of my-office for Paseo: your agents at their desks, in 3D.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"paseo-plugin.json",
|
|
23
|
+
"OVERVIEW.md",
|
|
23
24
|
"icon.png",
|
|
24
25
|
"index.client.tsx",
|
|
25
26
|
"index.server.ts",
|
package/server/activity.ts
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
CHECKLIST_STEP_MAX,
|
|
3
3
|
CHECKLIST_TEXT_MAX,
|
|
4
4
|
type ChecklistStep,
|
|
5
|
+
type ChecklistCounts,
|
|
6
|
+
type ChecklistProgress,
|
|
5
7
|
type Checklists,
|
|
6
8
|
} from "../shared/contracts.js";
|
|
7
9
|
import type { ActivityKind, ActivityStep, TestResult } from "../shared/names.js";
|
|
@@ -248,36 +250,40 @@ export function nextStep(
|
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
/**
|
|
251
|
-
* A step as the office sends it: its text's first line, cut to the most it sends.
|
|
252
|
-
* finished step, and for one with no text to show.
|
|
253
|
+
* A step as the office sends it: its text's first line, cut to the most it sends. Finished steps contribute to the count only.
|
|
253
254
|
*/
|
|
254
|
-
function checklistStep(entry: unknown): ChecklistStep | null {
|
|
255
|
+
function checklistStep(entry: unknown): ChecklistStep | "done" | null {
|
|
255
256
|
const text = field(entry, "text");
|
|
256
257
|
if (typeof text !== "string") return null;
|
|
257
258
|
const status = field(entry, "status");
|
|
258
259
|
// Either one saying finished wins: providers do not keep the pair consistent.
|
|
259
260
|
const finished = field(entry, "completed") === true || status === "completed";
|
|
260
|
-
if (finished) return null;
|
|
261
261
|
const line = text.split(/[\r\n]/, 1)[0].trim();
|
|
262
262
|
if (line === "") return null;
|
|
263
|
+
if (finished) return "done";
|
|
263
264
|
const shown =
|
|
264
265
|
line.length > CHECKLIST_TEXT_MAX ? `${line.slice(0, CHECKLIST_TEXT_MAX - 1)}…` : line;
|
|
265
266
|
return { text: shown, status: status === "in_progress" ? "in_progress" : "pending" };
|
|
266
267
|
}
|
|
267
268
|
|
|
268
269
|
/** The unfinished steps of the newest todo item in a tail; null when the tail has none. */
|
|
269
|
-
export function readChecklist(items: readonly ActivityItem[]):
|
|
270
|
+
export function readChecklist(items: readonly ActivityItem[]): {
|
|
271
|
+
steps: ChecklistStep[];
|
|
272
|
+
progress: ChecklistProgress;
|
|
273
|
+
} | null {
|
|
270
274
|
const todo = items.findLast((item) => item.type === "todo");
|
|
271
275
|
if (todo === undefined) return null;
|
|
272
|
-
|
|
273
|
-
const
|
|
276
|
+
const entries: readonly unknown[] = Array.isArray(todo.items) ? todo.items : [];
|
|
277
|
+
const progress = { completed: 0, total: 0 };
|
|
274
278
|
const steps: ChecklistStep[] = [];
|
|
275
279
|
for (const entry of entries) {
|
|
276
280
|
const step = checklistStep(entry);
|
|
277
|
-
if (step
|
|
278
|
-
|
|
281
|
+
if (step === null) continue;
|
|
282
|
+
progress.total++;
|
|
283
|
+
if (step === "done") progress.completed++;
|
|
284
|
+
else if (steps.length < CHECKLIST_STEP_MAX) steps.push(step);
|
|
279
285
|
}
|
|
280
|
-
return steps;
|
|
286
|
+
return { steps, progress };
|
|
281
287
|
}
|
|
282
288
|
|
|
283
289
|
/** What the poller knows of each running agent: its line, and its step when it is at one. */
|
|
@@ -295,7 +301,12 @@ export interface ActivityPorts {
|
|
|
295
301
|
* steps are finished; an agent whose read failed, or whose tail has none, is absent. An agent
|
|
296
302
|
* that stopped since the last round is read for this alone, once.
|
|
297
303
|
*/
|
|
298
|
-
onChange(
|
|
304
|
+
onChange(
|
|
305
|
+
activity: ActivityLines,
|
|
306
|
+
doing: ActivitySteps,
|
|
307
|
+
checklists: Readonly<Checklists>,
|
|
308
|
+
progress: Readonly<ChecklistCounts>,
|
|
309
|
+
): void;
|
|
299
310
|
}
|
|
300
311
|
|
|
301
312
|
export interface ActivityPoller {
|
|
@@ -325,7 +336,7 @@ export function startActivityPoller(ports: ActivityPorts): ActivityPoller {
|
|
|
325
336
|
let cancel: (() => void) | null = null;
|
|
326
337
|
let previous: ActivityLines = {};
|
|
327
338
|
let previousSteps: ActivitySteps = {};
|
|
328
|
-
let previousChecklists = "{}";
|
|
339
|
+
let previousChecklists = "[{},{}]";
|
|
329
340
|
let wasRunning: readonly string[] = [];
|
|
330
341
|
// The calls each agent's last read saw, kept while the poller runs: an agent's next turn is
|
|
331
342
|
// read against them too. A prompt ends the look back, so an old turn's call is never told.
|
|
@@ -336,6 +347,7 @@ export function startActivityPoller(ports: ActivityPorts): ActivityPoller {
|
|
|
336
347
|
next: Record<string, string>,
|
|
337
348
|
steps: Record<string, ActivityStep>,
|
|
338
349
|
checklists: Checklists,
|
|
350
|
+
progress: ChecklistCounts,
|
|
339
351
|
): Promise<void> {
|
|
340
352
|
try {
|
|
341
353
|
const items = await ports.tail(agentId);
|
|
@@ -345,7 +357,10 @@ export function startActivityPoller(ports: ActivityPorts): ActivityPoller {
|
|
|
345
357
|
const step = nextStep(previousSteps[agentId], items, seen);
|
|
346
358
|
if (step !== null) steps[agentId] = step;
|
|
347
359
|
const checklist = readChecklist(items);
|
|
348
|
-
if (checklist !== null)
|
|
360
|
+
if (checklist !== null) {
|
|
361
|
+
checklists[agentId] = checklist.steps;
|
|
362
|
+
progress[agentId] = checklist.progress;
|
|
363
|
+
}
|
|
349
364
|
const calls = callsIn(items);
|
|
350
365
|
// A call held back for a run's end has not been told: it stays new for the next read.
|
|
351
366
|
const newest = describeStep(items, seen);
|
|
@@ -362,10 +377,17 @@ export function startActivityPoller(ports: ActivityPorts): ActivityPoller {
|
|
|
362
377
|
|
|
363
378
|
// An agent often ticks its last step and stops between two reads: it is read once more after
|
|
364
379
|
// it stopped, for its checklist alone. A failed read leaves the checklist it had.
|
|
365
|
-
async function readStopped(
|
|
380
|
+
async function readStopped(
|
|
381
|
+
agentId: string,
|
|
382
|
+
checklists: Checklists,
|
|
383
|
+
progress: ChecklistCounts,
|
|
384
|
+
): Promise<void> {
|
|
366
385
|
try {
|
|
367
386
|
const checklist = readChecklist(await ports.tail(agentId));
|
|
368
|
-
if (checklist !== null)
|
|
387
|
+
if (checklist !== null) {
|
|
388
|
+
checklists[agentId] = checklist.steps;
|
|
389
|
+
progress[agentId] = checklist.progress;
|
|
390
|
+
}
|
|
369
391
|
} catch (error) {
|
|
370
392
|
if (!stopped) ports.log(`[office] activity of ${agentId}: ${errorMessage(error)}`);
|
|
371
393
|
}
|
|
@@ -375,17 +397,18 @@ export function startActivityPoller(ports: ActivityPorts): ActivityPoller {
|
|
|
375
397
|
const next: Record<string, string> = {};
|
|
376
398
|
const steps: Record<string, ActivityStep> = {};
|
|
377
399
|
const checklists: Checklists = {};
|
|
400
|
+
const progress: ChecklistCounts = {};
|
|
378
401
|
const running = [...ports.running()];
|
|
379
402
|
for (const agentId of running) {
|
|
380
403
|
if (stopped) return;
|
|
381
|
-
await readOne(agentId, next, steps, checklists);
|
|
404
|
+
await readOne(agentId, next, steps, checklists, progress);
|
|
382
405
|
}
|
|
383
406
|
for (const agentId of wasRunning) {
|
|
384
407
|
if (stopped) return;
|
|
385
|
-
if (!running.includes(agentId)) await readStopped(agentId, checklists);
|
|
408
|
+
if (!running.includes(agentId)) await readStopped(agentId, checklists, progress);
|
|
386
409
|
}
|
|
387
410
|
wasRunning = running;
|
|
388
|
-
const checklistsText = JSON.stringify(checklists);
|
|
411
|
+
const checklistsText = JSON.stringify([checklists, progress]);
|
|
389
412
|
const unchanged =
|
|
390
413
|
sameLines(previous, next) &&
|
|
391
414
|
sameSteps(previousSteps, steps) &&
|
|
@@ -394,7 +417,7 @@ export function startActivityPoller(ports: ActivityPorts): ActivityPoller {
|
|
|
394
417
|
previous = next;
|
|
395
418
|
previousSteps = steps;
|
|
396
419
|
previousChecklists = checklistsText;
|
|
397
|
-
ports.onChange(next, steps, checklists);
|
|
420
|
+
ports.onChange(next, steps, checklists, progress);
|
|
398
421
|
}
|
|
399
422
|
|
|
400
423
|
function runLogged(): void {
|
package/server/agent-tools.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@getpaseo/plugin/server";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import {
|
|
9
|
+
DUTY,
|
|
9
10
|
LOBBY,
|
|
10
11
|
POST_TEXT_MAX,
|
|
11
12
|
PostKindSchema,
|
|
@@ -32,9 +33,11 @@ export interface OfficeToolPorts {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const BoardChoiceSchema = z.enum(["room", "lobby"]);
|
|
36
|
+
/** The duty board is read, and its duties claimed and finished; it takes no post. */
|
|
37
|
+
const ReadChoiceSchema = z.enum(["room", "lobby", "duty"]);
|
|
35
38
|
|
|
36
39
|
export const ReadInputSchema = z.object({
|
|
37
|
-
board:
|
|
40
|
+
board: ReadChoiceSchema.optional(),
|
|
38
41
|
since: z.number().int().nonnegative().optional(),
|
|
39
42
|
});
|
|
40
43
|
export type ReadInput = z.output<typeof ReadInputSchema>;
|
|
@@ -53,8 +56,9 @@ export type UpdateInput = z.output<typeof UpdateInputSchema>;
|
|
|
53
56
|
/** "room" is the caller's workspace board; without a workspace it is the lobby. */
|
|
54
57
|
export function boardFor(
|
|
55
58
|
agent: Pick<ToolAgent, "workspaceId">,
|
|
56
|
-
choice: "room" | "lobby" | undefined,
|
|
59
|
+
choice: "room" | "lobby" | "duty" | undefined,
|
|
57
60
|
): string {
|
|
61
|
+
if (choice === "duty") return DUTY;
|
|
58
62
|
return choice === "lobby" || agent.workspaceId === null ? LOBBY : agent.workspaceId;
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -63,8 +67,9 @@ export function postLine(post: Post, label: (author: string) => string): string
|
|
|
63
67
|
const name = (author: string) => oneLine(label(author));
|
|
64
68
|
const state = post.state ? ` ${post.state}` : "";
|
|
65
69
|
const claim = post.claimedBy ? ` by ${name(post.claimedBy)}` : "";
|
|
70
|
+
const link = post.link ? ` (${post.board === LOBBY ? "on" : "lobby"} ${post.link})` : "";
|
|
66
71
|
const to = post.to ? ` to ${name(post.to)}` : "";
|
|
67
|
-
return `${post.id} ${post.kind}${state}${claim}, from ${name(post.author)}${to}: ${indented(post.text)}`;
|
|
72
|
+
return `${post.id} ${post.kind}${state}${claim}${link}, from ${name(post.author)}${to}: ${indented(post.text)}`;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
export function readText(
|
|
@@ -132,7 +137,7 @@ export function officeTools(ports: OfficeToolPorts): AgentToolDefinition[] {
|
|
|
132
137
|
defineAgentTool({
|
|
133
138
|
name: "office_read",
|
|
134
139
|
description:
|
|
135
|
-
"Read your workspace's office board (or board: lobby). Up to 30 posts, newest last
|
|
140
|
+
"Read your workspace's office board (or board: lobby, or duty for the day's duties). Up to 30 posts, newest last; pass the cursor as since for newer only.",
|
|
136
141
|
input: ReadInputSchema,
|
|
137
142
|
execute: (input, { agent }) => runRead(ports, agent, input),
|
|
138
143
|
}),
|
|
@@ -145,7 +150,8 @@ export function officeTools(ports: OfficeToolPorts): AgentToolDefinition[] {
|
|
|
145
150
|
}),
|
|
146
151
|
defineAgentTool({
|
|
147
152
|
name: "office_update",
|
|
148
|
-
description:
|
|
153
|
+
description:
|
|
154
|
+
"Claim, finish (done) or reopen a task or a duty on an office board (the duty board too), by post id.",
|
|
149
155
|
input: UpdateInputSchema,
|
|
150
156
|
execute: (input, { agent }) => runUpdate(ports, agent, input),
|
|
151
157
|
}),
|