@getpaseo/server 0.17.0 → 0.17.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 (34) hide show
  1. package/dist/server/builtin-plugins/antigravity-provider/server/usage.ts +22 -12
  2. package/dist/server/builtin-plugins/package.json +1 -1
  3. package/dist/server/server/agent/agent-manager.d.ts +10 -1
  4. package/dist/server/server/agent/agent-manager.js +22 -5
  5. package/dist/server/server/agent/agent-messages/delivery.d.ts +43 -5
  6. package/dist/server/server/agent/agent-messages/delivery.js +386 -213
  7. package/dist/server/server/agent/agent-messages/envelope.d.ts +8 -0
  8. package/dist/server/server/agent/agent-messages/envelope.js +8 -1
  9. package/dist/server/server/agent/agent-prompt.d.ts +9 -2
  10. package/dist/server/server/agent/agent-prompt.js +21 -10
  11. package/dist/server/server/agent/host-operations/index.js +1 -1
  12. package/dist/server/server/agent/providers/codex-app-server-agent.js +5 -1
  13. package/dist/server/server/agent/tools/paseo-tools.js +6 -5
  14. package/dist/server/server/bootstrap.js +43 -26
  15. package/dist/server/server/session/checkout/checkout-session.d.ts +3 -1
  16. package/dist/server/server/session/checkout/checkout-session.js +2 -2
  17. package/dist/server/server/session.d.ts +3 -2
  18. package/dist/server/server/session.js +29 -22
  19. package/dist/server/server/websocket-server.d.ts +1 -0
  20. package/dist/server/server/websocket-server.js +14 -0
  21. package/dist/server/server/workspace-archive-operations.d.ts +4 -0
  22. package/dist/server/server/workspace-archive-operations.js +24 -0
  23. package/dist/server/server/workspace-directory.d.ts +1 -3
  24. package/dist/server/server/workspace-directory.js +1 -12
  25. package/dist/server/skills/paseo/SKILL.md +1 -1
  26. package/dist/server/web-ui/_expo/static/js/web/{index-9e9b3c5827a186678679c43439d3998a.js → index-12cbb5f1badfbe448300b289565efbeb.js} +42 -42
  27. package/dist/server/web-ui/_expo/static/js/web/index-12cbb5f1badfbe448300b289565efbeb.js.br +0 -0
  28. package/dist/server/web-ui/_expo/static/js/web/index-12cbb5f1badfbe448300b289565efbeb.js.gz +0 -0
  29. package/dist/server/web-ui/index.html +1 -1
  30. package/dist/server/web-ui/index.html.br +0 -0
  31. package/dist/server/web-ui/index.html.gz +0 -0
  32. package/package.json +6 -6
  33. package/dist/server/web-ui/_expo/static/js/web/index-9e9b3c5827a186678679c43439d3998a.js.br +0 -0
  34. package/dist/server/web-ui/_expo/static/js/web/index-9e9b3c5827a186678679c43439d3998a.js.gz +0 -0
@@ -34,6 +34,14 @@ export declare function prepareAgentMessage(prompt: AgentPromptInput, source?: A
34
34
  prompt: AgentPromptInput;
35
35
  messageId?: string;
36
36
  };
37
+ /**
38
+ * Wrap a prompt in its envelope unconditionally. A person's prompt (`source` null) needs one
39
+ * only when it is quoted or shares a provider prompt with agent messages.
40
+ */
41
+ export declare function envelopeMessage(prompt: AgentPromptInput, source: AgentPromptSource | null, id?: string): {
42
+ prompt: AgentPromptInput;
43
+ messageId: string;
44
+ };
37
45
  /** The same projection owns provider echoes, acceptance, import, and replay. */
38
46
  export declare function projectAgentMessages(item: AgentTimelineItem): AgentTimelineItem[];
