Compare commits

...
Author SHA1 Message Date
paseo-bot[bot]andClaude Opus 5.5 e6390a85d1 Let idle cleanup unload an OpenCode chat while another session runs
The v2 runtime safety check vetoed collection whenever any session on
the server was active. The shared server stays up after its last lease
goes, so that veto kept every idle chat resident while one unrelated
session worked. Another session's execution now vetoes only when
releasing the lease would stop the server; the chat's own session and
its descendants still veto as before.

Fixes #10305

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 10:14:41 +00:00
paseo-ai[bot] d4fd6dcafd fix: update lockfile signatures and Nix hash [skip ci] 2026-11-27 10:13:16 +00:00
Mohamed Boudra 518e58cd63 chore(release): reconcile v0.18.0 (#11030) 2026-11-27 17:04:04 +07:00
paseo-bot[bot]andbenthecarman 82dcf7821e fix(usage): load Kimi usage for global logins (#8505)
* Find Kimi usage for logins to kimi.ai

The Kimi CLI keeps one credential slot per deployment. A login to the
global (kimi.ai) deployment writes its token to
credentials/kimi-code-env-<hash>.json and talks to api.kimi.ai, but the
usage source only read credentials/kimi-code.json and only called
api.kimi.com. Users signed in through kimi.ai saw no Kimi usage, or a
"Login expired. Sign in again." message when an old kimi-code.json from
an earlier login was still on disk.

Discovery now checks the slots of both official deployments and picks
the one with the latest expiry, which is the slot the CLI keeps
refreshing. The usage request goes to the API of that deployment.

Kimi access tokens last 15 minutes, so a CLI token is often expired
while the user is still signed in. Report those with refreshedBy so the
Usage page says to run kimi instead of asking for a new sign-in.

* fix(usage): preserve the selected Kimi credential home

Compare deployment credentials within each home so a newer legacy-home
login cannot override KIMI_CODE_HOME. Cover the expired-default plus live
global workflow through discovery and usage fetching.

Co-authored-by: benthecarman <benthecarman@live.com>

---------

Co-authored-by: benthecarman <benthecarman@live.com>
Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
2026-11-27 09:50:43 +00:00
Mohamed Boudra 5d003d9613 test(cli): report version from fake ACP provider helper (#11032)
antigravity-provider status() now runs --version and requires >= 1.5.1 (#10992). Without a --version handler, supervisor-acp.cjs exited with empty stdout on the version probe and broke 23-daemon-sigint-supervisor.test.ts at createAgent().
2026-11-27 16:36:42 +07:00
paseo-bot[bot]andpeanut_hzm 9868ebc11c fix(usage): discover the GLM Agent login for its Usage card (#8376)
* fix(usage): follow the CLIs' current auth locations for MiniMax and Z.ai

The usage sources look for credentials where the CLIs used to keep them, so
their plan quota never appears in Settings → Usage.

MiniMax Code (`mcode`) moved its OAuth login to
`~/.minimax/auth/<buildEnv>/<region>/<clientId>/auth.json`, with the token
inside a `records` map and the region in a sibling `auth-state.json`. The
source still looked in `~/.mmx/` for the older `access_token` shape. It also
called `/v1/token_plan/remains`, which the agent backend answers with
`status_code 1004` ("Please carry the API secret key in the 'Authorization'
field"); the coding-plan endpoint the CLI itself uses is
`/v1/api/openplatform/coding_plan/remains`.

Z.ai's `glm-acp-agent` reads `Z_AI_API_KEY` and persists it to
`~/.config/glm-acp-agent/credentials.json` as `z_ai_api_key`. The source
looked for `ZAI_API_KEY` and `GLM_API_KEY` only, and never read the
credentials file.

Both keep their existing lookups working, so a configured environment
variable or the older `~/.mmx/` layout still resolves.

* fix(usage): narrow credential discovery repair to the verified GLM path

Keep the independently reproduced GLM discovery fix and isolate its file test from inherited XDG_CONFIG_HOME. Leave MiniMax quota routing for separate verification before changing existing API-key requests.

Co-authored-by: peanut_hzm <peanut_hzm@163.com>

* test(usage): isolate the legacy login locator from inherited credentials

---------

Co-authored-by: peanut_hzm <peanut_hzm@163.com>
Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
2026-11-27 09:21:16 +00:00
35 changed files with 407 additions and 99 deletions
+19
View File
@@ -1,5 +1,24 @@
# Changelog
## 0.18.0 - 2026-11-27
- **Remote workspace browser proxy:** Desktop browser tabs in remote workspaces now route through the workspace daemon, so remote `localhost` servers open directly in Paseo. ([#10944](https://github.com/getpaseo/paseo/pull/10944) by [@airon-assustadus](https://github.com/airon-assustadus))
- **Per-device notification preferences:** Each device can choose which agent, terminal, and plugin events send notifications, and plugins can send notifications and handle taps. ([#10888](https://github.com/getpaseo/paseo/pull/10888))
- **Agent profile system prompts:** Save an optional system prompt on an agent profile to apply it to new agents started from that profile. ([#10996](https://github.com/getpaseo/paseo/pull/10996))
- **More syntax highlighting:** Syntax highlighting now covers diff and patch files along with Ruby, Kotlin, TOML, SQL, Lua, Protobuf, PowerShell, Groovy, Gradle, Scala, CMake, Properties, INI, R, Perl, and LaTeX. ([#11026](https://github.com/getpaseo/paseo/pull/11026) by [@hmalaspina](https://github.com/hmalaspina), [@kukicola](https://github.com/kukicola), [@MaximeConan](https://github.com/MaximeConan), [@singleton11](https://github.com/singleton11), [@chandlerok](https://github.com/chandlerok))
### Changed
- Changed ACP providers to cache model catalogs across daemon restarts instead of probing in the background, and cleaned up Antigravity ACP flags and metadata. Requires [Antigravity CLI 1.5.1 or later](https://paseo.sh/docs/supported-providers/antigravity) ([#10992](https://github.com/getpaseo/paseo/pull/10992))
### Fixed
- Fixed Paseo iOS crashing shortly after connecting when an enabled client plugin imports `react-native` ([#11011](https://github.com/getpaseo/paseo/pull/11011))
- Fixed OpenCode v2 agents staying stuck in running after Stop when stream events were missed or chat history was large ([#10955](https://github.com/getpaseo/paseo/pull/10955))
- Fixed steering a Pi agent during a run it started on its own aborting the run instead of steering it ([#10977](https://github.com/getpaseo/paseo/pull/10977) by [@viiqswim](https://github.com/viiqswim))
- Fixed creating a workspace from a pull request in a fork clone checking out the fork's pull request with the same number ([#10987](https://github.com/getpaseo/paseo/pull/10987))
- Fixed dropping images or files onto the composer leaving the input unfocused ([#11022](https://github.com/getpaseo/paseo/pull/11022))
## 0.17.6 - 2026-11-27
### Improved
+19
View File
@@ -1,5 +1,24 @@
# Changelog
## 0.18.0 - 2026-11-27
- **远程工作区浏览器代理**:远程工作区中的桌面端浏览器标签页现在会通过该工作区的 daemon 转发流量,远程 `localhost` 服务可以直接在 Paseo 中打开。([#10944](https://github.com/getpaseo/paseo/pull/10944),贡献者:[@airon-assustadus](https://github.com/airon-assustadus))
- **按设备配置通知偏好**:每台设备都可以分别选择哪些 Agent、终端和插件事件发送通知,插件现在也可以发送通知并处理点击。([#10888](https://github.com/getpaseo/paseo/pull/10888))
- **智能体配置文件系统提示词**:在智能体配置文件中保存可选的系统提示词,以便在通过该配置启动新 Agent 时应用。([#10996](https://github.com/getpaseo/paseo/pull/10996))
- **更多语法高亮语言**:语法高亮现已支持 diff 和 patch 文件,以及 Ruby、Kotlin、TOML、SQL、Lua、Protobuf、PowerShell、Groovy、Gradle、Scala、CMake、Properties、INI、R、Perl 和 LaTeX。([#11026](https://github.com/getpaseo/paseo/pull/11026),贡献者:[@hmalaspina](https://github.com/hmalaspina), [@kukicola](https://github.com/kukicola), [@MaximeConan](https://github.com/MaximeConan), [@singleton11](https://github.com/singleton11), [@chandlerok](https://github.com/chandlerok))
### 变更
- ACP Provider 现在会在 daemon 重启间将已发现的模型目录缓存到磁盘,不再在后台轮询,同时清理了多余的 Antigravity ACP 参数和元数据。需要 [Antigravity CLI 1.5.1 或更高版本](https://paseo.sh/zh-CN/docs/supported-providers/antigravity) ([#10992](https://github.com/getpaseo/paseo/pull/10992))
### 修复
- 修复已启用的客户端插件导入 `react-native` 时,Paseo iOS 在连接后不久崩溃的问题 ([#11011](https://github.com/getpaseo/paseo/pull/11011))
- 修复流事件丢失或对话历史较大时,OpenCode v2 Agent 在点击停止后仍停留在运行中的问题 ([#10955](https://github.com/getpaseo/paseo/pull/10955))
- 修复在 Pi Agent 运行其自行启动的轮次时发送引导消息会中止该轮次而不是引导它的问题 ([#10977](https://github.com/getpaseo/paseo/pull/10977),贡献者:[@viiqswim](https://github.com/viiqswim))
- 修复在 fork 克隆中根据 PR 创建工作区时,检出到 fork 中同编号 PR 的问题 ([#10987](https://github.com/getpaseo/paseo/pull/10987))
- 修复向 Composer 拖放图片或文件后输入框未获得焦点的问题 ([#11022](https://github.com/getpaseo/paseo/pull/11022))
## 0.17.6 - 2026-11-27
### 改进
+3 -1
View File
@@ -80,7 +80,9 @@ Provider checks follow the signals their runtimes expose:
- Codex queries background terminals for loaded threads, including native children, and protects
pending provider requests. App servers without the terminal-list RPC stay resident.
- OpenCode checks active executions and descendants. V1 checks PTYs; v2 also checks shell and
inbox inventories. The shared server remains leased while a session vetoes collection.
inbox inventories. The shared server remains leased while a session vetoes collection. V2 lets
another session's execution veto only when releasing the lease would stop the server; the shared
server stays up after its last lease goes.
- Pi checks streaming, compaction, pending replies, and adapter-owned operations. Known native
subagent signals also protect their parent through the daemon's subagent store.
- OMP additionally requires `get_state.isSettled: true` and `hasPendingAsyncWork: false`.
@@ -0,0 +1,4 @@
- Remote workspace browser proxy: Desktop browser tabs in remote workspaces now route through the workspace daemon, so remote localhost servers open directly in Paseo.
- Per-device notification preferences: Each device can choose which agent, terminal, and plugin events send notifications, and plugins can send notifications and handle taps.
Full notes: https://paseo.sh/changelog
@@ -0,0 +1,4 @@
- Remote workspace browser proxy: Desktop browser tabs in remote workspaces now route through the workspace daemon, so remote localhost servers open directly in Paseo.
- Per-device notification preferences: Each device can choose which agent, terminal, and plugin events send notifications, and plugins can send notifications and handle taps.
Full notes: https://paseo.sh/changelog
@@ -0,0 +1,4 @@
- Remote workspace browser proxy: Desktop browser tabs in remote workspaces now route through the workspace daemon, so remote localhost servers open directly in Paseo.
- Per-device notification preferences: Each device can choose which agent, terminal, and plugin events send notifications, and plugins can send notifications and handle taps.
Full notes: https://paseo.sh/changelog
@@ -0,0 +1,4 @@
- Remote workspace browser proxy: Desktop browser tabs in remote workspaces now route through the workspace daemon, so remote localhost servers open directly in Paseo.
- Per-device notification preferences: Each device can choose which agent, terminal, and plugin events send notifications, and plugins can send notifications and handle taps.
Full notes: https://paseo.sh/changelog
+1 -1
View File
@@ -1 +1 @@
sha256-kzMT9+KlfYhaEa643XUTzxOA4Y8+zdpdXEs2QguED7w=
sha256-SZV3WTKLb+JhxWNo/jWyx+2sipzfL93YbbqQSihd3Wo=
+29 -29
View File
@@ -1,12 +1,12 @@
{
"name": "paseo",
"version": "0.17.6",
"version": "0.18.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "paseo",
"version": "0.17.6",
"version": "0.18.0",
"hasInstallScript": true,
"license": "Apache-2.0",
"workspaces": [
@@ -37541,7 +37541,7 @@
},
"packages/app": {
"name": "@getpaseo/app",
"version": "0.17.6",
"version": "0.18.0",
"dependencies": {
"@codemirror/commands": "6.10.4",
"@codemirror/language": "6.12.4",
@@ -39694,13 +39694,13 @@
},
"packages/cli": {
"name": "@getpaseo/cli",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"@clack/prompts": "^1.0.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/server": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/server": "0.18.0",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"mime-types": "^2.1.35",
@@ -39947,11 +39947,11 @@
},
"packages/client": {
"name": "@getpaseo/client",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"@getpaseo/protocol": "0.17.6",
"@getpaseo/relay": "0.17.6",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"ws": "^8.20.0",
"zod": "^4.4.3"
},
@@ -39963,7 +39963,7 @@
},
"packages/desktop": {
"name": "@getpaseo/desktop",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"@getpaseo/cli": "*",
@@ -40206,7 +40206,7 @@
},
"packages/expo-two-way-audio": {
"name": "@getpaseo/expo-two-way-audio",
"version": "0.17.6",
"version": "0.18.0",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.14",
@@ -40252,7 +40252,7 @@
},
"packages/highlight": {
"name": "@getpaseo/highlight",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"@codemirror/language": "6.12.4",
@@ -40282,7 +40282,7 @@
},
"packages/plugin": {
"name": "@getpaseo/plugin",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"@agentclientprotocol/sdk": "^1.4.0",
@@ -40290,8 +40290,8 @@
"use-sync-external-store": "^1.6.0"
},
"devDependencies": {
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@types/node": "^20.9.0",
"@types/react": "~19.2.0",
"react": "19.2.3",
@@ -40301,8 +40301,8 @@
"zod": "^4.4.3"
},
"peerDependencies": {
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"react": ">=19.1.0 <20",
"react-native": ">=0.81.5",
"zod": "^4.4.3"
@@ -40324,7 +40324,7 @@
},
"packages/protocol": {
"name": "@getpaseo/protocol",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"semver": "^7.8.5",
@@ -40351,7 +40351,7 @@
}
},
"packages/react-native-enriched-markdown": {
"version": "0.17.6",
"version": "0.18.0",
"hasInstallScript": true,
"license": "MIT",
"peerDependencies": {
@@ -40367,7 +40367,7 @@
},
"packages/relay": {
"name": "@getpaseo/relay",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"dependencies": {
"@noble/ciphers": "^2.4.0",
@@ -40589,17 +40589,17 @@
},
"packages/server": {
"name": "@getpaseo/server",
"version": "0.17.6",
"version": "0.18.0",
"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.17.6",
"@getpaseo/highlight": "0.17.6",
"@getpaseo/plugin": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/relay": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/highlight": "0.18.0",
"@getpaseo/plugin": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"@isaacs/ttlcache": "^2.1.4",
"@modelcontextprotocol/node": "2.1.2",
"@modelcontextprotocol/sdk": "1.29.0",
@@ -41550,7 +41550,7 @@
},
"packages/website": {
"name": "@getpaseo/website",
"version": "0.17.6",
"version": "0.18.0",
"dependencies": {
"@cloudflare/vite-plugin": "^1.29.1",
"@cloudflare/workers-types": "^4.20260317.1",
@@ -43161,7 +43161,7 @@
},
"plugins": {
"name": "@getpaseo/builtin-plugins",
"version": "0.17.6",
"version": "0.18.0",
"dependencies": {
"@getpaseo/plugin": "*",
"zod": "^4.4.3"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "paseo",
"version": "0.17.6",
"version": "0.18.0",
"private": true,
"description": "Paseo: voice-controlled development environment for local AI coding agents",
"keywords": [
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/app",
"version": "0.17.6",
"version": "0.18.0",
"private": true,
"main": "index.ts",
"scripts": {
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/cli",
"version": "0.17.6",
"version": "0.18.0",
"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.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/server": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/server": "0.18.0",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"mime-types": "^2.1.35",
@@ -2,6 +2,11 @@ const { randomUUID } = require("node:crypto");
const { appendFileSync } = require("node:fs");
const { createInterface } = require("node:readline");
if (process.argv.slice(2).includes("--version")) {
process.stdout.write("1.5.18\n");
process.exit(0);
}
const eventsPath = process.argv[2];
const record = (event) => appendFileSync(eventsPath, JSON.stringify(event) + "\n");
const modes = {
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/client",
"version": "0.17.6",
"version": "0.18.0",
"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.17.6",
"@getpaseo/relay": "0.17.6",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"ws": "^8.20.0",
"zod": "^4.4.3"
},
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/desktop",
"version": "0.17.6",
"version": "0.18.0",
"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.17.6",
"version": "0.18.0",
"description": "Native module for two way audio streaming",
"keywords": [
"ExpoTwoWayAudio",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/highlight",
"version": "0.17.6",
"version": "0.18.0",
"license": "Apache-2.0",
"files": [
"dist",
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/plugin",
"version": "0.17.6",
"version": "0.18.0",
"description": "Paseo plugin SDK package",
"license": "Apache-2.0",
"files": [
@@ -83,8 +83,8 @@
"use-sync-external-store": "^1.6.0"
},
"devDependencies": {
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@types/node": "^20.9.0",
"@types/react": "~19.2.0",
"react": "19.2.3",
@@ -94,8 +94,8 @@
"zod": "^4.4.3"
},
"peerDependencies": {
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"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.17.6",
"version": "0.18.0",
"description": "Paseo shared protocol schemas and wire types",
"license": "Apache-2.0",
"files": [
@@ -1,6 +1,6 @@
{
"name": "react-native-enriched-markdown",
"version": "0.17.6",
"version": "0.18.0",
"private": true,
"description": "Markdown-based Rich Text solution for React Native",
"main": "./lib/module/index",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/relay",
"version": "0.17.6",
"version": "0.18.0",
"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.17.6",
"version": "0.18.0",
"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.17.6",
"@getpaseo/highlight": "0.17.6",
"@getpaseo/plugin": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/relay": "0.17.6",
"@getpaseo/client": "0.18.0",
"@getpaseo/highlight": "0.18.0",
"@getpaseo/plugin": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"@isaacs/ttlcache": "^2.1.4",
"@modelcontextprotocol/node": "2.1.2",
"@modelcontextprotocol/sdk": "1.29.0",
@@ -32,6 +32,7 @@ export class V2Harness {
readonly environments: Array<{ sessionID: string; variables: Record<string, string> }> = [];
readonly instructions = new Map<string, string>();
releases = 0;
releaseStopsServer = false;
active = false;
activeReads = 0;
autoComplete = true;
@@ -250,6 +251,7 @@ export class V2Harness {
this.releases += 1;
},
retain: () => this.connection,
releaseStopsServer: () => this.releaseStopsServer,
exited: new Promise<Error>(() => undefined),
};
readonly runtime = { acquire: async () => this.connection, shutdown: async () => undefined };
@@ -2130,7 +2130,7 @@ describe("OpenCode v2 session lifecycle", () => {
});
});
test("OpenCode v2 runtime safety retains shells, queued reports and shared executions", async () => {
test("OpenCode v2 runtime safety retains shells, queued reports and its own executions", async () => {
const harness = new V2Harness();
const client = new OpenCodeV2AgentClient({
logger: createTestLogger(),
@@ -2168,9 +2168,7 @@ test("OpenCode v2 runtime safety retains shells, queued reports and shared execu
];
expect(await session.canStopRuntime!()).toBe(false);
harness.api.session.inbox.list = async () => [];
harness.api.session.active = async () => ({
"unrelated-autonomous-session": { type: "running" },
});
harness.api.session.active = async () => ({ [session.id!]: { type: "running" } });
expect(await session.canStopRuntime!()).toBe(false);
harness.api.session.active = async () => ({});
expect(await session.canStopRuntime!()).toBe(true);
@@ -2183,6 +2181,27 @@ test("OpenCode v2 runtime safety retains shells, queued reports and shared execu
}
});
test("OpenCode v2 runtime safety vetoes another session's execution only when the release stops the server", async () => {
const harness = new V2Harness();
const client = new OpenCodeV2AgentClient({
logger: createTestLogger(),
runtime: harness.runtime,
});
const session = await client.createSession({ provider: "opencode", cwd: "/tmp/project" });
try {
harness.api.session.active = async () => ({
"unrelated-autonomous-session": { type: "running" },
});
// The shared server keeps running after this lease goes, so the other execution is safe.
expect(await session.canStopRuntime!()).toBe(true);
// Releasing the last lease of a dedicated server stops it, with the other execution inside.
harness.releaseStopsServer = true;
expect(await session.canStopRuntime!()).toBe(false);
} finally {
await session.close();
}
});
test("OpenCode v2 runtime safety follows descendant locations before releasing the last lease", async () => {
const harness = new V2Harness();
const child = {
@@ -125,9 +125,15 @@ test("a wrapped caller gets its own helper behind the wrap, and other callers ke
expect(launched.profile).toBe("agent");
expect(launched.argv.slice(0, 4)).toEqual(["--profile", process.execPath, script, "serve"]);
const wrappedAgain = wrapped.retain();
expect(wrapped.releaseStopsServer()).toBe(false);
await wrappedAgain.release();
expect(wrapped.releaseStopsServer()).toBe(true);
await wrapped.release();
await expect(wrapped.exited).resolves.toBeInstanceOf(Error);
await shared.release();
// The shared helper stays up for the next caller after its last lease goes.
expect(sharedAgain.releaseStopsServer()).toBe(false);
await sharedAgain.release();
} finally {
await runtime.shutdown();
@@ -37,6 +37,8 @@ export interface V2Connection {
client: V2Api;
release(): Promise<void>;
retain(): V2Connection;
/** True when releasing this lease would stop the server, with every execution inside it. */
releaseStopsServer(): boolean;
bindSession(sessionId: string, cwd: string): Promise<void>;
unbindSession(sessionId: string, cwd: string): Promise<void>;
refreshLocation(cwd: string, signal?: AbortSignal): Promise<void>;
@@ -174,6 +176,7 @@ export class V2Runtime {
client: generation.client,
release,
retain: () => this.lease(generation, pending),
releaseStopsServer: () => !released && generation.users === 1 && this.current !== pending,
bindSession: generation.bindSession,
unbindSession: generation.unbindSession,
refreshLocation: generation.refreshLocation,
@@ -751,12 +751,14 @@ export class OpenCodeV2Session implements AgentSession {
if (this.closed || this.exited || this.reconnecting || this.turns.id || this.dirty)
return false;
const request = { signal: AbortSignal.timeout(10_000) };
// Active executions are server-wide. Releasing the last lease must not stop an
// autonomous execution merely because it belongs to another session or location.
if (Object.keys(await this.client.session.active(request)).length > 0) return false;
const active = await this.client.session.active(request);
// Releasing the last lease of a server stops it, so it must not stop an autonomous
// execution merely because it belongs to another session or location.
if (this.connection.releaseStopsServer() && Object.keys(active).length > 0) return false;
const family = new Map([[this.info.id, this.info]]);
const directories = new Set<string>();
for (const info of family.values()) {
if (active[info.id]) return false;
if ((await this.client.session.inbox.list({ sessionID: info.id }, request)).length)
return false;
directories.add(info.location.directory);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/website",
"version": "0.17.6",
"version": "0.18.0",
"private": true,
"type": "module",
"scripts": {
+108 -4
View File
@@ -5,14 +5,22 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { discover, fetchUsage } from "./usage.js";
import type { UsageReport } from "@getpaseo/plugin/server/usage";
function kimiCredentialPath(dir: string): string {
return join(dir, "credentials", "kimi-code.json");
// The slot the Kimi CLI writes for a login to the global (.ai) deployment.
const GLOBAL_SLOT = "kimi-code-env-0e4f99c69cc27850";
function kimiCredentialPath(dir: string, slot = "kimi-code"): string {
return join(dir, "credentials", `${slot}.json`);
}
function writeKimiCredentials(dir: string, accessToken: string, overrides: object = {}): void {
function writeKimiCredentials(
dir: string,
accessToken: string,
overrides: object = {},
slot = "kimi-code",
): void {
mkdirSync(join(dir, "credentials"), { recursive: true });
writeFileSync(
kimiCredentialPath(dir),
kimiCredentialPath(dir, slot),
JSON.stringify({
access_token: accessToken,
refresh_token: "rt_kimi",
@@ -173,6 +181,102 @@ describe("kimi usage source", () => {
});
});
it("fetches usage from the global deployment for a kimi.ai login", async () => {
writeKimiCredentials(join(homeDir, ".kimi-code"), "kimi_global_token", {}, GLOBAL_SLOT);
let requestedUrl: string | null = null;
let authorization: string | null = null;
fetchApi = (async (url: RequestInfo | URL, init?: RequestInit) => {
requestedUrl = url.toString();
authorization = (init?.headers as Record<string, string> | undefined)?.Authorization ?? null;
return jsonResponse({ usage: { limit: "100", remaining: "60" } });
}) as unknown as typeof fetch;
const kimi = findProvider(await service().listUsage(), "kimi");
expect(requestedUrl).toBe("https://api.kimi.ai/coding/v1/usages");
expect(authorization).toBe("Bearer kimi_global_token");
expect(kimi.status).toBe("available");
});
it("prefers the login the CLI still refreshes over a stale slot", async () => {
const kimiHome = join(homeDir, ".kimi-code");
writeKimiCredentials(kimiHome, "kimi_stale_token", { expires_at: 1_791_426_752 });
writeKimiCredentials(kimiHome, "kimi_live_token", { expires_at: 1_793_292_337 }, GLOBAL_SLOT);
expect(await discover()).toEqual([
{
key: "default",
input: {
store: "file",
locator: kimiCredentialPath(kimiHome, GLOBAL_SLOT),
baseUrl: "https://api.kimi.ai/coding/v1",
},
},
]);
});
it("fetches global usage when an expired default-deployment login remains", async () => {
const kimiHome = join(homeDir, ".kimi-code");
writeKimiCredentials(kimiHome, "expired_default", { expires_at: 1_700_000_000 });
writeKimiCredentials(kimiHome, "live_global", { expires_at: 2_000_000_000 }, GLOBAL_SLOT);
const [account] = await discover();
if (!account) throw new Error("No configured Kimi account");
const requests: string[] = [];
const report = await fetchUsage(
account.input as Parameters<typeof fetchUsage>[0],
async (url, init) => {
requests.push(url.toString());
expect(new Headers(init?.headers).get("Authorization")).toBe("Bearer live_global");
return jsonResponse({ usage: { limit: "100", remaining: "60" } });
},
);
expect(requests).toEqual(["https://api.kimi.ai/coding/v1/usages"]);
expect(report).toMatchObject({ status: "available", windows: [{ usedPct: 40 }] });
});
it("keeps KIMI_CODE_HOME ahead of a newer legacy-home login", async () => {
const selectedHome = join(homeDir, "selected-kimi");
process.env.KIMI_CODE_HOME = selectedHome;
writeKimiCredentials(
selectedHome,
"selected_global_token",
{ expires_at: 2_000_000_000 },
GLOBAL_SLOT,
);
writeKimiCredentials(join(homeDir, ".kimi"), "legacy_token", { expires_at: 2_000_000_100 });
const accounts = await discover();
expect(accounts).toEqual([
{
key: "default",
input: {
store: "file",
locator: kimiCredentialPath(selectedHome, GLOBAL_SLOT),
baseUrl: "https://api.kimi.ai/coding/v1",
},
},
]);
});
it("asks the user to run kimi when the CLI token has expired", async () => {
writeKimiCredentials(join(homeDir, ".kimi-code"), "kimi_cli_token", {
expires_at: 1_700_000_000,
});
const kimi = findProvider(await service().listUsage(), "kimi");
expect(kimi).toEqual({
providerId: "kimi",
status: "unavailable",
problem: { kind: "expired", expiresAt: "2023-11-14T22:13:20.000Z", refreshedBy: "kimi" },
error: null,
planLabel: null,
});
});
it("reads Kimi credentials whose optional fields are null", async () => {
writeKimiCredentials(join(homeDir, ".kimi-code"), "kimi_cli_token", {
expires_at: null,
+43 -17
View File
@@ -1,4 +1,5 @@
import type { UsageInput } from "../shared/input.js";
import { createHash } from "node:crypto";
import { promises as fs } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
@@ -18,7 +19,21 @@ const ApiOptionalStringSchema = z.preprocess(
z.coerce.string().optional(),
);
const KIMI_USAGE_URL = "https://api.kimi.com/coding/v1/usages";
const KIMI_CODE_BASE_URL = "https://api.kimi.com/coding/v1";
// The Kimi CLI's official deployments. A login writes its token to a credential
// slot derived from the deployment, so a global (.ai) login never touches
// kimi-code.json. Mirrors resolveKimiCodeOAuthKey in the Kimi CLI.
const KIMI_CODE_DEPLOYMENTS = [
{ oauthHost: "https://auth.kimi.com", baseUrl: KIMI_CODE_BASE_URL },
{ oauthHost: "https://auth.kimi.ai", baseUrl: "https://api.kimi.ai/coding/v1" },
];
function credentialSlot(deployment: { oauthHost: string; baseUrl: string }): string {
if (deployment.baseUrl === KIMI_CODE_BASE_URL) return "kimi-code";
const hash = createHash("sha256").update(JSON.stringify(deployment)).digest("hex");
return `kimi-code-env-${hash.slice(0, 16)}`;
}
const KimiUsageFieldsSchema = z.object({
limit: ApiOptionalStringSchema,
@@ -257,7 +272,7 @@ export async function fetchUsage(
fetchApi: typeof fetch = fetch,
): Promise<UsageReport> {
async function callUsageApi(token: string): Promise<Response> {
return fetchApi(KIMI_USAGE_URL, {
return fetchApi(`${input.baseUrl ?? KIMI_CODE_BASE_URL}/usages`, {
signal: AbortSignal.timeout(15_000),
headers: {
Authorization: `Bearer ${token}`,
@@ -272,6 +287,7 @@ export async function fetchUsage(
return unavailable({
kind: "expired",
expiresAt: new Date(credentials.expires_at * 1000).toISOString(),
refreshedBy: "kimi",
});
const res = await callUsageApi(credentials.access_token);
@@ -306,21 +322,31 @@ async function readCredentials(input: UsageInput): Promise<KimiCredentials | und
}
}
export async function discover(): Promise<UsageAccount[]> {
const candidates: UsageInput[] = ["KIMI_TOKEN", "KIMI_API_KEY"].map((locator) => ({
store: "env",
locator,
}));
candidates.push(
...[
join(
process.env.KIMI_CODE_HOME || join(homedir(), ".kimi-code"),
"credentials",
"kimi-code.json",
),
join(homedir(), ".kimi", "credentials", "kimi-code.json"),
].map((locator) => ({ store: "file" as const, locator })),
);
for (const input of candidates)
for (const locator of ["KIMI_TOKEN", "KIMI_API_KEY"]) {
const input: UsageInput = { store: "env", locator };
if (await readCredentials(input)) return [{ key: "default", input }];
}
const homes = [
process.env.KIMI_CODE_HOME || join(homedir(), ".kimi-code"),
join(homedir(), ".kimi"),
];
// A login to another deployment leaves the old slot behind with a dead token.
// Within each home, prefer the latest expiry. Keep the configured home ahead
// of the legacy fallback, even if that fallback holds a newer token.
for (const home of homes) {
let found: { input: UsageInput; expiresAt: number } | undefined;
for (const deployment of KIMI_CODE_DEPLOYMENTS) {
const input: UsageInput = {
store: "file",
locator: join(home, "credentials", `${credentialSlot(deployment)}.json`),
baseUrl: deployment.baseUrl,
};
const credentials = await readCredentials(input);
if (!credentials) continue;
const expiresAt = credentials.expires_at ?? Number.POSITIVE_INFINITY;
if (!found || expiresAt > found.expiresAt) found = { input, expiresAt };
}
if (found) return [{ key: "default", input: found.input }];
}
return [];
}
@@ -3,6 +3,7 @@ export const inputSchema = z
.object({
store: z.enum(["env", "file"]),
locator: z.string().min(1),
baseUrl: z.url().optional(),
})
.strict();
export type UsageInput = z.infer<typeof inputSchema>;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/builtin-plugins",
"version": "0.17.6",
"version": "0.18.0",
"private": true,
"type": "module",
"scripts": {
+58 -9
View File
@@ -1,4 +1,4 @@
import { mkdtempSync, rmSync } from "node:fs";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -32,11 +32,13 @@ describe("zai usage source", () => {
process.env["USERPROFILE"] = homeDir;
for (const key of [
"APPDATA",
"XDG_CONFIG_HOME",
"COPILOT_TOKEN",
"GITHUB_TOKEN",
"GITHUB_PAT",
"CURSOR_ACCESS_TOKEN",
"CURSOR_TOKEN",
"Z_AI_API_KEY",
"ZAI_API_KEY",
"GLM_API_KEY",
"GROK_API_KEY",
@@ -116,11 +118,61 @@ describe("zai usage source", () => {
details: expect.arrayContaining([{ id: "status", label: "Status", value: "VALID" }]),
});
});
});
it("discovery returns a locator when fetch finds zai credentials", async () => {
const previous = process.env["ZAI_API_KEY"];
try {
it("fetches Z.ai usage from Z_AI_API_KEY, the name the glm-acp-agent CLI uses", async () => {
process.env["Z_AI_API_KEY"] = "zai_cli_token";
let authorization: string | null = null;
fetchApi = (async (_url: RequestInfo | URL, init?: RequestInit) => {
authorization = (init?.headers as Record<string, string> | undefined)?.Authorization ?? null;
return jsonResponse({ data: [{ productName: "GLM Coding Max", status: "VALID" }] });
}) as unknown as typeof fetch;
const zai = findProvider(await service().listUsage(), "zai");
expect(authorization).toBe("Bearer zai_cli_token");
expect(zai).toMatchObject({ status: "available", planLabel: "GLM Coding Max" });
});
it("reads Z.ai usage from the credentials file the glm-acp-agent CLI writes", async () => {
const configDir = join(homeDir, ".config", "glm-acp-agent");
mkdirSync(configDir, { recursive: true });
writeFileSync(
join(configDir, "credentials.json"),
JSON.stringify({ z_ai_api_key: "zai_file_token" }),
);
let authorization: string | null = null;
fetchApi = (async (_url: RequestInfo | URL, init?: RequestInit) => {
authorization = (init?.headers as Record<string, string> | undefined)?.Authorization ?? null;
return jsonResponse({ data: [{ productName: "GLM Coding Max", status: "VALID" }] });
}) as unknown as typeof fetch;
const zai = findProvider(await service().listUsage(), "zai");
expect(authorization).toBe("Bearer zai_file_token");
expect(zai).toMatchObject({ status: "available" });
});
it("honours XDG_CONFIG_HOME for the credentials file", async () => {
const configDir = join(homeDir, "xdg", "glm-acp-agent");
mkdirSync(configDir, { recursive: true });
writeFileSync(
join(configDir, "credentials.json"),
JSON.stringify({ z_ai_api_key: "zai_xdg_token" }),
);
process.env["XDG_CONFIG_HOME"] = join(homeDir, "xdg");
let authorization: string | null = null;
fetchApi = (async (_url: RequestInfo | URL, init?: RequestInit) => {
authorization = (init?.headers as Record<string, string> | undefined)?.Authorization ?? null;
return jsonResponse({ data: [{ productName: "GLM Coding Max", status: "VALID" }] });
}) as unknown as typeof fetch;
const zai = findProvider(await service().listUsage(), "zai");
expect(authorization).toBe("Bearer zai_xdg_token");
expect(zai).toMatchObject({ status: "available" });
});
it("discovery returns a locator when fetch finds zai credentials", async () => {
process.env["ZAI_API_KEY"] = "fixture-token";
let requested = false;
await fetchFirst(async () => {
@@ -131,10 +183,7 @@ it("discovery returns a locator when fetch finds zai credentials", async () => {
expect(await discover()).toEqual([
{ key: "default", input: { store: "env", locator: "ZAI_API_KEY" } },
]);
} finally {
if (previous === undefined) delete process.env["ZAI_API_KEY"];
else process.env["ZAI_API_KEY"] = previous;
}
});
});
describe("account discovery", () => {
+37 -2
View File
@@ -1,4 +1,7 @@
import type { UsageInput } from "../shared/input.js";
import { promises as fs } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import { z } from "zod";
import {
unavailable,
@@ -25,11 +28,16 @@ const ZaiUsageResponseSchema = z.object({
.optional(),
});
/** The credentials file the `glm-acp-agent` CLI writes. */
const ZaiCredentialsSchema = z.object({
z_ai_api_key: z.string().optional(),
});
export async function fetchUsage(
input: UsageInput,
fetchApi: typeof fetch = fetch,
): Promise<UsageReport> {
const token = process.env[input.locator];
const token = await readToken(input);
if (!token) throw new Error("Z.ai login store no longer exists");
const res = await fetchApi("https://api.z.ai/api/biz/subscription/list", {
@@ -64,9 +72,36 @@ export async function fetchUsage(
};
}
/**
* The Z.AI API key comes from the environment or from the credentials file the
* `glm-acp-agent` CLI writes. The CLI names the variable `Z_AI_API_KEY`; the
* older `ZAI_API_KEY` spelling is still accepted.
*/
async function readToken(input: UsageInput): Promise<string | undefined> {
if (input.store === "env") {
return process.env[input.locator];
}
try {
const raw: unknown = JSON.parse(await fs.readFile(input.locator, "utf8"));
return ZaiCredentialsSchema.parse(raw).z_ai_api_key;
} catch {
return undefined;
}
}
export async function discover(): Promise<UsageAccount[]> {
for (const locator of ["ZAI_API_KEY", "GLM_API_KEY"]) {
for (const locator of ["Z_AI_API_KEY", "ZAI_API_KEY", "GLM_API_KEY"]) {
if (process.env[locator]) return [{ key: "default", input: { store: "env", locator } }];
}
const credentialsPath = join(
process.env.XDG_CONFIG_HOME || join(homedir(), ".config"),
"glm-acp-agent",
"credentials.json",
);
if (await readToken({ store: "file", locator: credentialsPath })) {
return [{ key: "default", input: { store: "file", locator: credentialsPath } }];
}
return [];
}
+1 -1
View File
@@ -1,7 +1,7 @@
import { z } from "zod";
export const inputSchema = z
.object({
store: z.literal("env"),
store: z.enum(["env", "file"]),
locator: z.string().min(1),
})
.strict();