paseo-office 0.2.2 → 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.
- package/client/host-switches.tsx +17 -0
- package/client/notes-mode-row.tsx +140 -0
- package/client/office-state.ts +1 -0
- package/client/structure-view.tsx +2 -0
- package/client/team-name.tsx +81 -0
- package/client/world/adapter.ts +34 -1
- package/client/world/world-api.ts +12 -1
- package/docs/office.md +36 -2
- package/index.server.ts +35 -1
- package/package.json +1 -1
- package/server/activity.ts +40 -3
- package/server/directory.ts +5 -1
- package/server/hub.ts +9 -0
- package/server/life-feed.ts +13 -0
- package/server/live-ports.ts +30 -11
- package/server/notes-schedule.ts +2 -0
- package/server/notes-writer.ts +9 -1
- package/server/tenure.ts +10 -0
- package/server/world.generated.ts +1 -1
- package/server/writer-mode.ts +45 -0
- package/shared/contracts.ts +54 -0
- package/shared/model.ts +16 -1
- package/shared/settings.ts +3 -1
- package/shared/team-name.ts +23 -0
package/server/hub.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
OfficeSnapshot,
|
|
13
13
|
OfficeWorkspace,
|
|
14
14
|
Post,
|
|
15
|
+
SubagentCalls,
|
|
15
16
|
WakeState,
|
|
16
17
|
WorkspaceScript,
|
|
17
18
|
} from "../shared/contracts.js";
|
|
@@ -54,6 +55,7 @@ export interface HubPorts {
|
|
|
54
55
|
doing: ActivitySteps,
|
|
55
56
|
checklists: Readonly<Checklists>,
|
|
56
57
|
progress?: Readonly<ChecklistCounts>,
|
|
58
|
+
subagents?: Readonly<SubagentCalls>,
|
|
57
59
|
) => void,
|
|
58
60
|
): () => void;
|
|
59
61
|
timers: Timers;
|
|
@@ -138,6 +140,8 @@ export function createHub(ports: HubPorts): Hub {
|
|
|
138
140
|
// Kept after an agent stops, as the poller reads only running agents; dropped when it leaves.
|
|
139
141
|
let checklists: Checklists = {};
|
|
140
142
|
let checklistProgress: ChecklistCounts = {};
|
|
143
|
+
/** The provider's own sub-agents each running agent has at work, as the last round read them. */
|
|
144
|
+
let subagents: Readonly<SubagentCalls> = {};
|
|
141
145
|
let boards: Record<string, readonly Post[]> = {};
|
|
142
146
|
let wake: WakeState = { paused: false, queued: {} };
|
|
143
147
|
let notes: NotesState | null = null;
|
|
@@ -168,6 +172,7 @@ export function createHub(ports: HubPorts): Hub {
|
|
|
168
172
|
workspaces: [...view.workspaces],
|
|
169
173
|
activity: { ...activity },
|
|
170
174
|
doing: { ...doing },
|
|
175
|
+
...(Object.keys(subagents).length ? { subagents: { ...subagents } } : {}),
|
|
171
176
|
checklists: { ...checklists },
|
|
172
177
|
...(Object.keys(checklistProgress).length
|
|
173
178
|
? { checklistProgress: { ...checklistProgress } }
|
|
@@ -285,6 +290,7 @@ export function createHub(ports: HubPorts): Hub {
|
|
|
285
290
|
type: "activity",
|
|
286
291
|
activity: { ...activity },
|
|
287
292
|
doing: { ...doing },
|
|
293
|
+
...(Object.keys(subagents).length ? { subagents: { ...subagents } } : {}),
|
|
288
294
|
checklists: { ...checklists },
|
|
289
295
|
...(Object.keys(checklistProgress).length
|
|
290
296
|
? { checklistProgress: { ...checklistProgress } }
|
|
@@ -335,9 +341,11 @@ export function createHub(ports: HubPorts): Hub {
|
|
|
335
341
|
steps: ActivitySteps,
|
|
336
342
|
report: Readonly<Checklists>,
|
|
337
343
|
progress: Readonly<ChecklistCounts> = {},
|
|
344
|
+
working: Readonly<SubagentCalls> = {},
|
|
338
345
|
): void {
|
|
339
346
|
activity = next;
|
|
340
347
|
doing = steps;
|
|
348
|
+
subagents = working;
|
|
341
349
|
const listed = new Set(view.agents.map((agent) => agent.id));
|
|
342
350
|
const fresh = Object.entries(report).filter(([agentId]) => listed.has(agentId));
|
|
343
351
|
const merged = Object.entries({ ...checklists, ...Object.fromEntries(fresh) });
|
|
@@ -444,6 +452,7 @@ export function createHub(ports: HubPorts): Hub {
|
|
|
444
452
|
doing = {};
|
|
445
453
|
checklists = {};
|
|
446
454
|
checklistProgress = {};
|
|
455
|
+
subagents = {};
|
|
447
456
|
const stop = stopDirectory;
|
|
448
457
|
stopDirectory = null;
|
|
449
458
|
view = EMPTY_VIEW;
|
package/server/life-feed.ts
CHANGED
|
@@ -17,6 +17,8 @@ export function createLifeFeed(deps: {
|
|
|
17
17
|
const pending = new Map<string, Promise<void>>();
|
|
18
18
|
const folderTeams = new Map<string, Set<string>>();
|
|
19
19
|
let connected = false;
|
|
20
|
+
/** The name each workspace went by at the last view, to tell a rename. */
|
|
21
|
+
const shown = new Map<string, string>();
|
|
20
22
|
let queuedAge = Promise.resolve();
|
|
21
23
|
function snapshot(): Snapshot {
|
|
22
24
|
const born = new Map<string, string>();
|
|
@@ -84,6 +86,13 @@ export function createLifeFeed(deps: {
|
|
|
84
86
|
return;
|
|
85
87
|
}
|
|
86
88
|
const names = new Map(view.workspaces.map((w) => [w.id, w.name]));
|
|
89
|
+
// A workspace that goes by another name since the last view is the same team: its tenure
|
|
90
|
+
// goes with it, so a rename makes nobody an intern again.
|
|
91
|
+
for (const [id, name] of names) {
|
|
92
|
+
const before = shown.get(id);
|
|
93
|
+
if (before !== undefined && before !== name) deps.tenure.rename(before, name);
|
|
94
|
+
shown.set(id, name);
|
|
95
|
+
}
|
|
87
96
|
const at = deps.now();
|
|
88
97
|
const today = new Date(at).toDateString();
|
|
89
98
|
const seeds = new Map(
|
|
@@ -123,6 +132,10 @@ export function createLifeFeed(deps: {
|
|
|
123
132
|
readFolders(view, names);
|
|
124
133
|
changed();
|
|
125
134
|
},
|
|
135
|
+
/** A team now goes by `to`: its tenure goes with it, before the directory says so. */
|
|
136
|
+
renamed(from: string, to: string) {
|
|
137
|
+
if (deps.tenure.rename(from, to)) changed();
|
|
138
|
+
},
|
|
126
139
|
async turnEnded(id: string, lookup?: () => Promise<string | null>) {
|
|
127
140
|
const name = teams.get(id) ?? (await lookup?.());
|
|
128
141
|
if (name) {
|
package/server/live-ports.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
type ChatServicePorts,
|
|
8
8
|
} from "./chat-service.js";
|
|
9
9
|
import { PARENT_AGENT_ID_LABEL } from "./directory.js";
|
|
10
|
+
import { writerMode, writerModeChoices } from "./writer-mode.js";
|
|
11
|
+
import type { WriterModes } from "../shared/contracts.js";
|
|
10
12
|
import type { Hub, HubPorts } from "./hub.js";
|
|
11
13
|
import type { JanitorPorts } from "./janitor.js";
|
|
12
14
|
import { wakeTargetOf } from "./mention-queue.js";
|
|
@@ -250,28 +252,45 @@ export function liveScriptLogPorts(
|
|
|
250
252
|
|
|
251
253
|
type AgentConfig = Parameters<Paseo["agents"]["create"]>[0]["config"];
|
|
252
254
|
|
|
253
|
-
// Claude's "Accept File Edits", which a provider extending Claude lists too. The owner's call:
|
|
254
|
-
// nobody watches the 8:00 writer, so it edits the notes without asking.
|
|
255
|
-
const ACCEPT_EDITS_MODE = "acceptEdits";
|
|
256
|
-
|
|
257
255
|
/**
|
|
258
256
|
* The host's default provider, as the host can tell it. The app's new-agent form starts from the
|
|
259
257
|
* provider the device chose last, which the host never sees; so this takes the first enabled,
|
|
260
258
|
* ready provider in the daemon's order, with the model the form gives that provider: its default
|
|
261
|
-
* (else its first selectable one). The mode is
|
|
262
|
-
*
|
|
259
|
+
* (else its first selectable one). The mode is `writerMode`'s: the settings' where the provider
|
|
260
|
+
* offers it, else the one that accepts edits, else the provider's default. Nobody watches the
|
|
261
|
+
* 8:00 writer, so by default it edits the notes without asking.
|
|
263
262
|
*/
|
|
264
|
-
async function
|
|
263
|
+
async function writerProvider(paseo: Paseo, cwd: string) {
|
|
265
264
|
const { entries } = await paseo.providers.waitForReady({ cwd });
|
|
266
265
|
const entry = entries.find((candidate) => candidate.enabled && candidate.status === "ready");
|
|
267
266
|
if (entry === undefined) throw new Error("No agent provider is ready on this host");
|
|
267
|
+
return entry;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The provider the writer would start on now, its modes, and the one `wanted` comes to. */
|
|
271
|
+
export async function readWriterModes(
|
|
272
|
+
holder: PaseoHolder,
|
|
273
|
+
cwd: string,
|
|
274
|
+
wanted: string,
|
|
275
|
+
): Promise<WriterModes> {
|
|
276
|
+
const entry = await writerProvider(holder.require(), cwd);
|
|
277
|
+
const { modeId, fellBack } = writerMode(entry, wanted);
|
|
278
|
+
return {
|
|
279
|
+
provider: entry.label ?? entry.provider,
|
|
280
|
+
modes: writerModeChoices(entry),
|
|
281
|
+
modeId: modeId ?? null,
|
|
282
|
+
fellBack,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async function defaultAgentConfig(paseo: Paseo, cwd: string, wanted: string): Promise<AgentConfig> {
|
|
287
|
+
const entry = await writerProvider(paseo, cwd);
|
|
268
288
|
const models = (entry.models ?? []).filter((model) => model.isSelectable !== false);
|
|
269
289
|
const model = models.find((candidate) => candidate.isDefault) ?? models[0];
|
|
270
290
|
if (model === undefined) {
|
|
271
291
|
throw new Error(`The provider ${entry.label ?? entry.provider} offers no model`);
|
|
272
292
|
}
|
|
273
|
-
const
|
|
274
|
-
const modeId = acceptsEdits ? ACCEPT_EDITS_MODE : entry.defaultModeId;
|
|
293
|
+
const { modeId } = writerMode(entry, wanted);
|
|
275
294
|
return {
|
|
276
295
|
provider: `${entry.provider}/${model.id}`,
|
|
277
296
|
...(modeId ? { modeId } : {}),
|
|
@@ -290,9 +309,9 @@ export function liveNotesPorts(
|
|
|
290
309
|
(found) => found.isDirectory(),
|
|
291
310
|
() => false,
|
|
292
311
|
),
|
|
293
|
-
async startAgent({ cwd, title, prompt }) {
|
|
312
|
+
async startAgent({ cwd, title, prompt, mode }) {
|
|
294
313
|
const paseo = holder.require();
|
|
295
|
-
const config = await defaultAgentConfig(paseo, cwd);
|
|
314
|
+
const config = await defaultAgentConfig(paseo, cwd, mode ?? "");
|
|
296
315
|
const workspace = await paseo.workspaces.open(cwd);
|
|
297
316
|
const agent = await workspace.agents.create({ config, title, prompt });
|
|
298
317
|
return agent.id;
|
package/server/notes-schedule.ts
CHANGED
|
@@ -9,6 +9,8 @@ const NOTES: OfficeSchedule = { name: NOTES_SCHEDULE, label: "Stand-up notes", l
|
|
|
9
9
|
export interface NotesSettings {
|
|
10
10
|
notesFolder: string;
|
|
11
11
|
notesTimeZone: string;
|
|
12
|
+
/** The mode the writer starts in, by the provider's id; empty or absent for the office's choice. */
|
|
13
|
+
notesMode?: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/** What the 8:00 run follows: the folder and zone, and its weekdays, 0 for Sunday. */
|
package/server/notes-writer.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface WriterStart {
|
|
|
48
48
|
cwd: string;
|
|
49
49
|
title: string;
|
|
50
50
|
prompt: string;
|
|
51
|
+
/** The settings' mode for the writer; absent when none is set. */
|
|
52
|
+
mode?: string;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
export interface NotesPorts {
|
|
@@ -219,7 +221,13 @@ export function createNotesWriter(ports: NotesPorts): NotesWriter {
|
|
|
219
221
|
report: standupReport(await ports.snapshot(), now),
|
|
220
222
|
});
|
|
221
223
|
endedWhileStarting = new Map();
|
|
222
|
-
const
|
|
224
|
+
const mode = settings.notesMode?.trim() ?? "";
|
|
225
|
+
const writerId = await ports.startAgent({
|
|
226
|
+
cwd: folder,
|
|
227
|
+
title: NOTES_WRITER_TITLE,
|
|
228
|
+
prompt,
|
|
229
|
+
...(mode === "" ? {} : { mode }),
|
|
230
|
+
});
|
|
223
231
|
return { writerId, entry: { folder, ...day } };
|
|
224
232
|
}
|
|
225
233
|
|
package/server/tenure.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface Tenure {
|
|
|
55
55
|
list(live: ReadonlySet<string>): TenureProject[];
|
|
56
56
|
seed(teams: readonly SeedTeam[]): void;
|
|
57
57
|
get(team: string): TenureEntry | null;
|
|
58
|
+
/** A team that goes by another name keeps its entry; false when it has none or `to` is taken. */
|
|
59
|
+
rename(from: string, to: string): boolean;
|
|
58
60
|
/** True once seed() has run on this ledger, now or on an earlier start. */
|
|
59
61
|
seeded(): boolean;
|
|
60
62
|
}
|
|
@@ -94,6 +96,14 @@ export function createTenure(deps: { store: TenureStore; now?: () => number }):
|
|
|
94
96
|
return {
|
|
95
97
|
seeded: () => ledger.seeded,
|
|
96
98
|
get: (team) => projects[team] ?? null,
|
|
99
|
+
rename(from, to) {
|
|
100
|
+
const entry = projects[from];
|
|
101
|
+
if (!entry || !to || from === to || projects[to]) return false;
|
|
102
|
+
projects[to] = entry;
|
|
103
|
+
delete projects[from];
|
|
104
|
+
save();
|
|
105
|
+
return true;
|
|
106
|
+
},
|
|
97
107
|
seed(teams) {
|
|
98
108
|
if (ledger.seeded) return;
|
|
99
109
|
const at = now();
|