paseo-office 0.2.1 → 0.2.3

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.
@@ -0,0 +1,45 @@
1
+ /** A provider's modes, as Paseo lists them. */
2
+ export interface ProviderModes {
3
+ modes?: readonly { id: string; label?: string | null }[] | null;
4
+ defaultModeId?: string | null;
5
+ }
6
+
7
+ export interface WriterModeChoice {
8
+ id: string;
9
+ label: string;
10
+ }
11
+
12
+ // Claude's "Accept File Edits", which a provider extending Claude lists too.
13
+ const ACCEPT_EDITS_MODE = "acceptEdits";
14
+ // A writer that only plans writes nothing, so the mode is not offered.
15
+ const PLAN_MODE = "plan";
16
+
17
+ /** The modes the stand-up writer can be started in: the provider's, less the one that only plans. */
18
+ export function writerModeChoices(provider: ProviderModes): WriterModeChoice[] {
19
+ return (provider.modes ?? [])
20
+ .filter((mode) => mode.id !== PLAN_MODE)
21
+ .map((mode) => ({ id: mode.id, label: mode.label?.trim() || mode.id }));
22
+ }
23
+
24
+ export interface WriterMode {
25
+ /** The mode the writer starts in; absent where the provider names none. */
26
+ modeId?: string;
27
+ /** A mode was asked for and the provider does not offer it. */
28
+ fellBack: boolean;
29
+ }
30
+
31
+ /**
32
+ * The mode the writer starts in. `wanted` is the settings' mode, empty for none: then, and for a
33
+ * mode the provider does not offer, it is the provider's mode that accepts edits, else its
34
+ * default. Codex's and OpenCode's default modes edit in the workspace without asking already.
35
+ */
36
+ export function writerMode(provider: ProviderModes, wanted: string): WriterMode {
37
+ const choices = writerModeChoices(provider);
38
+ const asked = wanted.trim();
39
+ if (asked !== "" && choices.some((mode) => mode.id === asked)) {
40
+ return { modeId: asked, fellBack: false };
41
+ }
42
+ const acceptsEdits = choices.some((mode) => mode.id === ACCEPT_EDITS_MODE);
43
+ const modeId = acceptsEdits ? ACCEPT_EDITS_MODE : (provider.defaultModeId ?? undefined);
44
+ return { ...(modeId ? { modeId } : {}), fellBack: asked !== "" };
45
+ }
@@ -120,9 +120,22 @@ export const WorkspacePullRequestSchema = z.object({
120
120
  });
121
121
  export type WorkspacePullRequest = z.output<typeof WorkspacePullRequestSchema>;
122
122
 
