paseo-office 0.2.0 → 0.2.2

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.
Files changed (143) hide show
  1. package/OVERVIEW.md +27 -0
  2. package/README.md +65 -134
  3. package/client/action-button.tsx +4 -1
  4. package/client/activity-panel.tsx +6 -4
  5. package/client/agent-appearance.tsx +257 -0
  6. package/client/agent-card.tsx +2 -1
  7. package/client/agent-picker-text.ts +23 -4
  8. package/client/agent-picker.tsx +5 -8
  9. package/client/board-sheet.tsx +48 -16
  10. package/client/board-text.ts +12 -2
  11. package/client/brand.ts +1 -0
  12. package/client/chat-chrome.tsx +318 -0
  13. package/client/chat-compose-tools.tsx +314 -0
  14. package/client/chat-dictation.tsx +133 -0
  15. package/client/chat-more.tsx +119 -0
  16. package/client/chat-panel.tsx +401 -146
  17. package/client/chat-quick.tsx +198 -0
  18. package/client/chat-text.ts +25 -6
  19. package/client/column-sheet.tsx +93 -23
  20. package/client/conversation-model.ts +19 -5
  21. package/client/duty-sheet.tsx +321 -0
  22. package/client/duty-text.ts +20 -0
  23. package/client/fullscreen-header.tsx +28 -13
  24. package/client/fullscreen-theme.ts +38 -0
  25. package/client/host-details.tsx +269 -0
  26. package/client/host-styles.ts +129 -0
  27. package/client/host-switches.tsx +212 -83
  28. package/client/incidents-card.tsx +2 -1
  29. package/client/janitor-card.tsx +1 -1
  30. package/client/library-card.tsx +2 -1
  31. package/client/list-text.ts +8 -6
  32. package/client/lobby-board.tsx +73 -53
  33. package/client/machine-card.tsx +225 -85
  34. package/client/messenger-styles.ts +216 -0
  35. package/client/new-agent-form.tsx +153 -61
  36. package/client/new-agent-model.ts +2 -0
  37. package/client/notes-card.tsx +111 -83
  38. package/client/notes-days.tsx +1 -1
  39. package/client/office-brand-context.ts +44 -0
  40. package/client/office-column.tsx +2 -1
  41. package/client/office-keyboard.ts +79 -0
  42. package/client/office-link.ts +7 -1
  43. package/client/office-mark.tsx +29 -0
  44. package/client/office-modal.tsx +440 -0
  45. package/client/office-settings.tsx +75 -30
  46. package/client/office-state.ts +12 -2
  47. package/client/office-surface.tsx +591 -81
  48. package/client/pixel/actors.ts +2 -1
  49. package/client/pixel/art.ts +33 -19
  50. package/client/pixel/pixel-office.tsx +2 -2
  51. package/client/prompt-coach.tsx +152 -0
  52. package/client/qa-card.tsx +2 -1
  53. package/client/review-card.tsx +2 -1
  54. package/client/room-board.tsx +26 -2
  55. package/client/scene-picker.tsx +158 -0
  56. package/client/scene-previews.ts +10 -0
  57. package/client/session-pane.tsx +25 -5
  58. package/client/session-panel-detail.tsx +238 -0
  59. package/client/session-panel.tsx +222 -137
  60. package/client/session-styles.ts +224 -1
  61. package/client/session-transcript.tsx +243 -0
  62. package/client/sessions-panel.tsx +181 -22
  63. package/client/sessions-text.ts +18 -0
  64. package/client/settings-sections.tsx +126 -0
  65. package/client/sidebar-launcher.ts +29 -0
  66. package/client/ssh-hosts.tsx +331 -0
  67. package/client/ssh-metrics.ts +76 -0
  68. package/client/standup-card.tsx +2 -1
  69. package/client/structure-view.tsx +20 -3
  70. package/client/styles.ts +170 -62
  71. package/client/team-chat-preview.tsx +96 -0
  72. package/client/tracker-connections.tsx +252 -0
  73. package/client/transcript-styles.ts +90 -0
  74. package/client/use-device-switch.ts +21 -12
  75. package/client/use-duty-actions.ts +43 -0
  76. package/client/use-group-photo.ts +48 -0
  77. package/client/use-new-agent.ts +4 -0
  78. package/client/use-street.ts +8 -0
  79. package/client/workspace-office-tools.tsx +102 -0
  80. package/client/workspace-overlay-route.web.ts +47 -0
  81. package/client/workspace-overlay.tsx +195 -0
  82. package/client/world/adapter.ts +37 -2
  83. package/client/world/escape.ts +58 -0
  84. package/client/world/use-world-feed.ts +6 -2
  85. package/client/world/workspace-dock.ts +6 -0
  86. package/client/world/world-api.ts +45 -4
  87. package/client/world/world-bridge-page.ts +14 -3
  88. package/client/world/world-bridge.ts +50 -5
  89. package/client/world/world-frame.web.ts +8 -0
  90. package/client/world/world-view-native.tsx +31 -10
  91. package/client/world/world-view-shared.ts +36 -7
  92. package/client/world/world-view.tsx +93 -21
  93. package/docs/office.md +165 -64
  94. package/index.client.tsx +13 -6
  95. package/index.server.ts +232 -16
  96. package/package.json +2 -1
  97. package/server/activity.ts +42 -19
  98. package/server/agent-tools.ts +11 -5
  99. package/server/board-service.ts +381 -10
  100. package/server/brand-logo.ts +34 -0
  101. package/server/chat-group.ts +83 -0
  102. package/server/chat-service.ts +406 -62
  103. package/server/chat-store.ts +1 -4
  104. package/server/directory.ts +22 -7
  105. package/server/duty-service.ts +230 -0
  106. package/server/group-photo.ts +39 -0
  107. package/server/home-departure.ts +47 -0
  108. package/server/hub.ts +43 -1
  109. package/server/incidents-jira.ts +19 -7
  110. package/server/incidents-schedule.ts +10 -10
  111. package/server/incidents-sentry.ts +34 -8
  112. package/server/live-ports.ts +114 -18
  113. package/server/lobby-pickup.ts +170 -0
  114. package/server/machine/details.ts +91 -0
  115. package/server/mention-queue.ts +14 -0
  116. package/server/office.ts +110 -6
  117. package/server/paths.ts +14 -0
  118. package/server/ssh/LICENSE.paseo +211 -0
  119. package/server/ssh/client.ts +401 -0
  120. package/server/ssh/discovery.ts +230 -0
  121. package/server/ssh/installed.ts +104 -0
  122. package/server/ssh/monitor.ts +104 -0
  123. package/server/ssh/pid-files.ts +194 -0
  124. package/server/ssh/read.ts +136 -0
  125. package/server/subagent-names.ts +4 -0
  126. package/server/tracker-credentials.ts +141 -0
  127. package/server/words.generated.ts +1 -1
  128. package/server/world.generated.ts +1 -1
  129. package/shared/appearance.ts +43 -0
  130. package/shared/branding.ts +53 -0
  131. package/shared/chat-words.ts +2 -2
  132. package/shared/contracts.ts +199 -5
  133. package/shared/duties.ts +100 -0
  134. package/shared/host-details.ts +25 -0
  135. package/shared/lobby-assignment.ts +34 -0
  136. package/shared/model.ts +9 -1
  137. package/shared/names.ts +2 -0
  138. package/shared/settings.ts +14 -3
  139. package/shared/ssh.ts +34 -0
  140. package/shared/upstream/README.md +1 -3
  141. package/shared/upstream/chat-engine.d.ts +4 -0
  142. package/shared/upstream/prompt-coach.d.ts +6 -0
  143. package/shared/upstream/prompt-coach.js +178 -0
