Compare commits

..
Author SHA1 Message Date
paseo-bot[bot]andClaude Opus 5.5 878a89b10e test(android): build panel edge tests on the shared mounting context
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 09:33:28 +00:00
paseo-bot[bot]andClaude Opus 5.5 e167602ac5 chore: update panel scrolling branch from main
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 09:12:16 +00:00
paseo-bot[bot] f792ac8a4e chore: update panel scrolling branch from main 2026-11-06 07:49:20 +00:00
paseo-bot[bot] e8a9e2d699 chore(android): carry panel scrolling fix onto the current timeline 2026-11-06 07:48:53 +00:00
paseo-bot[bot]andluckxine 5feec6fa35 fix(android): contain nested panel motion in the current timeline
Identify the forward-order timeline by its existing native identity so panel edges stay still while ordinary parents retain Android handoff. Preserve the native content-position corrections.

Co-authored-by: luckxine <91582901+luckxine@users.noreply.github.com>
2026-11-06 07:46:51 +00:00
paseo-bot[bot]andluckxine 138d9d63ab fix(android): keep panel overscroll inside inverted timelines
Android forwards a nested panel’s unconsumed scroll and fling to its inverted parent, moving the timeline in the opposite visual direction. Keep that motion inside the panel while preserving ordinary parent scrolling and nested-scroll registration.

