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,252 @@
1
+ import { useCallback, useState } from "react";
2
+ import { Text, View } from "react-native";
3
+ import { useRpc } from "@getpaseo/plugin/client";
4
+ import { TextInput } from "@getpaseo/plugin/client/ui";
5
+ import {
6
+ trackersSaveRpc,
7
+ trackersTestRpc,
8
+ type IncidentsState,
9
+ type TrackerSource,
10
+ type TrackersResult,
11
+ } from "../shared/contracts.js";
12
+ import { ActionButton } from "./action-button.js";
13
+ import type { OfficeStyles } from "./styles.js";
14
+
15
+ type Connections = NonNullable<IncidentsState["connections"]>;
16
+
17
+ /** Where the host's sign-in comes from, as the line under a connection says it. */
18
+ export function sourceLine(name: string, source: TrackerSource | undefined): string | null {
19
+ switch (source) {
20
+ case "saved":
21
+ return `${name} connection saved on this host`;
22
+ case "env":
23
+ return `${name} connection from the host's environment; a saved one replaces it`;
24
+ case "none":
25
+ return `No ${name} connection on this host`;
26
+ default:
27
+ // Not known until the host has said: nothing is claimed before then.
28
+ return null;
29
+ }
30
+ }
31
+
32
+ /** The host's answer as a button takes it: a refusal becomes the button's error. */
33
+ function accept(result: TrackersResult): void {
34
+ if (!result.ok) throw new Error(result.problem);
35
+ }
36
+
37
+ interface FieldProps {
38
+ label: string;
39
+ hint: string;
40
+ value: string;
41
+ onChangeText(next: string): void;
42
+ secret?: boolean;
43
+ styles: OfficeStyles;
44
+ }
45
+
46
+ /** Typed text that is kept until a button sends it, unlike a setting's field. */
47
+ function ConnectionField({ label, hint, value, onChangeText, secret, styles }: FieldProps) {
48
+ return (
49
+ <View style={styles.headerField}>
50
+ <Text style={styles.sheetLabel}>{label}</Text>
51
+ <TextInput
52
+ accessibilityLabel={label}
53
+ accessibilityHint={hint}
54
+ value={value}
55
+ onChangeText={onChangeText}
56
+ secureTextEntry={secret === true}
57
+ autoCapitalize="none"
58
+ autoCorrect={false}
59
+ spellCheck={false}
60
+ style={styles.fieldInput}
61
+ />
62
+ <Text style={styles.fieldHint}>{hint}</Text>
63
+ </View>
64
+ );
65
+ }
66
+
67
+ interface ButtonsProps {
68
+ name: string;
69
+ source: TrackerSource | undefined;
70
+ /** What the last test or save came to; null before one, and after a change it no longer fits. */
71
+ note: string | null;
72
+ test(): Promise<void>;
73
+ save(): Promise<void>;
74
+ clear(): Promise<void>;
75
+ styles: OfficeStyles;
76
+ }
77
+
78
+ function ConnectionButtons({ name, source, note, test, save, clear, styles }: ButtonsProps) {
79
+ const line = note ?? sourceLine(name, source);
80
+ return (
81
+ <View style={styles.headerField}>
82
+ {line === null ? null : <Text style={styles.fieldHint}>{line}</Text>}
83
+ <View style={styles.actions}>
84
+ <ActionButton
85
+ label="Test connection"
86
+ pendingLabel="Testing..."
87
+ name={`Test ${name} connection`}
88
+ onPress={test}
89
+ styles={styles}
90
+ />
91
+ <ActionButton
92
+ label="Save connection"
93
+ pendingLabel="Saving..."
94
+ name={`Save ${name} connection`}
95
+ onPress={save}
96
+ primary
97
+ styles={styles}
98
+ />
99
+ {source === "saved" ? (
100
+ <ActionButton
101
+ label="Remove"
102
+ pendingLabel="Removing..."
103
+ name={`Remove saved ${name} connection`}
104
+ onPress={clear}
105
+ styles={styles}
106
+ />
107
+ ) : null}
108
+ </View>
109
+ </View>
110
+ );
111
+ }
112
+
113
+ interface JiraProps {
114
+ /** Absent until the host has said where its sign-in comes from. */
115
+ connection: Connections["jira"] | undefined;
116
+ styles: OfficeStyles;
117
+ }
118
+
119
+ /**
120
+ * Jira's address, email and API token, saved on the host in a file only the daemon's user can
121
+ * read. The token goes to the host and never comes back: its field is empty for the one kept.
122
+ */
123
+ export function JiraConnection({ connection, styles }: JiraProps) {
124
+ const callTest = useRpc(trackersTestRpc);
125
+ const callSave = useRpc(trackersSaveRpc);
126
+ // What is typed; null shows what the host holds.
127
+ const [baseUrl, setBaseUrl] = useState<string | null>(null);
128
+ const [email, setEmail] = useState<string | null>(null);
129
+ const [token, setToken] = useState("");
130
+ const [note, setNote] = useState<string | null>(null);
131
+ const typed = useCallback(
132
+ () => ({
133
+ baseUrl: baseUrl ?? connection?.baseUrl ?? "",
134
+ email: email ?? connection?.email ?? "",
135
+ token,
136
+ }),
137
+ [baseUrl, email, token, connection],
138
+ );
139
+ const test = useCallback(async () => {
140
+ setNote(null);
141
+ accept(await callTest({ tracker: "jira", ...typed() }));
142
+ setNote("Jira accepted the sign-in");
143
+ }, [callTest, typed]);
144
+ const save = useCallback(async () => {
145
+ setNote(null);
146
+ accept(await callSave({ action: "save-jira", ...typed() }));
147
+ setBaseUrl(null);
148
+ setEmail(null);
149
+ setToken("");
150
+ }, [callSave, typed]);
151
+ const clear = useCallback(async () => {
152
+ setNote(null);
153
+ accept(await callSave({ action: "clear", tracker: "jira" }));
154
+ setBaseUrl(null);
155
+ setEmail(null);
156
+ setToken("");
157
+ }, [callSave]);
158
+ const kept = connection?.source === "saved";
159
+ return (
160
+ <>
161
+ <ConnectionField
162
+ label="Jira address"
163
+ hint="Your Jira site, such as https://your-site.atlassian.net."
164
+ value={baseUrl ?? connection?.baseUrl ?? ""}
165
+ onChangeText={setBaseUrl}
166
+ styles={styles}
167
+ />
168
+ <ConnectionField
169
+ label="Jira email"
170
+ hint="The Atlassian account the API token belongs to."
171
+ value={email ?? connection?.email ?? ""}
172
+ onChangeText={setEmail}
173
+ styles={styles}
174
+ />
175
+ <ConnectionField
176
+ label="Jira API token"
177
+ hint={
178
+ kept
179
+ ? "Leave empty to keep the saved token. Stored on the host for its user only; never shown again."
180
+ : "Stored on the host for its user only; never shown again."
181
+ }
182
+ value={token}
183
+ onChangeText={setToken}
184
+ secret
185
+ styles={styles}
186
+ />
187
+ <ConnectionButtons
188
+ name="Jira"
189
+ source={connection?.source}
190
+ note={note}
191
+ test={test}
192
+ save={save}
193
+ clear={clear}
194
+ styles={styles}
195
+ />
196
+ </>
197
+ );
198
+ }
199
+
200
+ interface SentryProps {
201
+ connection: Connections["sentry"] | undefined;
202
+ styles: OfficeStyles;
203
+ }
204
+
205
+ /** Sentry's auth token, kept as Jira's. A test asks the organisation and address set below. */
206
+ export function SentryConnection({ connection, styles }: SentryProps) {
207
+ const callTest = useRpc(trackersTestRpc);
208
+ const callSave = useRpc(trackersSaveRpc);
209
+ const [token, setToken] = useState("");
210
+ const [note, setNote] = useState<string | null>(null);
211
+ const test = useCallback(async () => {
212
+ setNote(null);
213
+ accept(await callTest({ tracker: "sentry", token }));
214
+ setNote("Sentry accepted the token");
215
+ }, [callTest, token]);
216
+ const save = useCallback(async () => {
217
+ setNote(null);
218
+ accept(await callSave({ action: "save-sentry", token }));
219
+ setToken("");
220
+ }, [callSave, token]);
221
+ const clear = useCallback(async () => {
222
+ setNote(null);
223
+ accept(await callSave({ action: "clear", tracker: "sentry" }));
224
+ setToken("");
225
+ }, [callSave]);
226
+ const kept = connection?.source === "saved";
227
+ return (
228
+ <>
229
+ <ConnectionField
230
+ label="Sentry auth token"
231
+ hint={
232
+ kept
233
+ ? "A token is saved; type a new one to replace it. Stored on the host for its user only; never shown again."
234
+ : "Stored on the host for its user only; never shown again."
235
+ }
236
+ value={token}
237
+ onChangeText={setToken}
238
+ secret
239
+ styles={styles}
240
+ />
241
+ <ConnectionButtons
242
+ name="Sentry"
243
+ source={connection?.source}
244
+ note={note}
245
+ test={test}
246
+ save={save}
247
+ clear={clear}
248
+ styles={styles}
249
+ />
250
+ </>
251
+ );
252
+ }
@@ -0,0 +1,90 @@
1
+ import type { PluginTheme } from "@getpaseo/plugin";
2
+ import { Platform, StyleSheet } from "react-native";
3
+
4
+ /** The same reading column in the session drawer and in the larger workspace. */
5
+ export function transcriptStyles(colors: PluginTheme["colors"], touch: boolean) {
6
+ return StyleSheet.create({
7
+ messages: { gap: 16 },
8
+ assistant: { minWidth: 0, gap: 6 },
9
+ speaker: { flexDirection: "row", alignItems: "center", gap: 7 },
10
+ avatar: {
11
+ width: 22,
12
+ height: 22,
13
+ borderRadius: 7,
14
+ alignItems: "center",
15
+ justifyContent: "center",
16
+ borderWidth: 1,
17
+ borderColor: colors.border,
18
+ backgroundColor: colors.surface1,
19
+ },
20
+ initials: { fontSize: 10, fontWeight: "700", color: colors.accent },
21
+ name: { fontSize: 12, lineHeight: 17, fontWeight: "600", color: colors.foregroundMuted },
22
+ outgoing: {
23
+ alignSelf: "flex-end",
24
+ maxWidth: "92%",
25
+ minWidth: 0,
26
+ paddingHorizontal: 13,
27
+ paddingVertical: 9,
28
+ gap: 4,
29
+ borderRadius: 13,
30
+ borderTopRightRadius: 4,
31
+ backgroundColor: colors.surface2,
32
+ },
33
+ text: { color: colors.foreground, fontSize: 14, lineHeight: 21 },
34
+ assignment: {
35
+ minWidth: 0,
36
+ gap: 4,
37
+ paddingHorizontal: 13,
38
+ paddingBottom: 12,
39
+ borderRadius: 10,
40
+ borderWidth: 1,
41
+ borderColor: colors.border,
42
+ backgroundColor: colors.surface1,
43
+ },
44
+ disclosure: {
45
+ flexDirection: "row",
46
+ alignItems: "center",
47
+ gap: 8,
48
+ minHeight: touch ? 44 : 36,
49
+ },
50
+ stepButton: {
51
+ alignSelf: "flex-start",
52
+ maxWidth: "100%",
53
+ flexDirection: "row",
54
+ alignItems: "center",
55
+ gap: 8,
56
+ minHeight: touch ? 44 : 34,
57
+ paddingHorizontal: 10,
58
+ borderRadius: 8,
59
+ borderWidth: 1,
60
+ borderColor: colors.border,
61
+ backgroundColor: colors.surface1,
62
+ },
63
+ pressed: { backgroundColor: colors.surface2 },
64
+ steps: { gap: 4 },
65
+ stepList: { paddingLeft: 12, borderLeftWidth: 1, borderLeftColor: colors.border, gap: 5 },
66
+ code: {
67
+ color: colors.foregroundMuted,
68
+ fontFamily: Platform.select({ ios: "Menlo", default: "monospace" }),
69
+ fontSize: 12,
70
+ lineHeight: 18,
71
+ },
72
+ stepTitle: { color: colors.foreground, flexShrink: 1, fontWeight: "600", fontSize: 12 },
73
+ taskId: {
74
+ color: colors.foregroundMuted,
75
+ flexGrow: 1,
76
+ fontSize: 12,
77
+ fontVariant: ["tabular-nums"],
78
+ },
79
+ raw: { paddingTop: 10, marginTop: 5, borderTopWidth: 1, borderTopColor: colors.border },
80
+ warning: { color: colors.statusWarning },
81
+ danger: { color: colors.statusDanger },
82
+ notice: {
83
+ borderLeftWidth: 2,
84
+ borderLeftColor: colors.border,
85
+ paddingLeft: 10,
86
+ paddingVertical: 3,
87
+ },
88
+ errorNotice: { borderLeftColor: colors.statusDanger },
89
+ });
90
+ }
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
2
  import { useSettings } from "@getpaseo/plugin/client";
