Compare commits

..
Author SHA1 Message Date
Mohamed Boudra 35b0b35ae0 fix(timeline): reuse managed turn assignment for notices
Resolve notices before waiter matching with the same rule used by live persistence. Verify untagged foreground runtime notices through runAgent and idle Pi notices through timeline paging.
2026-11-18 15:42:24 +01:00
Mohamed Boudra 0f28b5672b test(timeline): keep notice paging assertions compatible with async history 2026-11-18 15:29:16 +01:00
Mohamed Boudra d777c0f7ab fix(timeline): keep replies visible across idle notifications
Resolve notification membership at the manager's live event boundary. An idle notice gets a display turn without starting a run, and in-flight notices join the open run.
2026-11-18 15:27:41 +01:00
38 changed files with 318 additions and 745 deletions
-21
View File
@@ -1,26 +1,5 @@
# Changelog
## 0.16.2 - 2026-11-18
### Fixed
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification ([#10092](https://github.com/getpaseo/paseo/pull/10092))
- Fixed detached worktree commits getting lost when archiving a workspace ([#10009](https://github.com/getpaseo/paseo/pull/10009) by [@ragokan](https://github.com/ragokan))
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it ([#10067](https://github.com/getpaseo/paseo/pull/10067))
- Fixed daemons losing their Hub connection after execution permissions changed ([#10113](https://github.com/getpaseo/paseo/pull/10113))
- Fixed saved hosts disappearing when one stored entry could not be read ([#9847](https://github.com/getpaseo/paseo/pull/9847) by [@ragokan](https://github.com/ragokan))
- Fixed worktree creation timing out while scanning large ignored folders that `.worktreeinclude` does not name ([#10020](https://github.com/getpaseo/paseo/pull/10020) by [@mgranderath](https://github.com/mgranderath))
- Fixed Steer cancelling a Claude compaction in progress ([#10028](https://github.com/getpaseo/paseo/pull/10028) by [@NightMachinery](https://github.com/NightMachinery))
- Fixed agents getting stuck after a second Stop when the provider reused the cancelled turn ID ([#9774](https://github.com/getpaseo/paseo/pull/9774) by [@DAnaeto](https://github.com/DAnaeto))
- Fixed Desktop staying blank after its renderer exited unexpectedly ([#10035](https://github.com/getpaseo/paseo/pull/10035))
- Fixed failed file downloads taking over the app window on web and Desktop ([#9937](https://github.com/getpaseo/paseo/pull/9937) by [@panta82](https://github.com/panta82))
- Fixed Import Session losing its scroll position when you select Load more ([#9974](https://github.com/getpaseo/paseo/pull/9974))
- Fixed terminals failing to open when the home filesystem refuses Unix sockets, such as on AFS ([#9214](https://github.com/getpaseo/paseo/pull/9214) by [@bendavid](https://github.com/bendavid))
- Fixed timed-out Git watchers repeatedly rescanning large repositories ([#9828](https://github.com/getpaseo/paseo/pull/9828) by [@Spshulem](https://github.com/Spshulem))
- Fixed `paseo workspace create --path .` using the local daemon's directory instead of the caller's ([#10010](https://github.com/getpaseo/paseo/pull/10010))
- Fixed MCP agent status and list responses omitting background work for idle agents ([#10022](https://github.com/getpaseo/paseo/pull/10022) by [@ortschun](https://github.com/ortschun))
- Fixed the thinking selector showing an old level after OMP changes it ([#9841](https://github.com/getpaseo/paseo/pull/9841) by [@dsingal0](https://github.com/dsingal0))
## 0.16.1 - 2026-11-17
### Fixed
-21
View File
@@ -1,26 +1,5 @@
# Changelog
## 0.16.2 - 2026-11-18
### 修复
- 修复启用“折叠轮次”时,Claude 回复后续后台任务通知导致上一条已完成的回复被折叠的问题 ([#10092](https://github.com/getpaseo/paseo/pull/10092))
- 修复归档工作区时丢失分离 HEAD 的 worktree 提交的问题 ([#10009](https://github.com/getpaseo/paseo/pull/10009),贡献者:[@ragokan](https://github.com/ragokan))
- 修复 Desktop 更新后,由上一次 Desktop 会话启动的旧版 daemon 仍在运行的问题 ([#10067](https://github.com/getpaseo/paseo/pull/10067))
- 修复更改执行权限后 daemon 与 Hub 断开连接的问题 ([#10113](https://github.com/getpaseo/paseo/pull/10113))
- 修复一条已保存的主机记录无法读取时,其他主机也消失的问题 ([#9847](https://github.com/getpaseo/paseo/pull/9847),贡献者:[@ragokan](https://github.com/ragokan))
- 修复创建 worktree 时,扫描 `.worktreeinclude` 未指定的大型忽略目录导致超时的问题 ([#10020](https://github.com/getpaseo/paseo/pull/10020),贡献者:[@mgranderath](https://github.com/mgranderath))
- 修复发送引导消息时取消 Claude 正在进行的上下文压缩的问题 ([#10028](https://github.com/getpaseo/paseo/pull/10028),贡献者:[@NightMachinery](https://github.com/NightMachinery))
- 修复 Provider 重用已取消的轮次 ID 时,再次停止导致 Agent 卡住的问题 ([#9774](https://github.com/getpaseo/paseo/pull/9774),贡献者:[@DAnaeto](https://github.com/DAnaeto))
- 修复 Desktop 渲染进程意外退出后窗口一直空白的问题 ([#10035](https://github.com/getpaseo/paseo/pull/10035))
- 修复 Web 和 Desktop 上文件下载失败时,错误页面占据应用窗口的问题 ([#9937](https://github.com/getpaseo/paseo/pull/9937),贡献者:[@panta82](https://github.com/panta82))
- 修复在“导入会话”中选择“加载更多”时丢失滚动位置的问题 ([#9974](https://github.com/getpaseo/paseo/pull/9974))
- 修复主目录所在的文件系统拒绝 Unix 套接字时无法打开终端的问题,例如 AFS ([#9214](https://github.com/getpaseo/paseo/pull/9214),贡献者:[@bendavid](https://github.com/bendavid))
- 修复 Git 监视器设置超时后反复扫描大型仓库的问题 ([#9828](https://github.com/getpaseo/paseo/pull/9828),贡献者:[@Spshulem](https://github.com/Spshulem))
- 修复 `paseo workspace create --path .` 使用本地 daemon 的目录而非命令所在目录的问题 ([#10010](https://github.com/getpaseo/paseo/pull/10010))
- 修复针对空闲 Agent 查询 MCP 状态或列表时漏报后台任务的问题 ([#10022](https://github.com/getpaseo/paseo/pull/10022),贡献者:[@ortschun](https://github.com/ortschun))
- 修复 OMP 更改思考级别后,选择器仍显示旧级别的问题 ([#9841](https://github.com/getpaseo/paseo/pull/9841),贡献者:[@dsingal0](https://github.com/dsingal0))
## 0.16.1 - 2026-11-17
### 修复
@@ -1,8 +0,0 @@
Fixed
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
- Fixed detached worktree commits getting lost when archiving a workspace
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
- Fixed daemons losing their Hub connection after execution permissions changed
- Fixed saved hosts disappearing when one stored entry could not be read
Full notes: https://paseo.sh/changelog
@@ -1,8 +0,0 @@
Fixed
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
- Fixed detached worktree commits getting lost when archiving a workspace
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
- Fixed daemons losing their Hub connection after execution permissions changed
- Fixed saved hosts disappearing when one stored entry could not be read
Full notes: https://paseo.sh/changelog
@@ -1,8 +0,0 @@
Fixed
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
- Fixed detached worktree commits getting lost when archiving a workspace
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
- Fixed daemons losing their Hub connection after execution permissions changed
- Fixed saved hosts disappearing when one stored entry could not be read
Full notes: https://paseo.sh/changelog
@@ -1,8 +0,0 @@
Fixed
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
- Fixed detached worktree commits getting lost when archiving a workspace
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
- Fixed daemons losing their Hub connection after execution permissions changed
- Fixed saved hosts disappearing when one stored entry could not be read
Full notes: https://paseo.sh/changelog
+1 -1
View File
@@ -1 +1 @@
sha256-yLTaVMgu3tc/dgngJ7RP0htJcWE0ZtQ4mouypevyv0s=
sha256-k7+5S/4tyAmHdZmUdhpuZ7GOc7hp9cG8wUBFdJI32ng=
+28 -28
View File
@@ -1,12 +1,12 @@
{
"name": "paseo",
"version": "0.16.2",
"version": "0.16.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "paseo",
"version": "0.16.2",
"version": "0.16.1",
"hasInstallScript": true,
"license": "Apache-2.0",
"workspaces": [
@@ -37468,7 +37468,7 @@
},
"packages/app": {
"name": "@getpaseo/app",
"version": "0.16.2",
"version": "0.16.1",
"dependencies": {
"@codemirror/commands": "6.10.4",
"@codemirror/language": "6.12.4",
@@ -39637,13 +39637,13 @@
},
"packages/cli": {
"name": "@getpaseo/cli",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@clack/prompts": "^1.0.0",
"@getpaseo/client": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/server": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"@getpaseo/server": "0.16.1",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"mime-types": "^2.1.35",
@@ -39890,11 +39890,11 @@
},
"packages/client": {
"name": "@getpaseo/client",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@getpaseo/protocol": "0.16.2",
"@getpaseo/relay": "0.16.2",
"@getpaseo/protocol": "0.16.1",
"@getpaseo/relay": "0.16.1",
"ws": "^8.20.0",
"zod": "^4.4.3"
},
@@ -39906,7 +39906,7 @@
},
"packages/desktop": {
"name": "@getpaseo/desktop",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@getpaseo/cli": "*",
@@ -40149,7 +40149,7 @@
},
"packages/expo-two-way-audio": {
"name": "@getpaseo/expo-two-way-audio",
"version": "0.16.2",
"version": "0.16.1",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.14",
@@ -40195,7 +40195,7 @@
},
"packages/highlight": {
"name": "@getpaseo/highlight",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@codemirror/language": "6.12.4",
@@ -40225,7 +40225,7 @@
},
"packages/plugin": {
"name": "@getpaseo/plugin",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@agentclientprotocol/sdk": "^1.4.0",
@@ -40233,8 +40233,8 @@
"use-sync-external-store": "^1.6.0"
},
"devDependencies": {
"@getpaseo/client": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"@types/node": "^20.9.0",
"@types/react": "~19.2.0",
"react": "19.2.3",
@@ -40244,8 +40244,8 @@
"zod": "^4.4.3"
},
"peerDependencies": {
"@getpaseo/client": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"react": ">=19.1.0 <20",
"react-native": ">=0.81.5",
"zod": "^4.4.3"
@@ -40267,7 +40267,7 @@
},
"packages/protocol": {
"name": "@getpaseo/protocol",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"semver": "^7.8.5",
@@ -40295,7 +40295,7 @@
},
"packages/relay": {
"name": "@getpaseo/relay",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@noble/ciphers": "^2.4.0",
@@ -40517,17 +40517,17 @@
},
"packages/server": {
"name": "@getpaseo/server",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"dependencies": {
"@agentclientprotocol/sdk": "^0.17.1",
"@anthropic-ai/claude-agent-sdk": "0.3.326",
"@anthropic-ai/sdk": "^0.104.2",
"@getpaseo/client": "0.16.2",
"@getpaseo/highlight": "0.16.2",
"@getpaseo/plugin": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/relay": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/highlight": "0.16.1",
"@getpaseo/plugin": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"@getpaseo/relay": "0.16.1",
"@isaacs/ttlcache": "^2.1.4",
"@modelcontextprotocol/sdk": "1.29.0",
"@opencode-ai/sdk": "1.14.46",
@@ -41474,7 +41474,7 @@
},
"packages/website": {
"name": "@getpaseo/website",
"version": "0.16.2",
"version": "0.16.1",
"dependencies": {
"@cloudflare/vite-plugin": "^1.29.1",
"@cloudflare/workers-types": "^4.20260317.1",
@@ -43084,7 +43084,7 @@
},
"plugins": {
"name": "@getpaseo/builtin-plugins",
"version": "0.16.2",
"version": "0.16.1",
"dependencies": {
"@getpaseo/plugin": "*",
"zod": "^4.4.3"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "paseo",
"version": "0.16.2",
"version": "0.16.1",
"private": true,
"description": "Paseo: voice-controlled development environment for local AI coding agents",
"keywords": [
@@ -56,20 +56,11 @@ function inFlightTurn(page: Page) {
return page.getByTestId("turn-working-indicator");
}
/**
* Presses a fork trigger until its menu shows.
*
* The in-flight turn's trigger sits below text that is still streaming in. While the chat is
* shorter than the viewport, each new line moves the trigger down. A line that arrives between
* the press and the release moves the trigger away from the pointer, so the press opens nothing,
* and the next press lands on the trigger where it is now.
*/
async function openForkMenu(page: Page, trigger: ReturnType<Page["getByRole"]>): Promise<void> {
const forkInNewTab = page.getByRole("menuitem", { name: "Fork in a new tab" });
await expect(async () => {
await trigger.click({ timeout: 5_000 });
await expect(forkInNewTab).toBeVisible({ timeout: 5_000 });
}).toPass({ timeout: 30_000 });
await trigger.click();
await expect(page.getByRole("menuitem", { name: "Fork in a new tab" })).toBeVisible({
timeout: 10_000,
});
}
export async function openMostRecentAssistantForkMenu(page: Page): Promise<void> {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/app",
"version": "0.16.2",
"version": "0.16.1",
"private": true,
"main": "index.ts",
"scripts": {
File diff suppressed because one or more lines are too long
@@ -215,32 +215,6 @@ describe("Mermaid sandbox runtime", () => {
expect(widths).toEqual([240, 350, 900]);
});
/**
* Agents often write a label that starts with a mention or holds an email address. Mermaid 11
* read the text up to the "@" as an edge id, so these diagrams failed to parse.
*/
it.each([
"flowchart LR\n F[@mention in any workspace] --> G[Look up token]",
"flowchart LR\n A[ops@example.com] --> B",
"flowchart LR\n A -->|@user approves| B",
"graph TD\n A(@x) --> B{@x?}",
])("renders a flowchart whose label contains an @: %s", async (source) => {
const frame = await mountRuntime();
const result = await render(frame, { revision: 1, source });
expect(result).toMatchObject({ type: "rendered", revision: 1, source });
});
it("still renders a flowchart edge id", async () => {
const frame = await mountRuntime();
const source = "flowchart LR\n A[Start] e1@--> B[End]";
const result = await render(frame, { revision: 1, source });
expect(result).toMatchObject({ type: "rendered", revision: 1, source });
});
it("coalesces queued input and never reports an obsolete result", async () => {
const frame = await mountRuntime();
const obsoleteSource = `flowchart TD\n${Array.from({ length: 250 }, (_, index) => `A${index} --> A${index + 1}`).join("\n")}`;
@@ -1,103 +0,0 @@
// @vitest-environment jsdom
import type { ReactNode } from "react";
import { cleanup, renderHook, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, expect, it } from "vitest";
import type { FileReadResult } from "@getpaseo/client/internal/daemon-client";
import { __setAttachmentStoreForTests } from "@/attachments/store";
import type { AttachmentStore } from "@/attachments/types";
import { useMarkdownSource, type MarkdownImageContext } from "./images";
import { PENDING_MARKDOWN_IMAGE } from "./source";
const memoryStore: AttachmentStore = {
storageType: "web-indexeddb",
async save(input) {
return {
id: input.id ?? "att_chart",
mimeType: input.mimeType ?? "image/png",
storageType: "web-indexeddb",
storageKey: input.id ?? "att_chart",
fileName: input.fileName,
createdAt: 1,
};
},
async encodeBase64() {
return "";
},
async resolvePreviewUrl() {
return "blob:chart";
},
async releasePreviewUrl() {},
async delete() {},
async garbageCollect() {},
};
function createHostFiles() {
const reads: { cwd: string; path: string }[] = [];
return {
reads,
async readFile(cwd: string, path: string): Promise<FileReadResult> {
reads.push({ cwd, path });
return {
kind: "image",
path,
mime: "image/png",
size: 4,
modifiedAt: "2026-11-18T00:00:00.000Z",
bytes: new Uint8Array([1, 2, 3, 4]),
};
},
};
}
beforeEach(() => {
__setAttachmentStoreForTests(memoryStore);
});
afterEach(() => {
cleanup();
__setAttachmentStoreForTests(null);
});
function renderMarkdownSource(text: string, initialProps: MarkdownImageContext) {
// No retries: a failed read settles at once. For a host's Markdown this is the state once the
// retries have run out on a host that is slow to connect.
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
const wrapper = ({ children }: { children: ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
const rendered = renderHook((props: MarkdownImageContext) => useMarkdownSource(text, props), {
wrapper,
initialProps,
});
return { ...rendered, queryClient };
}
it("waits for the host's client before reading a workspace image", async () => {
const context = { serverId: "srv_test", workspaceRoot: "/repo" };
const { result, rerender, queryClient } = renderMarkdownSource("![Chart](chart.png)", {
...context,
client: null,
});
await waitFor(() => {
expect(queryClient.isFetching()).toBe(0);
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe(
"![Chart](<pending>)",
);
});
const files = createHostFiles();
rerender({ ...context, client: files });
await waitFor(() => expect(result.current.imageSources).toEqual({ "blob:chart": "chart.png" }));
expect(files.reads).toEqual([{ cwd: "/repo", path: "chart.png" }]);
});
it("shows the alt text of a file image in Markdown that belongs to no host", async () => {
const { result } = renderMarkdownSource("![Chart](/tmp/chart.png)", {});
await waitFor(() =>
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe("Chart"),
);
});
@@ -81,10 +81,7 @@ export function useMarkdownSource(
const results = useFetchQueries(
acquisitions.map((acquisition, index) => ({
queryKey: ["markdownImage", acquisition?.key ?? sources[index]],
// A host that hasn't connected yet has no client. Its images stay pending until it does: the
// key doesn't change when the client arrives, so a read that already failed would not run
// again. Markdown with no host has no client to wait for and falls back to its alt text.
enabled: acquisition !== null && (context.client != null || !context.serverId),
enabled: acquisition !== null,
immutableWhen: () => true,
dataShape: "value",
gcTime: 0,
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/cli",
"version": "0.16.2",
"version": "0.16.1",
"description": "Paseo CLI - control your AI coding agents from the command line",
"license": "Apache-2.0",
"bin": {
@@ -29,9 +29,9 @@
},
"dependencies": {
"@clack/prompts": "^1.0.0",
"@getpaseo/client": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/server": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"@getpaseo/server": "0.16.1",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"mime-types": "^2.1.35",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/client",
"version": "0.16.2",
"version": "0.16.1",
"description": "Paseo client SDK package",
"license": "Apache-2.0",
"files": [
@@ -49,8 +49,8 @@
"measure:diff-materialization": "tsx scripts/measure-diff-materialization.ts"
},
"dependencies": {
"@getpaseo/protocol": "0.16.2",
"@getpaseo/relay": "0.16.2",
"@getpaseo/protocol": "0.16.1",
"@getpaseo/relay": "0.16.1",
"ws": "^8.20.0",
"zod": "^4.4.3"
},
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/desktop",
"version": "0.16.2",
"version": "0.16.1",
"private": true,
"description": "Paseo desktop app (Electron wrapper)",
"homepage": "https://paseo.sh",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/expo-two-way-audio",
"version": "0.16.2",
"version": "0.16.1",
"description": "Native module for two way audio streaming",
"keywords": [
"ExpoTwoWayAudio",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/highlight",
"version": "0.16.2",
"version": "0.16.1",
"license": "Apache-2.0",
"files": [
"dist",
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/plugin",
"version": "0.16.2",
"version": "0.16.1",
"description": "Paseo plugin SDK package",
"license": "Apache-2.0",
"files": [
@@ -78,8 +78,8 @@
"use-sync-external-store": "^1.6.0"
},
"devDependencies": {
"@getpaseo/client": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"@types/node": "^20.9.0",
"@types/react": "~19.2.0",
"react": "19.2.3",
@@ -89,8 +89,8 @@
"zod": "^4.4.3"
},
"peerDependencies": {
"@getpaseo/client": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"react": ">=19.1.0 <20",
"react-native": ">=0.81.5",
"zod": "^4.4.3"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/protocol",
"version": "0.16.2",
"version": "0.16.1",
"description": "Paseo shared protocol schemas and wire types",
"license": "Apache-2.0",
"files": [
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/relay",
"version": "0.16.2",
"version": "0.16.1",
"description": "Paseo relay for bridging daemon and client connections",
"license": "Apache-2.0",
"files": [
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/server",
"version": "0.16.2",
"version": "0.16.1",
"description": "Paseo backend server",
"license": "Apache-2.0",
"files": [
@@ -109,11 +109,11 @@
"@agentclientprotocol/sdk": "^0.17.1",
"@anthropic-ai/claude-agent-sdk": "0.3.326",
"@anthropic-ai/sdk": "^0.104.2",
"@getpaseo/client": "0.16.2",
"@getpaseo/highlight": "0.16.2",
"@getpaseo/plugin": "0.16.2",
"@getpaseo/protocol": "0.16.2",
"@getpaseo/relay": "0.16.2",
"@getpaseo/client": "0.16.1",
"@getpaseo/highlight": "0.16.1",
"@getpaseo/plugin": "0.16.1",
"@getpaseo/protocol": "0.16.1",
"@getpaseo/relay": "0.16.1",
"@isaacs/ttlcache": "^2.1.4",
"@modelcontextprotocol/sdk": "1.29.0",
"@opencode-ai/sdk": "1.14.46",
@@ -8,6 +8,10 @@ import { AgentManager, type AgentManagerEvent } from "./agent-manager.js";
import { AGENT_STREAM_COALESCE_DEFAULT_WINDOW_MS } from "./agent-stream-coalescer.js";
import { limitAgentTimelineItemContent } from "./agent-timeline-content.js";
import type { AgentTimelineRow } from "./agent-timeline-store-types.js";
import { OmpAgentClient } from "./providers/omp/agent.js";
import { FakeOmp } from "./providers/omp/test-utils/fake-omp.js";
import { PiRpcAgentClient } from "./providers/pi/agent.js";
import { FakePi } from "./providers/pi/test-utils/fake-pi.js";
import { projectTimelineRows } from "./timeline-projection.js";
import type {
AgentCapabilityFlags,
@@ -394,6 +398,235 @@ afterEach(() => {
vi.useRealTimers();
});
describe("live notification turns", () => {
test.each([
{ sequence: "while idle", agentStarted: false, emptyCycle: false },
{ sequence: "between agent_start and turn_start", agentStarted: true, emptyCycle: false },
{ sequence: "after an empty cycle", agentStarted: true, emptyCycle: true },
])(
"keeps OMP replies in separate turns with a notice $sequence",
async ({ agentStarted, emptyCycle }) => {
const runtime = new FakeOmp();
const provider = "omp";
const logger = createTestLogger();
const manager = new AgentManager({
clients: {
omp: new OmpAgentClient({
runtime,
logger,
runtimeSettings: { command: { mode: "replace", argv: [process.execPath] } },
}),
},
logger,
});
const workdir = mkdtempSync(join(tmpdir(), "omp-live-turns-"));
const events: AgentManagerEvent[] = [];
manager.subscribe((event) => events.push(event), { replayState: false });
const { id } = await manager.createAgent({ provider, cwd: workdir }, undefined, {
workspaceId: undefined,
});
try {
const session = runtime.latestSession();
const finishReply = async (text: string) => {
const completed = () =>
getStreamEvents(events, id).filter(
(event) => event.type === "agent_stream" && event.event.type === "turn_completed",
).length;
const before = completed();
session.streamAssistantText(text, text);
session.finishTurn({ role: "assistant", content: [] });
await vi.waitFor(() => {
expect(completed()).toBe(before + 1);
});
};
const notice = (message: string) => {
session.emit({ type: "extension_ui_request", id: message, method: "notify", message });
};
session.beginTurn();
await finishReply("First reply");
if (agentStarted) session.emit({ type: "agent_start" });
if (emptyCycle) session.emit({ type: "agent_end", messages: [] });
notice("Idle notice");
session.beginTurn();
session.acceptCustomMessage("<system-notice>Completion</system-notice>");
notice("Running notice");
await finishReply("Second reply");
const page = await manager.fetchTimeline(id, { wholeTurns: true, limit: 0 });
const ids = page.rows.map((row) => row.turnId);
expect(
page.rows.map(({ item }) => {
if (item.type === "assistant_message") return item.text;
if (item.type === "notification") return item.message;
return item.type;
}),
).toEqual(["First reply", "Idle notice", "Completion", "Running notice", "Second reply"]);
const [first, idle, wake] = ids;
expect(ids).toEqual([
expect.any(String),
expect.any(String),
expect.any(String),
wake,
wake,
]);
expect(new Set([first, idle, wake]).size).toBe(3);
expect(
getTimelineStreamEvents(events, id).map((event) =>
event.type === "agent_stream" && event.event.type === "timeline"
? event.event.turnId
: null,
),
).toEqual(ids);
expect(
(await manager.fetchTimeline(id, { wholeTurns: true, limit: 1 })).rows.map(
(row) => row.turnId,
),
).toEqual([wake, wake, wake]);
} finally {
await manager.closeAgent(id);
rmSync(workdir, { recursive: true, force: true });
}
},
);
test("keeps a Claude completion with the run it wakes after an independent notice", async () => {
const harness = createHarness({ provider: "claude" });
try {
const { agentId, session } = await createManagedSession(harness);
session.pushEvent(assistant("First reply", "claude", "first"));
session.pushEvent(
timelineEvent({ type: "notification", level: "info", message: "Idle" }, "claude"),
);
const completion = { ...toolCall({ status: "completed" }), name: "task_notification" };
session.pushEvent(
timelineEvent({ ...completion, callId: "stopped-task" }, "claude", "stopped"),
);
session.pushEvent(timelineEvent(completion, "claude", "wake"));
session.pushEvent({ type: "turn_started", provider: "claude", turnId: "wake" });
session.pushEvent(assistant("Second reply", "claude", "wake"));
session.pushEvent({ type: "turn_completed", provider: "claude", turnId: "wake" });
await vi.waitFor(() => {
expect(getStreamEvents(harness.events, agentId).at(-1)).toMatchObject({
event: { type: "turn_completed", turnId: "wake" },
});
});
const page = await harness.manager.fetchTimeline(agentId, { wholeTurns: true, limit: 0 });
expect(page.rows.map((row) => row.turnId)).toEqual([
"first",
expect.any(String),
"stopped",
"wake",
"wake",
]);
expect(page.rows[1]?.turnId).not.toBe("first");
expect(page.rows[1]?.turnId).not.toBe("wake");
expect(
getStreamEvents(harness.events, agentId).filter(
(event) => event.type === "agent_stream" && event.event.type === "turn_started",
),
).toEqual([
expect.objectContaining({
event: { type: "turn_started", provider: "claude", turnId: "wake" },
}),
]);
expect(
(await harness.manager.fetchTimeline(agentId, { wholeTurns: true, limit: 1 })).rows.map(
(row) => row.item,
),
).toEqual([completion, { type: "assistant_message", text: "Second reply" }]);
} finally {
harness.cleanup();
}
});
test("an OMP runtime notice during a foreground turn reaches the run caller", async () => {
const runtime = new FakeOmp();
const logger = createTestLogger();
const manager = new AgentManager({
clients: {
omp: new OmpAgentClient({
runtime,
logger,
runtimeSettings: { command: { mode: "replace", argv: [process.execPath] } },
}),
},
logger,
});
const workdir = mkdtempSync(join(tmpdir(), "omp-foreground-notice-"));
const agent = await manager.createAgent({ provider: "omp", cwd: workdir }, undefined, {
workspaceId: undefined,
});
const session = runtime.latestSession();
try {
const result = manager.runAgent(agent.id, "Work");
await vi.waitFor(() => expect(session.prompts).toHaveLength(1));
session.beginTurn();
session.emit({
type: "notice",
level: "info",
message: "Working",
});
session.streamAssistantText("Done");
session.finishTurn({ role: "assistant", content: [] });
const item = { type: "notification", level: "info", message: "Working" };
expect((await result).timeline).toContainEqual(item);
const rows = (await manager.fetchTimeline(agent.id, { wholeTurns: true, limit: 0 })).rows;
expect(rows.find((row) => row.item.type === "notification")?.turnId).toEqual(
expect.any(String),
);
expect(rows.find((row) => row.item.type === "notification")?.turnId).toEqual(
rows.find((row) => row.item.type === "assistant_message")?.turnId,
);
} finally {
await manager.closeAgent(agent.id);
rmSync(workdir, { recursive: true, force: true });
}
});
test("an idle Pi UI notice gets its own turn without starting a run", async () => {
const runtime = new FakePi();
const logger = createTestLogger();
const manager = new AgentManager({
clients: {
pi: new PiRpcAgentClient({
runtime,
logger,
runtimeSettings: { command: { mode: "replace", argv: [process.execPath] } },
}),
},
logger,
});
const workdir = mkdtempSync(join(tmpdir(), "pi-idle-notice-"));
const events: AgentManagerEvent[] = [];
manager.subscribe((event) => events.push(event), { replayState: false });
const { id } = await manager.createAgent({ provider: "pi", cwd: workdir }, undefined, {
workspaceId: undefined,
});
try {
runtime.latestSession().emit({
type: "extension_ui_request",
id: "notice",
method: "notify",
message: "Idle",
});
await vi.waitFor(() => expect(getTimelineStreamEvents(events, id)).toHaveLength(1));
const { rows } = await manager.fetchTimeline(id, { wholeTurns: true, limit: 1 });
const item = { type: "notification", level: "info", message: "Idle" };
expect(rows).toEqual([expect.objectContaining({ item, turnId: expect.any(String) })]);
expect(getStreamEvents(events, id)).toEqual([
expect.objectContaining({
event: { type: "timeline", provider: "pi", item, turnId: rows[0]?.turnId },
}),
]);
expect(manager.getAgent(id)?.lifecycle).toBe("idle");
} finally {
await manager.closeAgent(id);
rmSync(workdir, { recursive: true, force: true });
}
});
});
describe("target coalesced behavior", () => {
test("bounds tool output before persisting and streaming it", async () => {
const harness = createHarness();
@@ -606,9 +606,11 @@ function attachManagedTurnIdentity(
return turnId ? { event: { ...event, turnId }, turnId } : { event, turnId };
}
case "timeline": {
// Live provider items belong to the foreground turn that owns their dispatch.
// Provider history deliberately keeps absent IDs because it has no daemon turn identity.
const turnId = agent.activeForegroundTurnId ?? agent.activeTurnId ?? undefined;
// A notice with no open run is a display turn of its own.
const turnId =
agent.activeForegroundTurnId ??
agent.activeTurnId ??
(event.item.type === "notification" ? randomUUID() : undefined);
return turnId ? { event: { ...event, turnId }, turnId } : { event, turnId };
}
default:
@@ -4817,6 +4819,10 @@ export class AgentManager {
this.publishBackgroundWork(agent.id, items);
return;
}
// Resolve notice membership before selecting the foreground run's waiters.
if (event.type === "timeline" && event.item.type === "notification") {
event = attachManagedTurnIdentity(agent, event, false).event;
}
const turnId = getAgentStreamEventTurnId(event);
const matchingWaiters = this.runs.getMatchingWaiters(agent, turnId);
this.logger.trace(
@@ -605,8 +605,6 @@ class ProviderRuntimeSession {
>();
private readonly activeTurnIds = new Set<string>();
private terminal = false;
// The provider ended this session with session.closed, so it has nothing left to close.
private closedByProvider = false;
private closePromise: Promise<void> | null = null;
config: ProviderConfigState = { models: [], modes: [], thinkingOptions: [] };
commands: Array<{ name: string; description: string; argumentHint?: string }> = [];
@@ -725,7 +723,7 @@ class ProviderRuntimeSession {
async close(): Promise<void> {
this.history.length = 0;
if (this.restoration === "parent" || this.closedByProvider) {
if (this.restoration === "parent") {
this.runtime.removeSession(this.id, this.providerSessionId);
return;
}
@@ -790,7 +788,6 @@ class ProviderRuntimeSession {
return;
}
if (event.type === "session.runtime_failed" || event.type === "session.closed") {
if (event.type === "session.closed") this.closedByProvider = true;
if (this.terminal) return;
this.terminal = true;
this.publish(event);
@@ -1583,7 +1583,6 @@ export class OmpAgentSession implements AgentSession {
this.emit({
type: "timeline",
provider: this.provider,
turnId: this.currentTurnIdForEvent(),
item: {
type: "notification",
level:
@@ -136,94 +136,6 @@ describe("OMP rpc-ui permission mapper", () => {
).toEqual({ kind: "passthrough" });
});
test("maps approvals that offer session and grant choices beside the one-call approval", () => {
const session = classifyOmpRpcUiPermissionRequest({
type: "extension_ui_request",
id: "session-write",
method: "select",
title: "Allow tool: write\nPath: cap.txt\nContent:\nhello",
options: ["Approve", "Approve write for this session", "Deny"],
});
if (session.kind !== "tool") throw new Error("Expected session approval to map as a tool");
expect(
session.request.actions?.map((action) => [action.id, action.label, action.behavior]),
).toEqual([
["deny", "Deny", "deny"],
["approve", "Approve", "allow"],
["approve-option-0", "Approve write for this session", "allow"],
]);
expect(buildOmpRpcUiPermissionResponse(session.request, { behavior: "allow" })).toEqual({
value: "Approve",
});
expect(
buildOmpRpcUiPermissionResponse(session.request, {
behavior: "allow",
selectedActionId: "approve-option-0",
}),
).toEqual({ value: "Approve write for this session" });
expect(
buildOmpRpcUiPermissionResponse(session.request, {
behavior: "deny",
selectedActionId: "approve-option-0",
}),
).toEqual({ value: "Deny" });
const grants = classifyOmpRpcUiPermissionRequest({
type: "extension_ui_request",
id: "grant-edit",
method: "select",
title: "Allow tool: edit\nFile: src/a.ts",
options: ["Approve File", "Always Approve File", "Approve Once", "Deny"],
});
if (grants.kind !== "tool") throw new Error("Expected grant approval to map as a tool");
expect(buildOmpRpcUiPermissionResponse(grants.request, { behavior: "allow" })).toEqual({
value: "Approve Once",
});
expect(
buildOmpRpcUiPermissionResponse(grants.request, {
behavior: "allow",
selectedActionId: "approve-option-1",
}),
).toEqual({ value: "Always Approve File" });
});
test("allows one call when a grant is labeled Approve beside Approve Once", () => {
// OMP names the one-call choice "Approve Once" whenever it offers grants. A grant for a
// target that is not a file is then labeled "Approve", which remembers more than one call.
const grants = classifyOmpRpcUiPermissionRequest({
type: "extension_ui_request",
id: "grant-target",
method: "select",
title: "Allow tool: edit\nFile: src/a.ts",
options: ["Approve", "Always Approve", "Approve Once", "Deny"],
});
if (grants.kind !== "tool") throw new Error("Expected grant approval to map as a tool");
expect(buildOmpRpcUiPermissionResponse(grants.request, { behavior: "allow" })).toEqual({
value: "Approve Once",
});
});
test("passes through selects whose extra choices are not approvals", () => {
expect(
classifyOmpRpcUiPermissionRequest({
type: "extension_ui_request",
id: "odd-choice",
method: "select",
title: "Allow tool: bash\nCommand: echo hi",
options: ["Approve", "Edit command", "Deny"],
}),
).toEqual({ kind: "passthrough" });
expect(
classifyOmpRpcUiPermissionRequest({
type: "extension_ui_request",
id: "deny-first",
method: "select",
title: "Allow tool: bash\nCommand: echo hi",
options: ["Deny", "Approve"],
}),
).toEqual({ kind: "passthrough" });
});
test("responds to tool approvals with exact select values", () => {
const request = toolApproval("bash");
@@ -10,13 +10,8 @@ import type { OmpRuntimeEvent } from "./rpc-types.js";
const OMP_PROVIDER = "omp";
const OMP_RPC_UI_TOOL_APPROVAL_METADATA = "omp_rpc_ui_tool_approval";
const TOOL_APPROVAL_APPROVE_VALUE = "Approve";
// OMP labels the approve-this-call choice "Approve Once" when it also offers grants that remember
// more. A grant can then be labeled "Approve", so "Approve" is the one-call choice only without it.
const TOOL_APPROVAL_ONCE_VALUE = "Approve Once";
const TOOL_APPROVAL_DENY_VALUE = "Deny";
// Session and grant choices OMP offers beside the one-call approval, e.g. "Approve write for this session".
const TOOL_APPROVAL_EXTRA_CHOICE = /^(?:Always )?Approve\b/;
const TOOL_APPROVAL_EXTRA_ACTION_PREFIX = "approve-option-";
const TOOL_APPROVAL_OPTIONS = [TOOL_APPROVAL_APPROVE_VALUE, TOOL_APPROVAL_DENY_VALUE] as const;
const TOOL_TITLE_PREFIX = "Allow tool: ";
export type OmpRpcUiPermissionClassification =
@@ -30,12 +25,6 @@ interface ToolApprovalDescriptor {
args: AgentMetadata;
detail: ToolCallDetail;
description?: string;
choices: ToolApprovalChoices;
}
interface ToolApprovalChoices {
approveValue: string;
extraValues: string[];
}
export function classifyOmpRpcUiPermissionRequest(
@@ -48,13 +37,6 @@ export function classifyOmpRpcUiPermissionRequest(
}
const provider = options.provider ?? OMP_PROVIDER;
const { approveValue, extraValues } = descriptor.choices;
const extraActions = extraValues.map((value, index) => ({
id: `${TOOL_APPROVAL_EXTRA_ACTION_PREFIX}${index}`,
label: value,
behavior: "allow" as const,
variant: "secondary" as const,
}));
return {
kind: "tool",
request: {
@@ -75,18 +57,17 @@ export function classifyOmpRpcUiPermissionRequest(
},
{
id: "approve",
label: approveValue,
label: TOOL_APPROVAL_APPROVE_VALUE,
behavior: "allow",
variant: "primary",
},
...extraActions,
],
metadata: {
extensionUiMethod: "select",
toolApproval: OMP_RPC_UI_TOOL_APPROVAL_METADATA,
toolName: descriptor.toolName,
toolArgs: descriptor.args,
approveValue,
approveValue: TOOL_APPROVAL_APPROVE_VALUE,
denyValue: TOOL_APPROVAL_DENY_VALUE,
},
},
@@ -114,23 +95,13 @@ export function buildOmpRpcUiPermissionResponse(
const approveValue = readString(request.metadata.approveValue) ?? TOOL_APPROVAL_APPROVE_VALUE;
const denyValue = readString(request.metadata.denyValue) ?? TOOL_APPROVAL_DENY_VALUE;
if (response.behavior !== "allow") {
return { value: denyValue };
}
// Each extra choice's action label is the exact select value OMP offered.
const selectedExtraChoice = request.actions?.find(
(action) =>
action.id === response.selectedActionId &&
action.id.startsWith(TOOL_APPROVAL_EXTRA_ACTION_PREFIX),
);
return { value: selectedExtraChoice?.label ?? approveValue };
return { value: response.behavior === "allow" ? approveValue : denyValue };
}
function parseToolApprovalDescriptor(
event: ExtensionUiRequestEvent,
): ToolApprovalDescriptor | null {
const choices = event.method === "select" ? readToolApprovalChoices(event.options) : null;
if (!choices) {
if (event.method !== "select" || !hasExactToolApprovalOptions(event.options)) {
return null;
}
const title = readString(event.title);
@@ -147,15 +118,6 @@ function parseToolApprovalDescriptor(
const body = firstLineBreak < 0 ? "" : title.slice(firstLineBreak).replace(/^\r?\n/, "");
const bodyLines = body.split(/\r?\n/);
const parsed = parseToolApprovalBody(rawToolName, body, bodyLines);
return parsed ? { ...parsed, choices } : null;
}
function parseToolApprovalBody(
rawToolName: string,
body: string,
bodyLines: string[],
): Omit<ToolApprovalDescriptor, "choices"> | null {
switch (rawToolName) {
case "bash":
return parseBashApproval(body);
@@ -168,7 +130,7 @@ function parseToolApprovalBody(
}
}
function parseBashApproval(body: string): Omit<ToolApprovalDescriptor, "choices"> | null {
function parseBashApproval(body: string): ToolApprovalDescriptor | null {
const match = /(?:^|\r?\n)[\t ]*Command:[\t ]?(.*)$/s.exec(body);
const command = match?.[1];
if (!command) {
@@ -182,7 +144,7 @@ function parseBashApproval(body: string): Omit<ToolApprovalDescriptor, "choices"
};
}
function parseEditApproval(lines: string[]): Omit<ToolApprovalDescriptor, "choices"> | null {
function parseEditApproval(lines: string[]): ToolApprovalDescriptor | null {
const filePath = readPrefixedValue(lines, "File:");
if (!filePath) {
return null;
@@ -195,7 +157,7 @@ function parseEditApproval(lines: string[]): Omit<ToolApprovalDescriptor, "choic
};
}
function parseWriteApproval(lines: string[]): Omit<ToolApprovalDescriptor, "choices"> | null {
function parseWriteApproval(lines: string[]): ToolApprovalDescriptor | null {
const pathLineIndex = lines.findIndex((line) => line.trim().startsWith("Path:"));
if (pathLineIndex < 0) {
return null;
@@ -220,28 +182,12 @@ function parseWriteApproval(lines: string[]): Omit<ToolApprovalDescriptor, "choi
};
}
function readToolApprovalChoices(options: unknown): ToolApprovalChoices | null {
if (!Array.isArray(options) || !options.every((option) => typeof option === "string")) {
return null;
}
const labels = options as string[];
if (
labels.at(-1) !== TOOL_APPROVAL_DENY_VALUE ||
labels.indexOf(TOOL_APPROVAL_DENY_VALUE) !== labels.length - 1
) {
return null;
}
const approveValue = [TOOL_APPROVAL_ONCE_VALUE, TOOL_APPROVAL_APPROVE_VALUE].find((value) =>
labels.includes(value),
function hasExactToolApprovalOptions(options: unknown): boolean {
return (
Array.isArray(options) &&
options.length === TOOL_APPROVAL_OPTIONS.length &&
options.every((option, index) => option === TOOL_APPROVAL_OPTIONS[index])
);
if (!approveValue) {
return null;
}
const extraValues = labels.slice(0, -1).filter((label) => label !== approveValue);
if (!extraValues.every((label) => TOOL_APPROVAL_EXTRA_CHOICE.test(label))) {
return null;
}
return { approveValue, extraValues };
}
function readPrefixedValue(lines: readonly string[], prefix: string): string | null {
@@ -2074,7 +2074,6 @@ export class PiRpcAgentSession implements AgentSession {
this.emit({
type: "timeline",
provider: this.provider,
turnId: this.currentTurnIdForEvent(),
item: {
type: "notification",
level: toNotificationLevel(event.notifyType),
@@ -1,193 +0,0 @@
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { expect, onTestFinished, test } from "vitest";
import { DaemonClient } from "../test-utils/daemon-client.js";
import { createTestPaseoDaemon } from "../test-utils/paseo-daemon.js";
import { resolveDaemonVersion } from "../daemon-version.js";
const PROVIDER_ID = "closing-provider";
const PLUGIN_ID = "closing-provider-plugin";
// How the provider ends the session that ran the first turn.
type CloseMode =
// The first turn completes, then the provider closes the session on its own.
| "after-turn"
// The first turn fails and the provider closes the session with the failure.
| "after-failed-turn"
// The provider answers the second prompt by closing the session.
| "on-next-prompt";
async function createClosingProviderPlugin(root: string, mode: CloseMode): Promise<string> {
const directory = path.join(root, "plugin");
await mkdir(directory, { recursive: true });
await writeFile(
path.join(directory, "paseo-plugin.json"),
JSON.stringify({
id: PLUGIN_ID,
requirements: { paseo: `>=${resolveDaemonVersion(import.meta.url)}` },
}),
);
await writeFile(
path.join(directory, "index.server.ts"),
`import type {
ProviderEvent,
ProviderInput,
ProviderRegistration,
} from "@getpaseo/plugin/server/provider";
const CAPABILITIES = ["prompt.message", "session.persistence"];
const MODE = ${JSON.stringify(mode)};
const provider: ProviderRegistration = {
id: ${JSON.stringify(PROVIDER_ID)},
label: "Closing provider",
async connect() {
let listener: ((event: ProviderEvent) => void) | null = null;
const emit = (event: ProviderEvent) => listener?.(event);
let turn = 0;
const closed = new Set<string>();
return {
version: 1,
capabilities: CAPABILITIES,
async send(input: ProviderInput) {
if (input.type === "catalog") {
emit({
type: "catalog",
requestId: input.requestId,
catalog: {
models: [{ id: "closing-model", label: "Closing model" }],
modes: [],
thinkingOptions: [],
defaultModel: "closing-model",
},
});
return;
}
if (input.type === "session.open") {
emit({
type: "session.opened",
requestId: input.requestId,
sessionId: input.sessionId,
capabilities: CAPABILITIES,
restoration: "core",
persistence: { version: 1, data: { token: "root" } },
cwd: input.config.cwd,
});
emit({ type: "session.ready", requestId: input.requestId, sessionId: input.sessionId });
return;
}
if (input.type === "session.prompt") {
turn += 1;
if (MODE === "on-next-prompt" && turn === 2) {
closed.add(input.sessionId);
emit({ type: "session.closed", sessionId: input.sessionId });
return;
}
const turnId = "turn-" + turn;
emit({
type: "session.prompt_result",
sessionId: input.sessionId,
clientMessageId: input.prompt.clientMessageId,
result: { type: "turn", turnId },
});
emit({ type: "session.turn", sessionId: input.sessionId, turnId, state: "started" });
if (MODE === "after-failed-turn" && turn === 1) {
emit({ type: "session.turn", sessionId: input.sessionId, turnId, state: "failed", error: { message: "Provider turn failed" } });
emit({ type: "session.closed", sessionId: input.sessionId, error: { message: "Provider turn failed" } });
return;
}
emit({
type: "timeline.item",
sessionId: input.sessionId,
item: { type: "assistant_message", id: "answer-" + turn, text: "Done " + turn },
});
emit({ type: "session.turn", sessionId: input.sessionId, turnId, state: "completed" });
if (MODE === "after-turn" && turn === 1) {
emit({ type: "session.closed", sessionId: input.sessionId });
}
return;
}
if (input.type === "session.close") {
if (!closed.has(input.sessionId)) emit({ type: "session.closed", sessionId: input.sessionId });
}
if ("requestId" in input) {
emit({ type: "request.completed", requestId: input.requestId });
}
},
onEvent(next: (event: ProviderEvent) => void) {
listener = next;
return () => {
if (listener === next) listener = null;
};
},
async close() {},
};
},
};
export default function contribute(server: { registerProvider(p: ProviderRegistration): void }) {
server.registerProvider(provider);
return () => undefined;
}`,
);
return directory;
}
test.each<CloseMode>(["after-turn", "after-failed-turn", "on-next-prompt"])(
"an agent whose provider session closed (%s) runs its next prompt",
async (mode) => {
const root = await mkdtemp(path.join(tmpdir(), "plugin-provider-closed-session-"));
onTestFinished(() =>
rm(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }),
);
const pluginDirectory = await createClosingProviderPlugin(root, mode);
const workspace = path.join(root, "workspace");
await mkdir(workspace, { recursive: true });
const daemon = await createTestPaseoDaemon({
paseoHomeRoot: path.join(root, "daemon"),
staticDir: path.join(root, "static"),
pluginsEnabled: true,
plugins: {
[PLUGIN_ID]: { source: "directory", path: pluginDirectory, enabled: true },
},
});
const client = new DaemonClient({
url: `ws://127.0.0.1:${daemon.port}/ws`,
appVersion: "0.9.1",
});
onTestFinished(async () => {
await client.close();
await daemon.close();
});
await client.connect();
await client.fetchAgents({ subscribe: {} });
const agent = await client.createAgent({
provider: PROVIDER_ID,
model: "closing-model",
cwd: workspace,
title: "Closing provider agent",
});
await client.sendMessage(agent.id, "first");
await client.waitForFinish(agent.id, 30_000);
// Before the fix, reopening tried to close the session the provider had already
// closed, failed, and rejected this send with "Provider session <id> is stale".
await client.sendMessage(agent.id, "second");
expect((await client.waitForFinish(agent.id, 30_000)).status).toBe("idle");
const timeline = await client.fetchAgentTimeline(agent.id, {
direction: "tail",
limit: 0,
projection: "canonical",
});
const text = JSON.stringify(timeline.entries);
// In on-next-prompt the provider closed the session on prompt 2, so the reopened
// session answers the retried prompt as its third.
expect(text).toContain(mode === "on-next-prompt" ? "Done 3" : "Done 2");
expect(text).not.toMatch(/Provider session \S+ (closed|is stale)/);
},
60_000,
);
@@ -587,29 +587,6 @@ describe("WorkspaceGitServiceImpl", () => {
await service.dispose();
});
test("a client reconnecting within the release grace reuses the warm target", async () => {
const getCheckoutStatus = vi.fn(buildDefaultTestServiceDeps().getCheckoutStatus);
const service = createService({ getCheckoutStatus });
try {
const first = service.registerWorkspace({ cwd: REPO_CWD }, () => {});
const snapshot = await service.getSnapshot(REPO_CWD);
await waitForObservationToSettle(service, 1);
first.unsubscribe();
expect(service.getMetrics().workspaceTargetCount).toBe(1);
const reads = getCheckoutStatus.mock.calls.length;
const second = service.registerWorkspace({ cwd: REPO_CWD }, () => {});
await expect(service.getSnapshot(REPO_CWD)).resolves.toEqual(snapshot);
expect(getCheckoutStatus).toHaveBeenCalledTimes(reads);
second.unsubscribe();
await vi.advanceTimersByTimeAsync(90_000);
expect(service.getMetrics().workspaceTargetCount).toBe(0);
} finally {
await service.dispose();
}
});
test("onSnapshotUpdated delivers without workspace subscribers and can unsubscribe", async () => {
const service = createService();
const snapshots: WorkspaceGitRuntimeSnapshot[] = [];
@@ -646,7 +623,6 @@ describe("WorkspaceGitServiceImpl", () => {
const service = new WorkspaceGitServiceImpl({
logger: createLogger() as unknown as pino.Logger,
paseoHome: "/tmp/paseo-test",
releaseGraceMs: 0,
deps: {
...buildDefaultTestServiceDeps(),
getPullRequestStatus: async () => {
@@ -81,9 +81,6 @@ import { checkoutLiteFromGitSnapshot } from "./workspace-registry-model.js";
import { createWatcherLivenessCanary } from "./watcher-liveness-canary.js";
const WORKSPACE_GIT_WATCH_DEBOUNCE_MS = 1_000;
// A target outlives its last listener this long, so a reconnecting client reuses its snapshot
// and watchers instead of re-reading every checkout.
const WORKSPACE_GIT_RELEASE_GRACE_MS = 90_000;
export const BACKGROUND_GIT_FETCH_INTERVAL_MS = 180_000;
const FETCH_METADATA_ECHO_TTL_MS = 5_000;
export const WORKSPACE_GIT_OBSERVATION_REENSURE_INTERVAL_MS = 60_000;
@@ -444,8 +441,6 @@ interface WorkspaceGitServiceOptions {
worktreesRoot?: string;
fileObserver?: FileObserver;
deps?: Partial<WorkspaceGitServiceDependencies>;
/** How long a workspace target outlives its last listener; 0 releases it immediately. */
releaseGraceMs?: number;
}
class WorkspaceGitServiceDisposedError extends Error {
@@ -468,7 +463,6 @@ interface WorkspaceGitTarget {
gitDirPaths: GitObservationPaths | null;
cwd: string;
listeners: Set<WorkspaceGitListener>;
releaseTimer: NodeJS.Timeout | null;
workingTreeWatchTarget: WorkingTreeWatchTarget | null;
debounceTimer: NodeJS.Timeout | null;
pendingDebounceRequest: WorkspaceGitRefreshRequest | null;
@@ -663,7 +657,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
private readonly logger: pino.Logger;
private readonly paseoHome: string;
private readonly worktreesRoot: string | undefined;
private readonly releaseGraceMs: number;
private readonly fileObserver: FileObserver;
private readonly deps: WorkspaceGitServiceDependencies;
private readonly forgeResolver: ForgeResolver;
@@ -717,7 +710,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
this.logger = options.logger.child({ module: "workspace-git-service" });
this.paseoHome = options.paseoHome;
this.worktreesRoot = options.worktreesRoot;
this.releaseGraceMs = options.releaseGraceMs ?? WORKSPACE_GIT_RELEASE_GRACE_MS;
this.fileObserver = options.fileObserver ?? createFileObserver();
this.deps = resolveWorkspaceGitServiceDeps(
this.fileObserver.subscribe.bind(this.fileObserver),
@@ -741,7 +733,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
this.assertNotDisposed();
const cwd = resolve(params.cwd);
const target = this.ensureWorkspaceTarget(cwd);
this.cancelWorkspaceRelease(target);
target.listeners.add(listener);
if (target.folderMissing) {
void this.resumeWorkspaceIfFolderRestored(target);
@@ -1327,7 +1318,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
gitDirPaths: null,
cwd,
listeners: new Set(),
releaseTimer: null,
workingTreeWatchTarget: null,
debounceTimer: null,
pendingDebounceRequest: null,
@@ -3075,9 +3065,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
if (!target || target.closed || this.workspaceTargets.get(target.cwd) !== target) {
return;
}
if (options.origin === "observation" && this.releaseChangedWarmTarget(target)) {
return;
}
const request = this.buildScheduledRefreshRequest(options);
target.pendingDebounceRequest = this.mergeRefreshRequests(
@@ -3364,9 +3351,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
if (target.closed || this.workspaceTargets.get(target.cwd) !== target) {
return;
}
if (request.origin === "observation" && this.releaseChangedWarmTarget(target)) {
return;
}
try {
await this.requestWorkspaceSnapshot(target, request);
} catch (error) {
@@ -4120,52 +4104,7 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
return;
}
if (this.releaseGraceMs <= 0 || !this.isWorkspaceObservationEstablished(target)) {
this.removeWorkspaceTarget(target);
return;
}
// Keep the snapshot and watchers warm for a reconnecting client; stop forge polling now.
this.stopForgePrStatusPollForTarget(target);
this.cancelWorkspaceRelease(target);
target.releaseTimer = setTimeout(() => {
target.releaseTimer = null;
if (
!target.closed &&
target.listeners.size === 0 &&
this.workspaceTargets.get(target.cwd) === target
) {
this.removeWorkspaceTarget(target);
}
}, this.releaseGraceMs);
target.releaseTimer.unref?.();
}
/** Only a fully watched target stays warm; one still recovering a watcher is released now. */
private isWorkspaceObservationEstablished(target: WorkspaceGitTarget): boolean {
const repoTarget = target.repoGitRoot ? this.repoTargets.get(target.repoGitRoot) : undefined;
return Boolean(
target.latestSnapshot &&
!target.folderMissing &&
target.workingTreeWatchTarget?.subscription &&
repoTarget?.subscription,
);
}
/** A change seen while nobody listens ends the grace: the next consumer re-reads, nobody pays now. */
private releaseChangedWarmTarget(target: WorkspaceGitTarget): boolean {
if (target.listeners.size > 0 || !target.releaseTimer) {
return false;
}
this.cancelWorkspaceRelease(target);
this.removeWorkspaceTarget(target);
return true;
}
private cancelWorkspaceRelease(target: WorkspaceGitTarget): void {
if (target.releaseTimer) {
clearTimeout(target.releaseTimer);
target.releaseTimer = null;
}
}
private removeWorkspaceTarget(target: WorkspaceGitTarget): void {
@@ -4232,7 +4171,6 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
private closeWorkspaceTarget(target: WorkspaceGitTarget): void {
target.closed = true;
this.cancelWorkspaceRelease(target);
this.stopWorkspaceObservation(target);
target.listeners.clear();
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/website",
"version": "0.16.2",
"version": "0.16.1",
"private": true,
"type": "module",
"scripts": {
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/builtin-plugins",
"version": "0.16.2",
"version": "0.16.1",
"private": true,
"type": "module",
"scripts": {
-6
View File
@@ -86,12 +86,6 @@ const patchedPackages = [
nodeModulesPath: "node_modules/@mattermost/react-native-paste-input",
patchPrefix: "@mattermost+react-native-paste-input+",
},
// Backport of https://github.com/mermaid-js/mermaid/pull/8459 (lexer half): a flowchart label
// with an "@" parses. The patch header has the details. Remove when the app uses mermaid 12.
{
nodeModulesPath: "node_modules/mermaid",
patchPrefix: "mermaid+",
},
{
nodeModulesPath: "packages/server/node_modules/@opencode-ai/sdk",
patchPrefix: "@opencode-ai+sdk+",