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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
3
|
+
import { dutiesSaveRpc, dutyActedRpc, updateRpc } from "../shared/contracts.js";
|
|
4
|
+
import type { DutyDraft } from "../shared/duties.js";
|
|
5
|
+
|
|
6
|
+
export interface DutyActions {
|
|
7
|
+
/** Saves the whole list; rejects with the host's reason. */
|
|
8
|
+
save(duties: DutyDraft[]): Promise<void>;
|
|
9
|
+
markDone(id: string): Promise<void>;
|
|
10
|
+
reopen(id: string): Promise<void>;
|
|
11
|
+
/** The 3D office acted out a pretend duty with this agent's figure. */
|
|
12
|
+
acted(id: string, agentId: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Each action rejects with the server's message, which ActionButton shows under the button. */
|
|
16
|
+
export function useDutyActions(): DutyActions {
|
|
17
|
+
const save = useRpc(dutiesSaveRpc);
|
|
18
|
+
const update = useRpc(updateRpc);
|
|
19
|
+
const acted = useRpc(dutyActedRpc);
|
|
20
|
+
return useMemo(
|
|
21
|
+
(): DutyActions => ({
|
|
22
|
+
async save(duties) {
|
|
23
|
+
const result = await save({
|
|
24
|
+
duties: duties.map((duty) => ({ ...duty, days: [...duty.days] })),
|
|
25
|
+
});
|
|
26
|
+
if (!result.ok) throw new Error(result.error);
|
|
27
|
+
},
|
|
28
|
+
async markDone(id) {
|
|
29
|
+
const result = await update({ id, action: "done" });
|
|
30
|
+
if (!result.ok) throw new Error(result.error);
|
|
31
|
+
},
|
|
32
|
+
async reopen(id) {
|
|
33
|
+
const result = await update({ id, action: "reopen" });
|
|
34
|
+
if (!result.ok) throw new Error(result.error);
|
|
35
|
+
},
|
|
36
|
+
async acted(id, agentId) {
|
|
37
|
+
const result = await acted({ id, agentId });
|
|
38
|
+
if (!result.ok) throw new Error(result.error);
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
[save, update, acted],
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from "react";
|
|
2
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
3
|
+
import { chatRpc, GroupPhotoSchema } from "../shared/contracts.js";
|
|
4
|
+
|
|
5
|
+
export type GroupPhotoCapture = () => string | null | Promise<string | null>;
|
|
6
|
+
|
|
7
|
+
interface Shot {
|
|
8
|
+
requestId: string;
|
|
9
|
+
data: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** One in-flight action per office. Repeat an unacknowledged post with its original picture and ID. */
|
|
13
|
+
export function useGroupPhoto() {
|
|
14
|
+
const call = useRpc(chatRpc);
|
|
15
|
+
const [capture, setCapture] = useState<GroupPhotoCapture | null>(null);
|
|
16
|
+
const pending = useRef<Promise<void> | null>(null);
|
|
17
|
+
const shot = useRef<Shot | null>(null);
|
|
18
|
+
const onPhotoReady = useCallback((next: GroupPhotoCapture | null) => {
|
|
19
|
+
setCapture(() => next);
|
|
20
|
+
}, []);
|
|
21
|
+
const send = useCallback(() => {
|
|
22
|
+
if (pending.current) return pending.current;
|
|
23
|
+
const run = async () => {
|
|
24
|
+
if (!shot.current) {
|
|
25
|
+
const data = GroupPhotoSchema.safeParse(await capture?.());
|
|
26
|
+
if (!data.success)
|
|
27
|
+
throw new Error(
|
|
28
|
+
"The office could not take a photo. Try again when the 3D floor is ready.",
|
|
29
|
+
);
|
|
30
|
+
const requestId =
|
|
31
|
+
globalThis.crypto?.randomUUID?.() ??
|
|
32
|
+
`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
33
|
+
shot.current = { requestId, data: data.data };
|
|
34
|
+
}
|
|
35
|
+
const result = await call({ op: "photo", ...shot.current });
|
|
36
|
+
if (!result.ok) {
|
|
37
|
+
shot.current = null;
|
|
38
|
+
throw new Error(result.error);
|
|
39
|
+
}
|
|
40
|
+
shot.current = null;
|
|
41
|
+
};
|
|
42
|
+
pending.current = run().finally(() => {
|
|
43
|
+
pending.current = null;
|
|
44
|
+
});
|
|
45
|
+
return pending.current;
|
|
46
|
+
}, [call, capture]);
|
|
47
|
+
return { onPhotoReady, onGroupPhoto: capture ? send : undefined };
|
|
48
|
+
}
|
package/client/use-new-agent.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APPEARANCE_KEY, savedAppearance } from "../shared/appearance.js";
|
|
1
2
|
import { useCallback, useEffect, useState } from "react";
|
|
2
3
|
import { usePaseo, useSettings, type PluginPaseoApi } from "@getpaseo/plugin/client";
|
|
3
4
|
import { officeDeviceSettings } from "../shared/settings.js";
|
|
@@ -152,10 +153,13 @@ export function useNewAgent({ choice, change }: NewAgentInput): NewAgent {
|
|
|
152
153
|
if (problem !== null || workspace === undefined)
|
|
153
154
|
throw new Error(problem ?? "Choose a workspace.");
|
|
154
155
|
const { provider, model } = choice;
|
|
156
|
+
const profile = savedAppearance(choice.appearance);
|
|
155
157
|
// Through the workspace's handle: a create with only a folder makes a new workspace each time.
|
|
156
158
|
const handle = await paseo.workspaces.ref(workspace.id).agents.create({
|
|
157
159
|
config: { provider: `${provider}/${model}` },
|
|
158
160
|
prompt: choice.prompt.trim(),
|
|
161
|
+
...(profile?.name && { title: profile.name }),
|
|
162
|
+
...(profile && { metadata: { [APPEARANCE_KEY]: profile } }),
|
|
159
163
|
});
|
|
160
164
|
if (revision !== null && values !== null && provider !== null && model !== null) {
|
|
161
165
|
const lastAgent: LastAgent = { provider, model };
|
package/client/use-street.ts
CHANGED
|
@@ -11,3 +11,11 @@ export function streetDefault(layout: StreetLayout): boolean {
|
|
|
11
11
|
export function useStreetSwitch(layout: StreetLayout) {
|
|
12
12
|
return useDeviceSwitch("street", streetDefault(layout));
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
/** Earlier devices saved only whether the city street was visible. */
|
|
16
|
+
export function useOfficeScene(layout: StreetLayout) {
|
|
17
|
+
const legacy = useStreetSwitch(layout);
|
|
18
|
+
const scene = useDeviceSwitch("scene", legacy.on ? "city" : "plain");
|
|
19
|
+
const lighting = useDeviceSwitch("lighting", "auto");
|
|
20
|
+
return { scene, lighting, unsaved: scene.unsaved || lighting.unsaved };
|
|
21
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { ScrollView } from "@getpaseo/plugin/client/ui";
|
|
4
|
+
import type { OfficeRoom } from "../shared/model.js";
|
|
5
|
+
import { WorkspaceOverlay } from "./workspace-overlay.js";
|
|
6
|
+
import { SubagentRow } from "./session-panel-detail.js";
|
|
7
|
+
import type { SessionContext } from "./session-pane.js";
|
|
8
|
+
import { SessionPane, sessionChildren, sessionOf } from "./session-pane.js";
|
|
9
|
+
import type { OfficeSurfaceProps } from "./office-surface.js";
|
|
10
|
+
import type { OfficeStyles } from "./styles.js";
|
|
11
|
+
|
|
12
|
+
interface Options {
|
|
13
|
+
workspaceId: string | null;
|
|
14
|
+
agentId: string | null;
|
|
15
|
+
session: SessionContext;
|
|
16
|
+
onSelect(agentId: string): void;
|
|
17
|
+
onBoard(id: string): void;
|
|
18
|
+
onClose(): void;
|
|
19
|
+
styles: OfficeStyles;
|
|
20
|
+
layout: OfficeSurfaceProps["layout"];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Work on this session or its room's board on clients without an embeddable web workspace. */
|
|
24
|
+
function WorkspaceOfficeTools({
|
|
25
|
+
room,
|
|
26
|
+
agentId,
|
|
27
|
+
session,
|
|
28
|
+
styles,
|
|
29
|
+
layout,
|
|
30
|
+
onSelect,
|
|
31
|
+
onClose,
|
|
32
|
+
}: Omit<Options, "workspaceId" | "onBoard"> & { room: OfficeRoom | undefined }) {
|
|
33
|
+
const context = useMemo(
|
|
34
|
+
() => ({ actions: session.actions, closeSession: onClose }),
|
|
35
|
+
[session.actions, onClose],
|
|
36
|
+
);
|
|
37
|
+
const selected = agentId ? sessionOf(session.model, agentId) : null;
|
|
38
|
+
return (
|
|
39
|
+
<View style={styles.columnBody}>
|
|
40
|
+
{selected && agentId ? (
|
|
41
|
+
<SessionPane
|
|
42
|
+
hideClose
|
|
43
|
+
subagents={sessionChildren(session.model, agentId)}
|
|
44
|
+
onOpenSubagent={onSelect}
|
|
45
|
+
agentId={agentId}
|
|
46
|
+
agent={selected.agent}
|
|
47
|
+
room={selected.room}
|
|
48
|
+
reply={session.replies.texts.get(agentId) ?? ""}
|
|
49
|
+
setReply={session.replies.setText}
|
|
50
|
+
context={context}
|
|
51
|
+
styles={styles}
|
|
52
|
+
layout={layout}
|
|
53
|
+
/>
|
|
54
|
+
) : (
|
|
55
|
+
<ScrollView contentContainerStyle={styles.sessionList}>
|
|
56
|
+
{room?.rows.length ? (
|
|
57
|
+
room.rows.map(({ agent }) => (
|
|
58
|
+
<SubagentRow key={agent.id} agent={agent} onOpen={onSelect} styles={styles} />
|
|
59
|
+
))
|
|
60
|
+
) : (
|
|
61
|
+
<Text style={styles.muted}>No sessions in this workspace.</Text>
|
|
62
|
+
)}
|
|
63
|
+
</ScrollView>
|
|
64
|
+
)}
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
export type WorkspaceSelection = Pick<Options, "agentId" | "workspaceId">;
|
|
69
|
+
export function OfficeWorkspace({
|
|
70
|
+
selection,
|
|
71
|
+
hostId,
|
|
72
|
+
onBoard,
|
|
73
|
+
...tools
|
|
74
|
+
}: Omit<Options, keyof WorkspaceSelection> & {
|
|
75
|
+
selection: WorkspaceSelection | null;
|
|
76
|
+
hostId: string;
|
|
77
|
+
}) {
|
|
78
|
+
const room = tools.session.model.rooms.find((item) => item.id === selection?.workspaceId);
|
|
79
|
+
const boardId = room?.id;
|
|
80
|
+
const openBoard = useCallback(() => {
|
|
81
|
+
if (boardId) onBoard(boardId);
|
|
82
|
+
}, [onBoard, boardId]);
|
|
83
|
+
if (!selection) return null;
|
|
84
|
+
const title = room
|
|
85
|
+
? [...new Set([room.subtitle, room.name].filter(Boolean))].join(" · ")
|
|
86
|
+
: "Workspace";
|
|
87
|
+
return (
|
|
88
|
+
<WorkspaceOverlay
|
|
89
|
+
key={selection.workspaceId ?? hostId}
|
|
90
|
+
dockRequest={selection}
|
|
91
|
+
onBoard={room ? openBoard : undefined}
|
|
92
|
+
hostId={hostId}
|
|
93
|
+
{...selection}
|
|
94
|
+
title={title}
|
|
95
|
+
platform={tools.layout.platform}
|
|
96
|
+
styles={tools.styles}
|
|
97
|
+
onClose={tools.onClose}
|
|
98
|
+
>
|
|
99
|
+
<WorkspaceOfficeTools {...tools} room={room} agentId={selection.agentId} />
|
|
100
|
+
</WorkspaceOverlay>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Same spelling as Paseo's encodeWorkspaceIdForPathSegment, including legacy path-shaped IDs. */
|
|
2
|
+
function workspaceSegment(id: string): string {
|
|
3
|
+
if (/^[A-Za-z0-9._~-]+$/.test(id)) return id;
|
|
4
|
+
const bytes = new TextEncoder().encode(id);
|
|
5
|
+
const binary = Array.from(bytes, (byte) => String.fromCharCode(byte)).join("");
|
|
6
|
+
return "b64_" + btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** The stock app's workspace route. Connection addresses and pairing data stay with the host app. */
|
|
10
|
+
export function workspaceOverlayUrl(
|
|
11
|
+
page: URL,
|
|
12
|
+
hostId: string,
|
|
13
|
+
workspaceId: string | null,
|
|
14
|
+
agentId: string | null,
|
|
15
|
+
): string | null {
|
|
16
|
+
const web = page.protocol === "https:" || page.protocol === "http:";
|
|
17
|
+
const desktop = page.protocol === "paseo:" && page.host === "app";
|
|
18
|
+
if ((!web && !desktop) || page.username || page.password) return null;
|
|
19
|
+
const host = hostId.trim();
|
|
20
|
+
const workspace = workspaceId?.trim();
|
|
21
|
+
const agent = agentId?.trim();
|
|
22
|
+
if (!host || [host, workspace, agent].some((id) => id === "." || id === "..")) return null;
|
|
23
|
+
const root = "/h/" + encodeURIComponent(host);
|
|
24
|
+
let path: string;
|
|
25
|
+
let search = "";
|
|
26
|
+
if (workspace) {
|
|
27
|
+
path = root + "/workspace/" + workspaceSegment(workspace);
|
|
28
|
+
if (agent) search = "?open=" + encodeURIComponent("agent:" + agent);
|
|
29
|
+
} else if (agent) {
|
|
30
|
+
path = root + "/agent/" + encodeURIComponent(agent);
|
|
31
|
+
} else {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const url = new URL(page.href);
|
|
35
|
+
url.search = "";
|
|
36
|
+
if (page.hash.startsWith("#/h/")) {
|
|
37
|
+
url.hash = path + search;
|
|
38
|
+
} else {
|
|
39
|
+
// A reverse proxy may mount the app under a prefix before its /h/:server route.
|
|
40
|
+
const at = page.pathname.indexOf("/h/");
|
|
41
|
+
const base = at < 0 ? "" : page.pathname.slice(0, at);
|
|
42
|
+
url.hash = "";
|
|
43
|
+
url.pathname = base + path;
|
|
44
|
+
url.search = search;
|
|
45
|
+
}
|
|
46
|
+
return url.href;
|
|
47
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useMemo,
|
|
4
|
+
useState,
|
|
5
|
+
type CSSProperties,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
type SyntheticEvent,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { Pressable, StyleSheet, Text, View, type ViewStyle } from "react-native";
|
|
10
|
+
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
11
|
+
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
12
|
+
import { OfficeModal, useFullscreenDialog } from "./office-modal.js";
|
|
13
|
+
import type { OfficeStyles } from "./styles.js";
|
|
14
|
+
import { workspaceOverlayUrl } from "./workspace-overlay-route.web.js";
|
|
15
|
+
|
|
16
|
+
interface WorkspaceOverlayProps {
|
|
17
|
+
dockRequest: object;
|
|
18
|
+
hostId: string;
|
|
19
|
+
workspaceId: string | null;
|
|
20
|
+
agentId: string | null;
|
|
21
|
+
title: string;
|
|
22
|
+
platform: PluginSurfaceProps["layout"]["platform"];
|
|
23
|
+
styles: OfficeStyles;
|
|
24
|
+
onBoard?: () => void;
|
|
25
|
+
onClose(): void;
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const FRAME_NAME = "paseo-office-workspace";
|
|
30
|
+
const body: ViewStyle = { flex: 1, minHeight: 0, padding: 0, gap: 0 };
|
|
31
|
+
const tools: ViewStyle = { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 6 };
|
|
32
|
+
const toolbarSpacing: ViewStyle = { paddingHorizontal: 5, gap: 4 };
|
|
33
|
+
const inlineTools: ViewStyle = { paddingVertical: 6, paddingHorizontal: 12 };
|
|
34
|
+
const frameStyle: CSSProperties = { width: "100%", flex: 1, minHeight: 0, border: 0 };
|
|
35
|
+
const hiddenFrame: CSSProperties = { display: "none" };
|
|
36
|
+
|
|
37
|
+
function frameUrl({
|
|
38
|
+
platform,
|
|
39
|
+
hostId,
|
|
40
|
+
workspaceId,
|
|
41
|
+
agentId,
|
|
42
|
+
}: WorkspaceOverlayProps): string | null {
|
|
43
|
+
if (platform !== "web" || typeof window === "undefined" || window.name === FRAME_NAME)
|
|
44
|
+
return null;
|
|
45
|
+
return workspaceOverlayUrl(new URL(window.location.href), hostId, workspaceId, agentId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function ToolbarAction({
|
|
49
|
+
label,
|
|
50
|
+
caption,
|
|
51
|
+
icon,
|
|
52
|
+
selected,
|
|
53
|
+
onPress,
|
|
54
|
+
styles,
|
|
55
|
+
}: {
|
|
56
|
+
label: string;
|
|
57
|
+
caption: string;
|
|
58
|
+
icon: string;
|
|
59
|
+
selected?: boolean;
|
|
60
|
+
onPress(): void;
|
|
61
|
+
styles: OfficeStyles;
|
|
62
|
+
}) {
|
|
63
|
+
const [hovered, setHovered] = useState(false);
|
|
64
|
+
const enter = useCallback(() => setHovered(true), []);
|
|
65
|
+
const leave = useCallback(() => setHovered(false), []);
|
|
66
|
+
let surface = styles.workspaceAction;
|
|
67
|
+
if (selected) surface = styles.sidebarButtonActive;
|
|
68
|
+
else if (hovered) surface = styles.sidebarButtonHover;
|
|
69
|
+
return (
|
|
70
|
+
<Pressable
|
|
71
|
+
accessibilityRole="button"
|
|
72
|
+
accessibilityLabel={label}
|
|
73
|
+
aria-pressed={selected}
|
|
74
|
+
onHoverIn={enter}
|
|
75
|
+
onHoverOut={leave}
|
|
76
|
+
onPress={onPress}
|
|
77
|
+
style={StyleSheet.compose(surface, toolbarSpacing)}
|
|
78
|
+
>
|
|
79
|
+
<Icon name={icon} size={15} color={selected ? styles.workspaceAccent : styles.iconColor} />
|
|
80
|
+
<Text style={styles.sidebarButtonText}>{caption}</Text>
|
|
81
|
+
</Pressable>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The embedded workbench and the Office conversation keep their state while a person switches views. */
|
|
86
|
+
export function WorkspaceOverlay(props: WorkspaceOverlayProps) {
|
|
87
|
+
const { title, onClose, onBoard, styles, children } = props;
|
|
88
|
+
const url = frameUrl(props);
|
|
89
|
+
const inHeader = useFullscreenDialog();
|
|
90
|
+
// A new request from Sessions should show the requested workbench, even in the same room.
|
|
91
|
+
const [officeRequest, setOfficeRequest] = useState<object | null>(null);
|
|
92
|
+
const [visited, setVisited] = useState(false);
|
|
93
|
+
const [failedRequest, setFailedRequest] = useState<object | null>(null);
|
|
94
|
+
const blocked = failedRequest === props.dockRequest;
|
|
95
|
+
const showOffice = !url || officeRequest === props.dockRequest || blocked;
|
|
96
|
+
const change = useCallback(
|
|
97
|
+
(next: boolean) => {
|
|
98
|
+
if (!next) onClose();
|
|
99
|
+
},
|
|
100
|
+
[onClose],
|
|
101
|
+
);
|
|
102
|
+
const openOffice = useCallback(() => {
|
|
103
|
+
setVisited(true);
|
|
104
|
+
setOfficeRequest(props.dockRequest);
|
|
105
|
+
}, [props.dockRequest]);
|
|
106
|
+
const openWorkbench = useCallback(() => {
|
|
107
|
+
setOfficeRequest(null);
|
|
108
|
+
setFailedRequest(null);
|
|
109
|
+
}, []);
|
|
110
|
+
const failed = useCallback(() => {
|
|
111
|
+
setFailedRequest(props.dockRequest);
|
|
112
|
+
setVisited(true);
|
|
113
|
+
}, [props.dockRequest]);
|
|
114
|
+
const loaded = useCallback(
|
|
115
|
+
(event: SyntheticEvent<HTMLIFrameElement>) => {
|
|
116
|
+
const doc = event.currentTarget.contentDocument;
|
|
117
|
+
if (!doc || doc.URL === "about:blank") failed();
|
|
118
|
+
},
|
|
119
|
+
[failed],
|
|
120
|
+
);
|
|
121
|
+
const headerIcon = useMemo(
|
|
122
|
+
() => <Icon name="FolderOpen" size={18} color={styles.workspaceAccent} />,
|
|
123
|
+
[styles.workspaceAccent],
|
|
124
|
+
);
|
|
125
|
+
const toolbar = (url || onBoard) && (
|
|
126
|
+
<View role="group" aria-label="Workspace controls" style={tools}>
|
|
127
|
+
{url && (
|
|
128
|
+
<>
|
|
129
|
+
<ToolbarAction
|
|
130
|
+
label="Paseo workspace"
|
|
131
|
+
caption="Workspace"
|
|
132
|
+
icon="PanelsTopLeft"
|
|
133
|
+
selected={!showOffice}
|
|
134
|
+
onPress={openWorkbench}
|
|
135
|
+
styles={styles}
|
|
136
|
+
/>
|
|
137
|
+
<ToolbarAction
|
|
138
|
+
label="Office controls"
|
|
139
|
+
caption="Office controls"
|
|
140
|
+
icon="SlidersHorizontal"
|
|
141
|
+
selected={showOffice}
|
|
142
|
+
onPress={openOffice}
|
|
143
|
+
styles={styles}
|
|
144
|
+
/>
|
|
145
|
+
</>
|
|
146
|
+
)}
|
|
147
|
+
{onBoard && showOffice && (
|
|
148
|
+
<ToolbarAction
|
|
149
|
+
label="Workspace board"
|
|
150
|
+
caption="Board"
|
|
151
|
+
icon="Columns3"
|
|
152
|
+
onPress={onBoard}
|
|
153
|
+
styles={styles}
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
</View>
|
|
157
|
+
);
|
|
158
|
+
return (
|
|
159
|
+
<OfficeModal
|
|
160
|
+
title={title}
|
|
161
|
+
icon={headerIcon}
|
|
162
|
+
open
|
|
163
|
+
size="wide"
|
|
164
|
+
dockRequest={props.dockRequest}
|
|
165
|
+
onOpenChange={change}
|
|
166
|
+
headerActions={inHeader ? toolbar : undefined}
|
|
167
|
+
>
|
|
168
|
+
<OfficeModal.Content scrollable={false} contentContainerStyle={body}>
|
|
169
|
+
{!inHeader && toolbar && <View style={inlineTools}>{toolbar}</View>}
|
|
170
|
+
{blocked && (
|
|
171
|
+
<Text accessibilityRole="alert" style={styles.fieldHint}>
|
|
172
|
+
This browser couldn’t display the workspace.
|
|
173
|
+
</Text>
|
|
174
|
+
)}
|
|
175
|
+
{url && !blocked && (
|
|
176
|
+
<iframe
|
|
177
|
+
key={url}
|
|
178
|
+
name={FRAME_NAME}
|
|
179
|
+
// oxlint-disable-next-line react/iframe-missing-sandbox -- This frame runs the same trusted Paseo app and needs its paired-host storage.
|
|
180
|
+
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads allow-modals"
|
|
181
|
+
title="Paseo workspace"
|
|
182
|
+
src={url}
|
|
183
|
+
style={showOffice ? hiddenFrame : frameStyle}
|
|
184
|
+
allow="clipboard-read 'self'; clipboard-write 'self'"
|
|
185
|
+
onLoad={loaded}
|
|
186
|
+
onError={failed}
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
{(showOffice || visited) && (
|
|
190
|
+
<View style={showOffice ? body : styles.hidden}>{children}</View>
|
|
191
|
+
)}
|
|
192
|
+
</OfficeModal.Content>
|
|
193
|
+
</OfficeModal>
|
|
194
|
+
);
|
|
195
|
+
}
|
package/client/world/adapter.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { shirtColor } from "../../shared/appearance.js";
|
|
1
2
|
import type { OfficeBrand } from "../brand.js";
|
|
2
3
|
import {
|
|
3
4
|
agentTitle,
|
|
@@ -16,12 +17,16 @@ import type {
|
|
|
16
17
|
TestResult,
|
|
17
18
|
} from "../../shared/contracts.js";
|
|
18
19
|
import { machineTitle, memoryPercent, memoryTone } from "../../shared/machine-text.js";
|
|
20
|
+
import { shortHolder } from "../../shared/duties.js";
|
|
21
|
+
import { USER_AUTHOR } from "../../shared/names.js";
|
|
22
|
+
import { dutyRowTitle } from "../duty-text.js";
|
|
19
23
|
import { relativeLuminance } from "../luminance.js";
|
|
20
24
|
import type {
|
|
21
25
|
WorldWeather,
|
|
22
26
|
WorldBoardRow,
|
|
23
27
|
WorldBrand,
|
|
24
28
|
WorldColors,
|
|
29
|
+
WorldDuty,
|
|
25
30
|
WorldEvent,
|
|
26
31
|
WorldEventType,
|
|
27
32
|
WorldMachine,
|
|
@@ -74,6 +79,9 @@ function toSession(
|
|
|
74
79
|
return {
|
|
75
80
|
id: agent.id,
|
|
76
81
|
name: title,
|
|
82
|
+
...(agent.appearance
|
|
83
|
+
? { appearance: agent.appearance, shirt: shirtColor(agent.appearance) }
|
|
84
|
+
: {}),
|
|
77
85
|
title,
|
|
78
86
|
dir: team,
|
|
79
87
|
git: {
|
|
@@ -85,7 +93,9 @@ function toSession(
|
|
|
85
93
|
status,
|
|
86
94
|
agent: markOf(agent.provider),
|
|
87
95
|
lastPrompt: "",
|
|
88
|
-
...(status === "rest" && !stuck && Number.isFinite(idle)
|
|
96
|
+
...(status === "rest" && !stuck && Number.isFinite(idle)
|
|
97
|
+
? { doneAt: idle, idleSince: agent.idleSince }
|
|
98
|
+
: {}),
|
|
89
99
|
stuck,
|
|
90
100
|
...(row.waitingOn > 0 ? { waitingOn: row.waitingOn } : {}),
|
|
91
101
|
subs: [],
|
|
@@ -410,7 +420,11 @@ const PRODUCT_NAME = "Paseo";
|
|
|
410
420
|
|
|
411
421
|
/** What the lobby's sign shows: the host's brand, or the product's name over the scene's mark. */
|
|
412
422
|
export function worldBrand(brand: OfficeBrand | null): WorldBrand {
|
|
413
|
-
return {
|
|
423
|
+
return {
|
|
424
|
+
name: brand?.name ?? PRODUCT_NAME,
|
|
425
|
+
logoUrl: brand?.logoUrl ?? null,
|
|
426
|
+
...(brand?.color ? { color: brand.color } : {}),
|
|
427
|
+
};
|
|
414
428
|
}
|
|
415
429
|
|
|
416
430
|
/** What the scene is told of the weather: the host's scene, or none while the host has not said. */
|
|
@@ -419,3 +433,24 @@ export function worldWeather(scene: WeatherScene | undefined): WorldWeather {
|
|
|
419
433
|
if (scene.kind === "season") return { kind: "season" };
|
|
420
434
|
return { kind: "reading", code: scene.code, temp: scene.temp, cloud: scene.cloud };
|
|
421
435
|
}
|
|
436
|
+
|
|
437
|
+
/** Who has a duty, as the pantry's board names them: the agent's title cut short. */
|
|
438
|
+
function dutyHolder(model: OfficeModel, claimedBy: string | undefined): WorldDuty["holder"] {
|
|
439
|
+
if (claimedBy === undefined || claimedBy === USER_AUTHOR) return null;
|
|
440
|
+
const agent = model.agents.get(claimedBy);
|
|
441
|
+
const title = agent ? agentTitle(agent) : `Agent ${claimedBy.slice(0, 8)}`;
|
|
442
|
+
return { id: claimedBy, name: shortHolder(title) };
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** The day's duties for the pantry's board: names, holders and states, never instructions. */
|
|
446
|
+
export function worldDuties(model: OfficeModel): WorldDuty[] {
|
|
447
|
+
return model.duties.map((row) => ({
|
|
448
|
+
id: row.post.id,
|
|
449
|
+
name: dutyRowTitle(row),
|
|
450
|
+
chore: row.duty?.chore ?? null,
|
|
451
|
+
pretend: (row.duty?.instructions.trim() ?? "") === "",
|
|
452
|
+
holder: dutyHolder(model, row.post.claimedBy),
|
|
453
|
+
state: row.post.state ?? "open",
|
|
454
|
+
owed: row.owed,
|
|
455
|
+
}));
|
|
456
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Escape in the fullscreen office. A browser gives Escape to fullscreen itself, so the scene's own
|
|
2
|
+
// uses of the key (getting up from the karaoke, the pool table or the game sofa, leaving walk-in
|
|
3
|
+
// or photo mode, closing a card) never hear it. Where the browser can lock the key to the page
|
|
4
|
+
// (Chromium, and so the desktop app), the office holds it while fullscreen and leaves fullscreen
|
|
5
|
+
// itself when a press had nothing else to end. Where it cannot, nothing changes.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What the scene marks while Escape has something to end there: seated at an activity
|
|
9
|
+
* (`is-gaming`), walking (`is-fp`), photo mode (`is-photo`), the place card, the tour's card.
|
|
10
|
+
*/
|
|
11
|
+
const SCENE_BODY_MARKS = ["is-gaming", "is-fp", "is-photo"];
|
|
12
|
+
const SCENE_OPEN_CARDS = "#plc:not([hidden]), .tour";
|
|
13
|
+
|
|
14
|
+
/** Whether an Escape pressed in the scene's page now would be used by the scene. */
|
|
15
|
+
export function sceneUsesEscape(doc: Document): boolean {
|
|
16
|
+
const marks = doc.body.classList;
|
|
17
|
+
if (SCENE_BODY_MARKS.some((mark) => marks.contains(mark))) return true;
|
|
18
|
+
return doc.querySelector(SCENE_OPEN_CARDS) !== null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Whether an Escape pressed in Paseo's page now belongs to an open dialog of it. */
|
|
22
|
+
export function pageUsesEscape(doc: Document): boolean {
|
|
23
|
+
return doc.querySelector("dialog[open], [aria-modal='true']") !== null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface KeyboardLock {
|
|
27
|
+
lock?(keys: string[]): Promise<void>;
|
|
28
|
+
unlock?(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function keyboardOf(nav: Navigator): KeyboardLock | undefined {
|
|
32
|
+
return (nav as Navigator & { keyboard?: KeyboardLock }).keyboard;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Holds Escape for the page while fullscreen; a browser without the lock keeps its own Escape. */
|
|
36
|
+
export function lockEscape(nav: Navigator): void {
|
|
37
|
+
// A refusal (not fullscreen any more, no permission) leaves the browser's own Escape.
|
|
38
|
+
void keyboardOf(nav)
|
|
39
|
+
?.lock?.(["Escape"])
|
|
40
|
+
.catch(() => {});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function unlockEscape(nav: Navigator): void {
|
|
44
|
+
keyboardOf(nav)?.unlock?.();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Leaves fullscreen after an Escape nothing used. Asked once the press has been handled, so a
|
|
49
|
+
* handler that took it (`preventDefault`) is seen. `used` is read at the press, before any
|
|
50
|
+
* handler ends what it was for.
|
|
51
|
+
*/
|
|
52
|
+
export function leaveFullscreenAfter(event: KeyboardEvent, used: boolean, page: Document): void {
|
|
53
|
+
if (event.key !== "Escape" || used) return;
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
if (event.defaultPrevented || page.fullscreenElement === null) return;
|
|
56
|
+
void page.exitFullscreen().catch(() => {});
|
|
57
|
+
}, 0);
|
|
58
|
+
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
teamOfRoom,
|
|
13
13
|
worldBoardRows,
|
|
14
14
|
worldChanges,
|
|
15
|
+
worldDuties,
|
|
15
16
|
worldWeather,
|
|
16
17
|
worldMachine,
|
|
17
18
|
worldPeople,
|
|
@@ -39,6 +40,7 @@ export interface WorldFeedInput {
|
|
|
39
40
|
incidents: IncidentsState | undefined;
|
|
40
41
|
/** The device's Sound switch; null while it is read: nothing is sent then. */
|
|
41
42
|
streetNote?: boolean;
|
|
43
|
+
night?: boolean | undefined;
|
|
42
44
|
sound: boolean | null;
|
|
43
45
|
/** The floor plan the scene was started on: its desks seat the people. */
|
|
44
46
|
plan: WorldPlan;
|
|
@@ -65,6 +67,7 @@ export function useWorldFeed(
|
|
|
65
67
|
weather,
|
|
66
68
|
incidents,
|
|
67
69
|
streetNote,
|
|
70
|
+
night,
|
|
68
71
|
sound,
|
|
69
72
|
plan,
|
|
70
73
|
}: WorldFeedInput,
|
|
@@ -84,8 +87,8 @@ export function useWorldFeed(
|
|
|
84
87
|
|
|
85
88
|
useEffect(() => {
|
|
86
89
|
if (api === null) return;
|
|
87
|
-
world.current?.setTheme({ dark: isDarkTheme(theme.colors), colors: theme.colors });
|
|
88
|
-
}, [theme, api]);
|
|
90
|
+
world.current?.setTheme({ dark: night ?? isDarkTheme(theme.colors), colors: theme.colors });
|
|
91
|
+
}, [theme, night, api]);
|
|
89
92
|
|
|
90
93
|
useEffect(() => {
|
|
91
94
|
if (sound !== null) world.current?.setSound?.(sound);
|
|
@@ -101,6 +104,7 @@ export function useWorldFeed(
|
|
|
101
104
|
rests.current = restsAfter(rests.current, people.sessions, Date.now());
|
|
102
105
|
scene.setSessions(withRestTimes(people.sessions, rests.current));
|
|
103
106
|
scene.setBoardRows(worldBoardRows(model, people.sessions));
|
|
107
|
+
scene.setDuties?.(model.dutyList === null ? null : worldDuties(model));
|
|
104
108
|
const changes = worldChanges(memory.current, people);
|
|
105
109
|
for (const event of changes.events) scene.event(event);
|
|
106
110
|
memory.current = changes.memory;
|