39
47
  /**
@@ -130,11 +130,18 @@ export function prepareAgentMessage(prompt, source, id) {
130
130
  return { prompt, messageId: id };
131
131
  }
132
132
  }
133
+ return envelopeMessage(prompt, source ?? null, id);
134
+ }
135
+ /**
136
+ * Wrap a prompt in its envelope unconditionally. A person's prompt (`source` null) needs one
137
+ * only when it is quoted or shares a provider prompt with agent messages.
138
+ */
139
+ export function envelopeMessage(prompt, source, id) {
133
140
  const messageId = id ?? randomUUID();
134
141
  const text = typeof prompt === "string" ? prompt : prompt.flatMap(renderMessageText).join("\n\n");
135
142
  // Render textual attachments before wrapping, so provider replay still contains one
136
143
  // complete envelope instead of an envelope followed by provider-rendered context.
137
- const envelope = formatAgentMessage({ id: messageId, source: source ?? null, text });
144
+ const envelope = formatAgentMessage({ id: messageId, source, text });
138
145
  return {
139
146
  messageId,
140
147
  prompt: typeof prompt === "string"
@@ -1,4 +1,4 @@
1
- import { type AgentPromptSource } from "./agent-messages/index.js";
1
+ import { type AgentMessageDelivery, type AgentPromptSource } from "./agent-messages/index.js";
2
2
  import type { Logger } from "pino";
3
3
  import type { AgentPromptInput, AgentRunOptions } from "./agent-sdk-types.js";
4
4
  import type { AgentManager, ManagedAgent } from "./agent-manager.js";
@@ -66,6 +66,10 @@ export interface SendPromptToAgentParams {
66
66
  clearPendingPermissions?: boolean;
67
67
  logger: Logger;
68
68
  }
69
+ /** A prompt that does not wait its turn. Messages queued for the agent go with it. */
70
+ export interface SendDirectPromptParams extends SendPromptToAgentParams {
71
+ agentMessages: Pick<AgentMessageDelivery, "sendDirect">;
72
+ }
69
73
  export interface StartCreatedAgentInitialPromptParams {
70
74
  agentStorage: AgentStorage;
71
75
  agentManager: AgentManager;
@@ -85,10 +89,13 @@ export declare function waitForAgentRunStartWithTimeout(agentManager: Pick<Agent
85
89
  * chat mentions, notify-on-finish) MUST go through this so behavior can never
86
90
  * drift between them.
87
91
  *
92
+ * The prompt does not wait in the agent's message queue, and it does not jump it either:
93
+ * messages already queued for the agent are delivered ahead of it in the same provider prompt.
94
+ *
88
95
  * When `unarchive` is false and the agent is archived, the call is a silent
89
96
  * no-op (returns the normal turn-start disposition) — the agent is not run.
90
97
  */
91
- export declare function sendPromptToAgent(params: SendPromptToAgentParams): Promise<PromptDispatchResult>;
98
+ export declare function sendPromptToAgent(params: SendDirectPromptParams): Promise<PromptDispatchResult>;
92
99
  /** Dispatch daemon-prepared context without reclassifying it as human input. */
93
100
  export declare function sendPreparedPromptToAgent(params: Omit<SendPromptToAgentParams, "source" | "messageId">): Promise<PromptDispatchResult>;
94
101
  export declare function startCreatedAgentInitialPrompt(params: StartCreatedAgentInitialPromptParams): Promise<ManagedAgent>;
@@ -1,4 +1,4 @@
1
- import { prepareAgentMessage } from "./agent-messages/index.js";
1
+ import { prepareAgentMessage, } from "./agent-messages/index.js";
2
2
  import { ForegroundPromptStart } from "./agent-run-state.js";
3
3
  import { ensureAgentLoaded } from "./agent-loading.js";
4
4
  import { isStaleProviderSessionError } from "./stale-provider-session-error.js";
@@ -203,19 +203,30 @@ async function resolvePromptSource(source, manager, storage) {
203
203
  * chat mentions, notify-on-finish) MUST go through this so behavior can never
204
204
  * drift between them.
205
205
  *
206
+ * The prompt does not wait in the agent's message queue, and it does not jump it either:
207
+ * messages already queued for the agent are delivered ahead of it in the same provider prompt.
208
+ *
206
209
  * When `unarchive` is false and the agent is archived, the call is a silent
207
210
  * no-op (returns the normal turn-start disposition) — the agent is not run.
208
211
  */
209
212
  export async function sendPromptToAgent(params) {
210
- const source = await resolvePromptSource(params.source, params.agentManager, params.agentStorage);
211
- const delivery = prepareAgentMessage(params.prompt, source, params.messageId);
212
- return sendPreparedPromptToAgent({
213
- ...params,
214
- prompt: delivery.prompt,
215
- runOptions: delivery.messageId
216
- ? { ...params.runOptions, clientMessageId: delivery.messageId }
217
- : params.runOptions,
218
- });
213
+ const { agentMessages, source, messageId, ...send } = params;
214
+ return agentMessages.sendDirect({
215
+ recipientId: params.agentId,
216
+ prompt: params.prompt,
217
+ source: await resolvePromptSource(source, params.agentManager, params.agentStorage),
218
+ messageId,
219
+ sessionMode: params.sessionMode,
220
+ unarchive: params.unarchive,
221
+ }, (joined) => sendPreparedPromptToAgent({
222
+ ...send,
223
+ prompt: joined.prompt,
224
+ sessionMode: joined.sessionMode,
225
+ unarchive: joined.unarchive,
226
+ runOptions: joined.messageId
227
+ ? { ...send.runOptions, clientMessageId: joined.messageId }
228
+ : send.runOptions,
229
+ }));
219
230
  }
220
231
  /** Dispatch daemon-prepared context without reclassifying it as human input. */
221
232
  export async function sendPreparedPromptToAgent(params) {
@@ -238,7 +238,7 @@ export function createHostResolver(input) {
238
238
  ...receipt,
239
239
  status: agent.status,
240
240
  guidance: receipt.deliveryStatus === "queued"
241
- ? "Queued for delivery after two quiet seconds and the current turn ends, unless interrupt was requested. You will get notified when the prompted agent finishes, errors, or needs permission unless notifyOnFinish is false."
241
+ ? "Queued for delivery after two quiet seconds and the current turn ends. An interrupt replaces the turn now, after the messages queued before it. You will get notified when the prompted agent finishes, errors, or needs permission unless notifyOnFinish is false."
242
242
  : "Dispatch acknowledged. Observe completion using get_agent_status/get_agent_activity or SDK/RPC subscriptions and wait APIs.",
243
243
  });
244
244
  },
@@ -3368,7 +3368,11 @@ export class CodexAppServerAgentSession {
3368
3368
  if (!this.client || !this.currentThreadId)
3369
3369
  return;
3370
3370
  // Paseo reads history only when it replays it; the resume response needs no turns.
3371
- const params = { threadId: this.currentThreadId, excludeTurns: true };
3371
+ const params = {
3372
+ threadId: this.currentThreadId,
3373
+ cwd: this.config.cwd ?? null,
3374
+ excludeTurns: true,
3375
+ };
3372
3376
  if (this.deps.customCodexConfig) {
3373
3377
  // Resume otherwise prefers the provider stored on the thread, including
3374
3378
  // the unnamespaced key emitted by earlier Paseo versions.
@@ -918,7 +918,7 @@ function createToolCatalog(options, scope) {
918
918
  .object(legacyTopLevelCreateAgentInputSchema)
919
919
  .strict();
920
920
  const commonSendAgentPromptInputSchema = {
921
- activeTurnBehavior: ActiveTurnBehaviorSchema.optional().describe('Agent callers: "steer" (default) waits until the current turn ends; "interrupt" replaces it. Human callers: "steer" joins the turn, falling back to interrupt; default is interrupt.'),
921
+ activeTurnBehavior: ActiveTurnBehaviorSchema.optional().describe('Agent callers: "steer" (default) waits until the current turn ends; "interrupt" replaces it at once and delivers the messages queued before it first, in the same turn. Human callers: "steer" joins the turn, falling back to interrupt; default is interrupt.'),
922
922
  agentId: z.string(),
923
923
  prompt: z.string(),
924
924
  sessionMode: z.string().optional().describe("Optional mode to set before running the prompt."),
@@ -1427,7 +1427,7 @@ function createToolCatalog(options, scope) {
1427
1427
  const PROMPTED_AGENT_NOTIFICATION_GUIDANCE = "You will get notified when the prompted agent finishes, errors, or needs permission. Do not poll for status; continue with other work until the notification arrives.";
1428
1428
  registerTool("send_agent_prompt", {
1429
1429
  title: "Send agent prompt",
1430
- description: "Send a task. Agent callers receive an immediate queued receipt; delivery follows after two quiet seconds per recipient and waits for the current turn to end unless interrupt is requested. Completion reports include the target’s last response by default. Paseo supplies caller identity.",
1430
+ description: "Send a task. Agent callers receive an immediate queued receipt. The recipient reads messages in the order they were queued: a steer follows two quiet seconds and waits for the current turn to end; an interrupt replaces the turn at once and takes the messages queued before it along. A later message does not cancel an earlier one. Completion reports include the target’s last response by default. Paseo supplies caller identity.",
1431
1431
  inputSchema: sendAgentPromptInputSchema,
1432
1432
  outputSchema: {
1433
1433
  success: z.boolean(),
@@ -1490,13 +1490,14 @@ function createToolCatalog(options, scope) {
1490
1490
  deliveryStatus: receipt.status,
1491
1491
  messageId: receipt.messageId,
1492
1492
  status: agentManager.getAgent(agentId)?.lifecycle ?? "idle",
1493
- guidance: notifying
1494
- ? `Queued for delivery after two quiet seconds and the current turn ends. ${PROMPTED_AGENT_NOTIFICATION_GUIDANCE}`
1495
- : "Queued for delivery after two quiet seconds and the current turn ends; provider dispatch has not occurred.",
1493
+ guidance: `${activeTurnBehavior === "interrupt"
1494
+ ? "Queued to replace the current turn now, after the messages queued before it."
1495
+ : "Queued for delivery after two quiet seconds and the current turn ends."} ${notifying ? PROMPTED_AGENT_NOTIFICATION_GUIDANCE : "Provider dispatch has not occurred."}`,
1496
1496
  },
1497
1497
  };
1498
1498
  }
1499
1499
  const dispatch = await sendPromptToAgent({
1500
+ agentMessages: agentMessages(),
1500
1501
  agentManager,
1501
1502
  agentStorage,
1502
1503
  agentId,
@@ -733,7 +733,19 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
733
733
  prompt: daemonConfigStore.get().resumePrompt ?? "Resume working.",
734
734
  }),
735
735
  eligible: async (record) => !record.workspaceId || !(await workspaceRegistry?.get(record.workspaceId))?.archivedAt,
736
- dispatch: (agentId, prompt) => sendPromptToAgent({ agentId, prompt, agentManager, agentStorage, logger, unarchive: false }),
736
+ dispatch: (agentId, prompt) => {
737
+ if (!wsServer)
738
+ throw new Error("Daemon is not accepting agent messages");
739
+ return sendPromptToAgent({
740
+ agentMessages: wsServer.agentMessages,
741
+ agentId,
742
+ prompt,
743
+ agentManager,
744
+ agentStorage,
745
+ logger,
746
+ unarchive: false,
747
+ });
748
+ },
737
749
  report: (agentId, err) => logger.error({ agentId, err }, "Agent restart recovery failed"),
738
750
  });
739
751
  await restartRecovery.prepareStartup();
@@ -822,21 +834,10 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
822
834
  untrustedSource: workspace.untrustedSource,
823
835
  }));
824
836
  };
825
- const markWorkspaceArchivingExternal = (workspaceIds, archivingAt) => {
826
- const workspaceIdList = Array.from(workspaceIds);
827
- for (const session of wsServer?.listSessions() ?? []) {
828
- session.markWorkspaceArchivingForExternalMutation(workspaceIdList, archivingAt);
829
- }
830
- };
831
- const clearWorkspaceArchivingExternal = (workspaceIds) => {
832
- const workspaceIdList = Array.from(workspaceIds);
833
- for (const session of wsServer?.listSessions() ?? []) {
834
- session.clearWorkspaceArchivingForExternalMutation(workspaceIdList);
835
- }
836
- };
837
+ const markWorkspaceArchiving = (workspaceIds, archivingAt) => workspaceArchiveOperations.markArchiving(workspaceIds, archivingAt);
838
+ const clearWorkspaceArchiving = (workspaceIds) => workspaceArchiveOperations.clearArchiving(workspaceIds);
837
839
  const emitWorkspaceUpdatesExternal = async (workspaceIds) => {
838
- const workspaceIdList = Array.from(workspaceIds);
839
- await Promise.all((wsServer?.listSessions() ?? []).map((session) => session.emitWorkspaceUpdatesForExternalWorkspaceIds(workspaceIdList)));
840
+ await wsServer?.publishWorkspaceUpdates(workspaceIds);
840
841
  };
841
842
  const ensureWorkspaceForCreateAndBroadcastExternal = async (cwd, firstAgentContext, context) => {
842
843
  const workspaceId = await ensureWorkspaceForCreateExternal(cwd, firstAgentContext, context);
@@ -884,8 +885,8 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
884
885
  listActiveWorkspaces: listActiveWorkspacesExternal,
885
886
  getAutoArchivedChangeRequestUrl: async (workspaceId) => (await workspaceRegistry.get(workspaceId))?.autoArchivedChangeRequestUrl ?? null,
886
887
  archiveWorkspaceRecord: archiveWorkspaceRecordExternal,
887
- markWorkspaceArchiving: markWorkspaceArchivingExternal,
888
- clearWorkspaceArchiving: clearWorkspaceArchivingExternal,
888
+ markWorkspaceArchiving,
889
+ clearWorkspaceArchiving,
889
890
  emitWorkspaceUpdatesForWorkspaceIds: emitWorkspaceUpdatesExternal,
890
891
  });
891
892
  const createPaseoWorktreeForTools = async (input, serviceOptions) => {
@@ -955,8 +956,8 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
955
956
  getWorkspace: (workspaceIdToGet) => workspaceRegistry.get(workspaceIdToGet),
956
957
  archiveWorkspaceRecord: (workspaceIdToArchive, archivedAt) => archiveWorkspaceRecordExternal(workspaceIdToArchive, undefined, archivedAt),
957
958
  emitWorkspaceUpdatesForWorkspaceIds: emitWorkspaceUpdatesExternal,
958
- markWorkspaceArchiving: markWorkspaceArchivingExternal,
959
- clearWorkspaceArchiving: clearWorkspaceArchivingExternal,
959
+ markWorkspaceArchiving,
960
+ clearWorkspaceArchiving,
960
961
  killTerminalsForWorkspace: (workspaceIdToKill) => killTerminalsForWorkspace({ terminalManager, sessionLogger: logger }, workspaceIdToKill),
961
962
  stopWorkspaceSetup: (workspaceIdToStop) => workspaceSetupRuntime.stop(workspaceIdToStop),
962
963
  assertWorkspaceAutomationAllowed: (guardedWorkspaceId) => assertWorkspaceAutomationAllowedForWorkspace(workspaceRegistry, guardedWorkspaceId),
@@ -982,8 +983,8 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
982
983
  emit: emitExternalSessionMessage,
983
984
  emitAgentRemove: async () => undefined,
984
985
  emitWorkspaceUpdatesForWorkspaceIds: emitWorkspaceUpdatesExternal,
985
- markWorkspaceArchiving: markWorkspaceArchivingExternal,
986
- clearWorkspaceArchiving: clearWorkspaceArchivingExternal,
986
+ markWorkspaceArchiving,
987
+ clearWorkspaceArchiving,
987
988
  killTerminalsForWorkspace: (workspaceId) => killTerminalsForWorkspace({ terminalManager, sessionLogger: logger }, workspaceId),
988
989
  logger,
989
990
  });
