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.
Files changed (138) 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 +197 -73
  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/transcript-styles.ts +90 -0
  73. package/client/use-device-switch.ts +21 -12
  74. package/client/use-duty-actions.ts +43 -0
  75. package/client/use-group-photo.ts +48 -0
  76. package/client/use-new-agent.ts +4 -0
  77. package/client/use-street.ts +8 -0
  78. package/client/workspace-office-tools.tsx +102 -0
  79. package/client/workspace-overlay-route.web.ts +47 -0
  80. package/client/workspace-overlay.tsx +195 -0
  81. package/client/world/adapter.ts +37 -2
  82. package/client/world/escape.ts +58 -0
  83. package/client/world/use-world-feed.ts +6 -2
  84. package/client/world/workspace-dock.ts +6 -0
  85. package/client/world/world-api.ts +45 -4
  86. package/client/world/world-bridge-page.ts +14 -3
  87. package/client/world/world-bridge.ts +50 -5
  88. package/client/world/world-frame.web.ts +8 -0
  89. package/client/world/world-view-native.tsx +31 -10
  90. package/client/world/world-view-shared.ts +36 -7
  91. package/client/world/world-view.tsx +93 -21
  92. package/docs/office.md +148 -58
  93. package/index.client.tsx +13 -6
  94. package/index.server.ts +125 -9
  95. package/package.json +2 -1
  96. package/server/activity.ts +42 -19
  97. package/server/agent-tools.ts +11 -5
  98. package/server/board-service.ts +381 -10
  99. package/server/brand-logo.ts +34 -0
  100. package/server/chat-group.ts +83 -0
  101. package/server/chat-service.ts +406 -62
  102. package/server/chat-store.ts +1 -4
  103. package/server/directory.ts +22 -7
  104. package/server/duty-service.ts +230 -0
  105. package/server/group-photo.ts +39 -0
  106. package/server/home-departure.ts +47 -0
  107. package/server/hub.ts +43 -1
  108. package/server/live-ports.ts +114 -18
  109. package/server/lobby-pickup.ts +170 -0
  110. package/server/machine/details.ts +91 -0
  111. package/server/mention-queue.ts +14 -0
  112. package/server/office.ts +110 -6
  113. package/server/paths.ts +9 -0
  114. package/server/ssh/LICENSE.paseo +211 -0
  115. package/server/ssh/client.ts +401 -0
  116. package/server/ssh/discovery.ts +230 -0
  117. package/server/ssh/installed.ts +104 -0
  118. package/server/ssh/monitor.ts +104 -0
  119. package/server/ssh/pid-files.ts +194 -0
  120. package/server/ssh/read.ts +136 -0
  121. package/server/subagent-names.ts +4 -0
  122. package/server/words.generated.ts +1 -1
  123. package/server/world.generated.ts +1 -1
  124. package/shared/appearance.ts +43 -0
  125. package/shared/branding.ts +53 -0
  126. package/shared/chat-words.ts +2 -2
  127. package/shared/contracts.ts +135 -4
  128. package/shared/duties.ts +100 -0
  129. package/shared/host-details.ts +25 -0
  130. package/shared/lobby-assignment.ts +34 -0
  131. package/shared/model.ts +9 -1
  132. package/shared/names.ts +2 -0
  133. package/shared/settings.ts +14 -3
  134. package/shared/ssh.ts +34 -0
  135. package/shared/upstream/README.md +1 -3
  136. package/shared/upstream/chat-engine.d.ts +4 -0
  137. package/shared/upstream/prompt-coach.d.ts +6 -0
  138. package/shared/upstream/prompt-coach.js +178 -0
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+
3
+ export const APPEARANCE_KEY = "office.appearance";
4
+ export const COLORS = ["Red", "Orange", "Green", "Teal", "Blue", "Violet", "Pink", "Gold"] as const;
5
+ export const GENDERS = ["Male", "Female"] as const;
6
+ export const AVATARS = { glasses: "👓", headphones: "🎧", cap: "🧢", beanie: "🧶" } as const;
7
+ export const AppearanceSchema = z.object({
8
+ name: z
9
+ .string()
10
+ .trim()
11
+ .min(1)
12
+ .max(60)
13
+ .regex(/^[^\r\n]+$/)
14
+ .optional(),
15
+ gender: z.enum(GENDERS).optional(),
16
+ avatar: z.enum(["glasses", "headphones", "cap", "beanie"]).optional(),
17
+ color: z.enum(COLORS).optional(),
18
+ });
19
+ export type Appearance = z.output<typeof AppearanceSchema>;
20
+ /** Omit automatic choices from the persisted Office profile. */
21
+ export function savedAppearance(draft?: Appearance): Appearance | null {
22
+ const profile: Appearance = {};
23
+ const name = draft?.name?.trim();
24
+ if (name) profile.name = name;
25
+ if (draft?.gender) profile.gender = draft.gender;
26
+ if (draft?.avatar) profile.avatar = draft.avatar;
27
+ if (draft?.color) profile.color = draft.color;
28
+ return Object.keys(profile).length ? profile : null;
29
+ }
30
+ /** Floor colors with a day and night contrast of at least 3.2:1. */
31
+ export const SHIRTS = [
32
+ { shirt: "#DA494E", shade: "#B63D41" },
33
+ { shirt: "#B76724", shade: "#98561E" },
34
+ { shirt: "#2A8D58", shade: "#237549" },
35
+ { shirt: "#208892", shade: "#1B7179" },
36
+ { shirt: "#3D7AD8", shade: "#3366B4" },
37
+ { shirt: "#8265E8", shade: "#6C55C1" },
38
+ { shirt: "#C15499", shade: "#A1467F" },
39
+ { shirt: "#8C7C2D", shade: "#746625" },
40
+ ] as const;
41
+ export function shirtColor(appearance?: Appearance) {
42
+ return appearance?.color ? SHIRTS[COLORS.indexOf(appearance.color)].shirt : undefined;
43
+ }
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+
3
+ const name = z
4
+ .string()
5
+ .trim()
6
+ .min(1)
7
+ .max(64)
8
+ .regex(/^[^\r\n]+$/, "Use a single-line name");
9
+ const color = z
10
+ .string()
11
+ .trim()
12
+ .regex(/^#[0-9a-f]{6}$/i, "Use a six-digit hex color, such as #e8865f");
13
+ const logoUrl = z
14
+ .string()
15
+ .trim()
16
+ .max(2048)
17
+ .refine((value) => {
18
+ try {
19
+ const url = new URL(value);
20
+ return url.protocol === "https:" && !url.username && !url.password;
21
+ } catch {
22
+ return false;
23
+ }
24
+ }, "Enter an HTTPS image URL without credentials");
25
+
26
+ export const BrandingSchema = z.object({
27
+ name: name.optional(),
28
+ color: color.optional(),
29
+ logoUrl: logoUrl.optional(),
30
+ });
31
+ export type Branding = z.output<typeof BrandingSchema>;
32
+ export const brandFields = {
33
+ brandName: name.or(z.literal("")).optional(),
34
+ brandColor: color.or(z.literal("")).optional(),
35
+ brandLogoUrl: logoUrl.or(z.literal("")).optional(),
36
+ };
37
+
38
+ /** Resolve each field independently; publish only the three validated display values. */
39
+ export function hostBrand(
40
+ values: { brandName?: string; brandColor?: string; brandLogoUrl?: string },
41
+ env: Record<string, string | undefined>,
42
+ ): Branding | undefined {
43
+ const result: Branding = {};
44
+ for (const [field, override, fallback] of [
45
+ ["name", values.brandName, env.PASEO_BRAND_NAME],
46
+ ["color", values.brandColor, env.PASEO_BRAND_COLOR],
47
+ ["logoUrl", values.brandLogoUrl, env.PASEO_BRAND_LOGO_URL],
48
+ ] as const) {
49
+ const value = BrandingSchema.shape[field].safeParse(override || fallback);
50
+ if (value.success && value.data) result[field] = value.data;
51
+ }
52
+ return Object.keys(result).length ? result : undefined;
53
+ }
@@ -4,7 +4,6 @@ import type { Translate } from "./upstream/chat-engine.js";
4
4
  // Upstream's English name for the director (vendor/my-office/src/i18n/locales/en/people.js).
5
5
  const DIRECTOR = "Director";
6
6
  const CHAT_PREFIX = "chat.";
7
- const plural = new Intl.PluralRules("en-US");
8
7
 
9
8
  // Array.isArray does not narrow a readonly array.
10
9
  function isList(words: ChatWords): words is readonly ChatWords[] {
@@ -53,7 +52,8 @@ function line(
53
52
  ): string | undefined {
54
53
  if (words === undefined || typeof words === "string") return words;
55
54
  if (isList(words)) return line(words[Math.floor(Math.random() * words.length)], values);
56
- const chosen = words[plural.select(Number(values.n ?? 0))] ?? words.other;
55
+ // This English dictionary only pluralizes counts. Mobile clients can lack Intl.PluralRules.
56
+ const chosen = Math.abs(Number(values.n)) === 1 ? (words.one ?? words.other) : words.other;
57
57
  return typeof chosen === "string" ? chosen : undefined;
58
58
  }
59
59
 
@@ -1,10 +1,12 @@
1
+ import { BrandingSchema } from "./branding.js";
2
+ import { AppearanceSchema } from "./appearance.js";
1
3
  import { WORDS_LANGUAGES } from "./scene-language.js";
2
4
  import { defineRpc, defineSubscription } from "@getpaseo/plugin";
3
5
  import { z } from "zod";
4
6
  // In their own file, so code that needs only a name does not load the schemas.
5
7
  import { ACTIVITY_KINDS, TEST_RESULTS } from "./names.js";
6
8
 
7
- export { ACTIVITY_KINDS, LOBBY, USER_AUTHOR } from "./names.js";
9
+ export { ACTIVITY_KINDS, DUTY, LOBBY, USER_AUTHOR } from "./names.js";
8
10
  export type { ActivityKind, ActivityStep, TestResult } from "./names.js";
9
11
  export const POST_TEXT_MAX = 2000;
10
12
  /** The checks of one pull request the office carries. */
@@ -49,6 +51,7 @@ export const OfficeAgentSchema = z.object({
49
51
  createdAt: z.string(),
50
52
  /** Absent for a provider that reports no context window, and before an agent's first turn. */
51
53
  context: AgentContextSchema.optional(),
54
+ appearance: AppearanceSchema.optional(),
52
55
  /** A sub-agent's number among its parent's, as the office stored it on the agent. */
53
56
  number: z.number().int().positive().optional(),
54
57
  /** On a parent: the number its next sub-agent gets. */
@@ -60,6 +63,8 @@ export const OfficeAgentSchema = z.object({
60
63
  * earliest. Absent for any other status: a running agent's time moves with every step.
61
64
  */
62
65
  idleSince: z.string().optional(),
66
+ /** When the host flagged the currently pending permission. */
67
+ permissionSince: z.string().optional(),
63
68
  /** What the agent's turns have cost so far; absent when its provider says no cost. */
64
69
  costUsd: z.number().nonnegative().optional(),
65
70
  /** When the agent was last prompted; on a running or starting agent only. */
@@ -153,11 +158,43 @@ export const PostSchema = z.object({
153
158
  /** Tasks only. */
154
159
  state: TaskStateSchema.optional(),
155
160
  claimedBy: z.string().optional(),
161
+ /** Named lobby tasks created with tracked pickup. Older named posts may already have woken their agent. */
162
+ namedPickup: z.literal(true).optional(),
163
+ /** Persisted until Paseo acknowledges an automatic lobby assignment. */
164
+ pickupMessageId: z.string().optional(),
165
+ /** On the duty board: the duty of the list it was posted for, and its day (YYYY-MM-DD). */
166
+ duty: z.object({ id: z.string(), day: z.string() }).optional(),
167
+ /** A claimed lobby task's copy on the claimer's board, and the copy's lobby task: each other's id. */
168
+ link: z.string().optional(),
156
169
  createdAt: z.string(),
157
170
  updatedAt: z.string(),
158
171
  });
159
172
  export type Post = z.output<typeof PostSchema>;
160
173
 
174
+ /** The scene's four pantry chores, which a duty of the starting list is acted out as. */
175
+ export const DUTY_CHORES = ["cups", "trash", "plants", "table"] as const;
176
+ export type DutyChore = (typeof DUTY_CHORES)[number];
177
+
178
+ /** A duty of the owner's list. Without instructions it is pretend: the 3D office acts it out. */
179
+ export const DutySchema = z.object({
180
+ id: z.string(),
181
+ name: z.string(),
182
+ /** What an agent handed the duty is asked to do; empty for a pretend duty. */
183
+ instructions: z.string(),
184
+ /** The weekdays it comes due, 0 for Sunday to 6 for Saturday. */
185
+ days: z.array(z.number().int().min(0).max(6)),
186
+ /** The chore the 3D office acts it out as; absent for a duty the owner added. */
187
+ chore: z.enum(DUTY_CHORES).optional(),
188
+ });
189
+ export type Duty = z.output<typeof DutySchema>;
190
+
191
+ /** The duty list, and the day the duty board was last brought up to (null before the first). */
192
+ export const DutyBoardSchema = z.object({
193
+ duties: z.array(DutySchema),
194
+ day: z.string().nullable(),
195
+ });
196
+ export type DutyBoard = z.output<typeof DutyBoardSchema>;
197
+
161
198
  export const WakeStateSchema = z.object({
162
199
  paused: z.boolean(),
163
200
  /** Deliveries waiting, per agent id; agents with none are absent. */
@@ -188,6 +225,15 @@ export type ChecklistStep = z.output<typeof ChecklistStepSchema>;
188
225
  export const ChecklistsSchema = z.record(z.string(), z.array(ChecklistStepSchema));
189
226
  export type Checklists = z.output<typeof ChecklistsSchema>;
190
227
 
228
+ /** Full step counts, independently of the cap on unfinished step text. */
229
+ const ChecklistProgressSchema = z.object({
230
+ completed: z.number().int().nonnegative(),
231
+ total: z.number().int().nonnegative(),
232
+ });
233
+ export type ChecklistProgress = z.output<typeof ChecklistProgressSchema>;
234
+ const ChecklistCountsSchema = z.record(z.string(), ChecklistProgressSchema);
235
+ export type ChecklistCounts = z.output<typeof ChecklistCountsSchema>;
236
+
191
237
  /** The stand-up notes writer, and the 8:00 schedule that starts it. */
192
238
  export const NotesStateSchema = z.object({
193
239
  /** A notes folder is set in the office's settings. */
@@ -263,6 +309,24 @@ export type WeatherState = z.output<typeof WeatherStateSchema>;
263
309
 
264
310
  /** The most characters of one chat message the office takes. */
265
311
  export const CHAT_TEXT_MAX = 600;
312
+ export const CHAT_IMAGE_LIMIT = 4;
313
+ export const CHAT_IMAGE_CHARS = 1_000_000;
314
+ // The group picture is the renderer's 480 × 360 JPEG. Six fit in a single office snapshot.
315
+ export const GROUP_PHOTO_MAX = 96_000;
316
+ export const GROUP_PHOTO_COUNT = 6;
317
+ export const GroupPhotoSchema = z
318
+ .string()
319
+ .max(GROUP_PHOTO_MAX)
320
+ .regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]*={0,2}$/);
321
+ const ChatImageSchema = z.object({
322
+ mimeType: z.literal("image/jpeg"),
323
+ data: z
324
+ .string()
325
+ .min(4)
326
+ .max(CHAT_IMAGE_CHARS)
327
+ .regex(/^[A-Za-z0-9+/]+={0,2}$/),
328
+ });
329
+ export type ChatImage = z.output<typeof ChatImageSchema>;
266
330
  /** The most chat messages kept, as upstream's engine keeps them. */
267
331
  export const CHAT_MESSAGE_MAX = 300;
268
332
 
@@ -286,8 +350,7 @@ export const ChatRemindSchema = z.object({
286
350
  });
287
351
 
288
352
  /**
289
- * A message of the team chat, as upstream's engine keeps it. Keys not named here (a photo's
290
- * picture, a work card's body) are dropped on parse.
353
+ * A message of the team chat, as upstream's engine keeps it. Older photos may have no picture.
291
354
  */
292
355
  export const ChatMessageSchema = z.object({
293
356
  id: z.string(),
@@ -302,9 +365,12 @@ export const ChatMessageSchema = z.object({
302
365
  name: z.string().optional(),
303
366
  text: z.string(),
304
367
  sticker: z.number().int().nullable().optional(),
368
+ photo: GroupPhotoSchema.nullable().optional().catch(null),
305
369
  poll: ChatPollSchema.nullable().optional(),
306
370
  remind: ChatRemindSchema.nullable().optional(),
307
371
  reply: ChatReplySchema.nullable().optional(),
372
+ /** Routing of a plain group exchange or delivery notice. Older messages have no tag. */
373
+ tag: z.string().optional().catch(undefined),
308
374
  /** Emoji → who reacted with it. */
309
375
  reacts: z.record(z.string(), z.array(z.string())),
310
376
  recalled: z.boolean().optional(),
@@ -315,6 +381,7 @@ export type ChatMessage = z.output<typeof ChatMessageSchema>;
315
381
  export const ChatSnapshotSchema = z.object({
316
382
  messages: z.array(ChatMessageSchema),
317
383
  typing: z.array(z.string()),
384
+ pinned: z.string().nullable().optional(),
318
385
  });
319
386
  export type ChatSnapshot = z.output<typeof ChatSnapshotSchema>;
320
387
 
@@ -326,13 +393,22 @@ export const ChatChangeSchema = z.discriminatedUnion("op", [
326
393
  z.object({ op: z.literal("add"), message: ChatMessageSchema }),
327
394
  z.object({ op: z.literal("update"), message: ChatMessageSchema }),
328
395
  z.object({ op: z.literal("typing"), names: z.array(z.string()) }),
329
- z.object({ op: z.literal("all"), messages: z.array(ChatMessageSchema) }),
396
+ z.object({
397
+ op: z.literal("all"),
398
+ messages: z.array(ChatMessageSchema),
399
+ pinned: z.string().nullable().optional(),
400
+ }),
330
401
  z.object({ op: z.literal("act"), what: z.literal("meeting"), id: z.string() }),
331
402
  ]);
332
403
  export type ChatChange = z.output<typeof ChatChangeSchema>;
333
404
 
334
405
  /** What the owner does in the chat; each op goes to the engine's function of that name. */
335
406
  export const ChatRequestSchema = z.discriminatedUnion("op", [
407
+ z.object({
408
+ op: z.literal("photo"),
409
+ requestId: z.string().min(1).max(80),
410
+ data: GroupPhotoSchema,
411
+ }),
336
412
  z.object({
337
413
  op: z.literal("life"),
338
414
  kind: z.string().min(1).max(40),
@@ -343,7 +419,15 @@ export const ChatRequestSchema = z.discriminatedUnion("op", [
343
419
  text: z.string().max(CHAT_TEXT_MAX).optional(),
344
420
  sticker: z.number().int().min(0).optional(),
345
421
  replyTo: z.string().min(1).optional(),
422
+ to: z.string().min(1).optional(),
423
+ images: z.array(ChatImageSchema).min(1).max(CHAT_IMAGE_LIMIT).optional(),
424
+ }),
425
+ z.object({
426
+ op: z.literal("poll"),
427
+ question: z.string().trim().min(1).max(120),
428
+ options: z.array(z.string().trim().min(1).max(60)).min(2).max(6),
346
429
  }),
430
+ z.object({ op: z.literal("pin"), id: z.string().min(1) }),
347
431
  z.object({ op: z.literal("react"), id: z.string().min(1), emoji: z.string().min(1) }),
348
432
  z.object({ op: z.literal("vote"), id: z.string().min(1), index: z.number().int().min(0) }),
349
433
  z.object({ op: z.literal("rsvp"), id: z.string().min(1), yes: z.boolean() }),
@@ -359,6 +443,7 @@ export const ChatResultSchema = z.union([
359
443
  export type ChatResult = z.output<typeof ChatResultSchema>;
360
444
 
361
445
  export const OfficeSnapshotSchema = z.object({
446
+ brand: BrandingSchema.optional(),
362
447
  agents: z.array(OfficeAgentSchema),
363
448
  workspaces: z.array(OfficeWorkspaceSchema),
364
449
  /** The "doing now" line of each running agent that has one. */
@@ -367,6 +452,7 @@ export const OfficeSnapshotSchema = z.object({
367
452
  doing: z.record(z.string(), ActivityStepSchema).optional(),
368
453
  /** Each agent's own checklist, kept after the agent stops. */
369
454
  checklists: ChecklistsSchema.optional(),
455
+ checklistProgress: ChecklistCountsSchema.optional(),
370
456
  boards: z.record(z.string(), z.array(PostSchema)),
371
457
  wake: WakeStateSchema,
372
458
  /** Absent until the office's server has read the writer's state. */
@@ -376,6 +462,8 @@ export const OfficeSnapshotSchema = z.object({
376
462
  weather: WeatherStateSchema.optional(),
377
463
  /** Absent until the office's server has loaded the chat. */
378
464
  chat: ChatSnapshotSchema.optional(),
465
+ /** The duty list; absent until the office's server has read it. Its posts are `boards.duty`. */
466
+ duties: DutyBoardSchema.optional(),
379
467
  });
380
468
  export type OfficeSnapshot = z.output<typeof OfficeSnapshotSchema>;
381
469
 
@@ -388,6 +476,7 @@ export const OfficeEventSchema = z.discriminatedUnion("type", [
388
476
  activity: z.record(z.string(), z.string()),
389
477
  doing: z.record(z.string(), ActivityStepSchema).optional(),
390
478
  checklists: ChecklistsSchema.optional(),
479
+ checklistProgress: ChecklistCountsSchema.optional(),
391
480
  }),
392
481
  z.object({ type: z.literal("board"), board: z.string(), posts: z.array(PostSchema) }),
393
482
  z.object({ type: z.literal("board-removed"), board: z.string() }),
@@ -602,6 +691,37 @@ export const setWakesPausedRpc = defineRpc({
602
691
  output: WakeStateSchema,
603
692
  });
604
693
 
694
+ /** The duty list as the editor saves it: a duty already listed keeps its id. */
695
+ export const DutyDraftSchema = z.object({
696
+ id: z.string().min(1).max(80).optional(),
697
+ name: z.string().max(400),
698
+ instructions: z.string().max(20_000),
699
+ days: z.array(z.number()).max(14),
700
+ });
701
+
702
+ export const DutiesResultSchema = z.union([
703
+ z.object({ ok: z.literal(true) }),
704
+ z.object({ ok: z.literal(false), error: z.string() }),
705
+ ]);
706
+ export type DutiesResult = z.output<typeof DutiesResultSchema>;
707
+
708
+ /** Saves the whole duty list; a duty due today that has no post yet is posted at once. */
709
+ export const dutiesSaveRpc = defineRpc({
710
+ name: "office.duties.save.request",
711
+ input: z.object({ duties: z.array(DutyDraftSchema).max(50) }),
712
+ output: DutiesResultSchema,
713
+ });
714
+
715
+ /**
716
+ * The 3D office acted out a pretend duty with this agent's figure: it is done by that agent. The
717
+ * first report wins; one for a duty an agent is handed is refused.
718
+ */
719
+ export const dutyActedRpc = defineRpc({
720
+ name: "office.duty.acted.request",
721
+ input: z.object({ id: z.string().min(1), agentId: z.string().min(1).max(80) }),
722
+ output: PostResultSchema,
723
+ });
724
+
605
725
  /**
606
726
  * Starts the stand-up notes writer, as the bell does. `started` is false when none started: one
607
727
  * is at work, no folder is set, or it could not start (the snapshot's `notes.problem` says why).
@@ -626,6 +746,12 @@ export const chatRpc = defineRpc({
626
746
  output: ChatResultSchema,
627
747
  });
628
748
 
749
+ export const worldLogoRpc = defineRpc({
750
+ name: "office.world.logo",
751
+ input: z.object({}),
752
+ output: z.object({ url: z.string(), data: z.string().nullable() }).nullable(),
753
+ });
754
+
629
755
  /**
630
756
  * The script of the page that draws the 3D office: the vendored my-office scene with three.js,
631
757
  * one self-contained file. A browser evaluates it in a frame of its own.
@@ -671,6 +797,11 @@ export const lifeSubscription = defineSubscription({
671
797
  input: z.object({}),
672
798
  event: LifeEventSchema,
673
799
  });
800
+ export const homeDepartureRpc = defineRpc({
801
+ name: "office.home.departure",
802
+ input: z.object({ agentId: z.string().min(1), idleSince: z.string().min(1) }),
803
+ output: z.object({ archived: z.boolean() }),
804
+ });
674
805
  export const tenureRpc = defineRpc({
675
806
  name: "office.tenure.request",
676
807
  input: z.object({ op: z.enum(["farewell", "official"]), name: z.string().min(1).max(200) }),
@@ -0,0 +1,100 @@
1
+ import type { Duty, DutyBoard, Post } from "./contracts.js";
2
+ import { DUTY } from "./names.js";
3
+
4
+ /** The most duties the list holds. */
5
+ export const DUTY_MAX = 12;
6
+ export const DUTY_NAME_MAX = 40;
7
+ export const DUTY_INSTRUCTIONS_MAX = 2000;
8
+ /** The most characters of a holder's name the 3D board and its tooltip show. */
9
+ export const DUTY_HOLDER_CHARS = 24;
10
+ /** A duty comes due at 08:00 in the notes' zone, the stand-up's hour: minutes of the day. */
11
+ export const DUTY_DUE_MINUTE = 8 * 60;
12
+
13
+ const WEEKDAYS = [1, 2, 3, 4, 5];
14
+
15
+ /** The list a host starts with: the 3D pantry's four chores, pretend, Monday to Friday. */
16
+ export const STARTING_DUTIES: readonly Duty[] = [
17
+ { id: "cups", name: "Wash the cups", instructions: "", days: WEEKDAYS, chore: "cups" },
18
+ { id: "bin", name: "Take out the bin", instructions: "", days: WEEKDAYS, chore: "trash" },
19
+ { id: "plants", name: "Water the plants", instructions: "", days: WEEKDAYS, chore: "plants" },
20
+ { id: "tables", name: "Wipe the tables", instructions: "", days: WEEKDAYS, chore: "table" },
21
+ ];
22
+
23
+ /** A duty as the editor sends it: an id for one already on the list, none for a new one. */
24
+ export interface DutyDraft {
25
+ id?: string;
26
+ name: string;
27
+ instructions: string;
28
+ days: readonly number[];
29
+ }
30
+
31
+ function dutyProblem(duty: DutyDraft, index: number): string | null {
32
+ const name = duty.name.trim();
33
+ if (name === "") return `duty ${index + 1} has no name`;
34
+ if (/[\r\n\u2028\u2029]/.test(name)) return `the name of duty ${index + 1} has a line break`;
35
+ if (name.length > DUTY_NAME_MAX) return `"${name}" is longer than ${DUTY_NAME_MAX} characters`;
36
+ if (duty.instructions.trim().length > DUTY_INSTRUCTIONS_MAX) {
37
+ return `the instructions of "${name}" are longer than 2,000 characters`;
38
+ }
39
+ if (duty.days.some((day) => !Number.isInteger(day) || day < 0 || day > 6)) {
40
+ return `"${name}" has a day that is not 0 (Sunday) to 6 (Saturday)`;
41
+ }
42
+ if (duty.days.some((day, at) => duty.days.indexOf(day) !== at))
43
+ return `"${name}" has a day twice`;
44
+ return null;
45
+ }
46
+
47
+ /** Why the list cannot be saved, as one sentence; null when it can. */
48
+ export function dutyListProblem(duties: readonly DutyDraft[]): string | null {
49
+ if (duties.length > DUTY_MAX) {
50
+ return `Unable to save: the duty board holds at most ${DUTY_MAX} duties`;
51
+ }
52
+ for (const [index, duty] of duties.entries()) {
53
+ const problem = dutyProblem(duty, index);
54
+ if (problem !== null) return `Unable to save: ${problem}`;
55
+ }
56
+ return null;
57
+ }
58
+
59
+ /** The text of a duty's post: its name, then its instructions after a blank line. */
60
+ export function dutyPostText(duty: Pick<Duty, "name" | "instructions">): string {
61
+ const instructions = duty.instructions.trim();
62
+ const name = duty.name.trim();
63
+ return instructions === "" ? name : `${name}\n\n${instructions}`;
64
+ }
65
+
66
+ /** A duty post on the board, with its duty (null once the duty left the list). */
67
+ export interface DutyRow {
68
+ post: Post;
69
+ duty: Duty | null;
70
+ /** Not done on its day: it stays on the board, owed. */
71
+ owed: boolean;
72
+ }
73
+
74
+ /**
75
+ * The day's duty board: one row per duty post, in the list's order, then the posts whose duty
76
+ * left the list, oldest first. A post open or claimed from an earlier day than the board's is owed.
77
+ */
78
+ export function dutyRows(board: DutyBoard | undefined, posts: readonly Post[]): DutyRow[] {
79
+ if (board === undefined) return [];
80
+ const order = new Map(board.duties.map((duty, index) => [duty.id, index]));
81
+ const rank = (post: Post) => order.get(post.duty?.id ?? "") ?? board.duties.length;
82
+ return posts
83
+ .filter((post) => post.board === DUTY && post.kind === "task" && post.duty !== undefined)
84
+ .sort((left, right) => rank(left) - rank(right) || left.seq - right.seq)
85
+ .map((post) => ({
86
+ post,
87
+ duty: board.duties.find((duty) => duty.id === post.duty?.id) ?? null,
88
+ owed:
89
+ post.state !== "done" &&
90
+ board.day !== null &&
91
+ (post.duty?.day ?? board.day).localeCompare(board.day) < 0,
92
+ }));
93
+ }
94
+
95
+ /** A holder's name on one line, cut to DUTY_HOLDER_CHARS with an ellipsis. */
96
+ export function shortHolder(name: string): string {
97
+ const line = name.trim().replace(/\s+/g, " ");
98
+ if (line.length <= DUTY_HOLDER_CHARS) return line;
99
+ return `${line.slice(0, DUTY_HOLDER_CHARS - 1).trimEnd()}…`;
100
+ }
@@ -0,0 +1,25 @@
1
+ import { defineRpc } from "@getpaseo/plugin";
2
+ import { z } from "zod";
3
+
4
+ const size = z.object({ used: z.number(), total: z.number() });
5
+ const processGroup = z.object({ name: z.string(), bytes: z.number(), count: z.number() });
6
+ const sample = z.object({ at: z.number(), ram: z.number().nullable(), cpu: z.number().nullable() });
7
+ const details = z.object({
8
+ readAt: z.number(),
9
+ hostname: z.string(),
10
+ cores: z.number(),
11
+ load: z.array(z.number()),
12
+ swap: size.nullable(),
13
+ disk: z.object({ available: z.number(), total: z.number() }).nullable(),
14
+ apps: z.array(processGroup),
15
+ caches: z.array(z.object({ name: z.string(), bytes: z.number() })),
16
+ history: z.array(sample),
17
+ });
18
+
19
+ export type HostDetails = z.output<typeof details>;
20
+ export type HostSample = z.output<typeof sample>;
21
+ export const hostDetailsRpc = defineRpc({
22
+ name: "office.machine.details",
23
+ input: z.strictObject({}),
24
+ output: details,
25
+ });
@@ -0,0 +1,34 @@
1
+ import type { Post } from "./contracts.js";
2
+
3
+ type Claim = Pick<Post, "id" | "seq">;
4
+
5
+ /** A session that opened before a plugin reload can report completion in its reply. */
6
+ export function completionLine(claim: Claim): string {
7
+ return `Completed office task ${claim.id} (assignment ${claim.seq}).`;
8
+ }
9
+
10
+ export function assignmentFooter(claim: Claim): string {
11
+ return [
12
+ `Work on this task. When it is complete, use office_update with id "${claim.id}" and action "done". If you need input, leave it claimed and explain what you need.`,
13
+ `If the tool is unavailable and you have finished, put this exact line at the end of your reply: ${completionLine(claim)}`,
14
+ ].join("\n");
15
+ }
16
+
17
+ const HEADING =
18
+ /^The office assigned you (?:lobby task (p\d+) from (?:the user|agent \S.*)|duty (p\d+) from the duty board)\.$/;
19
+
20
+ /** Recognize a complete generated prompt before presenting its task separately from the instructions. */
21
+ export function readLobbyAssignment(
22
+ text: string,
23
+ ): { id: string; body: string; kind: "lobby" | "duty" } | null {
24
+ if (!text.startsWith("The office assigned you ")) return null;
25
+ const [heading, ...lines] = text.split("\n");
26
+ const found = HEADING.exec(heading ?? "");
27
+ const id = found?.[1] ?? found?.[2];
28
+ const seq = /\(assignment (\d+)\)\.$/.exec(lines.at(-1) ?? "")?.[1];
29
+ if (!id || !seq || lines.length < 3) return null;
30
+ if (lines.splice(-2).join("\n") !== assignmentFooter({ id, seq: Number(seq) })) return null;
31
+ if (!lines.every((line) => line.startsWith(" "))) return null;
32
+ const body = lines.map((line) => line.slice(2)).join("\n");
33
+ return { id, body, kind: found?.[2] ? "duty" : "lobby" };
34
+ }
package/shared/model.ts CHANGED
@@ -2,12 +2,14 @@ import type {
2
2
  ActivityStep,
3
3
  ChecklistStep,
4
4
  Checklists,
5
+ Duty,
5
6
  OfficeAgent,
6
7
  OfficeSnapshot,
7
8
  OfficeWorkspace,
8
9
  Post,
9
10
  } from "./contracts.js";
10
- import { LOBBY } from "./names.js";
11
+ import { dutyRows, type DutyRow } from "./duties.js";
12
+ import { DUTY, LOBBY } from "./names.js";
11
13
 
12
14
  export const LOBBY_NAME = "Lobby";
13
15
 
@@ -66,6 +68,10 @@ export interface OfficeModel {
66
68
  roomOfAgent: ReadonlyMap<string, string>;
67
69
  /** The agents that wait on sub-agents, each with how many (`waitingOnOf`). */
68
70
  waitingOn: ReadonlyMap<string, number>;
71
+ /** The owner's duty list; null until the host has sent it. */
72
+ dutyList: readonly Duty[] | null;
73
+ /** The duty board's posts as the day's duties: today's, and the owed ones. */
74
+ duties: DutyRow[];
69
75
  }
70
76
 
71
77
  export type DotTone = "running" | "idle" | "starting" | "warning" | "danger";
@@ -292,6 +298,8 @@ export function buildOfficeModel(state: OfficeSnapshot): OfficeModel {
292
298
  agents,
293
299
  roomOfAgent,
294
300
  waitingOn,
301
+ dutyList: state.duties?.duties ?? null,
302
+ duties: dutyRows(state.duties, state.boards[DUTY] ?? []),
295
303
  };
296
304
  }
297
305
 
package/shared/names.ts CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  /** The host-wide board. Every other board id is a workspace id. */
5
5
  export const LOBBY = "lobby";
6
+ /** The host-wide board of the day's duties, posted from the duty list. */
7
+ export const DUTY = "duty";
6
8
  /** The author of a post the user made in the office. */
7
9
  export const USER_AUTHOR = "user";
8
10
 
@@ -1,3 +1,4 @@
1
+ import { brandFields } from "./branding.js";
1
2
  import { LANGUAGE_CHOICES } from "./scene-language.js";
2
3
  import { defineSettings } from "@getpaseo/plugin";
3
4
  import { WEATHER_MODES, MANUAL_CHOICES } from "./weather.js";
@@ -46,6 +47,8 @@ export const FLOOR_PLANS = ["pro", "cozy", "hq"] as const;
46
47
  export type FloorPlanChoice = (typeof FLOOR_PLANS)[number];
47
48
 
48
49
  const HostValuesSchema = z.object({
50
+ ...brandFields,
51
+ archiveOnDeparture: z.boolean().default(false),
49
52
  agentTools: z.boolean().default(true),
50
53
  notesFolder: z.string().default(""),
51
54
  notesTimeZone: z.string().default(""),
@@ -123,7 +126,7 @@ const SUNDAY_TO_THURSDAY = [0, 1, 2, 3, 4];
123
126
  export const officeHostSettings = defineSettings({
124
127
  id: "office",
125
128
  scope: "host",
126
- version: 5,
129
+ version: 6,
127
130
  schema: HostValuesSchema.superRefine(refuseBadTrackerValues)
128
131
  .superRefine(refuseBadDays)
129
132
  .superRefine(({ weatherUrl }, ctx) => {
@@ -144,7 +147,13 @@ export const officeHostSettings = defineSettings({
144
147
  : values,
145
148
  });
146
149
 
147
- /** The office's views: the 3D floor, the 2D pixel floor and the list. */
150
+ /** Outdoor environments for the 3D floor. */
151
+ export const OFFICE_SCENES = ["plain", "city", "countryside", "beach"] as const;
152
+ export type OfficeScene = (typeof OFFICE_SCENES)[number];
153
+ export const OFFICE_LIGHTING = ["auto", "day", "night"] as const;
154
+ export type OfficeLighting = (typeof OFFICE_LIGHTING)[number];
155
+
156
+ /** The 3D floor, the 2D pixel floor and the list. */
148
157
  export const OFFICE_VIEWS = ["3d", "2d", "list"] as const;
149
158
  export type OfficeViewChoice = (typeof OFFICE_VIEWS)[number];
150
159
 
@@ -152,7 +161,7 @@ export type OfficeViewChoice = (typeof OFFICE_VIEWS)[number];
152
161
  * Per device. `view` is the view somebody chose. A device that never chose has only `threeD`,
153
162
  * from when the office had a 3D switch: off is the list, on leaves the choice to the device. A
154
163
  * save writes both. A client from before version 2 reads neither: it refuses the newer version.
155
- * `street` controls the 3D street. When absent, wide web layouts show it.
164
+ * Earlier devices chose City or Plain with `street`. An explicit `scene` takes precedence.
156
165
  * `rungIncidents` is when this device rang its alarm for each incident, epoch ms by incident id.
157
166
  * `lastAgent` is the provider and model of the last agent started from the office, the next
158
167
  * form's start. Every save of this setting writes the document whole and carries it through.
@@ -164,6 +173,8 @@ export const officeDeviceSettings = defineSettings({
164
173
  schema: z.object({
165
174
  threeD: z.boolean().default(true),
166
175
  street: z.boolean().optional(),
176
+ scene: z.enum(OFFICE_SCENES).optional(),
177
+ lighting: z.enum(OFFICE_LIGHTING).optional(),
167
178
  sessionsHidden: z.boolean().optional(),
168
179
  view: z.enum(OFFICE_VIEWS).optional(),
169
180
  rungIncidents: z.record(z.string(), z.number()).default({}),