Co-authored-by: luckxine <91582901+luckxine@users.noreply.github.com>
2026-11-01 14:32:01 +00:00
39 changed files with 293 additions and 410 deletions
-19
View File
@@ -1,24 +1,5 @@
# 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,24 +1,5 @@
# 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
### 改进
+1 -3
View File
@@ -80,9 +80,7 @@ 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. 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.
inbox inventories. The shared server remains leased while a session vetoes collection.
- 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`.
+11 -2
View File
@@ -202,8 +202,17 @@ This is the Android counterpart of the iOS local-simulator flow in [development.
`modules/paseo-scroll` replaces React Native's vertical scroll view with `PaseoScrollView`, which
keeps React Native's scroll manager interface and corrects how the chat timeline holds its position.
[agent-stream-disclosure.md](agent-stream-disclosure.md#scroll-view-corrections) lists the
corrections and the React Native issues they work around. Its instrumentation tests run the scroll
view in a real window, mounting through React Native's own mounting manager and injecting touches:
corrections and the React Native issues they work around.
The timeline's `nativeID` (`agent-chat-scroll-native-virtualized`) also identifies it to the native
scroll owner: a nested panel's edge overshoot and unconsumed fling must leave the timeline still.
Ordinary scroll parents retain Android's handoff. Keep that identity in sync with
`agent-stream/strategy-native.tsx`; the end pin is absent while reading history, so it cannot
identify the timeline for this rule.
Its instrumentation tests run the scroll view in a real window, mounting through React Native's own
mounting manager and injecting touches. `PanelEdgeTest` covers both panel edges, flings,
interior/direct scrolling, and ordinary-parent handoff:
```bash
cd packages/app/android
@@ -1,4 +0,0 @@
- 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,4 +0,0 @@
- 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,4 +0,0 @@
- 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,4 +0,0 @@
- 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-SZV3WTKLb+JhxWNo/jWyx+2sipzfL93YbbqQSihd3Wo=
sha256-kzMT9+KlfYhaEa643XUTzxOA4Y8+zdpdXEs2QguED7w=
+29 -29
View File
@@ -1,12 +1,12 @@
{
"name": "paseo",
"version": "0.18.0",
"version": "0.17.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "paseo",
"version": "0.18.0",
"version": "0.17.6",
"hasInstallScript": true,
"license": "Apache-2.0",
"workspaces": [
@@ -37541,7 +37541,7 @@
},
"packages/app": {
"name": "@getpaseo/app",
"version": "0.18.0",
"version": "0.17.6",
"dependencies": {
"@codemirror/commands": "6.10.4",
"@codemirror/language": "6.12.4",
@@ -39694,13 +39694,13 @@
},
"packages/cli": {
"name": "@getpaseo/cli",
"version": "0.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"dependencies": {
"@clack/prompts": "^1.0.0",
"@getpaseo/client": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/server": "0.18.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/server": "0.17.6",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"mime-types": "^2.1.35",
@@ -39947,11 +39947,11 @@
},
"packages/client": {
"name": "@getpaseo/client",
"version": "0.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"dependencies": {
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/relay": "0.17.6",
"ws": "^8.20.0",
"zod": "^4.4.3"
},
@@ -39963,7 +39963,7 @@
},
"packages/desktop": {
"name": "@getpaseo/desktop",
"version": "0.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"dependencies": {
"@getpaseo/cli": "*",
@@ -40206,7 +40206,7 @@
},
"packages/expo-two-way-audio": {
"name": "@getpaseo/expo-two-way-audio",
"version": "0.18.0",
"version": "0.17.6",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.14",
@@ -40252,7 +40252,7 @@
},
"packages/highlight": {
"name": "@getpaseo/highlight",
"version": "0.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"dependencies": {
"@codemirror/language": "6.12.4",
@@ -40282,7 +40282,7 @@
},
"packages/plugin": {
"name": "@getpaseo/plugin",
"version": "0.18.0",
"version": "0.17.6",
"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.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@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.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"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.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"dependencies": {
"semver": "^7.8.5",
@@ -40351,7 +40351,7 @@
}
},
"packages/react-native-enriched-markdown": {
"version": "0.18.0",
"version": "0.17.6",
"hasInstallScript": true,
"license": "MIT",
"peerDependencies": {
@@ -40367,7 +40367,7 @@
},
"packages/relay": {
"name": "@getpaseo/relay",
"version": "0.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"dependencies": {
"@noble/ciphers": "^2.4.0",
@@ -40589,17 +40589,17 @@
},
"packages/server": {
"name": "@getpaseo/server",
"version": "0.18.0",
"version": "0.17.6",
"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.18.0",
"@getpaseo/highlight": "0.18.0",
"@getpaseo/plugin": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"@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",
"@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.18.0",
"version": "0.17.6",
"dependencies": {
"@cloudflare/vite-plugin": "^1.29.1",
"@cloudflare/workers-types": "^4.20260317.1",
@@ -43161,7 +43161,7 @@
},
"plugins": {
"name": "@getpaseo/builtin-plugins",
"version": "0.18.0",
"version": "0.17.6",
"dependencies": {
"@getpaseo/plugin": "*",
"zod": "^4.4.3"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "paseo",
"version": "0.18.0",
"version": "0.17.6",
"private": true,
"description": "Paseo: voice-controlled development environment for local AI coding agents",
"keywords": [
@@ -0,0 +1,158 @@
package sh.paseo.scroll
import android.app.Activity
import android.content.Intent
import android.os.SystemClock
import android.view.View
import android.widget.FrameLayout
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.react.uimanager.DisplayMetricsHolder
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.views.scroll.ReactScrollView
import com.facebook.react.views.scroll.ReactScrollViewManager
import com.facebook.react.views.view.ReactViewGroup
import com.facebook.soloader.SoLoader
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
/** Forward-order parent, as used by the current Android timeline, and a nested panel at its edge. */
@RunWith(AndroidJUnit4::class)
class PanelEdgeTest {
private val instrumentation = InstrumentationRegistry.getInstrumentation()
private var activity: Activity? = null
private lateinit var manager: ReactScrollViewManager
@After fun finish() {
instrumentation.runOnMainSync { activity?.finish() }
}
@Test fun panelBottomEdgeLeavesTimelineStill() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
child.scrollTo(0, 600)
assertTrue(child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
child.dispatchNestedScroll(0, 0, 0, 100, null)
child.stopNestedScroll()
assertEquals("Panel stays at its bottom", 600, child.scrollY)
assertEquals("Panel overshoot must leave timeline still", 400, parent.scrollY)
}
}
@Test fun panelTopEdgeLeavesTimelineStill() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
child.scrollTo(0, 0)
assertTrue(child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
child.dispatchNestedScroll(0, 0, 0, -100, null)
child.stopNestedScroll()
assertEquals("Panel stays at its top", 0, child.scrollY)
assertEquals("Panel overshoot must leave timeline still", 400, parent.scrollY)
}
}
@Test fun panelFlingLeavesTimelineStill() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
child.scrollTo(0, 600)
assertTrue(child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
child.dispatchNestedFling(0f, 1500f, false)
child.stopNestedScroll()
}
SystemClock.sleep(500)
instrumentation.runOnMainSync {
assertEquals("Panel fling must leave timeline still", 400, parent.scrollY)
}
}
@Test fun disablingChildNestedScrollPreventsHandoff() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
child.isNestedScrollingEnabled = false
assertEquals(false, child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
child.dispatchNestedScroll(0, 0, 0, 100, null)
assertEquals(400, parent.scrollY)
}
}
@Test fun ordinaryParentStillConsumesNestedOvershoot() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
manager.setNativeId(parent, "ordinary-scroll-parent")
assertTrue(child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
child.dispatchNestedScroll(0, 0, 0, 100, null)
child.stopNestedScroll()
assertEquals("Ordinary parent retains framework handoff", 500, parent.scrollY)
}
}
@Test fun ordinaryParentStillConsumesUnconsumedFling() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
manager.setNativeId(parent, "ordinary-scroll-parent")
child.scrollTo(0, 600)
assertTrue(child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
child.dispatchNestedFling(0f, 1500f, false)
child.stopNestedScroll()
}
SystemClock.sleep(500)
instrumentation.runOnMainSync { assertTrue(parent.scrollY > 400) }
}
@Test fun consumedPanelFlingDoesNotStartParentFling() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
assertTrue(child.startNestedScroll(View.SCROLL_AXIS_VERTICAL))
assertEquals(false, child.dispatchNestedFling(0f, 1500f, true))
child.stopNestedScroll()
assertEquals(400, parent.scrollY)
}
}
@Test fun panelInteriorScrollingLeavesTimelineStill() {
val (parent, child) = openPanel()
instrumentation.runOnMainSync {
child.scrollTo(0, 100)
assertEquals(100, child.scrollY)
assertEquals(400, parent.scrollY)
parent.scrollTo(0, 500)
assertEquals("Direct timeline scrolling remains available", 500, parent.scrollY)
}
}
private fun openPanel(): Pair<ReactScrollView, ReactScrollView> {
val started = instrumentation.startActivitySync(
Intent(instrumentation.targetContext, Activity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
activity = started
lateinit var parent: ReactScrollView
lateinit var child: ReactScrollView
instrumentation.runOnMainSync {
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(started)
SoLoader.init(started, OpenSourceMergedSoMapping)
val react = MountingReactContext(started.applicationContext)
val context = ThemedReactContext(react, started)
manager = PaseoScrollPackage().createViewManager(react, ReactScrollViewManager.REACT_CLASS) as ReactScrollViewManager
parent = manager.createViewInstance(context)
manager.setNativeId(parent, "agent-chat-scroll-native-virtualized")
child = manager.createViewInstance(context)
child.isNestedScrollingEnabled = true
val content = ReactViewGroup(context)
content.addView(child, FrameLayout.LayoutParams(300, 200).apply { topMargin = 400 })
parent.addView(content)
val childContent = ReactViewGroup(context)
child.addView(childContent)
started.setContentView(FrameLayout(started).apply { addView(parent, FrameLayout.LayoutParams(300, 400)) })
parent.layout(0, 0, 300, 400)
content.layout(0, 0, 300, 2000)
child.layout(0, 400, 300, 600)
childContent.layout(0, 0, 300, 800)
parent.scrollTo(0, 400)
}
return Pair(parent, child)
}
}
@@ -14,10 +14,13 @@ import com.facebook.react.views.scroll.ReactScrollView;
import com.facebook.react.views.scroll.ReactScrollViewHelper;
/**
* React Native's vertical scroll view with five corrections. Java, because the content-position
* React Native's vertical scroll view with six corrections. Java, because the content-position
* config type is internal to React Native's Kotlin module.
*/
final class PaseoScrollView extends ReactScrollView {
// The chat timeline, packages/app/src/agent-stream/strategy-native.tsx.
private static final String TIMELINE_NATIVE_ID = "agent-chat-scroll-native-virtualized";
// The chat timeline's end pin, packages/app/src/agent-stream/native-end-pin.tsx.
private static final String END_PIN_NATIVE_ID = "paseo-end-pin";
@@ -35,6 +38,26 @@ final class PaseoScrollView extends ReactScrollView {
super(context);
}
// A panel owns its gesture through its edges; remaining child motion must not move the chat
// behind it. The timeline's native identity stays present when its end pin is removed for
// reading history. Ordinary parents retain Android's nested-scroll handoff.
@Override
public void onNestedScroll(
View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
if (isTimeline()) return;
super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
}
@Override
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
if (isTimeline() && !consumed) return true;
return super.onNestedFling(target, velocityX, velocityY, consumed);
}
private boolean isTimeline() {
return TIMELINE_NATIVE_ID.equals(getTag(R.id.view_tag_native_id));
}
@Override
public void setMaintainVisibleContentPosition(
@Nullable MaintainVisibleScrollPositionHelper.Config config) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/app",
"version": "0.18.0",
"version": "0.17.6",
"private": true,
"main": "index.ts",
"scripts": {
@@ -775,6 +775,7 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
extraData={renderHistoryMountedRow}
keyExtractor={keyExtractor}
testID="agent-chat-scroll"
// The Android scroll owner identifies the timeline to contain nested panel gestures.
nativeID="agent-chat-scroll-native-virtualized"
ListHeaderComponent={historyStartContent}
ListFooterComponent={liveAuxiliaryContent ?? undefined}
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/cli",
"version": "0.18.0",
"version": "0.17.6",
"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.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/server": "0.18.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/server": "0.17.6",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"mime-types": "^2.1.35",
@@ -2,11 +2,6 @@ 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.18.0",
"version": "0.17.6",
"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.18.0",
"@getpaseo/relay": "0.18.0",
"@getpaseo/protocol": "0.17.6",
"@getpaseo/relay": "0.17.6",
"ws": "^8.20.0",
"zod": "^4.4.3"
},
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/desktop",
"version": "0.18.0",
"version": "0.17.6",
"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.18.0",
"version": "0.17.6",
"description": "Native module for two way audio streaming",
"keywords": [
"ExpoTwoWayAudio",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/highlight",
"version": "0.18.0",
"version": "0.17.6",
"license": "Apache-2.0",
"files": [
"dist",
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@getpaseo/plugin",
"version": "0.18.0",
"version": "0.17.6",
"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.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"@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.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/client": "0.17.6",
"@getpaseo/protocol": "0.17.6",
"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.18.0",
"version": "0.17.6",
"description": "Paseo shared protocol schemas and wire types",
"license": "Apache-2.0",
"files": [
@@ -1,6 +1,6 @@
{
"name": "react-native-enriched-markdown",
"version": "0.18.0",
"version": "0.17.6",
"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.18.0",
"version": "0.17.6",
"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.18.0",
"version": "0.17.6",
"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.18.0",
"@getpaseo/highlight": "0.18.0",
"@getpaseo/plugin": "0.18.0",
"@getpaseo/protocol": "0.18.0",
"@getpaseo/relay": "0.18.0",
"@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",
"@isaacs/ttlcache": "^2.1.4",
"@modelcontextprotocol/node": "2.1.2",
"@modelcontextprotocol/sdk": "1.29.0",
@@ -32,7 +32,6 @@ 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;
@@ -251,7 +250,6 @@ 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 its own executions", async () => {
test("OpenCode v2 runtime safety retains shells, queued reports and shared executions", async () => {
const harness = new V2Harness();
const client = new OpenCodeV2AgentClient({
logger: createTestLogger(),
@@ -2168,7 +2168,9 @@ test("OpenCode v2 runtime safety retains shells, queued reports and its own exec
];
expect(await session.canStopRuntime!()).toBe(false);
harness.api.session.inbox.list = async () => [];
harness.api.session.active = async () => ({ [session.id!]: { type: "running" } });
harness.api.session.active = async () => ({
"unrelated-autonomous-session": { type: "running" },
});
expect(await session.canStopRuntime!()).toBe(false);
harness.api.session.active = async () => ({});
expect(await session.canStopRuntime!()).toBe(true);
@@ -2181,27 +2183,6 @@ test("OpenCode v2 runtime safety retains shells, queued reports and its own exec
}
});
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,15 +125,9 @@ 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,8 +37,6 @@ 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>;
@@ -176,7 +174,6 @@ 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,14 +751,12 @@ 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) };
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;
// 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 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.18.0",
"version": "0.17.6",
"private": true,
"type": "module",
"scripts": {
+4 -108
View File
@@ -5,22 +5,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { discover, fetchUsage } from "./usage.js";
import type { UsageReport } from "@getpaseo/plugin/server/usage";
// 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 kimiCredentialPath(dir: string): string {
return join(dir, "credentials", "kimi-code.json");
}
function writeKimiCredentials(
dir: string,
accessToken: string,
overrides: object = {},
slot = "kimi-code",
): void {
function writeKimiCredentials(dir: string, accessToken: string, overrides: object = {}): void {
mkdirSync(join(dir, "credentials"), { recursive: true });
writeFileSync(
kimiCredentialPath(dir, slot),
kimiCredentialPath(dir),
JSON.stringify({
access_token: accessToken,
refresh_token: "rt_kimi",
@@ -181,102 +173,6 @@ 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,
+17 -43
View File
@@ -1,5 +1,4 @@
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";
@@ -19,21 +18,7 @@ const ApiOptionalStringSchema = z.preprocess(
z.coerce.string().optional(),
);
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 KIMI_USAGE_URL = "https://api.kimi.com/coding/v1/usages";
const KimiUsageFieldsSchema = z.object({
limit: ApiOptionalStringSchema,
@@ -272,7 +257,7 @@ export async function fetchUsage(
fetchApi: typeof fetch = fetch,
): Promise<UsageReport> {
async function callUsageApi(token: string): Promise<Response> {
return fetchApi(`${input.baseUrl ?? KIMI_CODE_BASE_URL}/usages`, {
return fetchApi(KIMI_USAGE_URL, {
signal: AbortSignal.timeout(15_000),
headers: {
Authorization: `Bearer ${token}`,
@@ -287,7 +272,6 @@ 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);
@@ -322,31 +306,21 @@ async function readCredentials(input: UsageInput): Promise<KimiCredentials | und
}
}
export async function discover(): Promise<UsageAccount[]> {
for (const locator of ["KIMI_TOKEN", "KIMI_API_KEY"]) {
const input: UsageInput = { store: "env", locator };
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)
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,7 +3,6 @@ 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.18.0",
"version": "0.17.6",
"private": true,
"type": "module",
"scripts": {
+9 -58
View File
@@ -1,4 +1,4 @@
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -32,13 +32,11 @@ 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",
@@ -118,61 +116,11 @@ describe("zai usage source", () => {
details: expect.arrayContaining([{ id: "status", label: "Status", value: "VALID" }]),
});
});
});
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 () => {
it("discovery returns a locator when fetch finds zai credentials", async () => {
const previous = process.env["ZAI_API_KEY"];
try {
process.env["ZAI_API_KEY"] = "fixture-token";
let requested = false;
await fetchFirst(async () => {
@@ -183,7 +131,10 @@ describe("zai usage source", () => {
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", () => {
+2 -37
View File
@@ -1,7 +1,4 @@
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,
@@ -28,16 +25,11 @@ 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 = await readToken(input);
const token = process.env[input.locator];
if (!token) throw new Error("Z.ai login store no longer exists");
const res = await fetchApi("https://api.z.ai/api/biz/subscription/list", {
@@ -72,36 +64,9 @@ 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 ["Z_AI_API_KEY", "ZAI_API_KEY", "GLM_API_KEY"]) {
for (const locator of ["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.enum(["env", "file"]),
store: z.literal("env"),
locator: z.string().min(1),
})
.strict();