@@ -1061,8 +1062,8 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
1061
1062
  getWorkspace: (workspaceIdToGet) => workspaceRegistry.get(workspaceIdToGet),
1062
1063
  archiveWorkspaceRecord: (workspaceIdToArchive, archivedAt) => archiveWorkspaceRecordExternal(workspaceIdToArchive, undefined, archivedAt),
1063
1064
  emitWorkspaceUpdatesForWorkspaceIds: emitWorkspaceUpdatesExternal,
1064
- markWorkspaceArchiving: markWorkspaceArchivingExternal,
1065
- clearWorkspaceArchiving: clearWorkspaceArchivingExternal,
1065
+ markWorkspaceArchiving,
1066
+ clearWorkspaceArchiving,
1066
1067
  killTerminalsForWorkspace: (workspaceIdToKill) => killTerminalsForWorkspace({
1067
1068
  terminalManager,
1068
1069
  sessionLogger: logger,
@@ -1214,8 +1215,8 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
1214
1215
  assertAutomationAllowed: (workspaceId) => assertWorkspaceAutomationAllowedForWorkspace(workspaceRegistry, workspaceId),
1215
1216
  getGlobalServicePorts: () => daemonConfigStore.readServicePorts(),
1216
1217
  }),
1217
- markWorkspaceArchiving: markWorkspaceArchivingExternal,
1218
- clearWorkspaceArchiving: clearWorkspaceArchivingExternal,
1218
+ markWorkspaceArchiving,
1219
+ clearWorkspaceArchiving,
1219
1220
  ensureWorkspaceForCreate: createAgentCommandDependencies.ensureWorkspaceForCreate,