123
+ /**
124
+ * A sub-agent a provider runs inside an agent's own session, as the tool call that started it.
125
+ * It is no Paseo agent: it has no session of its own. `type` is the kind of sub-agent the
126
+ * provider names ("Explore"), never its task.
127
+ */
128
+ export const SubagentCallSchema = z.object({ id: z.string(), type: z.string() });
129
+ export type SubagentCall = z.output<typeof SubagentCallSchema>;
130
+ export const SubagentCallsSchema = z.record(z.string(), z.array(SubagentCallSchema));
131
+ export type SubagentCalls = z.output<typeof SubagentCallsSchema>;
132
+
123
133
  export const OfficeWorkspaceSchema = z.object({
124
134
  id: z.string(),
135
+ /** The name its team goes by: the office's own when the owner gave one, else the workspace's. */
125
136
  name: z.string(),
137
+ /** The workspace's own name in Paseo; present only while the team goes by another. */
138
+ workspaceName: z.string().optional(),
126
139
  projectName: z.string(),
127
140
  branch: z.string().optional(),
128
141
  ticket: WorkspaceTicketSchema.optional(),
@@ -268,14 +281,32 @@ export const IncidentSchema = z.object({
268
281
  });
269
282
  export type Incident = z.output<typeof IncidentSchema>;
270
283
 
284
+ /** Where a tracker's sign-in is: saved from the settings, in the daemon's environment, or nowhere. */
285
+ export const TRACKER_SOURCES = ["saved", "env", "none"] as const;
286
+ export type TrackerSource = (typeof TRACKER_SOURCES)[number];
287
+
271
288
  /** The open incidents, and what keeps a tracker from being checked. */
272
289
  export const IncidentsStateSchema = z.object({
273
290
  open: z.array(IncidentSchema),
274
291
  /** Why a tracker's last check failed; absent once one succeeds. */
275
292
  problems: z.object({ jira: z.string().optional(), sentry: z.string().optional() }),
276
- /** The tracker's token variables are set on the host. Never the values. */
293
+ /** The tracker has a sign-in on the host, saved or in its environment. Never the values. */
277
294
  jiraReady: z.boolean(),
278
295
  sentryReady: z.boolean(),
296
+ /**
297
+ * Where each tracker's sign-in comes from, and Jira's address and email. Never a token. Absent
298
+ * from a server older than the settings' connections.
299
+ */
300
+ connections: z
301
+ .object({
302
+ jira: z.object({
303
+ source: z.enum(TRACKER_SOURCES),
304
+ baseUrl: z.string(),
305
+ email: z.string(),
306
+ }),
307
+ sentry: z.object({ source: z.enum(TRACKER_SOURCES) }),
308
+ })
309
+ .optional(),
279
310
  /** Why the check's schedule could not follow the settings; null once it does. */
280
311
  scheduleError: z.string().nullable(),
281
312
  });
@@ -450,6 +481,8 @@ export const OfficeSnapshotSchema = z.object({
450
481
  activity: z.record(z.string(), z.string()),
451
482
  /** The step of each running agent: the tool call it is at, or made since the read before. */
452
483
  doing: z.record(z.string(), ActivityStepSchema).optional(),
484
+ /** The provider's own sub-agents each running agent has at work now; absent from an older server. */
485
+ subagents: SubagentCallsSchema.optional(),
453
486
  /** Each agent's own checklist, kept after the agent stops. */
454
487
  checklists: ChecklistsSchema.optional(),
455
488
  checklistProgress: ChecklistCountsSchema.optional(),
@@ -475,6 +508,7 @@ export const OfficeEventSchema = z.discriminatedUnion("type", [
475
508
  type: z.literal("activity"),
476
509
  activity: z.record(z.string(), z.string()),
477
510
  doing: z.record(z.string(), ActivityStepSchema).optional(),
511
+ subagents: SubagentCallsSchema.optional(),
478
512
  checklists: ChecklistsSchema.optional(),
479
513
  checklistProgress: ChecklistCountsSchema.optional(),
480
514
  }),
@@ -732,6 +766,89 @@ export const notesWriteRpc = defineRpc({
732
766
  output: z.object({ started: z.boolean() }),
733
767
  });
734
768
 
769
+ /**
770
+ * Gives a workspace's team a name of the office's own, kept on the workspace; an empty name goes
771
+ * back to the workspace's. The team's tenure follows the name.
772
+ */
773
+ export const teamRenameRpc = defineRpc({
774
+ name: "office.team.rename.request",
775
+ input: z.object({ workspaceId: z.string().min(1), name: z.string().max(200) }),
776
+ output: z.union([
777
+ z.object({ ok: z.literal(true), name: z.string() }),
778
+ z.object({ ok: z.literal(false), problem: z.string() }),
779
+ ]),
780
+ });
781
+
782
+ export const WriterModesSchema = z.object({
783
+ /** The provider the writer would start on now, by its label. */
784
+ provider: z.string(),
785
+ /** Its modes the writer can start in, by the provider's own names. */
786
+ modes: z.array(z.object({ id: z.string(), label: z.string() })),
787
+ /** The mode the settings come to; null where the provider names none. */
788
+ modeId: z.string().nullable(),
789
+ /** The settings name a mode this provider does not offer. */
790
+ fellBack: z.boolean(),
791
+ });
792
+ export type WriterModes = z.output<typeof WriterModesSchema>;
793
+
794
+ /**
795
+ * The modes the stand-up writer can start in, for the settings. `problem` when no provider is
796
+ * ready or the settings cannot be read.
797
+ */
798
+ export const notesModesRpc = defineRpc({
799
+ name: "office.notes.modes.request",
800
+ input: z.object({}),
801
+ output: z.union([
802
+ WriterModesSchema.extend({ ok: z.literal(true) }),
803
+ z.object({ ok: z.literal(false), problem: z.string() }),
804
+ ]),
805
+ });
806
+
807
+ const JiraConnectionSchema = z.object({
808
+ baseUrl: z.string().max(500),
809
+ email: z.string().max(320),
810
+ /** Empty for the token already saved. */
811
+ token: z.string().max(4000),
812
+ });
813
+ const SentryConnectionSchema = z.object({ token: z.string().max(4000) });
814
+
815
+ export const TrackersChangeSchema = z.discriminatedUnion("action", [
816
+ JiraConnectionSchema.extend({ action: z.literal("save-jira") }),
817
+ SentryConnectionSchema.extend({ action: z.literal("save-sentry") }),
818
+ z.object({ action: z.literal("clear"), tracker: z.enum(INCIDENT_SOURCES) }),
819
+ ]);
820
+ export type TrackersChange = z.output<typeof TrackersChangeSchema>;
821
+
822
+ /** `problem` is why it failed, in words safe to show: never a token. */
823
+ export const TrackersResultSchema = z.union([
824
+ z.object({ ok: z.literal(true) }),
825
+ z.object({ ok: z.literal(false), problem: z.string() }),
826
+ ]);
827
+ export type TrackersResult = z.output<typeof TrackersResultSchema>;
828
+
829
+ /**
830
+ * Saves or clears a tracker's connection on the host, in a file only the daemon's user can read.
831
+ * The token is never sent back; the office's state names where each sign-in comes from.
832
+ */
833
+ export const trackersSaveRpc = defineRpc({
834
+ name: "office.trackers.save.request",
835
+ input: TrackersChangeSchema,
836
+ output: TrackersResultSchema,
837
+ });
838
+
839
+ /** One signed-in request to the tracker with the connection as typed; nothing is saved. */
840
+ const TrackersProbeSchema = z.discriminatedUnion("tracker", [
841
+ JiraConnectionSchema.extend({ tracker: z.literal("jira") }),
842
+ SentryConnectionSchema.extend({ tracker: z.literal("sentry") }),
843
+ ]);
844
+ export type TrackersProbe = z.output<typeof TrackersProbeSchema>;
845
+
846
+ export const trackersTestRpc = defineRpc({
847
+ name: "office.trackers.test.request",
848
+ input: TrackersProbeSchema,
849
+ output: TrackersResultSchema,
850
+ });
851
+
735
852
  /** Closes the named open incidents, or all of them when none are named. Their keys stay seen. */
736
853
  export const incidentsDismissRpc = defineRpc({
737
854
  name: "office.incidents.dismiss.request",
package/shared/model.ts CHANGED
@@ -7,6 +7,8 @@ import type {
7
7
  OfficeSnapshot,
8
8
  OfficeWorkspace,
9
9
  Post,
10
+ SubagentCall,
11
+ SubagentCalls,
10
12
  } from "./contracts.js";
11
13
  import { dutyRows, type DutyRow } from "./duties.js";
12
14
  import { DUTY, LOBBY } from "./names.js";
@@ -26,6 +28,11 @@ export interface OfficeRow {
26
28
  * them, so it is not idle. 0 for everyone else.
27
29
  */
28
30
  waitingOn: number;
31
+ /**
32
+ * The provider's own sub-agents a running agent has at work, inside its session. They are no
33
+ * agents of the office: only the 3D floor draws them. Absent for an agent with none.
34
+ */
35
+ subagents?: readonly SubagentCall[];
29
36
  }
30
37
 
31
38
  export interface OfficeRoom {
@@ -170,6 +177,7 @@ function orderRows(
170
177
  activity: Readonly<Record<string, string>>,
171
178
  doing: Readonly<Record<string, ActivityStep>>,
172
179
  waitingOn: ReadonlyMap<string, number>,
180
+ subagents: Readonly<SubagentCalls> = {},
173
181
  ): OfficeRow[] {
174
182
  const sorted = [...agents].sort(byCreation);
175
183
  const ids = new Set(sorted.map((agent) => agent.id));
@@ -195,6 +203,7 @@ function orderRows(
195
203
  activity: running ? (activity[agent.id] ?? null) : null,
196
204
  step: running ? (doing[agent.id] ?? null) : null,
197
205
  waitingOn: waitingOn.get(agent.id) ?? 0,
206
+ ...(running && subagents[agent.id]?.length ? { subagents: subagents[agent.id] } : {}),
198
207
  });
199
208
  for (const child of children.get(agent.id) ?? []) visit(child, 1);
200
209
  }
@@ -280,7 +289,13 @@ export function buildOfficeModel(state: OfficeSnapshot): OfficeModel {
280
289
  subtitle,
281
290
  lobby,
282
291
  workspace,
283
- rows: orderRows(byRoom.get(id) ?? [], state.activity, state.doing ?? {}, waitingOn),
292
+ rows: orderRows(
293
+ byRoom.get(id) ?? [],
294
+ state.activity,
295
+ state.doing ?? {},
296
+ waitingOn,
297
+ state.subagents,
298
+ ),
284
299
  posts: visiblePosts(posts),
285
300
  todos,
286
301
  };
@@ -52,6 +52,7 @@ const HostValuesSchema = z.object({
52
52
  agentTools: z.boolean().default(true),
53
53
  notesFolder: z.string().default(""),
54
54
  notesTimeZone: z.string().default(""),
55
+ notesMode: z.string().max(100).default(""),
55
56
  notesDays: z
56
57
  .array(z.number())
57
58
  .default([1, 2, 3, 4, 5])
@@ -117,7 +118,8 @@ const SUNDAY_TO_THURSDAY = [0, 1, 2, 3, 4];
117
118
  /**
118
119
  * Host-wide. `agentTools` off removes the office tools from agent sessions opened afterwards.
119
120
  * `notesFolder` is the absolute path the stand-up notes are written in, empty for none, and
120
- * `notesTimeZone` the IANA zone of their 8:00 run, empty for the host's. `notesDays` are the
121
+ * `notesTimeZone` the IANA zone of their 8:00 run, empty for the host's. `notesMode` is the
122
+ * mode the notes writer starts in, by its provider's id, empty for the office's own choice. `notesDays` are the
121
123
  * weekdays of that run, 0 for Sunday to 6 for Saturday, in order; none is no run. `floorPlan` is
122
124
  * the 3D floor's plan: `pro` the company floor, `cozy` one open room, or `hq` headquarters. `jiraProjects`
123
125
  * and `sentryProjects` are the comma separated projects checked for incidents, `sentryOrg` their
@@ -0,0 +1,23 @@
1
+ /** On a workspace: the office's own name for its team. Paseo never reads the key. */
2
+ export const TEAM_NAME_KEY = "office.team.name";
3
+ export const TEAM_NAME_MAX = 40;
4
+
5
+ /** A team name as it is kept: one line, trimmed, at most TEAM_NAME_MAX characters; "" for none. */
6
+ export function tidyTeamName(name: string): string {
7
+ return name.replace(/\s+/g, " ").trim().slice(0, TEAM_NAME_MAX);
8
+ }
9
+
10
+ /** The team name stored on a workspace, or null when it has none. */
11
+ export function storedTeamName(metadata: Readonly<Record<string, unknown>> | null | undefined) {
12
+ const stored = metadata?.[TEAM_NAME_KEY];
13
+ const name = typeof stored === "string" ? tidyTeamName(stored) : "";
14
+ return name === "" ? null : name;
15
+ }
16
+
17
+ /** The name a workspace's team goes by: the office's own, else the workspace's. */
18
+ export function teamNameOf(workspace: {
19
+ name: string;
20
+ metadata?: Readonly<Record<string, unknown>> | null;
21
+ }): string {
22
+ return storedTeamName(workspace.metadata) ?? workspace.name;
23
+ }