@@ -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
+ }
@@ -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) ? { doneAt: 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 { name: brand?.name ?? PRODUCT_NAME, logoUrl: brand?.logoUrl ?? null };
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;
@@ -0,0 +1,6 @@
1
+ import { createContext } from "react";
2
+
3
+ // The fullscreen surface owns the window; the camera toolbar lives in its scene iframe.
4
+ export const RegisterWorkspaceDock = createContext<
5
+ ((button: HTMLButtonElement | null) => void) | null
6
+ >(null);
@@ -1,5 +1,7 @@
1
+ import type { Appearance } from "../../shared/appearance.js";
2
+ import type { OfficeScene } from "../../shared/settings.js";
1
3
  import type { WordsLanguage } from "../../shared/scene-language.js";
2
- import type { LifeEvent } from "../../shared/contracts.js";
4
+ import type { DutyChore, LifeEvent } from "../../shared/contracts.js";
3
5
  import type { PluginTheme } from "@getpaseo/plugin";
4
6
 
5
7
  /**
@@ -12,6 +14,8 @@ export type WorldWeather = import("../../shared/contracts.js").WeatherScene;
12
14
 
13
15
  /** A person in the office, in the shape the vendored scene reads. */
14
16
  export interface WorldSession {
17
+ appearance?: Appearance;
18
+ shirt?: string;
15
19
  id: string;
16
20
  name: string;
17
21
  title: string;
@@ -30,6 +34,8 @@ export interface WorldSession {
30
34
  * it works, waits or is stopped on an error.
31
35
  */
32
36
  doneAt?: number;
37
+ /** Host revision for an idle session eligible for archive when its worker gets home. */
38
+ idleSince?: string;
33
39
  /** A red name tag: the agent ended in an error. */
34
40
  stuck: boolean;
35
41
  /**
@@ -91,6 +97,25 @@ export interface WorldBoardRow {
91
97
  state: "doing" | "wait" | "done";
92
98
  }
93
99
 
100
+ /**
101
+ * A duty of the day's duty board, as the pantry's board shows it. Never its instructions: only
102
+ * its name, who has it and its state.
103
+ */
104
+ export interface WorldDuty {
105
+ /** The duty's post: a pretend duty acted out is reported by it (`onDutyDone`). */
106
+ id: string;
107
+ name: string;
108
+ /** The chore it is acted out as; null: its figure walks to the board and back. */
109
+ chore: DutyChore | null;
110
+ /** No agent is asked: the scene picks a free figure to act it out, and reports it done. */
111
+ pretend: boolean;
112
+ /** Who has it: the agent and its name cut short; null while open, or when ticked by hand. */
113
+ holder: { id: string; name: string } | null;
114
+ state: "open" | "claimed" | "done";
115
+ /** Not done on its day: still on the board. */
116
+ owed: boolean;
117
+ }
118
+
94
119
  /** Something an agent left listening, as the scene draws it: a small server box. */
95
120
  export interface WorldDevServer {
96
121
  /** Whose it is. Not alive: forgotten, so the box stands in the server room with a red light. */
@@ -121,6 +146,7 @@ export type WorldColors = PluginTheme["colors"];
121
146
 
122
147
  /** What the lobby's sign and the reception's plaque show. */
123
148
  export interface WorldBrand {
149
+ color?: string;
124
150
  name: string;
125
151
  /** The logo's address in full; null draws the scene's own mark. */
126
152
  logoUrl: string | null;
@@ -131,11 +157,13 @@ export type WorldTenureProject = WorldTenure["projects"][number];
131
157
  export type WorldLiftService = LifeEvent["lift"];
132
158
 
133
159
  export interface WorldStartOptions {
160
+ onWentHome?(agentId: string, idleSince: string): void;
134
161
  /** Something the office's people would say in the team chat: a kind of moment and a few words. */
135
162
  onLife?(kind: string, vars: Record<string, string>): void;
136
163
  /** The tenure list's two writes: a farewell was held, an intern was made permanent. */
137
164
  onTenure?(op: { op: "farewell" | "official"; name: string }): void;
138
165
 
166
+ scene?: OfficeScene;
139
167
  street?: { kit: string | null };
140
168
  language?: WordsLanguage;
141
169
  words?: string;
@@ -169,13 +197,15 @@ export interface WorldStartOptions {
169
197
  /** The label over the meeting room's screen was chosen. Absent: the scene shows no label. */
170
198
  onNotes?(): void;
171
199
  /**
172
- * A person's session was asked for: E by them while walking in. The surface always supplies it
173
- * and it opens the session in the office's column, as the card's "Open session" does. Absent
174
- * only in a caller with no session to open; the scene then chooses the person, as a click does.
200
+ * Walk-in requests the person's workspace. Without a workspace handler the scene selects the person.
175
201
  */
176
202
  onOpen?(agentId: string): void;
177
203
  /** The incidents' banner was chosen. */
178
204
  onIncidents?(): void;
205
+ /** The pantry's duty board was chosen. Absent: a click says the day's duties in a note. */
206
+ onDuties?(): void;
207
+ /** A figure acted out a pretend duty (`WorldDuty.id`): the host records it done by that agent. */
208
+ onDutyDone?(id: string, agentId: string): void;
179
209
  /** A short line the office says once. */
180
210
  onToast?(text: string): void;
181
211
  /**
@@ -183,11 +213,15 @@ export interface WorldStartOptions {
183
213
  * answers with `setSound`; the scene has already applied it, since audio starts only inside a press.
184
214
  */
185
215
  onSound?(on: boolean): void;
216
+ /** Fullscreen belongs to the surface containing the floor and both sidebars. */
217
+ onToggleFullscreen?(): void;
186
218
  /** False hides Photo mode: a WebView cannot keep a download. Absent: Photo mode is offered. */
187
219
  photo?: boolean;
188
220
  }
189
221
 
190
222
  export interface WorldApi {
223
+ /** A small JPEG of the current floor, where this renderer supports capture. */
224
+ captureGroupPhoto?(): string | null;
191
225
  version: number;
192
226
  start(options: WorldStartOptions): void;
193
227
  /** Gives the graphics context back; the page is thrown away after it. */
@@ -198,6 +232,12 @@ export interface WorldApi {
198
232
  select(agentId: string | null): void;
199
233
  focusProject(project: string): void;
200
234
  setBoardRows(rows: readonly WorldBoardRow[]): void;
235
+ /**
236
+ * The day's duties for the pantry's board. Once given, the scene no longer keeps a rota of its
237
+ * own. Null while the host has sent no duty list (an older host, or before it is read): the
238
+ * scene keeps upstream's rota. Absent on a page built from before the duty board.
239
+ */
240
+ setDuties?(duties: readonly WorldDuty[] | null): void;
201
241
  /**
202
242
  * The host's readings. With null the server room is furniture: no chip, no hand, no tap, and
203
243
  * the wall screen shows no memory.
@@ -232,6 +272,7 @@ export interface WorldApi {
232
272
  * from before sounds.
233
273
  */
234
274
  setSound?(on: boolean): void;
275
+ setFullscreen?(active: boolean): void;
235
276
  }
236
277
 
237
278
  /** The version of the contract above; the page says which it speaks. */
@@ -7,8 +7,8 @@ import { WORLD_API_VERSION } from "./world-api.js";
7
7
  * `start` become stand-ins that post `{ callback, args }`. A scene that throws, or one that is not
8
8
  * the contract's version, posts `{ problem }`, which the office shows as any other failure.
9
9
  *
10
- * It also turns Full screen off: whether a WebView reports `fullscreenEnabled` is the WebView's
11
- * business, and the bar's button reads it at `start`.
10
+ * Older scene bundles decide whether to show Full screen from the WebView document.
11
+ * Keep it off there as well as omitting the web surface's fullscreen callback.
12
12
  */
13
13
  export function bridgePageScript(scene: string): string {
14
14
  return `(function () {
@@ -28,6 +28,7 @@ export function bridgePageScript(scene: string): string {
28
28
  });
29
29
  return options;
30
30
  }
31
+ var reportPhoto;
31
32
  frame.onMessage = function (text) {
32
33
  var message;
33
34
  try { message = JSON.parse(text); } catch (e) { return; }
@@ -35,7 +36,17 @@ export function bridgePageScript(scene: string): string {
35
36
  if (!message || !world || typeof world[message.call] !== "function") return;
36
37
  var args = message.args || [];
37
38
  if (message.call === "start" && args[0]) args[0] = standIns(args[0]);
38
- try { world[message.call].apply(world, args); } catch (error) { problem(error); }
39
+ if (message.call === "captureGroupPhoto" && reportPhoto) {
40
+ try { reportPhoto(args[0], world.captureGroupPhoto()); } catch (error) { reportPhoto(args[0], null); }
41
+ return;
42
+ }
43
+ try {
44
+ world[message.call].apply(world, args);
45
+ if (message.call === "start" && args[0].onCaptureReady && typeof world.captureGroupPhoto === "function") {
46
+ reportPhoto = args[0].onCaptured;
47
+ args[0].onCaptureReady();
48
+ }
49
+ } catch (error) { problem(error); }
39
50
  };
40
51
  try {
41
52
  ${scene}
@@ -1,3 +1,4 @@
1
+ import type { GroupPhotoCapture } from "../use-group-photo.js";
1
2
  import { WORLD_API_VERSION, type WorldApi, type WorldStartOptions } from "./world-api.js";
2
3
 
3
4
  /** From the plugin to the page: a call of `PaseoOfficeWorld`. */
@@ -35,17 +36,20 @@ function parseReply(text: string): BridgeReply | null {
35
36
  function brandForPage(brand: WorldStartOptions["brand"]): WorldStartOptions["brand"] {
36
37
  if (brand === undefined) return undefined;
37
38
  return {
38
- name: brand.name,
39
+ ...brand,
39
40
  logoUrl: brand.logoUrl?.startsWith("data:") ? brand.logoUrl : null,
40
41
  };
41
42
  }
42
43
 
43
44
  /**
44
45
  * The scene's API over messages. Each call becomes `{ call, args }` for `post`; the page answers
45
- * with `{ callback, args }` for a callback `start` was given, or `{ problem }`. Nothing waits here:
46
- * `post` is a ScriptFrame handle's, which holds posts until the page is ready.
46
+ * with `{ callback, args }` for a callback `start` was given, or `{ problem }`. A photo request waits
47
+ * for its matching JPEG or the capture timeout.
47
48
  */
48
- export function createWorldBridge(post: (text: string) => void): WorldBridge {
49
+ export function createWorldBridge(
50
+ post: (text: string) => void,
51
+ onPhotoReady?: (capture: GroupPhotoCapture | null) => void,
52
+ ): WorldBridge {
49
53
  const handlers = new Map<string, Handler>();
50
54
  const send = (message: BridgeCall) => post(JSON.stringify(message));
51
55
  const sender =
@@ -53,6 +57,33 @@ export function createWorldBridge(post: (text: string) => void): WorldBridge {
53
57
  (...args: unknown[]) =>
54
58
  send({ call, args });
55
59
 
60
+ let pendingPhoto: {
61
+ id: number;
62
+ timer: ReturnType<typeof setTimeout>;
63
+ resolve(data: string | null): void;
64
+ } | null = null;
65
+ let photoId = 0;
66
+ const finishPhoto = (data: string | null) => {
67
+ if (!pendingPhoto) return;
68
+ clearTimeout(pendingPhoto.timer);
69
+ const { resolve } = pendingPhoto;
70
+ pendingPhoto = null;
71
+ resolve(data);
72
+ };
73
+ const capture = (): Promise<string | null> => {
74
+ finishPhoto(null);
75
+ const id = ++photoId;
76
+ return new Promise((resolve) => {
77
+ const timer = setTimeout(() => finishPhoto(null), 10_000);
78
+ pendingPhoto = { id, resolve, timer };
79
+ try {
80
+ send({ call: "captureGroupPhoto", args: [id] });
81
+ } catch {
82
+ finishPhoto(null);
83
+ }
84
+ });
85
+ };
86
+
56
87
  const api: WorldApi = {
57
88
  version: WORLD_API_VERSION,
58
89
  start(options) {
@@ -67,19 +98,33 @@ export function createWorldBridge(post: (text: string) => void): WorldBridge {
67
98
  data[key] = value;
68
99
  }
69
100
  }
101
+ if (onPhotoReady) {
102
+ handlers.set("onCaptureReady", () => onPhotoReady(capture));
103
+ handlers.set("onCaptured", (id, photo) => {
104
+ if (pendingPhoto && id === pendingPhoto.id)
105
+ finishPhoto(typeof photo === "string" ? photo : null);
106
+ });
107
+ callbacks.push("onCaptureReady", "onCaptured");
108
+ }
70
109
  const brand = brandForPage(options.brand);
71
110
  send({
72
111
  call: "start",
73
112
  args: [{ ...data, ...(brand === undefined ? {} : { brand }), callbacks }],
74
113
  });
75
114
  },
76
- stop: sender("stop"),
115
+ stop() {
116
+ handlers.clear();
117
+ finishPhoto(null);
118
+ onPhotoReady?.(null);
119
+ send({ call: "stop", args: [] });
120
+ },
77
121
  setTheme: sender("setTheme"),
78
122
  setSessions: sender("setSessions"),
79
123
  event: sender("event"),
80
124
  select: sender("select"),
81
125
  focusProject: sender("focusProject"),
82
126
  setBoardRows: sender("setBoardRows"),
127
+ setDuties: sender("setDuties"),
83
128
  photoRelease: sender("photoRelease"),
84
129
  setClaudeVersion: sender("setClaudeVersion"),
85
130
  setTenure: sender("setTenure"),
@@ -1,3 +1,4 @@
1
+ import { leaveFullscreenAfter, sceneUsesEscape } from "./escape.js";
1
2
  import { isWorldApi, type WorldApi } from "./world-api.js";
2
3
 
3
4
  // Web only. world-view.tsx calls this from an effect, and the surface renders that view only in
@@ -86,6 +87,13 @@ export function openWorldFrame({ container, script, title }: WorldFrameInput): W
86
87
  if (doc.body.classList.contains("is-fp")) return;
87
88
  if (doc.activeElement === null || doc.activeElement === doc.body) focusApp();
88
89
  });
90
+ // The office holds Escape while fullscreen (escape.ts): a press the scene has no use
91
+ // for leaves fullscreen. Read in the capture phase, before the scene ends what it was for.
92
+ doc.addEventListener(
93
+ "keydown",
94
+ (event) => leaveFullscreenAfter(event, sceneUsesEscape(doc), document),
95
+ true,
96
+ );
89
97
  loaded = world;
90
98
  resolve(world);
91
99
  },