1220
1221
  createPaseoWorktree: createAgentCommandDependencies.createPaseoWorktree,
1221
1222
  browserToolsEnabled: browserToolsPolicy.isEnabled(),
@@ -1549,10 +1550,26 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
1549
1550
  timeoutMs: AGENT_CLOSE_TIMEOUT_MS,
1550
1551
  label: "drain plugin lifecycle events",
1551
1552
  }).catch((error) => logger.warn({ err: error }, "Plugin lifecycle events did not finish"));
1552
- await agentManager.flushForShutdown().catch(() => undefined);
1553
+ let shutdownFlushTimedOut = false;
1554
+ await withTimeout({
1555
+ promise: agentManager.flushForShutdown(),
1556
+ timeoutMs: AGENT_CLOSE_TIMEOUT_MS,
1557
+ label: "flush agent shutdown tasks",
1558
+ }).catch((error) => {
1559
+ shutdownFlushTimedOut = true;
1560
+ logger.warn({ err: error }, "Agent shutdown tasks did not finish before provider shutdown");
1561
+ });
1553
1562
  detachAgentStoragePersistence();
1554
1563
  await agentStorage.flush().catch(() => undefined);
1555
1564
  await agentProviderRuntime.shutdown();
1565
+ if (shutdownFlushTimedOut) {
1566
+ await withTimeout({
1567
+ promise: agentManager.flushForShutdown(),
1568
+ timeoutMs: AGENT_CLOSE_TIMEOUT_MS,
1569
+ label: "flush agent shutdown tasks after provider shutdown",
1570
+ }).catch((error) => logger.warn({ err: error }, "Agent shutdown tasks did not finish after provider shutdown"));
1571
+ await agentStorage.flush().catch(() => undefined);
1572
+ }
1556
1573
  await pluginRuntime.stopAllPlugins();
