mirror of
https://github.com/anomalyco/opencode.git
synced 2026-10-08 16:25:33 +00:00
Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d4f99f93d | ||
|
|
194e51321d | ||
|
|
0621ea9d9f | ||
|
|
62e087ff7b | ||
|
|
da40b8fbe3 | ||
|
|
2f1a0e72af | ||
|
|
434f7b2a36 | ||
|
|
93afa91904 | ||
|
|
d869df3801 | ||
|
|
9e100f4f88 | ||
|
|
a19285d10d | ||
|
|
f108fa4928 | ||
|
|
a80ca68c96 | ||
|
|
c9e1ed7080 | ||
|
|
8f4861875f | ||
|
|
6861df7638 | ||
|
|
53533fd0bf | ||
|
|
3b684acd8d | ||
|
|
5d05835023 | ||
|
|
0d07f915d2 | ||
|
|
216c311744 | ||
|
|
6297cd5a0b | ||
|
|
c28e9ec311 | ||
|
|
c4327a67fa | ||
|
|
6b9f03b13f |
No files matched your search
@@ -33,7 +33,7 @@
|
||||
},
|
||||
"packages/ai": {
|
||||
"name": "@opencode/ai",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@aws-sdk/credential-providers": "3.1057.0",
|
||||
"@opencode/schema": "workspace:*",
|
||||
@@ -55,7 +55,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@opencode/app",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@corvu/drawer": "catalog:",
|
||||
"@dnd-kit/abstract": "0.5.0",
|
||||
@@ -112,7 +112,7 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@opencode/cli",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"bin": {
|
||||
"opencode": "./bin/opencode.cjs",
|
||||
"opencode2": "./bin/opencode2.cjs",
|
||||
@@ -131,6 +131,7 @@
|
||||
"@opencode/util": "workspace:*",
|
||||
"@opentui/core": "catalog:",
|
||||
"@opentui/solid": "catalog:",
|
||||
"@opentunnel/client": "0.2.0",
|
||||
"@parcel/watcher": "2.5.1",
|
||||
"@silvia-odwyer/photon-node": "0.3.4",
|
||||
"diff": "catalog:",
|
||||
@@ -179,7 +180,7 @@
|
||||
},
|
||||
"packages/client": {
|
||||
"name": "@opencode/client",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/protocol": "workspace:*",
|
||||
"@opencode/schema": "workspace:*",
|
||||
@@ -204,7 +205,7 @@
|
||||
},
|
||||
"packages/codemode": {
|
||||
"name": "@opencode/codemode",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"acorn": "8.15.0",
|
||||
"effect": "catalog:",
|
||||
@@ -217,7 +218,7 @@
|
||||
},
|
||||
"packages/console/app": {
|
||||
"name": "@opencode/console-app",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "1.15.2",
|
||||
"@ibm/plex": "6.4.1",
|
||||
@@ -253,7 +254,7 @@
|
||||
},
|
||||
"packages/console/core": {
|
||||
"name": "@opencode/console-core",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-sts": "3.782.0",
|
||||
"@jsx-email/render": "1.1.1",
|
||||
@@ -280,7 +281,7 @@
|
||||
},
|
||||
"packages/console/function": {
|
||||
"name": "@opencode/console-function",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@openauthjs/openauth": "0.0.0-20250322224806",
|
||||
"@opencode/console-core": "workspace:*",
|
||||
@@ -297,7 +298,7 @@
|
||||
},
|
||||
"packages/console/mail": {
|
||||
"name": "@opencode/console-mail",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@jsx-email/all": "2.2.3",
|
||||
"@jsx-email/cli": "1.4.3",
|
||||
@@ -321,7 +322,7 @@
|
||||
},
|
||||
"packages/console/support": {
|
||||
"name": "@opencode/console-support",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "1.15.2",
|
||||
"@opencode/console-core": "workspace:*",
|
||||
@@ -341,7 +342,7 @@
|
||||
},
|
||||
"packages/core": {
|
||||
"name": "@opencode/core",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@ai-sdk/cohere": "3.0.27",
|
||||
"@ai-sdk/perplexity": "3.0.26",
|
||||
@@ -406,7 +407,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@opencode/desktop",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@zip.js/zip.js": "2.7.62",
|
||||
"electron-context-menu": "5.0.0",
|
||||
@@ -451,7 +452,7 @@
|
||||
},
|
||||
"packages/enterprise": {
|
||||
"name": "@opencode/enterprise",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@hono/standard-validator": "catalog:",
|
||||
"@opencode-ai/sdk": "1.18.21",
|
||||
@@ -488,7 +489,7 @@
|
||||
},
|
||||
"packages/function": {
|
||||
"name": "@opencode/function",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@octokit/auth-app": "8.0.1",
|
||||
"@octokit/rest": "catalog:",
|
||||
@@ -504,7 +505,7 @@
|
||||
},
|
||||
"packages/gui-extensions": {
|
||||
"name": "@opencode/gui-extensions",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@betteroffice/docx": "0.4.3",
|
||||
"@betteroffice/fonts": "0.4.0",
|
||||
@@ -553,7 +554,7 @@
|
||||
},
|
||||
"packages/http-recorder": {
|
||||
"name": "@opencode/http-recorder",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@effect/platform-node-shared": "4.0.0-rc.112",
|
||||
},
|
||||
@@ -572,7 +573,7 @@
|
||||
},
|
||||
"packages/httpapi-codegen": {
|
||||
"name": "@opencode/httpapi-codegen",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"effect": "catalog:",
|
||||
"prettier": "3.6.2",
|
||||
@@ -585,7 +586,7 @@
|
||||
},
|
||||
"packages/latex": {
|
||||
"name": "@opencode/latex",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/plugin": "workspace:*",
|
||||
"@opentui/core": "catalog:",
|
||||
@@ -599,7 +600,7 @@
|
||||
},
|
||||
"packages/merman": {
|
||||
"name": "@opencode/merman",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/plugin": "workspace:*",
|
||||
"@opentui/core": "catalog:",
|
||||
@@ -614,7 +615,7 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@opencode/plugin",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@ai-sdk/provider": "3.0.8",
|
||||
"@opencode/ai": "workspace:*",
|
||||
@@ -638,8 +639,8 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@opencode/theme": "workspace:*",
|
||||
"@opentui/core": ">=0.5.16",
|
||||
"@opentui/solid": ">=0.5.16",
|
||||
"@opentui/core": ">=0.5.17",
|
||||
"@opentui/solid": ">=0.5.17",
|
||||
"solid-js": ">=1.9.0",
|
||||
},
|
||||
"optionalPeers": [
|
||||
@@ -651,7 +652,7 @@
|
||||
},
|
||||
"packages/plugin-browser": {
|
||||
"name": "@opencode/plugin-browser",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/plugin": "workspace:*",
|
||||
"@opencode/schema": "workspace:*",
|
||||
@@ -681,7 +682,7 @@
|
||||
},
|
||||
"packages/protocol": {
|
||||
"name": "@opencode/protocol",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/schema": "workspace:*",
|
||||
"effect": "catalog:",
|
||||
@@ -696,7 +697,7 @@
|
||||
},
|
||||
"packages/schema": {
|
||||
"name": "@opencode/schema",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@standard-schema/spec": "catalog:",
|
||||
"effect": "catalog:",
|
||||
@@ -720,7 +721,7 @@
|
||||
},
|
||||
"packages/sdk": {
|
||||
"name": "@opencode/sdk",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/client": "workspace:*",
|
||||
"@opencode/core": "workspace:*",
|
||||
@@ -741,7 +742,7 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@opencode/server",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@effect/platform-node": "catalog:",
|
||||
"@effect/platform-node-shared": "catalog:",
|
||||
@@ -762,7 +763,7 @@
|
||||
},
|
||||
"packages/session-ui": {
|
||||
"name": "@opencode/session-ui",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@kobalte/core": "catalog:",
|
||||
"@opencode/client": "workspace:*",
|
||||
@@ -797,7 +798,7 @@
|
||||
},
|
||||
"packages/simulation": {
|
||||
"name": "@opencode/simulation",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/ai": "workspace:*",
|
||||
"@opencode/core": "workspace:*",
|
||||
@@ -817,7 +818,7 @@
|
||||
},
|
||||
"packages/stats/app": {
|
||||
"name": "@opencode/stats-app",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@ibm/plex": "6.4.1",
|
||||
"@kobalte/core": "catalog:",
|
||||
@@ -851,7 +852,7 @@
|
||||
},
|
||||
"packages/stats/core": {
|
||||
"name": "@opencode/stats-core",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-athena": "3.933.0",
|
||||
"@planetscale/database": "1.19.0",
|
||||
@@ -870,7 +871,7 @@
|
||||
},
|
||||
"packages/stats/server": {
|
||||
"name": "@opencode/stats-server",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-firehose": "3.933.0",
|
||||
"@effect/platform-node": "catalog:",
|
||||
@@ -916,7 +917,7 @@
|
||||
},
|
||||
"packages/theme": {
|
||||
"name": "@opencode/theme",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opentui/core": "catalog:",
|
||||
"effect": "catalog:",
|
||||
@@ -930,7 +931,7 @@
|
||||
},
|
||||
"packages/tui": {
|
||||
"name": "@opencode/tui",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@opencode/client": "workspace:*",
|
||||
"@opencode/core": "workspace:*",
|
||||
@@ -964,8 +965,9 @@
|
||||
},
|
||||
"packages/ui": {
|
||||
"name": "@opencode/ui",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@kitlangton/solid-motion": "0.2.2",
|
||||
"@kobalte/core": "catalog:",
|
||||
"@pierre/diffs": "catalog:",
|
||||
"@solid-primitives/event-listener": "catalog:",
|
||||
@@ -973,7 +975,6 @@
|
||||
"fuzzysort": "catalog:",
|
||||
"katex": "0.16.47",
|
||||
"marked": "catalog:",
|
||||
"marked-katex-extension": "5.1.13",
|
||||
"marked-shiki": "catalog:",
|
||||
"motion": "12.34.5",
|
||||
"remeda": "catalog:",
|
||||
@@ -1000,7 +1001,7 @@
|
||||
},
|
||||
"packages/util": {
|
||||
"name": "@opencode/util",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@effect/opentelemetry": "catalog:",
|
||||
"@effect/platform-node": "catalog:",
|
||||
@@ -1038,7 +1039,7 @@
|
||||
},
|
||||
"packages/web": {
|
||||
"name": "@opencode/web",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@astrojs/cloudflare": "12.6.3",
|
||||
"@astrojs/markdown-remark": "6.3.1",
|
||||
@@ -1079,7 +1080,7 @@
|
||||
},
|
||||
"services/update": {
|
||||
"name": "@opencode/update",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"jose": "6.0.11",
|
||||
"semver": "catalog:",
|
||||
@@ -1156,9 +1157,9 @@
|
||||
"@npmcli/arborist": "9.4.0",
|
||||
"@octokit/rest": "22.0.0",
|
||||
"@openauthjs/openauth": "0.0.0-20250322224806",
|
||||
"@opentui/core": "0.5.16",
|
||||
"@opentui/keymap": "0.5.16",
|
||||
"@opentui/solid": "0.5.16",
|
||||
"@opentui/core": "0.5.17",
|
||||
"@opentui/keymap": "0.5.17",
|
||||
"@opentui/solid": "0.5.17",
|
||||
"@pierre/diffs": "1.5.1",
|
||||
"@playwright/test": "1.59.1",
|
||||
"@sentry/solid": "10.71.0",
|
||||
@@ -2018,6 +2019,8 @@
|
||||
|
||||
"@jsx-email/text": ["@jsx-email/text@1.0.2", "", { "peerDependencies": { "react": "^18.2.0" } }, "sha512-0zzwEwrKtY6tfjPJF0r3krKCDpP/ySYDvkn4+MvIFrIH5RZKmn3XDa5o/3hkbxMwpLn4MsXGIXn9XzMTaqTfUA=="],
|
||||
|
||||
"@kitlangton/solid-motion": ["@kitlangton/solid-motion@0.2.2", "", { "dependencies": { "motion-dom": "14.0.0", "motion-utils": "14.0.0" }, "peerDependencies": { "solid-js": "^1.8.0" } }, "sha512-Fp7T8gJta3aRGJakBPQ6WIWmF6U6TmWhT6sGNNgkBiJ8cOVfuKkF9yYXzhvgRtKpo7WfzxtNLku907dLHhTDtw=="],
|
||||
|
||||
"@kobalte/core": ["@kobalte/core@0.13.13", "", { "dependencies": { "@floating-ui/dom": "^1.5.1", "@internationalized/number": "^3.2.1", "@kobalte/utils": "^0.9.2", "@solid-primitives/props": "^3.1.8", "@solid-primitives/resize-observer": "^2.0.26", "solid-presence": "^0.2.0", "solid-prevent-scroll": "^0.1.11" }, "peerDependencies": { "solid-js": "^1.9.8" } }, "sha512-czBC+IQdOgJoW7DJjeh0rht7SPmTPgWsKg7Jo3RHMfwx028WxJtDylx9dJuJuD/GUae15+E4nYafu8LwuixFYQ=="],
|
||||
|
||||
"@kobalte/utils": ["@kobalte/utils@0.9.2", "", { "dependencies": { "@solid-primitives/event-listener": "^2.2.14", "@solid-primitives/keyed": "^1.2.0", "@solid-primitives/map": "^0.4.7", "@solid-primitives/media": "^2.2.4", "@solid-primitives/props": "^3.1.8", "@solid-primitives/refs": "^1.0.5", "@solid-primitives/utils": "^6.2.1" }, "peerDependencies": { "solid-js": "^1.8.8" } }, "sha512-jRVXr+zsVHxzDXRoh+CDeXzvCsFJ6uiHhqqNQ26Cw9ZsZ3D6nqPUBt1gGVtj2ZPmRL3a9Uk1v8D1aJ8/I12Dow=="],
|
||||
@@ -2302,27 +2305,31 @@
|
||||
|
||||
"@opentelemetry/semantic-conventions": ["@opentelemetry/semantic-conventions@1.43.0", "", {}, "sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg=="],
|
||||
|
||||
"@opentui/core": ["@opentui/core@0.5.16", "", { "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.5.16", "@opentui/core-darwin-x64": "0.5.16", "@opentui/core-linux-arm64": "0.5.16", "@opentui/core-linux-arm64-musl": "0.5.16", "@opentui/core-linux-x64": "0.5.16", "@opentui/core-linux-x64-musl": "0.5.16", "@opentui/core-win32-arm64": "0.5.16", "@opentui/core-win32-x64": "0.5.16" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-RDVip7Ih8Lg5tFkwTDGFqc0TXx8A+rRvm3UuDAqd9YayDx4fIsECBjSS8FDPLYvq5KP1gJB4oY8iGM8WgTbNqw=="],
|
||||
"@opentui/core": ["@opentui/core@0.5.17", "", { "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.5.17", "@opentui/core-darwin-x64": "0.5.17", "@opentui/core-linux-arm64": "0.5.17", "@opentui/core-linux-arm64-musl": "0.5.17", "@opentui/core-linux-x64": "0.5.17", "@opentui/core-linux-x64-musl": "0.5.17", "@opentui/core-win32-arm64": "0.5.17", "@opentui/core-win32-x64": "0.5.17" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-75vMaKPKc6tnnUWEultPxiiSU0kqNSdAjbcsFGQecjCF4Z1Jrr4NZBiRo3SoMciai/nq24JCiYcVqPjaKtl/6Q=="],
|
||||
|
||||
"@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.5.16", "", { "os": "darwin", "cpu": "arm64" }, "sha512-mbdp/A2KJOv7hI0b0ezqZx/5vh5G6LwhZnjRW4K3hNcoZM4yC55y/D+L8J960rT4o7QRB3cNXr3NSlnVi1btZA=="],
|
||||
"@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.5.17", "", { "os": "darwin", "cpu": "arm64" }, "sha512-ptobzW+1zM29nHvadwy+8uW9jvV8NJr63vcQXWe2rQNtpwN/6k7lEXWiS5LndeBs9AMV5tTsXMEMhttgts4BDQ=="],
|
||||
|
||||
"@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.5.16", "", { "os": "darwin", "cpu": "x64" }, "sha512-D1oA0VBitDHOYrg58GaxQQNAXJ1nSFwu2HQMZklL/LkrqZLX23K/oxgutH/GKvLsyRQNsIVfsXmGZ2LtGiGpxA=="],
|
||||
"@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.5.17", "", { "os": "darwin", "cpu": "x64" }, "sha512-6yLbnElIZPxhZSrZSyS4mB5+k0YFlpRO0Q8uX4sLFTmvOy8tIeDPFcTGRQqZQ1Rk938tiAhf7iyAX3P1wL4Liw=="],
|
||||
|
||||
"@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.5.16", "", { "os": "linux", "cpu": "arm64" }, "sha512-ghu4tKIR3wZMZ8Ih/VLeyyG/C7kQgAZuKoGKRSUPcVEF6Qr99yHhtIixBrBoFXfqVm63n5lGimS6KKqbdUQ1yA=="],
|
||||
"@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.5.17", "", { "os": "linux", "cpu": "arm64" }, "sha512-HO3dYgzQBGJhe58uJauVClIJg3vToYl/LZa7ZzqxQ+3vZ//cxaJ7tgXhHWR2uJE02550yI69e5nqBpSOTT9E8Q=="],
|
||||
|
||||
"@opentui/core-linux-arm64-musl": ["@opentui/core-linux-arm64-musl@0.5.16", "", { "os": "linux", "cpu": "arm64" }, "sha512-t1vppHpf6iR7k+JF6kQtcLKr11gIxm2nH1h9y3eawrG4NCXDQbOvn7XtC6KsT3I1iy0A2Yy+nM0heISziORZlQ=="],
|
||||
"@opentui/core-linux-arm64-musl": ["@opentui/core-linux-arm64-musl@0.5.17", "", { "os": "linux", "cpu": "arm64" }, "sha512-QMRdDbmR0LwpmX1HXVbN+V3A44/QsbWzMsF3V7cEz7MaDq6RNBs3CUFqfkPorKgPtI75T0AxM7FdJnjt9C4d0Q=="],
|
||||
|
||||
"@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.5.16", "", { "os": "linux", "cpu": "x64" }, "sha512-y63M7JrjfAQPUwTXogDGqBjS46DfC51LebBUQYVE01/N2F1inybD08qEfxUAFx/Omlf7CXef6liLDdRyTLaohw=="],
|
||||
"@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.5.17", "", { "os": "linux", "cpu": "x64" }, "sha512-lNmtQlcwsio4IVo2trc0QoMyun31UsN0mzmSc2BtYMOeOC5e0PyWaEAZWJb/g6AinOs9xwJGL02JAN5J3QPWsw=="],
|
||||
|
||||
"@opentui/core-linux-x64-musl": ["@opentui/core-linux-x64-musl@0.5.16", "", { "os": "linux", "cpu": "x64" }, "sha512-lQ1kRwFPBRElG2uFl0afWzpHyUwVEizbV2Ue1IA8DXH15sRCOd7KqeOltpzuKJYIyLey7vLF8SofAe8K1JNnTg=="],
|
||||
"@opentui/core-linux-x64-musl": ["@opentui/core-linux-x64-musl@0.5.17", "", { "os": "linux", "cpu": "x64" }, "sha512-M2RatQaeET/werHFSH+cg7OkQk/Wn0VoVXZLLEL7DiCDTuhZyMfi3uFDz0+R1IGiiUITqHWpZdZ1LdBY8NCjwQ=="],
|
||||
|
||||
"@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.5.16", "", { "os": "win32", "cpu": "arm64" }, "sha512-cML9+1tqEe+SaB5xlx9jKcYAIG15Eg9sImH/LYyMbm+al7dRBNy5IzdFCldXfwC50blM/goiyzLN1CjTo02vCQ=="],
|
||||
"@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.5.17", "", { "os": "win32", "cpu": "arm64" }, "sha512-MyVVpZ0CyGDQ+g4eM0zURqEd/9jDrBIPcZdLyZOmWbdoVu36PLM9KAkqwl/n5ASn/rOrQd+d14jUAsZJvFTqzw=="],
|
||||
|
||||
"@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.5.16", "", { "os": "win32", "cpu": "x64" }, "sha512-1QZ9yHK9xTZBNXVgjPfbdQ94nfw0/KZic9XkuAsNBzUGTkYmfGKZSvPB1YKomBt/1lipRoCdMAnihlS/R7g5eg=="],
|
||||
"@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.5.17", "", { "os": "win32", "cpu": "x64" }, "sha512-etkuzyfclRX9wel4ivCOk90dUdZNtjK7U6vr7ZHmwkZyOik34ec3Gse0B/jyk192Xdx0l50Tl2xgC1h68XRiEQ=="],
|
||||
|
||||
"@opentui/keymap": ["@opentui/keymap@0.5.16", "", { "dependencies": { "@opentui/core": "0.5.16" }, "peerDependencies": { "@opentui/react": "0.5.16", "@opentui/solid": "0.5.16", "react": ">=19.2.0", "solid-js": "1.9.12" }, "optionalPeers": ["@opentui/react", "@opentui/solid", "react", "solid-js"] }, "sha512-W78sDuTHMjHa8NwYmoGx5Xy0ztcGsuzrUa/1d24jADj9JCYEJQjABnrWZBRSExsNjiFYV3SxeCKwAPhJli0M3g=="],
|
||||
"@opentui/keymap": ["@opentui/keymap@0.5.17", "", { "dependencies": { "@opentui/core": "0.5.17" }, "peerDependencies": { "@opentui/react": "0.5.17", "@opentui/solid": "0.5.17", "react": ">=19.2.0", "solid-js": "1.9.12" }, "optionalPeers": ["@opentui/react", "@opentui/solid", "react", "solid-js"] }, "sha512-y8UdvkOhQVM+e5VlCv/f7m8AxVEWeXoHnjhxZ2SEXA+HKDfWjXjkptAyRhyMZ8wRgtNv2LJiSTHfzelBQk5Syg=="],
|
||||
|
||||
"@opentui/solid": ["@opentui/solid@0.5.16", "", { "dependencies": { "@babel/core": "7.29.7", "@babel/preset-typescript": "7.27.1", "@opentui/core": "0.5.16", "babel-plugin-module-resolver": "5.0.2", "babel-preset-solid": "1.9.12", "entities": "7.0.1", "s-js": "^0.4.9" }, "peerDependencies": { "solid-js": "1.9.12" } }, "sha512-gCULWG+HORd5IVydiCchlmULgY1PQccODJvJKDNYJHDmhwyg9/sNSFUxoYajEXLZ40pUIL8ENAK+6p34Z9m/JQ=="],
|
||||
"@opentui/solid": ["@opentui/solid@0.5.17", "", { "dependencies": { "@babel/core": "7.29.7", "@babel/preset-typescript": "7.27.1", "@opentui/core": "0.5.17", "babel-plugin-module-resolver": "5.0.2", "babel-preset-solid": "1.9.12", "entities": "7.0.1", "s-js": "^0.4.9" }, "peerDependencies": { "solid-js": "1.9.12" } }, "sha512-YShxRqJYyg3ysh4qR2NpCDhr+I1OpIfmcn8nQch7EsBpmUOZh8INqThQI722tXBULOAYhOQWqzr5APjJxYDFbQ=="],
|
||||
|
||||
"@opentunnel/client": ["@opentunnel/client@0.2.0", "", { "dependencies": { "@opentunnel/protocol": "0.2.0", "effect": "4.0.0-rc.112" } }, "sha512-UHbLK+y2aPdcTuu4FaCz3Ezcm52Z4TxGp5Hdy9aLYLsz9GUlPpPFaYXjdq8pFyfQlA9qAyI/z5zx5FlZx3aSbw=="],
|
||||
|
||||
"@opentunnel/protocol": ["@opentunnel/protocol@0.2.0", "", { "dependencies": { "effect": "4.0.0-rc.112" } }, "sha512-XQAm3InG70HysML+NiSPxCCfoP+ZzWuxXcCFFFh/qxrvMxuJyOrxsPT49vTo2rDCgrYYdbiFqpz8oXIJh0BYXw=="],
|
||||
|
||||
"@oslojs/asn1": ["@oslojs/asn1@1.0.0", "", { "dependencies": { "@oslojs/binary": "1.0.0" } }, "sha512-zw/wn0sj0j0QKbIXfIlnEcTviaCzYOY3V5rAyjR6YtOByFtJiT574+8p9Wlach0lZH9fddD4yb9laEAIl4vXQA=="],
|
||||
|
||||
@@ -4620,8 +4627,6 @@
|
||||
|
||||
"marked": ["marked@18.0.11", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-HnslJfsZkRPBDJRHvVtAaWlZHEpSu7u8LgQuJCELjRKuWR+hpq4A7sLq3p8HaI9ypVoXDXxV34CsQJEe1+J5Aw=="],
|
||||
|
||||
"marked-katex-extension": ["marked-katex-extension@5.1.13", "", { "peerDependencies": { "katex": ">=0.16 <0.19", "marked": ">=4 <19" } }, "sha512-+6gVygGg5at9g+YsuIQZk7XcAc6Pg1P0grEJKEWvF7DAwceZ7ZIvU0fhQe6auUqSbnPmSjJxZuICdSCdbGaFRw=="],
|
||||
|
||||
"marked-shiki": ["marked-shiki@1.2.1", "", { "peerDependencies": { "marked": ">=7.0.0", "shiki": ">=1.0.0" } }, "sha512-yHxYQhPY5oYaIRnROn98foKhuClark7M373/VpLxiy5TrDu9Jd/LsMwo8w+U91Up4oDb9IXFrP0N1MFRz8W/DQ=="],
|
||||
|
||||
"marky": ["marky@1.3.0", "", {}, "sha512-ocnPZQLNpvbedwTy9kNrQEsknEfgvcLMvOtz3sFeWApDq1MXH1TqkCIx58xlpESsfwQOnuBO9beyQuNGzVvuhQ=="],
|
||||
@@ -4790,9 +4795,9 @@
|
||||
|
||||
"motion": ["motion@12.34.5", "", { "dependencies": { "framer-motion": "^12.34.5", "tslib": "^2.4.0" }, "peerDependencies": { "@emotion/is-prop-valid": "*", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@emotion/is-prop-valid", "react", "react-dom"] }, "sha512-N06NLJ9IeBHeielRqIvYvjPfXuRdyTxa+9++BgpGa+hY2D7TcMkI6QzV3jaRuv0aZRXgMa7cPy9YcBUBisPzAQ=="],
|
||||
|
||||
"motion-dom": ["motion-dom@12.43.0", "", { "dependencies": { "motion-utils": "^12.39.0" } }, "sha512-azKON4d9S65PEoFUiQTMTgPheEmzf2QngdRc50AKfJp9Q9mmcBVw22c8eMq9k8kxOFHdL7+WZY7N/5F/lwiDag=="],
|
||||
"motion-dom": ["motion-dom@14.0.0", "", { "dependencies": { "motion-utils": "14.0.0" } }, "sha512-aU3ApXo1yTpeUi3JU+jbDk2TELjxPE3MbBMUP7nZHlARb6RweJK+ojmLjpuB0YsY6zhbBl1YWGo8LMsI1/Llqw=="],
|
||||
|
||||
"motion-utils": ["motion-utils@12.39.0", "", {}, "sha512-8nadJAJjTtqRkmRF36FoJTrywK9nnFmnPwnSMyxaOCU7GDjN9RTMJIxx9De8ErM+vpPhMccr/6fo5WciyQLnMQ=="],
|
||||
"motion-utils": ["motion-utils@14.0.0", "", {}, "sha512-jBsyjVxTTRZNeuvd/v+btVXr90LQkYl4HhRu9T2ARc+PMnvkmjsjRVeAg4Qm10b6TlTw+kykWI8gu/6LuvpLSQ=="],
|
||||
|
||||
"mrmime": ["mrmime@2.0.1", "", {}, "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ=="],
|
||||
|
||||
@@ -7462,6 +7467,10 @@
|
||||
|
||||
"minipass-pipeline/minipass/yallist": ["yallist@4.0.0", "", {}, "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="],
|
||||
|
||||
"motion/framer-motion/motion-dom": ["motion-dom@12.43.0", "", { "dependencies": { "motion-utils": "^12.39.0" } }, "sha512-azKON4d9S65PEoFUiQTMTgPheEmzf2QngdRc50AKfJp9Q9mmcBVw22c8eMq9k8kxOFHdL7+WZY7N/5F/lwiDag=="],
|
||||
|
||||
"motion/framer-motion/motion-utils": ["motion-utils@12.39.0", "", {}, "sha512-8nadJAJjTtqRkmRF36FoJTrywK9nnFmnPwnSMyxaOCU7GDjN9RTMJIxx9De8ErM+vpPhMccr/6fo5WciyQLnMQ=="],
|
||||
|
||||
"openid-client/lru-cache/yallist": ["yallist@4.0.0", "", {}, "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="],
|
||||
|
||||
"p-locate/p-limit/yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
exact = true
|
||||
# Only install newly resolved package versions published at least 3 days ago.
|
||||
minimumReleaseAge = 259200
|
||||
minimumReleaseAgeExcludes = ["@ai-sdk/amazon-bedrock", "@ai-sdk/anthropic", "@brendonovich/vite-plugin-opencode", "@opencode/sdk", "@opencode-ai/pty", "@opencode-ai/pty-darwin-arm64", "@opencode-ai/pty-darwin-x64", "@opencode-ai/pty-linux-arm64-gnu", "@opencode-ai/pty-linux-arm64-musl", "@opencode-ai/pty-linux-x64-gnu", "@opencode-ai/pty-linux-x64-musl", "@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid", "opentui-spinner", "gitlab-ai-provider", "opencode-gitlab-auth", "@ff-labs/fff-node", "@ff-labs/fff-bun", "@ff-labs/fff-bin-darwin-arm64", "@ff-labs/fff-bin-darwin-x64", "@ff-labs/fff-bin-linux-arm64-gnu", "@ff-labs/fff-bin-linux-arm64-musl", "@ff-labs/fff-bin-linux-x64-gnu", "@ff-labs/fff-bin-linux-x64-musl", "@ff-labs/fff-bin-win32-arm64", "@ff-labs/fff-bin-win32-x64", "@pierre/diffs", "@pierre/theming", "app-builder-lib", "dmg-builder", "electron", "electron-builder", "electron-publish", "blume", "mermaid"]
|
||||
minimumReleaseAgeExcludes = ["@ai-sdk/amazon-bedrock", "@ai-sdk/anthropic", "@brendonovich/vite-plugin-opencode", "@kitlangton/solid-motion", "@opencode/sdk", "@opencode-ai/pty", "@opencode-ai/pty-darwin-arm64", "@opencode-ai/pty-darwin-x64", "@opencode-ai/pty-linux-arm64-gnu", "@opencode-ai/pty-linux-arm64-musl", "@opencode-ai/pty-linux-x64-gnu", "@opencode-ai/pty-linux-x64-musl", "@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid", "@opentunnel/client", "@opentunnel/protocol", "opentui-spinner", "gitlab-ai-provider", "opencode-gitlab-auth", "@ff-labs/fff-node", "@ff-labs/fff-bun", "@ff-labs/fff-bin-darwin-arm64", "@ff-labs/fff-bin-darwin-x64", "@ff-labs/fff-bin-linux-arm64-gnu", "@ff-labs/fff-bin-linux-arm64-musl", "@ff-labs/fff-bin-linux-x64-gnu", "@ff-labs/fff-bin-linux-x64-musl", "@ff-labs/fff-bin-win32-arm64", "@ff-labs/fff-bin-win32-x64", "@pierre/diffs", "@pierre/theming", "app-builder-lib", "dmg-builder", "electron", "electron-builder", "electron-publish", "blume", "mermaid"]
|
||||
|
||||
[test]
|
||||
root = "./do-not-run-tests-from-root"
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"nodeModules": {
|
||||
"x86_64-linux": "sha256-GHLheOh+zY847BpZ9G/vCfjPT7jUt8doODFOQP9REjw=",
|
||||
"aarch64-linux": "sha256-+To0HYoZzNJ5Qd7y22/ZvljcxQbchGBvYaCPYhte2As=",
|
||||
"aarch64-darwin": "sha256-KVGWrTpe8SB8PgKAyb+2FFRBvXLkJlJVsVTHa/bUhg0="
|
||||
"x86_64-linux": "sha256-6+0Lqv+/nZL4+9QF2SVh21VqMhicCnt84lUvlxoQxjc=",
|
||||
"aarch64-linux": "sha256-tmKG8kZUa6w6PlX1dKeeNY4dYH6wPV4gBs6ynbvLwz4=",
|
||||
"aarch64-darwin": "sha256-Khb55UlgZo39zOQ7OCkJXJ8Zottv7SQy3D8N8nlOn/I="
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "opencode",
|
||||
"description": "AI-powered development tool",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "bun@1.4.2",
|
||||
@@ -53,9 +53,9 @@
|
||||
"@octokit/rest": "22.0.0",
|
||||
"@hono/standard-validator": "0.2.0",
|
||||
"@hono/zod-validator": "0.4.2",
|
||||
"@opentui/core": "0.5.16",
|
||||
"@opentui/keymap": "0.5.16",
|
||||
"@opentui/solid": "0.5.16",
|
||||
"@opentui/core": "0.5.17",
|
||||
"@opentui/keymap": "0.5.17",
|
||||
"@opentui/solid": "0.5.17",
|
||||
"@tanstack/solid-virtual": "3.13.37",
|
||||
"@shikijs/stream": "4.4.3",
|
||||
"@standard-schema/spec": "1.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"name": "@opencode/ai",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Effect, Option } from "effect"
|
||||
import { AIError, LLMEvent, type ProviderMetadata, type ToolCall } from "../../schema/index.js"
|
||||
import { AIError, LLMEvent, type ProviderMetadata, type ToolCall, type ToolInputError } from "../../schema/index.js"
|
||||
import { eventError, parseToolInput, type ToolAccumulator } from "../shared.js"
|
||||
import { parse } from "./partial-json.js"
|
||||
|
||||
@@ -79,16 +79,6 @@ const inputDelta = (tool: PendingTool, text: string): LLMEvent => {
|
||||
const toolCall = (route: string, tool: PendingTool, inputOverride?: string) => {
|
||||
const raw = inputOverride ?? tool.input
|
||||
return parseToolInput(route, tool.name, raw).pipe(
|
||||
Effect.catch((error) =>
|
||||
tool.providerExecuted
|
||||
? Effect.fail(error)
|
||||
: Effect.succeed(
|
||||
Option.getOrElse(
|
||||
Option.map(parsePartialInput(raw), (input) => input ?? {}),
|
||||
() => ({}),
|
||||
),
|
||||
),
|
||||
),
|
||||
Effect.map(
|
||||
(input): ToolCall =>
|
||||
LLMEvent.toolCall({
|
||||
@@ -100,10 +90,15 @@ const toolCall = (route: string, tool: PendingTool, inputOverride?: string) => {
|
||||
providerMetadata: tool.providerMetadata,
|
||||
}),
|
||||
),
|
||||
Effect.catch((error) =>
|
||||
tool.providerExecuted
|
||||
? Effect.fail(error)
|
||||
: Effect.succeed(LLMEvent.toolInputError({ id: tool.id, name: tool.name, namespace: tool.namespace, raw })),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
const finishEvents = (tool: PendingTool, event: ToolCall): ReadonlyArray<LLMEvent> => [
|
||||
const finishEvents = (tool: PendingTool, event: ToolCall | ToolInputError): ReadonlyArray<LLMEvent> => [
|
||||
LLMEvent.toolInputEnd({
|
||||
id: tool.id,
|
||||
name: tool.name,
|
||||
@@ -206,7 +201,7 @@ export const appendExisting = <K extends StreamKey>(
|
||||
|
||||
/**
|
||||
* Finalize one pending tool call: parse the accumulated raw JSON, remove it
|
||||
* from state, and recover incomplete local arguments when needed.
|
||||
* from state, and reject malformed local arguments without repairing them.
|
||||
* Missing keys are a no-op because some providers emit stop events for
|
||||
* non-tool content blocks.
|
||||
*/
|
||||
|
||||
@@ -91,7 +91,7 @@ const configuredRoute = (input: Config, modelID: string | ModelID) => {
|
||||
provider: id,
|
||||
message: "Google Vertex tuned models do not support Express Mode API keys",
|
||||
})
|
||||
const location = GoogleVertexShared.location(inputLocation, "us-central1")
|
||||
const location = GoogleVertexShared.location(inputLocation, "global")
|
||||
const project = GoogleVertexShared.project(inputProject)
|
||||
const endpoint =
|
||||
baseURL ??
|
||||
|
||||
@@ -1131,7 +1131,7 @@ describe("Bedrock Converse route", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("recovers incomplete tool input at finalization", () =>
|
||||
it.effect("rejects incomplete tool input at finalization", () =>
|
||||
Effect.gen(function* () {
|
||||
const body = eventStreamBody(
|
||||
["messageStart", { role: "assistant" }],
|
||||
@@ -1148,10 +1148,11 @@ describe("Bedrock Converse route", () => {
|
||||
)
|
||||
const response = yield* LLMClient.generate(baseRequest).pipe(Effect.provide(fixedBytes(body)))
|
||||
|
||||
expect(response.events.find((event) => event.type === "tool-call")).toMatchObject({
|
||||
expect(response.toolCalls).toEqual([])
|
||||
expect(response.events.find((event) => event.type === "tool-input-error")).toMatchObject({
|
||||
id: "tool_1",
|
||||
name: "lookup",
|
||||
input: { query: "partial" },
|
||||
raw: '{"query":"partial',
|
||||
})
|
||||
expect(response.finishReason).toEqual({ normalized: "tool-calls", raw: "end_turn" })
|
||||
}),
|
||||
|
||||
@@ -4507,7 +4507,7 @@ describe("OpenAI Responses route", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("recovers authoritative incomplete final function arguments", () =>
|
||||
it.effect("rejects authoritative incomplete final function arguments", () =>
|
||||
Effect.gen(function* () {
|
||||
const body = sseEvents(
|
||||
{
|
||||
@@ -4533,17 +4533,17 @@ describe("OpenAI Responses route", () => {
|
||||
}),
|
||||
).pipe(Effect.provide(fixedResponse(body)))
|
||||
|
||||
expect(response.events.find(LLMEvent.is.toolCall)).toMatchObject({
|
||||
expect(response.toolCalls).toEqual([])
|
||||
expect(response.events.find(LLMEvent.is.toolInputError)).toMatchObject({
|
||||
id: "call_1",
|
||||
name: "lookup",
|
||||
input: { query: "partial" },
|
||||
raw: '{"query":"partial',
|
||||
})
|
||||
expect(response.finishReason.normalized).toBe("tool-calls")
|
||||
expect(response.events.some(LLMEvent.is.toolInputError)).toBeFalse()
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("recovers incomplete function arguments when output_item.added is absent", () =>
|
||||
it.effect("rejects incomplete function arguments when output_item.added is absent", () =>
|
||||
Effect.gen(function* () {
|
||||
const body = sseEvents(
|
||||
{
|
||||
@@ -4560,10 +4560,11 @@ describe("OpenAI Responses route", () => {
|
||||
)
|
||||
const response = yield* LLMClient.generate(request).pipe(Effect.provide(fixedResponse(body)))
|
||||
|
||||
expect(response.events.find(LLMEvent.is.toolCall)).toMatchObject({
|
||||
expect(response.toolCalls).toEqual([])
|
||||
expect(response.events.find(LLMEvent.is.toolInputError)).toMatchObject({
|
||||
id: "call_1",
|
||||
name: "lookup",
|
||||
input: { query: "partial" },
|
||||
raw: '{"query":"partial',
|
||||
})
|
||||
expect(response.finishReason.normalized).toBe("tool-calls")
|
||||
}),
|
||||
|
||||
@@ -126,7 +126,7 @@ describe("ToolStream", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("finalizes incomplete local input using the partial JSON parser", () =>
|
||||
it.effect("rejects incomplete final local input", () =>
|
||||
Effect.gen(function* () {
|
||||
const tools = ToolStream.start(ToolStream.empty<string>(), "item_1", {
|
||||
id: "call_1",
|
||||
@@ -139,13 +139,13 @@ describe("ToolStream", () => {
|
||||
tools: {},
|
||||
events: [
|
||||
{ type: "tool-input-end", id: "call_1", name: "lookup" },
|
||||
{ type: "tool-call", id: "call_1", name: "lookup", input: { query: "partial" } },
|
||||
{ type: "tool-input-error", id: "call_1", name: "lookup", raw: '{"query":"partial' },
|
||||
],
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("repairs malformed string escapes in final local input", () =>
|
||||
it.effect("rejects malformed string escapes in final local input", () =>
|
||||
Effect.gen(function* () {
|
||||
const tools = ToolStream.start(ToolStream.empty<string>(), "item_1", {
|
||||
id: "call_1",
|
||||
@@ -156,12 +156,12 @@ describe("ToolStream", () => {
|
||||
|
||||
expect(finished.events).toEqual([
|
||||
{ type: "tool-input-end", id: "call_1", name: "lookup" },
|
||||
{ type: "tool-call", id: "call_1", name: "lookup", input: { path: "A\\H", text: "first\tsecond" } },
|
||||
{ type: "tool-input-error", id: "call_1", name: "lookup", raw: '{"path":"A\\H","text":"first\tsecond"}' },
|
||||
])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("defaults unrecoverable local input to an empty object", () =>
|
||||
it.effect("rejects invalid final local input instead of defaulting to an empty object", () =>
|
||||
Effect.gen(function* () {
|
||||
const tools = ToolStream.start(ToolStream.empty<string>(), "item_1", {
|
||||
id: "call_1",
|
||||
@@ -172,12 +172,12 @@ describe("ToolStream", () => {
|
||||
|
||||
expect(finished.events).toEqual([
|
||||
{ type: "tool-input-end", id: "call_1", name: "lookup" },
|
||||
{ type: "tool-call", id: "call_1", name: "lookup", input: {} },
|
||||
{ type: "tool-input-error", id: "call_1", name: "lookup", raw: "invalid" },
|
||||
])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("recovers incomplete input alongside valid parallel tool calls", () =>
|
||||
it.effect("rejects incomplete input without dropping valid parallel tool calls", () =>
|
||||
Effect.gen(function* () {
|
||||
const valid = ToolStream.start(ToolStream.empty<number>(), 0, {
|
||||
id: "call_valid",
|
||||
@@ -197,7 +197,7 @@ describe("ToolStream", () => {
|
||||
{ type: "tool-input-end", id: "call_valid", name: "lookup" },
|
||||
{ type: "tool-call", id: "call_valid", name: "lookup", input: { query: "weather" } },
|
||||
{ type: "tool-input-end", id: "call_invalid", name: "lookup" },
|
||||
{ type: "tool-call", id: "call_invalid", name: "lookup", input: { query: "partial" } },
|
||||
{ type: "tool-input-error", id: "call_invalid", name: "lookup", raw: '{"query":"partial' },
|
||||
],
|
||||
})
|
||||
}),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { expect, test, type Page } from "@playwright/test"
|
||||
import { holdRoute, NO_PROVIDER, project, REMOTE_SERVER, seed, sessionHref } from "../utils/app"
|
||||
import { expectPath, holdRoute, NO_PROVIDER, project, REMOTE_SERVER, seed, sessionHref } from "../utils/app"
|
||||
import { mockOpenCodeServer } from "../utils/mock-server"
|
||||
import { fixture, mockStressTimeline } from "../utils/session-fixture"
|
||||
import { mockRemoteServer } from "../utils/workspace"
|
||||
import { expectAppVisible } from "../utils/waits"
|
||||
import { APP_READY_TIMEOUT, expectAppVisible } from "../utils/waits"
|
||||
|
||||
test.use({ serviceWorkers: "block" })
|
||||
|
||||
@@ -77,6 +77,33 @@ test("the session context menu renames, exports, and deletes a Home session", as
|
||||
await expect(renamedRow).toBeHidden()
|
||||
})
|
||||
|
||||
test("the Home shortcut focuses session search, and the Home button leaves focus alone", async ({ page }) => {
|
||||
await mockStressTimeline(page)
|
||||
await seed(page, {
|
||||
projects: { local: [{ worktree: fixture.directory, expanded: true }] },
|
||||
lastProject: { local: fixture.directory },
|
||||
tabs: [fixture.sourceID],
|
||||
})
|
||||
await page.goto(sessionHref(fixture.sourceID))
|
||||
const editor = page.locator('[data-component="composer-editor"]')
|
||||
await expect(editor).toBeEditable({ timeout: APP_READY_TIMEOUT })
|
||||
await editor.click()
|
||||
|
||||
await page.keyboard.press("ControlOrMeta+b")
|
||||
const search = page.getByRole("textbox", { name: /Search sessions/ })
|
||||
await expect(search).toBeFocused()
|
||||
await page.keyboard.type("jump")
|
||||
await expect(page.getByRole("option")).toHaveCount(1)
|
||||
await expect(page.getByRole("option")).toContainText(fixture.expected.targetTitle)
|
||||
|
||||
await page.keyboard.press("ControlOrMeta+b")
|
||||
await expectPath(page, sessionHref(fixture.sourceID))
|
||||
|
||||
await page.getByRole("button", { name: "Home", exact: true }).click()
|
||||
await expect(search).toHaveValue("")
|
||||
await expect(search).not.toBeFocused()
|
||||
})
|
||||
|
||||
test("Home shows loaded sessions before the location request resolves", async ({ page }) => {
|
||||
const location = await holdRoute(page, (url) => url.pathname === "/api/location")
|
||||
await openHome(page)
|
||||
|
||||
@@ -143,7 +143,7 @@ test("open file tab browses, searches, and tracks missing files", async ({ page
|
||||
const panel = page.locator("#review-panel")
|
||||
const sidebar = panel.locator('[data-slot="session-review-v2-sidebar"]')
|
||||
const sidebarToggle = panel.getByRole("button", { name: "Toggle file tree" })
|
||||
const contextButton = page.getByRole("button", { name: "View context usage" })
|
||||
const contextButton = page.getByRole("button", { name: "Toggle session context" })
|
||||
const openFile = panel.getByRole("button", { name: "Open file" })
|
||||
const tab = (name: string) => panel.getByRole("tab", { name, exact: true })
|
||||
await contextButton.click()
|
||||
@@ -309,7 +309,7 @@ test("context closes the side region only when its button opened it", async ({ p
|
||||
})
|
||||
const panel = page.locator("#review-panel")
|
||||
const toggle = page.getByRole("button", { name: "Toggle review", exact: true })
|
||||
const contextButton = page.getByRole("button", { name: "View context usage" })
|
||||
const contextButton = page.getByRole("button", { name: "Toggle session context" })
|
||||
const context = panel.getByRole("tab", { name: "Context", exact: true })
|
||||
|
||||
await contextButton.click()
|
||||
@@ -333,6 +333,57 @@ test("context closes the side region only when its button opened it", async ({ p
|
||||
await expect(panel.locator("#session-side-panel-review-tab")).toHaveAttribute("aria-selected", "true")
|
||||
})
|
||||
|
||||
test("context hides free-model cost but keeps paid-model zero cost", async ({ page }) => {
|
||||
const cases = [
|
||||
{ id: "ses_context_free", title: "Free model", model: "free", cost: 0, usage: false, text: "0" },
|
||||
{ id: "ses_context_paid", title: "Paid model", model: "paid", cost: 0, usage: false, text: "0·$0.00" },
|
||||
{ id: "ses_context_used", title: "Paid usage", model: "paid", cost: 1.25, usage: true, text: "2k·$1.25" },
|
||||
{ id: "ses_context_free_used", title: "Free usage", model: "free", cost: 0, usage: true, text: "2k" },
|
||||
{ id: "ses_context_mixed", title: "Previously paid", model: "free", cost: 1.25, usage: true, text: "2k·$1.25" },
|
||||
{ id: "ses_context_unknown", title: "Unknown pricing", model: "missing", cost: 0, usage: false, text: "0·$0.00" },
|
||||
{ id: "ses_context_output", title: "Output pricing", model: "output", cost: 0, usage: false, text: "0·$0.00" },
|
||||
]
|
||||
|
||||
await openSession(page, {
|
||||
name: "ContextPricing",
|
||||
provider: provider(
|
||||
{ id: "free", name: "Free", cost: { input: 0, output: 0 } },
|
||||
{ id: "paid", name: "Paid", cost: { input: 1, output: 3 } },
|
||||
{ id: "output", name: "Output", cost: { input: 0, output: 1 } },
|
||||
),
|
||||
sessions: cases.map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
model: { id: item.model, providerID: "opencode" },
|
||||
cost: item.cost,
|
||||
})),
|
||||
pageMessages: (id) => ({
|
||||
items: cases.flatMap((item): SessionMessageInfo[] =>
|
||||
item.id === id && item.usage
|
||||
? [
|
||||
{
|
||||
id: `msg_${item.id}`,
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { id: item.model, providerID: "opencode" },
|
||||
tokens: { input: 1500, output: 500, reasoning: 0, cache: { read: 0, write: 0 } },
|
||||
content: [{ type: "text", text: "Done." }],
|
||||
time: { created: 1, completed: 2 },
|
||||
},
|
||||
]
|
||||
: [],
|
||||
),
|
||||
}),
|
||||
})
|
||||
const button = page.getByRole("button", { name: "Toggle session context", exact: true })
|
||||
|
||||
for (const item of cases) {
|
||||
await page.locator("[data-titlebar-tab-slot]", { hasText: item.title }).click()
|
||||
await expectSessionTitle(page, item.title)
|
||||
await expect(button).toHaveText(item.text)
|
||||
}
|
||||
})
|
||||
|
||||
test("file tree expands Windows paths and scrolls long names in both directions", async ({ page }) => {
|
||||
const directory = "C:/OpenCode/OpenFileExpand"
|
||||
const longFilename = "a-very-long-file-name-that-must-overflow-the-file-sidebar-instead-of-being-truncated.ts"
|
||||
@@ -630,7 +681,7 @@ test("restores review state and the side-panel tab per session", async ({ page }
|
||||
await page.getByRole("option", { name: "Branch changes" }).click()
|
||||
await page.getByRole("button", { name: "beta.ts" }).click()
|
||||
await selectedFile("beta.ts")
|
||||
await page.getByRole("button", { name: "View context usage" }).click()
|
||||
await page.getByRole("button", { name: "Toggle session context" }).click()
|
||||
await selectedTab("Context")
|
||||
|
||||
await switchSession("Gamma review state")
|
||||
|
||||
@@ -737,15 +737,30 @@ test("/compact runs with the composer model and shows a queued compaction, as in
|
||||
expect(models).toMatchObject([{ model: { id: "queue-model", providerID: "opencode" } }])
|
||||
})
|
||||
|
||||
for (const action of ["Move to queue", "Delete"] as const) {
|
||||
test(`${action} on a pending steer replaces Revert, as in the TUI`, async ({ page }) => {
|
||||
const mock = createQueueMock(["U2: Also check the retry path."])
|
||||
for (const [action, status] of [
|
||||
["Move to queue", "steering"],
|
||||
["Delete", "steering"],
|
||||
["Move to queue", "starting"],
|
||||
["Delete", "starting"],
|
||||
] as const) {
|
||||
test(`${action} on a ${status} pending steer replaces Revert, as in the TUI`, async ({ page }) => {
|
||||
// A steer waits behind work only once the running execution delivered input; before that it is starting.
|
||||
const delivered: SessionMessageInfo[] =
|
||||
status === "steering"
|
||||
? [{ id: "msg_queue_delivered", type: "user", text: "First prompt", time: { created: 1 } }]
|
||||
: []
|
||||
|
||||
const mock = createQueueMock(["U2: Also check the retry path."], delivered)
|
||||
const inboxID = mock.rows[0].id
|
||||
mock.rows[0].delivery = "steer"
|
||||
const view = await openQueue(page, mock)
|
||||
const pending = userRow(page, inboxID)
|
||||
|
||||
await expect(pending).toContainText("U2: Also check the retry path.")
|
||||
const message = pending.locator('[data-component="user-message"]')
|
||||
|
||||
if (status === "steering") await expect(message).toHaveAttribute("data-pending", "true")
|
||||
else await expect(message).not.toHaveAttribute("data-pending")
|
||||
await pending.hover()
|
||||
await expect(pending.getByRole("button", { name: "Revert message" })).toHaveCount(0)
|
||||
await pending.getByRole("button", { name: action }).click()
|
||||
|
||||
@@ -1012,6 +1012,99 @@ test.describe("background shortcut", () => {
|
||||
await expect(backgroundCard).toContainText("Background task (background)")
|
||||
})
|
||||
|
||||
for (const fixture of [
|
||||
{ name: "from far below", before: 40, searches: 40, after: 80 },
|
||||
// The collapsed timeline fits the viewport, so it only becomes scrollable once the group opens.
|
||||
{ name: "that opens the last row", before: 0, searches: 40, after: 0 },
|
||||
// Reaching the shell lands on the end of the timeline, which would otherwise follow new content again.
|
||||
{ name: "at the end of the timeline", before: 40, searches: 0, after: 0 },
|
||||
]) {
|
||||
test(`holds a revealed shell ${fixture.name} just under its stuck group header`, async ({ page }) => {
|
||||
const timeline = await setupTimeline(page, {
|
||||
settings: { timelineDetail: detailed },
|
||||
sessionStatus: { [sessionID]: { type: "busy" } },
|
||||
messages: [
|
||||
userMessage(),
|
||||
assistantMessage(
|
||||
[
|
||||
...(fixture.before ? [textPart("prt_earlier", notes("Earlier", fixture.before))] : []),
|
||||
...searches(0, 42 - fixture.searches),
|
||||
toolPart(
|
||||
"prt_far_shell",
|
||||
"shell",
|
||||
"completed",
|
||||
{ command: "sleep 120" },
|
||||
{ output: "working", metadata: { shellID: "shell_far", status: "running" } },
|
||||
),
|
||||
// The open group outgrows the viewport, so aligning the group instead of the shell misses it.
|
||||
...searches(42 - fixture.searches, fixture.searches),
|
||||
...(fixture.after ? [textPart("prt_follow_up", notes("Follow-up", fixture.after))] : []),
|
||||
],
|
||||
{ completed: false },
|
||||
),
|
||||
],
|
||||
})
|
||||
|
||||
await timeline.transport.send({
|
||||
id: "evt_far_shell_created",
|
||||
created: 3,
|
||||
type: "shell.created",
|
||||
location: { directory },
|
||||
data: {
|
||||
info: {
|
||||
id: "shell_far",
|
||||
status: "running",
|
||||
command: "sleep 120",
|
||||
cwd: directory,
|
||||
shell: "bash",
|
||||
file: "/tmp/far.out",
|
||||
metadata: { sessionID },
|
||||
time: { started: 2 },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const group = page
|
||||
.locator('[data-component="collapsed-tool-group"]')
|
||||
.locator(':scope > [data-component="collapsible"] > [data-slot="collapsible-trigger"]')
|
||||
|
||||
const shellTrigger = page.locator('[data-timeline-part-id="prt_far_shell"] [data-slot="collapsible-trigger"]')
|
||||
|
||||
const aligned = () =>
|
||||
expect
|
||||
.poll(async () => {
|
||||
const [header, shell] = await Promise.all([group.boundingBox(), shellTrigger.boundingBox()])
|
||||
|
||||
return header && shell ? Math.round(shell.y - (header.y + header.height)) : undefined
|
||||
})
|
||||
.toBe(0)
|
||||
|
||||
await expect(
|
||||
fixture.after ? page.getByText(`Follow-up note ${fixture.after}.`, { exact: true }) : group,
|
||||
).toBeInViewport()
|
||||
await expect(shellTrigger).toHaveCount(0)
|
||||
await page.getByRole("button", { name: "1 running", exact: true }).click()
|
||||
await page
|
||||
.getByRole("menu", { name: "1 running", exact: true })
|
||||
.getByRole("menuitem", { name: /sleep 120/ })
|
||||
.click()
|
||||
|
||||
await expect(group).toHaveAttribute("aria-expanded", "true")
|
||||
await expect(shellTrigger).toHaveAttribute("aria-expanded", "true")
|
||||
await expect(shellTrigger).toBeInViewport()
|
||||
|
||||
// A shell at the very end cannot rise under the header until more content arrives below it.
|
||||
if (fixture.searches) await aligned()
|
||||
// Nothing covers the row, so it takes the next click.
|
||||
await shellTrigger.click({ trial: true })
|
||||
|
||||
// The agent keeps writing below the shell; the shell stays where it was revealed.
|
||||
await timeline.send(partUpdated(textPart("prt_late", notes("Late", 30))))
|
||||
await expect(page.getByText("Late note 30.", { exact: true })).toBeAttached()
|
||||
await aligned()
|
||||
})
|
||||
}
|
||||
|
||||
test("hides the running switcher when viewing the only running subagent", async ({ page }) => {
|
||||
const childID = "ses_only_running_child"
|
||||
|
||||
@@ -1735,6 +1828,16 @@ function pauseExitAnimations(locator: Locator) {
|
||||
})
|
||||
}
|
||||
|
||||
function notes(label: string, count: number) {
|
||||
return Array.from({ length: count }, (_, index) => `${label} note ${index + 1}.`).join("\n\n")
|
||||
}
|
||||
|
||||
function searches(from: number, count: number) {
|
||||
return Array.from({ length: count }, (_, index) =>
|
||||
toolPart(`prt_search_${from + index}`, "grep", "completed", { pattern: `needle_${from + index}` }),
|
||||
)
|
||||
}
|
||||
|
||||
function runningSubagent(): SessionMessageAssistant {
|
||||
return {
|
||||
...completed,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/app",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"description": "",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { useCommand } from "@/shell/commands/command"
|
||||
import { useLayout } from "@/shell/state/layout"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { serverName } from "@/runtime/server/registry"
|
||||
import { displayName } from "@opencode/ui/project-avatar"
|
||||
import { sessionLabel } from "@/session/title"
|
||||
import { makeEventListener } from "@solid-primitives/event-listener"
|
||||
import { createMemo, onCleanup } from "solid-js"
|
||||
import { createMemo, onCleanup, onMount } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import type { HomeController } from "../model"
|
||||
import { homeSessionSearchKey, type HomeSessionRecord, type HomeSessionsController } from "./controller"
|
||||
@@ -15,12 +16,19 @@ type HomeSessionSearchSource = Pick<HomeSessionsController, "data" | "session">
|
||||
export function createHomeSessionSearchController(home: HomeController, sessions: HomeSessionSearchSource) {
|
||||
const command = useCommand()
|
||||
const language = useLanguage()
|
||||
const layout = useLayout()
|
||||
|
||||
const [state, setState] = createStore({
|
||||
const [state, setState] = createStore<{
|
||||
value: string
|
||||
focused: boolean
|
||||
highlighted: string
|
||||
exact: HomeSessionRecord | undefined
|
||||
lookingUp: boolean
|
||||
}>({
|
||||
value: "",
|
||||
focused: false,
|
||||
highlighted: "",
|
||||
exact: undefined as HomeSessionRecord | undefined,
|
||||
exact: undefined,
|
||||
lookingUp: false,
|
||||
})
|
||||
|
||||
@@ -78,6 +86,9 @@ export function createHomeSessionSearchController(home: HomeController, sessions
|
||||
}),
|
||||
)
|
||||
onCleanup(() => lookup++)
|
||||
onMount(() => {
|
||||
if (layout.home.searchFocus.take()) focus()
|
||||
})
|
||||
|
||||
command.register("home.search", () => [
|
||||
{
|
||||
|
||||
@@ -195,14 +195,10 @@ export function createActiveSessionRegion(input: {
|
||||
}
|
||||
|
||||
const pendingSteer: NonNullable<SessionUserActions["pending"]> = {
|
||||
steer: (messageID) => {
|
||||
status: (messageID) => {
|
||||
const sessionID = input.session.identity.params.id
|
||||
|
||||
if (!sessionID) return false
|
||||
|
||||
return data.session.pending
|
||||
.list(sessionID)
|
||||
.some((item) => item.id === messageID && item.type === "user" && item.delivery === "steer")
|
||||
return sessionID ? data.session.pending.status(sessionID, messageID) : undefined
|
||||
},
|
||||
queue: ({ sessionID, messageID }) =>
|
||||
server.api.session.inbox
|
||||
|
||||
@@ -110,7 +110,14 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
{ defer: true },
|
||||
),
|
||||
)
|
||||
const [rendering, setRendering] = createStore({ initialTail: coldBottomMount, scrollAdjustment: 0 })
|
||||
|
||||
const [rendering, setRendering] = createStore<{
|
||||
initialTail: boolean
|
||||
scrollAdjustment: number
|
||||
/** A revealed tool whose top edge stays put until the user scrolls. */
|
||||
anchor?: { key: string; partID: string }
|
||||
}>({ initialTail: coldBottomMount, scrollAdjustment: 0 })
|
||||
|
||||
const rows = input.projection.rows
|
||||
const rowByKey = input.projection.rowByKey
|
||||
|
||||
@@ -137,6 +144,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
const id = input.projection.activeMessageID()
|
||||
const active = id ? (input.projection.messageLastRowIndex().get(id) ?? -1) : -1
|
||||
const initialTail = rendering.initialTail && input.pinned()
|
||||
const anchored = rendering.anchor ? rowKeys().indexOf(rendering.anchor.key) : -1
|
||||
|
||||
return (range: Range) => {
|
||||
// Batch a bounded cheap suffix, but stop before unknown/large content.
|
||||
@@ -164,7 +172,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
: defaultRangeExtractor({ ...range, overscan: 2 })
|
||||
|
||||
return filterVirtualIndexes(
|
||||
[...new Set([...indexes, ...(active < 0 ? [] : [active])])].sort((a, b) => a - b),
|
||||
[...new Set([...indexes, ...[active, anchored].filter((index) => index >= 0)])].sort((a, b) => a - b),
|
||||
range.count,
|
||||
)
|
||||
}
|
||||
@@ -336,6 +344,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
})
|
||||
})
|
||||
batchingColdSizes = false
|
||||
pinAnchor()
|
||||
|
||||
if (coldPending) pinColdBottom()
|
||||
settleColdBottom()
|
||||
@@ -403,19 +412,60 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
|
||||
const key = found.group.key
|
||||
|
||||
setToolOpen(
|
||||
found.group.type === "context"
|
||||
? { [`context:${key}`]: true, [`${key}:tool:${found.partID}`]: true }
|
||||
: { [key]: true },
|
||||
)
|
||||
input.onUnpin()
|
||||
prepareNavigation()
|
||||
virtualizer.scrollToIndex(found.index, { align: "center" })
|
||||
// Opening the group and anchoring its row render the tool synchronously, wherever the row is.
|
||||
batch(() => {
|
||||
setToolOpen(
|
||||
found.group.type === "context"
|
||||
? { [`context:${key}`]: true, [`${key}:tool:${found.partID}`]: true }
|
||||
: { [key]: true },
|
||||
)
|
||||
setRendering("anchor", { key: TimelineRow.key(rows()[found.index]!), partID: found.partID })
|
||||
})
|
||||
// Until its ResizeObserver delivers, the opened row keeps its collapsed size, so the timeline may not scroll yet
|
||||
// (and cannot unpin) or ends above the tool. Commit the real size first.
|
||||
const opened = virtualContent?.querySelector<HTMLElement>(`[data-index="${found.index}"]`)
|
||||
|
||||
if (opened) resizeItem(found.index, opened.offsetHeight)
|
||||
input.onUnpin()
|
||||
pinAnchor()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Puts the anchored tool's top edge at its scroll margin, just below the headers that stick above it. Its own
|
||||
// growth extends downward, so only size changes at or above its row can move it; each of those calls this again.
|
||||
function pinAnchor() {
|
||||
const anchor = rendering.anchor
|
||||
const root = listRoot()
|
||||
|
||||
if (!anchor || !root) return
|
||||
const element = virtualContent?.querySelector<HTMLElement>(`[data-timeline-part-id="${CSS.escape(anchor.partID)}"]`)
|
||||
|
||||
// Following the end is a different position to hold.
|
||||
if (!element || !active() || input.pinned()) return releaseAnchor()
|
||||
|
||||
const offset = Math.min(
|
||||
root.scrollHeight - root.clientHeight,
|
||||
Math.max(
|
||||
0,
|
||||
root.scrollTop +
|
||||
element.getBoundingClientRect().top -
|
||||
root.getBoundingClientRect().top -
|
||||
parseFloat(getComputedStyle(element).scrollMarginTop),
|
||||
),
|
||||
)
|
||||
|
||||
if (Math.abs(offset - root.scrollTop) > 1) virtualizer.scrollToOffset(offset)
|
||||
}
|
||||
|
||||
function releaseAnchor() {
|
||||
if (rendering.anchor) setRendering("anchor", undefined)
|
||||
}
|
||||
|
||||
function prepareNavigation() {
|
||||
releaseAnchor()
|
||||
|
||||
if (touchStart === undefined) touchScrolling = false
|
||||
flushTouchAdjustment()
|
||||
}
|
||||
@@ -600,6 +650,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
// Upward input is the one intent geometry cannot recover: nudging up while still a pixel from
|
||||
// the end must stop following, even though the resulting position still looks like the end.
|
||||
const handleListWheel = (event: WheelEvent & { currentTarget: HTMLDivElement }) => {
|
||||
releaseAnchor()
|
||||
input.onUserScroll(event.target)
|
||||
|
||||
if (event.deltaY < 0) input.onUnpin()
|
||||
@@ -607,6 +658,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
|
||||
const handleListTouchStart = (event: TouchEvent) => {
|
||||
clearTouchTarget()
|
||||
releaseAnchor()
|
||||
input.onUserScroll(event.target)
|
||||
touchScrolling = true
|
||||
touchStart = event.touches[0]?.clientY
|
||||
@@ -663,6 +715,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
// Drag-selecting past the edge and dragging the scrollbar both scroll without a wheel or key,
|
||||
// so a held pointer is what separates those from the virtualizer's own measurement adjustments.
|
||||
const handleListPointerDown = (event: PointerEvent & { currentTarget: HTMLDivElement }) => {
|
||||
releaseAnchor()
|
||||
input.onUserScroll(event.target)
|
||||
pointerHeld = true
|
||||
}
|
||||
@@ -688,6 +741,7 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
if (!isScrollKeyTarget(event.target, key)) return
|
||||
|
||||
if (scrollKeyOwner(event.currentTarget, event.target, key) !== event.currentTarget) return
|
||||
releaseAnchor()
|
||||
input.onUserScroll(event.currentTarget)
|
||||
|
||||
if (upwardKeys.has(key)) input.onUnpin()
|
||||
@@ -706,7 +760,8 @@ export function createTimelineVirtualizer(input: Input) {
|
||||
const atEnd = maxScroll - scrollTop <= endEpsilon
|
||||
const arrived = scrollTop > previousTop + endEpsilon || maxScroll < previousMaxScroll
|
||||
|
||||
if (maxScroll <= 1 || (atEnd && arrived)) input.onPin()
|
||||
// An anchor holds its tool even when reaching it lands at the end; only the user's own scroll lets it go.
|
||||
if (maxScroll <= 1 || (atEnd && arrived && !rendering.anchor)) input.onPin()
|
||||
else if ((pointerHeld || touchScrolling) && scrollTop < previousTop - endEpsilon) input.onUnpin()
|
||||
settleColdBottom()
|
||||
input.onScheduleScrollState(root)
|
||||
|
||||
@@ -214,6 +214,9 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
|
||||
sessionTabPreview: {},
|
||||
})
|
||||
|
||||
// Opening Home with its shortcut focuses session search, so typing filters immediately.
|
||||
let homeSearchFocus = false
|
||||
|
||||
// Names of other session-scoped stores, e.g. extension storage, so pruning drops them with the layout state.
|
||||
const [scoped, setScoped, , scopedReady] = persisted(
|
||||
Persist.global("layout.scoped"),
|
||||
@@ -355,6 +358,17 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
|
||||
setSelection(selection: HomeProjectSelection) {
|
||||
setStore("home", "selection", reconcile(selection))
|
||||
},
|
||||
searchFocus: {
|
||||
request() {
|
||||
homeSearchFocus = true
|
||||
},
|
||||
take() {
|
||||
const requested = homeSearchFocus
|
||||
homeSearchFocus = false
|
||||
|
||||
return requested
|
||||
},
|
||||
},
|
||||
},
|
||||
sessionState: {
|
||||
/** Records a session-scoped store, so pruning a session's layout state drops it too. */
|
||||
|
||||
@@ -452,7 +452,10 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
|
||||
category: language.t("command.category.view"),
|
||||
keybind: windows() ? "alt+home" : "mod+b",
|
||||
hidden: true,
|
||||
onSelect: toggleHome,
|
||||
onSelect: () => {
|
||||
if (layout.route().type !== "home") layout.home.searchFocus.request()
|
||||
toggleHome()
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/cli",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
@@ -37,6 +37,7 @@
|
||||
"@opencode/util": "workspace:*",
|
||||
"@opentui/core": "catalog:",
|
||||
"@opentui/solid": "catalog:",
|
||||
"@opentunnel/client": "0.2.0",
|
||||
"@parcel/watcher": "2.5.1",
|
||||
"@silvia-odwyer/photon-node": "0.3.4",
|
||||
"diff": "catalog:",
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Script } from "@opencode/script"
|
||||
import { createSolidTransformPlugin } from "@opentui/solid/bun-plugin"
|
||||
import type { BunPlugin } from "bun"
|
||||
import pkg from "../package.json"
|
||||
import { discoverPluginRuntimeSpecifiers, pluginRuntimeLoaderCode } from "@opencode/plugin/runtime-modules"
|
||||
import { buildAppArchive } from "./app-assets"
|
||||
import { verifyArtifact, verifySimulationGraph } from "./verify-artifact"
|
||||
import { resolveOpencodePty } from "./opencode-pty"
|
||||
@@ -82,6 +83,30 @@ export default () => readFileSync(archive)`,
|
||||
}))
|
||||
},
|
||||
}
|
||||
const pluginRuntimeEntries = discoverPluginRuntimeSpecifiers()
|
||||
const pluginRuntimeModulesSource = [
|
||||
"export const resolveHostPackageRoots = () => []",
|
||||
"const modules = {",
|
||||
...[...pluginRuntimeEntries.keys()].map(
|
||||
(specifier) => ` ${JSON.stringify(specifier)}: ${pluginRuntimeLoaderCode(specifier, pluginRuntimeEntries)},`,
|
||||
),
|
||||
"}",
|
||||
"export const loadRuntimeModules = () => modules",
|
||||
].join("\n")
|
||||
const pluginRuntimePlugin: BunPlugin = {
|
||||
name: "opencode-plugin-runtime",
|
||||
setup(build) {
|
||||
build.onLoad({ filter: /plugin[/\\]src[/\\]runtime-modules\.ts$/ }, () => ({
|
||||
contents: pluginRuntimeModulesSource,
|
||||
loader: "ts",
|
||||
}))
|
||||
build.onLoad({ filter: /[/\\]internal[/\\]httpApi(?:Scalar|Swagger)\.js$/ }, () => ({
|
||||
contents:
|
||||
'export const css = ""; export const javascript = \'document.body.textContent = "Scalar/Swagger UI assets are not bundled in OpenCode"\'',
|
||||
loader: "js",
|
||||
}))
|
||||
},
|
||||
}
|
||||
|
||||
for (const item of targets) {
|
||||
const opencodePty = await resolveOpencodePty({
|
||||
@@ -128,7 +153,14 @@ export default { path: file, version: ${JSON.stringify(opencodePty.version)}, sh
|
||||
const result = await Bun.build({
|
||||
entrypoints: ["./src/index.ts"],
|
||||
tsconfig: "./tsconfig.json",
|
||||
plugins: [appAssetsPlugin, solidPlugin, parcelWatcherPlugin, opencodePtyPlugin, simulationGraphPlugin],
|
||||
plugins: [
|
||||
appAssetsPlugin,
|
||||
solidPlugin,
|
||||
parcelWatcherPlugin,
|
||||
opencodePtyPlugin,
|
||||
pluginRuntimePlugin,
|
||||
simulationGraphPlugin,
|
||||
],
|
||||
external: ["node-gyp"],
|
||||
format: "esm",
|
||||
minify: true,
|
||||
|
||||
@@ -116,6 +116,10 @@ function copyBinary(source) {
|
||||
|
||||
function resolveBinary(name) {
|
||||
const packagePath = require.resolve(`${name}/package.json`)
|
||||
// Package managers keep an older platform package when the matching version is not yet on the registry,
|
||||
// which would silently install the previous release under the new launcher.
|
||||
const version = JSON.parse(fs.readFileSync(packagePath, "utf8")).version
|
||||
if (version !== dependencies[name]) throw new Error(`${name} is ${version}, expected ${dependencies[name]}`)
|
||||
return path.join(path.dirname(packagePath), "bin", sourceBinary)
|
||||
}
|
||||
|
||||
|
||||
@@ -530,6 +530,10 @@ const Root = Spec.make(typeof OPENCODE_CLI_NAME === "string" ? OPENCODE_CLI_NAME
|
||||
),
|
||||
Flag.optional,
|
||||
),
|
||||
remote: Flag.boolean("remote").pipe(
|
||||
Flag.withDescription("Pair through the OpenTunnel remote address, enabling remote access if needed"),
|
||||
Flag.withDefault(false),
|
||||
),
|
||||
},
|
||||
}),
|
||||
Spec.make("serve", {
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
import { EOL } from "os"
|
||||
import { Effect, Option } from "effect"
|
||||
import { Effect, Option, Schedule } from "effect"
|
||||
import { Service } from "@opencode/client/effect/service"
|
||||
import { OpenCode } from "@opencode/client/promise"
|
||||
import { renderUnicodeCompact } from "uqr"
|
||||
import { Commands } from "../commands"
|
||||
import { Runtime } from "../../framework/runtime"
|
||||
import { RemoteTunnel } from "../../services/remote-tunnel"
|
||||
import { ServiceConfig } from "../../services/service-config"
|
||||
|
||||
export default Runtime.handler(
|
||||
Commands.commands.pair,
|
||||
Effect.fn("cli.pair")(function* (input: Runtime.Input<typeof Commands.commands.pair>) {
|
||||
if ((yield* ServiceConfig.read()).disabled === true)
|
||||
const config = yield* ServiceConfig.read()
|
||||
if (config.disabled === true)
|
||||
return yield* Effect.fail(
|
||||
new Error("Pairing requires the background service; run `opencode service unset disabled` first"),
|
||||
)
|
||||
if (input.remote && Option.isSome(input.url))
|
||||
return yield* Effect.fail(new Error("--remote cannot be combined with --url"))
|
||||
// Changing the setting restarts the service, and the ensure below starts it again with the tunnel.
|
||||
if (input.remote && config.remote !== true) yield* ServiceConfig.set("remote", "true")
|
||||
const endpoint = yield* Service.ensure(yield* ServiceConfig.options())
|
||||
const client = OpenCode.make({ baseUrl: endpoint.url, headers: Service.headers(endpoint) })
|
||||
const urls = Option.isSome(input.url)
|
||||
? [input.url.value]
|
||||
: (yield* Effect.tryPromise(() => client.server.info())).urls
|
||||
const urls = yield* pairingURLs(client, input)
|
||||
const pairing = yield* Effect.tryPromise(() => client.server.pair())
|
||||
const links = urls.map((url) => new URL(`/auth/connect/${pairing.code}`, url).href)
|
||||
// Loopback URLs are useless to the scanning device, so the QR code only carries reachable addresses.
|
||||
@@ -45,7 +49,7 @@ export default Runtime.handler(
|
||||
].join(EOL) + EOL,
|
||||
)
|
||||
|
||||
if (Option.isSome(input.url)) return
|
||||
if (input.remote || Option.isSome(input.url)) return
|
||||
const url = new URL(endpoint.url)
|
||||
if (!["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)) return
|
||||
process.stderr.write(
|
||||
@@ -61,6 +65,34 @@ export default Runtime.handler(
|
||||
}),
|
||||
)
|
||||
|
||||
const pairingURLs = Effect.fnUntraced(function* (
|
||||
client: ReturnType<typeof OpenCode.make>,
|
||||
input: Runtime.Input<typeof Commands.commands.pair>,
|
||||
) {
|
||||
if (input.remote) return [yield* remoteURL(client)]
|
||||
if (Option.isSome(input.url)) return [input.url.value]
|
||||
return (yield* Effect.tryPromise(() => client.server.info())).urls
|
||||
})
|
||||
|
||||
// The service attaches the tunnel in the background, so wait for its URL to appear in server info.
|
||||
const remoteURL = Effect.fnUntraced(function* (client: ReturnType<typeof OpenCode.make>) {
|
||||
const tunnelURL = Effect.gen(function* () {
|
||||
const hostname = yield* RemoteTunnel.hostname()
|
||||
const info = yield* Effect.tryPromise(() => client.server.info())
|
||||
const url = info.urls.find((candidate) => hostname !== undefined && new URL(candidate).hostname === hostname)
|
||||
if (url === undefined) return yield* Effect.fail(new Error("Remote tunnel is not ready"))
|
||||
return url
|
||||
})
|
||||
return yield* tunnelURL.pipe(
|
||||
Effect.retry({ schedule: Schedule.spaced("1 second") }),
|
||||
Effect.timeoutOrElse({
|
||||
duration: "3 minutes",
|
||||
orElse: () =>
|
||||
Effect.fail(new Error("Timed out waiting for the remote tunnel; run `opencode pair --remote` again to retry")),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
function isLoopback(hostname: string) {
|
||||
return (
|
||||
hostname === "localhost" || hostname.endsWith(".localhost") || hostname.startsWith("127.") || hostname === "[::1]"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { ensurePluginRuntime } from "@opencode/plugin/runtime"
|
||||
import { NodeRuntime, NodeServices } from "@effect/platform-node"
|
||||
import { Cause, Effect } from "effect"
|
||||
import { getErrorReported } from "effect/Runtime"
|
||||
@@ -17,6 +18,8 @@ import { EffectFlock } from "@opencode/util/effect-flock"
|
||||
import { Heap } from "./heap"
|
||||
import { CpuProfile } from "./cpu-profile"
|
||||
|
||||
ensurePluginRuntime()
|
||||
|
||||
if (process.env.OPENCODE_SSH_ASKPASS_PORT) {
|
||||
const { askpass } = await import("./ssh-askpass")
|
||||
process.exit(await Effect.runPromise(askpass.pipe(Effect.provide(NodeServices.layer))))
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Env } from "./env"
|
||||
import { ServiceConfig } from "./services/service-config"
|
||||
import { RetainedImage } from "./services/retained-image"
|
||||
import { ServiceRegistration } from "./services/service-registration"
|
||||
import { RemoteTunnel } from "./services/remote-tunnel"
|
||||
import { WebUi } from "./services/web-ui"
|
||||
import { databasePath } from "./database-path"
|
||||
|
||||
@@ -88,6 +89,7 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
|
||||
if (!password) return yield* Effect.fail(new Error("Missing server password"))
|
||||
const instanceID = randomUUID()
|
||||
const transform = yield* WebUi.handler()
|
||||
const remote = { urls: [] as ReadonlyArray<string> }
|
||||
const launch = start(
|
||||
{
|
||||
app: {
|
||||
@@ -144,6 +146,7 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
|
||||
}),
|
||||
},
|
||||
transform,
|
||||
() => remote.urls,
|
||||
)
|
||||
const server = yield* launch.pipe(
|
||||
Effect.catch((error) => {
|
||||
@@ -170,6 +173,19 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
|
||||
}),
|
||||
)
|
||||
if (server === undefined) return
|
||||
if (serviceOptions !== undefined && config.remote === true && server.address._tag === "TcpAddress") {
|
||||
const bound = server.address.hostname
|
||||
// A wildcard bind also listens on loopback, which is all the tunnel needs to reach.
|
||||
const host = bound === "0.0.0.0" || bound === "::" ? "127.0.0.1" : bound.includes(":") ? `[${bound}]` : bound
|
||||
yield* Effect.forkScoped(
|
||||
RemoteTunnel.run({
|
||||
target: `${host}:${server.address.port}`,
|
||||
onURL: (url) => {
|
||||
remote.urls = url === undefined ? [] : [url]
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
const url = HttpServer.formatAddress(server.address)
|
||||
console.log(options.mode === "stdio" ? JSON.stringify({ url }) : `server listening on ${url}`)
|
||||
if (foreground && !environmentPassword) console.log(`server password ${password}`)
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
export * as RemoteTunnel from "./remote-tunnel"
|
||||
|
||||
import type { OpenTunnelError } from "@opentunnel/client/effect"
|
||||
import { Cause, Effect, Schedule } from "effect"
|
||||
import { EOL } from "os"
|
||||
import { OPENCODE_CHANNEL } from "../version"
|
||||
|
||||
// OpenTunnel keeps one tunnel per device in its default profile, shared by the opentunnel CLI and every app
|
||||
// using the SDK; each claims its own routes. The service claims a subdomain rather than the tunnel hostname,
|
||||
// which the CLI may route, and each channel's service gets its own subdomain.
|
||||
export function route(channel = OPENCODE_CHANNEL) {
|
||||
if (channel === "latest") return "opencode"
|
||||
return `opencode-${channel.toLowerCase().replace(/[^a-z0-9-]/g, "-")}`.slice(0, 63).replace(/-+$/, "")
|
||||
}
|
||||
|
||||
// Holds the route for the life of the service. The SDK reconnects through network failures itself, so only
|
||||
// setup failures reach the retry here; a rejected token or failed certificate stops it for good.
|
||||
export const run = Effect.fnUntraced(function* (input: {
|
||||
readonly target: string
|
||||
readonly onURL: (url: string | undefined) => void
|
||||
}) {
|
||||
const { OpenTunnelClient, OpenTunnelAttachError } = yield* Effect.promise(() => import("@opentunnel/client/effect"))
|
||||
const fatal = (error: OpenTunnelError) =>
|
||||
error._tag === "OpenTunnelClientError" &&
|
||||
(error.cause instanceof OpenTunnelAttachError || error.message.startsWith("Certificate issuance failed"))
|
||||
yield* Effect.gen(function* () {
|
||||
const client = yield* OpenTunnelClient
|
||||
const connection = yield* client.tunnel.connect({ routes: { [route()]: input.target } })
|
||||
input.onURL(`https://${route()}.${connection.tunnel.hostname}`)
|
||||
yield* connection.closed
|
||||
}).pipe(
|
||||
Effect.scoped,
|
||||
Effect.ensuring(Effect.sync(() => input.onURL(undefined))),
|
||||
Effect.tapError((error) =>
|
||||
fatal(error) ? Effect.void : Effect.logWarning("remote access tunnel unavailable; retrying", { cause: error }),
|
||||
),
|
||||
Effect.retry({
|
||||
while: (error) => !fatal(error),
|
||||
schedule: Schedule.min([Schedule.exponential("1 second"), Schedule.spaced("30 seconds")]),
|
||||
}),
|
||||
Effect.provide(OpenTunnelClient.layer()),
|
||||
Effect.catchCause((cause) =>
|
||||
Cause.hasInterruptsOnly(cause)
|
||||
? Effect.failCause(cause)
|
||||
: Effect.logError("remote access tunnel stopped; run `opencode service set remote true` to retry", { cause }),
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
// A device without a tunnel creates its shared one here, in the foreground, because issuing the certificate
|
||||
// takes a while; the service then only attaches its route on start. An interrupted issuance resumes next time.
|
||||
export const ensure = Effect.fnUntraced(function* () {
|
||||
const { OpenTunnelClient } = yield* Effect.promise(() => import("@opentunnel/client/effect"))
|
||||
return yield* Effect.gen(function* () {
|
||||
const client = yield* OpenTunnelClient
|
||||
if ((yield* client.tunnel.get()) === undefined)
|
||||
process.stderr.write("Setting up remote access; this can take a minute..." + EOL)
|
||||
return `${route()}.${(yield* client.tunnel.ensure()).hostname}`
|
||||
}).pipe(
|
||||
Effect.provide(OpenTunnelClient.layer()),
|
||||
Effect.timeoutOrElse({
|
||||
duration: "5 minutes",
|
||||
orElse: () => Effect.fail(new Error("Timed out creating the remote access tunnel; run the command again to resume")),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
// The tunnel hostname is persisted once the certificate is ready, so this is undefined until then.
|
||||
export const hostname = Effect.fnUntraced(function* () {
|
||||
const { OpenTunnelStorage } = yield* Effect.promise(() => import("@opentunnel/client/effect"))
|
||||
const identity = yield* OpenTunnelStorage.xdg().load("default")
|
||||
return identity === undefined ? undefined : `${route()}.${identity.hostname}`
|
||||
})
|
||||
@@ -6,6 +6,7 @@ import { Effect, FileSystem, Option, Schema } from "effect"
|
||||
import { randomBytes } from "crypto"
|
||||
import path from "path"
|
||||
import { selfCommand } from "../util/process"
|
||||
import { RemoteTunnel } from "./remote-tunnel"
|
||||
|
||||
// The CLI's service configuration file, plus the Service.EnsureOptions binding that
|
||||
// points the client package's service operations at this CLI: which
|
||||
@@ -13,6 +14,7 @@ import { selfCommand } from "../util/process"
|
||||
|
||||
export const Info = Schema.Struct({
|
||||
disabled: Schema.optional(Schema.Boolean),
|
||||
remote: Schema.optional(Schema.Boolean),
|
||||
hostname: Schema.optional(Schema.String),
|
||||
port: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(65_535))),
|
||||
password: Schema.optional(Schema.String),
|
||||
@@ -21,7 +23,7 @@ export const Info = Schema.Struct({
|
||||
})
|
||||
export type Info = typeof Info.Type
|
||||
|
||||
const keys = ["disabled", "hostname", "port", "password", "cors", "env"] as const
|
||||
const keys = ["disabled", "remote", "hostname", "port", "password", "cors", "env"] as const
|
||||
type Key = (typeof keys)[number]
|
||||
|
||||
const decodeInfo = Schema.decodeUnknownEffect(Schema.fromJsonString(Info))
|
||||
@@ -81,6 +83,7 @@ export const migrateConfig = Effect.fnUntraced(function* (legacy: string, file:
|
||||
function configKey(key: string): Key {
|
||||
if (
|
||||
key === "disabled" ||
|
||||
key === "remote" ||
|
||||
key === "hostname" ||
|
||||
key === "port" ||
|
||||
key === "password" ||
|
||||
@@ -163,6 +166,9 @@ export const get = Effect.fn("cli.service-config.get")(function* (key?: string,
|
||||
case "disabled": {
|
||||
return String((yield* read()).disabled ?? false)
|
||||
}
|
||||
case "remote": {
|
||||
return String((yield* read()).remote ?? false)
|
||||
}
|
||||
case "hostname": {
|
||||
return (yield* read()).hostname ?? ""
|
||||
}
|
||||
@@ -195,6 +201,14 @@ export const set = Effect.fn("cli.service-config.set")(function* (key: string, v
|
||||
yield* write({ ...(yield* read()), disabled: value === "true" })
|
||||
return
|
||||
}
|
||||
case "remote": {
|
||||
if (value !== "true" && value !== "false") throw new Error("Remote must be true or false")
|
||||
// A tunnel that cannot be created leaves remote access off instead of a service that keeps retrying.
|
||||
if (value === "true") yield* RemoteTunnel.ensure()
|
||||
yield* Service.stop(yield* options())
|
||||
yield* write({ ...(yield* read()), remote: value === "true" })
|
||||
return
|
||||
}
|
||||
case "hostname": {
|
||||
yield* Service.stop(yield* options())
|
||||
yield* write({ ...(yield* read()), hostname: value })
|
||||
@@ -244,6 +258,12 @@ export const unset = Effect.fn("cli.service-config.unset")(function* (key: strin
|
||||
yield* write(next)
|
||||
return
|
||||
}
|
||||
case "remote": {
|
||||
yield* Service.stop(yield* options())
|
||||
const { remote: _remote, ...next } = yield* read()
|
||||
yield* write(next)
|
||||
return
|
||||
}
|
||||
case "hostname": {
|
||||
yield* Service.stop(yield* options())
|
||||
const { hostname: _hostname, ...next } = yield* read()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { validateRoutes } from "@opentunnel/client/effect"
|
||||
import { expect, test } from "bun:test"
|
||||
import { RemoteTunnel } from "../src/services/remote-tunnel"
|
||||
|
||||
test("each channel serves remote access on its own valid subdomain of the shared tunnel", () => {
|
||||
const channels = ["latest", "dev", "beta", "Preview/Feature_X.1", "a".repeat(80), "trailing-"]
|
||||
const routes = channels.map((channel) => RemoteTunnel.route(channel))
|
||||
|
||||
expect(routes.slice(0, 3)).toEqual(["opencode", "opencode-dev", "opencode-beta"])
|
||||
expect(new Set(routes).size).toBe(routes.length)
|
||||
// The SDK rejects invalid route names, which would keep the service from ever attaching.
|
||||
expect(() => validateRoutes(Object.fromEntries(routes.map((name) => [name, "127.0.0.1:4096"])))).not.toThrow()
|
||||
})
|
||||
@@ -43,6 +43,26 @@ test("service disabled accepts only booleans without changing configuration on i
|
||||
}
|
||||
})
|
||||
|
||||
// Enabling remote creates a real tunnel, so only the paths that stay local are covered here.
|
||||
test("service remote accepts only booleans and persists across set and unset", async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-service-remote-config-"))
|
||||
const layer = Global.layerWith({ config: path.join(root, "config"), state: path.join(root, "state") })
|
||||
const run = <A, E>(effect: Effect.Effect<A, E, Global.Service | FileSystem.FileSystem>) =>
|
||||
Effect.runPromise(effect.pipe(Effect.provide(layer), Effect.provide(NodeFileSystem.layer)))
|
||||
try {
|
||||
expect(await run(ServiceConfig.get("remote"))).toBe("false")
|
||||
await expect(run(ServiceConfig.set("remote", "on"))).rejects.toThrow("Remote must be true or false")
|
||||
expect(await run(ServiceConfig.read())).toEqual({})
|
||||
await run(ServiceConfig.set("remote", "false"))
|
||||
expect(await run(ServiceConfig.read())).toEqual({ remote: false })
|
||||
expect(await run(ServiceConfig.get("remote"))).toBe("false")
|
||||
await run(ServiceConfig.unset("remote"))
|
||||
expect(await run(ServiceConfig.read())).toEqual({})
|
||||
} finally {
|
||||
await fs.rm(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
test("local channel stores service config with the local service filename", async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-service-"))
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/client",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// Mirrors @opencode/protocol/api-version, which the dependency-free promise client cannot import.
|
||||
export const API_VERSION_HEADER = "x-opencode-api-version"
|
||||
export const API_VERSION = 2
|
||||
@@ -1,6 +1,5 @@
|
||||
export * as OpenCode from "./client.js"
|
||||
|
||||
import { API_VERSION, API_VERSION_HEADER } from "../api-version.js"
|
||||
import { Cause, Context, Effect, Stream } from "effect"
|
||||
import { HttpClient, HttpClientRequest } from "effect/unstable/http"
|
||||
import { SharedEvents } from "../shared-events.js"
|
||||
@@ -18,10 +17,9 @@ export const make = Effect.fn("OpenCode.make")(function* (options?: { readonly b
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
HttpClient.mapRequestEffect(httpClient, (request) =>
|
||||
Effect.map(CurrentHeaders, (headers) => {
|
||||
const versioned = HttpClientRequest.setHeader(request, API_VERSION_HEADER, String(API_VERSION))
|
||||
return headers ? HttpClientRequest.setHeaders(versioned, new Headers(headers)) : versioned
|
||||
}),
|
||||
Effect.map(CurrentHeaders, (headers) =>
|
||||
headers ? HttpClientRequest.setHeaders(request, new Headers(headers)) : request,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export * as OpenCode from "./client.js"
|
||||
|
||||
import { API_VERSION, API_VERSION_HEADER } from "../api-version.js"
|
||||
import { SharedEvents } from "../shared-events.js"
|
||||
import { OpenCode } from "./generated/index.js"
|
||||
import type { ClientOptions } from "./generated/client.js"
|
||||
@@ -9,9 +8,7 @@ import { makeRpc } from "./rpc.js"
|
||||
export type { ClientOptions, RequestOptions } from "./generated/client.js"
|
||||
|
||||
export function make(options: ClientOptions) {
|
||||
const headers = new Headers(options.headers)
|
||||
headers.set(API_VERSION_HEADER, String(API_VERSION))
|
||||
const raw = OpenCode.make({ ...options, headers })
|
||||
const raw = OpenCode.make(options)
|
||||
const events = SharedEvents.make((signal, onActivity) => raw.event.subscribe({ signal, onActivity }))
|
||||
return {
|
||||
...raw,
|
||||
|
||||
@@ -52,6 +52,12 @@ import type { SessionInbox } from "@opencode/schema/session-inbox"
|
||||
import { batch, createEffect, createMemo, createSignal, onCleanup } from "solid-js"
|
||||
|
||||
export type DataSessionStatus = "idle" | "running"
|
||||
/**
|
||||
* Where a pending user prompt stands relative to the runner: `starting` is promoted at the next idle boundary,
|
||||
* `steering` waits for the next step boundary of an execution that already delivered input, `stranded` outlived an
|
||||
* execution that ended without delivering it, and `queued` waits for every steer to drain.
|
||||
*/
|
||||
export type DataPendingStatus = "starting" | "steering" | "stranded" | "queued"
|
||||
type OpenCodeEventMap = { [Type in OpenCodeEvent["type"]]: Extract<OpenCodeEvent, { type: Type }> }
|
||||
|
||||
export type CreateDataInput = {
|
||||
@@ -1400,6 +1406,23 @@ export function createData(config: CreateDataInput) {
|
||||
list(sessionID: string) {
|
||||
return store.session.pending[sessionID] ?? []
|
||||
},
|
||||
// An execution's idle boundary promotes every pending steer at once, so a steer only waits behind work
|
||||
// once the current execution has delivered input.
|
||||
status(sessionID: string, inboxID: string): DataPendingStatus | undefined {
|
||||
const pending = store.session.pending[sessionID] ?? []
|
||||
const item = pending.find((entry) => entry.id === inboxID && entry.type === "user")
|
||||
if (!item) return undefined
|
||||
if (item.delivery === "queue") return "queued"
|
||||
const messages = store.session.message[sessionID] ?? []
|
||||
const boundary = messages.findLastIndex((entry) => entry.type === "idle")
|
||||
if ((store.session.active[sessionID] ?? "idle") === "idle")
|
||||
return boundary >= 0 && item.time.created <= messages[boundary].time.created ? "stranded" : "starting"
|
||||
return messages
|
||||
.slice(boundary + 1)
|
||||
.some((entry) => entry.type === "user" && !pending.some((other) => other.id === entry.id))
|
||||
? "steering"
|
||||
: "starting"
|
||||
},
|
||||
sync(sessionID: string) {
|
||||
return sync.run(`session.pending:${sessionID}`, async () => {
|
||||
const updates = new Map<string, SessionInboxInfo | SessionInbox.Delivery | undefined>()
|
||||
|
||||
@@ -37,9 +37,3 @@ test("shared DTO schemas construct and decode plain objects", () => {
|
||||
expect(Prompt.ast.annotations?.identifier).toBe("Prompt")
|
||||
expect(SessionMessage.AssistantText.ast.annotations?.identifier).toBe("Session.Message.Assistant.Text")
|
||||
})
|
||||
|
||||
test("client API version mirrors the protocol", async () => {
|
||||
const client = await import("../src/api-version")
|
||||
const protocol = await import("@opencode/protocol/api-version")
|
||||
expect(client).toEqual(protocol)
|
||||
})
|
||||
@@ -1,7 +1,6 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { Context, DateTime, Effect, Stream } from "effect"
|
||||
import { HttpClient, HttpClientResponse } from "effect/unstable/http"
|
||||
import { API_VERSION, API_VERSION_HEADER } from "../src/api-version"
|
||||
import {
|
||||
AbsolutePath,
|
||||
Agent,
|
||||
@@ -43,25 +42,6 @@ test("server.info decodes the readiness response", async () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("requests send the client's API version", async () => {
|
||||
const headers: Array<string | undefined> = []
|
||||
const httpClient = HttpClient.make((request) => {
|
||||
headers.push(request.headers[API_VERSION_HEADER])
|
||||
return Effect.succeed(
|
||||
HttpClientResponse.fromWeb(
|
||||
request,
|
||||
Response.json({ version: "current", pid: 123, urls: [], paths: { tmp: "/tmp/opencode" } }),
|
||||
),
|
||||
)
|
||||
})
|
||||
await Effect.gen(function* () {
|
||||
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
|
||||
yield* client.server.info()
|
||||
}).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise)
|
||||
|
||||
expect(headers).toEqual([String(API_VERSION)])
|
||||
})
|
||||
|
||||
test("vcs.base decodes nullable review-base metadata", async () => {
|
||||
const location = { directory: "/repo", project: { id: "global", directory: "/repo", canonical: "/repo" } }
|
||||
const base = {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { API_VERSION, API_VERSION_HEADER } from "../src/api-version"
|
||||
import { isSessionNotFoundError, isUnauthorizedError, OpenCode } from "../src/promise/index"
|
||||
|
||||
test("exposes every standard HTTP API group", () => {
|
||||
@@ -1126,19 +1125,3 @@ const modelSwitchedEvent = {
|
||||
model: { id: "claude", providerID: "anthropic" },
|
||||
},
|
||||
}
|
||||
|
||||
test("requests send the client's API version alongside configured headers", async () => {
|
||||
let headers: Headers | undefined
|
||||
const client = OpenCode.make({
|
||||
baseUrl: "http://localhost:3000",
|
||||
headers: { authorization: "Basic secret", [API_VERSION_HEADER]: "1" },
|
||||
fetch: async (input, init) => {
|
||||
headers = new Headers(init?.headers)
|
||||
return Response.json({ version: "2.0.0", pid: 1, urls: [], paths: { tmp: "/tmp" } })
|
||||
},
|
||||
})
|
||||
|
||||
await client.server.info()
|
||||
expect(headers?.get(API_VERSION_HEADER)).toBe(String(API_VERSION))
|
||||
expect(headers?.get("authorization")).toBe("Basic secret")
|
||||
})
|
||||
@@ -0,0 +1,180 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { createRoot } from "solid-js"
|
||||
import { createData, type CreateDataInput } from "../src/solid"
|
||||
import { OpenCode, type OpenCodeEvent } from "../src/promise"
|
||||
|
||||
const sessionID = "ses_pending"
|
||||
|
||||
function fixture() {
|
||||
const listeners = new Set<Parameters<CreateDataInput["event"]["listen"]>[0]>()
|
||||
const api = OpenCode.make({
|
||||
baseUrl: "http://opencode.local",
|
||||
fetch: async (input, init) => {
|
||||
const request = input instanceof Request ? input : new Request(input, init)
|
||||
return request.method === "GET" ? Response.json({ data: [] }) : Response.json({ data: {} })
|
||||
},
|
||||
})
|
||||
let seq = 0
|
||||
return createRoot((dispose) => {
|
||||
const data = createData({
|
||||
api: () => api,
|
||||
directory: "/project",
|
||||
event: {
|
||||
on: () => () => {},
|
||||
listen(handler) {
|
||||
listeners.add(handler)
|
||||
return () => listeners.delete(handler)
|
||||
},
|
||||
},
|
||||
})
|
||||
const emit = (type: string, payload: Record<string, unknown> = {}) => {
|
||||
seq++
|
||||
const event = {
|
||||
id: `evt_${seq}`,
|
||||
type,
|
||||
created: seq,
|
||||
durable: { aggregateID: sessionID, seq, version: 1 },
|
||||
data: { sessionID, ...payload },
|
||||
} as OpenCodeEvent
|
||||
listeners.forEach((listener) => listener({ name: event.type, details: event }))
|
||||
}
|
||||
return {
|
||||
data,
|
||||
dispose,
|
||||
enqueue: (id: string, delivery: "steer" | "queue" = "steer") =>
|
||||
emit("session.inbox.enqueued", { inboxID: id, item: { type: "user", delivery, payload: { text: id } } }),
|
||||
deliver: (id: string) => emit("session.inbox.delivered", { inboxID: id }),
|
||||
started: () => emit("session.execution.started"),
|
||||
settled: (outcome: "succeeded" | "failed" | "interrupted") =>
|
||||
emit(
|
||||
`session.execution.${outcome}`,
|
||||
outcome === "failed"
|
||||
? { error: { type: "provider", message: "Provider unavailable" } }
|
||||
: outcome === "interrupted"
|
||||
? { reason: "user" }
|
||||
: {},
|
||||
),
|
||||
move: (id: string, delivery: "steer" | "queue") =>
|
||||
emit("session.inbox.delivery.changed", { inboxID: id, delivery }),
|
||||
status: (id: string) => data.session.pending.status(sessionID, id),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
test("an idle send is starting from optimistic admission until delivery", async () => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
// The composer marks the Session running in the same task as optimistic admission.
|
||||
const sending = setup.data.session.prompt({ sessionID, id: "msg_first", text: "first" })
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
setup.data.session.setStatus(sessionID, "running")
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
await sending
|
||||
setup.enqueue("msg_first")
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
setup.started()
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
setup.deliver("msg_first")
|
||||
expect(setup.status("msg_first")).toBeUndefined()
|
||||
expect(setup.data.session.message.get(sessionID, "msg_first")?.type).toBe("user")
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
test("a steer sent after the execution delivered input is steering, and follows delivery changes", () => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
setup.enqueue("msg_first")
|
||||
setup.started()
|
||||
setup.deliver("msg_first")
|
||||
setup.enqueue("msg_steer")
|
||||
expect(setup.status("msg_steer")).toBe("steering")
|
||||
setup.move("msg_steer", "queue")
|
||||
expect(setup.status("msg_steer")).toBe("queued")
|
||||
setup.move("msg_steer", "steer")
|
||||
expect(setup.status("msg_steer")).toBe("steering")
|
||||
setup.deliver("msg_steer")
|
||||
expect(setup.status("msg_steer")).toBeUndefined()
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
test("rapid follow-ups join the starting execution until it delivers without them", () => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
setup.enqueue("msg_first")
|
||||
setup.started()
|
||||
setup.enqueue("msg_second")
|
||||
// The idle boundary promotes every pending steer, so both are starting.
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
expect(setup.status("msg_second")).toBe("starting")
|
||||
// Promotion happened before the second admission landed; it now steers the running execution.
|
||||
setup.deliver("msg_first")
|
||||
expect(setup.status("msg_second")).toBe("steering")
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
test.each(["failed", "interrupted"] as const)("an undelivered steer is stranded after execution %s", (outcome) => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
setup.enqueue("msg_first")
|
||||
setup.started()
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
setup.settled(outcome)
|
||||
expect(setup.data.session.status(sessionID)).toBe("idle")
|
||||
expect(setup.status("msg_first")).toBe("stranded")
|
||||
// A new idle send starts fresh, and its execution promotes the stranded steer with it.
|
||||
setup.enqueue("msg_retry")
|
||||
expect(setup.status("msg_retry")).toBe("starting")
|
||||
expect(setup.status("msg_first")).toBe("stranded")
|
||||
setup.started()
|
||||
expect(setup.status("msg_first")).toBe("starting")
|
||||
expect(setup.status("msg_retry")).toBe("starting")
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
test("a later execution starts fresh after an earlier turn delivered input", () => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
setup.enqueue("msg_first")
|
||||
setup.started()
|
||||
setup.deliver("msg_first")
|
||||
setup.settled("succeeded")
|
||||
setup.enqueue("msg_next")
|
||||
expect(setup.status("msg_next")).toBe("starting")
|
||||
setup.started()
|
||||
expect(setup.status("msg_next")).toBe("starting")
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
test("a remote idle prompt is starting", () => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
setup.enqueue("msg_remote")
|
||||
expect(setup.status("msg_remote")).toBe("starting")
|
||||
setup.started()
|
||||
expect(setup.status("msg_remote")).toBe("starting")
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
test("a queued prompt is queued regardless of execution state", () => {
|
||||
const setup = fixture()
|
||||
try {
|
||||
setup.enqueue("msg_queued", "queue")
|
||||
expect(setup.status("msg_queued")).toBe("queued")
|
||||
setup.started()
|
||||
expect(setup.status("msg_queued")).toBe("queued")
|
||||
} finally {
|
||||
setup.dispose()
|
||||
}
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/codemode",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"description": "Effect-native confined code execution over schema-described tools",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/console-app",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/console-core",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/console-function",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/console-mail",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"dependencies": {
|
||||
"@jsx-email/all": "2.2.3",
|
||||
"@jsx-email/cli": "1.4.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/console-support",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"name": "@opencode/core",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
+11
-11
@@ -144,19 +144,19 @@ export const layer = (options?: Options) =>
|
||||
|
||||
const loadWellknownEntry = Effect.fnUntraced(function* (entry: WellKnown.Entry) {
|
||||
const auth = entry.manifest.auth
|
||||
if (!auth) return []
|
||||
const credential = (yield* credentials.list(entry.integrationID)).at(-1)
|
||||
if (!credential || credential.value.type !== "key") return []
|
||||
const variables = { [auth.env]: credential.value.key }
|
||||
const configs = yield* wellknown
|
||||
.resolve(entry, variables)
|
||||
.pipe(
|
||||
Effect.catch(() =>
|
||||
Effect.logWarning("failed to load wellknown config", { source: entry.origin }).pipe(
|
||||
Effect.as([] as const),
|
||||
),
|
||||
const variables = auth && credential?.value.type === "key" ? { [auth.env]: credential.value.key } : undefined
|
||||
// A failed refresh, including a missing credential, keeps the last resolved config so remote providers
|
||||
// and allowlists do not disappear; only removing the source clears it.
|
||||
const configs = yield* (
|
||||
variables ? wellknown.resolve(entry, variables) : Effect.fail(new Error("No usable wellknown credential"))
|
||||
).pipe(
|
||||
Effect.catch((error) =>
|
||||
Effect.logWarning("failed to load wellknown config", { source: entry.origin, error }).pipe(
|
||||
Effect.andThen(wellknown.cached(entry.origin)),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
return yield* Effect.forEach(configs, (config) =>
|
||||
ConfigVariable.substitute({
|
||||
type: "virtual",
|
||||
|
||||
@@ -20,7 +20,7 @@ function resolveLocation(options: Record<string, any>) {
|
||||
process.env.GOOGLE_VERTEX_LOCATION ??
|
||||
process.env.GOOGLE_CLOUD_LOCATION ??
|
||||
process.env.VERTEX_LOCATION ??
|
||||
"us-central1"
|
||||
"global"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ const builtins = new Map<string, () => Promise<unknown>>([
|
||||
["@opencode/ai/providers/alibaba/messages", () => import("@opencode/ai/providers/alibaba/messages")],
|
||||
["@opencode/ai/providers/alibaba/responses", () => import("@opencode/ai/providers/alibaba/responses")],
|
||||
["@opencode/ai/providers/anthropic", () => import("@opencode/ai/providers/anthropic")],
|
||||
["@opencode/ai/providers/anthropic-compatible", () => import("@opencode/ai/providers/anthropic-compatible")],
|
||||
["@opencode/ai/providers/azure", () => import("@opencode/ai/providers/azure")],
|
||||
["@opencode/ai/providers/azure/chat", () => import("@opencode/ai/providers/azure/chat")],
|
||||
["@opencode/ai/providers/azure/responses", () => import("@opencode/ai/providers/azure/responses")],
|
||||
@@ -95,6 +96,14 @@ const builtins = new Map<string, () => Promise<unknown>>([
|
||||
["@opencode/ai/providers/openai/chat", () => import("@opencode/ai/providers/openai/chat")],
|
||||
["@opencode/ai/providers/openai/responses", () => import("@opencode/ai/providers/openai/responses")],
|
||||
["@opencode/ai/providers/openai-compatible", () => import("@opencode/ai/providers/openai-compatible")],
|
||||
[
|
||||
"@opencode/ai/providers/openai-compatible/responses",
|
||||
() => import("@opencode/ai/providers/openai-compatible/responses"),
|
||||
],
|
||||
[
|
||||
"@opencode/ai/providers/openai-compatible-responses",
|
||||
() => import("@opencode/ai/providers/openai-compatible-responses"),
|
||||
],
|
||||
["@opencode/ai/providers/openrouter", () => import("@opencode/ai/providers/openrouter")],
|
||||
["@opencode/ai/providers/togetherai", () => import("@opencode/ai/providers/togetherai")],
|
||||
["@opencode/ai/providers/venice", () => import("@opencode/ai/providers/venice")],
|
||||
|
||||
@@ -395,7 +395,7 @@ export const createLLMEventPublisher = (bus: Pick<Bus.Interface, "publish">, inp
|
||||
})
|
||||
|
||||
const failUnsettledTools = Effect.fn("SessionRunner.failUnsettledTools")(
|
||||
(error: SessionError.Error, scope: "hosted" | "all" = "all") => failTools(error, scope),
|
||||
(error: SessionError.Error, scope: "hosted" | "all" | "uncalled" = "all") => failTools(error, scope),
|
||||
)
|
||||
|
||||
const publish = Effect.fnUntraced(function* (event: LLMEvent) {
|
||||
|
||||
@@ -61,6 +61,11 @@ interface Input {
|
||||
const TOOLS_INTERRUPTED = { type: "aborted", message: "Tool execution interrupted" } as const
|
||||
const STEP_INTERRUPTED = { type: "aborted", message: "Step interrupted" } as const
|
||||
const RESULT_MISSING = { type: "tool.result-missing", message: "Provider did not return a tool result" } as const
|
||||
const INPUT_INCOMPLETE = {
|
||||
type: "tool.input-incomplete",
|
||||
message:
|
||||
"Tool call arguments were not completed and were not executed. Re-issue the tool call with complete arguments.",
|
||||
} as const
|
||||
|
||||
/** Captures Location-scoped dependencies without introducing another service or execution loop. */
|
||||
export const make = Effect.gen(function* () {
|
||||
@@ -216,10 +221,11 @@ export const make = Effect.gen(function* () {
|
||||
if (toolFailure) yield* publisher.failUnsettledTools(toolFailure)
|
||||
if (interrupted) yield* publisher.failAssistant(STEP_INTERRUPTED)
|
||||
|
||||
// All local fibers have joined; only provider-hosted results can still be missing.
|
||||
// Parsers may leave unfinished calls without an execution event.
|
||||
if (llmError || (Exit.isSuccess(stream) && !recorded.providerFailed)) {
|
||||
const missing = yield* publisher.failUnsettledTools(RESULT_MISSING, "hosted")
|
||||
if (missing && !llmError && !recorded.finish) yield* publisher.failAssistant(RESULT_MISSING)
|
||||
yield* publisher.failUnsettledTools(INPUT_INCOMPLETE, "uncalled")
|
||||
}
|
||||
|
||||
const record = publisher.record()
|
||||
|
||||
@@ -48,7 +48,10 @@ export interface Interface {
|
||||
readonly refresh: () => Effect.Effect<boolean, Error>
|
||||
readonly add: (origin: string) => Effect.Effect<Entry, Error>
|
||||
readonly remove: (origin: string) => Effect.Effect<void>
|
||||
/** Resolves and caches the configuration for a registered source. */
|
||||
readonly resolve: (entry: Entry, variables: Readonly<Record<string, string>>) => Effect.Effect<Config[], Error>
|
||||
/** Returns the last configuration resolved for an origin, kept until the source is removed. */
|
||||
readonly cached: (origin: string) => Effect.Effect<Config[]>
|
||||
}
|
||||
|
||||
export class Service extends Context.Service<Service, Interface>()("@opencode/WellKnown") {}
|
||||
@@ -97,6 +100,9 @@ const resolveEntry = Effect.fnUntraced(function* (entry: Entry, variables: Reado
|
||||
|
||||
const sourcesKey = "wellknown:sources"
|
||||
const Sources = Schema.Array(Schema.String)
|
||||
const manifestKey = (origin: string) => `wellknown:manifest:${origin}`
|
||||
const configKey = (origin: string) => `wellknown:config:${origin}`
|
||||
const Configs = Schema.Array(Config)
|
||||
|
||||
const layer = Layer.effect(
|
||||
Service,
|
||||
@@ -107,7 +113,22 @@ const layer = Layer.effect(
|
||||
const cache = yield* Ref.make(new Map<string, Entry>())
|
||||
const lock = Semaphore.makeUnsafe(1)
|
||||
const loadEntry = Effect.fn("WellKnown.loadEntry")(function* (origin: string) {
|
||||
const manifest = yield* inspect(origin).pipe(Effect.provideService(HttpClient.HttpClient, http))
|
||||
const manifest = yield* inspect(origin).pipe(
|
||||
Effect.provideService(HttpClient.HttpClient, http),
|
||||
Effect.tap((manifest) => kv.set(manifestKey(origin), manifest)),
|
||||
// An unreachable source keeps its last manifest so its remote config still loads after a restart.
|
||||
Effect.catch((error) =>
|
||||
kv
|
||||
.get(manifestKey(origin))
|
||||
.pipe(
|
||||
Effect.flatMap((cached) =>
|
||||
Schema.is(Manifest)(cached)
|
||||
? Effect.logWarning("failed to load wellknown manifest", { origin, error }).pipe(Effect.as(cached))
|
||||
: Effect.fail(error),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
return { origin, integrationID: Integration.ID.make(origin), manifest }
|
||||
})
|
||||
|
||||
@@ -167,6 +188,8 @@ const layer = Layer.effect(
|
||||
sourcesKey,
|
||||
origins.filter((item) => item !== origin),
|
||||
)
|
||||
yield* kv.remove(manifestKey(origin))
|
||||
yield* kv.remove(configKey(origin))
|
||||
yield* Ref.update(cache, (current) => {
|
||||
const next = new Map(current)
|
||||
next.delete(origin)
|
||||
@@ -176,9 +199,15 @@ const layer = Layer.effect(
|
||||
},
|
||||
(effect, _value) => lock.withPermit(effect),
|
||||
),
|
||||
resolve: Effect.fn("WellKnown.resolveEntry")((entry, variables) =>
|
||||
resolveEntry(entry, variables).pipe(Effect.provideService(HttpClient.HttpClient, http)),
|
||||
),
|
||||
resolve: Effect.fn("WellKnown.resolveEntry")(function* (entry, variables) {
|
||||
const configs = yield* resolveEntry(entry, variables).pipe(Effect.provideService(HttpClient.HttpClient, http))
|
||||
yield* kv.set(configKey(entry.origin), configs)
|
||||
return configs
|
||||
}),
|
||||
cached: Effect.fn("WellKnown.cached")(function* (origin) {
|
||||
const value = yield* kv.get(configKey(origin))
|
||||
return Schema.is(Configs)(value) ? [...value] : []
|
||||
}),
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { describe, expect, test } from "bun:test"
|
||||
import { Effect, Fiber, Layer, Logger, Schema, Stream } from "effect"
|
||||
import { FastCheck } from "effect/testing"
|
||||
import { Config } from "@opencode/core/config"
|
||||
import { Directory, Document, Event, Info } from "@opencode/schema/config"
|
||||
import { Directory, Document, type Entry, Event, Info } from "@opencode/schema/config"
|
||||
import { ConfigModel } from "@opencode/schema/config/model"
|
||||
import { ConfigProvider } from "@opencode/schema/config/provider"
|
||||
import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"
|
||||
@@ -21,6 +21,7 @@ import { Project } from "@opencode/core/project"
|
||||
import { Provider } from "@opencode/core/provider"
|
||||
import { AbsolutePath } from "@opencode/core/schema"
|
||||
import { WellKnown } from "@opencode/core/wellknown"
|
||||
import { KV } from "@opencode/core/kv"
|
||||
import { Integration } from "@opencode/schema/integration"
|
||||
import { emptyCredentialNode, emptyWellknownNode } from "../fixture/config-nodes"
|
||||
import { location } from "../fixture/location"
|
||||
@@ -512,6 +513,7 @@ describe("Config", () => {
|
||||
available
|
||||
? Effect.succeed([{ shell: variables.TOKEN }])
|
||||
: Effect.fail(new Error("expired credential")),
|
||||
cached: () => Effect.succeed([]),
|
||||
}),
|
||||
),
|
||||
deps: [],
|
||||
@@ -550,6 +552,145 @@ describe("Config", () => {
|
||||
),
|
||||
)
|
||||
|
||||
it.live("keeps the last resolved wellknown config across failures and restarts until its source is removed", () =>
|
||||
Effect.acquireUseRelease(
|
||||
Effect.promise(() => tmpdir()),
|
||||
(tmp) => {
|
||||
let manifestStatus = 200
|
||||
let configStatus = 200
|
||||
let requests = 0
|
||||
let key: string | undefined = "secret"
|
||||
const server = Bun.serve({
|
||||
port: 0,
|
||||
fetch(request) {
|
||||
const url = new URL(request.url)
|
||||
if (url.pathname === "/.well-known/opencode") {
|
||||
if (manifestStatus !== 200) return new Response("Unavailable", { status: manifestStatus })
|
||||
return Response.json({
|
||||
auth: { command: ["login"], env: "TOKEN" },
|
||||
remote_config: { url: `${url.origin}/config`, headers: { authorization: "Bearer {env:TOKEN}" } },
|
||||
})
|
||||
}
|
||||
requests++
|
||||
if (configStatus !== 200) return new Response("Unavailable", { status: configStatus })
|
||||
return Response.json({
|
||||
config: {
|
||||
enabled_providers: ["remote"],
|
||||
provider: { remote: { npm: "@ai-sdk/openai-compatible", models: { chat: {} } } },
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
const origin = server.url.origin
|
||||
const integrationID = Integration.ID.make(origin)
|
||||
const credentialNode = makeGlobalNode({
|
||||
service: Credential.Service,
|
||||
layer: Layer.mock(Credential.Service)({
|
||||
list: () =>
|
||||
Effect.succeed(
|
||||
key === undefined
|
||||
? []
|
||||
: [
|
||||
new Credential.Info({
|
||||
id: Credential.ID.create(),
|
||||
integrationID,
|
||||
label: "default",
|
||||
value: Credential.Key.make({ type: "key", key }),
|
||||
}),
|
||||
],
|
||||
),
|
||||
}),
|
||||
deps: [],
|
||||
})
|
||||
const global = path.join(tmp.path, "global")
|
||||
const project = path.join(tmp.path, "project")
|
||||
const remote = (entries: readonly Entry[]) => ({
|
||||
provider: Config.latest(entries, "providers")?.remote?.package,
|
||||
policies: Config.latest(entries, "experimental")?.policies,
|
||||
})
|
||||
const loaded = {
|
||||
provider: "aisdk:@ai-sdk/openai-compatible",
|
||||
policies: [
|
||||
{ action: "provider.use", resource: "*", effect: "deny" },
|
||||
{ action: "provider.use", resource: "remote", effect: "allow" },
|
||||
],
|
||||
} as const
|
||||
const removed = { provider: undefined, policies: undefined }
|
||||
return Effect.gen(function* () {
|
||||
yield* Effect.promise(() => fs.mkdir(project, { recursive: true }))
|
||||
const kv = Layer.succeedContext(yield* Layer.build(LayerNode.compile(KV.node)))
|
||||
// Each build is a fresh process sharing one persisted KV store.
|
||||
const instance = () =>
|
||||
AppNodeBuilder.build(LayerNode.group([Config.node, Bus.node, WellKnown.node]), [
|
||||
Location.node.replace(
|
||||
Layer.succeed(
|
||||
Location.Service,
|
||||
Location.Service.of(location({ directory: AbsolutePath.make(project) })),
|
||||
),
|
||||
),
|
||||
Global.node.replace(Global.layerWith({ config: global, home: path.join(global, "home") })),
|
||||
Credential.node.replace(credentialNode),
|
||||
KV.node.replace(kv),
|
||||
Watcher.node.replace(Watcher.testLayer),
|
||||
])
|
||||
const services = Effect.gen(function* () {
|
||||
const config = yield* Config.Service
|
||||
const bus = yield* Bus.Service
|
||||
// Each reload also rewrites a local file so Config publishes an update to wait on.
|
||||
const reload = Effect.fnUntraced(function* (shell: string, trigger: Effect.Effect<unknown, Error>) {
|
||||
const updated = yield* bus
|
||||
.subscribe(Event.Updated)
|
||||
.pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped({ startImmediately: true }))
|
||||
yield* Effect.promise(() => fs.writeFile(path.join(project, "opencode.json"), JSON.stringify({ shell })))
|
||||
yield* trigger
|
||||
yield* Fiber.join(updated)
|
||||
return remote(yield* config.entries())
|
||||
})
|
||||
const switched = bus.publish(
|
||||
Credential.Event.Switched,
|
||||
{ credentialID: Credential.ID.create(), integrationID },
|
||||
{ global: true },
|
||||
)
|
||||
return { config, bus, wellknown: yield* WellKnown.Service, reload, switched }
|
||||
})
|
||||
|
||||
yield* Effect.gen(function* () {
|
||||
const warm = yield* services
|
||||
expect(yield* warm.reload("initial", warm.wellknown.add(origin))).toEqual(loaded)
|
||||
|
||||
configStatus = 503
|
||||
const before = requests
|
||||
expect(yield* warm.reload("unavailable", warm.switched)).toEqual(loaded)
|
||||
expect(requests).toBeGreaterThan(before)
|
||||
|
||||
key = undefined
|
||||
expect(yield* warm.reload("logged-out", warm.switched)).toEqual(loaded)
|
||||
|
||||
manifestStatus = 503
|
||||
const updated = yield* warm.bus
|
||||
.subscribe(WellKnown.Event.Updated)
|
||||
.pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped({ startImmediately: true }))
|
||||
expect(yield* warm.wellknown.refresh()).toBe(false)
|
||||
yield* Effect.sleep("50 millis")
|
||||
expect(updated.pollUnsafe()).toBeUndefined()
|
||||
}).pipe(Effect.scoped, Effect.provide(instance()))
|
||||
|
||||
key = "secret"
|
||||
yield* Effect.gen(function* () {
|
||||
const cold = yield* services
|
||||
expect(remote(yield* cold.config.entries())).toEqual(loaded)
|
||||
// The wellknown plugin loads these entries at startup and dies if they fail.
|
||||
expect(yield* cold.wellknown.entries()).toHaveLength(1)
|
||||
expect(yield* cold.reload("removed", cold.wellknown.remove(origin))).toEqual(removed)
|
||||
manifestStatus = 200
|
||||
expect(yield* cold.reload("re-added", cold.wellknown.add(origin))).toEqual(removed)
|
||||
}).pipe(Effect.scoped, Effect.provide(instance()))
|
||||
}).pipe(Effect.ensuring(Effect.promise(() => server.stop(true))))
|
||||
},
|
||||
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
|
||||
),
|
||||
)
|
||||
|
||||
it.live("logs redacted source-aware diagnostics for every config source", () => {
|
||||
const output: Array<Record<string, unknown>> = []
|
||||
const logger = Logger.map(Logger.formatStructured, (entry) => {
|
||||
@@ -613,6 +754,7 @@ describe("Config", () => {
|
||||
remove: () => Effect.die("unused Wellknown.remove"),
|
||||
// Exercise the loader boundary against a malformed implementation response.
|
||||
resolve: () => Effect.succeed([null as unknown as WellKnown.Config]),
|
||||
cached: () => Effect.succeed([]),
|
||||
}),
|
||||
),
|
||||
deps: [],
|
||||
|
||||
@@ -31,6 +31,7 @@ export const emptyWellknownNode = makeGlobalNode({
|
||||
add: () => Effect.die("unused Wellknown.add"),
|
||||
remove: () => Effect.die("unused Wellknown.remove"),
|
||||
resolve: () => Effect.die("unused Wellknown.resolve"),
|
||||
cached: () => Effect.succeed([]),
|
||||
}),
|
||||
),
|
||||
deps: [],
|
||||
|
||||
@@ -1,21 +1,32 @@
|
||||
import { expect } from "bun:test"
|
||||
import { cp } from "node:fs/promises"
|
||||
import path from "node:path"
|
||||
import { Deferred, Effect, Exit, Fiber, Layer, Schedule, Scope, Stream } from "effect"
|
||||
import { Brand, Cause, Deferred, Effect, Exit, Fiber, Layer, Option, Schedule, Schema, Scope, Stream } from "effect"
|
||||
import { Agent } from "@opencode/schema/agent"
|
||||
import { Session } from "@opencode/schema/session"
|
||||
import { SessionMessage } from "@opencode/schema/session-message"
|
||||
import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"
|
||||
import { Watcher } from "@opencode/core/filesystem/watcher"
|
||||
import { Config } from "@opencode/core/config"
|
||||
import { Plugin } from "@opencode/core/plugin"
|
||||
import { ManagedPolicy } from "@opencode/core/managed-policy"
|
||||
import { PluginModule } from "@opencode/core/plugin/module"
|
||||
import { Rpc } from "@opencode/core/rpc"
|
||||
import { Tool } from "@opencode/core/tool"
|
||||
import { execute } from "@opencode/core/tool/runtime"
|
||||
import { Global } from "@opencode/util/global"
|
||||
import { Npm } from "@opencode/util/npm"
|
||||
import { createForeignPackageFilter, ensurePluginRuntime } from "@opencode/plugin/runtime"
|
||||
import { createLoader, discoverPluginRuntimeSpecifiers, pluginRuntimeLoaderCode } from "@opencode/plugin/runtime-modules"
|
||||
import { tempGlobalLayer } from "../fixture/global"
|
||||
import { tmpdirScoped } from "../fixture/tmpdir"
|
||||
import { testEffect } from "../lib/effect"
|
||||
import { PluginTestLayer } from "./fixture"
|
||||
|
||||
ensurePluginRuntime()
|
||||
|
||||
const it = testEffect(
|
||||
Layer.mergeAll(
|
||||
Config.testLayer(),
|
||||
ManagedPolicy.layer,
|
||||
PluginTestLayer,
|
||||
AppNodeBuilder.build(Npm.node, [Global.node.replace(tempGlobalLayer)]),
|
||||
Watcher.layer().pipe(Layer.provide(Watcher.nativeLayer)),
|
||||
),
|
||||
@@ -95,6 +106,297 @@ it.live("interrupts pending watcher setup when the loader scope closes during mo
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("loads plugins and their transitive dependencies against the host's Effect and @opencode/plugin instances", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* tmpdirScoped()
|
||||
const pluginDir = path.join(directory.path, "plugin")
|
||||
const pluginEffectDir = path.join(pluginDir, "node_modules/effect")
|
||||
const hostEffectDir = path.dirname(Bun.resolveSync("effect/package.json", import.meta.dir))
|
||||
|
||||
yield* Effect.promise(async () => {
|
||||
await cp(path.join(hostEffectDir, "dist"), path.join(pluginEffectDir, "dist"), {
|
||||
recursive: true,
|
||||
filter: (src) => !src.endsWith(".d.ts") && !src.endsWith(".map") && !/httpApi(?:Scalar|Swagger)\.js$/.test(src),
|
||||
})
|
||||
const pkg = { ...(await Bun.file(path.join(hostEffectDir, "package.json")).json()), version: "4.0.0-rc.111" }
|
||||
|
||||
// Sabotage the plugin's own Effect copy with the version-skew failure modes so loading it would crash:
|
||||
// 1. Effect.log reading an incompatible fiber log-level property (crashing host logger with logLevel.toUpperCase)
|
||||
// 2. Effect.runPromise calling fiber.succeedWith on a host fiber
|
||||
// 3. Schema.withDecodingDefault / Schema.Int / Schema.isPattern / Schema.Trim using foreign parser sentinels
|
||||
const internalEffectPath = path.join(pluginEffectDir, "dist/internal/effect.js")
|
||||
const originalInternalEffect = await Bun.file(internalEffectPath).text()
|
||||
const logPattern =
|
||||
/const logLevel = level \?\? fiber\.(?:currentLogLevel|cache\.logLevel);\r?\n\s*if \(isLogLevelGreaterThan\(fiber\.(?:minimumLogLevel|cache\.minimumLogLevel), logLevel\)\) \{/
|
||||
const runPromisePattern = /const runPromiseExit = runPromiseExitWith\(context\);/
|
||||
expect(logPattern.test(originalInternalEffect)).toBe(true)
|
||||
expect(runPromisePattern.test(originalInternalEffect)).toBe(true)
|
||||
|
||||
await writeFiles(pluginDir, {
|
||||
"node_modules/effect/package.json": JSON.stringify(pkg),
|
||||
"node_modules/effect/dist/internal/effect.js": originalInternalEffect
|
||||
.replace(
|
||||
logPattern,
|
||||
"const logLevel = level ?? fiber.foreignSkew?.logLevel;\n if (isLogLevelGreaterThan(fiber.foreignSkew?.minimumLogLevel, logLevel)) {",
|
||||
)
|
||||
.replace(
|
||||
runPromisePattern,
|
||||
"if (true) return (effect) => Promise.resolve().then(() => { const fiber = {}; return fiber.succeedWith(effect); });\n const runPromiseExit = runPromiseExitWith(context);",
|
||||
),
|
||||
"node_modules/transitive-dep/package.json":
|
||||
'{"name":"transitive-dep","type":"module","exports":{".":"./index.js"}}',
|
||||
"node_modules/transitive-dep/index.js": `import { Effect, Schema } from "effect"
|
||||
import { some } from "effect/Option"
|
||||
export const depToolInput = Schema.Struct({
|
||||
mode: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed("from-dep"))),
|
||||
count: Schema.Int,
|
||||
code: Schema.Trim.check(Schema.isPattern(/^v[0-9]+$/)),
|
||||
})
|
||||
export const depCaptured = { Effect, Schema, some }`,
|
||||
"node_modules/@opencode/plugin/package.json":
|
||||
'{"name":"@opencode/plugin","type":"module","exports":{"./effect":"./effect.js","./rpc":"./rpc.js"}}',
|
||||
"node_modules/@opencode/plugin/effect.js": "export const Plugin = { define: (p) => p }",
|
||||
"node_modules/@opencode/plugin/rpc.js": "export const Rpc = { define: (d) => d }",
|
||||
"index.ts": `import { Plugin } from "@opencode/plugin/effect"
|
||||
import { Rpc } from "@opencode/plugin/rpc"
|
||||
import { Effect, Schema } from "effect"
|
||||
import { some } from "effect/Option"
|
||||
import { nominal } from "effect/Brand"
|
||||
import { depCaptured, depToolInput } from "transitive-dep"
|
||||
|
||||
export const captured = {
|
||||
plugin: { Effect, Schema, some, nominal },
|
||||
dep: depCaptured,
|
||||
pluginCount: -1,
|
||||
}
|
||||
|
||||
const Contract = Rpc.define({
|
||||
id: "host-effect-rpc",
|
||||
methods: {
|
||||
check: {
|
||||
input: Schema.Struct({
|
||||
count: Schema.Int.pipe(Schema.withDecodingDefault(Effect.succeed(5))),
|
||||
tag: Schema.Trim.check(Schema.isPattern(/^v[0-9]+$/)),
|
||||
}),
|
||||
output: Schema.Struct({ value: Schema.String }),
|
||||
},
|
||||
},
|
||||
events: {},
|
||||
})
|
||||
|
||||
export default Plugin.define({
|
||||
id: "host-effect-fixture",
|
||||
effect: (ctx) =>
|
||||
Effect.gen(function* () {
|
||||
yield* Effect.log("setup log from plugin")
|
||||
const listed = yield* Effect.promise(() =>
|
||||
Effect.runPromise(ctx.plugin.list().pipe(Effect.orDie)),
|
||||
)
|
||||
captured.pluginCount = listed.data.length
|
||||
|
||||
yield* ctx.tool.transform((editor) => {
|
||||
editor.add({
|
||||
name: "check_tool",
|
||||
description: "Tool with decoding default from transitive dependency and Int/Trim/isPattern checks",
|
||||
input: depToolInput,
|
||||
output: Schema.Struct({ formatted: Schema.String }),
|
||||
execute: ({ mode, count, code }) =>
|
||||
Effect.log("executing check_tool").pipe(
|
||||
Effect.as({
|
||||
output: { formatted: \`\${mode}:\${code}:\${count}\` },
|
||||
content: \`\${mode}:\${code}:\${count}\`,
|
||||
}),
|
||||
),
|
||||
})
|
||||
})
|
||||
|
||||
yield* ctx.rpc.register(Contract, {
|
||||
check: ({ count, tag }) =>
|
||||
Effect.log("executing rpc check").pipe(
|
||||
Effect.as({ value: \`\${tag}#\${count}\` }),
|
||||
),
|
||||
}).pipe(Effect.orDie)
|
||||
}),
|
||||
})`,
|
||||
})
|
||||
})
|
||||
|
||||
const modules = yield* PluginModule.make()
|
||||
const plugins = yield* Plugin.Service
|
||||
const tools = yield* Tool.Service
|
||||
const rpc = yield* Rpc.Service
|
||||
|
||||
const definition = yield* modules.load({ type: "add", target: pluginDir, options: {} })
|
||||
if ("pending" in definition || "blocked" in definition) return yield* Effect.die(new Error("Local plugin was not loaded"))
|
||||
yield* plugins.activate([definition])
|
||||
yield* plugins.awaitActivation
|
||||
|
||||
expect(yield* plugins.list()).toMatchObject([{ id: "host-effect-fixture", state: { status: "active" } }])
|
||||
|
||||
const imported = yield* Effect.promise(() => import(path.join(pluginDir, "index.ts")))
|
||||
expect(imported.captured.plugin.Effect).toBe(Effect)
|
||||
expect(imported.captured.plugin.Schema).toBe(Schema)
|
||||
expect(imported.captured.plugin.some).toBe(Option.some)
|
||||
expect(imported.captured.plugin.nominal).toBe(Brand.nominal)
|
||||
expect(imported.captured.dep.Effect).toBe(Effect)
|
||||
expect(imported.captured.dep.Schema).toBe(Schema)
|
||||
expect(imported.captured.dep.some).toBe(Option.some)
|
||||
expect(imported.captured.pluginCount).toBe(0)
|
||||
|
||||
const checkTool = (yield* tools.list()).find((tool) => tool.id === "check_tool")
|
||||
expect(checkTool).toBeDefined()
|
||||
if (!checkTool) return
|
||||
|
||||
const context = {
|
||||
sessionID: Session.ID.make("ses_host_effect"),
|
||||
agent: Agent.ID.make("build"),
|
||||
messageID: SessionMessage.ID.make("msg_host_effect"),
|
||||
id: Tool.CallID.make("call_host_effect"),
|
||||
progress: () => Effect.void,
|
||||
}
|
||||
|
||||
expect(yield* execute(checkTool, { count: 3, code: " v42 " }, context)).toEqual({
|
||||
output: { formatted: "from-dep:v42:3" },
|
||||
content: [{ type: "text", text: "from-dep:v42:3" }],
|
||||
})
|
||||
expect(yield* rpc.call("host-effect-rpc", "check", { tag: " v9 " })).toEqual({ value: "v9#5" })
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("redirects plugin dependencies with a nested Effect 3 installation to the host, allows effect/package.json, and fails loudly on unprovided subpaths", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* tmpdirScoped()
|
||||
const pluginDir = path.join(directory.path, "v3-dep-plugin")
|
||||
const badDir = path.join(directory.path, "removed-subpath-plugin")
|
||||
const v3DepDir = path.join(pluginDir, "node_modules/v3-dep")
|
||||
|
||||
yield* Effect.promise(() =>
|
||||
writeFiles(directory.path, {
|
||||
"v3-dep-plugin/node_modules/effect/package.json":
|
||||
'{"name":"effect","version":"4.0.0-rc.111","type":"module","exports":{"./package.json":"./package.json"}}',
|
||||
"v3-dep-plugin/node_modules/v3-dep/node_modules/effect/package.json":
|
||||
'{"name":"effect","version":"3.19.19","type":"module","exports":{".":"./index.js","./Option":"./Option.js","./ReadonlyArray":"./ReadonlyArray.js"}}',
|
||||
"v3-dep-plugin/node_modules/v3-dep/node_modules/effect/index.js":
|
||||
"export const Effect = { major: 3 }; export const Schema = { major: 3 }",
|
||||
"v3-dep-plugin/node_modules/v3-dep/node_modules/effect/Option.js": "export const some = () => ({ major: 3 })",
|
||||
"v3-dep-plugin/node_modules/v3-dep/node_modules/effect/ReadonlyArray.js": "export const fromIterable = () => []",
|
||||
"v3-dep-plugin/node_modules/v3-dep/package.json":
|
||||
'{"name":"v3-dep","type":"module","exports":{".":"./index.js","./v3-only":"./v3-only.js"}}',
|
||||
"v3-dep-plugin/node_modules/v3-dep/index.js":
|
||||
'import { Effect, Schema } from "effect"; import { some } from "effect/Option"; export const v3DepCaptured = { Effect, Schema, some }',
|
||||
"v3-dep-plugin/node_modules/v3-dep/v3-only.js":
|
||||
'import { fromIterable } from "effect/ReadonlyArray"; export { fromIterable }',
|
||||
"v3-dep-plugin/index.ts":
|
||||
'import pkg from "effect/package.json" with { type: "json" }; import { v3DepCaptured } from "v3-dep"; export const effectPkgName = pkg.name; export { v3DepCaptured }; export default { id: "v3-dep-plugin", async setup() {} }',
|
||||
"removed-subpath-plugin/node_modules/effect/package.json":
|
||||
'{"name":"effect","type":"module","exports":{"./RemovedLegacySubpath":"./RemovedLegacySubpath.js"}}',
|
||||
"removed-subpath-plugin/node_modules/effect/RemovedLegacySubpath.js": "export const legacy = true",
|
||||
"removed-subpath-plugin/index.ts":
|
||||
'import { legacy } from "effect/RemovedLegacySubpath"; export default { id: "removed-subpath", async setup() { void legacy } }',
|
||||
}),
|
||||
)
|
||||
|
||||
const modules = yield* PluginModule.make()
|
||||
expect(yield* modules.load({ type: "add", target: pluginDir, options: {} })).toMatchObject({ id: "v3-dep-plugin" })
|
||||
|
||||
const imported = yield* Effect.promise(() => import(path.join(pluginDir, "index.ts")))
|
||||
expect(imported.effectPkgName).toBe("effect")
|
||||
expect(imported.v3DepCaptured.Effect).toBe(Effect)
|
||||
expect(imported.v3DepCaptured.Schema).toBe(Schema)
|
||||
expect(imported.v3DepCaptured.some).toBe(Option.some)
|
||||
yield* Effect.promise(async () => {
|
||||
await expect(import(path.join(v3DepDir, "v3-only.js"))).rejects.toThrow("effect/ReadonlyArray.js")
|
||||
})
|
||||
|
||||
const exit = yield* modules.load({ type: "add", target: badDir, options: {} }).pipe(Effect.exit)
|
||||
expect(Exit.isFailure(exit)).toBe(true)
|
||||
if (Exit.isFailure(exit)) {
|
||||
expect(String(Cause.squash(exit.cause))).toContain("effect/RemovedLegacySubpath.js")
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("discovers exported specifiers from the resolved tree even when dist/ exists, and validates barrel loader routing, async loader dedup, and Windows foreign filters", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* tmpdirScoped()
|
||||
const consumerDir = path.join(directory.path, "consumer")
|
||||
const jitFixtureDir = path.join(directory.path, "jit-fixture")
|
||||
const asyncModPath = path.join(directory.path, "async-mod.ts")
|
||||
|
||||
yield* Effect.promise(() =>
|
||||
writeFiles(directory.path, {
|
||||
"consumer/node_modules/@opencode/plugin/package.json": JSON.stringify({
|
||||
name: "@opencode/plugin",
|
||||
type: "module",
|
||||
exports: {
|
||||
".": "./src/promise/index.ts",
|
||||
"./effect": "./src/effect/index.ts",
|
||||
"./effect/*": "./src/effect/*.ts",
|
||||
},
|
||||
}),
|
||||
"consumer/node_modules/@opencode/plugin/src/promise/index.ts": "export const root = 'src'",
|
||||
"consumer/node_modules/@opencode/plugin/src/effect/index.ts": "export * as plugin from './plugin.ts'",
|
||||
"consumer/node_modules/@opencode/plugin/src/effect/plugin.ts": "export const leaf = 'src'",
|
||||
"consumer/node_modules/@opencode/plugin/src/unexported.ts": "export const secret = true",
|
||||
"consumer/node_modules/@opencode/plugin/dist/promise/index.js": "export const root = 'dist'",
|
||||
"consumer/node_modules/@opencode/plugin/dist/effect/index.js": "export const index = 'dist'",
|
||||
"consumer/node_modules/@opencode/plugin/dist/effect/plugin.js": "export const leaf = 'dist'",
|
||||
"jit-fixture/SchemaJITCompiler.js": "export const enable = () => 'fn'",
|
||||
"jit-fixture/enable.js": "export {}",
|
||||
"async-mod.ts": "await new Promise((r) => setTimeout(r, 20)); export const nonce = Math.random()",
|
||||
}),
|
||||
)
|
||||
|
||||
const discovered = discoverPluginRuntimeSpecifiers(consumerDir, ["@opencode/plugin"])
|
||||
expect(discovered.get("@opencode/plugin")?.replaceAll("\\", "/")).toEndWith("src/promise/index.ts")
|
||||
expect(discovered.get("@opencode/plugin/effect")?.replaceAll("\\", "/")).toEndWith("src/effect/index.ts")
|
||||
expect(discovered.get("@opencode/plugin/effect/plugin")?.replaceAll("\\", "/")).toEndWith("src/effect/plugin.ts")
|
||||
expect(discovered.has("@opencode/plugin/unexported")).toBe(false)
|
||||
|
||||
const hostDiscovered = new Map(discoverPluginRuntimeSpecifiers())
|
||||
hostDiscovered.set("effect/schema/SchemaJITCompiler", path.join(jitFixtureDir, "SchemaJITCompiler.js"))
|
||||
hostDiscovered.set("effect/schema/SchemaJITCompiler/enable", path.join(jitFixtureDir, "enable.js"))
|
||||
expect(pluginRuntimeLoaderCode("effect/Option", hostDiscovered)).toBe('() => require("effect")["Option"]')
|
||||
expect(pluginRuntimeLoaderCode("effect/testing", hostDiscovered)).toBe('() => require("effect/testing")')
|
||||
expect(pluginRuntimeLoaderCode("effect/unstable/http/MultipartParser/HeadersParser", hostDiscovered)).toBe(
|
||||
'() => require("effect/unstable/http/MultipartParser/HeadersParser")',
|
||||
)
|
||||
expect(pluginRuntimeLoaderCode("effect/schema/SchemaJITCompiler/enable", hostDiscovered)).toBe(
|
||||
'() => require("effect/schema/SchemaJITCompiler/enable")',
|
||||
)
|
||||
|
||||
const loadAsync = createLoader(asyncModPath)
|
||||
const first = loadAsync()
|
||||
const second = loadAsync()
|
||||
expect(first).toBeInstanceOf(Promise)
|
||||
expect(first).toBe(second)
|
||||
const [res1, res2] = yield* Effect.promise(() => Promise.all([first, second]))
|
||||
expect(res1).toBe(res2)
|
||||
|
||||
const winFilter = createForeignPackageFilter([
|
||||
"C:\\runner\\_work\\opencode\\node_modules\\.bun\\effect@4.0.0-rc.112\\node_modules\\effect",
|
||||
])
|
||||
expect(
|
||||
winFilter.test(
|
||||
"C:\\runner\\_work\\opencode\\node_modules\\.bun\\effect@4.0.0-rc.112\\node_modules\\effect\\dist\\index.js",
|
||||
),
|
||||
).toBe(false)
|
||||
expect(
|
||||
winFilter.test(
|
||||
"C:/runner/_work/opencode/node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/index.js",
|
||||
),
|
||||
).toBe(false)
|
||||
expect(winFilter.test("C:\\Users\\plugin\\node_modules\\effect\\dist\\index.js")).toBe(true)
|
||||
expect(winFilter.test("C:/Users/plugin/node_modules/effect/dist/index.js")).toBe(true)
|
||||
expect(winFilter.test("C:\\Users\\user\\.bun\\install\\cache\\effect@4.0.1@@@1\\dist\\index.js")).toBe(true)
|
||||
expect(winFilter.test("C:/Users/user/.bun/install/cache/effect@4.0.1@@@1/dist/index.js")).toBe(true)
|
||||
}),
|
||||
)
|
||||
|
||||
async function writeFiles(root: string, files: Record<string, string>) {
|
||||
await Promise.all(Object.entries(files).map(([file, text]) => Bun.write(path.join(root, file), text)))
|
||||
}
|
||||
|
||||
it.live("blocks a local plugin before module initialization and honors replacement policies", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* tmpdirScoped()
|
||||
|
||||
@@ -277,7 +277,7 @@ describe("GoogleVertexPlugin", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("defaults location to us-central1 when only project is configured", () =>
|
||||
it.effect("defaults location to global when only project is configured", () =>
|
||||
withEnv(
|
||||
{
|
||||
GOOGLE_CLOUD_PROJECT: undefined,
|
||||
@@ -299,7 +299,7 @@ describe("GoogleVertexPlugin", () => {
|
||||
yield* addPlugin()
|
||||
const provider = required(yield* catalog.get(Provider.ID.make("google-vertex")))
|
||||
expect(provider.settings?.project).toBe("config-project")
|
||||
expect(provider.settings?.location).toBe("us-central1")
|
||||
expect(provider.settings?.location).toBe("global")
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -845,7 +845,16 @@ const fragmentFixture = (kind: FragmentKind, id: string, chunks: readonly string
|
||||
return {
|
||||
partialEvents,
|
||||
completeEvents: [...partialEvents, LLMEvent.toolInputEnd({ id, name: "echo" })],
|
||||
expectedAssistant: { type: "assistant", content: [expectedContent] },
|
||||
expectedAssistant: {
|
||||
type: "assistant",
|
||||
content: [
|
||||
{
|
||||
type: "tool",
|
||||
id,
|
||||
state: { status: "error", input: {}, error: { type: "tool.input-incomplete" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
expectedContent,
|
||||
}
|
||||
}
|
||||
@@ -6023,6 +6032,30 @@ describe("SessionRunnerLLM", () => {
|
||||
])
|
||||
})
|
||||
|
||||
scenario("settles unfinished tool input after an output limit", function* (s) {
|
||||
yield* s.llm.push(
|
||||
TestLLM.complete(
|
||||
{ reason: { normalized: "length" } },
|
||||
LLMEvent.toolInputStart({ id: "call-incomplete", name: "echo" }),
|
||||
LLMEvent.toolInputDelta({ id: "call-incomplete", name: "echo", text: '{"text":"partial' }),
|
||||
),
|
||||
TestLLM.stop(),
|
||||
)
|
||||
|
||||
yield* s.runPrompt("Recover unfinished tool input")
|
||||
|
||||
expect(s.requests).toHaveLength(2)
|
||||
expect(s.executions).toEqual([])
|
||||
expect(requireAssistant(yield* s.context).content).toMatchObject([
|
||||
{
|
||||
type: "tool",
|
||||
id: "call-incomplete",
|
||||
executed: false,
|
||||
state: { status: "error", error: { type: "tool.input-incomplete" } },
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
scenario("continues after malformed local tool input without exposing raw arguments", function* (s) {
|
||||
const marker = "raw-malformed-marker"
|
||||
const raw = `{"text":"${marker}`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@opencode/desktop",
|
||||
"private": true,
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"homepage": "https://opencode.ai",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/enterprise",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/function",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/gui-extensions",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -5,6 +5,7 @@ export default {
|
||||
"usage.usage": "Context",
|
||||
"usage.cost": "Cost",
|
||||
"usage.view": "View context usage",
|
||||
"usage.toggle": "Toggle session context",
|
||||
"systemPrompt.title": "System Prompt",
|
||||
"rawMessages.title": "Raw messages",
|
||||
"export.session": "Export session",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Show, createMemo, type ComponentProps, type JSX } from "solid-js"
|
||||
import { ProgressCircle } from "@opencode/ui/progress-circle"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { Button } from "@opencode/ui/button"
|
||||
import { Tooltip } from "@opencode/ui/tooltip"
|
||||
import { useI18n } from "@opencode/ui/context/i18n"
|
||||
import { useExtension, type MountedSession } from "../sdk"
|
||||
@@ -62,10 +62,26 @@ export function SessionContextUsage(props: {
|
||||
}
|
||||
})
|
||||
|
||||
const tokens = createMemo(() =>
|
||||
new Intl.NumberFormat(i18n.locale(), { notation: "compact", maximumFractionDigits: 0 })
|
||||
.format(context()?.total ?? 0)
|
||||
.toLocaleLowerCase(i18n.locale()),
|
||||
)
|
||||
|
||||
const cost = createMemo(() => {
|
||||
return usd().format(info()?.cost ?? 0)
|
||||
})
|
||||
|
||||
const showCost = createMemo(() => {
|
||||
if ((info()?.cost ?? 0) > 0) return true
|
||||
const ref = info()?.model ?? messages().findLast((item) => item.type === "assistant")?.model
|
||||
const model = ref ? catalogModel(props.session, ref)?.model : undefined
|
||||
|
||||
if (!model) return true
|
||||
|
||||
return model.cost.some((cost) => cost.input > 0 || cost.output > 0 || cost.cache.read > 0 || cost.cache.write > 0)
|
||||
})
|
||||
|
||||
const openContext = () => {
|
||||
if (!props.session.id) return
|
||||
layout.toggle(`${ctx.id}:main`, props.session)
|
||||
@@ -89,13 +105,15 @@ export function SessionContextUsage(props: {
|
||||
|
||||
const compactCircle = () => (
|
||||
<div class="flex items-center justify-center">
|
||||
<ProgressCircle appearance="compact" percentage={context()?.usage ?? 0} />
|
||||
<ProgressCircle appearance="compact" size={16} percentage={context()?.usage ?? 0} />
|
||||
</div>
|
||||
)
|
||||
|
||||
const tooltipValue = () => (
|
||||
<div class="flex w-[120px] flex-col gap-2">
|
||||
<ContextTooltipRow name={ctx.t("usage.cost")} value={cost()} />
|
||||
<Show when={showCost()}>
|
||||
<ContextTooltipRow name={ctx.t("usage.cost")} value={cost()} />
|
||||
</Show>
|
||||
<ContextTooltipRow name={ctx.t("usage.usage")} value={`${context()?.usage ?? 0}%`} />
|
||||
<ContextTooltipRow name={ctx.t("usage.tokens")} value={context()?.total.toLocaleString(i18n.locale()) ?? "0"} />
|
||||
</div>
|
||||
@@ -103,18 +121,33 @@ export function SessionContextUsage(props: {
|
||||
|
||||
return (
|
||||
<Show when={props.session.id}>
|
||||
<Tooltip value={tooltipValue()} placement={props.placement ?? "top"} shift={-8}>
|
||||
<Tooltip
|
||||
value={variant() === "indicator" ? tooltipValue() : ctx.t("usage.toggle")}
|
||||
placement={props.placement ?? "top"}
|
||||
>
|
||||
<Show
|
||||
when={variant() === "indicator"}
|
||||
fallback={
|
||||
<IconButton
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
icon={compactCircle()}
|
||||
class="group shrink-0"
|
||||
style={{ padding: "0 6px", color: "var(--v2-text-text-faint)" }}
|
||||
onClick={openContext}
|
||||
aria-label={ctx.t("usage.view")}
|
||||
/>
|
||||
aria-expanded={layout.state(`${ctx.id}:main`, props.session) === "visible"}
|
||||
aria-label={ctx.t("usage.toggle")}
|
||||
>
|
||||
<span class="flex items-center gap-2 whitespace-nowrap group-active:text-v2-text-text-muted">
|
||||
{compactCircle()}
|
||||
<span>{tokens()}</span>
|
||||
<Show when={showCost()}>
|
||||
<span aria-hidden="true" class="flex w-1.5 shrink-0 items-center justify-center">
|
||||
·
|
||||
</span>
|
||||
<span>{cost()}</span>
|
||||
</Show>
|
||||
</span>
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
{circle()}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"name": "@opencode/http-recorder",
|
||||
"description": "Record and replay Effect HTTP and WebSocket traffic with deterministic cassettes",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/httpapi-codegen",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/latex",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/merman",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/plugin-browser",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"description": "OpenCode's desktop browser plugin",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# `@opencode/plugin`
|
||||
|
||||
Authoring interfaces and runtime loader support for OpenCode V2 plugins:
|
||||
|
||||
- `@opencode/plugin` — [Promise plugin API](./src/README.md)
|
||||
- `@opencode/plugin/effect` — [Effect plugin API](./src/effect/README.md)
|
||||
- `@opencode/plugin/rpc` — portable RPC contract definitions
|
||||
- `@opencode/plugin/tui` — terminal UI plugin API
|
||||
|
||||
## Packaging And Runtime `effect`
|
||||
|
||||
When the OpenCode CLI loads server or TUI plugins, it resolves imports of `effect`, exported `effect/*` subpaths, and `@opencode/plugin` entrypoints (including imports from dependencies inside a plugin's `node_modules`) to the host's runtime module instances so fibers, loggers, and `Schema` parsers share one copy.
|
||||
|
||||
- Declare `effect` as a `peerDependency` (and `devDependency` for local type-checking and testing) rather than a bundled runtime dependency.
|
||||
- Do not bundle `effect` into published plugin files; if you build with a bundler, keep `effect` and `effect/*` external. Two copies of `effect` do not share fiber, logger, or `Schema` internals.
|
||||
- Plugins and their `node_modules` dependencies always receive OpenCode's host `effect` instance. Use `effect` APIs and module paths compatible with the OpenCode release you target; dependencies built on another `effect` major (such as Effect 3) are not supported.
|
||||
- Only public `effect` subpaths are provided. A plugin that imports one of Effect's private `internal` modules fails to load with an error naming the path.
|
||||
- The compiled OpenCode binary does not include the Scalar and Swagger UI assets used by Effect's HTTP API docs pages; serving those pages from a plugin shows a notice instead.
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/plugin",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
@@ -13,6 +13,7 @@
|
||||
".": "./src/promise/index.ts",
|
||||
"./effect": "./src/effect/index.ts",
|
||||
"./host": "./src/host.ts",
|
||||
"./runtime": "./src/runtime.ts",
|
||||
"./tui": "./src/tui/index.ts",
|
||||
"./*": "./src/*.ts"
|
||||
},
|
||||
@@ -37,8 +38,8 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@opencode/theme": "workspace:*",
|
||||
"@opentui/core": ">=0.5.16",
|
||||
"@opentui/solid": ">=0.5.16",
|
||||
"@opentui/core": ">=0.5.17",
|
||||
"@opentui/solid": ">=0.5.17",
|
||||
"solid-js": ">=1.9.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { existsSync, realpathSync } from "node:fs"
|
||||
import path from "node:path"
|
||||
import { pathToFileURL } from "node:url"
|
||||
|
||||
export type RuntimeModuleLoader = () => Record<string, unknown> | Promise<Record<string, unknown>>
|
||||
|
||||
const runtimePackages = ["effect", "@opencode/plugin"] as const
|
||||
|
||||
export function resolveHostPackageRoots(from = import.meta.dir, packages: readonly string[] = runtimePackages) {
|
||||
return packages.flatMap((pkgName) => {
|
||||
const dir = path.dirname(Bun.resolveSync(`${pkgName}/package.json`, from))
|
||||
return [dir, findNodeModulesDir(pkgName, from, dir)]
|
||||
})
|
||||
}
|
||||
|
||||
export function loadRuntimeModules(): Readonly<Record<string, RuntimeModuleLoader>> {
|
||||
const entries = discoverPluginRuntimeSpecifiers()
|
||||
const effectEntry = entries.get("effect")
|
||||
if (effectEntry) require(effectEntry)
|
||||
return Object.fromEntries(
|
||||
[...entries.entries()].map(([specifier, resolved]) => [specifier, createLoader(resolved)]),
|
||||
)
|
||||
}
|
||||
|
||||
export function discoverPluginRuntimeSpecifiers(
|
||||
from = import.meta.dir,
|
||||
packages: readonly string[] = runtimePackages,
|
||||
): ReadonlyMap<string, string> {
|
||||
const entries = new Map<string, string>()
|
||||
for (const pkgName of packages) {
|
||||
const realDir = path.dirname(Bun.resolveSync(`${pkgName}/package.json`, from))
|
||||
// Resolve workspace @opencode/plugin paths via node_modules so OpenTUI does not wrap host files in async rewrite loaders.
|
||||
const loadDir = findNodeModulesDir(pkgName, from, realDir)
|
||||
const toLoadPath = (resolved: string) =>
|
||||
loadDir === realDir ? resolved : path.join(loadDir, path.relative(realDir, resolved))
|
||||
const rootEntry = Bun.resolveSync(pkgName, from)
|
||||
const relParts = path.relative(realDir, rootEntry).replaceAll("\\", "/").split("/")
|
||||
const scanDir = relParts.length > 1 ? path.join(realDir, relParts[0]) : realDir
|
||||
const ext = path.extname(rootEntry) || ".js"
|
||||
entries.set(pkgName, toLoadPath(rootEntry))
|
||||
for (const file of new Bun.Glob(`**/*${ext}`).scanSync({ cwd: scanDir })) {
|
||||
const normalized = file.replaceAll("\\", "/")
|
||||
if (
|
||||
normalized.startsWith("internal/") ||
|
||||
normalized.includes("/internal/") ||
|
||||
normalized.startsWith("source.") ||
|
||||
normalized.startsWith("runtime")
|
||||
) {
|
||||
continue
|
||||
}
|
||||
const base = normalized.slice(0, -ext.length)
|
||||
if (base === "index") continue
|
||||
const candidates = base.endsWith("/index")
|
||||
? [`${pkgName}/${base.slice(0, -"/index".length)}`, `${pkgName}/${base}`]
|
||||
: [`${pkgName}/${base}`]
|
||||
for (const specifier of candidates) {
|
||||
if (entries.has(specifier)) continue
|
||||
try {
|
||||
entries.set(specifier, toLoadPath(Bun.resolveSync(specifier, from)))
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
export function pluginRuntimeLoaderCode(specifier: string, entries: ReadonlyMap<string, string>) {
|
||||
if (specifier.startsWith("effect/")) {
|
||||
const slash = specifier.lastIndexOf("/")
|
||||
const parent = specifier.slice(0, slash)
|
||||
const member = specifier.slice(slash + 1)
|
||||
const parentResolved = entries.get(parent)
|
||||
const resolved = entries.get(specifier)
|
||||
if (
|
||||
member !== "index" &&
|
||||
parentResolved &&
|
||||
resolved &&
|
||||
(require(parentResolved) as Record<string, unknown>)[member] === require(resolved)
|
||||
) {
|
||||
return `() => require(${JSON.stringify(parent)})[${JSON.stringify(member)}]`
|
||||
}
|
||||
}
|
||||
return `() => require(${JSON.stringify(specifier)})`
|
||||
}
|
||||
|
||||
export function createLoader(resolved: string): RuntimeModuleLoader {
|
||||
let cached: Record<string, unknown> | undefined
|
||||
let pending: Promise<Record<string, unknown>> | undefined
|
||||
return () => {
|
||||
if (cached) return cached
|
||||
if (pending) return pending
|
||||
try {
|
||||
return (cached = require(resolved) as Record<string, unknown>)
|
||||
} catch {
|
||||
return (pending = import(pathToFileURL(resolved).href).then(
|
||||
(mod: Record<string, unknown>) => (cached = mod),
|
||||
(error) => {
|
||||
pending = undefined
|
||||
throw error
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findNodeModulesDir(pkgName: string, from: string, realDir: string) {
|
||||
if (/[/\\]node_modules[/\\]/.test(realDir)) return realDir
|
||||
for (let dir = path.resolve(from); ; dir = path.dirname(dir)) {
|
||||
const candidate = path.join(dir, "node_modules", pkgName)
|
||||
if (existsSync(candidate) && realpathSync(candidate) === realDir) return candidate
|
||||
if (path.dirname(dir) === dir) return realDir
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { loadRuntimeModules, resolveHostPackageRoots, type RuntimeModuleLoader } from "./runtime-modules.js"
|
||||
|
||||
const foreignPkgSuffix = String.raw`(?:node_modules[/\\](@opencode[/\\]plugin|effect)|(@opencode[/\\]plugin|effect)@[^/\\]+@@@\d+)`
|
||||
const foreignPkgPattern = new RegExp(String.raw`^(.*[/\\]${foreignPkgSuffix})[/\\](.+)$`)
|
||||
|
||||
let installed: Readonly<Record<string, RuntimeModuleLoader>> | undefined
|
||||
|
||||
export function provides(specifier: string) {
|
||||
return installed !== undefined && Object.hasOwn(installed, specifier)
|
||||
}
|
||||
|
||||
export function ensurePluginRuntime() {
|
||||
if (typeof Bun === "undefined") return {}
|
||||
if (installed) return installed
|
||||
const modules = loadRuntimeModules()
|
||||
installed = modules
|
||||
Bun.plugin({
|
||||
name: "opencode-plugin-runtime",
|
||||
setup(build) {
|
||||
for (const [specifier, load] of Object.entries(modules)) {
|
||||
build.module(specifier, () => {
|
||||
const exports = load()
|
||||
return exports instanceof Promise
|
||||
? exports.then((value) => ({ exports: value, loader: "object" as const }))
|
||||
: { exports, loader: "object" as const }
|
||||
})
|
||||
}
|
||||
build.onLoad({ filter: createForeignPackageFilter() }, (args) => {
|
||||
const match = args.path.match(foreignPkgPattern)
|
||||
const target = match ? `${match[2] ?? match[3]}/${match[4]}`.replaceAll("\\", "/") : args.path
|
||||
throw new Error(
|
||||
`Cannot load "${target}" from plugin node_modules: "${target}" is not provided by OpenCode; plugins must use the host's "effect" and "@opencode/plugin" modules.`,
|
||||
)
|
||||
})
|
||||
},
|
||||
})
|
||||
return modules
|
||||
}
|
||||
|
||||
export function createForeignPackageFilter(rootsInput: Iterable<string> = resolveHostPackageRoots()) {
|
||||
const suffix = String.raw`[/\\]${foreignPkgSuffix}[/\\].*\.[cm]?[jt]sx?(?:[?#].*)?$`
|
||||
const roots = [...new Set(rootsInput)]
|
||||
if (roots.length === 0) return new RegExp(suffix)
|
||||
const escaped = roots
|
||||
.map((value) =>
|
||||
value
|
||||
.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
||||
.replace(/(?:\\\/|\\\\|\/)+/g, "[/\\\\]"),
|
||||
)
|
||||
.join("|")
|
||||
return new RegExp(`^(?!(?:${escaped})[/\\\\]).*${suffix}`)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs"
|
||||
import path from "node:path"
|
||||
import { fileURLToPath, pathToFileURL } from "node:url"
|
||||
import { Host } from "./host.js"
|
||||
import { provides } from "./runtime.js"
|
||||
import { localSource } from "./source.js"
|
||||
import { missingPackageTarget } from "./source.package.js"
|
||||
|
||||
@@ -39,6 +40,7 @@ export async function prepareSource(entrypoint: string, track: (file: string, di
|
||||
? new URL(item.path, pathToFileURL(file))
|
||||
: localSource(item.path, path.dirname(file))
|
||||
if (!local) {
|
||||
if (provides(item.path)) continue
|
||||
try {
|
||||
Bun.resolveSync(item.path, path.dirname(file))
|
||||
} catch {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"
|
||||
import { mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises"
|
||||
import { tmpdir } from "node:os"
|
||||
import path from "node:path"
|
||||
import { describe, it } from "node:test"
|
||||
@@ -11,7 +11,7 @@ const source = 'throw new Error("Plugin code must not run during resolution")'
|
||||
const name = "@fixture/plugin"
|
||||
|
||||
async function fixture(files: Record<string, string>, installed = false) {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "opencode-host-"))
|
||||
const root = await realpath(await mkdtemp(path.join(tmpdir(), "opencode-host-")))
|
||||
const directory = installed ? path.join(root, "node_modules", name) : root
|
||||
await Promise.all(
|
||||
Object.entries(files).map(async ([file, content]) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/protocol",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* Clients send the API version they can decode in this header. The server omits response variants newer than
|
||||
* that version, so a newer server does not break an older client that rejects unknown union members.
|
||||
*/
|
||||
export const API_VERSION_HEADER = "x-opencode-api-version"
|
||||
|
||||
/**
|
||||
* Response-shape versions:
|
||||
*
|
||||
* - `1`: clients that send no header (v2.0.24 and earlier).
|
||||
* - `2`: understands `external` integration methods, connections, and credentials.
|
||||
*
|
||||
* Bump this when a response can contain a value an older client cannot decode, and omit that value on the server
|
||||
* for requests below the new version.
|
||||
*/
|
||||
export const API_VERSION = 2
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/schema",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"name": "@opencode/sdk",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/server",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
export * as ApiVersion from "./api-version"
|
||||
|
||||
import type { Integration } from "@opencode/core/integration"
|
||||
import { API_VERSION_HEADER } from "@opencode/protocol/api-version"
|
||||
import type { Credential } from "@opencode/schema/credential"
|
||||
import type { HttpServerRequest } from "effect/unstable/http"
|
||||
|
||||
// Responses omit values newer than the requesting client's API version. Remove a version's
|
||||
// omissions once clients below it are no longer supported.
|
||||
|
||||
/** Returns the API version the requesting client can decode. Clients that send no header predate versioning. */
|
||||
export function requested(request: HttpServerRequest.HttpServerRequest) {
|
||||
const version = Number(request.headers[API_VERSION_HEADER])
|
||||
return Number.isSafeInteger(version) && version > 0 ? version : 1
|
||||
}
|
||||
|
||||
/** Version 1 clients reject `external` integration methods and connections. */
|
||||
export function integration(info: Integration.Info, version: number): Integration.Info {
|
||||
if (version >= 2) return info
|
||||
return {
|
||||
...info,
|
||||
methods: info.methods.filter((method) => method.type !== "external"),
|
||||
connections: info.connections.filter(
|
||||
(connection) => connection.type !== "credential" || connection.method !== "external",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/** Version 1 clients reject `external` credential values. */
|
||||
export function credentials<T extends { readonly value: Credential.Value }>(entries: T[], version: number) {
|
||||
if (version >= 2) return entries
|
||||
return entries.filter((entry) => entry.value.type !== "external")
|
||||
}
|
||||
@@ -3,15 +3,14 @@ import { ConflictError } from "@opencode/protocol/errors"
|
||||
import { Effect } from "effect"
|
||||
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi"
|
||||
import { Api } from "../api"
|
||||
import { ApiVersion } from "../api-version"
|
||||
|
||||
export const CredentialHandler = HttpApiBuilder.group(Api, "server.credential", (handlers) =>
|
||||
handlers
|
||||
.handle(
|
||||
"credential.list",
|
||||
Effect.fn(function* (ctx) {
|
||||
Effect.fn(function* () {
|
||||
const credential = yield* Credential.Service
|
||||
return { data: ApiVersion.credentials(entries(yield* credential.all()), ApiVersion.requested(ctx.request)) }
|
||||
return { data: entries(yield* credential.all()) }
|
||||
}),
|
||||
)
|
||||
.handle(
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from "@opencode/protocol/errors"
|
||||
import { response } from "../location"
|
||||
import { WellKnown } from "@opencode/core/wellknown"
|
||||
import { ApiVersion } from "../api-version"
|
||||
|
||||
const authorize = <A, R>(effect: Effect.Effect<A, Integration.AuthorizationError, R>) =>
|
||||
effect.pipe(
|
||||
@@ -30,13 +29,10 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
||||
return handlers
|
||||
.handle(
|
||||
"integration.list",
|
||||
Effect.fn(function* (ctx) {
|
||||
Effect.fn(function* () {
|
||||
yield* Plugin.awaitActivation
|
||||
const service = yield* Integration.Service
|
||||
const version = ApiVersion.requested(ctx.request)
|
||||
return yield* response(
|
||||
service.list().pipe(Effect.map((list) => list.map((item) => ApiVersion.integration(item, version)))),
|
||||
)
|
||||
return yield* response(service.list())
|
||||
}),
|
||||
)
|
||||
.handle(
|
||||
@@ -49,7 +45,7 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
||||
integrationID: ctx.params.integrationID,
|
||||
message: `Integration not found: ${ctx.params.integrationID}`,
|
||||
})
|
||||
return yield* response(Effect.succeed(ApiVersion.integration(integration, ApiVersion.requested(ctx.request))))
|
||||
return yield* response(Effect.succeed(integration))
|
||||
}),
|
||||
)
|
||||
.handle(
|
||||
|
||||
@@ -47,6 +47,7 @@ export const start = Effect.fn("ServerProcess.start")(function* <E, R>(
|
||||
options: ServerOptions,
|
||||
lifecycle?: Lifecycle<E, R>,
|
||||
transform?: Transform,
|
||||
remoteURLs?: () => ReadonlyArray<string>,
|
||||
) {
|
||||
const password = options.password
|
||||
if (!password) return yield* Effect.fail(new Error("Missing server password"))
|
||||
@@ -55,12 +56,13 @@ export const start = Effect.fn("ServerProcess.start")(function* <E, R>(
|
||||
const shutdown = yield* Latch.make()
|
||||
const status = yield* Status.make()
|
||||
const bound = yield* listen({ hostname, port })
|
||||
const urls = () => {
|
||||
const localURLs = () => {
|
||||
const address = bound.server.address()
|
||||
if (address === null || typeof address === "string") return []
|
||||
const host = address.family === "IPv6" ? `[${address.address}]` : address.address
|
||||
return ServerInfo.connectionURLs(`http://${host}:${address.port}`, hostname)
|
||||
}
|
||||
const urls = () => [...localURLs(), ...(remoteURLs?.() ?? [])]
|
||||
const application = yield* Ref.make(Option.none<App>())
|
||||
const app = dispatch(password, status, application, options.app?.version ?? "unknown", urls, Global.Path.tmp)
|
||||
// Request fibers may continue inbound trace context, but must not inherit the server startup parent.
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
import { expect } from "bun:test"
|
||||
import { SdkPlugins } from "@opencode/core/plugin/sdk"
|
||||
import { Plugin } from "@opencode/plugin/effect"
|
||||
import { API_VERSION, API_VERSION_HEADER } from "@opencode/protocol/api-version"
|
||||
import { Context, Effect, Layer } from "effect"
|
||||
import { HttpEffect, HttpRouter, HttpServer } from "effect/unstable/http"
|
||||
import { tmpdirScoped } from "../../core/test/fixture/tmpdir"
|
||||
import { it } from "../../core/test/lib/effect"
|
||||
import { createRoutes } from "../src/routes"
|
||||
|
||||
it.live(
|
||||
"omits external integration methods, connections, and credentials for clients below API version 2",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const tmp = yield* tmpdirScoped("opencode-api-version-")
|
||||
const context = yield* Layer.build(
|
||||
createRoutes({
|
||||
password: "secret",
|
||||
database: { path: ":memory:" },
|
||||
models: { fetch: false },
|
||||
fs: { filewatcher: false },
|
||||
config: { directory: tmp.path, project: false },
|
||||
}).pipe(Layer.provide(HttpServer.layerServices)),
|
||||
)
|
||||
yield* Context.get(context, SdkPlugins.Service).register(
|
||||
Plugin.define({
|
||||
id: "external-fixture",
|
||||
effect: (ctx) =>
|
||||
ctx.integration.transform((editor) => {
|
||||
editor.update("cloud", (integration) => {
|
||||
integration.name = "Cloud"
|
||||
})
|
||||
editor.method.update({ integrationID: "cloud", method: { type: "key", label: "API key" } })
|
||||
editor.method.update({
|
||||
integrationID: "cloud",
|
||||
method: { id: "profile", type: "external", label: "Profile" },
|
||||
})
|
||||
}),
|
||||
}),
|
||||
)
|
||||
const handler = Context.get(context, HttpRouter.HttpRouter)
|
||||
.asHttpEffect()
|
||||
.pipe(HttpEffect.toWebHandlerWith(context))
|
||||
const request = (route: string, input: { version?: number; body?: unknown } = {}) =>
|
||||
Effect.promise(async (signal) => {
|
||||
const url = new URL(route, "http://opencode.local")
|
||||
url.searchParams.set("location[directory]", tmp.path)
|
||||
const headers = new Headers({ authorization: `Basic ${btoa("opencode:secret")}` })
|
||||
if (input.version !== undefined) headers.set(API_VERSION_HEADER, String(input.version))
|
||||
if (input.body !== undefined) headers.set("content-type", "application/json")
|
||||
const response = await handler(
|
||||
new Request(url, {
|
||||
method: input.body === undefined ? "GET" : "POST",
|
||||
headers,
|
||||
body: input.body === undefined ? undefined : JSON.stringify(input.body),
|
||||
signal,
|
||||
}),
|
||||
)
|
||||
expect(response.status).toBeLessThan(300)
|
||||
return response.json()
|
||||
})
|
||||
|
||||
yield* request("/api/credential", {
|
||||
version: API_VERSION,
|
||||
body: { integrationID: "cloud", label: "Default profile", value: { type: "external", methodID: "profile" } },
|
||||
})
|
||||
yield* request("/api/credential", {
|
||||
version: API_VERSION,
|
||||
body: { integrationID: "cloud", label: "Key", value: { type: "key", key: "secret" }, activate: false },
|
||||
})
|
||||
|
||||
const cloud = (body: { data: Array<{ id: string }> }) => body.data.find((item) => item.id === "cloud")
|
||||
expect(cloud(yield* request("/api/integration", { version: API_VERSION }))).toMatchObject({
|
||||
methods: [{ type: "key" }, { type: "external", id: "profile" }],
|
||||
connections: expect.arrayContaining([expect.objectContaining({ method: "external" })]),
|
||||
})
|
||||
expect((yield* request("/api/credential", { version: API_VERSION })).data).toHaveLength(2)
|
||||
|
||||
// v2.0.24 and earlier send no version header; a malformed header is treated the same way.
|
||||
for (const version of [undefined, 1, Number.NaN]) {
|
||||
const legacy = cloud(yield* request("/api/integration", { version }))
|
||||
expect(legacy).toMatchObject({ methods: [{ type: "key" }] })
|
||||
expect(legacy).not.toMatchObject({ methods: expect.arrayContaining([{ type: "external" }]) })
|
||||
expect(JSON.stringify(legacy)).not.toContain('"external"')
|
||||
expect(JSON.stringify(yield* request("/api/integration/cloud", { version }))).not.toContain('"external"')
|
||||
expect(yield* request("/api/credential", { version })).toMatchObject({
|
||||
data: [{ integrationID: "cloud", value: { type: "key" } }],
|
||||
})
|
||||
}
|
||||
}),
|
||||
15_000,
|
||||
)
|
||||
@@ -236,3 +236,26 @@ async function readUntil(reader: ReadableStreamDefaultReader<Uint8Array>, expect
|
||||
if (new TextDecoder().decode(next.value).includes(expected)) return
|
||||
}
|
||||
}
|
||||
|
||||
it.live("server info lists remote URLs alongside local addresses while they are available", () =>
|
||||
Effect.gen(function* () {
|
||||
const remote = { urls: ["https://example.opentunnel.xyz"] as ReadonlyArray<string> }
|
||||
const server = yield* ServerProcess.start<never, never>(
|
||||
{ hostname: "127.0.0.1", port: 0, password: "secret", database: { path: ":memory:" } },
|
||||
undefined,
|
||||
undefined,
|
||||
() => remote.urls,
|
||||
)
|
||||
const base = HttpServer.formatAddress(server.address)
|
||||
const info = () =>
|
||||
Effect.promise(() =>
|
||||
fetch(new URL("/api/info", base), { headers: { authorization: `Basic ${btoa("opencode:secret")}` } }).then(
|
||||
(response) => response.json() as Promise<{ urls: ReadonlyArray<string> }>,
|
||||
),
|
||||
)
|
||||
|
||||
expect((yield* info()).urls).toEqual([base, "https://example.opentunnel.xyz"])
|
||||
remote.urls = []
|
||||
expect((yield* info()).urls).toEqual([base])
|
||||
}),
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@opencode/session-ui",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -28,9 +28,12 @@ export type SessionUserAttachmentReference = {
|
||||
export type SessionUserActions = {
|
||||
openAttachment?: (file: PromptFileAttachment) => void
|
||||
revert?: (input: { sessionID: string; messageID: string }) => Promise<void> | void
|
||||
/** A steer the server has not delivered yet. Like the TUI, it can move to the queue or be deleted. */
|
||||
/**
|
||||
* An input the server has not delivered yet. Like the TUI, a pending steer can move to the queue or be deleted;
|
||||
* it shows as waiting only while `steering` behind delivered work or `stranded` by an execution that ended.
|
||||
*/
|
||||
pending?: {
|
||||
steer: (messageID: string) => boolean
|
||||
status: (messageID: string) => "starting" | "steering" | "stranded" | "queued" | undefined
|
||||
queue: (input: { sessionID: string; messageID: string }) => Promise<void>
|
||||
remove: (input: { sessionID: string; messageID: string }) => Promise<void>
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export type Projection = {
|
||||
}
|
||||
|
||||
// Split with the renderer's math syntax so a display block is never cut into separately rendered pieces.
|
||||
const lexer = new Marked(...markdownMath)
|
||||
const lexer = new Marked(markdownMath)
|
||||
|
||||
function refs(text: string) {
|
||||
if (!text.includes("]:")) return false
|
||||
|
||||
@@ -817,6 +817,8 @@
|
||||
|
||||
[data-component="tool-part-wrapper"] {
|
||||
width: 100%;
|
||||
/* Revealing a tool lands its title just below the headers that stick above it. */
|
||||
scroll-margin-top: var(--sticky-accordion-top, 0px);
|
||||
}
|
||||
|
||||
[data-component="dock-prompt"][data-kind="permission"] {
|
||||
|
||||
@@ -259,7 +259,9 @@ export function CurrentUserMessageDisplay(props: {
|
||||
const dialog = useDialog()
|
||||
const i18n = useI18n()
|
||||
const [state, setState] = createStore({ copied: false, reverting: false, updating: false })
|
||||
const pending = createMemo(() => !!props.actions?.pending?.steer(props.message.id))
|
||||
const status = createMemo(() => props.actions?.pending?.status(props.message.id))
|
||||
const pending = createMemo(() => status() !== undefined && status() !== "queued")
|
||||
const waiting = createMemo(() => status() === "steering" || status() === "stranded")
|
||||
const attachments = createMemo(() => (props.message.files ?? []).filter(attached))
|
||||
const references = createMemo(() => props.references ?? [])
|
||||
const inlineFiles = createMemo(() => (props.message.files ?? []).filter((file) => !!file.mention))
|
||||
@@ -271,7 +273,7 @@ export function CurrentUserMessageDisplay(props: {
|
||||
const metaHead = createMemo(() => {
|
||||
const agent = props.agent
|
||||
|
||||
return [pending() ? i18n.t("ui.message.pending") : "", agent ? agent[0]?.toUpperCase() + agent.slice(1) : "", model()]
|
||||
return [waiting() ? i18n.t("ui.message.pending") : "", agent ? agent[0]?.toUpperCase() + agent.slice(1) : "", model()]
|
||||
.filter(Boolean)
|
||||
.join("\u00A0\u00B7\u00A0")
|
||||
})
|
||||
@@ -353,7 +355,7 @@ export function CurrentUserMessageDisplay(props: {
|
||||
return (
|
||||
<div
|
||||
data-component="user-message"
|
||||
data-pending={pending() ? "true" : undefined}
|
||||
data-pending={waiting() ? "true" : undefined}
|
||||
data-timeline-part-id={props.text ? `${props.message.id}:text:0` : undefined}
|
||||
>
|
||||
<Show
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/simulation",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/stats-app",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/stats-core",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/stats-server",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/theme",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@opencode/tui",
|
||||
"version": "2.0.24",
|
||||
"version": "2.0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -73,6 +73,7 @@ import { SessionTabs } from "./component/session-tabs"
|
||||
import { clampSessionTabsWidth, sessionTabsFitVertically, SESSION_SIDEBAR_WIDTH } from "./ui/layout"
|
||||
import { createPaneResize } from "./ui/pane-resize"
|
||||
import { PaneResizeHandle } from "./ui/pane-resize-handle"
|
||||
import { clickedLink } from "./ui/link"
|
||||
import { ThemeErrorToast } from "./component/theme-error-toast"
|
||||
import { createThemeSource, ThemeProvider, useTheme, useThemes } from "./context/theme"
|
||||
import { Home } from "./routes/home"
|
||||
@@ -1331,9 +1332,11 @@ function App() {
|
||||
evt.preventDefault()
|
||||
evt.stopPropagation()
|
||||
}}
|
||||
onMouseUp={
|
||||
copyOnSelectEnabled() ? (event) => Selection.copyOnSelectRelease(event, renderer, toast, clipboard) : undefined
|
||||
}
|
||||
onMouseUp={(event) => {
|
||||
const url = clickedLink(renderer, event)
|
||||
if (url) return void openUrl(url).catch(toast.error)
|
||||
if (copyOnSelectEnabled()) Selection.copyOnSelectRelease(event, renderer, toast, clipboard)
|
||||
}}
|
||||
>
|
||||
<box
|
||||
flexGrow={1}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { mermanLayoutsStory } from "./merman-layouts"
|
||||
import { sessionTabsStory } from "./session-tabs"
|
||||
import { sessionLocationMissingStory } from "./session-location-missing"
|
||||
import { oneCellSpinnerStory } from "./one-cell-spinner"
|
||||
import { linkClicksStory } from "./link-clicks"
|
||||
|
||||
/**
|
||||
* A story is a full-screen, fixture-driven simulation of a real production component. Stories own
|
||||
@@ -17,7 +18,13 @@ export type Story = {
|
||||
render: (context: Plugin.Context) => JSX.Element
|
||||
}
|
||||
|
||||
const stories: Story[] = [mermanLayoutsStory, sessionTabsStory, sessionLocationMissingStory, oneCellSpinnerStory]
|
||||
const stories: Story[] = [
|
||||
mermanLayoutsStory,
|
||||
sessionTabsStory,
|
||||
sessionLocationMissingStory,
|
||||
oneCellSpinnerStory,
|
||||
linkClicksStory,
|
||||
]
|
||||
|
||||
function Commands(props: { context: Plugin.Context }) {
|
||||
props.context.keymap.layer(() => ({
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import type { Plugin } from "@opencode/plugin/tui"
|
||||
import type { SessionMessageAssistant, SessionMessageAssistantText } from "@opencode/client"
|
||||
import { useTerminalDimensions } from "@opentui/solid"
|
||||
import { createSignal } from "solid-js"
|
||||
import { useConfig } from "../../../config"
|
||||
import { createTimelineAnchors } from "../../../routes/session/anchors"
|
||||
import { TextPart } from "../../../routes/session/message-parts"
|
||||
import { context } from "../../../routes/session/render-context"
|
||||
import { StoryFooter } from "./footer"
|
||||
import type { Story } from "./index"
|
||||
|
||||
const text = `Click, double-click, drag, right-click, or Ctrl/Shift+click the links below.
|
||||
|
||||
**Long bare URL:** https://www.rockauto.com/en/catalog/dodge,2004,ram+1500,4.7l+v8,1432463,brake+&+wheel+hub,brake+pad,1684
|
||||
|
||||
**Named link:** read [the OpenTUI terminal capabilities guide](https://github.com/anomalyco/opentui/blob/main/packages/core/docs/terminal-capabilities.mdx) for details.
|
||||
|
||||
**URL in inline code (not linked):** \`https://github.com/anomalyco/opencode/issues/51727#issuecomment-wrapped-link\`
|
||||
|
||||
**Relative link (not http):** see [link.tsx](packages/tui/src/ui/link.tsx).
|
||||
|
||||
| Issue | Link |
|
||||
| --- | --- |
|
||||
| Wrapped links | https://github.com/anomalyco/opencode/issues/51727 |
|
||||
| Ctrl+click | https://github.com/anomalyco/opencode/issues/44442 |
|
||||
|
||||
- A list item ending in https://example.com/a/very/long/path/that/keeps/going/until/it/wraps/around`
|
||||
|
||||
const part: SessionMessageAssistantText = { type: "text", text }
|
||||
const message: SessionMessageAssistant = {
|
||||
id: "link-clicks",
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { providerID: "fixture", id: "fixture" },
|
||||
time: { created: 0, completed: 1 },
|
||||
content: [part],
|
||||
}
|
||||
|
||||
function LinkClicksStory(props: { context: Plugin.Context }) {
|
||||
const dimensions = useTerminalDimensions()
|
||||
const theme = props.context.theme
|
||||
const config = useConfig()
|
||||
const [narrow, setNarrow] = createSignal(true)
|
||||
const [markdownMode, setMarkdownMode] = createSignal<"source" | "rendered">("rendered")
|
||||
const width = () => (narrow() ? Math.min(48, dimensions().width) : dimensions().width)
|
||||
|
||||
props.context.keymap.layer(() => ({
|
||||
commands: [
|
||||
{
|
||||
bind: "escape",
|
||||
title: "Back to storybook",
|
||||
group: "Storybook",
|
||||
run: () => props.context.ui.router.navigate({ type: "plugin", name: "storybook" }),
|
||||
},
|
||||
{
|
||||
bind: "w",
|
||||
title: "Toggle narrow width",
|
||||
group: "Storybook",
|
||||
run: () => setNarrow((value) => !value),
|
||||
},
|
||||
{
|
||||
bind: "m",
|
||||
title: "Toggle markdown mode",
|
||||
group: "Storybook",
|
||||
run: () => setMarkdownMode((mode) => (mode === "rendered" ? "source" : "rendered")),
|
||||
},
|
||||
],
|
||||
}))
|
||||
|
||||
return (
|
||||
<box
|
||||
width={dimensions().width}
|
||||
height={dimensions().height}
|
||||
flexDirection="column"
|
||||
backgroundColor={theme.background.base}
|
||||
>
|
||||
<context.Provider
|
||||
value={{
|
||||
get width() {
|
||||
return width()
|
||||
},
|
||||
get terminal() {
|
||||
return dimensions()
|
||||
},
|
||||
sessionID: "link-clicks",
|
||||
anchors: createTimelineAnchors(),
|
||||
groupExpanded: () => true,
|
||||
setGroupExpanded: () => {},
|
||||
thinkingMode: () => "show",
|
||||
markdownMode,
|
||||
groupExploration: () => false,
|
||||
diffWrapMode: () => "word",
|
||||
models: () => [],
|
||||
messageIndex: () => undefined,
|
||||
legacyTurns: () => false,
|
||||
config: config.data,
|
||||
mutatePending: async () => false,
|
||||
pendingDelivery: () => undefined,
|
||||
}}
|
||||
>
|
||||
<scrollbox flexGrow={1} minHeight={0}>
|
||||
<box width={width()} paddingTop={1} paddingRight={2}>
|
||||
<TextPart part={part} message={message} last />
|
||||
</box>
|
||||
</scrollbox>
|
||||
</context.Provider>
|
||||
<StoryFooter
|
||||
context={props.context}
|
||||
title="storybook / Link clicks"
|
||||
details={[`${width()} cols`, markdownMode()]}
|
||||
controls={[
|
||||
{ shortcut: "w", label: "narrow/full width" },
|
||||
{ shortcut: "m", label: "rendered/source" },
|
||||
{ shortcut: "esc", label: "back" },
|
||||
]}
|
||||
/>
|
||||
</box>
|
||||
)
|
||||
}
|
||||
|
||||
export const linkClicksStory: Story = {
|
||||
id: "link-clicks",
|
||||
title: "Link clicks",
|
||||
render: (context) => <LinkClicksStory context={context} />,
|
||||
}
|
||||
Loaded 100 of 119 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user