3
- import { officeDeviceSettings } from "../shared/settings.js";
3
+ import { officeDeviceSettings, type OfficeScene, type OfficeLighting } from "../shared/settings.js";
4
4
 
5
5
  export interface DeviceSwitch {
6
6
  /** The switch as the person left it (a tap shows at once); null while the device's setting is read or unreadable. */
@@ -11,8 +11,8 @@ export interface DeviceSwitch {
11
11
  }
12
12
 
13
13
  /** A save of the tap against a revision, and whether the store took it. */
14
- interface Tried {
15
- value: boolean;
14
+ interface Tried<Value> {
15
+ value: Value;
16
16
  revision: string;
17
17
  stored: boolean;
18
18
  }
@@ -23,14 +23,22 @@ interface Tried {
23
23
  * tried again on the revision a reload shows; a refusal that moved nothing is not, and the switch
24
24
  * then holds the tap until the next tap or the surface closes (`unsaved`).
25
25
  */
26
- export function useDeviceSwitch(
27
- field: "street" | "sound" | "sessionsHidden",
28
- fallback: boolean,
29
- ): DeviceSwitch {
26
+ interface Preferences {
27
+ street: boolean;
28
+ sound: boolean;
29
+ sessionsHidden: boolean;
30
+ scene: OfficeScene;
31
+ lighting: OfficeLighting;
32
+ }
33
+
34
+ export function useDeviceSwitch<Field extends keyof Preferences>(
35
+ field: Field,
36
+ fallback: Preferences[Field],
37
+ ) {
30
38
  const settings = useSettings(officeDeviceSettings);
31
39
  const stored = settings.status === "ready" ? settings : null;
32
- const [wanted, setWanted] = useState<boolean | null>(null);
33
- const [tried, setTried] = useState<Tried | null>(null);
40
+ const [wanted, setWanted] = useState<Preferences[Field] | null>(null);
41
+ const [tried, setTried] = useState<Tried<Preferences[Field]> | null>(null);
34
42
  const [saving, setSaving] = useState(false);
35
43
  const mounted = useRef(true);
36
44
  useEffect(() => {
@@ -51,7 +59,7 @@ export function useDeviceSwitch(
51
59
  // Waiting for the store to show a save it took, or given up on a refusal: not saved again.
52
60
  if (tried?.value === wanted && tried.revision === revision) return;
53
61
  setSaving(true);
54
- async function keep(value: boolean): Promise<void> {
62
+ async function keep(value: Preferences[Field]): Promise<void> {
55
63
  const ok = await save({ ...values, [field]: value }, revision);
56
64
  if (!ok) await reload().catch(() => undefined);
57
65
  if (!mounted.current) return;
@@ -60,7 +68,7 @@ export function useDeviceSwitch(
60
68
  }
61
69
  void keep(wanted);
62
70
  }, [wanted, stored, saving, tried, save, reload, field]);
63
- const set = useCallback((next: boolean) => {
71
+ const set = useCallback((next: Preferences[Field]) => {
64
72
  setTried(null);
65
73
  setWanted(next);
66
74
  }, []);
@@ -73,7 +81,8 @@ export function useDeviceSwitch(
73
81
  // The floor waits for the street choice before starting. A finished, unreadable
74
82
  // document falls back to the layout default and can still be overridden for this visit.
75
83
  const streetUnreadable =
76
- field === "street" && (settings.status === "error" || settings.status === "invalid");
84
+ (field === "street" || field === "scene" || field === "lighting") &&
85
+ (settings.status === "error" || settings.status === "invalid");
77
86
  const on = wanted ?? stored?.values[field] ?? (stored || streetUnreadable ? fallback : null);
78
87
  return { on, unsaved: unsaved || (wanted !== null && streetUnreadable), set };
79
88
  }
@@ -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
+ }
@@ -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 };
@@ -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
+ }