1557
1574
  try {
1558
1575
  if (keepTerminals) {
@@ -92,7 +92,9 @@ export declare class CheckoutSession {
92
92
  handleSubscribeDiffRequest(msg: SubscribeCheckoutDiffRequest, ownership: SessionDelivery): Promise<void>;
93
93
  handleUnsubscribeDiffRequest(msg: UnsubscribeCheckoutDiffRequest, ownership: SessionDelivery): Promise<void>;
94
94
  handleRefreshRequest(msg: CheckoutRefreshRequest): Promise<void>;
95
- emitStatusUpdate(cwd: string, snapshot: WorkspaceGitRuntimeSnapshot): void;
95
+ emitStatusUpdate(cwd: string, snapshot: WorkspaceGitRuntimeSnapshot, options?: {
96
+ force: boolean;
97
+ }): void;
96
98
  /**
97
99
  * Notify the live diff subscriptions that the working tree at `cwd` changed.
98
100
  * Called by the command handlers below after they mutate the repository.
@@ -378,7 +378,7 @@ export class CheckoutSession {
378
378
  });
379
379
  }
380
380
  }
381
- emitStatusUpdate(cwd, snapshot) {
381
+ emitStatusUpdate(cwd, snapshot, options) {
382
382
  try {
383
383
  const requestId = `subscription:${cwd}`;
384
384
  const payload = {
@@ -394,7 +394,7 @@ export class CheckoutSession {
394
394
  }),
395
395
  };
396
396
  const fingerprint = JSON.stringify(payload);
397
- if (this.statusUpdateFingerprints.get(cwd) === fingerprint)
397
+ if (!options?.force && this.statusUpdateFingerprints.get(cwd) === fingerprint)
398
398
  return;
399
399
  this.statusUpdateFingerprints.set(cwd, fingerprint);
400
400
  this.host.emit({
@@ -79,6 +79,7 @@ export interface SessionOptions {
79
79
  getTransportBufferedAmount?: (source?: object) => number | null;
80
80
  getConnectedHostBufferedAmount?: () => number | null;
81
81
  onLifecycleIntent?: (intent: SessionLifecycleIntent) => void;
82
+ publishWorkspaceArchiveUpdates?: (workspaceIds: Iterable<string>) => Promise<void>;
82
83
  onWorkspaceRecovered?: (workspace: PersistedWorkspaceRecord) => Promise<void>;
83
84
  publishScriptStatusUpdate?: (message: ScriptStatusUpdateMessage) => void;
84
85
  logger: pino.Logger;
@@ -242,6 +243,7 @@ export declare class Session {
242
243
  private readonly onBinaryMessageToSource;
243
244
  private readonly getTransportBufferedAmount;
244
245
  private readonly onLifecycleIntent;
246
+ private readonly onWorkspaceArchiveUpdate;
245
247
  private readonly onWorkspaceRecovered;
246
248
  private readonly sessionLogger;
247
249
  private readonly paseoHome;
@@ -334,8 +336,7 @@ export declare class Session {
334
336
  syncWorkspaceGitObserverForWorkspace(workspace: PersistedWorkspaceRecord): Promise<void>;
335
337
  emitWorkspaceUpdateForWorkspaceId(workspaceId: string): Promise<void>;
336
338
  private emitCreatedWorkspaceUpdate;
337
- markWorkspaceArchivingForExternalMutation(workspaceIds: Iterable<string>, archivingAt: string): void;
338
- clearWorkspaceArchivingForExternalMutation(workspaceIds: Iterable<string>): void;
339
+ private readonly publishWorkspaceArchiveUpdates;
339
340
  emitWorkspaceUpdatesForExternalWorkspaceIds(workspaceIds: Iterable<string>): Promise<void>;
340
341
  syncWorkspaceGitObserversForExternalWorkspaceIds(workspaceIds: Iterable<string>): Promise<void>;
341
342
  warmWorkspaceGitDataForWorkspace(workspace: PersistedWorkspaceRecord): Promise<void>;
@@ -277,6 +277,8 @@ export class Session {
277
277
  this.workspaceUpdateTails = new Map();
278
278
  this.inflightRequests = 0;
279
279
  this.peakInflightRequests = 0;
280
+ this.publishWorkspaceArchiveUpdates = (workspaceIds) => this.onWorkspaceArchiveUpdate?.(workspaceIds) ??
281
+ this.emitWorkspaceUpdatesForWorkspaceIds(workspaceIds);
280
282
  this.creationResourceExists = async (kind, id) => kind === "workspace"
281
283
  ? (await this.workspaceRegistry.get(id)) !== null
282
284
  : this.agentManager.getAgent(id) != null || (await this.agentStorage.get(id)) !== null;
@@ -323,6 +325,7 @@ export class Session {
323
325
  : null;
324
326
  this.getTransportBufferedAmount = getTransportBufferedAmount ?? (() => 0);
325
327
  this.onLifecycleIntent = onLifecycleIntent ?? null;
328
+ this.onWorkspaceArchiveUpdate = options.publishWorkspaceArchiveUpdates;
326
329
  this.onWorkspaceRecovered = onWorkspaceRecovered ?? null;
327
330
  this.pushNotifications = pushNotifications;
328
331
  this.paseoHome = paseoHome;
@@ -626,7 +629,7 @@ export class Session {
626
629
  archiveWorkspaceRecord: (workspaceId) => this.archiveWorkspaceRecord(workspaceId),
627
630
  emit: (message) => this.emit(message),
628
631
  emitAgentRemove: (agentId) => this.agentUpdates.removeAgent(agentId),
629
- emitWorkspaceUpdatesForWorkspaceIds: (workspaceIds) => this.emitWorkspaceUpdatesForWorkspaceIds(workspaceIds),
632
+ emitWorkspaceUpdatesForWorkspaceIds: this.publishWorkspaceArchiveUpdates,
630
633
  markWorkspaceArchiving: (workspaceIds, archivingAt) => this.markWorkspaceArchiving(workspaceIds, archivingAt),
631
634
  clearWorkspaceArchiving: (workspaceIds) => this.clearWorkspaceArchiving(workspaceIds),
632
635
  killTerminalsForWorkspace: (workspaceId) => this.terminalController.killTerminalsForWorkspace(workspaceId),
@@ -673,6 +676,7 @@ export class Session {
673
676
  getGlobalServicePorts: () => this.daemonConfigStore.readServicePorts(),
674
677
  });
675
678
  this.workspaceDirectory = new WorkspaceDirectory({
679
+ getArchivingAt: (workspaceId) => this.workspaceArchiveOperations.getArchivingAt(workspaceId),
676
680
  logger: this.sessionLogger,
677
681
  projectRegistry: this.projectRegistry,
678
682
  workspaceRegistry: this.workspaceRegistry,
@@ -922,12 +926,6 @@ export class Session {
922
926
  },
923
927
  });
924
928
  }
925
- markWorkspaceArchivingForExternalMutation(workspaceIds, archivingAt) {
926
- this.markWorkspaceArchiving(workspaceIds, archivingAt);
927
- }
928
- clearWorkspaceArchivingForExternalMutation(workspaceIds) {
929
- this.clearWorkspaceArchiving(workspaceIds);
930
- }
931
929
  async emitWorkspaceUpdatesForExternalWorkspaceIds(workspaceIds) {
932
930
  await this.emitWorkspaceUpdatesForWorkspaceIds(workspaceIds);
933
931
  }
@@ -948,6 +946,14 @@ export class Session {
948
946
  async refreshRecoveredWorkspaceForExternalMutation(workspace) {
949
947
  try {
950
948
  await this.syncWorkspaceGitObserverForWorkspace(workspace);
949
+ if (workspace.kind !== "directory" && this.wantsEvent("checkout_status_update")) {
950
+ // Recovery can refresh Git before this session starts observing again.
951
+ // Publish the current status to replace any read made while archived.
952
+ const snapshot = await this.workspaceGitService.getSnapshot(workspace.cwd, {
953
+ includeForge: false,
954
+ });
955
+ this.checkoutSession.emitStatusUpdate(workspace.cwd, snapshot, { force: true });
956
+ }
951
957
  await this.emitWorkspaceUpdateForWorkspaceId(workspace.workspaceId);
952
958
  }
953
959
  catch (error) {
@@ -3043,12 +3049,12 @@ export class Session {
3043
3049
  const activeWorkspaceIds = projectWorkspaces
3044
3050
  .filter((workspace) => !workspace.archivedAt)
3045
3051
  .map((workspace) => workspace.workspaceId);
3046
- if (activeWorkspaceIds.length > 0) {
3047
- this.markWorkspaceArchiving(activeWorkspaceIds, new Date().toISOString());
3048
- await this.emitWorkspaceUpdatesForWorkspaceIds(activeWorkspaceIds);
3049
- }
3050
3052
  const removedWorkspaceIds = [];
3053
+ this.markWorkspaceArchiving(activeWorkspaceIds, new Date().toISOString());
3051
3054
  try {
3055
+ if (activeWorkspaceIds.length > 0) {
3056
+ await this.publishWorkspaceArchiveUpdates(activeWorkspaceIds);
3057
+ }
3052
3058
  for (const workspaceId of activeWorkspaceIds) {
3053
3059
  const archivedAt = new Date().toISOString();
3054
3060
  await archiveWorkspaceContents({
@@ -3067,18 +3073,17 @@ export class Session {
3067
3073
  }).catch((error) => {
3068
3074
  this.sessionLogger.warn({ err: error, projectId: resolvedProjectId }, "Failed to clean up removed project icon");
3069
3075
  });
3076
+ const updateIds = removedWorkspaceIds.length > 0
3077
+ ? removedWorkspaceIds
3078
+ : [projectWorkspaces[0]?.workspaceId ?? projectId];
3079
+ await this.emitWorkspaceUpdatesForWorkspaceIds(updateIds, { removedProjectId: projectId });
3070
3080
  }
3071
3081
  finally {
3082
+ this.clearWorkspaceArchiving(activeWorkspaceIds);
3072
3083
  if (activeWorkspaceIds.length > 0) {
3073
- this.clearWorkspaceArchiving(activeWorkspaceIds);
3084
+ await this.publishWorkspaceArchiveUpdates(activeWorkspaceIds);
3074
3085
  }
3075
3086
  }
3076
- const updateIds = removedWorkspaceIds.length > 0
3077
- ? removedWorkspaceIds
3078
- : [projectWorkspaces[0]?.workspaceId ?? projectId];
3079
- await this.emitWorkspaceUpdatesForWorkspaceIds(updateIds, {
3080
- removedProjectId: projectId,
3081
- });
3082
3087
  this.emit({
3083
3088
  type: "project.remove.response",
3084
3089
  payload: {
@@ -3355,6 +3360,7 @@ export class Session {
3355
3360
  const prompt = buildAgentPrompt(promptText, images, attachments);
3356
3361
  try {
3357
3362
  await sendPromptToAgent({
3363
+ agentMessages: this.agentMessages,
3358
3364
  agentManager: this.agentManager,
3359
3365
  agentStorage: this.agentStorage,
3360
3366
  agentId,
@@ -4364,7 +4370,7 @@ export class Session {
4364
4370
  listActiveWorkspaces: () => this.listActiveWorkspaceRefs(),
4365
4371
  archiveWorkspaceRecord: (workspaceId, archivedAt) => this.archiveWorkspaceRecord(workspaceId, archivedAt),
4366
4372
  emit: (message) => this.emit(message),
4367
- emitWorkspaceUpdatesForWorkspaceIds: (workspaceIds) => this.emitWorkspaceUpdatesForWorkspaceIds(workspaceIds),
4373
+ emitWorkspaceUpdatesForWorkspaceIds: this.publishWorkspaceArchiveUpdates,
4368
4374
  markWorkspaceArchiving: (workspaceIds, archivingAt) => this.markWorkspaceArchiving(workspaceIds, archivingAt),
4369
4375
  clearWorkspaceArchiving: (workspaceIds) => this.clearWorkspaceArchiving(workspaceIds),
4370
4376
  killTerminalsForWorkspace: (workspaceId) => this.terminalController.killTerminalsForWorkspace(workspaceId),
@@ -4789,10 +4795,10 @@ export class Session {
4789
4795
  return this.describeWorkspaceRecord(input.workspace, input.projectRecord);
4790
4796
  }
4791
4797
  markWorkspaceArchiving(workspaceIds, archivingAt) {
4792
- this.workspaceDirectory.markArchiving(workspaceIds, archivingAt);
4798
+ this.workspaceArchiveOperations.markArchiving(workspaceIds, archivingAt);
4793
4799
  }
4794
4800
  clearWorkspaceArchiving(workspaceIds) {
4795
- this.workspaceDirectory.clearArchiving(workspaceIds);
4801
+ this.workspaceArchiveOperations.clearArchiving(workspaceIds);
4796
4802
  }
4797
4803
  async buildWorkspaceDescriptorMap(options) {
4798
4804
  return this.workspaceDirectory.buildDescriptorMap(options);
@@ -6228,7 +6234,7 @@ export class Session {
6228
6234
  getWorkspace: (workspaceId) => this.workspaceRegistry.get(workspaceId),
6229
6235
  listActiveWorkspaces: () => this.listActiveWorkspaceRefs(),
6230
6236
  archiveWorkspaceRecord: (workspaceId, archivedAt) => this.archiveWorkspaceRecord(workspaceId, archivedAt),
6231
- emitWorkspaceUpdatesForWorkspaceIds: (workspaceIds) => this.emitWorkspaceUpdatesForWorkspaceIds(workspaceIds),
6237
+ emitWorkspaceUpdatesForWorkspaceIds: this.publishWorkspaceArchiveUpdates,
6232
6238
  markWorkspaceArchiving: (workspaceIds, archivingAt) => this.markWorkspaceArchiving(workspaceIds, archivingAt),
6233
6239
  clearWorkspaceArchiving: (workspaceIds) => this.clearWorkspaceArchiving(workspaceIds),
6234
6240
  assertWorkspaceAutomationAllowed: (workspaceId) => assertWorkspaceAutomationAllowedForWorkspace(this.workspaceRegistry, workspaceId),
@@ -7010,6 +7016,7 @@ export class Session {
7010
7016
  return;
7011
7017
  }
7012
7018
  const result = await sendPromptToAgent({
7019
+ agentMessages: this.agentMessages,
7013
7020
  agentManager: this.agentManager,
7014
7021
  agentStorage: this.agentStorage,
7015
7022
  agentId,
@@ -161,6 +161,7 @@ export declare class VoiceAssistantWebSocketServer {
161
161
  private attachAuthenticatedSocket;
162
162
  broadcast(message: WSOutboundMessage): void;
163
163
  listSessions(): Session[];
164
+ publishWorkspaceUpdates(workspaceIds: Iterable<string>): Promise<void>;
164
165
  publishProjectUpdate(update: ProjectUpdate): void;
165
166
  publishScriptStatusUpdate(message: ScriptStatusUpdateMessage): void;
166
167
  publishSpeechReadiness(readiness: SpeechReadinessSnapshot | null): void;
@@ -372,6 +372,7 @@ export class VoiceAssistantWebSocketServer {
372
372
  if (event.type === "agent_state")
373
373
  notify(event.agent.id);
374
374
  }, { replayState: false }),
375
+ onStop: (notify) => agentManager.onStop(notify),
375
376
  dispatch: async (batch) => {
376
377
  const dispatch = await sendPreparedPromptToAgent({
377
378
  agentManager,
@@ -391,6 +392,7 @@ export class VoiceAssistantWebSocketServer {
391
392
  await waitForAgentRunStartWithTimeout(agentManager, batch.recipientId, dispatch.started);
392
393
  return dispatch.disposition;
393
394
  },
395
+ awaitStart: (agentId, started) => waitForAgentRunStartWithTimeout(agentManager, agentId, started),
394
396
  onError: (err, batch) => this.logger.error({ err, agentId: batch.recipientId, messageIds: batch.messageIds }, "Agent message batch dispatch failed"),
395
397
  });
396
398
  this.messageReceipts = new MessageReceipts(join(paseoHome, "agent-requests"));
@@ -626,6 +628,17 @@ export class VoiceAssistantWebSocketServer {
626
628
  listSessions() {
627
629
  return Array.from(new Set([...this.sessions.values(), ...this.externalSessionsByKey.values()].map((connection) => connection.session)));
628
630
  }
631
+ async publishWorkspaceUpdates(workspaceIds) {
632
+ const ids = Array.from(workspaceIds);
633
+ await Promise.all(this.listSessions().map(async (session) => {
634
+ try {
635
+ await session.emitWorkspaceUpdatesForExternalWorkspaceIds(ids);
636
+ }
637
+ catch (error) {
638
+ this.logger.warn({ err: error }, "Failed to publish workspace updates");
639
+ }
640
+ }));
641
+ }
629
642
  publishProjectUpdate(update) {
630
643
  for (const session of this.listSessions()) {
631
644
  void session
@@ -1122,6 +1135,7 @@ export class VoiceAssistantWebSocketServer {
1122
1135
  getTransportBufferedAmount: options.getTransportBufferedAmount,
1123
1136
  onLifecycleIntent: options.onLifecycleIntent,
1124
1137
  logger: options.connectionLogger.child({ module: "session" }),
1138
+ publishWorkspaceArchiveUpdates: (workspaceIds) => this.publishWorkspaceUpdates(workspaceIds),
1125
1139
  onWorkspaceRecovered: async (workspace) => {
1126
1140
  await Promise.all(this.listSessions().map((activeSession) => activeSession.refreshRecoveredWorkspaceForExternalMutation(workspace)));
1127
1141
  },
@@ -30,6 +30,10 @@ export interface WorkspaceArchiveUndoInput {
30
30
  export declare class WorkspaceArchiveOperations {
31
31
  private readonly lanes;
32
32
  private readonly checkoutGates;
33
+ private readonly archiving;
34
+ getArchivingAt(workspaceId: string): string | null;
35
+ markArchiving(workspaceIds: Iterable<string>, startedAt: string): void;
36
+ clearArchiving(workspaceIds: Iterable<string>): void;
33
37
  archive(workspaceId: string, run: (signal: AbortSignal) => Promise<ArchiveResult>): Promise<WorkspaceArchiveOutcome>;
34
38
  undo(workspaceId: string, restore: (input: WorkspaceArchiveUndoInput) => Promise<void>): Promise<void>;
35
39
  /**
@@ -23,6 +23,30 @@ export class WorkspaceArchiveOperations {
23
23
  constructor() {
24
24
  this.lanes = new Map();
25
25
  this.checkoutGates = new Map();
26
+ // Project removal can overlap a checkout-scoped archive of the same workspace.
27
+ this.archiving = new Map();
28
+ }
29
+ getArchivingAt(workspaceId) {
30
+ return this.archiving.get(workspaceId)?.startedAt ?? null;
31
+ }
32
+ markArchiving(workspaceIds, startedAt) {
33
+ for (const id of workspaceIds) {
34
+ const current = this.archiving.get(id);
35
+ if (current)
36
+ current.count += 1;
37
+ else
38
+ this.archiving.set(id, { startedAt, count: 1 });
39
+ }
40
+ }
41
+ clearArchiving(workspaceIds) {
42
+ for (const id of workspaceIds) {
43
+ const current = this.archiving.get(id);
44
+ if (!current)
45
+ continue;
46
+ current.count -= 1;
47
+ if (current.count === 0)
48
+ this.archiving.delete(id);
49
+ }
26
50
  }
27
51
  archive(workspaceId, run) {
28
52
  const current = this.lanes.get(workspaceId);
@@ -24,6 +24,7 @@ export interface WorkspaceDirectoryDeps {
24
24
  listActive(): Promise<PersistedWorkspaceRecord[]>;
25
25
  get(id: string): Promise<PersistedWorkspaceRecord | null>;
26
26
  };
27
+ getArchivingAt(workspaceId: string): string | null;
27
28
  listAgentPayloads(workspaceIds?: Iterable<string>): Promise<AgentSnapshotPayload[]>;
28
29
  workspaceLastUserMessageTimes(workspaceIds?: Iterable<string>): Promise<ReadonlyMap<string, string>>;
29
30
  listProviderSubagentActivity(): Promise<ProviderSubagentWorkspaceActivity[]>;
@@ -64,7 +65,6 @@ export declare function workspaceIdsOnCheckout(workspaces: Iterable<PersistedWor
64
65
  export declare function workspaceIdsForProjects(workspaces: Iterable<PersistedWorkspaceRecord>, projectIds: ReadonlySet<string>): string[];
65
66
  export declare class WorkspaceDirectory {
66
67
  private readonly deps;
67
- private readonly archivingByWorkspaceId;
68
68
  /**
69
69
  * Per-workspace last-seen winning bucket + entered-at. Persists across
70
70
  * `buildDescriptorMap` calls inside the daemon process; reset on cold start.
@@ -73,8 +73,6 @@ export declare class WorkspaceDirectory {
73
73
  private readonly bucketHistoryByWorkspaceId;
74
74
  private readonly pager;
75
75
  constructor(deps: WorkspaceDirectoryDeps);
76
- markArchiving(workspaceIds: Iterable<string>, archivingAt: string): void;
77
- clearArchiving(workspaceIds: Iterable<string>): void;
78
76
  buildDescriptorMap(options: {
79
77
  includeGitData: boolean;
80
78
  workspaceIds?: Iterable<string>;