mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-10-27 12:40:32 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15ec9ab0dc | ||
|
|
98c284bb87 | ||
|
|
71d93b3ada | ||
|
|
ef42c46e5a | ||
|
|
fa949a20db | ||
|
|
b8df8e0e54 | ||
|
|
64aa130c66 |
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.53.0"
|
||||
".": "0.54.1"
|
||||
}
|
||||
|
||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,5 +1,22 @@
|
||||
# Changelog
|
||||
|
||||
## [0.54.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.54.0...v0.54.1) (2026-06-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* apply modelOverrides when resolving availableModels allowlist ([#827](https://github.com/agentclientprotocol/claude-agent-acp/issues/827)) ([98c284b](https://github.com/agentclientprotocol/claude-agent-acp/commit/98c284bb871a96710596dfdc2b9ea25d2400f6b2))
|
||||
|
||||
## [0.54.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.53.0...v0.54.0) (2026-06-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add Fast mode session config support ([#828](https://github.com/agentclientprotocol/claude-agent-acp/issues/828)) ([fa949a2](https://github.com/agentclientprotocol/claude-agent-acp/commit/fa949a20db0e33f2d63aebeb37e9fea212d8ee95))
|
||||
* **deps-dev:** bump prettier from 3.9.1 to 3.9.3 in the minor group ([#821](https://github.com/agentclientprotocol/claude-agent-acp/issues/821)) ([b8df8e0](https://github.com/agentclientprotocol/claude-agent-acp/commit/b8df8e0e5460fd782214f4dde488f7476c80c454))
|
||||
* **deps:** bump @anthropic-ai/claude-agent-sdk to 0.3.197 for Sonnet 5 ([#826](https://github.com/agentclientprotocol/claude-agent-acp/issues/826)) ([ef42c46](https://github.com/agentclientprotocol/claude-agent-acp/commit/ef42c46e5aea3bb53f433b9f9dd36a62a9f2df6a))
|
||||
* **deps:** bump fast-uri from 3.1.2 to 3.1.3 ([#822](https://github.com/agentclientprotocol/claude-agent-acp/issues/822)) ([64aa130](https://github.com/agentclientprotocol/claude-agent-acp/commit/64aa130c66c299f9835193796ba372b3ed40e7c1))
|
||||
|
||||
## [0.53.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.52.0...v0.53.0) (2026-06-29)
|
||||
|
||||
|
||||
|
||||
228
package-lock.json
generated
228
package-lock.json
generated
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"name": "@agentclientprotocol/claude-agent-acp",
|
||||
"version": "0.53.0",
|
||||
"version": "0.54.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@agentclientprotocol/claude-agent-acp",
|
||||
"version": "0.53.0",
|
||||
"version": "0.54.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "1.0.0",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.195",
|
||||
"@agentclientprotocol/sdk": "1.1.0",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.197",
|
||||
"zod": "^3.25.0 || ^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"claude-agent-acp": "dist/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anthropic-ai/sdk": "0.106.0",
|
||||
"@anthropic-ai/sdk": "0.108.0",
|
||||
"@eslint/js": "10.0.1",
|
||||
"@tsconfig/node22": "22.0.5",
|
||||
"@types/node": "26.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "8.62.0",
|
||||
"@typescript-eslint/parser": "8.62.0",
|
||||
"@typescript-eslint/eslint-plugin": "8.62.1",
|
||||
"@typescript-eslint/parser": "8.62.1",
|
||||
"eslint": "10.6.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"globals": "17.7.0",
|
||||
"prettier": "3.9.1",
|
||||
"prettier": "3.9.4",
|
||||
"ts-node": "10.9.2",
|
||||
"typescript": "6.0.3",
|
||||
"vitest": "4.1.9"
|
||||
@@ -36,31 +36,31 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@agentclientprotocol/sdk": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-1.0.0.tgz",
|
||||
"integrity": "sha512-5FHgLbLZhSAq9F+9SU7AOCXTDzaw/IYx/AvMjrZDs/YFZ9ZPxkdn9ti3fSkny0huHfj2hrqF6pqdns9gN5/Fig==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-1.1.0.tgz",
|
||||
"integrity": "sha512-NT2KqphUJ3w6EksUL51ZhJgIYgq/ZLGcBPkyMKgRSO5PMVwe9DnKKX+Htnvk6KHh6dUuh34UHK4gKp+4te1Mdg==",
|
||||
"license": "Apache-2.0",
|
||||
"peerDependencies": {
|
||||
"zod": "^3.25.0 || ^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk/-/claude-agent-sdk-0.3.195.tgz",
|
||||
"integrity": "sha512-FVmXu9pvOMbuBKWrF8YsYQdQ/upOpv5rS8lFAnFO5jbyXT/2hN7kEPd2vd2GJpaMvNcO/KptyQUK5AxjjTz3+w==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk/-/claude-agent-sdk-0.3.197.tgz",
|
||||
"integrity": "sha512-XNIi8W1tb+QfMkcK+5kepOC6BsxG8wtupd72H+pIPzIJypVQhHy7FoX+KBMtTRYwtl+5dsjKyABhjWXebeUilw==",
|
||||
"license": "SEE LICENSE IN README.md",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.195",
|
||||
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.195"
|
||||
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.197",
|
||||
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.197"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@anthropic-ai/sdk": ">=0.93.0",
|
||||
@@ -69,9 +69,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-darwin-arm64": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-arm64/-/claude-agent-sdk-darwin-arm64-0.3.195.tgz",
|
||||
"integrity": "sha512-WIMM/8HRCLsTDHFTIwQvvE8WCA/oaMJtdQxsP7iNyfzIGwXbuOyU95V8vYIhZfaO2yaSpbBRncunq4CtR5H4ng==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-arm64/-/claude-agent-sdk-darwin-arm64-0.3.197.tgz",
|
||||
"integrity": "sha512-jC6WvH5Hr6APTfbMjo4nC6LlyMMqbpCMwiHXIw7/AsQXIHQhZ+cRRMesQlV6UFI1l3O53gLZHzsG9cXwfrPHKw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -82,9 +82,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-darwin-x64": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-x64/-/claude-agent-sdk-darwin-x64-0.3.195.tgz",
|
||||
"integrity": "sha512-RY7DB+4LXosE0MJ+XELmakfPrDN1YX4lkk9CTDm28jGCVcESRz9kAEqbyaiC48dZcmN9V1NCLutzINGdcr1TBg==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-x64/-/claude-agent-sdk-darwin-x64-0.3.197.tgz",
|
||||
"integrity": "sha512-ZQNvGkMrTyatBlHTIQ4w2i2aLBuvq355UP/FDLnVXIH8l23RsL1x/0w9P+dqB7EmY9OZi/cPxSrpskpo+dZWLA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -95,9 +95,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-linux-arm64": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64/-/claude-agent-sdk-linux-arm64-0.3.195.tgz",
|
||||
"integrity": "sha512-JuIq5Fnz/F1snl0aqi1gcuRZqPWoPNrL9dJ0DuievCxKkO8hnEz/Mmn5Zos7x1X8HE//ZnEvmQXoEQEZXonJew==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64/-/claude-agent-sdk-linux-arm64-0.3.197.tgz",
|
||||
"integrity": "sha512-pWhQgCtAft4EGM4Zn24HRad1a/k2u6oA+2uM/KCdjehfKtooDiHfMNd1yzXY/n9AEBWP0RHB2Vz3mJ30X2pVAg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -111,9 +111,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-linux-arm64-musl": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64-musl/-/claude-agent-sdk-linux-arm64-musl-0.3.195.tgz",
|
||||
"integrity": "sha512-ZmyBA/AFzhgutcxb7dbhCm6GTjJytwNYXTxJoKE2B3A409WCYccjMqeji6vCMNxyyfylglGo5D8dVMIxW9aoug==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64-musl/-/claude-agent-sdk-linux-arm64-musl-0.3.197.tgz",
|
||||
"integrity": "sha512-VuIGXsLGK/aqSQ0tTBqqPVNzjefWS5SWnK8mlYyQitT4s5UDzHXJm0UZBTGxRtlcS0e2+QAHKwbGBCq1ZKSXjg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -127,9 +127,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-linux-x64": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64/-/claude-agent-sdk-linux-x64-0.3.195.tgz",
|
||||
"integrity": "sha512-s1lNi1cL93luoqsItH+fNO4KpIhdkvnVhWGGQUQ/8ftwa2gfmcIQnOg1hG8Ks+KzeD3UUQ8L9YEVHVADnFI/9A==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64/-/claude-agent-sdk-linux-x64-0.3.197.tgz",
|
||||
"integrity": "sha512-AUccrbdcv4Hy/GteP/gYLjG/zDP+fe2BFtDMctEfRFVz40DazYDcOyW1+nIgSTQtxf5jSTAVVf3cNuXB2CZwlw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -143,9 +143,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-linux-x64-musl": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64-musl/-/claude-agent-sdk-linux-x64-musl-0.3.195.tgz",
|
||||
"integrity": "sha512-nf8Q/LauB+ZOC6QDjxNhbsvwUtYjKYnaWJLTYFwhkmsLujePnety1AtT/1ubaUoq5AM1j297DhMlYTasa79OUA==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64-musl/-/claude-agent-sdk-linux-x64-musl-0.3.197.tgz",
|
||||
"integrity": "sha512-3Tuy7XhD4UIKE4A4RPmKJcbL7Q/3dcB1hEWQt2lKP7c/DlixeEv+tRzvpnFZKhFX2hy0tkBk3QjkozSAacMC/w==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -159,9 +159,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-win32-arm64": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-arm64/-/claude-agent-sdk-win32-arm64-0.3.195.tgz",
|
||||
"integrity": "sha512-hbkDE+xPIZzRWm+D+BKrH9uJH6USIZdDIlsyrIlGi3JFHoieYoA1vdUNyldSS9+F3ZqQtfPjr2Qy08IVB6akYA==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-arm64/-/claude-agent-sdk-win32-arm64-0.3.197.tgz",
|
||||
"integrity": "sha512-Wx8uiAKBenDuL8lWQmrqnX5ppljaH5unQ9cKiCz2/9Kgf09dgnrwbX8n/FhndCZR8PmYw539eWwYVrSVc/bl6w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -172,9 +172,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk-win32-x64": {
|
||||
"version": "0.3.195",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-x64/-/claude-agent-sdk-win32-x64-0.3.195.tgz",
|
||||
"integrity": "sha512-av0piEB3X1Dzhpr8A+DqHVZ9y8s1jpn8enzwX0TKKUPBn5IqLTWC7wD6v66aoUgu4f+g4ThZirmDZA6shyPEZQ==",
|
||||
"version": "0.3.197",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-x64/-/claude-agent-sdk-win32-x64-0.3.197.tgz",
|
||||
"integrity": "sha512-ZXJO/VvR3SI4G0gwthWeFXWdHB5RXPu3rtfGRcKZ/YgtDeW17rQ+LZIJTk2ywzbLb8EvlghR5JPgn293hC179Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -185,9 +185,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@anthropic-ai/sdk": {
|
||||
"version": "0.106.0",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.106.0.tgz",
|
||||
"integrity": "sha512-ufwVvYNDBj2dzOGupBCTaNzBLxqcTnGOzI4z8Wouxlt+mT3J3HuOmatgCy1VmwCHOUueqZ41ERhm0O99OUcbWA==",
|
||||
"version": "0.108.0",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.108.0.tgz",
|
||||
"integrity": "sha512-XBnl7Nszpbzg0aLnOCmdBi0bOU5goAsQ/L+NPNiuUPowDj8Mbzx0vlIIc1M79BjIvmw5nUM5G3jbrCBStT/0fQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"json-schema-to-ts": "^3.1.1",
|
||||
@@ -944,17 +944,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.62.0.tgz",
|
||||
"integrity": "sha512-o+mpz7EYiMzXoySXiKmzlabIvTVqUuK5yLrAedRPRDA0IpPFMUV1IXt6OqljIxX/kumN6EjUYp41Hqelh6p/Dw==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.62.1.tgz",
|
||||
"integrity": "sha512-4EQM77WgVNxj7OkL/5b/D/xZsw00G577+UriYTC7JF5opcF3T2AuoeY7ueLaZgSVjSgCS6yOAJB5bRGLPSJUzA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.12.2",
|
||||
"@typescript-eslint/scope-manager": "8.62.0",
|
||||
"@typescript-eslint/type-utils": "8.62.0",
|
||||
"@typescript-eslint/utils": "8.62.0",
|
||||
"@typescript-eslint/visitor-keys": "8.62.0",
|
||||
"@typescript-eslint/scope-manager": "8.62.1",
|
||||
"@typescript-eslint/type-utils": "8.62.1",
|
||||
"@typescript-eslint/utils": "8.62.1",
|
||||
"@typescript-eslint/visitor-keys": "8.62.1",
|
||||
"ignore": "^7.0.5",
|
||||
"natural-compare": "^1.4.0",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
@@ -967,22 +967,22 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^8.62.0",
|
||||
"@typescript-eslint/parser": "^8.62.1",
|
||||
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
||||
"typescript": ">=4.8.4 <6.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.62.0.tgz",
|
||||
"integrity": "sha512-dzHeT2gySzZtLDsuqxU9AkYgIsQoHAHtRBpOqM+Ofzx1Bwrd2RcCjQJ+6iQbsHOIR6NS33bF2W1k3blN1zLDrA==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.62.1.tgz",
|
||||
"integrity": "sha512-sPhE4iHuJDSvoAiec+Ro8JyXw8f0ql13HFR82P99nCm9GwTEKG0KYLvDe6REk8BCXuit6vJAv/Yxg5ABaNS2rA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.62.0",
|
||||
"@typescript-eslint/types": "8.62.0",
|
||||
"@typescript-eslint/typescript-estree": "8.62.0",
|
||||
"@typescript-eslint/visitor-keys": "8.62.0",
|
||||
"@typescript-eslint/scope-manager": "8.62.1",
|
||||
"@typescript-eslint/types": "8.62.1",
|
||||
"@typescript-eslint/typescript-estree": "8.62.1",
|
||||
"@typescript-eslint/visitor-keys": "8.62.1",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -998,14 +998,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.62.0.tgz",
|
||||
"integrity": "sha512-wexnCqiTg7BOGtbLDftYpRWlmLq4xfoMd7BKFR6Y75sZS3QmRKLdN3yWLhmIYgqMmP/OXWpj3H8odkb5nGURCQ==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.62.1.tgz",
|
||||
"integrity": "sha512-yQ3RgY5RkSBpsNS1Bx/JQEcA24FOSdfGktoyprAr5u18390UQdtVcfnEv4nIrIshNnavlVyZBKxQwT1fIAE6cg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/tsconfig-utils": "^8.62.0",
|
||||
"@typescript-eslint/types": "^8.62.0",
|
||||
"@typescript-eslint/tsconfig-utils": "^8.62.1",
|
||||
"@typescript-eslint/types": "^8.62.1",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1020,14 +1020,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.62.0.tgz",
|
||||
"integrity": "sha512-1lX38kNxXIRb8mEc3lbq5mdHq1Pf2+U0nFU65KfT18mtPxxl0fvjuEE92mHuXPuCtElJhOrddOpyMlM3Z0umEA==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.62.1.tgz",
|
||||
"integrity": "sha512-r4d249KbQ1SFdpeStvob8Ih6aPPIzfqllPVOtvhve6ZcpuVcYo5/7zUWckKpHE7StASX4kTKZTLf0WQm/wPkcg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.62.0",
|
||||
"@typescript-eslint/visitor-keys": "8.62.0"
|
||||
"@typescript-eslint/types": "8.62.1",
|
||||
"@typescript-eslint/visitor-keys": "8.62.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1038,9 +1038,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.62.0.tgz",
|
||||
"integrity": "sha512-y2GAdB6ykaXUvuspbYnizQc4oDDz0Tz/Yc7iWrXf9mx8vm/L/0vLHCe0tS2boG96Zy+DivnVDQ9ZUEWoHqqx1g==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.62.1.tgz",
|
||||
"integrity": "sha512-xadytJqX9vJVQ2fdQjkcIVigwaOJNWkpjdLt6cEQ+xPnrI1fkp+/jZE/I97k9KUjqtpd25i0HeyZf3T6dutv2g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1055,15 +1055,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.62.0.tgz",
|
||||
"integrity": "sha512-+g5O3j0w2ldzC86Pv6fvbO/xhAonbJFIdf/MKQ1d30gndlsVzUOE83ldfSE15Qrl9fhFjK6AovHs5Wpp6vx86w==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.62.1.tgz",
|
||||
"integrity": "sha512-aXM5xlqXiTxPibXB93cLAURfT3rlizf7uMXISCXy66Isr/9hISJx3yDsKl0L7lKa51b8JpFuNKby0/O0pEm9jg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.62.0",
|
||||
"@typescript-eslint/typescript-estree": "8.62.0",
|
||||
"@typescript-eslint/utils": "8.62.0",
|
||||
"@typescript-eslint/types": "8.62.1",
|
||||
"@typescript-eslint/typescript-estree": "8.62.1",
|
||||
"@typescript-eslint/utils": "8.62.1",
|
||||
"debug": "^4.4.3",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
},
|
||||
@@ -1080,9 +1080,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.62.0.tgz",
|
||||
"integrity": "sha512-KvAclkktORPvM54TgLgA4z9HIV1M8zOgw9ZVNXl9f/8dLYfXYX1wkMXP7qmabpijQRV5bHJLOmoyGQbLMaUYeg==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.62.1.tgz",
|
||||
"integrity": "sha512-ooCzJFaf+Hg+uG6fA3NRFGuFjlfNlDhBthbv4ZPU/0elCAFUfnyXUvf/WOpHz/jYwSmvU2GkR2LtyUfy1AxZ1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1094,16 +1094,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.62.0.tgz",
|
||||
"integrity": "sha512-+hVbNxtW64pIcZWDPGbyaKF7vp2IBTVY5ma1blwwksrjdsbdqqEKvJWMGbBofei4F6Dovx1M0RJgoFeNu2279A==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.62.1.tgz",
|
||||
"integrity": "sha512-xMcW9oP9u7fAMXYs9A65CVmtLQe2r//oXINHfi8HV+oiqhih17sbLdhXr4540YWlgpDKQdY854OL5ZrdCiQsAA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.62.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.62.0",
|
||||
"@typescript-eslint/types": "8.62.0",
|
||||
"@typescript-eslint/visitor-keys": "8.62.0",
|
||||
"@typescript-eslint/project-service": "8.62.1",
|
||||
"@typescript-eslint/tsconfig-utils": "8.62.1",
|
||||
"@typescript-eslint/types": "8.62.1",
|
||||
"@typescript-eslint/visitor-keys": "8.62.1",
|
||||
"debug": "^4.4.3",
|
||||
"minimatch": "^10.2.2",
|
||||
"semver": "^7.7.3",
|
||||
@@ -1122,16 +1122,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.62.0.tgz",
|
||||
"integrity": "sha512-82r66fi9zYwZ+mTq3vKgwjbZ1PVk/DJzrXFLpG6RnBbdvH8TEGVHIs9H4d2drhkOzf0syZuD/OZvvlu6GDbP4g==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.62.1.tgz",
|
||||
"integrity": "sha512-sHtbPfuKNZCG+ih8SyjjucqRntSVmp8XgL5u6o9mAhiSn8ds5o/M/XdM0abweme2Tln3szOstOrZ9OXitvPh0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.9.1",
|
||||
"@typescript-eslint/scope-manager": "8.62.0",
|
||||
"@typescript-eslint/types": "8.62.0",
|
||||
"@typescript-eslint/typescript-estree": "8.62.0"
|
||||
"@typescript-eslint/scope-manager": "8.62.1",
|
||||
"@typescript-eslint/types": "8.62.1",
|
||||
"@typescript-eslint/typescript-estree": "8.62.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1146,13 +1146,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.62.0.tgz",
|
||||
"integrity": "sha512-CY3uyFSRbcQv3nnSv8S0+lDftMVz6P963PoRlxrV7ew/Md564g9ut60PYzdLM5qW4jFn93GBF+Soi90ISAN+GQ==",
|
||||
"version": "8.62.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.62.1.tgz",
|
||||
"integrity": "sha512-4g3BLxfdTMy8iZG0MaBkadnlRrCJ74cQiFbyEVMrkwIoqdyaXXQM22cotDvrl4x28wgIZ9rEJRoM+mmhSJpJ1g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.62.0",
|
||||
"@typescript-eslint/types": "8.62.1",
|
||||
"eslint-visitor-keys": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2114,9 +2114,9 @@
|
||||
"license": "Unlicense"
|
||||
},
|
||||
"node_modules/fast-uri": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",
|
||||
"integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==",
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz",
|
||||
"integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
@@ -3227,9 +3227,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.9.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.1.tgz",
|
||||
"integrity": "sha512-ppiDo2CSwexck1eyZUwJHg/N3nf1+6IRCv7W/VJ5vaLnVCmB7+3CdRfMwoCHBBX6xTrREDTksZ4OZl5SSf4zXA==",
|
||||
"version": "3.9.4",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.4.tgz",
|
||||
"integrity": "sha512-yWG/o/4oJfo036EKAfK6ACAoDOfHeRHx4tuxkfBZiauURiaSmYwlpOr5LQqKtIkRD2z1PLteme2WoxEnj4tHTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
@@ -3826,16 +3826,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-8.1.0.tgz",
|
||||
"integrity": "sha512-BuJcQK/56NQTWDGn4ABea3q4SSBdNPWwNZKTkkUpcMPnLoquSYH8llRtSUIgoL1KSCpHt5eghLShn50mH36y7Q==",
|
||||
"version": "8.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-8.1.2.tgz",
|
||||
"integrity": "sha512-6YYPbRXTxx6bRXmOn7XdnQAy5DQNHhDgtjhDHI13oe4pY93kkcdGJWxpGwOm++/Wh0QpQhDrpIoVMrmrsI5AGQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lightningcss": "^1.32.0",
|
||||
"picomatch": "^4.0.4",
|
||||
"postcss": "^8.5.15",
|
||||
"rolldown": "~1.1.2",
|
||||
"postcss": "^8.5.16",
|
||||
"rolldown": "~1.1.3",
|
||||
"tinyglobby": "^0.2.17"
|
||||
},
|
||||
"bin": {
|
||||
|
||||
14
package.json
14
package.json
@@ -3,7 +3,7 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"version": "0.53.0",
|
||||
"version": "0.54.1",
|
||||
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
||||
"main": "dist/lib.js",
|
||||
"types": "dist/lib.d.ts",
|
||||
@@ -63,21 +63,21 @@
|
||||
"node": ">=22"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "1.0.0",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.195",
|
||||
"@agentclientprotocol/sdk": "1.1.0",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.197",
|
||||
"zod": "^3.25.0 || ^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anthropic-ai/sdk": "0.106.0",
|
||||
"@anthropic-ai/sdk": "0.108.0",
|
||||
"@eslint/js": "10.0.1",
|
||||
"@tsconfig/node22": "22.0.5",
|
||||
"@types/node": "26.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "8.62.0",
|
||||
"@typescript-eslint/parser": "8.62.0",
|
||||
"@typescript-eslint/eslint-plugin": "8.62.1",
|
||||
"@typescript-eslint/parser": "8.62.1",
|
||||
"eslint": "10.6.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"globals": "17.7.0",
|
||||
"prettier": "3.9.1",
|
||||
"prettier": "3.9.4",
|
||||
"ts-node": "10.9.2",
|
||||
"typescript": "6.0.3",
|
||||
"vitest": "4.1.9"
|
||||
|
||||
317
src/acp-agent.ts
317
src/acp-agent.ts
@@ -51,6 +51,7 @@ import {
|
||||
AgentInfo,
|
||||
CanUseTool,
|
||||
deleteSession,
|
||||
FastModeState,
|
||||
getSessionInfo,
|
||||
getSessionMessages,
|
||||
listSessions,
|
||||
@@ -246,6 +247,10 @@ type Session = {
|
||||
/** The currently selected main-thread agent name, or "default" for the
|
||||
* standard Claude Code agent (no `agent` flag applied). */
|
||||
currentAgent: string;
|
||||
/** Whether Fast mode is currently enabled for this session. Tracked as the
|
||||
* user's intent so it persists across model switches; the Fast mode config
|
||||
* option is only surfaced while the selected model supports it. */
|
||||
fastModeEnabled: boolean;
|
||||
abortController: AbortController;
|
||||
/** Signal the consumer races `query.next()` against. Aborted by cancel()
|
||||
* (after a grace period) to force the active turn to settle "cancelled" when
|
||||
@@ -1348,6 +1353,10 @@ export class ClaudeAcpAgent {
|
||||
case "system":
|
||||
switch (message.subtype) {
|
||||
case "init":
|
||||
// A fresh `system`/init (e.g. after reinitialize) can carry an
|
||||
// updated Fast mode state; reconcile it with what we seeded at
|
||||
// session creation.
|
||||
await this.syncFastModeState(message.session_id, session, message.fast_mode_state);
|
||||
break;
|
||||
case "status": {
|
||||
if (message.status === "compacting") {
|
||||
@@ -1620,6 +1629,14 @@ export class ClaudeAcpAgent {
|
||||
// slash-command output forwarding) but their cost is real.
|
||||
const isTaskNotification = message.origin?.kind === "task-notification";
|
||||
|
||||
// Reconcile the Fast mode toggle with the SDK's reported state.
|
||||
// Gated to user-driven turns like every other side effect below; a
|
||||
// background followup's state lands on the next user turn's result.
|
||||
// Runs even when the turn errors or was cancelled.
|
||||
if (!isTaskNotification) {
|
||||
await this.syncFastModeState(params.sessionId, session, message.fast_mode_state);
|
||||
}
|
||||
|
||||
// A user-turn result needs an active turn so its stop reason is
|
||||
// attributed and the turn settles at idle. Local-only commands carry
|
||||
// no user-message echo to promote them, so do it here from the head.
|
||||
@@ -2383,7 +2400,7 @@ export class ClaudeAcpAgent {
|
||||
}
|
||||
|
||||
await this.applySessionMode(params.sessionId, params.modeId);
|
||||
await this.updateConfigOption(params.sessionId, "mode", params.modeId);
|
||||
await this.updateConfigOption(params.sessionId, MODE_CONFIG_ID, params.modeId);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -2401,15 +2418,24 @@ export class ClaudeAcpAgent {
|
||||
if (session.queryClosed) {
|
||||
throw RequestError.internalError(undefined, SESSION_ENDED_MESSAGE);
|
||||
}
|
||||
if (typeof params.value !== "string") {
|
||||
throw new Error(`Invalid value for config option ${params.configId}: ${params.value}`);
|
||||
}
|
||||
|
||||
const option = session.configOptions.find((o) => o.id === params.configId);
|
||||
if (!option) {
|
||||
throw new Error(`Unknown config option: ${params.configId}`);
|
||||
}
|
||||
|
||||
// Fast mode carries a boolean value (for Clients that opted into boolean
|
||||
// config options) or the "on"/"off" select fallback, so it bypasses the
|
||||
// string-only validation the select-style options below rely on.
|
||||
if (params.configId === FAST_MODE_CONFIG_ID) {
|
||||
await this.applyFastMode(session, resolveFastModeEnabled(params));
|
||||
return { configOptions: session.configOptions };
|
||||
}
|
||||
|
||||
if (typeof params.value !== "string") {
|
||||
throw new Error(`Invalid value for config option ${params.configId}: ${params.value}`);
|
||||
}
|
||||
|
||||
const allValues =
|
||||
"options" in option && Array.isArray(option.options)
|
||||
? option.options.flatMap((o) => ("options" in o ? o.options : [o]))
|
||||
@@ -2419,7 +2445,7 @@ export class ClaudeAcpAgent {
|
||||
// For model options, fall back to resolveModelPreference when the exact
|
||||
// value doesn't match. This lets callers use human-friendly aliases like
|
||||
// "opus" or "sonnet" instead of full model IDs like "claude-opus-4-6".
|
||||
if (!validValue && params.configId === "model") {
|
||||
if (!validValue && params.configId === MODEL_CONFIG_ID) {
|
||||
const modelInfos: ModelInfo[] = allValues.map((o) => ({
|
||||
value: o.value,
|
||||
displayName: o.name,
|
||||
@@ -2439,7 +2465,7 @@ export class ClaudeAcpAgent {
|
||||
// model ID rather than the caller-supplied alias.
|
||||
const resolvedValue = validValue.value;
|
||||
|
||||
if (params.configId === "mode") {
|
||||
if (params.configId === MODE_CONFIG_ID) {
|
||||
await this.applySessionMode(params.sessionId, resolvedValue);
|
||||
await this.client.sessionUpdate({
|
||||
sessionId: params.sessionId,
|
||||
@@ -2448,7 +2474,7 @@ export class ClaudeAcpAgent {
|
||||
currentModeId: resolvedValue,
|
||||
},
|
||||
});
|
||||
} else if (params.configId === "model") {
|
||||
} else if (params.configId === MODEL_CONFIG_ID) {
|
||||
await this.sessions[params.sessionId].query.setModel(resolvedValue);
|
||||
}
|
||||
// Effort SDK sync is handled inside applyConfigOptionValue so that direct
|
||||
@@ -2706,7 +2732,7 @@ export class ClaudeAcpAgent {
|
||||
currentModeId: selectedMode,
|
||||
},
|
||||
});
|
||||
await this.updateConfigOption(sessionId, "mode", selectedMode);
|
||||
await this.updateConfigOption(sessionId, MODE_CONFIG_ID, selectedMode);
|
||||
|
||||
return {
|
||||
behavior: "allow",
|
||||
@@ -2906,12 +2932,12 @@ export class ClaudeAcpAgent {
|
||||
configId: string,
|
||||
value: string,
|
||||
): Promise<void> {
|
||||
if (configId === "mode") {
|
||||
if (configId === MODE_CONFIG_ID) {
|
||||
session.modes = { ...session.modes, currentModeId: value };
|
||||
session.configOptions = session.configOptions.map((o) =>
|
||||
o.id === configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o,
|
||||
);
|
||||
} else if (configId === "model") {
|
||||
} else if (configId === MODEL_CONFIG_ID) {
|
||||
// `ModelInfo.supportsAutoMode` is the canonical SDK signal for clamping
|
||||
// modes below; its `displayName`/`description` also let us infer the
|
||||
// context window for semantic aliases (e.g. `default`) whose ID alone
|
||||
@@ -2961,7 +2987,7 @@ export class ClaudeAcpAgent {
|
||||
}
|
||||
|
||||
// Rebuild config options since effort levels depend on the selected model
|
||||
const effortOpt = session.configOptions.find((o) => o.id === "effort");
|
||||
const effortOpt = session.configOptions.find((o) => o.id === EFFORT_CONFIG_ID);
|
||||
const currentEffort =
|
||||
typeof effortOpt?.currentValue === "string" ? effortOpt.currentValue : undefined;
|
||||
session.configOptions = buildConfigOptions(
|
||||
@@ -2971,10 +2997,18 @@ export class ClaudeAcpAgent {
|
||||
currentEffort,
|
||||
session.agents,
|
||||
session.currentAgent,
|
||||
{
|
||||
// The toggle follows the newly selected model: it disappears when the
|
||||
// model lacks fast support and reappears (with the retained user
|
||||
// intent) when a supporting model is selected again.
|
||||
supported: newModelInfo?.supportsFastMode ?? false,
|
||||
enabled: session.fastModeEnabled,
|
||||
useBooleanOption: clientSupportsBooleanConfigOptions(this.clientCapabilities),
|
||||
},
|
||||
);
|
||||
|
||||
// Sync effort with the SDK if it changed after the model switch
|
||||
const newEffortOpt = session.configOptions.find((o) => o.id === "effort");
|
||||
const newEffortOpt = session.configOptions.find((o) => o.id === EFFORT_CONFIG_ID);
|
||||
const newEffort =
|
||||
typeof newEffortOpt?.currentValue === "string" ? newEffortOpt.currentValue : undefined;
|
||||
if (newEffort !== currentEffort) {
|
||||
@@ -2998,7 +3032,7 @@ export class ClaudeAcpAgent {
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (configId === "agent") {
|
||||
} else if (configId === AGENT_CONFIG_ID) {
|
||||
// Live agent switch — no subprocess restart needed. Apply the SDK flag
|
||||
// first so a rejected control request leaves both `currentAgent` and the
|
||||
// config option untouched (no UI/SDK desync). Passing `null` clears the
|
||||
@@ -3015,7 +3049,7 @@ export class ClaudeAcpAgent {
|
||||
session.configOptions = session.configOptions.map((o) =>
|
||||
o.id === configId && typeof o.currentValue === "string" ? { ...o, currentValue: value } : o,
|
||||
);
|
||||
if (configId === "effort") {
|
||||
if (configId === EFFORT_CONFIG_ID) {
|
||||
await session.query.applyFlagSettings({
|
||||
effortLevel: toSdkEffortLevel(value),
|
||||
});
|
||||
@@ -3023,6 +3057,77 @@ export class ClaudeAcpAgent {
|
||||
}
|
||||
}
|
||||
|
||||
/** Replace the Fast mode option in `session.configOptions` so it reflects
|
||||
* `enabled` (and the client's current boolean-capability). A no-op when the
|
||||
* option isn't present, so callers must confirm the current model surfaces
|
||||
* it first. */
|
||||
private refreshFastModeOption(session: Session, enabled: boolean): void {
|
||||
const refreshed = createFastModeConfigOption(
|
||||
enabled,
|
||||
clientSupportsBooleanConfigOptions(this.clientCapabilities),
|
||||
);
|
||||
session.configOptions = session.configOptions.map((o) =>
|
||||
o.id === FAST_MODE_CONFIG_ID ? refreshed : o,
|
||||
);
|
||||
}
|
||||
|
||||
/** Toggle Fast mode for a session: push the SDK flag, record the user's
|
||||
* intent, and refresh the Fast mode config option in place. Only reached
|
||||
* once the option exists (i.e. the current model supports fast mode), so the
|
||||
* option is guaranteed to be present in `configOptions`. */
|
||||
private async applyFastMode(session: Session, enabled: boolean): Promise<void> {
|
||||
// Apply the SDK flag first so a rejected control request leaves both the
|
||||
// session state and the config option untouched (no UI/SDK desync).
|
||||
await session.query.applyFlagSettings({ fastMode: enabled });
|
||||
session.fastModeEnabled = enabled;
|
||||
this.refreshFastModeOption(session, enabled);
|
||||
}
|
||||
|
||||
/** Reconcile the session's Fast mode toggle with an SDK-reported
|
||||
* `fast_mode_state` (delivered on `system`/init and on user-turn `result`s).
|
||||
* The SDK can flip fast mode independently of the user — e.g. back to `on`
|
||||
* once a rate-limit `cooldown` clears — so we mirror definitive on/off
|
||||
* changes into the config option and notify the client.
|
||||
*
|
||||
* Guards, in order:
|
||||
* - absent state: nothing to reconcile.
|
||||
* - no Fast mode option: the current model doesn't support fast mode, so the
|
||||
* reported state reflects capability, not the user's intent. Leave the
|
||||
* retained setting untouched so it's correct when a supporting model is
|
||||
* reselected (the source of the earlier intent-clobber bug was mutating it
|
||||
* here).
|
||||
* - `cooldown`: a transient suspension of an already-enabled fast mode.
|
||||
* Leave the toggle as-is rather than flapping it — and never let a stray
|
||||
* cooldown spuriously enable a toggle the user has off. */
|
||||
private async syncFastModeState(
|
||||
sessionId: string,
|
||||
session: Session,
|
||||
state: FastModeState | undefined,
|
||||
): Promise<void> {
|
||||
if (state === undefined) {
|
||||
return;
|
||||
}
|
||||
if (!session.configOptions.some((o) => o.id === FAST_MODE_CONFIG_ID)) {
|
||||
return;
|
||||
}
|
||||
if (state === "cooldown") {
|
||||
return;
|
||||
}
|
||||
const enabled = state === "on";
|
||||
if (enabled === session.fastModeEnabled) {
|
||||
return;
|
||||
}
|
||||
session.fastModeEnabled = enabled;
|
||||
this.refreshFastModeOption(session, enabled);
|
||||
await this.client.sessionUpdate({
|
||||
sessionId,
|
||||
update: {
|
||||
sessionUpdate: "config_option_update",
|
||||
configOptions: session.configOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private async getOrCreateSession(params: {
|
||||
sessionId: string;
|
||||
cwd: string;
|
||||
@@ -3274,7 +3379,7 @@ export class ClaudeAcpAgent {
|
||||
currentModeId: "plan",
|
||||
},
|
||||
});
|
||||
await this.updateConfigOption(sessionId, "mode", "plan");
|
||||
await this.updateConfigOption(sessionId, MODE_CONFIG_ID, "plan");
|
||||
},
|
||||
}),
|
||||
],
|
||||
@@ -3381,8 +3486,13 @@ export class ClaudeAcpAgent {
|
||||
// configOptions, the current-model resolver, and the stored modelInfos
|
||||
// consistent with what the user configured.
|
||||
const settingsAvailableModels = settingsManager.getSettings().availableModels;
|
||||
const settingsModelOverrides = settingsManager.getSettings().modelOverrides;
|
||||
const allowedModels = Array.isArray(settingsAvailableModels)
|
||||
? applyAvailableModelsAllowlist(initializationResult.models, settingsAvailableModels)
|
||||
? applyAvailableModelsAllowlist(
|
||||
initializationResult.models,
|
||||
settingsAvailableModels,
|
||||
settingsModelOverrides,
|
||||
)
|
||||
: initializationResult.models;
|
||||
|
||||
const models = await getAvailableModels(
|
||||
@@ -3445,6 +3555,19 @@ export class ClaudeAcpAgent {
|
||||
? requestedAgent
|
||||
: DEFAULT_AGENT_ID;
|
||||
|
||||
// Seed Fast mode from the SDK's reported state so the UI reflects reality
|
||||
// (the CLI may start a session with fast mode already on, or force it off
|
||||
// when `fastModePerSessionOptIn` is set). The toggle is only surfaced while
|
||||
// the resolved model advertises `supportsFastMode`.
|
||||
const fastModeEnabled =
|
||||
initializationResult.fast_mode_state !== undefined &&
|
||||
fastModeStateEnabled(initializationResult.fast_mode_state);
|
||||
const fastMode: FastModeOptionState = {
|
||||
supported: currentModelInfo?.supportsFastMode ?? false,
|
||||
enabled: fastModeEnabled,
|
||||
useBooleanOption: clientSupportsBooleanConfigOptions(this.clientCapabilities),
|
||||
};
|
||||
|
||||
const configOptions = buildConfigOptions(
|
||||
modes,
|
||||
models,
|
||||
@@ -3452,10 +3575,11 @@ export class ClaudeAcpAgent {
|
||||
settingsManager.getSettings().effortLevel,
|
||||
agents,
|
||||
currentAgent,
|
||||
fastMode,
|
||||
);
|
||||
|
||||
// Apply the initial effort level to the SDK so it matches the UI default
|
||||
const initialEffort = configOptions.find((o) => o.id === "effort");
|
||||
const initialEffort = configOptions.find((o) => o.id === EFFORT_CONFIG_ID);
|
||||
if (
|
||||
initialEffort &&
|
||||
typeof initialEffort.currentValue === "string" &&
|
||||
@@ -3484,6 +3608,7 @@ export class ClaudeAcpAgent {
|
||||
configOptions,
|
||||
agents,
|
||||
currentAgent,
|
||||
fastModeEnabled,
|
||||
abortController,
|
||||
emitRawSDKMessages: sessionMeta?.claudeCode?.emitRawSDKMessages ?? false,
|
||||
contextWindowSize:
|
||||
@@ -3704,6 +3829,96 @@ export async function discoverCustomAgents(q: Query): Promise<AgentInfo[]> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Stable ids for the session config options surfaced via `configOptions`.
|
||||
* Centralized so the option declarations in `buildConfigOptions` and the
|
||||
* handlers in `setSessionConfigOption`/`applyConfigOptionValue` reference the
|
||||
* same identifiers and can't drift apart. */
|
||||
export const MODE_CONFIG_ID = "mode";
|
||||
export const MODEL_CONFIG_ID = "model";
|
||||
export const EFFORT_CONFIG_ID = "effort";
|
||||
export const AGENT_CONFIG_ID = "agent";
|
||||
export const FAST_MODE_CONFIG_ID = "fast";
|
||||
|
||||
/** Select-fallback values used when the client has not opted into boolean
|
||||
* config options (see {@link createFastModeConfigOption}). */
|
||||
export const FAST_MODE_ON = "on";
|
||||
export const FAST_MODE_OFF = "off";
|
||||
const FAST_MODE_DESCRIPTION = "Faster responses on supported models";
|
||||
|
||||
/** Map the SDK's tri-state `fast_mode_state` onto the boolean config toggle.
|
||||
* `cooldown` (fast mode temporarily suspended after a rate limit, per the SDK
|
||||
* docs) keeps the toggle on so it reflects the user's intent — only an
|
||||
* explicit `off` clears it. */
|
||||
export function fastModeStateEnabled(state: FastModeState): boolean {
|
||||
return state !== "off";
|
||||
}
|
||||
|
||||
/** Whether the Client advertised support for boolean session config options
|
||||
* (`session.configOptions.boolean`). Agents MUST only send `type: "boolean"`
|
||||
* config options to Clients that opt in; otherwise we fall back to a `select`.
|
||||
* See https://agentclientprotocol.com/rfds/boolean-config-option. */
|
||||
export function clientSupportsBooleanConfigOptions(
|
||||
clientCapabilities?: ClientCapabilities | null,
|
||||
): boolean {
|
||||
return clientCapabilities?.session?.configOptions?.boolean != null;
|
||||
}
|
||||
|
||||
/** Build the Fast mode config option. When the Client supports boolean config
|
||||
* options we expose a native `type: "boolean"` toggle; otherwise we degrade to
|
||||
* a two-value `select` ("on"/"off") so older Clients still get a usable
|
||||
* control. */
|
||||
export function createFastModeConfigOption(
|
||||
enabled: boolean,
|
||||
useBooleanOption: boolean,
|
||||
): SessionConfigOption {
|
||||
const base = {
|
||||
id: FAST_MODE_CONFIG_ID,
|
||||
name: "Fast mode",
|
||||
description: FAST_MODE_DESCRIPTION,
|
||||
category: "model_config",
|
||||
} as const;
|
||||
|
||||
if (useBooleanOption) {
|
||||
return { ...base, type: "boolean", currentValue: enabled };
|
||||
}
|
||||
|
||||
return {
|
||||
...base,
|
||||
type: "select",
|
||||
currentValue: enabled ? FAST_MODE_ON : FAST_MODE_OFF,
|
||||
options: [
|
||||
{ value: FAST_MODE_ON, name: "On" },
|
||||
{ value: FAST_MODE_OFF, name: "Off" },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** Resolve the requested Fast mode value from a `session/set_config_option`
|
||||
* request. Accepts a native boolean (boolean-capable Clients) or the
|
||||
* "on"/"off" select-fallback strings. */
|
||||
export function resolveFastModeEnabled(params: SetSessionConfigOptionRequest): boolean {
|
||||
const value = params.value;
|
||||
if (typeof value === "boolean") {
|
||||
return value;
|
||||
}
|
||||
if (value === FAST_MODE_ON) {
|
||||
return true;
|
||||
}
|
||||
if (value === FAST_MODE_OFF) {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Invalid value for config option ${FAST_MODE_CONFIG_ID}: ${value}`);
|
||||
}
|
||||
|
||||
/** Per-model Fast mode state threaded into {@link buildConfigOptions}. The
|
||||
* option is only surfaced when the current model `supported`s fast mode. */
|
||||
export type FastModeOptionState = {
|
||||
supported: boolean;
|
||||
enabled: boolean;
|
||||
/** Whether the Client opted into boolean config options. */
|
||||
useBooleanOption: boolean;
|
||||
};
|
||||
|
||||
export function buildConfigOptions(
|
||||
modes: SessionModeState,
|
||||
models: SessionModelState,
|
||||
@@ -3711,10 +3926,11 @@ export function buildConfigOptions(
|
||||
currentEffortLevel?: string,
|
||||
agents: AgentInfo[] = [],
|
||||
currentAgent: string = DEFAULT_AGENT_ID,
|
||||
fastMode?: FastModeOptionState,
|
||||
): SessionConfigOption[] {
|
||||
const options: SessionConfigOption[] = [
|
||||
{
|
||||
id: "mode",
|
||||
id: MODE_CONFIG_ID,
|
||||
name: "Mode",
|
||||
description: "Session permission mode",
|
||||
category: "mode",
|
||||
@@ -3727,7 +3943,7 @@ export function buildConfigOptions(
|
||||
})),
|
||||
},
|
||||
{
|
||||
id: "model",
|
||||
id: MODEL_CONFIG_ID,
|
||||
name: "Model",
|
||||
description: "AI model to use",
|
||||
category: "model",
|
||||
@@ -3764,7 +3980,7 @@ export function buildConfigOptions(
|
||||
currentEffortLevel && includes(currentEffortLevel) ? currentEffortLevel : "default";
|
||||
|
||||
options.push({
|
||||
id: "effort",
|
||||
id: EFFORT_CONFIG_ID,
|
||||
name: "Effort",
|
||||
description: "Available effort levels for this model",
|
||||
category: "thought_level",
|
||||
@@ -3774,13 +3990,20 @@ export function buildConfigOptions(
|
||||
});
|
||||
}
|
||||
|
||||
// Surface the Fast mode toggle only when the current model supports it. The
|
||||
// option renders as a native boolean toggle for Clients that opted in, and a
|
||||
// two-value select otherwise.
|
||||
if (fastMode?.supported) {
|
||||
options.push(createFastModeConfigOption(fastMode.enabled, fastMode.useBooleanOption));
|
||||
}
|
||||
|
||||
// Only surface the Agent picker when there's a real choice — i.e. the user
|
||||
// has configured at least one custom agent (built-ins are filtered out in
|
||||
// discoverCustomAgents). With none configured, "Default" would be the only
|
||||
// entry, so we omit the option entirely.
|
||||
if (agents.length > 0) {
|
||||
options.push({
|
||||
id: "agent",
|
||||
id: AGENT_CONFIG_ID,
|
||||
name: "Agent",
|
||||
description: "Main-thread agent persona",
|
||||
type: "select",
|
||||
@@ -3803,14 +4026,17 @@ export function buildConfigOptions(
|
||||
// but the SDK model list uses IDs like "claude-opus-4-6-1m".
|
||||
const MODEL_CONTEXT_HINT_PATTERN = /\[(\d+m)\]$/i;
|
||||
|
||||
// Captures a model family version such as `4-6` or `4.7` so we can keep
|
||||
// `claude-opus-4-6` from being copied onto the SDK's `opus` alias when that
|
||||
// alias currently resolves to a different family version (e.g. Opus 4.7).
|
||||
const MODEL_FAMILY_VERSION_PATTERN = /\b(\d+)[-.](\d+)\b/;
|
||||
// Captures a model family version: `4-6`/`4.7` for dated generations, or a
|
||||
// bare `5` for single-number ones like "Sonnet 5". Used to keep a pinned
|
||||
// `claude-opus-4-6` from matching the `opus` alias once it points at 4.7.
|
||||
const MODEL_FAMILY_VERSION_PATTERN = /\b(\d+)(?:[-.](\d+))?\b/;
|
||||
|
||||
function extractModelFamilyVersion(s: string): string | null {
|
||||
const match = s.match(MODEL_FAMILY_VERSION_PATTERN);
|
||||
return match ? `${match[1]}.${match[2]}` : null;
|
||||
// Strip "[1m]"-style context hints first — that digit is context window
|
||||
// size, not a model generation version.
|
||||
const match = s.replace(/\[\d+m\]/gi, "").match(MODEL_FAMILY_VERSION_PATTERN);
|
||||
if (!match) return null;
|
||||
return match[2] ? `${match[1]}.${match[2]}` : match[1];
|
||||
}
|
||||
|
||||
function modelVersionsCompatible(preference: string, candidate: ModelInfo): boolean {
|
||||
@@ -3856,7 +4082,7 @@ function scoreModelMatch(model: ModelInfo, tokens: string[], contextHint?: strin
|
||||
return score;
|
||||
}
|
||||
|
||||
function resolveModelPreference(models: ModelInfo[], preference: string): ModelInfo | null {
|
||||
export function resolveModelPreference(models: ModelInfo[], preference: string): ModelInfo | null {
|
||||
const trimmed = preference.trim();
|
||||
if (!trimmed) return null;
|
||||
|
||||
@@ -3871,6 +4097,18 @@ function resolveModelPreference(models: ModelInfo[], preference: string): ModelI
|
||||
);
|
||||
if (directMatch) return directMatch;
|
||||
|
||||
// Exact match on the alias's canonical resolved id (e.g. a pinned
|
||||
// "claude-sonnet-5" against the "sonnet" row's `resolvedModel`). SDK-
|
||||
// reported and unambiguous, so it's tried before the fuzzier tiers below.
|
||||
// "default" is skipped first since it shares a resolvedModel with
|
||||
// whichever alias the CLI currently recommends — a specific pin should
|
||||
// land on that named alias, not "default".
|
||||
const resolvedMatch =
|
||||
models.find(
|
||||
(model) => model.value !== "default" && model.resolvedModel?.toLowerCase() === lower,
|
||||
) ?? models.find((model) => model.resolvedModel?.toLowerCase() === lower);
|
||||
if (resolvedMatch) return resolvedMatch;
|
||||
|
||||
// Substring match
|
||||
const includesMatch = models.find((model) => {
|
||||
if (!modelVersionsCompatible(trimmed, model)) return false;
|
||||
@@ -3930,7 +4168,11 @@ function resolveSettingsModel(
|
||||
* - The Default option is unaffected by `availableModels` — it always remains
|
||||
* available, even when the allowlist is `[]`.
|
||||
*/
|
||||
function applyAvailableModelsAllowlist(sdkModels: ModelInfo[], allowlist: string[]): ModelInfo[] {
|
||||
export function applyAvailableModelsAllowlist(
|
||||
sdkModels: ModelInfo[],
|
||||
allowlist: string[],
|
||||
settingsModelOverrides?: Record<string, string>,
|
||||
): ModelInfo[] {
|
||||
// Default is always preserved per the docs. Synthesize one if the SDK
|
||||
// didn't surface it so downstream code (e.g. `getAvailableModels` picking
|
||||
// `models[0]` as a fallback) still has something to work with.
|
||||
@@ -3944,17 +4186,28 @@ function applyAvailableModelsAllowlist(sdkModels: ModelInfo[], allowlist: string
|
||||
|
||||
const sdkModelsWithoutDefault = sdkModels.filter((m) => m.value !== "default");
|
||||
|
||||
// Bedrock/Vertex deployments enforce short aliases (e.g. "claude-opus-4-6")
|
||||
// in availableModels but require provider-specific IDs at the API. We still
|
||||
// resolve `sdkMatch` against the alias (`trimmed`) — that's what the
|
||||
// matching heuristics above are built for, and override targets (ARNs,
|
||||
// opaque provider IDs) often won't textually resemble anything in
|
||||
// `sdkModelsWithoutDefault`. Only the entry's surfaced `value` becomes the
|
||||
// override target, so it's what `setModel` ends up passing to the API.
|
||||
for (const entry of allowlist) {
|
||||
const trimmed = entry.trim();
|
||||
if (!trimmed || seen.has(trimmed)) continue;
|
||||
|
||||
const overridden = settingsModelOverrides?.[trimmed];
|
||||
const effective = overridden ?? trimmed;
|
||||
if (seen.has(effective)) continue;
|
||||
|
||||
const sdkMatch = resolveModelPreference(sdkModelsWithoutDefault, trimmed);
|
||||
if (sdkMatch) {
|
||||
result.push({ ...sdkMatch, value: trimmed });
|
||||
result.push({ ...sdkMatch, value: effective });
|
||||
} else {
|
||||
result.push({ value: trimmed, displayName: trimmed, description: "" });
|
||||
result.push({ value: effective, displayName: trimmed, description: "" });
|
||||
}
|
||||
seen.add(trimmed);
|
||||
seen.add(effective);
|
||||
}
|
||||
|
||||
// The custom model option (ANTHROPIC_CUSTOM_MODEL_OPTION) is exempt from the
|
||||
|
||||
@@ -811,6 +811,55 @@ describe("ClaudeAcpAgent settings", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("maps allowlist aliases through modelOverrides to provider IDs", async () => {
|
||||
// Bedrock/Vertex deployments enforce short aliases in availableModels
|
||||
// but require provider-specific IDs at the API. Without applying
|
||||
// modelOverrides during allowlist resolution, the alias is surfaced as
|
||||
// the model value and passed verbatim to setModel, which the provider
|
||||
// API rejects with a 400 "invalid model identifier".
|
||||
await fs.promises.writeFile(
|
||||
path.join(tempDir, "settings.json"),
|
||||
JSON.stringify({
|
||||
availableModels: ["claude-opus-4-6", "claude-sonnet-4-6"],
|
||||
model: "claude-opus-4-6",
|
||||
modelOverrides: {
|
||||
"claude-opus-4-6": "global.anthropic.claude-opus-4-6-v1[1m]",
|
||||
"claude-sonnet-4-6": "global.anthropic.claude-sonnet-4-6[1m]",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const projectDir = path.join(tempDir, "project");
|
||||
await fs.promises.mkdir(projectDir, { recursive: true });
|
||||
|
||||
const { setModelSpy } = mockQueryWithModels([
|
||||
{ value: "default", displayName: "Default", description: "Default model" },
|
||||
{ value: "opus", displayName: "Opus", description: "Claude Opus 4.6" },
|
||||
{ value: "sonnet", displayName: "Sonnet", description: "Claude Sonnet 4.6" },
|
||||
]);
|
||||
|
||||
const { ClaudeAcpAgent } = await import("../acp-agent.js");
|
||||
const agent: ClaudeAcpAgentType = new ClaudeAcpAgent(createMockClient());
|
||||
|
||||
const response = await (agent as any).createSession({
|
||||
cwd: projectDir,
|
||||
mcpServers: [],
|
||||
_meta: { disableBuiltInTools: true },
|
||||
});
|
||||
|
||||
const modelOption = response.configOptions.find((o: any) => o.id === "model");
|
||||
expect(modelOption.options.map((o: any) => o.value)).toEqual([
|
||||
"default",
|
||||
"global.anthropic.claude-opus-4-6-v1[1m]",
|
||||
"global.anthropic.claude-sonnet-4-6[1m]",
|
||||
]);
|
||||
// The allowlist synthesized the overridden ID (the SDK only surfaced the
|
||||
// `opus` alias), so the adapter syncs the provider ID via setModel — never
|
||||
// the raw alias that Bedrock would reject.
|
||||
expect(setModelSpy).toHaveBeenCalledWith("global.anthropic.claude-opus-4-6-v1[1m]");
|
||||
expect(modelOption.currentValue).toBe("global.anthropic.claude-opus-4-6-v1[1m]");
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves model aliases like opus[1m] to the correct model", async () => {
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
streamEventToAcpNotifications,
|
||||
messageIdForGrouping,
|
||||
buildConfigOptions,
|
||||
createFastModeConfigOption,
|
||||
discoverCustomAgents,
|
||||
runPromptWithCancellation,
|
||||
type AcpClient,
|
||||
@@ -1810,6 +1811,7 @@ describe("permission request cancellation", () => {
|
||||
configOptions: [],
|
||||
agents: [],
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
@@ -2267,6 +2269,77 @@ describe("stop reason propagation", () => {
|
||||
expect(response.usage?.outputTokens).toBe(promptResult.usage.output_tokens);
|
||||
});
|
||||
|
||||
it("only reconciles Fast mode from user-driven results, not task-notification followups", async () => {
|
||||
const updates: any[] = [];
|
||||
const mockClient = {
|
||||
sessionUpdate: async (n: any) => {
|
||||
updates.push(n);
|
||||
},
|
||||
} as unknown as AcpClient;
|
||||
const agent = new ClaudeAcpAgent(mockClient, { log: () => {}, error: () => {} });
|
||||
(agent as any).clientCapabilities = { session: { configOptions: { boolean: {} } } };
|
||||
|
||||
const input = new Pushable<any>();
|
||||
|
||||
// A background followup reports fast_mode_state="on". It must NOT flip the
|
||||
// user's toggle or emit a config_option_update (every other side effect in
|
||||
// the result handler is likewise gated behind !isTaskNotification).
|
||||
const backgroundTaskResult = {
|
||||
...createResultMessage({ subtype: "success", stop_reason: null, is_error: false }),
|
||||
origin: { kind: "task-notification" },
|
||||
fast_mode_state: "on",
|
||||
};
|
||||
|
||||
// The user prompt's own result reports the same state — this one IS a user
|
||||
// turn, so it reconciles and notifies.
|
||||
const promptResult = {
|
||||
...createResultMessage({ subtype: "success", stop_reason: null, is_error: false }),
|
||||
fast_mode_state: "on",
|
||||
};
|
||||
|
||||
async function* messageGenerator() {
|
||||
yield { type: "system", subtype: "init", session_id: "test-session" };
|
||||
yield backgroundTaskResult;
|
||||
|
||||
const iter = input[Symbol.asyncIterator]();
|
||||
const { value: userMessage } = await iter.next();
|
||||
yield {
|
||||
type: "user",
|
||||
message: userMessage.message,
|
||||
parent_tool_use_id: null,
|
||||
uuid: userMessage.uuid,
|
||||
session_id: "test-session",
|
||||
isReplay: true,
|
||||
};
|
||||
|
||||
yield promptResult;
|
||||
yield { type: "system", subtype: "session_state_changed", state: "idle" };
|
||||
}
|
||||
|
||||
agent.sessions["test-session"] = mockSessionState({
|
||||
query: wrapQuery(messageGenerator()),
|
||||
input,
|
||||
fastModeEnabled: false,
|
||||
configOptions: [createFastModeConfigOption(false, true)],
|
||||
});
|
||||
|
||||
await agent.prompt({
|
||||
sessionId: "test-session",
|
||||
prompt: [{ type: "text", text: "test" }],
|
||||
});
|
||||
|
||||
// The user-turn result flipped the toggle and emitted exactly one
|
||||
// config_option_update; the background result contributed none.
|
||||
expect((agent.sessions["test-session"] as any).fastModeEnabled).toBe(true);
|
||||
const configUpdates = updates.filter(
|
||||
(n: any) => n.update?.sessionUpdate === "config_option_update",
|
||||
);
|
||||
expect(configUpdates).toHaveLength(1);
|
||||
expect(configUpdates[0].update.configOptions).toContainEqual(
|
||||
createFastModeConfigOption(true, true),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not fold a task-notification result's tokens into an already-active turn's usage", async () => {
|
||||
const agent = createMockAgent();
|
||||
|
||||
@@ -2713,6 +2786,7 @@ describe("session/close", () => {
|
||||
configOptions: [],
|
||||
agents: [],
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
@@ -2799,6 +2873,7 @@ describe("session/delete", () => {
|
||||
configOptions: [],
|
||||
agents: [],
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
@@ -2902,6 +2977,7 @@ describe("getOrCreateSession param change detection", () => {
|
||||
configOptions: [],
|
||||
agents: [],
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
@@ -5117,6 +5193,7 @@ describe("post-error recovery", () => {
|
||||
configOptions: [],
|
||||
agents: [],
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
@@ -5688,6 +5765,7 @@ describe("session/cancel wedge recovery (issue #680)", () => {
|
||||
configOptions: [],
|
||||
agents: [],
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
@@ -6142,6 +6220,7 @@ describe("agent selection config option", () => {
|
||||
configOptions: buildConfigOptions(baseModes, baseModels, [], undefined, agents, "default"),
|
||||
agents,
|
||||
currentAgent: "default",
|
||||
fastModeEnabled: false,
|
||||
abortController: new AbortController(),
|
||||
emitRawSDKMessages: false,
|
||||
contextWindowSize: 200000,
|
||||
|
||||
341
src/tests/fast-mode-config.test.ts
Normal file
341
src/tests/fast-mode-config.test.ts
Normal file
@@ -0,0 +1,341 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import type { ClientCapabilities, SessionNotification } from "@agentclientprotocol/sdk";
|
||||
import type { ModelInfo } from "@anthropic-ai/claude-agent-sdk";
|
||||
import {
|
||||
buildConfigOptions,
|
||||
clientSupportsBooleanConfigOptions,
|
||||
createFastModeConfigOption,
|
||||
fastModeStateEnabled,
|
||||
resolveFastModeEnabled,
|
||||
FAST_MODE_CONFIG_ID,
|
||||
FAST_MODE_ON,
|
||||
FAST_MODE_OFF,
|
||||
ClaudeAcpAgent,
|
||||
type AcpClient,
|
||||
} from "../acp-agent.js";
|
||||
|
||||
const MODES = {
|
||||
currentModeId: "default",
|
||||
availableModes: [{ id: "default", name: "Default", description: "Standard behavior" }],
|
||||
};
|
||||
|
||||
const MODELS = {
|
||||
currentModelId: "claude-opus-4-8",
|
||||
availableModels: [
|
||||
{ modelId: "claude-opus-4-8", name: "Claude Opus", description: "Most capable" },
|
||||
],
|
||||
};
|
||||
|
||||
const MODEL_INFOS: ModelInfo[] = [
|
||||
{ value: "claude-opus-4-8", displayName: "Claude Opus", description: "Most capable" },
|
||||
];
|
||||
|
||||
describe("createFastModeConfigOption", () => {
|
||||
it("produces a native boolean toggle when the client opted in", () => {
|
||||
expect(createFastModeConfigOption(true, true)).toEqual({
|
||||
id: FAST_MODE_CONFIG_ID,
|
||||
name: "Fast mode",
|
||||
description: expect.any(String),
|
||||
category: "model_config",
|
||||
type: "boolean",
|
||||
currentValue: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to an on/off select when the client did not opt in", () => {
|
||||
const option = createFastModeConfigOption(false, false);
|
||||
expect(option).toMatchObject({
|
||||
id: FAST_MODE_CONFIG_ID,
|
||||
type: "select",
|
||||
category: "model_config",
|
||||
currentValue: FAST_MODE_OFF,
|
||||
options: [
|
||||
{ value: FAST_MODE_ON, name: "On" },
|
||||
{ value: FAST_MODE_OFF, name: "Off" },
|
||||
],
|
||||
});
|
||||
expect(option).not.toHaveProperty("currentValue", true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientSupportsBooleanConfigOptions", () => {
|
||||
it("is true only when session.configOptions.boolean is present", () => {
|
||||
expect(
|
||||
clientSupportsBooleanConfigOptions({ session: { configOptions: { boolean: {} } } }),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("is false when the capability is omitted or null at any level", () => {
|
||||
expect(clientSupportsBooleanConfigOptions(undefined)).toBe(false);
|
||||
expect(clientSupportsBooleanConfigOptions(null)).toBe(false);
|
||||
expect(clientSupportsBooleanConfigOptions({})).toBe(false);
|
||||
expect(clientSupportsBooleanConfigOptions({ session: { configOptions: {} } })).toBe(false);
|
||||
expect(
|
||||
clientSupportsBooleanConfigOptions({ session: { configOptions: { boolean: null } } }),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveFastModeEnabled", () => {
|
||||
const base = { sessionId: "s", configId: FAST_MODE_CONFIG_ID };
|
||||
|
||||
it("accepts native boolean values", () => {
|
||||
expect(resolveFastModeEnabled({ ...base, type: "boolean", value: true })).toBe(true);
|
||||
expect(resolveFastModeEnabled({ ...base, type: "boolean", value: false })).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts the on/off select fallback", () => {
|
||||
expect(resolveFastModeEnabled({ ...base, value: FAST_MODE_ON })).toBe(true);
|
||||
expect(resolveFastModeEnabled({ ...base, value: FAST_MODE_OFF })).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects any other value", () => {
|
||||
expect(() => resolveFastModeEnabled({ ...base, value: "maybe" })).toThrow(
|
||||
/Invalid value for config option fast/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fastModeStateEnabled", () => {
|
||||
it("treats cooldown as on (the user's intent persists through rate-limit cooldown)", () => {
|
||||
expect(fastModeStateEnabled("on")).toBe(true);
|
||||
expect(fastModeStateEnabled("cooldown")).toBe(true);
|
||||
expect(fastModeStateEnabled("off")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildConfigOptions Fast mode", () => {
|
||||
it("omits the Fast mode option when the model does not support it", () => {
|
||||
const options = buildConfigOptions(MODES, MODELS, MODEL_INFOS, undefined, [], "default", {
|
||||
supported: false,
|
||||
enabled: false,
|
||||
useBooleanOption: true,
|
||||
});
|
||||
expect(options.find((o) => o.id === FAST_MODE_CONFIG_ID)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("omits the Fast mode option when no fast mode state is provided", () => {
|
||||
const options = buildConfigOptions(MODES, MODELS, MODEL_INFOS, undefined, [], "default");
|
||||
expect(options.find((o) => o.id === FAST_MODE_CONFIG_ID)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("surfaces a boolean toggle when supported and the client opted in", () => {
|
||||
const options = buildConfigOptions(MODES, MODELS, MODEL_INFOS, undefined, [], "default", {
|
||||
supported: true,
|
||||
enabled: true,
|
||||
useBooleanOption: true,
|
||||
});
|
||||
expect(options).toContainEqual(createFastModeConfigOption(true, true));
|
||||
});
|
||||
|
||||
it("surfaces a select fallback when supported but the client did not opt in", () => {
|
||||
const options = buildConfigOptions(MODES, MODELS, MODEL_INFOS, undefined, [], "default", {
|
||||
supported: true,
|
||||
enabled: false,
|
||||
useBooleanOption: false,
|
||||
});
|
||||
expect(options).toContainEqual(createFastModeConfigOption(false, false));
|
||||
});
|
||||
});
|
||||
|
||||
describe("setSessionConfigOption Fast mode toggle", () => {
|
||||
const SESSION_ID = "fast-session";
|
||||
|
||||
function setup(opts: { useBooleanOption: boolean }) {
|
||||
const sessionUpdates: SessionNotification[] = [];
|
||||
const client = {
|
||||
sessionUpdate: async (n: SessionNotification) => {
|
||||
sessionUpdates.push(n);
|
||||
},
|
||||
requestPermission: async () => ({ outcome: { outcome: "cancelled" } }),
|
||||
readTextFile: async () => ({ content: "" }),
|
||||
writeTextFile: async () => ({}),
|
||||
} as unknown as AcpClient;
|
||||
|
||||
const agent = new ClaudeAcpAgent(client);
|
||||
const clientCapabilities: ClientCapabilities = opts.useBooleanOption
|
||||
? { session: { configOptions: { boolean: {} } } }
|
||||
: {};
|
||||
(agent as unknown as { clientCapabilities: ClientCapabilities }).clientCapabilities =
|
||||
clientCapabilities;
|
||||
|
||||
const applyFlagSettings = vi.fn();
|
||||
(agent as unknown as { sessions: Record<string, unknown> }).sessions[SESSION_ID] = {
|
||||
query: { applyFlagSettings },
|
||||
fastModeEnabled: false,
|
||||
configOptions: [createFastModeConfigOption(false, opts.useBooleanOption)],
|
||||
};
|
||||
|
||||
return { agent, applyFlagSettings, sessionUpdates };
|
||||
}
|
||||
|
||||
it("toggles Fast mode on/off through a boolean value", async () => {
|
||||
const { agent, applyFlagSettings } = setup({ useBooleanOption: true });
|
||||
|
||||
const onResponse = await agent.setSessionConfigOption({
|
||||
sessionId: SESSION_ID,
|
||||
configId: FAST_MODE_CONFIG_ID,
|
||||
type: "boolean",
|
||||
value: true,
|
||||
});
|
||||
expect(applyFlagSettings).toHaveBeenCalledWith({ fastMode: true });
|
||||
expect(onResponse.configOptions).toContainEqual(createFastModeConfigOption(true, true));
|
||||
expect(
|
||||
(agent as unknown as { sessions: Record<string, { fastModeEnabled: boolean }> }).sessions[
|
||||
SESSION_ID
|
||||
].fastModeEnabled,
|
||||
).toBe(true);
|
||||
|
||||
const offResponse = await agent.setSessionConfigOption({
|
||||
sessionId: SESSION_ID,
|
||||
configId: FAST_MODE_CONFIG_ID,
|
||||
type: "boolean",
|
||||
value: false,
|
||||
});
|
||||
expect(applyFlagSettings).toHaveBeenLastCalledWith({ fastMode: false });
|
||||
expect(offResponse.configOptions).toContainEqual(createFastModeConfigOption(false, true));
|
||||
});
|
||||
|
||||
it("toggles Fast mode through the on/off select fallback", async () => {
|
||||
const { agent, applyFlagSettings } = setup({ useBooleanOption: false });
|
||||
|
||||
const response = await agent.setSessionConfigOption({
|
||||
sessionId: SESSION_ID,
|
||||
configId: FAST_MODE_CONFIG_ID,
|
||||
value: FAST_MODE_ON,
|
||||
});
|
||||
expect(applyFlagSettings).toHaveBeenCalledWith({ fastMode: true });
|
||||
expect(response.configOptions).toContainEqual(createFastModeConfigOption(true, false));
|
||||
});
|
||||
|
||||
it("does not change session state when the SDK rejects the flag", async () => {
|
||||
const { agent, applyFlagSettings } = setup({ useBooleanOption: true });
|
||||
applyFlagSettings.mockRejectedValueOnce(new Error("nope"));
|
||||
|
||||
await expect(
|
||||
agent.setSessionConfigOption({
|
||||
sessionId: SESSION_ID,
|
||||
configId: FAST_MODE_CONFIG_ID,
|
||||
type: "boolean",
|
||||
value: true,
|
||||
}),
|
||||
).rejects.toThrow("nope");
|
||||
|
||||
const session = (agent as unknown as { sessions: Record<string, { fastModeEnabled: boolean }> })
|
||||
.sessions[SESSION_ID];
|
||||
expect(session.fastModeEnabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("syncFastModeState (SDK-driven state changes)", () => {
|
||||
const SESSION_ID = "fast-session";
|
||||
|
||||
function setup(opts: { fastModeEnabled: boolean; withOption: boolean }) {
|
||||
const sessionUpdates: SessionNotification[] = [];
|
||||
const client = {
|
||||
sessionUpdate: async (n: SessionNotification) => {
|
||||
sessionUpdates.push(n);
|
||||
},
|
||||
requestPermission: async () => ({ outcome: { outcome: "cancelled" } }),
|
||||
readTextFile: async () => ({ content: "" }),
|
||||
writeTextFile: async () => ({}),
|
||||
} as unknown as AcpClient;
|
||||
|
||||
const agent = new ClaudeAcpAgent(client);
|
||||
(agent as unknown as { clientCapabilities: ClientCapabilities }).clientCapabilities = {
|
||||
session: { configOptions: { boolean: {} } },
|
||||
};
|
||||
|
||||
const session = {
|
||||
query: {},
|
||||
fastModeEnabled: opts.fastModeEnabled,
|
||||
configOptions: opts.withOption
|
||||
? [createFastModeConfigOption(opts.fastModeEnabled, true)]
|
||||
: [],
|
||||
};
|
||||
(agent as unknown as { sessions: Record<string, unknown> }).sessions[SESSION_ID] = session;
|
||||
|
||||
const sync = (
|
||||
agent as unknown as {
|
||||
syncFastModeState: (
|
||||
sessionId: string,
|
||||
session: unknown,
|
||||
state: string | undefined,
|
||||
) => Promise<void>;
|
||||
}
|
||||
).syncFastModeState.bind(agent);
|
||||
|
||||
return { sync, session, sessionUpdates };
|
||||
}
|
||||
|
||||
it("emits a config_option_update when the SDK reports a new state", async () => {
|
||||
const { sync, session, sessionUpdates } = setup({ fastModeEnabled: false, withOption: true });
|
||||
|
||||
await sync(SESSION_ID, session, "on");
|
||||
|
||||
expect(session.fastModeEnabled).toBe(true);
|
||||
expect(session.configOptions).toContainEqual(createFastModeConfigOption(true, true));
|
||||
expect(sessionUpdates).toHaveLength(1);
|
||||
expect(sessionUpdates[0].update).toMatchObject({
|
||||
sessionUpdate: "config_option_update",
|
||||
});
|
||||
const updated = (
|
||||
sessionUpdates[0].update as { configOptions: ReturnType<typeof createFastModeConfigOption>[] }
|
||||
).configOptions;
|
||||
expect(updated).toContainEqual(createFastModeConfigOption(true, true));
|
||||
});
|
||||
|
||||
it("leaves the toggle on and quiet during a rate-limit cooldown", async () => {
|
||||
const { sync, session, sessionUpdates } = setup({ fastModeEnabled: true, withOption: true });
|
||||
|
||||
// cooldown is a transient suspension of an already-enabled fast mode.
|
||||
await sync(SESSION_ID, session, "cooldown");
|
||||
|
||||
expect(session.fastModeEnabled).toBe(true);
|
||||
expect(sessionUpdates).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("never lets a stray cooldown spuriously enable a toggle the user has off", async () => {
|
||||
const { sync, session, sessionUpdates } = setup({ fastModeEnabled: false, withOption: true });
|
||||
|
||||
await sync(SESSION_ID, session, "cooldown");
|
||||
|
||||
expect(session.fastModeEnabled).toBe(false);
|
||||
expect(sessionUpdates).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("clears the toggle when the SDK reports off", async () => {
|
||||
const { sync, session, sessionUpdates } = setup({ fastModeEnabled: true, withOption: true });
|
||||
|
||||
await sync(SESSION_ID, session, "off");
|
||||
|
||||
expect(session.fastModeEnabled).toBe(false);
|
||||
expect(session.configOptions).toContainEqual(createFastModeConfigOption(false, true));
|
||||
expect(sessionUpdates).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("is a no-op when the reported state is undefined or unchanged", async () => {
|
||||
const { sync, session, sessionUpdates } = setup({ fastModeEnabled: false, withOption: true });
|
||||
|
||||
await sync(SESSION_ID, session, undefined);
|
||||
await sync(SESSION_ID, session, "off");
|
||||
|
||||
expect(sessionUpdates).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("preserves the retained setting (no clobber) when the model has no Fast mode option", async () => {
|
||||
// Model without fast support: the SDK reports a capability-driven state, not
|
||||
// the user's intent. We must leave session.fastModeEnabled untouched so it's
|
||||
// correct when a supporting model is reselected — reconciling here was the
|
||||
// original intent-clobber bug.
|
||||
const enabledCase = setup({ fastModeEnabled: true, withOption: false });
|
||||
await enabledCase.sync(SESSION_ID, enabledCase.session, "off");
|
||||
expect(enabledCase.session.fastModeEnabled).toBe(true);
|
||||
expect(enabledCase.sessionUpdates).toHaveLength(0);
|
||||
|
||||
const disabledCase = setup({ fastModeEnabled: false, withOption: false });
|
||||
await disabledCase.sync(SESSION_ID, disabledCase.session, "on");
|
||||
expect(disabledCase.session.fastModeEnabled).toBe(false);
|
||||
expect(disabledCase.sessionUpdates).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
150
src/tests/model-resolution.test.ts
Normal file
150
src/tests/model-resolution.test.ts
Normal file
@@ -0,0 +1,150 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { randomUUID } from "crypto";
|
||||
import { query } from "@anthropic-ai/claude-agent-sdk";
|
||||
import type { ModelInfo } from "@anthropic-ai/claude-agent-sdk";
|
||||
import { resolveModelPreference, applyAvailableModelsAllowlist } from "../acp-agent.js";
|
||||
|
||||
// Mirrors a real `supportedModels()` response: alias rows carry
|
||||
// `resolvedModel`, and "Sonnet 5" has no `major.minor` dot unlike older
|
||||
// "claude-opus-4-6"-style ids.
|
||||
const LIVE_SHAPED_MODELS: ModelInfo[] = [
|
||||
{
|
||||
value: "default",
|
||||
resolvedModel: "claude-opus-4-8[1m]",
|
||||
displayName: "Default (recommended)",
|
||||
description: "Use the default model (currently Opus 4.8 (1M context))",
|
||||
},
|
||||
{
|
||||
value: "opus[1m]",
|
||||
resolvedModel: "claude-opus-4-8[1m]",
|
||||
displayName: "Opus",
|
||||
description: "Opus 4.8 with 1M context · Best for everyday, complex tasks",
|
||||
},
|
||||
{
|
||||
value: "sonnet",
|
||||
resolvedModel: "claude-sonnet-5",
|
||||
displayName: "Sonnet",
|
||||
description: "Sonnet 5 · Efficient for routine tasks",
|
||||
},
|
||||
{
|
||||
value: "haiku",
|
||||
resolvedModel: "claude-haiku-4-5-20251001",
|
||||
displayName: "Haiku",
|
||||
description: "Haiku 4.5 · Fastest for quick answers",
|
||||
},
|
||||
];
|
||||
|
||||
describe("resolveModelPreference - resolvedModel matching", () => {
|
||||
it("matches a preference that equals an alias's resolvedModel exactly", () => {
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "claude-sonnet-5")?.value).toBe("sonnet");
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "claude-opus-4-8[1m]")?.value).toBe(
|
||||
"opus[1m]",
|
||||
);
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "claude-haiku-4-5-20251001")?.value).toBe(
|
||||
"haiku",
|
||||
);
|
||||
});
|
||||
|
||||
it("is case-insensitive", () => {
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "CLAUDE-SONNET-5")?.value).toBe("sonnet");
|
||||
});
|
||||
|
||||
it("still resolves plain aliases via the direct-match tier", () => {
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "sonnet")?.value).toBe("sonnet");
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "opus[1m]")?.value).toBe("opus[1m]");
|
||||
});
|
||||
|
||||
it("does not let a retired dated id drift onto a same-family alias of a different generation", () => {
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "claude-sonnet-4-6")).toBeNull();
|
||||
});
|
||||
|
||||
// "opus[1m]"'s `value` has no dotted version, just the context-hint digit
|
||||
// in "[1m]" — unstripped, that reads as version "1" and blocks the match
|
||||
// before the matcher reaches the description's real "4.8".
|
||||
it("does not mistake an alias's context-hint suffix for its version", () => {
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "claude-opus-4-8")?.value).toBe("opus[1m]");
|
||||
});
|
||||
|
||||
it("returns null for a preference that matches nothing", () => {
|
||||
expect(resolveModelPreference(LIVE_SHAPED_MODELS, "claude-gpt-99")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyAvailableModelsAllowlist - resolvedModel matching", () => {
|
||||
it("resolves an allowlist entry pinned to a canonical resolvedModel id", () => {
|
||||
const result = applyAvailableModelsAllowlist(LIVE_SHAPED_MODELS, ["claude-sonnet-5"]);
|
||||
const entry = result.find((m) => m.value === "claude-sonnet-5");
|
||||
expect(entry).toBeDefined();
|
||||
expect(entry?.displayName).toBe("Sonnet");
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyAvailableModelsAllowlist - modelOverrides", () => {
|
||||
const SDK_MODELS: ModelInfo[] = [
|
||||
{ value: "default", displayName: "Default", description: "Default model" },
|
||||
{
|
||||
value: "opus",
|
||||
displayName: "Opus",
|
||||
description: "Claude Opus 4.6",
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: ["low", "high"],
|
||||
},
|
||||
];
|
||||
|
||||
it("surfaces the override target as the value while keeping the alias's display metadata", () => {
|
||||
// The override target is an opaque Bedrock ARN with no "opus" substring,
|
||||
// so matching against it (instead of the "claude-opus-4-6" alias) would
|
||||
// find nothing and silently drop displayName/description/supportsEffort.
|
||||
const overrides = {
|
||||
"claude-opus-4-6": "arn:aws:bedrock:us-west-2:111122223333:inference-profile/custom-7f3a",
|
||||
};
|
||||
const result = applyAvailableModelsAllowlist(SDK_MODELS, ["claude-opus-4-6"], overrides);
|
||||
|
||||
const entry = result.find((m) => m.value === overrides["claude-opus-4-6"]);
|
||||
expect(entry).toEqual({
|
||||
value: overrides["claude-opus-4-6"],
|
||||
displayName: "Opus",
|
||||
description: "Claude Opus 4.6",
|
||||
supportsEffort: true,
|
||||
supportedEffortLevels: ["low", "high"],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Runs against the real SDK (no mocks) so the fixture above is flagged the
|
||||
// moment the SDK's actual model list shape drifts from it. Requires a usable
|
||||
// ANTHROPIC_API_KEY, hence opt-in via RUN_INTEGRATION_TESTS.
|
||||
describe.skipIf(!process.env.RUN_INTEGRATION_TESTS)("model resolution (real SDK)", () => {
|
||||
it("every model's resolvedModel (when present) resolves back to that same row", async () => {
|
||||
const q = query({ prompt: "hi", options: { sessionId: randomUUID() } });
|
||||
try {
|
||||
const models = await q.supportedModels();
|
||||
expect(models.length).toBeGreaterThan(0);
|
||||
|
||||
for (const model of models) {
|
||||
// "default" shares a resolvedModel with the CLI's recommended named
|
||||
// alias, and resolution intentionally prefers that alias on a tie.
|
||||
if (!model.resolvedModel || model.value === "default") continue;
|
||||
const resolved = resolveModelPreference(models, model.resolvedModel);
|
||||
expect(resolved?.value).toBe(model.value);
|
||||
}
|
||||
} finally {
|
||||
q.return(undefined);
|
||||
}
|
||||
}, 30000);
|
||||
|
||||
it("resolves the well-known 'sonnet' and 'opus' aliases to a model bearing their family name", async () => {
|
||||
const q = query({ prompt: "hi", options: { sessionId: randomUUID() } });
|
||||
try {
|
||||
const models = await q.supportedModels();
|
||||
|
||||
const sonnet = resolveModelPreference(models, "sonnet");
|
||||
expect(sonnet?.resolvedModel?.toLowerCase()).toContain("sonnet");
|
||||
|
||||
const opus = resolveModelPreference(models, "opus");
|
||||
expect(opus?.resolvedModel?.toLowerCase()).toContain("opus");
|
||||
} finally {
|
||||
q.return(undefined);
|
||||
}
|
||||
}, 30000);
|
||||
});
|
||||
@@ -1614,6 +1614,68 @@ describe("toolInfoFromToolUse - undefined input regression", () => {
|
||||
const info = toolInfoFromToolUse(toolUse, false);
|
||||
expect(info.title).toBe("Update TODOs");
|
||||
});
|
||||
|
||||
it("ReportFindings with undefined input should not throw", () => {
|
||||
const toolUse = { name: "ReportFindings", id: "toolu_findings_undef", input: undefined };
|
||||
const info = toolInfoFromToolUse(toolUse, false);
|
||||
expect(info.title).toBe("Report findings: none found");
|
||||
expect(info.content).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toolInfoFromToolUse - ReportFindings", () => {
|
||||
it("should summarize findings count and list each in content", () => {
|
||||
const toolUse = {
|
||||
name: "ReportFindings",
|
||||
id: "toolu_findings_1",
|
||||
input: {
|
||||
findings: [
|
||||
{
|
||||
file: "src/foo.ts",
|
||||
line: 42,
|
||||
summary: "Off-by-one in loop bound",
|
||||
failure_scenario: "Empty array → index out of bounds crash",
|
||||
},
|
||||
{
|
||||
file: "src/bar.ts",
|
||||
summary: "Unhandled promise rejection",
|
||||
failure_scenario: "Network failure → unhandled rejection",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const info = toolInfoFromToolUse(toolUse, false);
|
||||
|
||||
expect(info.kind).toBe("think");
|
||||
expect(info.title).toBe("Report 2 findings");
|
||||
expect(info.content).toEqual([
|
||||
{
|
||||
type: "content",
|
||||
content: { type: "text", text: "**src/foo.ts:42** — Off-by-one in loop bound" },
|
||||
},
|
||||
{
|
||||
type: "content",
|
||||
content: { type: "text", text: "**src/bar.ts** — Unhandled promise rejection" },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should report a singular title and empty findings array", () => {
|
||||
const oneFinding = {
|
||||
name: "ReportFindings",
|
||||
id: "toolu_findings_2",
|
||||
input: { findings: [{ file: "src/baz.ts", summary: "Leak", failure_scenario: "..." }] },
|
||||
};
|
||||
expect(toolInfoFromToolUse(oneFinding, false).title).toBe("Report 1 finding");
|
||||
|
||||
const noFindings = {
|
||||
name: "ReportFindings",
|
||||
id: "toolu_findings_3",
|
||||
input: { findings: [] },
|
||||
};
|
||||
expect(toolInfoFromToolUse(noFindings, false).title).toBe("Report findings: none found");
|
||||
});
|
||||
});
|
||||
|
||||
describe("planEntries - undefined input regression", () => {
|
||||
|
||||
20
src/tools.ts
20
src/tools.ts
@@ -15,6 +15,7 @@ import {
|
||||
FileWriteInput,
|
||||
GlobInput,
|
||||
GrepInput,
|
||||
ReportFindingsInput,
|
||||
TaskCreateInput,
|
||||
TaskCreateOutput,
|
||||
TaskUpdateInput,
|
||||
@@ -371,6 +372,25 @@ export function toolInfoFromToolUse(
|
||||
};
|
||||
}
|
||||
|
||||
case "ReportFindings": {
|
||||
const input = toolUse.input as ReportFindingsInput | undefined;
|
||||
const findings = input?.findings ?? [];
|
||||
return {
|
||||
title:
|
||||
findings.length === 0
|
||||
? "Report findings: none found"
|
||||
: `Report ${findings.length} finding${findings.length === 1 ? "" : "s"}`,
|
||||
kind: "think",
|
||||
content: findings.map((finding) => ({
|
||||
type: "content" as const,
|
||||
content: {
|
||||
type: "text" as const,
|
||||
text: `**${finding.file}${finding.line ? `:${finding.line}` : ""}** — ${finding.summary}`,
|
||||
},
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
case "TaskCreate": {
|
||||
const input = toolUse.input as TaskCreateInput | undefined;
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user