mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-19 23:05:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e0af1cdff | ||
|
|
7aa42ea437 | ||
|
|
d016bf0b44 | ||
|
|
b93afb9156 | ||
|
|
b60f3d26aa | ||
|
|
bcf52f93b1 | ||
|
|
d8c98400fb | ||
|
|
77392d3c1b | ||
|
|
8edccf0503 | ||
|
|
ac633eb096 | ||
|
|
25ff8adf06 | ||
|
|
09a15abb06 | ||
|
|
81fb9c03f6 |
@@ -1,5 +1,26 @@
|
||||
# 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
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# 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
|
||||
|
||||
### 修复
|
||||
|
||||
@@ -65,9 +65,13 @@ Initialization timeouts guard lack of catch-up progress, not the full multi-page
|
||||
|
||||
Opening or resuming an agent fetches the latest available turns with a soft target of 40
|
||||
projected items. Backward pages and prompt-jump windows also include whole turns, including
|
||||
all currently available rows of an active run. There is no per-turn cap: a large run can
|
||||
exceed the target. Local history mounting uses the same boundaries so revealing older rows
|
||||
does not change the collapse state of a turn already displayed.
|
||||
all currently available rows of an active run. A large run can exceed the target. For a paged
|
||||
request whose complete-turn reply cannot fit the wire message limit, the daemon falls back to
|
||||
item pages with continuation cursors so the rest remains reachable. A tail page starts at the first row of
|
||||
the source span it reaches. When one item's updates span the turn up to its last row and more than
|
||||
the limit, no smaller tail page exists and the request fails with an error. Local history mounting uses
|
||||
turn boundaries so revealing older rows does not change the collapse state of a turn already
|
||||
displayed.
|
||||
|
||||
`wholeTurns` is a preference negotiated once at the client fetch boundary. Hosts advertising
|
||||
`features.wholeTurnTimeline` receive it; other hosts receive the existing item-based request.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
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
@@ -1 +1 @@
|
||||
sha256-k7+5S/4tyAmHdZmUdhpuZ7GOc7hp9cG8wUBFdJI32ng=
|
||||
sha256-yLTaVMgu3tc/dgngJ7RP0htJcWE0ZtQ4mouypevyv0s=
|
||||
|
||||
Generated
+28
-28
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "paseo",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
@@ -37468,7 +37468,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -39637,13 +39637,13 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/server": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/server": "0.16.2",
|
||||
"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.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/relay": "0.16.2",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
@@ -39906,7 +39906,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"version": "0.16.2",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -40195,7 +40195,7 @@
|
||||
},
|
||||
"packages/highlight": {
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -40225,7 +40225,7 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@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.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"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.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"semver": "^7.8.5",
|
||||
@@ -40295,7 +40295,7 @@
|
||||
},
|
||||
"packages/relay": {
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@noble/ciphers": "^2.4.0",
|
||||
@@ -40517,17 +40517,17 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"@getpaseo/highlight": "0.16.1",
|
||||
"@getpaseo/plugin": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@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",
|
||||
"@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.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"version": "0.16.2",
|
||||
"dependencies": {
|
||||
"@getpaseo/plugin": "*",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"description": "Paseo: voice-controlled development environment for local AI coding agents",
|
||||
"keywords": [
|
||||
|
||||
@@ -56,11 +56,20 @@ 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> {
|
||||
await trigger.click();
|
||||
await expect(page.getByRole("menuitem", { name: "Fork in a new tab" })).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
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 });
|
||||
}
|
||||
|
||||
export async function openMostRecentAssistantForkMenu(page: Page): Promise<void> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -215,6 +215,32 @@ 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")}`;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// @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("", {
|
||||
...context,
|
||||
client: null,
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(queryClient.isFetching()).toBe(0);
|
||||
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe(
|
||||
"",
|
||||
);
|
||||
});
|
||||
|
||||
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("", {});
|
||||
|
||||
await waitFor(() =>
|
||||
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe("Chart"),
|
||||
);
|
||||
});
|
||||
@@ -81,7 +81,10 @@ export function useMarkdownSource(
|
||||
const results = useFetchQueries(
|
||||
acquisitions.map((acquisition, index) => ({
|
||||
queryKey: ["markdownImage", acquisition?.key ?? sources[index]],
|
||||
enabled: acquisition !== null,
|
||||
// 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),
|
||||
immutableWhen: () => true,
|
||||
dataShape: "value",
|
||||
gcTime: 0,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/server": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/server": "0.16.2",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/relay": "0.16.2",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
|
||||
@@ -308,7 +308,8 @@ export interface PaseoAgentTimelineRefetchOptions {
|
||||
projection?: FetchAgentTimelineProjection;
|
||||
/**
|
||||
* Extends a `tail` or `before` page back to the start of the oldest turn it touches, so
|
||||
* `{ direction: "tail", limit: 1, wholeTurns: true }` returns the latest turn.
|
||||
* `{ direction: "tail", limit: 1, wholeTurns: true }` returns the latest turn. When the complete
|
||||
* turns do not fit the message limit, the host returns an item page that can start mid-turn.
|
||||
*/
|
||||
wholeTurns?: boolean;
|
||||
requestId?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"description": "Paseo desktop app (Electron wrapper)",
|
||||
"homepage": "https://paseo.sh",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Native module for two way audio streaming",
|
||||
"keywords": [
|
||||
"ExpoTwoWayAudio",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"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.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@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.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"react": ">=19.1.0 <20",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
@@ -109,7 +109,8 @@ export interface PluginHookEvents {
|
||||
* The payload carries no history. Read the turn with
|
||||
* `paseo.agents.ref(agent.id).timeline.refetch({ direction: "tail", limit: 1, wholeTurns: true })`
|
||||
* and keep the entries whose `turnId` equals this `turnId`. The result is empty when a newer turn
|
||||
* started before the read, or when `turnId` is `null`.
|
||||
* started before the read, or when `turnId` is `null`. A turn larger than the message limit
|
||||
* arrives as an item page that can start mid-turn; page `before` its `startCursor` for the rest.
|
||||
*/
|
||||
outcome: PluginTurnOutcome;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Paseo shared protocol schemas and wire types",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Paseo relay for bridging daemon and client connections",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Paseo backend server",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
@@ -90,7 +90,7 @@
|
||||
"speech:transcribe:local": "tsx scripts/transcribe-local-wav.ts",
|
||||
"test": "npm run test:unit && npm run test:integration",
|
||||
"test:unit": "vitest run --fileParallelism --exclude \"**/*.e2e.test.ts\"",
|
||||
"test:integration": "vitest run --maxWorkers=1 src/server/git-filename-diffs.e2e.test.ts src/server/daemon-e2e/checkout-diff-content.e2e.test.ts src/server/daemon-e2e/create-agent-mode.e2e.test.ts src/server/daemon-e2e/filesystem.e2e.test.ts src/server/daemon-e2e/file-download.e2e.test.ts src/server/daemon-e2e/cli-logs-follow.e2e.test.ts src/server/creation/creation.e2e.test.ts src/server/daemon-e2e/creation-status.e2e.test.ts src/server/daemon-e2e/persisted-creation-caller.e2e.test.ts src/server/daemon-e2e/terminal-workspace-sdk.e2e.test.ts src/server/daemon-e2e/terminal-worker-lifecycle.e2e.test.ts src/server/workspace-create-worktree-source.e2e.test.ts src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/daemon-e2e/oversized-message.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts src/server/plugins/plugin-paseo-api.e2e.test.ts src/server/plugins/usage-sources.e2e.test.ts src/server/plugins/lifecycle.e2e.test.ts src/server/connected-hosts/hosts.e2e.test.ts src/server/owned-subscriptions.e2e.test.ts && vitest run --maxWorkers=1 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts -t \"merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history\"",
|
||||
"test:integration": "vitest run --maxWorkers=1 src/server/git-filename-diffs.e2e.test.ts src/server/daemon-e2e/checkout-diff-content.e2e.test.ts src/server/daemon-e2e/create-agent-mode.e2e.test.ts src/server/daemon-e2e/filesystem.e2e.test.ts src/server/daemon-e2e/file-download.e2e.test.ts src/server/daemon-e2e/cli-logs-follow.e2e.test.ts src/server/creation/creation.e2e.test.ts src/server/daemon-e2e/creation-status.e2e.test.ts src/server/daemon-e2e/persisted-creation-caller.e2e.test.ts src/server/daemon-e2e/terminal-workspace-sdk.e2e.test.ts src/server/daemon-e2e/terminal-worker-lifecycle.e2e.test.ts src/server/workspace-create-worktree-source.e2e.test.ts src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/daemon-e2e/oversized-message.e2e.test.ts src/server/daemon-e2e/oversized-whole-turn.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts src/server/plugins/plugin-paseo-api.e2e.test.ts src/server/plugins/usage-sources.e2e.test.ts src/server/plugins/lifecycle.e2e.test.ts src/server/connected-hosts/hosts.e2e.test.ts src/server/owned-subscriptions.e2e.test.ts && vitest run --maxWorkers=1 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts -t \"merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history\"",
|
||||
"test:hub-cli-contract": "vitest run --maxWorkers=1 src/server/hub/hub-cli-contract.test.ts",
|
||||
"test:integration:all": "npm run test:e2e",
|
||||
"test:integration:real": "vitest run real.e2e.test.ts",
|
||||
@@ -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.1",
|
||||
"@getpaseo/highlight": "0.16.1",
|
||||
"@getpaseo/plugin": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@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",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
"@opencode-ai/sdk": "1.14.46",
|
||||
|
||||
@@ -5,6 +5,190 @@ import { describe, expect, it } from "vitest";
|
||||
import { selectReferenceProjectedTimelinePage } from "./test-utils/timeline-page-reference.js";
|
||||
import type { AgentTimelineItem } from "./agent-sdk-types.js";
|
||||
import { InMemoryAgentTimelineStore } from "./agent-timeline-store.js";
|
||||
import { selectTimelineResponseWithinFrameBudget } from "../session/timeline-frame-budget.js";
|
||||
|
||||
describe("whole-turn byte budget", () => {
|
||||
function fixture() {
|
||||
const store = new InMemoryAgentTimelineStore();
|
||||
store.initialize("agent", { epoch: "current" });
|
||||
for (let index = 1; index <= 8; index++) {
|
||||
store.append(
|
||||
"agent",
|
||||
{ type: "assistant_message", messageId: `item-${index}`, text: "\u20ac".repeat(180) },
|
||||
{ turnId: "one-turn" },
|
||||
);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
function request(
|
||||
store: ReturnType<typeof fixture>,
|
||||
options: {
|
||||
maxBytes: number;
|
||||
limit: number;
|
||||
direction?: "before" | "after";
|
||||
cursor?: { epoch: string; seq: number };
|
||||
},
|
||||
) {
|
||||
return selectTimelineResponseWithinFrameBudget({
|
||||
wholeTurns: true,
|
||||
limit: options.limit,
|
||||
maxBytes: options.maxBytes,
|
||||
select: ({ wholeTurns, limit }) => {
|
||||
const { rows, ...page } = store.fetch("agent", {
|
||||
direction: options.direction ?? "tail",
|
||||
cursor: options.cursor,
|
||||
wholeTurns,
|
||||
limit,
|
||||
});
|
||||
return { type: "fetch_agent_timeline_response", payload: { ...page, entries: rows } };
|
||||
},
|
||||
}).payload;
|
||||
}
|
||||
|
||||
it("keeps complete turns whenever they fit, and leaves explicit full reads unchanged", () => {
|
||||
const store = fixture();
|
||||
expect(request(store, { maxBytes: 10000, limit: 2 }).entries.map((row) => row.seq)).toEqual([
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
]);
|
||||
expect(request(store, { maxBytes: 500, limit: 0 }).entries).toHaveLength(8);
|
||||
});
|
||||
|
||||
it("splits an oversized turn into adjacent older pages without losing any entries", () => {
|
||||
const store = fixture();
|
||||
let page = request(store, { maxBytes: 1300, limit: 2 });
|
||||
expect(page).toMatchObject({ startSeq: 8, endSeq: 8, hasOlder: true });
|
||||
const seen = page.entries.map((row) => row.seq);
|
||||
for (let index = 7; index >= 1; index--) {
|
||||
page = request(store, {
|
||||
maxBytes: 1300,
|
||||
limit: 2,
|
||||
direction: "before",
|
||||
cursor: { epoch: page.epoch, seq: page.startSeq! },
|
||||
});
|
||||
expect(page).toMatchObject({ startSeq: index, endSeq: index, hasOlder: index > 1 });
|
||||
seen.unshift(...page.entries.map((row) => row.seq));
|
||||
}
|
||||
expect(seen).toEqual([1, 2, 3, 4, 5, 6, 7, 8]);
|
||||
});
|
||||
|
||||
it("keeps the forward cursor on the oldest unsent part of an oversized turn", () => {
|
||||
const store = fixture();
|
||||
let seq = 1;
|
||||
for (let expected = 2; expected <= 8; expected++) {
|
||||
const page = request(store, {
|
||||
maxBytes: 1300,
|
||||
limit: 2,
|
||||
direction: "after",
|
||||
cursor: { epoch: "current", seq },
|
||||
});
|
||||
expect(page).toMatchObject({ startSeq: expected, endSeq: expected, hasNewer: expected < 8 });
|
||||
seq = page.endSeq!;
|
||||
}
|
||||
});
|
||||
|
||||
it("reports when even a single row cannot fit", () => {
|
||||
expect(() => request(fixture(), { maxBytes: 100, limit: 2 })).toThrow(
|
||||
/timeline item exceeds the response size limit/i,
|
||||
);
|
||||
});
|
||||
|
||||
function spannedTurn(trailing: number) {
|
||||
const store = new InMemoryAgentTimelineStore();
|
||||
store.initialize("agent", { epoch: "current" });
|
||||
const tool = (callId: string, status: "running" | "completed") =>
|
||||
({
|
||||
type: "tool_call",
|
||||
callId,
|
||||
name: "shell",
|
||||
status,
|
||||
error: null,
|
||||
detail: { type: "shell", command: "sleep 600" },
|
||||
}) as AgentTimelineItem;
|
||||
store.append("agent", tool("background", "running"), { turnId: "one-turn" });
|
||||
for (let index = 1; index <= 8; index++) {
|
||||
store.append(
|
||||
"agent",
|
||||
{ type: "assistant_message", messageId: `item-${index}`, text: "€".repeat(180) },
|
||||
{ turnId: "one-turn" },
|
||||
);
|
||||
}
|
||||
store.append("agent", tool("background", "completed"), { turnId: "one-turn" });
|
||||
for (let index = 1; index <= trailing; index++) {
|
||||
store.append("agent", tool(`after-${index}`, "completed"), { turnId: "one-turn" });
|
||||
}
|
||||
let selects = 0;
|
||||
const tail = () =>
|
||||
selectTimelineResponseWithinFrameBudget({
|
||||
wholeTurns: true,
|
||||
limit: 40,
|
||||
maxBytes: 1300,
|
||||
select: ({ wholeTurns, limit }) => {
|
||||
selects++;
|
||||
const { rows, ...page } = store.fetch("agent", { direction: "tail", wholeTurns, limit });
|
||||
return { type: "fetch_agent_timeline_response", payload: { ...page, entries: rows } };
|
||||
},
|
||||
}).payload;
|
||||
return { tail, selects: () => selects };
|
||||
}
|
||||
|
||||
it("reports when one tool call spans the turn to its last row", () => {
|
||||
const turn = spannedTurn(0);
|
||||
expect(turn.tail).toThrow(/one item spans more than the response size limit/i);
|
||||
expect(turn.selects()).toBe(5);
|
||||
});
|
||||
|
||||
it("reaches the rows after a tool call that spans most of the turn", () => {
|
||||
for (const trailing of [1, 3, 7]) {
|
||||
const page = spannedTurn(trailing).tail();
|
||||
expect(page.hasOlder).toBe(true);
|
||||
expect(page.entries.length).toBeGreaterThan(0);
|
||||
expect(
|
||||
page.entries.every(
|
||||
(row) => row.item.type === "tool_call" && row.item.callId.startsWith("after-"),
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("whole-turn byte budget across turns", () => {
|
||||
it("pages back from an oversized turn into the turn before it without repeating rows", () => {
|
||||
const store = new InMemoryAgentTimelineStore();
|
||||
store.initialize("agent", { epoch: "current" });
|
||||
store.append("agent", { type: "user_message", text: "first", messageId: "u1" });
|
||||
for (let index = 1; index <= 5; index++)
|
||||
store.append("agent", { type: "assistant_message", messageId: `a${index}`, text: "ok" });
|
||||
store.append("agent", { type: "user_message", text: "second", messageId: "u2" });
|
||||
for (let index = 1; index <= 8; index++)
|
||||
store.append("agent", {
|
||||
type: "assistant_message",
|
||||
messageId: `b${index}`,
|
||||
text: "x".repeat(400),
|
||||
});
|
||||
|
||||
const fetch = (direction: "tail" | "before", cursor?: { epoch: string; seq: number }) =>
|
||||
selectTimelineResponseWithinFrameBudget({
|
||||
wholeTurns: true,
|
||||
limit: 4,
|
||||
maxBytes: 2500,
|
||||
select: ({ wholeTurns, limit }) => {
|
||||
const { rows, ...page } = store.fetch("agent", { direction, cursor, wholeTurns, limit });
|
||||
return { type: "fetch_agent_timeline_response", payload: { ...page, entries: rows } };
|
||||
},
|
||||
}).payload;
|
||||
|
||||
let page = fetch("tail");
|
||||
const seen = page.entries.map((row) => row.seqStart);
|
||||
while (page.hasOlder) {
|
||||
const cursor = page.startSeq!;
|
||||
page = fetch("before", { epoch: "current", seq: cursor });
|
||||
expect(page.endSeq).toBe(cursor - 1);
|
||||
seen.unshift(...page.entries.map((row) => row.seqStart));
|
||||
}
|
||||
expect(seen).toEqual(Array.from({ length: 15 }, (_, index) => index + 1));
|
||||
});
|
||||
});
|
||||
|
||||
describe("InMemoryAgentTimelineStore", () => {
|
||||
it("resets stale forward cursors to complete available turns", () => {
|
||||
|
||||
@@ -605,6 +605,8 @@ 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 }> = [];
|
||||
@@ -723,7 +725,7 @@ class ProviderRuntimeSession {
|
||||
|
||||
async close(): Promise<void> {
|
||||
this.history.length = 0;
|
||||
if (this.restoration === "parent") {
|
||||
if (this.restoration === "parent" || this.closedByProvider) {
|
||||
this.runtime.removeSession(this.id, this.providerSessionId);
|
||||
return;
|
||||
}
|
||||
@@ -788,6 +790,7 @@ 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);
|
||||
|
||||
@@ -136,6 +136,94 @@ 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,8 +10,13 @@ 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";
|
||||
const TOOL_APPROVAL_OPTIONS = [TOOL_APPROVAL_APPROVE_VALUE, TOOL_APPROVAL_DENY_VALUE] as const;
|
||||
// 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_TITLE_PREFIX = "Allow tool: ";
|
||||
|
||||
export type OmpRpcUiPermissionClassification =
|
||||
@@ -25,6 +30,12 @@ interface ToolApprovalDescriptor {
|
||||
args: AgentMetadata;
|
||||
detail: ToolCallDetail;
|
||||
description?: string;
|
||||
choices: ToolApprovalChoices;
|
||||
}
|
||||
|
||||
interface ToolApprovalChoices {
|
||||
approveValue: string;
|
||||
extraValues: string[];
|
||||
}
|
||||
|
||||
export function classifyOmpRpcUiPermissionRequest(
|
||||
@@ -37,6 +48,13 @@ 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: {
|
||||
@@ -57,17 +75,18 @@ export function classifyOmpRpcUiPermissionRequest(
|
||||
},
|
||||
{
|
||||
id: "approve",
|
||||
label: TOOL_APPROVAL_APPROVE_VALUE,
|
||||
label: approveValue,
|
||||
behavior: "allow",
|
||||
variant: "primary",
|
||||
},
|
||||
...extraActions,
|
||||
],
|
||||
metadata: {
|
||||
extensionUiMethod: "select",
|
||||
toolApproval: OMP_RPC_UI_TOOL_APPROVAL_METADATA,
|
||||
toolName: descriptor.toolName,
|
||||
toolArgs: descriptor.args,
|
||||
approveValue: TOOL_APPROVAL_APPROVE_VALUE,
|
||||
approveValue,
|
||||
denyValue: TOOL_APPROVAL_DENY_VALUE,
|
||||
},
|
||||
},
|
||||
@@ -95,13 +114,23 @@ export function buildOmpRpcUiPermissionResponse(
|
||||
|
||||
const approveValue = readString(request.metadata.approveValue) ?? TOOL_APPROVAL_APPROVE_VALUE;
|
||||
const denyValue = readString(request.metadata.denyValue) ?? TOOL_APPROVAL_DENY_VALUE;
|
||||
return { value: response.behavior === "allow" ? approveValue : denyValue };
|
||||
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 };
|
||||
}
|
||||
|
||||
function parseToolApprovalDescriptor(
|
||||
event: ExtensionUiRequestEvent,
|
||||
): ToolApprovalDescriptor | null {
|
||||
if (event.method !== "select" || !hasExactToolApprovalOptions(event.options)) {
|
||||
const choices = event.method === "select" ? readToolApprovalChoices(event.options) : null;
|
||||
if (!choices) {
|
||||
return null;
|
||||
}
|
||||
const title = readString(event.title);
|
||||
@@ -118,6 +147,15 @@ 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);
|
||||
@@ -130,7 +168,7 @@ function parseToolApprovalDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
function parseBashApproval(body: string): ToolApprovalDescriptor | null {
|
||||
function parseBashApproval(body: string): Omit<ToolApprovalDescriptor, "choices"> | null {
|
||||
const match = /(?:^|\r?\n)[\t ]*Command:[\t ]?(.*)$/s.exec(body);
|
||||
const command = match?.[1];
|
||||
if (!command) {
|
||||
@@ -144,7 +182,7 @@ function parseBashApproval(body: string): ToolApprovalDescriptor | null {
|
||||
};
|
||||
}
|
||||
|
||||
function parseEditApproval(lines: string[]): ToolApprovalDescriptor | null {
|
||||
function parseEditApproval(lines: string[]): Omit<ToolApprovalDescriptor, "choices"> | null {
|
||||
const filePath = readPrefixedValue(lines, "File:");
|
||||
if (!filePath) {
|
||||
return null;
|
||||
@@ -157,7 +195,7 @@ function parseEditApproval(lines: string[]): ToolApprovalDescriptor | null {
|
||||
};
|
||||
}
|
||||
|
||||
function parseWriteApproval(lines: string[]): ToolApprovalDescriptor | null {
|
||||
function parseWriteApproval(lines: string[]): Omit<ToolApprovalDescriptor, "choices"> | null {
|
||||
const pathLineIndex = lines.findIndex((line) => line.trim().startsWith("Path:"));
|
||||
if (pathLineIndex < 0) {
|
||||
return null;
|
||||
@@ -182,12 +220,28 @@ function parseWriteApproval(lines: string[]): ToolApprovalDescriptor | null {
|
||||
};
|
||||
}
|
||||
|
||||
function hasExactToolApprovalOptions(options: unknown): boolean {
|
||||
return (
|
||||
Array.isArray(options) &&
|
||||
options.length === TOOL_APPROVAL_OPTIONS.length &&
|
||||
options.every((option, index) => option === TOOL_APPROVAL_OPTIONS[index])
|
||||
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),
|
||||
);
|
||||
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 {
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, test } from "vitest";
|
||||
import { createDaemonTestContext } from "../test-utils/index.js";
|
||||
|
||||
// #8458: a whole-turn page is one logical message, so a turn above the message limit never arrived.
|
||||
test("reading a turn larger than the message limit returns pages that reach its start", async () => {
|
||||
const ctx = await createDaemonTestContext();
|
||||
const cwd = mkdtempSync(path.join(tmpdir(), "oversized-whole-turn-"));
|
||||
try {
|
||||
const agent = await ctx.client.createAgent({ provider: "codex", cwd });
|
||||
const replies = 420;
|
||||
for (let index = 0; index < replies; index += 1) {
|
||||
await ctx.daemon.daemon.agentManager.appendTimelineItem(agent.id, {
|
||||
type: "assistant_message",
|
||||
messageId: `reply-${index}`,
|
||||
text: `reply-${index} ${"x".repeat(250 * 1024)}`,
|
||||
});
|
||||
await ctx.daemon.daemon.agentManager.appendTimelineItem(agent.id, {
|
||||
type: "tool_call",
|
||||
callId: `call-${index}`,
|
||||
name: "Bash",
|
||||
status: "completed",
|
||||
error: null,
|
||||
detail: { type: "shell", command: `echo ${index}`, output: `${index}` },
|
||||
});
|
||||
}
|
||||
|
||||
let page = await ctx.client.fetchAgentTimeline(agent.id, {
|
||||
direction: "tail",
|
||||
limit: 40,
|
||||
wholeTurns: true,
|
||||
timeout: 20_000,
|
||||
});
|
||||
const seen = new Set<string>();
|
||||
const collect = () => {
|
||||
for (const entry of page.entries) {
|
||||
if (entry.item.type === "assistant_message") seen.add(entry.item.text.split(" ")[0]);
|
||||
}
|
||||
};
|
||||
collect();
|
||||
expect(page.entries.length).toBeGreaterThan(0);
|
||||
while (page.hasOlder) {
|
||||
const cursor = page.startCursor;
|
||||
if (!cursor) throw new Error("page with older history has no start cursor");
|
||||
page = await ctx.client.fetchAgentTimeline(agent.id, {
|
||||
direction: "before",
|
||||
cursor,
|
||||
limit: 40,
|
||||
wholeTurns: true,
|
||||
timeout: 20_000,
|
||||
});
|
||||
collect();
|
||||
}
|
||||
expect(seen.size).toBe(replies);
|
||||
|
||||
const small = await ctx.client.fetchAgentTimeline(agent.id, { direction: "tail", limit: 1 });
|
||||
expect(small.entries).toHaveLength(1);
|
||||
} finally {
|
||||
await ctx.cleanup();
|
||||
rmSync(cwd, { recursive: true, force: true });
|
||||
}
|
||||
}, 180_000);
|
||||
|
||||
// A tail page starts at the first row of the source span it lands in. One tool call that starts
|
||||
// before the oversized turn and completes after it spans every row, so no smaller page exists.
|
||||
// The daemon answers with an error instead of letting the request time out.
|
||||
test("reading a turn that one tool call spans past the message limit fails with a reply", async () => {
|
||||
const ctx = await createDaemonTestContext();
|
||||
const cwd = mkdtempSync(path.join(tmpdir(), "oversized-spanned-turn-"));
|
||||
try {
|
||||
const agent = await ctx.client.createAgent({ provider: "codex", cwd });
|
||||
const background = (status: "running" | "completed") => ({
|
||||
type: "tool_call" as const,
|
||||
callId: "background",
|
||||
name: "Bash",
|
||||
status,
|
||||
error: null,
|
||||
detail: { type: "shell" as const, command: "sleep 600" },
|
||||
});
|
||||
await ctx.daemon.daemon.agentManager.appendTimelineItem(agent.id, background("running"));
|
||||
for (let index = 0; index < 420; index += 1) {
|
||||
await ctx.daemon.daemon.agentManager.appendTimelineItem(agent.id, {
|
||||
type: "assistant_message",
|
||||
messageId: `reply-${index}`,
|
||||
text: `reply-${index} ${"x".repeat(250 * 1024)}`,
|
||||
});
|
||||
}
|
||||
await ctx.daemon.daemon.agentManager.appendTimelineItem(agent.id, background("completed"));
|
||||
|
||||
await expect(
|
||||
ctx.client.fetchAgentTimeline(agent.id, {
|
||||
direction: "tail",
|
||||
limit: 40,
|
||||
wholeTurns: true,
|
||||
timeout: 20_000,
|
||||
}),
|
||||
).rejects.toThrow(/one item spans more than the response size limit/i);
|
||||
|
||||
const small = await ctx.client.fetchAgentTimeline(agent.id, { direction: "before", limit: 1 });
|
||||
expect(small.entries).toHaveLength(1);
|
||||
} finally {
|
||||
await ctx.cleanup();
|
||||
rmSync(cwd, { recursive: true, force: true });
|
||||
}
|
||||
}, 180_000);
|
||||
@@ -0,0 +1,193 @@
|
||||
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,
|
||||
);
|
||||
@@ -213,6 +213,7 @@ import {
|
||||
type SpeechModelsSessionOptions,
|
||||
} from "./session/speech/speech-models-session.js";
|
||||
import { WorkspaceFilesSession } from "./session/files/workspace-files-session.js";
|
||||
import { selectTimelineResponseWithinFrameBudget } from "./session/timeline-frame-budget.js";
|
||||
import { AgentConfigSession } from "./session/agent-config/agent-config-session.js";
|
||||
import { ProjectConfigSession } from "./session/project-config/project-config-session.js";
|
||||
import { DaemonSession, type DaemonRuntimeConfig } from "./session/daemon/daemon-session.js";
|
||||
@@ -8458,76 +8459,58 @@ export class Session {
|
||||
});
|
||||
const agentPayload = await this.buildAgentPayload(snapshot);
|
||||
|
||||
const fetchedControlTimeline = this.agentManager.fetchTimeline(msg.agentId, {
|
||||
direction,
|
||||
cursor,
|
||||
const supportsReasoningMerge = source
|
||||
? this.supportsForSource(CLIENT_CAPS.reasoningMergeEnum, source)
|
||||
: this.supports(CLIENT_CAPS.reasoningMergeEnum);
|
||||
const response = selectTimelineResponseWithinFrameBudget({
|
||||
limit: msg.limit,
|
||||
wholeTurns: msg.wholeTurns,
|
||||
});
|
||||
const selectedTimeline = {
|
||||
timeline: fetchedControlTimeline,
|
||||
entries: fetchedControlTimeline.rows,
|
||||
startSeq: fetchedControlTimeline.startSeq,
|
||||
endSeq: fetchedControlTimeline.endSeq,
|
||||
hasOlder: fetchedControlTimeline.hasOlder,
|
||||
hasNewer: fetchedControlTimeline.hasNewer,
|
||||
};
|
||||
const startCursor =
|
||||
selectedTimeline.startSeq !== null
|
||||
? { epoch: selectedTimeline.timeline.epoch, seq: selectedTimeline.startSeq }
|
||||
: null;
|
||||
const endCursor =
|
||||
selectedTimeline.endSeq !== null
|
||||
? { epoch: selectedTimeline.timeline.epoch, seq: selectedTimeline.endSeq }
|
||||
: null;
|
||||
const entries = selectedTimeline.entries.filter((entry) =>
|
||||
this.supportsTimelineItem(entry.item, source),
|
||||
);
|
||||
|
||||
this.emitForSource(
|
||||
{
|
||||
type: "fetch_agent_timeline_response",
|
||||
payload: {
|
||||
requestId: msg.requestId,
|
||||
agentId: msg.agentId,
|
||||
agent: agentPayload,
|
||||
select: ({ limit, wholeTurns }) => {
|
||||
const timeline = this.agentManager.fetchTimeline(msg.agentId, {
|
||||
direction,
|
||||
projection,
|
||||
epoch: selectedTimeline.timeline.epoch,
|
||||
reset: fetchedControlTimeline.reset,
|
||||
staleCursor: fetchedControlTimeline.staleCursor,
|
||||
gap: fetchedControlTimeline.gap,
|
||||
window: selectedTimeline.timeline.window,
|
||||
startCursor,
|
||||
endCursor,
|
||||
hasOlder: selectedTimeline.hasOlder,
|
||||
hasNewer: selectedTimeline.hasNewer,
|
||||
...(msg.mergeWindow === true ? { mergeWindow: true } : {}),
|
||||
entries: entries.map((entry) => {
|
||||
const payloadEntry = {
|
||||
provider: snapshot.provider,
|
||||
item: entry.item,
|
||||
timestamp: entry.timestamp,
|
||||
seqStart: entry.seqStart,
|
||||
seqEnd: entry.seqEnd,
|
||||
sourceSeqRanges: entry.sourceSeqRanges,
|
||||
turnId: undefined as string | undefined,
|
||||
collapsed: (
|
||||
source
|
||||
? this.supportsForSource(CLIENT_CAPS.reasoningMergeEnum, source)
|
||||
: this.supports(CLIENT_CAPS.reasoningMergeEnum)
|
||||
)
|
||||
? entry.collapsed
|
||||
: entry.collapsed.filter((value) => value !== "reasoning_merge"),
|
||||
};
|
||||
payloadEntry.turnId = entry.turnId;
|
||||
return payloadEntry;
|
||||
}),
|
||||
error: null,
|
||||
},
|
||||
cursor,
|
||||
limit,
|
||||
wholeTurns,
|
||||
});
|
||||
const { epoch, startSeq, endSeq } = timeline;
|
||||
return {
|
||||
type: "fetch_agent_timeline_response" as const,
|
||||
payload: {
|
||||
requestId: msg.requestId,
|
||||
agentId: msg.agentId,
|
||||
agent: agentPayload,
|
||||
direction,
|
||||
projection,
|
||||
epoch,
|
||||
reset: timeline.reset,
|
||||
staleCursor: timeline.staleCursor,
|
||||
gap: timeline.gap,
|
||||
window: timeline.window,
|
||||
startCursor: startSeq === null ? null : { epoch, seq: startSeq },
|
||||
endCursor: endSeq === null ? null : { epoch, seq: endSeq },
|
||||
hasOlder: timeline.hasOlder,
|
||||
hasNewer: timeline.hasNewer,
|
||||
...(msg.mergeWindow === true ? { mergeWindow: true } : {}),
|
||||
entries: timeline.rows
|
||||
.filter((entry) => this.supportsTimelineItem(entry.item, source))
|
||||
.map((entry) => ({
|
||||
provider: snapshot.provider,
|
||||
item: entry.item,
|
||||
timestamp: entry.timestamp,
|
||||
seqStart: entry.seqStart,
|
||||
seqEnd: entry.seqEnd,
|
||||
sourceSeqRanges: entry.sourceSeqRanges,
|
||||
turnId: entry.turnId,
|
||||
collapsed: supportsReasoningMerge
|
||||
? entry.collapsed
|
||||
: entry.collapsed.filter((value) => value !== "reasoning_merge"),
|
||||
})),
|
||||
error: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
source,
|
||||
);
|
||||
});
|
||||
this.emitForSource(response, source);
|
||||
} catch (error) {
|
||||
this.sessionLogger.error(
|
||||
{ err: error, agentId: msg.agentId },
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { MAX_WEBSOCKET_MESSAGE_BYTES } from "@getpaseo/protocol/websocket-message-limit";
|
||||
|
||||
// Routed replies add their own envelope around the session frame.
|
||||
const TIMELINE_FRAME_BUDGET_BYTES = MAX_WEBSOCKET_MESSAGE_BYTES - 64 * 1024;
|
||||
|
||||
interface TimelineRequest {
|
||||
wholeTurns?: boolean;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
interface TimelineResponse {
|
||||
payload: { entries: readonly unknown[] };
|
||||
}
|
||||
|
||||
function fitsFrameBudget(response: TimelineResponse, maxBytes: number): boolean {
|
||||
const { entries, ...payload } = response.payload;
|
||||
// Count bytes without constructing an oversized JSON string for the whole turn.
|
||||
let bytes = Buffer.byteLength(
|
||||
JSON.stringify({
|
||||
type: "session",
|
||||
message: { ...response, payload: { ...payload, entries: [] } },
|
||||
}),
|
||||
);
|
||||
for (const entry of entries) {
|
||||
bytes += Buffer.byteLength(JSON.stringify(entry)) + 1;
|
||||
if (bytes > maxBytes) return false;
|
||||
}
|
||||
return bytes <= maxBytes;
|
||||
}
|
||||
|
||||
export function selectTimelineResponseWithinFrameBudget<T extends TimelineResponse>(
|
||||
options: TimelineRequest & { select: (request: TimelineRequest) => T; maxBytes?: number },
|
||||
): T {
|
||||
const { select, wholeTurns, maxBytes = TIMELINE_FRAME_BUDGET_BYTES } = options;
|
||||
let { limit } = options;
|
||||
const requested = select({ wholeTurns, limit });
|
||||
// Preserve whole-turn pages that fit and the existing explicit full-read contract.
|
||||
if (wholeTurns !== true || limit === 0 || fitsFrameBudget(requested, maxBytes)) return requested;
|
||||
|
||||
for (;;) {
|
||||
// Reselect using the original direction and cursor; slicing the old response
|
||||
// would keep the wrong fences and hide the skipped entries from scrollback.
|
||||
const page = select({ wholeTurns: false, limit });
|
||||
if (fitsFrameBudget(page, maxBytes)) return page;
|
||||
const count = page.payload.entries.length;
|
||||
const currentLimit = limit ?? count;
|
||||
if (currentLimit <= 1) {
|
||||
// A tail page starts at the first row of the source span it lands in, so
|
||||
// one item whose updates span the page keeps it larger than the limit.
|
||||
throw new Error(
|
||||
count > 1
|
||||
? "One item spans more than the response size limit, so the timeline page cannot shrink."
|
||||
: "A timeline item exceeds the response size limit.",
|
||||
);
|
||||
}
|
||||
// A smaller limit can return the same rows while it still lands inside a
|
||||
// span, so keep halving the limit rather than judging progress by row count.
|
||||
limit = Math.max(1, Math.floor(Math.min(currentLimit, count) / 2));
|
||||
}
|
||||
}
|
||||
@@ -587,6 +587,29 @@ 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[] = [];
|
||||
@@ -623,6 +646,7 @@ describe("WorkspaceGitServiceImpl", () => {
|
||||
const service = new WorkspaceGitServiceImpl({
|
||||
logger: createLogger() as unknown as pino.Logger,
|
||||
paseoHome: "/tmp/paseo-test",
|
||||
releaseGraceMs: 0,
|
||||
deps: {
|
||||
...buildDefaultTestServiceDeps(),
|
||||
getPullRequestStatus: async () => {
|
||||
|
||||
@@ -81,6 +81,9 @@ 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;
|
||||
@@ -441,6 +444,8 @@ 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 {
|
||||
@@ -463,6 +468,7 @@ interface WorkspaceGitTarget {
|
||||
gitDirPaths: GitObservationPaths | null;
|
||||
cwd: string;
|
||||
listeners: Set<WorkspaceGitListener>;
|
||||
releaseTimer: NodeJS.Timeout | null;
|
||||
workingTreeWatchTarget: WorkingTreeWatchTarget | null;
|
||||
debounceTimer: NodeJS.Timeout | null;
|
||||
pendingDebounceRequest: WorkspaceGitRefreshRequest | null;
|
||||
@@ -657,6 +663,7 @@ 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;
|
||||
@@ -710,6 +717,7 @@ 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),
|
||||
@@ -733,6 +741,7 @@ 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);
|
||||
@@ -1318,6 +1327,7 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
|
||||
gitDirPaths: null,
|
||||
cwd,
|
||||
listeners: new Set(),
|
||||
releaseTimer: null,
|
||||
workingTreeWatchTarget: null,
|
||||
debounceTimer: null,
|
||||
pendingDebounceRequest: null,
|
||||
@@ -3065,6 +3075,9 @@ 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(
|
||||
@@ -3351,6 +3364,9 @@ 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) {
|
||||
@@ -4104,7 +4120,52 @@ 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 {
|
||||
@@ -4171,6 +4232,7 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
|
||||
|
||||
private closeWorkspaceTarget(target: WorkspaceGitTarget): void {
|
||||
target.closed = true;
|
||||
this.cancelWorkspaceRelease(target);
|
||||
this.stopWorkspaceObservation(target);
|
||||
target.listeners.clear();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/builtin-plugins",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -538,7 +538,7 @@ server.addHook("agent.turn.before", async ({ agent, turnId }) => {
|
||||
|
||||
## agent.turn.after
|
||||
|
||||
A live turn completes, fails, or is canceled. Receives `{ agent, turnId, outcome }`. `outcome.kind` is `completed`, `failed`, or `canceled`. The payload carries no history. Read the turn from the agent's timeline: `refetch({ direction: "tail", limit: 1, wholeTurns: true })` returns the latest turn whole, as below. Keep the entries whose `turnId` equals `event.turnId`, because a turn that starts before your read, such as a follow-up another plugin sent, replaces this one as the latest. The filtered list is empty in that case, and when `event.turnId` is `null`. Plugins built against an older SDK that read `event.timeline` get an empty array.
|
||||
A live turn completes, fails, or is canceled. Receives `{ agent, turnId, outcome }`. `outcome.kind` is `completed`, `failed`, or `canceled`. The payload carries no history. Read the turn from the agent's timeline: `refetch({ direction: "tail", limit: 1, wholeTurns: true })` returns the latest turn whole, as below, unless the turn is larger than the message limit ([timeline handle](/docs/sdk/reference#timeline-handle)). Keep the entries whose `turnId` equals `event.turnId`, because a turn that starts before your read, such as a follow-up another plugin sent, replaces this one as the latest. The filtered list is empty in that case, and when `event.turnId` is `null`. Plugins built against an older SDK that read `event.timeline` get an empty array.
|
||||
|
||||
### Send a follow-up when a turn ends
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ server.addHook("agent.turn.before", async ({ agent, turnId }) => {
|
||||
|
||||
## agent.turn.after {#agentturnafter}
|
||||
|
||||
实时轮次完成、失败或取消后触发,收到 `{ agent, turnId, outcome }`。`outcome.kind` 为 `completed`、`failed` 或 `canceled`。载荷不含历史。请从 Agent 的时间线读取本轮:`refetch({ direction: "tail", limit: 1, wholeTurns: true })` 会完整返回最近一轮,见下面的示例。只保留 `turnId` 等于 `event.turnId` 的条目:如果在读取前已有新一轮开始(例如另一个插件发送的后续消息),最近一轮就不再是本轮。此时过滤后的列表为空;`event.turnId` 为 `null` 时也为空。基于旧版 SDK 构建、仍读取 `event.timeline` 的插件只会拿到空数组。
|
||||
实时轮次完成、失败或取消后触发,收到 `{ agent, turnId, outcome }`。`outcome.kind` 为 `completed`、`failed` 或 `canceled`。载荷不含历史。请从 Agent 的时间线读取本轮:`refetch({ direction: "tail", limit: 1, wholeTurns: true })` 会完整返回最近一轮,见下面的示例;超过消息上限的轮次除外(见[时间线句柄](/docs/sdk/reference#timeline-handle))。只保留 `turnId` 等于 `event.turnId` 的条目:如果在读取前已有新一轮开始(例如另一个插件发送的后续消息),最近一轮就不再是本轮。此时过滤后的列表为空;`event.turnId` 为 `null` 时也为空。基于旧版 SDK 构建、仍读取 `event.timeline` 的插件只会拿到空数组。
|
||||
|
||||
### 在轮次结束时发送后续消息 {#send-a-follow-up-when-a-turn-ends}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ workspace the call creates is background too. With a `parent` and no value, the
|
||||
|
||||
### Timeline handle
|
||||
|
||||
`agent.timeline.refetch(options?)` fetches a page. Options are `direction`, `cursor`, `limit`, `projection`, `wholeTurns`, and `requestId`. `wholeTurns: true` extends a `tail` or `before` page back to the start of the oldest turn it reaches, so `{ direction: "tail", limit: 1, wholeTurns: true }` returns the latest turn. It requires `features.wholeTurnTimeline`; older hosts ignore it and return a page of `limit` items.
|
||||
`agent.timeline.refetch(options?)` fetches a page. Options are `direction`, `cursor`, `limit`, `projection`, `wholeTurns`, and `requestId`. `wholeTurns: true` extends a `tail` or `before` page back to the start of the oldest turn it reaches, so `{ direction: "tail", limit: 1, wholeTurns: true }` returns the latest turn. If the complete turns of a page do not fit the 100 MiB message limit, the host returns a page of items with cursors instead, and that page can start partway through a turn. Use `startCursor` with `direction: "before"` to read the rest. It requires `features.wholeTurnTimeline`; older hosts ignore it and return a page of `limit` items.
|
||||
|
||||
`agent.timeline.subscribe(handler)` establishes network demand for this agent and restores it after reconnect. Its unsubscribe function releases that demand; await `unsubscribe.ready` for initial daemon acknowledgement before starting work. Delivery is live-only. Reconnect emits a local `subscription_restored` event; request missed history explicitly with `refetch()`. A live replacement invalidates the previous epoch. See the callback shapes, paging and failure behavior in [timeline events](./events.md#follow-timeline-events).
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ nav: API 参考
|
||||
|
||||
### 时间线句柄 {#timeline-handle}
|
||||
|
||||
`agent.timeline.refetch(options?)` 获取一页时间线。选项有 `direction`、`cursor`、`limit`、`projection`、`wholeTurns` 和 `requestId`。`wholeTurns: true` 会把 `tail` 或 `before` 页向前扩展到它所触及的最早一轮的开头,因此 `{ direction: "tail", limit: 1, wholeTurns: true }` 返回最近一轮。它需要 `features.wholeTurnTimeline`;旧版主机会忽略它,返回 `limit` 条记录。
|
||||
`agent.timeline.refetch(options?)` 获取一页时间线。选项有 `direction`、`cursor`、`limit`、`projection`、`wholeTurns` 和 `requestId`。`wholeTurns: true` 会把 `tail` 或 `before` 页向前扩展到它所触及的最早一轮的开头,因此 `{ direction: "tail", limit: 1, wholeTurns: true }` 返回最近一轮。如果一页的完整轮次超过 100 MiB 消息上限,主机会改为返回带游标的条目页,这一页可能从某一轮的中间开始。用 `startCursor` 和 `direction: "before"` 读取其余部分。它需要 `features.wholeTurnTimeline`;旧版主机会忽略它,返回 `limit` 条记录。
|
||||
|
||||
`agent.timeline.subscribe(handler)` 为该 Agent 建立网络订阅需求,并在重连后恢复它。它返回的取消订阅函数会释放这项需求;开始工作之前,请 await `unsubscribe.ready` 以等待 daemon 的初始确认。投递只包含实时内容。重连时会发出一个本地的 `subscription_restored` 事件;错过的历史请用 `refetch()` 显式请求。实时的替换会使之前的 epoch 失效。回调的形状、分页和失败行为见[时间线事件](./events.md#follow-timeline-events)。
|
||||
|
||||
|
||||
@@ -86,6 +86,12 @@ 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+",
|
||||
|
||||
Reference in New Issue
Block a user