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.
- package/OVERVIEW.md +27 -0
- package/README.md +65 -134
- package/client/action-button.tsx +4 -1
- package/client/activity-panel.tsx +6 -4
- package/client/agent-appearance.tsx +257 -0
- package/client/agent-card.tsx +2 -1
- package/client/agent-picker-text.ts +23 -4
- package/client/agent-picker.tsx +5 -8
- package/client/board-sheet.tsx +48 -16
- package/client/board-text.ts +12 -2
- package/client/brand.ts +1 -0
- package/client/chat-chrome.tsx +318 -0
- package/client/chat-compose-tools.tsx +314 -0
- package/client/chat-dictation.tsx +133 -0
- package/client/chat-more.tsx +119 -0
- package/client/chat-panel.tsx +401 -146
- package/client/chat-quick.tsx +198 -0
- package/client/chat-text.ts +25 -6
- package/client/column-sheet.tsx +93 -23
- package/client/conversation-model.ts +19 -5
- package/client/duty-sheet.tsx +321 -0
- package/client/duty-text.ts +20 -0
- package/client/fullscreen-header.tsx +28 -13
- package/client/fullscreen-theme.ts +38 -0
- package/client/host-details.tsx +269 -0
- package/client/host-styles.ts +129 -0
- package/client/host-switches.tsx +212 -83
- package/client/incidents-card.tsx +2 -1
- package/client/janitor-card.tsx +1 -1
- package/client/library-card.tsx +2 -1
- package/client/list-text.ts +8 -6
- package/client/lobby-board.tsx +73 -53
- package/client/machine-card.tsx +225 -85
- package/client/messenger-styles.ts +216 -0
- package/client/new-agent-form.tsx +153 -61
- package/client/new-agent-model.ts +2 -0
- package/client/notes-card.tsx +111 -83
- package/client/notes-days.tsx +1 -1
- package/client/office-brand-context.ts +44 -0
- package/client/office-column.tsx +2 -1
- package/client/office-keyboard.ts +79 -0
- package/client/office-link.ts +7 -1
- package/client/office-mark.tsx +29 -0
- package/client/office-modal.tsx +440 -0
- package/client/office-settings.tsx +75 -30
- package/client/office-state.ts +12 -2
- package/client/office-surface.tsx +591 -81
- package/client/pixel/actors.ts +2 -1
- package/client/pixel/art.ts +33 -19
- package/client/pixel/pixel-office.tsx +2 -2
- package/client/prompt-coach.tsx +152 -0
- package/client/qa-card.tsx +2 -1
- package/client/review-card.tsx +2 -1
- package/client/room-board.tsx +26 -2
- package/client/scene-picker.tsx +158 -0
- package/client/scene-previews.ts +10 -0
- package/client/session-pane.tsx +25 -5
- package/client/session-panel-detail.tsx +238 -0
- package/client/session-panel.tsx +222 -137
- package/client/session-styles.ts +224 -1
- package/client/session-transcript.tsx +243 -0
- package/client/sessions-panel.tsx +181 -22
- package/client/sessions-text.ts +18 -0
- package/client/settings-sections.tsx +126 -0
- package/client/sidebar-launcher.ts +29 -0
- package/client/ssh-hosts.tsx +331 -0
- package/client/ssh-metrics.ts +76 -0
- package/client/standup-card.tsx +2 -1
- package/client/structure-view.tsx +20 -3
- package/client/styles.ts +170 -62
- package/client/team-chat-preview.tsx +96 -0
- package/client/tracker-connections.tsx +252 -0
- package/client/transcript-styles.ts +90 -0
- package/client/use-device-switch.ts +21 -12
- package/client/use-duty-actions.ts +43 -0
- package/client/use-group-photo.ts +48 -0
- package/client/use-new-agent.ts +4 -0
- package/client/use-street.ts +8 -0
- package/client/workspace-office-tools.tsx +102 -0
- package/client/workspace-overlay-route.web.ts +47 -0
- package/client/workspace-overlay.tsx +195 -0
- package/client/world/adapter.ts +37 -2
- package/client/world/escape.ts +58 -0
- package/client/world/use-world-feed.ts +6 -2
- package/client/world/workspace-dock.ts +6 -0
- package/client/world/world-api.ts +45 -4
- package/client/world/world-bridge-page.ts +14 -3
- package/client/world/world-bridge.ts +50 -5
- package/client/world/world-frame.web.ts +8 -0
- package/client/world/world-view-native.tsx +31 -10
- package/client/world/world-view-shared.ts +36 -7
- package/client/world/world-view.tsx +93 -21
- package/docs/office.md +165 -64
- package/index.client.tsx +13 -6
- package/index.server.ts +232 -16
- package/package.json +2 -1
- package/server/activity.ts +42 -19
- package/server/agent-tools.ts +11 -5
- package/server/board-service.ts +381 -10
- package/server/brand-logo.ts +34 -0
- package/server/chat-group.ts +83 -0
- package/server/chat-service.ts +406 -62
- package/server/chat-store.ts +1 -4
- package/server/directory.ts +22 -7
- package/server/duty-service.ts +230 -0
- package/server/group-photo.ts +39 -0
- package/server/home-departure.ts +47 -0
- package/server/hub.ts +43 -1
- package/server/incidents-jira.ts +19 -7
- package/server/incidents-schedule.ts +10 -10
- package/server/incidents-sentry.ts +34 -8
- package/server/live-ports.ts +114 -18
- package/server/lobby-pickup.ts +170 -0
- package/server/machine/details.ts +91 -0
- package/server/mention-queue.ts +14 -0
- package/server/office.ts +110 -6
- package/server/paths.ts +14 -0
- package/server/ssh/LICENSE.paseo +211 -0
- package/server/ssh/client.ts +401 -0
- package/server/ssh/discovery.ts +230 -0
- package/server/ssh/installed.ts +104 -0
- package/server/ssh/monitor.ts +104 -0
- package/server/ssh/pid-files.ts +194 -0
- package/server/ssh/read.ts +136 -0
- package/server/subagent-names.ts +4 -0
- package/server/tracker-credentials.ts +141 -0
- package/server/words.generated.ts +1 -1
- package/server/world.generated.ts +1 -1
- package/shared/appearance.ts +43 -0
- package/shared/branding.ts +53 -0
- package/shared/chat-words.ts +2 -2
- package/shared/contracts.ts +199 -5
- package/shared/duties.ts +100 -0
- package/shared/host-details.ts +25 -0
- package/shared/lobby-assignment.ts +34 -0
- package/shared/model.ts +9 -1
- package/shared/names.ts +2 -0
- package/shared/settings.ts +14 -3
- package/shared/ssh.ts +34 -0
- package/shared/upstream/README.md +1 -3
- package/shared/upstream/chat-engine.d.ts +4 -0
- package/shared/upstream/prompt-coach.d.ts +6 -0
- package/shared/upstream/prompt-coach.js +178 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { 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
|
+
}
|
package/shared/chat-words.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
package/shared/contracts.ts
CHANGED
|
@@ -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. */
|
|
@@ -222,14 +268,32 @@ export const IncidentSchema = z.object({
|
|
|
222
268
|
});
|
|
223
269
|
export type Incident = z.output<typeof IncidentSchema>;
|
|
224
270
|
|
|
271
|
+
/** Where a tracker's sign-in is: saved from the settings, in the daemon's environment, or nowhere. */
|
|
272
|
+
export const TRACKER_SOURCES = ["saved", "env", "none"] as const;
|
|
273
|
+
export type TrackerSource = (typeof TRACKER_SOURCES)[number];
|
|
274
|
+
|
|
225
275
|
/** The open incidents, and what keeps a tracker from being checked. */
|
|
226
276
|
export const IncidentsStateSchema = z.object({
|
|
227
277
|
open: z.array(IncidentSchema),
|
|
228
278
|
/** Why a tracker's last check failed; absent once one succeeds. */
|
|
229
279
|
problems: z.object({ jira: z.string().optional(), sentry: z.string().optional() }),
|
|
230
|
-
/** The tracker
|
|
280
|
+
/** The tracker has a sign-in on the host, saved or in its environment. Never the values. */
|
|
231
281
|
jiraReady: z.boolean(),
|
|
232
282
|
sentryReady: z.boolean(),
|
|
283
|
+
/**
|
|
284
|
+
* Where each tracker's sign-in comes from, and Jira's address and email. Never a token. Absent
|
|
285
|
+
* from a server older than the settings' connections.
|
|
286
|
+
*/
|
|
287
|
+
connections: z
|
|
288
|
+
.object({
|
|
289
|
+
jira: z.object({
|
|
290
|
+
source: z.enum(TRACKER_SOURCES),
|
|
291
|
+
baseUrl: z.string(),
|
|
292
|
+
email: z.string(),
|
|
293
|
+
}),
|
|
294
|
+
sentry: z.object({ source: z.enum(TRACKER_SOURCES) }),
|
|
295
|
+
})
|
|
296
|
+
.optional(),
|
|
233
297
|
/** Why the check's schedule could not follow the settings; null once it does. */
|
|
234
298
|
scheduleError: z.string().nullable(),
|
|
235
299
|
});
|
|
@@ -263,6 +327,24 @@ export type WeatherState = z.output<typeof WeatherStateSchema>;
|
|
|
263
327
|
|
|
264
328
|
/** The most characters of one chat message the office takes. */
|
|
265
329
|
export const CHAT_TEXT_MAX = 600;
|
|
330
|
+
export const CHAT_IMAGE_LIMIT = 4;
|
|
331
|
+
export const CHAT_IMAGE_CHARS = 1_000_000;
|
|
332
|
+
// The group picture is the renderer's 480 × 360 JPEG. Six fit in a single office snapshot.
|
|
333
|
+
export const GROUP_PHOTO_MAX = 96_000;
|
|
334
|
+
export const GROUP_PHOTO_COUNT = 6;
|
|
335
|
+
export const GroupPhotoSchema = z
|
|
336
|
+
.string()
|
|
337
|
+
.max(GROUP_PHOTO_MAX)
|
|
338
|
+
.regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]*={0,2}$/);
|
|
339
|
+
const ChatImageSchema = z.object({
|
|
340
|
+
mimeType: z.literal("image/jpeg"),
|
|
341
|
+
data: z
|
|
342
|
+
.string()
|
|
343
|
+
.min(4)
|
|
344
|
+
.max(CHAT_IMAGE_CHARS)
|
|
345
|
+
.regex(/^[A-Za-z0-9+/]+={0,2}$/),
|
|
346
|
+
});
|
|
347
|
+
export type ChatImage = z.output<typeof ChatImageSchema>;
|
|
266
348
|
/** The most chat messages kept, as upstream's engine keeps them. */
|
|
267
349
|
export const CHAT_MESSAGE_MAX = 300;
|
|
268
350
|
|
|
@@ -286,8 +368,7 @@ export const ChatRemindSchema = z.object({
|
|
|
286
368
|
});
|
|
287
369
|
|
|
288
370
|
/**
|
|
289
|
-
* A message of the team chat, as upstream's engine keeps it.
|
|
290
|
-
* picture, a work card's body) are dropped on parse.
|
|
371
|
+
* A message of the team chat, as upstream's engine keeps it. Older photos may have no picture.
|
|
291
372
|
*/
|
|
292
373
|
export const ChatMessageSchema = z.object({
|
|
293
374
|
id: z.string(),
|
|
@@ -302,9 +383,12 @@ export const ChatMessageSchema = z.object({
|
|
|
302
383
|
name: z.string().optional(),
|
|
303
384
|
text: z.string(),
|
|
304
385
|
sticker: z.number().int().nullable().optional(),
|
|
386
|
+
photo: GroupPhotoSchema.nullable().optional().catch(null),
|
|
305
387
|
poll: ChatPollSchema.nullable().optional(),
|
|
306
388
|
remind: ChatRemindSchema.nullable().optional(),
|
|
307
389
|
reply: ChatReplySchema.nullable().optional(),
|
|
390
|
+
/** Routing of a plain group exchange or delivery notice. Older messages have no tag. */
|
|
391
|
+
tag: z.string().optional().catch(undefined),
|
|
308
392
|
/** Emoji → who reacted with it. */
|
|
309
393
|
reacts: z.record(z.string(), z.array(z.string())),
|
|
310
394
|
recalled: z.boolean().optional(),
|
|
@@ -315,6 +399,7 @@ export type ChatMessage = z.output<typeof ChatMessageSchema>;
|
|
|
315
399
|
export const ChatSnapshotSchema = z.object({
|
|
316
400
|
messages: z.array(ChatMessageSchema),
|
|
317
401
|
typing: z.array(z.string()),
|
|
402
|
+
pinned: z.string().nullable().optional(),
|
|
318
403
|
});
|
|
319
404
|
export type ChatSnapshot = z.output<typeof ChatSnapshotSchema>;
|
|
320
405
|
|
|
@@ -326,13 +411,22 @@ export const ChatChangeSchema = z.discriminatedUnion("op", [
|
|
|
326
411
|
z.object({ op: z.literal("add"), message: ChatMessageSchema }),
|
|
327
412
|
z.object({ op: z.literal("update"), message: ChatMessageSchema }),
|
|
328
413
|
z.object({ op: z.literal("typing"), names: z.array(z.string()) }),
|
|
329
|
-
z.object({
|
|
414
|
+
z.object({
|
|
415
|
+
op: z.literal("all"),
|
|
416
|
+
messages: z.array(ChatMessageSchema),
|
|
417
|
+
pinned: z.string().nullable().optional(),
|
|
418
|
+
}),
|
|
330
419
|
z.object({ op: z.literal("act"), what: z.literal("meeting"), id: z.string() }),
|
|
331
420
|
]);
|
|
332
421
|
export type ChatChange = z.output<typeof ChatChangeSchema>;
|
|
333
422
|
|
|
334
423
|
/** What the owner does in the chat; each op goes to the engine's function of that name. */
|
|
335
424
|
export const ChatRequestSchema = z.discriminatedUnion("op", [
|
|
425
|
+
z.object({
|
|
426
|
+
op: z.literal("photo"),
|
|
427
|
+
requestId: z.string().min(1).max(80),
|
|
428
|
+
data: GroupPhotoSchema,
|
|
429
|
+
}),
|
|
336
430
|
z.object({
|
|
337
431
|
op: z.literal("life"),
|
|
338
432
|
kind: z.string().min(1).max(40),
|
|
@@ -343,7 +437,15 @@ export const ChatRequestSchema = z.discriminatedUnion("op", [
|
|
|
343
437
|
text: z.string().max(CHAT_TEXT_MAX).optional(),
|
|
344
438
|
sticker: z.number().int().min(0).optional(),
|
|
345
439
|
replyTo: z.string().min(1).optional(),
|
|
440
|
+
to: z.string().min(1).optional(),
|
|
441
|
+
images: z.array(ChatImageSchema).min(1).max(CHAT_IMAGE_LIMIT).optional(),
|
|
346
442
|
}),
|
|
443
|
+
z.object({
|
|
444
|
+
op: z.literal("poll"),
|
|
445
|
+
question: z.string().trim().min(1).max(120),
|
|
446
|
+
options: z.array(z.string().trim().min(1).max(60)).min(2).max(6),
|
|
447
|
+
}),
|
|
448
|
+
z.object({ op: z.literal("pin"), id: z.string().min(1) }),
|
|
347
449
|
z.object({ op: z.literal("react"), id: z.string().min(1), emoji: z.string().min(1) }),
|
|
348
450
|
z.object({ op: z.literal("vote"), id: z.string().min(1), index: z.number().int().min(0) }),
|
|
349
451
|
z.object({ op: z.literal("rsvp"), id: z.string().min(1), yes: z.boolean() }),
|
|
@@ -359,6 +461,7 @@ export const ChatResultSchema = z.union([
|
|
|
359
461
|
export type ChatResult = z.output<typeof ChatResultSchema>;
|
|
360
462
|
|
|
361
463
|
export const OfficeSnapshotSchema = z.object({
|
|
464
|
+
brand: BrandingSchema.optional(),
|
|
362
465
|
agents: z.array(OfficeAgentSchema),
|
|
363
466
|
workspaces: z.array(OfficeWorkspaceSchema),
|
|
364
467
|
/** The "doing now" line of each running agent that has one. */
|
|
@@ -367,6 +470,7 @@ export const OfficeSnapshotSchema = z.object({
|
|
|
367
470
|
doing: z.record(z.string(), ActivityStepSchema).optional(),
|
|
368
471
|
/** Each agent's own checklist, kept after the agent stops. */
|
|
369
472
|
checklists: ChecklistsSchema.optional(),
|
|
473
|
+
checklistProgress: ChecklistCountsSchema.optional(),
|
|
370
474
|
boards: z.record(z.string(), z.array(PostSchema)),
|
|
371
475
|
wake: WakeStateSchema,
|
|
372
476
|
/** Absent until the office's server has read the writer's state. */
|
|
@@ -376,6 +480,8 @@ export const OfficeSnapshotSchema = z.object({
|
|
|
376
480
|
weather: WeatherStateSchema.optional(),
|
|
377
481
|
/** Absent until the office's server has loaded the chat. */
|
|
378
482
|
chat: ChatSnapshotSchema.optional(),
|
|
483
|
+
/** The duty list; absent until the office's server has read it. Its posts are `boards.duty`. */
|
|
484
|
+
duties: DutyBoardSchema.optional(),
|
|
379
485
|
});
|
|
380
486
|
export type OfficeSnapshot = z.output<typeof OfficeSnapshotSchema>;
|
|
381
487
|
|
|
@@ -388,6 +494,7 @@ export const OfficeEventSchema = z.discriminatedUnion("type", [
|
|
|
388
494
|
activity: z.record(z.string(), z.string()),
|
|
389
495
|
doing: z.record(z.string(), ActivityStepSchema).optional(),
|
|
390
496
|
checklists: ChecklistsSchema.optional(),
|
|
497
|
+
checklistProgress: ChecklistCountsSchema.optional(),
|
|
391
498
|
}),
|
|
392
499
|
z.object({ type: z.literal("board"), board: z.string(), posts: z.array(PostSchema) }),
|
|
393
500
|
z.object({ type: z.literal("board-removed"), board: z.string() }),
|
|
@@ -602,6 +709,37 @@ export const setWakesPausedRpc = defineRpc({
|
|
|
602
709
|
output: WakeStateSchema,
|
|
603
710
|
});
|
|
604
711
|
|
|
712
|
+
/** The duty list as the editor saves it: a duty already listed keeps its id. */
|
|
713
|
+
export const DutyDraftSchema = z.object({
|
|
714
|
+
id: z.string().min(1).max(80).optional(),
|
|
715
|
+
name: z.string().max(400),
|
|
716
|
+
instructions: z.string().max(20_000),
|
|
717
|
+
days: z.array(z.number()).max(14),
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
export const DutiesResultSchema = z.union([
|
|
721
|
+
z.object({ ok: z.literal(true) }),
|
|
722
|
+
z.object({ ok: z.literal(false), error: z.string() }),
|
|
723
|
+
]);
|
|
724
|
+
export type DutiesResult = z.output<typeof DutiesResultSchema>;
|
|
725
|
+
|
|
726
|
+
/** Saves the whole duty list; a duty due today that has no post yet is posted at once. */
|
|
727
|
+
export const dutiesSaveRpc = defineRpc({
|
|
728
|
+
name: "office.duties.save.request",
|
|
729
|
+
input: z.object({ duties: z.array(DutyDraftSchema).max(50) }),
|
|
730
|
+
output: DutiesResultSchema,
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* The 3D office acted out a pretend duty with this agent's figure: it is done by that agent. The
|
|
735
|
+
* first report wins; one for a duty an agent is handed is refused.
|
|
736
|
+
*/
|
|
737
|
+
export const dutyActedRpc = defineRpc({
|
|
738
|
+
name: "office.duty.acted.request",
|
|
739
|
+
input: z.object({ id: z.string().min(1), agentId: z.string().min(1).max(80) }),
|
|
740
|
+
output: PostResultSchema,
|
|
741
|
+
});
|
|
742
|
+
|
|
605
743
|
/**
|
|
606
744
|
* Starts the stand-up notes writer, as the bell does. `started` is false when none started: one
|
|
607
745
|
* is at work, no folder is set, or it could not start (the snapshot's `notes.problem` says why).
|
|
@@ -612,6 +750,51 @@ export const notesWriteRpc = defineRpc({
|
|
|
612
750
|
output: z.object({ started: z.boolean() }),
|
|
613
751
|
});
|
|
614
752
|
|
|
753
|
+
const JiraConnectionSchema = z.object({
|
|
754
|
+
baseUrl: z.string().max(500),
|
|
755
|
+
email: z.string().max(320),
|
|
756
|
+
/** Empty for the token already saved. */
|
|
757
|
+
token: z.string().max(4000),
|
|
758
|
+
});
|
|
759
|
+
const SentryConnectionSchema = z.object({ token: z.string().max(4000) });
|
|
760
|
+
|
|
761
|
+
export const TrackersChangeSchema = z.discriminatedUnion("action", [
|
|
762
|
+
JiraConnectionSchema.extend({ action: z.literal("save-jira") }),
|
|
763
|
+
SentryConnectionSchema.extend({ action: z.literal("save-sentry") }),
|
|
764
|
+
z.object({ action: z.literal("clear"), tracker: z.enum(INCIDENT_SOURCES) }),
|
|
765
|
+
]);
|
|
766
|
+
export type TrackersChange = z.output<typeof TrackersChangeSchema>;
|
|
767
|
+
|
|
768
|
+
/** `problem` is why it failed, in words safe to show: never a token. */
|
|
769
|
+
export const TrackersResultSchema = z.union([
|
|
770
|
+
z.object({ ok: z.literal(true) }),
|
|
771
|
+
z.object({ ok: z.literal(false), problem: z.string() }),
|
|
772
|
+
]);
|
|
773
|
+
export type TrackersResult = z.output<typeof TrackersResultSchema>;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Saves or clears a tracker's connection on the host, in a file only the daemon's user can read.
|
|
777
|
+
* The token is never sent back; the office's state names where each sign-in comes from.
|
|
778
|
+
*/
|
|
779
|
+
export const trackersSaveRpc = defineRpc({
|
|
780
|
+
name: "office.trackers.save.request",
|
|
781
|
+
input: TrackersChangeSchema,
|
|
782
|
+
output: TrackersResultSchema,
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
/** One signed-in request to the tracker with the connection as typed; nothing is saved. */
|
|
786
|
+
const TrackersProbeSchema = z.discriminatedUnion("tracker", [
|
|
787
|
+
JiraConnectionSchema.extend({ tracker: z.literal("jira") }),
|
|
788
|
+
SentryConnectionSchema.extend({ tracker: z.literal("sentry") }),
|
|
789
|
+
]);
|
|
790
|
+
export type TrackersProbe = z.output<typeof TrackersProbeSchema>;
|
|
791
|
+
|
|
792
|
+
export const trackersTestRpc = defineRpc({
|
|
793
|
+
name: "office.trackers.test.request",
|
|
794
|
+
input: TrackersProbeSchema,
|
|
795
|
+
output: TrackersResultSchema,
|
|
796
|
+
});
|
|
797
|
+
|
|
615
798
|
/** Closes the named open incidents, or all of them when none are named. Their keys stay seen. */
|
|
616
799
|
export const incidentsDismissRpc = defineRpc({
|
|
617
800
|
name: "office.incidents.dismiss.request",
|
|
@@ -626,6 +809,12 @@ export const chatRpc = defineRpc({
|
|
|
626
809
|
output: ChatResultSchema,
|
|
627
810
|
});
|
|
628
811
|
|
|
812
|
+
export const worldLogoRpc = defineRpc({
|
|
813
|
+
name: "office.world.logo",
|
|
814
|
+
input: z.object({}),
|
|
815
|
+
output: z.object({ url: z.string(), data: z.string().nullable() }).nullable(),
|
|
816
|
+
});
|
|
817
|
+
|
|
629
818
|
/**
|
|
630
819
|
* The script of the page that draws the 3D office: the vendored my-office scene with three.js,
|
|
631
820
|
* one self-contained file. A browser evaluates it in a frame of its own.
|
|
@@ -671,6 +860,11 @@ export const lifeSubscription = defineSubscription({
|
|
|
671
860
|
input: z.object({}),
|
|
672
861
|
event: LifeEventSchema,
|
|
673
862
|
});
|
|
863
|
+
export const homeDepartureRpc = defineRpc({
|
|
864
|
+
name: "office.home.departure",
|
|
865
|
+
input: z.object({ agentId: z.string().min(1), idleSince: z.string().min(1) }),
|
|
866
|
+
output: z.object({ archived: z.boolean() }),
|
|
867
|
+
});
|
|
674
868
|
export const tenureRpc = defineRpc({
|
|
675
869
|
name: "office.tenure.request",
|
|
676
870
|
input: z.object({ op: z.enum(["farewell", "official"]), name: z.string().min(1).max(200) }),
|
package/shared/duties.ts
ADDED
|
@@ -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 {
|
|
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
|
|