diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f610b8f..d8c6f50 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,3 +22,15 @@ jobs: - run: npm ci - run: npm run build - run: npm publish + release: + runs-on: ubuntu-latest + needs: [publish-npm] + permissions: + contents: write + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - name: Create Release + id: create_release + uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 + with: + draft: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cb6e85..9c2af32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.0 (2025-10-23) + +- Update to latest ACP JSON Schema + ## 0.4.9 (20205-10-21) - Fix: incorrect method for session/set_model client implementation. diff --git a/package-lock.json b/package-lock.json index 65d6ce5..4a52a9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@agentclientprotocol/sdk", - "version": "0.4.9", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@agentclientprotocol/sdk", - "version": "0.4.9", + "version": "0.5.0", "license": "Apache-2.0", "dependencies": { "zod": "^3.0.0" @@ -26,7 +26,7 @@ "typedoc": "^0.28.14", "typedoc-github-theme": "^0.3.1", "typescript": "^5.9.3", - "vitest": "^3.2.4" + "vitest": "^4.0.2" } }, "node_modules/@apidevtools/json-schema-ref-parser": { @@ -509,9 +509,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", - "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", "dev": true, "license": "MIT", "engines": { @@ -819,9 +819,9 @@ } }, "node_modules/@oclif/core": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.6.0.tgz", - "integrity": "sha512-nVe56MTWDD6+/oOxfEIrnnnq7bDBMseE904rI2+ZCvLLqY6Hm8yh07Ks149UgZiJvxYhQPsGEry2ifh8zz3irw==", + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.7.2.tgz", + "integrity": "sha512-AmZnhEnyD7bFxmzEKRaOEr0kzonmwIip72eWZPWB5+7D9ayHa/QFX08zhaQT9eOo0//ed64v5p5QZIbYCbQaJQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1205,6 +1205,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -1520,39 +1527,40 @@ } }, "node_modules/@vitest/expect": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", - "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.2.tgz", + "integrity": "sha512-izQY+ABWqL2Vyr5+LNo3m16nLLTAzLn8em6i5uxqsrWRhdgzdN5JIHrpFVGBAYRGDAbtwE+yD4Heu8gsBSWTVQ==", "dev": true, "license": "MIT", "dependencies": { + "@standard-schema/spec": "^1.0.0", "@types/chai": "^5.2.2", - "@vitest/spy": "3.2.4", - "@vitest/utils": "3.2.4", - "chai": "^5.2.0", - "tinyrainbow": "^2.0.0" + "@vitest/spy": "4.0.2", + "@vitest/utils": "4.0.2", + "chai": "^6.0.1", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/mocker": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", - "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.2.tgz", + "integrity": "sha512-oiny+oBSGU9vHMA1DPdO+t1GVidCRuA4lKSG6rbo5SrCiTCGl7bTCyTaUkwxDpUkiSxEVneeXW4LJ4fg3H56dw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "3.2.4", + "@vitest/spy": "4.0.2", "estree-walker": "^3.0.3", - "magic-string": "^0.30.17" + "magic-string": "^0.30.19" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + "vite": "^6.0.0 || ^7.0.0-0" }, "peerDependenciesMeta": { "msw": { @@ -1564,42 +1572,41 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", - "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.2.tgz", + "integrity": "sha512-PhrSiljryCz5nUDhHla5ihXYy2iRCBob+rNqlu34dA+KZIllVR39rUGny5R3kLgDgw3r8GW1ptOo64WbieMkeQ==", "dev": true, "license": "MIT", "dependencies": { - "tinyrainbow": "^2.0.0" + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/runner": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", - "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.2.tgz", + "integrity": "sha512-mPS5T/ZDuO6J5rsQiA76CFmlHtos7dnCvL14I1Oo8SbcjIhJd6kirFmekovfYLRygdF0gJe6SA5asCKIWKw1tw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "3.2.4", - "pathe": "^2.0.3", - "strip-literal": "^3.0.0" + "@vitest/utils": "4.0.2", + "pathe": "^2.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/snapshot": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", - "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.2.tgz", + "integrity": "sha512-NibujZAh+fTQlpGdP8J2pZcsPg7EPjiLUOUq9In++4p35vc9xIFMkXfQDbBSpijqZPe6i2hEKrUCbKu70/sPzw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.2.4", - "magic-string": "^0.30.17", + "@vitest/pretty-format": "4.0.2", + "magic-string": "^0.30.19", "pathe": "^2.0.3" }, "funding": { @@ -1607,28 +1614,24 @@ } }, "node_modules/@vitest/spy": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", - "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.2.tgz", + "integrity": "sha512-KrTWRXFPYrbhD0iUXeoA8BMXl81nvemj5D8sc7NbTlRvCeUWo36JheOWtAUCafcNi0G72ycAdsvWQVSOxy/3TA==", "dev": true, "license": "MIT", - "dependencies": { - "tinyspy": "^4.0.3" - }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", - "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.2.tgz", + "integrity": "sha512-H9jFzZb/5B5Qh7ajPUWMJ8UYGxQ4EQTaNLSm3icXs/oXkzQ1jqfcWDEJ4U3LkFPZOd6QW8M2MYjz32poW+KKqg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.2.4", - "loupe": "^3.1.4", - "tinyrainbow": "^2.0.0" + "@vitest/pretty-format": "4.0.2", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" @@ -1878,16 +1881,6 @@ "ieee754": "^1.1.13" } }, - "node_modules/cac": { - "version": "6.7.14", - "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", - "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/call-bind-apply-helpers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", @@ -1940,18 +1933,11 @@ } }, "node_modules/chai": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", - "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.0.tgz", + "integrity": "sha512-aUTnJc/JipRzJrNADXVvpVqi6CO0dn3nx4EVPxijri+fj3LUUDyZQOgVeW54Ob3Y1Xh9Iz8f+CgaCl8v0mn9bA==", "dev": true, "license": "MIT", - "dependencies": { - "assertion-error": "^2.0.1", - "check-error": "^2.1.1", - "deep-eql": "^5.0.1", - "loupe": "^3.1.0", - "pathval": "^2.0.0" - }, "engines": { "node": ">=18" } @@ -1993,16 +1979,6 @@ "dev": true, "license": "MIT" }, - "node_modules/check-error": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", - "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -2213,16 +2189,6 @@ } } }, - "node_modules/deep-eql": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", - "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -2962,9 +2928,9 @@ } }, "node_modules/get-tsconfig": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.12.0.tgz", - "integrity": "sha512-LScr2aNr2FbjAjZh2C6X6BxRx1/x+aTDExct/xyq2XKbYOiG5c0aK7pMsSuyc0brz3ibr/lbQiHD9jzt4lccJw==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz", + "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3409,13 +3375,6 @@ "node": ">=10" } }, - "node_modules/js-tokens": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", - "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", - "dev": true, - "license": "MIT" - }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -3581,13 +3540,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/loupe": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", - "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", - "dev": true, - "license": "MIT" - }, "node_modules/lunr": { "version": "2.3.9", "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", @@ -3923,16 +3875,6 @@ "dev": true, "license": "MIT" }, - "node_modules/pathval": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", - "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14.16" - } - }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -4521,19 +4463,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/strip-literal": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", - "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "js-tokens": "^9.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, "node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -4649,30 +4578,10 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/tinypool": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", - "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.0.0 || >=20.0.0" - } - }, "node_modules/tinyrainbow": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", - "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tinyspy": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.4.tgz", - "integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", "dev": true, "license": "MIT", "engines": { @@ -4947,9 +4856,9 @@ "license": "MIT" }, "node_modules/vite": { - "version": "7.1.11", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.11.tgz", - "integrity": "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg==", + "version": "7.1.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.12.tgz", + "integrity": "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==", "dev": true, "license": "MIT", "dependencies": { @@ -5021,29 +4930,6 @@ } } }, - "node_modules/vite-node": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", - "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", - "dev": true, - "license": "MIT", - "dependencies": { - "cac": "^6.7.14", - "debug": "^4.4.1", - "es-module-lexer": "^1.7.0", - "pathe": "^2.0.3", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" - }, - "bin": { - "vite-node": "vite-node.mjs" - }, - "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, "node_modules/vite/node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -5076,41 +4962,38 @@ } }, "node_modules/vitest": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", - "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.2.tgz", + "integrity": "sha512-SXrA2ZzOPulX479d8W13RqKSmvHb9Bfg71eW7Fbs6ZjUFcCCXyt/OzFCkNyiUE8mFlPHa4ZVUGw0ky+5ndKnrg==", "dev": true, "license": "MIT", "dependencies": { - "@types/chai": "^5.2.2", - "@vitest/expect": "3.2.4", - "@vitest/mocker": "3.2.4", - "@vitest/pretty-format": "^3.2.4", - "@vitest/runner": "3.2.4", - "@vitest/snapshot": "3.2.4", - "@vitest/spy": "3.2.4", - "@vitest/utils": "3.2.4", - "chai": "^5.2.0", - "debug": "^4.4.1", - "expect-type": "^1.2.1", - "magic-string": "^0.30.17", + "@vitest/expect": "4.0.2", + "@vitest/mocker": "4.0.2", + "@vitest/pretty-format": "4.0.2", + "@vitest/runner": "4.0.2", + "@vitest/snapshot": "4.0.2", + "@vitest/spy": "4.0.2", + "@vitest/utils": "4.0.2", + "debug": "^4.4.3", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.19", "pathe": "^2.0.3", - "picomatch": "^4.0.2", + "picomatch": "^4.0.3", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", - "tinyglobby": "^0.2.14", - "tinypool": "^1.1.1", - "tinyrainbow": "^2.0.0", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", - "vite-node": "3.2.4", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.0.0", "why-is-node-running": "^2.3.0" }, "bin": { "vitest": "vitest.mjs" }, "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" }, "funding": { "url": "https://opencollective.com/vitest" @@ -5118,9 +5001,11 @@ "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", - "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", - "@vitest/browser": "3.2.4", - "@vitest/ui": "3.2.4", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.0.2", + "@vitest/browser-preview": "4.0.2", + "@vitest/browser-webdriverio": "4.0.2", + "@vitest/ui": "4.0.2", "happy-dom": "*", "jsdom": "*" }, @@ -5134,7 +5019,13 @@ "@types/node": { "optional": true }, - "@vitest/browser": { + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { "optional": true }, "@vitest/ui": { diff --git a/package.json b/package.json index ccccf86..7430675 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agentclientprotocol/sdk", - "version": "0.4.9", + "version": "0.5.0", "publishConfig": { "access": "public" }, @@ -61,6 +61,6 @@ "typedoc": "^0.28.14", "typedoc-github-theme": "^0.3.1", "typescript": "^5.9.3", - "vitest": "^3.2.4" + "vitest": "^4.0.2" } } diff --git a/schema/schema.json b/schema/schema.json index 96b1378..7102970 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -35,50 +35,178 @@ "anyOf": [ { "$ref": "#/$defs/SessionNotification", + "description": "Handles session update notifications from the agent.\n\nThis is a notification endpoint (no response expected) that receives\nreal-time updates about session progress, including message chunks,\ntool calls, and execution plans.\n\nNote: Clients SHOULD continue accepting tool call updates even after\nsending a `session/cancel` notification, as the agent may send final\nupdates before responding with the cancelled stop reason.\n\nSee protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)", "title": "SessionNotification" }, { + "description": "Handles extension notifications from the agent.\n\nAllows the Agent to send an arbitrary notification that is not part of the ACP spec.\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", "title": "ExtNotification" } ], "description": "All possible notifications that an agent can send to a client.\n\nThis enum is used internally for routing RPC notifications. You typically won't need\nto use this directly - use the notification methods on the [`Client`] trait instead.\n\nNotifications do not expect a response.", "x-docs-ignore": true }, + "AgentOutgoingMessage": { + "anyOf": [ + { + "properties": { + "id": { + "anyOf": [ + { + "title": "null", + "type": "null" + }, + { + "format": "int64", + "title": "number", + "type": "integer" + }, + { + "title": "string", + "type": "string" + } + ], + "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + }, + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { + "$ref": "#/$defs/AgentRequest" + }, + { + "type": "null" + } + ] + } + }, + "required": ["id", "method"], + "title": "Request", + "type": "object" + }, + { + "oneOf": [ + { + "properties": { + "result": { + "$ref": "#/$defs/AgentResponse" + } + }, + "required": ["result"], + "type": "object" + }, + { + "properties": { + "error": { + "$ref": "#/$defs/Error" + } + }, + "required": ["error"], + "type": "object" + } + ], + "properties": { + "id": { + "anyOf": [ + { + "title": "null", + "type": "null" + }, + { + "format": "int64", + "title": "number", + "type": "integer" + }, + { + "title": "string", + "type": "string" + } + ], + "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + } + }, + "required": ["id"], + "title": "Response", + "type": "object" + }, + { + "properties": { + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { + "$ref": "#/$defs/AgentNotification" + }, + { + "type": "null" + } + ] + } + }, + "required": ["method"], + "title": "Notification", + "type": "object" + } + ], + "description": "A message (request, response, or notification) with `\"jsonrpc\": \"2.0\"` specified as\n[required by JSON-RPC 2.0 Specification][1].\n\n[1]: https://www.jsonrpc.org/specification#compatibility", + "properties": { + "jsonrpc": { + "enum": ["2.0"], + "type": "string" + } + }, + "required": ["jsonrpc"], + "type": "object", + "x-docs-ignore": true + }, "AgentRequest": { "anyOf": [ { "$ref": "#/$defs/WriteTextFileRequest", + "description": "Writes content to a text file in the client's file system.\n\nOnly available if the client advertises the `fs.writeTextFile` capability.\nAllows the agent to create or modify files within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)", "title": "WriteTextFileRequest" }, { "$ref": "#/$defs/ReadTextFileRequest", + "description": "Reads content from a text file in the client's file system.\n\nOnly available if the client advertises the `fs.readTextFile` capability.\nAllows the agent to access file contents within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)", "title": "ReadTextFileRequest" }, { "$ref": "#/$defs/RequestPermissionRequest", + "description": "Requests permission from the user for a tool call operation.\n\nCalled by the agent when it needs user authorization before executing\na potentially sensitive operation. The client should present the options\nto the user and return their decision.\n\nIf the client cancels the prompt turn via `session/cancel`, it MUST\nrespond to this request with `RequestPermissionOutcome::Cancelled`.\n\nSee protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)", "title": "RequestPermissionRequest" }, { "$ref": "#/$defs/CreateTerminalRequest", + "description": "Executes a command in a new terminal\n\nOnly available if the `terminal` Client capability is set to `true`.\n\nReturns a `TerminalId` that can be used with other terminal methods\nto get the current output, wait for exit, and kill the command.\n\nThe `TerminalId` can also be used to embed the terminal in a tool call\nby using the `ToolCallContent::Terminal` variant.\n\nThe Agent is responsible for releasing the terminal by using the `terminal/release`\nmethod.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)", "title": "CreateTerminalRequest" }, { "$ref": "#/$defs/TerminalOutputRequest", + "description": "Gets the terminal output and exit status\n\nReturns the current content in the terminal without waiting for the command to exit.\nIf the command has already exited, the exit status is included.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)", "title": "TerminalOutputRequest" }, { "$ref": "#/$defs/ReleaseTerminalRequest", + "description": "Releases a terminal\n\nThe command is killed if it hasn't exited yet. Use `terminal/wait_for_exit`\nto wait for the command to exit before releasing the terminal.\n\nAfter release, the `TerminalId` can no longer be used with other `terminal/*` methods,\nbut tool calls that already contain it, continue to display its output.\n\nThe `terminal/kill` method can be used to terminate the command without releasing\nthe terminal, allowing the Agent to call `terminal/output` and other methods.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)", "title": "ReleaseTerminalRequest" }, { "$ref": "#/$defs/WaitForTerminalExitRequest", + "description": "Waits for the terminal command to exit and return its exit status\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)", "title": "WaitForTerminalExitRequest" }, { "$ref": "#/$defs/KillTerminalCommandRequest", + "description": "Kills the terminal command without releasing the terminal\n\nWhile `terminal/release` will also kill the command, this method will keep\nthe `TerminalId` valid so it can be used with other methods.\n\nThis method can be helpful when implementing command timeouts which terminate\nthe command as soon as elapsed, and then get the final output so it can be sent\nto the model.\n\nNote: `terminal/release` when `TerminalId` is no longer needed.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)", "title": "KillTerminalCommandRequest" }, { + "description": "Handles extension method requests from the agent.\n\nAllows the Agent to send an arbitrary request that is not part of the ACP spec.\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", "title": "ExtMethodRequest" } ], @@ -144,32 +272,6 @@ }, "type": "object" }, - "AudioContent": { - "description": "Audio provided to or from an LLM.", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "annotations": { - "anyOf": [ - { - "$ref": "#/$defs/Annotations" - }, - { - "type": "null" - } - ] - }, - "data": { - "type": "string" - }, - "mimeType": { - "type": "string" - } - }, - "required": ["data", "mimeType"], - "type": "object" - }, "AuthMethod": { "description": "Describes an available authentication method.", "properties": { @@ -330,46 +432,173 @@ "anyOf": [ { "$ref": "#/$defs/CancelNotification", + "description": "Cancels ongoing operations for a session.\n\nThis is a notification sent by the client to cancel an ongoing prompt turn.\n\nUpon receiving this notification, the Agent SHOULD:\n- Stop all language model requests as soon as possible\n- Abort all tool call invocations in progress\n- Send any pending `session/update` notifications\n- Respond to the original `session/prompt` request with `StopReason::Cancelled`\n\nSee protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)", "title": "CancelNotification" }, { + "description": "Handles extension notifications from the client.\n\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", "title": "ExtNotification" } ], "description": "All possible notifications that a client can send to an agent.\n\nThis enum is used internally for routing RPC notifications. You typically won't need\nto use this directly - use the notification methods on the [`Agent`] trait instead.\n\nNotifications do not expect a response.", "x-docs-ignore": true }, + "ClientOutgoingMessage": { + "anyOf": [ + { + "properties": { + "id": { + "anyOf": [ + { + "title": "null", + "type": "null" + }, + { + "format": "int64", + "title": "number", + "type": "integer" + }, + { + "title": "string", + "type": "string" + } + ], + "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + }, + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { + "$ref": "#/$defs/ClientRequest" + }, + { + "type": "null" + } + ] + } + }, + "required": ["id", "method"], + "title": "Request", + "type": "object" + }, + { + "oneOf": [ + { + "properties": { + "result": { + "$ref": "#/$defs/ClientResponse" + } + }, + "required": ["result"], + "type": "object" + }, + { + "properties": { + "error": { + "$ref": "#/$defs/Error" + } + }, + "required": ["error"], + "type": "object" + } + ], + "properties": { + "id": { + "anyOf": [ + { + "title": "null", + "type": "null" + }, + { + "format": "int64", + "title": "number", + "type": "integer" + }, + { + "title": "string", + "type": "string" + } + ], + "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + } + }, + "required": ["id"], + "title": "Response", + "type": "object" + }, + { + "properties": { + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { + "$ref": "#/$defs/ClientNotification" + }, + { + "type": "null" + } + ] + } + }, + "required": ["method"], + "title": "Notification", + "type": "object" + } + ], + "description": "A message (request, response, or notification) with `\"jsonrpc\": \"2.0\"` specified as\n[required by JSON-RPC 2.0 Specification][1].\n\n[1]: https://www.jsonrpc.org/specification#compatibility", + "properties": { + "jsonrpc": { + "enum": ["2.0"], + "type": "string" + } + }, + "required": ["jsonrpc"], + "type": "object", + "x-docs-ignore": true + }, "ClientRequest": { "anyOf": [ { "$ref": "#/$defs/InitializeRequest", + "description": "Establishes the connection with a client and negotiates protocol capabilities.\n\nThis method is called once at the beginning of the connection to:\n- Negotiate the protocol version to use\n- Exchange capability information between client and agent\n- Determine available authentication methods\n\nThe agent should respond with its supported protocol version and capabilities.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)", "title": "InitializeRequest" }, { "$ref": "#/$defs/AuthenticateRequest", + "description": "Authenticates the client using the specified authentication method.\n\nCalled when the agent requires authentication before allowing session creation.\nThe client provides the authentication method ID that was advertised during initialization.\n\nAfter successful authentication, the client can proceed to create sessions with\n`new_session` without receiving an `auth_required` error.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)", "title": "AuthenticateRequest" }, { "$ref": "#/$defs/NewSessionRequest", + "description": "Creates a new conversation session with the agent.\n\nSessions represent independent conversation contexts with their own history and state.\n\nThe agent should:\n- Create a new session context\n- Connect to any specified MCP servers\n- Return a unique session ID for future requests\n\nMay return an `auth_required` error if the agent requires authentication.\n\nSee protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)", "title": "NewSessionRequest" }, { "$ref": "#/$defs/LoadSessionRequest", + "description": "Loads an existing session to resume a previous conversation.\n\nThis method is only available if the agent advertises the `loadSession` capability.\n\nThe agent should:\n- Restore the session context and conversation history\n- Connect to the specified MCP servers\n- Stream the entire conversation history back to the client via notifications\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)", "title": "LoadSessionRequest" }, { "$ref": "#/$defs/SetSessionModeRequest", + "description": "Sets the current mode for a session.\n\nAllows switching between different agent modes (e.g., \"ask\", \"architect\", \"code\")\nthat affect system prompts, tool availability, and permission behaviors.\n\nThe mode must be one of the modes advertised in `availableModes` during session\ncreation or loading. Agents may also change modes autonomously and notify the\nclient via `current_mode_update` notifications.\n\nThis method can be called at any time during a session, whether the Agent is\nidle or actively generating a response.\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)", "title": "SetSessionModeRequest" }, { "$ref": "#/$defs/PromptRequest", + "description": "Processes a user prompt within a session.\n\nThis method handles the whole lifecycle of a prompt:\n- Receives user messages with optional context (files, images, etc.)\n- Processes the prompt using language models\n- Reports language model content and tool calls to the Clients\n- Requests permission to run tools\n- Executes any requested tool calls\n- Returns when the turn is complete with a stop reason\n\nSee protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)", "title": "PromptRequest" }, { "$ref": "#/$defs/SetSessionModelRequest", + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSelect a model for a given session.", "title": "SetSessionModelRequest" }, { + "description": "Handles extension method requests from the client.\n\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", "title": "ExtMethodRequest" } ], @@ -642,29 +871,6 @@ "x-method": "terminal/create", "x-side": "client" }, - "EmbeddedResource": { - "description": "The contents of a resource, embedded into a prompt or tool call result.", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "annotations": { - "anyOf": [ - { - "$ref": "#/$defs/Annotations" - }, - { - "type": "null" - } - ] - }, - "resource": { - "$ref": "#/$defs/EmbeddedResourceResource" - } - }, - "required": ["resource"], - "type": "object" - }, "EmbeddedResourceResource": { "anyOf": [ { @@ -696,6 +902,25 @@ "required": ["name", "value"], "type": "object" }, + "Error": { + "description": "JSON-RPC error object.\n\nRepresents an error that occurred during method execution, following the\nJSON-RPC 2.0 error object specification with optional additional data.\n\nSee protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)", + "properties": { + "code": { + "description": "A number indicating the error type that occurred.\nThis must be an integer as defined in the JSON-RPC specification.", + "format": "int32", + "type": "integer" + }, + "data": { + "description": "Optional primitive or structured value that contains additional information about the error.\nThis may include debugging information or context-specific details." + }, + "message": { + "description": "A string providing a short description of the error.\nThe message should be limited to a concise single sentence.", + "type": "string" + } + }, + "required": ["code", "message"], + "type": "object" + }, "FileSystemCapability": { "description": "File system capabilities that a client may support.\n\nSee protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem)", "properties": { @@ -733,35 +958,6 @@ "required": ["name", "value"], "type": "object" }, - "ImageContent": { - "description": "An image provided to or from an LLM.", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "annotations": { - "anyOf": [ - { - "$ref": "#/$defs/Annotations" - }, - { - "type": "null" - } - ] - }, - "data": { - "type": "string" - }, - "mimeType": { - "type": "string" - }, - "uri": { - "type": ["string", "null"] - } - }, - "required": ["data", "mimeType"], - "type": "object" - }, "InitializeRequest": { "description": "Request parameters for the initialize method.\n\nSent by the client to establish connection and negotiate capabilities.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)", "properties": { @@ -1164,23 +1360,6 @@ } ] }, - "Plan": { - "description": "An execution plan for accomplishing complex tasks.\n\nPlans consist of multiple entries representing individual tasks or goals.\nAgents report plans to clients to provide visibility into their execution strategy.\nPlans can evolve during execution as the agent discovers new requirements or completes tasks.\n\nSee protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "entries": { - "description": "The list of tasks to be accomplished.\n\nWhen updating a plan, the agent must send a complete list of all entries\nwith their current status. The client replaces the entire plan with each update.", - "items": { - "$ref": "#/$defs/PlanEntry" - }, - "type": "array" - } - }, - "required": ["entries"], - "type": "object" - }, "PlanEntry": { "description": "A single entry in the execution plan.\n\nRepresents a task or goal that the assistant intends to accomplish\nas part of fulfilling the user's request.\nSee protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)", "properties": { @@ -1440,8 +1619,64 @@ "description": "The session ID for this request." }, "toolCall": { - "$ref": "#/$defs/ToolCallUpdate", - "description": "Details about the tool call requiring permission." + "description": "Details about the tool call requiring permission.", + "properties": { + "_meta": { + "description": "Extension point for implementations" + }, + "content": { + "description": "Replace the content collection.", + "items": { + "$ref": "#/$defs/ToolCallContent" + }, + "type": ["array", "null"] + }, + "kind": { + "anyOf": [ + { + "$ref": "#/$defs/ToolKind" + }, + { + "type": "null" + } + ], + "description": "Update the tool kind." + }, + "locations": { + "description": "Replace the locations collection.", + "items": { + "$ref": "#/$defs/ToolCallLocation" + }, + "type": ["array", "null"] + }, + "rawInput": { + "description": "Update the raw input." + }, + "rawOutput": { + "description": "Update the raw output." + }, + "status": { + "anyOf": [ + { + "$ref": "#/$defs/ToolCallStatus" + }, + { + "type": "null" + } + ], + "description": "Update the execution status." + }, + "title": { + "description": "Update the human-readable title.", + "type": ["string", "null"] + }, + "toolCallId": { + "$ref": "#/$defs/ToolCallId", + "description": "The ID of the tool call being updated." + } + }, + "required": ["toolCallId"], + "type": "object" } }, "required": ["sessionId", "toolCall", "options"], @@ -1465,45 +1700,6 @@ "x-method": "session/request_permission", "x-side": "client" }, - "ResourceLink": { - "description": "A resource that the server is capable of reading, included in a prompt or tool call result.", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "annotations": { - "anyOf": [ - { - "$ref": "#/$defs/Annotations" - }, - { - "type": "null" - } - ] - }, - "description": { - "type": ["string", "null"] - }, - "mimeType": { - "type": ["string", "null"] - }, - "name": { - "type": "string" - }, - "size": { - "format": "int64", - "type": ["integer", "null"] - }, - "title": { - "type": ["string", "null"] - }, - "uri": { - "type": "string" - } - }, - "required": ["name", "uri"], - "type": "object" - }, "Role": { "description": "The sender or recipient of messages and data in a conversation.", "enum": ["assistant", "user"], @@ -1604,8 +1800,12 @@ { "description": "A chunk of the user's message being streamed.", "properties": { + "_meta": { + "description": "Extension point for implementations" + }, "content": { - "$ref": "#/$defs/ContentBlock" + "$ref": "#/$defs/ContentBlock", + "description": "A single item of content" }, "sessionUpdate": { "const": "user_message_chunk", @@ -1618,8 +1818,12 @@ { "description": "A chunk of the agent's response being streamed.", "properties": { + "_meta": { + "description": "Extension point for implementations" + }, "content": { - "$ref": "#/$defs/ContentBlock" + "$ref": "#/$defs/ContentBlock", + "description": "A single item of content" }, "sessionUpdate": { "const": "agent_message_chunk", @@ -1632,8 +1836,12 @@ { "description": "A chunk of the agent's internal reasoning being streamed.", "properties": { + "_meta": { + "description": "Extension point for implementations" + }, "content": { - "$ref": "#/$defs/ContentBlock" + "$ref": "#/$defs/ContentBlock", + "description": "A single item of content" }, "sessionUpdate": { "const": "agent_thought_chunk", @@ -1781,7 +1989,11 @@ { "description": "Available commands are ready or have changed", "properties": { + "_meta": { + "description": "Extension point for implementations" + }, "availableCommands": { + "description": "Commands the agent can execute", "items": { "$ref": "#/$defs/AvailableCommand" }, @@ -1798,8 +2010,12 @@ { "description": "The current mode of the session has changed\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)", "properties": { + "_meta": { + "description": "Extension point for implementations" + }, "currentModeId": { - "$ref": "#/$defs/SessionModeId" + "$ref": "#/$defs/SessionModeId", + "description": "The ID of the current mode" }, "sessionUpdate": { "const": "current_mode_update", @@ -1971,29 +2187,6 @@ "x-method": "terminal/output", "x-side": "client" }, - "TextContent": { - "description": "Text provided to or from an LLM.", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "annotations": { - "anyOf": [ - { - "$ref": "#/$defs/Annotations" - }, - { - "type": "null" - } - ] - }, - "text": { - "type": "string" - } - }, - "required": ["text"], - "type": "object" - }, "TextResourceContents": { "description": "Text-based resource contents.", "properties": { @@ -2013,52 +2206,6 @@ "required": ["text", "uri"], "type": "object" }, - "ToolCall": { - "description": "Represents a tool call that the language model has requested.\n\nTool calls are actions that the agent executes on behalf of the language model,\nsuch as reading files, executing code, or fetching data from external sources.\n\nSee protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls)", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "content": { - "description": "Content produced by the tool call.", - "items": { - "$ref": "#/$defs/ToolCallContent" - }, - "type": "array" - }, - "kind": { - "$ref": "#/$defs/ToolKind", - "description": "The category of tool being invoked.\nHelps clients choose appropriate icons and UI treatment." - }, - "locations": { - "description": "File locations affected by this tool call.\nEnables \"follow-along\" features in clients.", - "items": { - "$ref": "#/$defs/ToolCallLocation" - }, - "type": "array" - }, - "rawInput": { - "description": "Raw input parameters sent to the tool." - }, - "rawOutput": { - "description": "Raw output returned by the tool." - }, - "status": { - "$ref": "#/$defs/ToolCallStatus", - "description": "Current execution status of the tool call." - }, - "title": { - "description": "Human-readable title describing what the tool is doing.", - "type": "string" - }, - "toolCallId": { - "$ref": "#/$defs/ToolCallId", - "description": "Unique identifier for this tool call within the session." - } - }, - "required": ["toolCallId", "title"], - "type": "object" - }, "ToolCallContent": { "description": "Content produced by a tool call.\n\nTool calls can produce different types of content including\nstandard content blocks (text, images) or file diffs.\n\nSee protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content)", "oneOf": [ @@ -2168,66 +2315,6 @@ } ] }, - "ToolCallUpdate": { - "description": "An update to an existing tool call.\n\nUsed to report progress and results as tools execute. All fields except\nthe tool call ID are optional - only changed fields need to be included.\n\nSee protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating)", - "properties": { - "_meta": { - "description": "Extension point for implementations" - }, - "content": { - "description": "Replace the content collection.", - "items": { - "$ref": "#/$defs/ToolCallContent" - }, - "type": ["array", "null"] - }, - "kind": { - "anyOf": [ - { - "$ref": "#/$defs/ToolKind" - }, - { - "type": "null" - } - ], - "description": "Update the tool kind." - }, - "locations": { - "description": "Replace the locations collection.", - "items": { - "$ref": "#/$defs/ToolCallLocation" - }, - "type": ["array", "null"] - }, - "rawInput": { - "description": "Update the raw input." - }, - "rawOutput": { - "description": "Update the raw output." - }, - "status": { - "anyOf": [ - { - "$ref": "#/$defs/ToolCallStatus" - }, - { - "type": "null" - } - ], - "description": "Update the execution status." - }, - "title": { - "description": "Update the human-readable title.", - "type": ["string", "null"] - }, - "toolCallId": { - "$ref": "#/$defs/ToolCallId", - "description": "The ID of the tool call being updated." - } - }, - "required": ["toolCallId"], - "type": "object" - }, "ToolKind": { "description": "Categories of tools that can be invoked.\n\nTool kinds help clients choose appropriate icons and optimize how they\ndisplay tool execution progress.\n\nSee protocol docs: [Creating](https://agentclientprotocol.com/protocol/tool-calls#creating)", "oneOf": [ @@ -2363,28 +2450,12 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "anyOf": [ { - "$ref": "#/$defs/AgentRequest", - "title": "ClientRequest" - }, - { - "$ref": "#/$defs/ClientResponse", - "title": "ClientResponse" - }, - { - "$ref": "#/$defs/ClientNotification", - "title": "ClientNotification" - }, - { - "$ref": "#/$defs/ClientRequest", - "title": "AgentRequest" - }, - { - "$ref": "#/$defs/AgentResponse", - "title": "AgentResponse" + "$ref": "#/$defs/AgentOutgoingMessage", + "title": "AgentOutgoingMessage" }, { - "$ref": "#/$defs/AgentNotification", - "title": "AgentNotification" + "$ref": "#/$defs/ClientOutgoingMessage", + "title": "ClientOutgoingMessage" } ] } diff --git a/scripts/generate.js b/scripts/generate.js index 501970b..4d38046 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -2,10 +2,60 @@ import { compile } from "json-schema-to-typescript"; import { generate } from "ts-to-zod"; -import fs from "fs"; +import * as fs from "fs/promises"; +import { dirname } from "path"; -const jsonSchema = JSON.parse(fs.readFileSync("./schema/schema.json", "utf8")); -const metadata = JSON.parse(fs.readFileSync("./schema/meta.json", "utf8")); +const CURRENT_SCHEMA_RELEASE = "v0.5.0"; + +await downloadSchemas(CURRENT_SCHEMA_RELEASE); + +/** + * Downloads a file from a URL to a local path + * @param {string} url - The URL to download from + * @param {string} outputPath - The local path to save the file + */ +async function downloadFile(url, outputPath) { + await fs.mkdir(dirname(outputPath), { recursive: true }); + + const response = await fetch(url); + + if (response.status === 302 || response.status === 301) { + // Follow redirects + await downloadFile(response.headers.location, outputPath); + return; + } + + if (response.status !== 200) { + throw new Error(`Failed to download ${url}: ${response.status}`); + } + + await fs.writeFile(outputPath, response.body); +} + +/** + * Downloads schema files from a GitHub release + * @param {string} tag - The GitHub release tag (e.g., "v0.5.0") + */ +async function downloadSchemas(tag) { + const baseUrl = `https://github.com/agentclientprotocol/agent-client-protocol/releases/download/${tag}`; + const files = [ + { url: `${baseUrl}/schema.json`, path: "./schema/schema.json" }, + { url: `${baseUrl}/meta.json`, path: "./schema/meta.json" }, + ]; + + console.log(`Downloading schemas from release ${tag}...`); + + for (const file of files) { + await downloadFile(file.url, file.path); + } + + console.log("Schema files downloaded successfully\n"); +} + +const jsonSchema = JSON.parse( + await fs.readFile("./schema/schema.json", "utf8"), +); +const metadata = JSON.parse(await fs.readFile("./schema/meta.json", "utf8")); const tsSrc = await compile(jsonSchema, "Agent Client Protocol", { additionalProperties: false, @@ -65,4 +115,4 @@ function markZodSchemasAsInternal(src) { return src.replace(/(export const \w+Schema = )/g, "/** @internal */\n$1"); } -fs.writeFileSync("src/schema.ts", schemaTs, "utf8"); +await fs.writeFile("src/schema.ts", schemaTs, "utf8"); diff --git a/src/schema.ts b/src/schema.ts index 4bd3b6d..2276f96 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -25,13 +25,17 @@ export const PROTOCOL_VERSION = 1; import { z } from "zod"; -export type AgentClientProtocol = - | ClientRequest - | ClientResponse - | ClientNotification - | AgentRequest - | AgentResponse - | AgentNotification; +export type AgentClientProtocol = AgentOutgoingMessage | ClientOutgoingMessage; +/** + * A message (request, response, or notification) with `"jsonrpc": "2.0"` specified as + * [required by JSON-RPC 2.0 Specification][1]. + * + * [1]: https://www.jsonrpc.org/specification#compatibility + */ +export type AgentOutgoingMessage = Request | Response | Notification; +export type Null = null; +export type Number = number; +export type String = string; /** * All possible requests that an agent can send to a client. * @@ -41,7 +45,7 @@ export type AgentClientProtocol = * This enum encompasses all method calls from agent to client. */ /** @internal */ -export type ClientRequest = +export type AgentRequest = | WriteTextFileRequest | ReadTextFileRequest | RequestPermissionRequest @@ -62,20 +66,7 @@ export type ClientRequest = export type ToolCallContent = | { /** - * Content blocks represent displayable information in the Agent Client Protocol. - * - * They provide a structured way to handle various types of user-facing content—whether - * it's text from language models, images for analysis, or embedded resources for context. - * - * Content blocks appear in: - * - User prompts sent via `session/prompt` - * - Language model output streamed through `session/update` notifications - * - Progress updates and results from tool calls - * - * This structure is compatible with the Model Context Protocol (MCP), enabling - * agents to seamlessly forward content from MCP tool outputs without transformation. - * - * See protocol docs: [Content](https://agentclientprotocol.com/protocol/content) + * The actual content block. */ content: | { @@ -205,35 +196,59 @@ export type ToolKind = * See protocol docs: [Status](https://agentclientprotocol.com/protocol/tool-calls#status) */ export type ToolCallStatus = "pending" | "in_progress" | "completed" | "failed"; +export type Response = + | { + result: AgentResponse; + } + | { + error: Error; + }; /** - * All possible responses that a client can send to an agent. + * All possible responses that an agent can send to a client. * * This enum is used internally for routing RPC responses. You typically won't need * to use this directly - the responses are handled automatically by the connection. * - * These are responses to the corresponding `AgentRequest` variants. + * These are responses to the corresponding `ClientRequest` variants. */ /** @internal */ -export type ClientResponse = - | WriteTextFileResponse - | ReadTextFileResponse - | RequestPermissionResponse - | CreateTerminalResponse - | TerminalOutputResponse - | ReleaseTerminalResponse - | WaitForTerminalExitResponse - | KillTerminalResponse +export type AgentResponse = + | InitializeResponse + | AuthenticateResponse + | NewSessionResponse + | LoadSessionResponse + | SetSessionModeResponse + | PromptResponse + | SetSessionModelResponse | ExtMethodResponse; /** - * All possible notifications that a client can send to an agent. + * Unique identifier for a Session Mode. + */ +export type SessionModeId = string; +/** + * All possible notifications that an agent can send to a client. * * This enum is used internally for routing RPC notifications. You typically won't need - * to use this directly - use the notification methods on the [`Agent`] trait instead. + * to use this directly - use the notification methods on the [`Client`] trait instead. * * Notifications do not expect a response. */ /** @internal */ -export type ClientNotification = CancelNotification | ExtNotification; +export type AgentNotification = SessionNotification | ExtNotification; +/** + * The input specification for a command. + */ +export type AvailableCommandInput = UnstructuredCommandInput; +/** + * A message (request, response, or notification) with `"jsonrpc": "2.0"` specified as + * [required by JSON-RPC 2.0 Specification][1]. + * + * [1]: https://www.jsonrpc.org/specification#compatibility + */ +export type ClientOutgoingMessage = Request1 | Response1 | Notification1; +export type Null1 = null; +export type Number1 = number; +export type String1 = string; /** * All possible requests that a client can send to an agent. * @@ -243,7 +258,7 @@ export type ClientNotification = CancelNotification | ExtNotification; * This enum encompasses all method calls from client to agent. */ /** @internal */ -export type AgentRequest = +export type ClientRequest = | InitializeRequest | AuthenticateRequest | NewSessionRequest @@ -372,47 +387,66 @@ export type ContentBlock = resource: EmbeddedResourceResource; type: "resource"; }; +export type Response1 = + | { + result: ClientResponse; + } + | { + error: Error; + }; /** - * All possible responses that an agent can send to a client. + * All possible responses that a client can send to an agent. * * This enum is used internally for routing RPC responses. You typically won't need * to use this directly - the responses are handled automatically by the connection. * - * These are responses to the corresponding `ClientRequest` variants. + * These are responses to the corresponding `AgentRequest` variants. */ /** @internal */ -export type AgentResponse = - | InitializeResponse - | AuthenticateResponse - | NewSessionResponse - | LoadSessionResponse - | SetSessionModeResponse - | PromptResponse - | SetSessionModelResponse +export type ClientResponse = + | WriteTextFileResponse + | ReadTextFileResponse + | RequestPermissionResponse + | CreateTerminalResponse + | TerminalOutputResponse + | ReleaseTerminalResponse + | WaitForTerminalExitResponse + | KillTerminalResponse | ExtMethodResponse1; /** - * Unique identifier for a Session Mode. - */ -export type SessionModeId = string; -/** - * All possible notifications that an agent can send to a client. + * All possible notifications that a client can send to an agent. * * This enum is used internally for routing RPC notifications. You typically won't need - * to use this directly - use the notification methods on the [`Client`] trait instead. + * to use this directly - use the notification methods on the [`Agent`] trait instead. * * Notifications do not expect a response. */ /** @internal */ -export type AgentNotification = SessionNotification | ExtNotification1; -/** - * The input specification for a command. - */ -export type AvailableCommandInput = UnstructuredCommandInput; +export type ClientNotification = CancelNotification | ExtNotification1; +export interface Request { + /** + * JSON RPC Request Id + * + * An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] + * + * The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects. + * + * [1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling. + * + * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. + */ + id: Null | Number | String; + method: string; + params?: AgentRequest | null; +} /** - * Request to write content to a text file. + * Writes content to a text file in the client's file system. + * + * Only available if the client advertises the `fs.writeTextFile` capability. + * Allows the agent to create or modify files within the client's environment. * - * Only available if the client supports the `fs.writeTextFile` capability. + * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client) */ export interface WriteTextFileRequest { /** @@ -435,9 +469,12 @@ export interface WriteTextFileRequest { sessionId: string; } /** - * Request to read content from a text file. + * Reads content from a text file in the client's file system. * - * Only available if the client supports the `fs.readTextFile` capability. + * Only available if the client advertises the `fs.readTextFile` capability. + * Allows the agent to access file contents within the client's environment. + * + * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client) */ export interface ReadTextFileRequest { /** @@ -464,9 +501,14 @@ export interface ReadTextFileRequest { sessionId: string; } /** - * Request for user permission to execute a tool call. + * Requests permission from the user for a tool call operation. + * + * Called by the agent when it needs user authorization before executing + * a potentially sensitive operation. The client should present the options + * to the user and return their decision. * - * Sent when the agent needs authorization before performing a sensitive operation. + * If the client cancels the prompt turn via `session/cancel`, it MUST + * respond to this request with `RequestPermissionOutcome::Cancelled`. * * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission) */ @@ -485,7 +527,53 @@ export interface RequestPermissionRequest { * The session ID for this request. */ sessionId: string; - toolCall: ToolCallUpdate; + /** + * Details about the tool call requiring permission. + */ + toolCall: { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * Replace the content collection. + */ + content?: ToolCallContent[] | null; + /** + * Update the tool kind. + */ + kind?: ToolKind | null; + /** + * Replace the locations collection. + */ + locations?: ToolCallLocation[] | null; + /** + * Update the raw input. + */ + rawInput?: { + [k: string]: unknown; + }; + /** + * Update the raw output. + */ + rawOutput?: { + [k: string]: unknown; + }; + /** + * Update the execution status. + */ + status?: ToolCallStatus | null; + /** + * Update the human-readable title. + */ + title?: string | null; + /** + * The ID of the tool call being updated. + */ + toolCallId: string; + }; } /** * An option presented to the user when requesting permission. @@ -510,53 +598,6 @@ export interface PermissionOption { */ optionId: string; } -/** - * Details about the tool call requiring permission. - */ -export interface ToolCallUpdate { - /** - * Extension point for implementations - */ - _meta?: { - [k: string]: unknown; - }; - /** - * Replace the content collection. - */ - content?: ToolCallContent[] | null; - /** - * Update the tool kind. - */ - kind?: ToolKind | null; - /** - * Replace the locations collection. - */ - locations?: ToolCallLocation[] | null; - /** - * Update the raw input. - */ - rawInput?: { - [k: string]: unknown; - }; - /** - * Update the raw output. - */ - rawOutput?: { - [k: string]: unknown; - }; - /** - * Update the execution status. - */ - status?: ToolCallStatus | null; - /** - * Update the human-readable title. - */ - title?: string | null; - /** - * The ID of the tool call being updated. - */ - toolCallId: string; -} /** * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed */ @@ -624,7 +665,20 @@ export interface ToolCallLocation { path: string; } /** - * Request to create a new terminal and execute a command. + * Executes a command in a new terminal + * + * Only available if the `terminal` Client capability is set to `true`. + * + * Returns a `TerminalId` that can be used with other terminal methods + * to get the current output, wait for exit, and kill the command. + * + * The `TerminalId` can also be used to embed the terminal in a tool call + * by using the `ToolCallContent::Terminal` variant. + * + * The Agent is responsible for releasing the terminal by using the `terminal/release` + * method. + * + * See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals) */ export interface CreateTerminalRequest { /** @@ -685,7 +739,12 @@ export interface EnvVariable { value: string; } /** - * Request to get the current output and status of a terminal. + * Gets the terminal output and exit status + * + * Returns the current content in the terminal without waiting for the command to exit. + * If the command has already exited, the exit status is included. + * + * See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals) */ export interface TerminalOutputRequest { /** @@ -704,7 +763,18 @@ export interface TerminalOutputRequest { terminalId: string; } /** - * Request to release a terminal and free its resources. + * Releases a terminal + * + * The command is killed if it hasn't exited yet. Use `terminal/wait_for_exit` + * to wait for the command to exit before releasing the terminal. + * + * After release, the `TerminalId` can no longer be used with other `terminal/*` methods, + * but tool calls that already contain it, continue to display its output. + * + * The `terminal/kill` method can be used to terminate the command without releasing + * the terminal, allowing the Agent to call `terminal/output` and other methods. + * + * See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals) */ export interface ReleaseTerminalRequest { /** @@ -723,7 +793,9 @@ export interface ReleaseTerminalRequest { terminalId: string; } /** - * Request to wait for a terminal command to exit. + * Waits for the terminal command to exit and return its exit status + * + * See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals) */ export interface WaitForTerminalExitRequest { /** @@ -742,7 +814,18 @@ export interface WaitForTerminalExitRequest { terminalId: string; } /** - * Request to kill a terminal command without releasing the terminal. + * Kills the terminal command without releasing the terminal + * + * While `terminal/release` will also kill the command, this method will keep + * the `TerminalId` valid so it can be used with other methods. + * + * This method can be helpful when implementing command timeouts which terminate + * the command as soon as elapsed, and then get the final output so it can be sent + * to the model. + * + * Note: `terminal/release` when `TerminalId` is no longer needed. + * + * See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals) */ export interface KillTerminalCommandRequest { /** @@ -760,36 +843,49 @@ export interface KillTerminalCommandRequest { */ terminalId: string; } +/** + * Handles extension method requests from the agent. + * + * Allows the Agent to send an arbitrary request that is not part of the ACP spec. + * Extension methods provide a way to add custom functionality while maintaining + * protocol compatibility. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + */ export interface ExtMethodRequest { [k: string]: unknown; } /** - * Response to `fs/write_text_file` + * Response from the initialize method. + * + * Contains the negotiated protocol version and agent capabilities. + * + * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) */ -export interface WriteTextFileResponse { +export interface InitializeResponse { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; -} -/** - * Response containing the contents of a text file. - */ -export interface ReadTextFileResponse { + agentCapabilities?: AgentCapabilities; /** - * Extension point for implementations + * Authentication methods supported by the agent. */ - _meta?: { - [k: string]: unknown; - }; - content: string; + authMethods?: AuthMethod[]; + /** + * The protocol version the client specified if supported by the agent, + * or the latest protocol version supported by the agent. + * + * The client should disconnect, if it doesn't support this version. + */ + protocolVersion: number; } /** - * Response to a permission request. + * Capabilities supported by the agent. */ -export interface RequestPermissionResponse { +export interface AgentCapabilities { /** * Extension point for implementations */ @@ -797,24 +893,16 @@ export interface RequestPermissionResponse { [k: string]: unknown; }; /** - * The user's decision on the permission request. + * Whether the agent supports `session/load`. */ - outcome: - | { - outcome: "cancelled"; - } - | { - /** - * The ID of the option the user selected. - */ - optionId: string; - outcome: "selected"; - }; + loadSession?: boolean; + mcpCapabilities?: McpCapabilities; + promptCapabilities?: PromptCapabilities; } /** - * Response containing the ID of the created terminal. + * MCP capabilities supported by the agent. */ -export interface CreateTerminalResponse { +export interface McpCapabilities { /** * Extension point for implementations */ @@ -822,14 +910,18 @@ export interface CreateTerminalResponse { [k: string]: unknown; }; /** - * The unique identifier for the created terminal. + * Agent supports [`McpServer::Http`]. */ - terminalId: string; + http?: boolean; + /** + * Agent supports [`McpServer::Sse`]. + */ + sse?: boolean; } /** - * Response containing the terminal output and exit status. + * Prompt capabilities supported by the agent. */ -export interface TerminalOutputResponse { +export interface PromptCapabilities { /** * Extension point for implementations */ @@ -837,22 +929,25 @@ export interface TerminalOutputResponse { [k: string]: unknown; }; /** - * Exit status if the command has completed. + * Agent supports [`ContentBlock::Audio`]. */ - exitStatus?: TerminalExitStatus | null; + audio?: boolean; /** - * The terminal output captured so far. + * Agent supports embedded context in `session/prompt` requests. + * + * When enabled, the Client is allowed to include [`ContentBlock::Resource`] + * in prompt requests for pieces of context that are referenced in the message. */ - output: string; + embeddedContext?: boolean; /** - * Whether the output was truncated due to byte limits. + * Agent supports [`ContentBlock::Image`]. */ - truncated: boolean; + image?: boolean; } /** - * Exit status of a terminal command. + * Describes an available authentication method. */ -export interface TerminalExitStatus { +export interface AuthMethod { /** * Extension point for implementations */ @@ -860,18 +955,22 @@ export interface TerminalExitStatus { [k: string]: unknown; }; /** - * The process exit code (may be null if terminated by signal). + * Optional description providing more details about this authentication method. */ - exitCode?: number | null; + description?: string | null; /** - * The signal that terminated the process (may be null if exited normally). + * Unique identifier for this authentication method. */ - signal?: string | null; + id: string; + /** + * Human-readable name of the authentication method. + */ + name: string; } /** - * Response to terminal/release method + * Response to authenticate method */ -export interface ReleaseTerminalResponse { +export interface AuthenticateResponse { /** * Extension point for implementations */ @@ -880,9 +979,11 @@ export interface ReleaseTerminalResponse { }; } /** - * Response containing the exit status of a terminal command. + * Response from creating a new session. + * + * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) */ -export interface WaitForTerminalExitResponse { +export interface NewSessionResponse { /** * Extension point for implementations */ @@ -890,34 +991,34 @@ export interface WaitForTerminalExitResponse { [k: string]: unknown; }; /** - * The process exit code (may be null if terminated by signal). - */ - exitCode?: number | null; + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Initial model state if supported by the Agent + */ + models?: SessionModelState | null; /** - * The signal that terminated the process (may be null if exited normally). + * Initial mode state if supported by the Agent + * + * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ - signal?: string | null; -} -/** - * Response to terminal/kill command method - */ -export interface KillTerminalResponse { + modes?: SessionModeState | null; /** - * Extension point for implementations + * Unique identifier for the created session. + * + * Used in all subsequent requests for this conversation. */ - _meta?: { - [k: string]: unknown; - }; -} -export interface ExtMethodResponse { - [k: string]: unknown; + sessionId: string; } /** - * Notification to cancel ongoing operations for a session. + * **UNSTABLE** * - * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation) + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * The set of models and the one currently active. */ -export interface CancelNotification { +export interface SessionModelState { /** * Extension point for implementations */ @@ -925,54 +1026,45 @@ export interface CancelNotification { [k: string]: unknown; }; /** - * The ID of the session to cancel operations for. + * The set of models that the Agent can use */ - sessionId: string; -} -export interface ExtNotification { - [k: string]: unknown; + availableModels: ModelInfo[]; + /** + * The current model the Agent is in. + */ + currentModelId: string; } /** - * Request parameters for the initialize method. + * **UNSTABLE** * - * Sent by the client to establish connection and negotiate capabilities. + * This capability is not part of the spec yet, and may be removed or changed at any point. * - * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) + * Information about a selectable model. */ -export interface InitializeRequest { +export interface ModelInfo { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; - clientCapabilities?: ClientCapabilities; /** - * The latest protocol version supported by the client. + * Optional description of the model. */ - protocolVersion: number; -} -/** - * Capabilities supported by the client. - */ -export interface ClientCapabilities { + description?: string | null; /** - * Extension point for implementations + * Unique identifier for the model. */ - _meta?: { - [k: string]: unknown; - }; - fs?: FileSystemCapability; + modelId: string; /** - * Whether the Client support all `terminal/*` methods. + * Human-readable name of the model. */ - terminal?: boolean; + name: string; } /** - * File system capabilities supported by the client. - * Determines which file operations the agent can request. + * The set of modes and the one currently active. */ -export interface FileSystemCapability { +export interface SessionModeState { /** * Extension point for implementations */ @@ -980,57 +1072,34 @@ export interface FileSystemCapability { [k: string]: unknown; }; /** - * Whether the Client supports `fs/read_text_file` requests. - */ - readTextFile?: boolean; - /** - * Whether the Client supports `fs/write_text_file` requests. - */ - writeTextFile?: boolean; -} -/** - * Request parameters for the authenticate method. - * - * Specifies which authentication method to use. - */ -export interface AuthenticateRequest { - /** - * Extension point for implementations + * The set of modes that the Agent can operate in */ - _meta?: { - [k: string]: unknown; - }; + availableModes: SessionMode[]; /** - * The ID of the authentication method to use. - * Must be one of the methods advertised in the initialize response. + * Unique identifier for a Session Mode. */ - methodId: string; + currentModeId: string; } /** - * Request parameters for creating a new session. + * A mode the agent can operate in. * - * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) + * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ -export interface NewSessionRequest { +export interface SessionMode { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; - /** - * The working directory for this session. Must be an absolute path. - */ - cwd: string; - /** - * List of MCP (Model Context Protocol) servers the agent should connect to. - */ - mcpServers: McpServer[]; + description?: string | null; + id: SessionModeId; + name: string; } /** - * An HTTP header to set when making requests to the MCP server. + * Response from loading an existing session. */ -export interface HttpHeader { +export interface LoadSessionResponse { /** * Extension point for implementations */ @@ -1038,68 +1107,32 @@ export interface HttpHeader { [k: string]: unknown; }; /** - * The name of the HTTP header. + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Initial model state if supported by the Agent */ - name: string; + models?: SessionModelState | null; /** - * The value to set for the HTTP header. + * Initial mode state if supported by the Agent + * + * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ - value: string; + modes?: SessionModeState | null; } /** - * Stdio transport configuration - * - * All Agents MUST support this transport. + * Response to `session/set_mode` method. */ -export interface Stdio { - /** - * Command-line arguments to pass to the MCP server. - */ - args: string[]; - /** - * Path to the MCP server executable. - */ - command: string; - /** - * Environment variables to set when launching the MCP server. - */ - env: EnvVariable[]; - /** - * Human-readable name identifying this MCP server. - */ - name: string; +export interface SetSessionModeResponse { + meta?: unknown; } /** - * Request parameters for loading an existing session. - * - * Only available if the Agent supports the `loadSession` capability. + * Response from processing a user prompt. * - * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions) - */ -export interface LoadSessionRequest { - /** - * Extension point for implementations - */ - _meta?: { - [k: string]: unknown; - }; - /** - * The working directory for this session. - */ - cwd: string; - /** - * List of MCP servers to connect to for this session. - */ - mcpServers: McpServer[]; - /** - * The ID of the session to load. - */ - sessionId: string; -} -/** - * Request parameters for setting a session mode. + * See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion) */ -export interface SetSessionModeRequest { +export interface PromptResponse { /** * Extension point for implementations */ @@ -1107,106 +1140,473 @@ export interface SetSessionModeRequest { [k: string]: unknown; }; /** - * Unique identifier for a Session Mode. - */ - modeId: string; - /** - * The ID of the session to set the mode for. + * Indicates why the agent stopped processing the turn. */ - sessionId: string; + stopReason: + | "end_turn" + | "max_tokens" + | "max_turn_requests" + | "refusal" + | "cancelled"; } /** - * Request parameters for sending a user prompt to the agent. + * **UNSTABLE** * - * Contains the user's message and any additional context. + * This capability is not part of the spec yet, and may be removed or changed at any point. * - * See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message) + * Response to `session/set_model` method. */ -export interface PromptRequest { +export interface SetSessionModelResponse { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; - /** - * The blocks of content that compose the user's message. - * - * As a baseline, the Agent MUST support [`ContentBlock::Text`] and [`ContentBlock::ResourceLink`], - * while other variants are optionally enabled via [`PromptCapabilities`]. - * - * The Client MUST adapt its interface according to [`PromptCapabilities`]. - * - * The client MAY include referenced pieces of context as either - * [`ContentBlock::Resource`] or [`ContentBlock::ResourceLink`]. - * - * When available, [`ContentBlock::Resource`] is preferred - * as it avoids extra round-trips and allows the message to include - * pieces of context from sources the agent may not have access to. - */ - prompt: ContentBlock[]; - /** - * The ID of the session to send this user message to - */ - sessionId: string; +} +export interface ExtMethodResponse { + [k: string]: unknown; } /** - * **UNSTABLE** + * JSON-RPC error object. * - * This capability is not part of the spec yet, and may be removed or changed at any point. + * Represents an error that occurred during method execution, following the + * JSON-RPC 2.0 error object specification with optional additional data. * - * Request parameters for setting a session model. + * See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object) */ -export interface SetSessionModelRequest { +export interface Error { /** - * Extension point for implementations + * A number indicating the error type that occurred. + * This must be an integer as defined in the JSON-RPC specification. */ - _meta?: { - [k: string]: unknown; - }; + code: number; /** - * The ID of the model to set. + * Optional primitive or structured value that contains additional information about the error. + * This may include debugging information or context-specific details. */ - modelId: string; + data?: { + [k: string]: unknown; + }; /** - * The ID of the session to set the model for. + * A string providing a short description of the error. + * The message should be limited to a concise single sentence. */ - sessionId: string; + message: string; } -export interface ExtMethodRequest1 { - [k: string]: unknown; +export interface Notification { + method: string; + params?: AgentNotification | null; } /** - * Response from the initialize method. + * Handles session update notifications from the agent. * - * Contains the negotiated protocol version and agent capabilities. + * This is a notification endpoint (no response expected) that receives + * real-time updates about session progress, including message chunks, + * tool calls, and execution plans. * - * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) + * Note: Clients SHOULD continue accepting tool call updates even after + * sending a `session/cancel` notification, as the agent may send final + * updates before responding with the cancelled stop reason. + * + * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output) */ -export interface InitializeResponse { +export interface SessionNotification { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; - agentCapabilities?: AgentCapabilities; /** - * Authentication methods supported by the agent. + * The ID of the session this update pertains to. */ - authMethods?: AuthMethod[]; + sessionId: string; /** - * The protocol version the client specified if supported by the agent, - * or the latest protocol version supported by the agent. - * - * The client should disconnect, if it doesn't support this version. + * The actual update content. */ - protocolVersion: number; + update: + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * A single item of content + */ + content: + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + text: string; + type: "text"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + data: string; + mimeType: string; + type: "image"; + uri?: string | null; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + data: string; + mimeType: string; + type: "audio"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + description?: string | null; + mimeType?: string | null; + name: string; + size?: number | null; + title?: string | null; + type: "resource_link"; + uri: string; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + resource: EmbeddedResourceResource; + type: "resource"; + }; + sessionUpdate: "user_message_chunk"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * A single item of content + */ + content: + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + text: string; + type: "text"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + data: string; + mimeType: string; + type: "image"; + uri?: string | null; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + data: string; + mimeType: string; + type: "audio"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + description?: string | null; + mimeType?: string | null; + name: string; + size?: number | null; + title?: string | null; + type: "resource_link"; + uri: string; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + resource: EmbeddedResourceResource; + type: "resource"; + }; + sessionUpdate: "agent_message_chunk"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * A single item of content + */ + content: + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + text: string; + type: "text"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + data: string; + mimeType: string; + type: "image"; + uri?: string | null; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + data: string; + mimeType: string; + type: "audio"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + description?: string | null; + mimeType?: string | null; + name: string; + size?: number | null; + title?: string | null; + type: "resource_link"; + uri: string; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + annotations?: Annotations | null; + resource: EmbeddedResourceResource; + type: "resource"; + }; + sessionUpdate: "agent_thought_chunk"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * Content produced by the tool call. + */ + content?: ToolCallContent[]; + /** + * The category of tool being invoked. + * Helps clients choose appropriate icons and UI treatment. + */ + kind?: + | "read" + | "edit" + | "delete" + | "move" + | "search" + | "execute" + | "think" + | "fetch" + | "switch_mode" + | "other"; + /** + * File locations affected by this tool call. + * Enables "follow-along" features in clients. + */ + locations?: ToolCallLocation[]; + /** + * Raw input parameters sent to the tool. + */ + rawInput?: { + [k: string]: unknown; + }; + /** + * Raw output returned by the tool. + */ + rawOutput?: { + [k: string]: unknown; + }; + sessionUpdate: "tool_call"; + /** + * Current execution status of the tool call. + */ + status?: "pending" | "in_progress" | "completed" | "failed"; + /** + * Human-readable title describing what the tool is doing. + */ + title: string; + /** + * Unique identifier for this tool call within the session. + */ + toolCallId: string; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * Replace the content collection. + */ + content?: ToolCallContent[] | null; + /** + * Update the tool kind. + */ + kind?: ToolKind | null; + /** + * Replace the locations collection. + */ + locations?: ToolCallLocation[] | null; + /** + * Update the raw input. + */ + rawInput?: { + [k: string]: unknown; + }; + /** + * Update the raw output. + */ + rawOutput?: { + [k: string]: unknown; + }; + sessionUpdate: "tool_call_update"; + /** + * Update the execution status. + */ + status?: ToolCallStatus | null; + /** + * Update the human-readable title. + */ + title?: string | null; + /** + * The ID of the tool call being updated. + */ + toolCallId: string; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * The list of tasks to be accomplished. + * + * When updating a plan, the agent must send a complete list of all entries + * with their current status. The client replaces the entire plan with each update. + */ + entries: PlanEntry[]; + sessionUpdate: "plan"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * Commands the agent can execute + */ + availableCommands: AvailableCommand[]; + sessionUpdate: "available_commands_update"; + } + | { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * The ID of the current mode + */ + currentModeId: string; + sessionUpdate: "current_mode_update"; + }; } /** - * Capabilities supported by the agent. + * A single entry in the execution plan. + * + * Represents a task or goal that the assistant intends to accomplish + * as part of fulfilling the user's request. + * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries) */ -export interface AgentCapabilities { +export interface PlanEntry { /** * Extension point for implementations */ @@ -1214,16 +1614,23 @@ export interface AgentCapabilities { [k: string]: unknown; }; /** - * Whether the agent supports `session/load`. + * Human-readable description of what this task aims to accomplish. */ - loadSession?: boolean; - mcpCapabilities?: McpCapabilities; - promptCapabilities?: PromptCapabilities; + content: string; + /** + * The relative importance of this task. + * Used to indicate which tasks are most critical to the overall goal. + */ + priority: "high" | "medium" | "low"; + /** + * Current execution status of this task. + */ + status: "pending" | "in_progress" | "completed"; } /** - * MCP capabilities supported by the agent. + * Information about a command. */ -export interface McpCapabilities { +export interface AvailableCommand { /** * Extension point for implementations */ @@ -1231,44 +1638,101 @@ export interface McpCapabilities { [k: string]: unknown; }; /** - * Agent supports [`McpServer::Http`]. + * Human-readable description of what the command does. */ - http?: boolean; + description: string; /** - * Agent supports [`McpServer::Sse`]. + * Input for the command if required */ - sse?: boolean; + input?: AvailableCommandInput | null; + /** + * Command name (e.g., `create_plan`, `research_codebase`). + */ + name: string; } /** - * Prompt capabilities supported by the agent. + * All text that was typed after the command name is provided as input. */ -export interface PromptCapabilities { +export interface UnstructuredCommandInput { + /** + * A hint to display when the input hasn't been provided yet + */ + hint: string; +} +/** + * Handles extension notifications from the agent. + * + * Allows the Agent to send an arbitrary notification that is not part of the ACP spec. + * Extension notifications provide a way to send one-way messages for custom functionality + * while maintaining protocol compatibility. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + */ +export interface ExtNotification { + [k: string]: unknown; +} +export interface Request1 { + /** + * JSON RPC Request Id + * + * An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] + * + * The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects. + * + * [1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling. + * + * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. + */ + id: Null1 | Number1 | String1; + method: string; + params?: ClientRequest | null; +} +/** + * Establishes the connection with a client and negotiates protocol capabilities. + * + * This method is called once at the beginning of the connection to: + * - Negotiate the protocol version to use + * - Exchange capability information between client and agent + * - Determine available authentication methods + * + * The agent should respond with its supported protocol version and capabilities. + * + * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) + */ +export interface InitializeRequest { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; + clientCapabilities?: ClientCapabilities; /** - * Agent supports [`ContentBlock::Audio`]. + * The latest protocol version supported by the client. */ - audio?: boolean; + protocolVersion: number; +} +/** + * Capabilities supported by the client. + */ +export interface ClientCapabilities { /** - * Agent supports embedded context in `session/prompt` requests. - * - * When enabled, the Client is allowed to include [`ContentBlock::Resource`] - * in prompt requests for pieces of context that are referenced in the message. + * Extension point for implementations */ - embeddedContext?: boolean; + _meta?: { + [k: string]: unknown; + }; + fs?: FileSystemCapability; /** - * Agent supports [`ContentBlock::Image`]. + * Whether the Client support all `terminal/*` methods. */ - image?: boolean; + terminal?: boolean; } /** - * Describes an available authentication method. + * File system capabilities supported by the client. + * Determines which file operations the agent can request. */ -export interface AuthMethod { +export interface FileSystemCapability { /** * Extension point for implementations */ @@ -1276,35 +1740,53 @@ export interface AuthMethod { [k: string]: unknown; }; /** - * Optional description providing more details about this authentication method. - */ - description?: string | null; - /** - * Unique identifier for this authentication method. + * Whether the Client supports `fs/read_text_file` requests. */ - id: string; + readTextFile?: boolean; /** - * Human-readable name of the authentication method. + * Whether the Client supports `fs/write_text_file` requests. */ - name: string; + writeTextFile?: boolean; } /** - * Response to authenticate method + * Authenticates the client using the specified authentication method. + * + * Called when the agent requires authentication before allowing session creation. + * The client provides the authentication method ID that was advertised during initialization. + * + * After successful authentication, the client can proceed to create sessions with + * `new_session` without receiving an `auth_required` error. + * + * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) */ -export interface AuthenticateResponse { +export interface AuthenticateRequest { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; + /** + * The ID of the authentication method to use. + * Must be one of the methods advertised in the initialize response. + */ + methodId: string; } /** - * Response from creating a new session. + * Creates a new conversation session with the agent. * - * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) + * Sessions represent independent conversation contexts with their own history and state. + * + * The agent should: + * - Create a new session context + * - Connect to any specified MCP servers + * - Return a unique session ID for future requests + * + * May return an `auth_required` error if the agent requires authentication. + * + * See protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup) */ -export interface NewSessionResponse { +export interface NewSessionRequest { /** * Extension point for implementations */ @@ -1312,34 +1794,18 @@ export interface NewSessionResponse { [k: string]: unknown; }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Initial model state if supported by the Agent - */ - models?: SessionModelState | null; - /** - * Initial mode state if supported by the Agent - * - * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) + * The working directory for this session. Must be an absolute path. */ - modes?: SessionModeState | null; + cwd: string; /** - * Unique identifier for the created session. - * - * Used in all subsequent requests for this conversation. + * List of MCP (Model Context Protocol) servers the agent should connect to. */ - sessionId: string; + mcpServers: McpServer[]; } /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * The set of models and the one currently active. + * An HTTP header to set when making requests to the MCP server. */ -export interface SessionModelState { +export interface HttpHeader { /** * Extension point for implementations */ @@ -1347,22 +1813,50 @@ export interface SessionModelState { [k: string]: unknown; }; /** - * The set of models that the Agent can use + * The name of the HTTP header. */ - availableModels: ModelInfo[]; + name: string; /** - * The current model the Agent is in. + * The value to set for the HTTP header. */ - currentModelId: string; + value: string; } /** - * **UNSTABLE** + * Stdio transport configuration * - * This capability is not part of the spec yet, and may be removed or changed at any point. + * All Agents MUST support this transport. + */ +export interface Stdio { + /** + * Command-line arguments to pass to the MCP server. + */ + args: string[]; + /** + * Path to the MCP server executable. + */ + command: string; + /** + * Environment variables to set when launching the MCP server. + */ + env: EnvVariable[]; + /** + * Human-readable name identifying this MCP server. + */ + name: string; +} +/** + * Loads an existing session to resume a previous conversation. * - * Information about a selectable model. + * This method is only available if the agent advertises the `loadSession` capability. + * + * The agent should: + * - Restore the session context and conversation history + * - Connect to the specified MCP servers + * - Stream the entire conversation history back to the client via notifications + * + * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions) */ -export interface ModelInfo { +export interface LoadSessionRequest { /** * Extension point for implementations */ @@ -1370,22 +1864,34 @@ export interface ModelInfo { [k: string]: unknown; }; /** - * Optional description of the model. + * The working directory for this session. */ - description?: string | null; + cwd: string; /** - * Unique identifier for the model. + * List of MCP servers to connect to for this session. */ - modelId: string; + mcpServers: McpServer[]; /** - * Human-readable name of the model. + * The ID of the session to load. */ - name: string; + sessionId: string; } /** - * The set of modes and the one currently active. + * Sets the current mode for a session. + * + * Allows switching between different agent modes (e.g., "ask", "architect", "code") + * that affect system prompts, tool availability, and permission behaviors. + * + * The mode must be one of the modes advertised in `availableModes` during session + * creation or loading. Agents may also change modes autonomously and notify the + * client via `current_mode_update` notifications. + * + * This method can be called at any time during a session, whether the Agent is + * idle or actively generating a response. + * + * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ -export interface SessionModeState { +export interface SetSessionModeRequest { /** * Extension point for implementations */ @@ -1393,34 +1899,63 @@ export interface SessionModeState { [k: string]: unknown; }; /** - * The set of modes that the Agent can operate in + * Unique identifier for a Session Mode. */ - availableModes: SessionMode[]; + modeId: string; /** - * Unique identifier for a Session Mode. + * The ID of the session to set the mode for. */ - currentModeId: string; + sessionId: string; } /** - * A mode the agent can operate in. + * Processes a user prompt within a session. * - * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) + * This method handles the whole lifecycle of a prompt: + * - Receives user messages with optional context (files, images, etc.) + * - Processes the prompt using language models + * - Reports language model content and tool calls to the Clients + * - Requests permission to run tools + * - Executes any requested tool calls + * - Returns when the turn is complete with a stop reason + * + * See protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn) */ -export interface SessionMode { +export interface PromptRequest { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; - description?: string | null; - id: SessionModeId; - name: string; + /** + * The blocks of content that compose the user's message. + * + * As a baseline, the Agent MUST support [`ContentBlock::Text`] and [`ContentBlock::ResourceLink`], + * while other variants are optionally enabled via [`PromptCapabilities`]. + * + * The Client MUST adapt its interface according to [`PromptCapabilities`]. + * + * The client MAY include referenced pieces of context as either + * [`ContentBlock::Resource`] or [`ContentBlock::ResourceLink`]. + * + * When available, [`ContentBlock::Resource`] is preferred + * as it avoids extra round-trips and allows the message to include + * pieces of context from sources the agent may not have access to. + */ + prompt: ContentBlock[]; + /** + * The ID of the session to send this user message to + */ + sessionId: string; } /** - * Response from loading an existing session. + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Select a model for a given session. */ -export interface LoadSessionResponse { +export interface SetSessionModelRequest { /** * Extension point for implementations */ @@ -1428,74 +1963,52 @@ export interface LoadSessionResponse { [k: string]: unknown; }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Initial model state if supported by the Agent + * The ID of the model to set. */ - models?: SessionModelState | null; + modelId: string; /** - * Initial mode state if supported by the Agent - * - * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) + * The ID of the session to set the model for. */ - modes?: SessionModeState | null; + sessionId: string; } /** - * Response to `session/set_mode` method. + * Handles extension method requests from the client. + * + * Extension methods provide a way to add custom functionality while maintaining + * protocol compatibility. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) */ -export interface SetSessionModeResponse { - meta?: unknown; +export interface ExtMethodRequest1 { + [k: string]: unknown; } /** - * Response from processing a user prompt. - * - * See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion) + * Response to `fs/write_text_file` */ -export interface PromptResponse { +export interface WriteTextFileResponse { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; - /** - * Indicates why the agent stopped processing the turn. - */ - stopReason: - | "end_turn" - | "max_tokens" - | "max_turn_requests" - | "refusal" - | "cancelled"; } /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Response to `session/set_model` method. + * Response containing the contents of a text file. */ -export interface SetSessionModelResponse { +export interface ReadTextFileResponse { /** * Extension point for implementations */ _meta?: { [k: string]: unknown; }; -} -export interface ExtMethodResponse1 { - [k: string]: unknown; + content: string; } /** - * Notification containing a session update from the agent. - * - * Used to stream real-time progress and results during prompt processing. - * - * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output) + * Response to a permission request. */ -export interface SessionNotification { +export interface RequestPermissionResponse { /** * Extension point for implementations */ @@ -1503,160 +2016,39 @@ export interface SessionNotification { [k: string]: unknown; }; /** - * The ID of the session this update pertains to. - */ - sessionId: string; - /** - * The actual update content. + * The user's decision on the permission request. */ - update: - | { - content: ContentBlock; - sessionUpdate: "user_message_chunk"; - } - | { - content: ContentBlock; - sessionUpdate: "agent_message_chunk"; - } - | { - content: ContentBlock; - sessionUpdate: "agent_thought_chunk"; - } - | { - /** - * Extension point for implementations - */ - _meta?: { - [k: string]: unknown; - }; - /** - * Content produced by the tool call. - */ - content?: ToolCallContent[]; - /** - * The category of tool being invoked. - * Helps clients choose appropriate icons and UI treatment. - */ - kind?: - | "read" - | "edit" - | "delete" - | "move" - | "search" - | "execute" - | "think" - | "fetch" - | "switch_mode" - | "other"; - /** - * File locations affected by this tool call. - * Enables "follow-along" features in clients. - */ - locations?: ToolCallLocation[]; - /** - * Raw input parameters sent to the tool. - */ - rawInput?: { - [k: string]: unknown; - }; - /** - * Raw output returned by the tool. - */ - rawOutput?: { - [k: string]: unknown; - }; - sessionUpdate: "tool_call"; - /** - * Current execution status of the tool call. - */ - status?: "pending" | "in_progress" | "completed" | "failed"; - /** - * Human-readable title describing what the tool is doing. - */ - title: string; - /** - * Unique identifier for this tool call within the session. - */ - toolCallId: string; - } + outcome: | { - /** - * Extension point for implementations - */ - _meta?: { - [k: string]: unknown; - }; - /** - * Replace the content collection. - */ - content?: ToolCallContent[] | null; - /** - * Update the tool kind. - */ - kind?: ToolKind | null; - /** - * Replace the locations collection. - */ - locations?: ToolCallLocation[] | null; - /** - * Update the raw input. - */ - rawInput?: { - [k: string]: unknown; - }; - /** - * Update the raw output. - */ - rawOutput?: { - [k: string]: unknown; - }; - sessionUpdate: "tool_call_update"; - /** - * Update the execution status. - */ - status?: ToolCallStatus | null; - /** - * Update the human-readable title. - */ - title?: string | null; - /** - * The ID of the tool call being updated. - */ - toolCallId: string; + outcome: "cancelled"; } | { /** - * Extension point for implementations - */ - _meta?: { - [k: string]: unknown; - }; - /** - * The list of tasks to be accomplished. - * - * When updating a plan, the agent must send a complete list of all entries - * with their current status. The client replaces the entire plan with each update. + * The ID of the option the user selected. */ - entries: PlanEntry[]; - sessionUpdate: "plan"; - } - | { - availableCommands: AvailableCommand[]; - sessionUpdate: "available_commands_update"; - } - | { - currentModeId: SessionModeId; - sessionUpdate: "current_mode_update"; + optionId: string; + outcome: "selected"; }; } /** - * A single entry in the execution plan. - * - * Represents a task or goal that the assistant intends to accomplish - * as part of fulfilling the user's request. - * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries) + * Response containing the ID of the created terminal. + */ +export interface CreateTerminalResponse { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * The unique identifier for the created terminal. + */ + terminalId: string; +} +/** + * Response containing the terminal output and exit status. */ -export interface PlanEntry { +export interface TerminalOutputResponse { /** * Extension point for implementations */ @@ -1664,23 +2056,22 @@ export interface PlanEntry { [k: string]: unknown; }; /** - * Human-readable description of what this task aims to accomplish. + * Exit status if the command has completed. */ - content: string; + exitStatus?: TerminalExitStatus | null; /** - * The relative importance of this task. - * Used to indicate which tasks are most critical to the overall goal. + * The terminal output captured so far. */ - priority: "high" | "medium" | "low"; + output: string; /** - * Current execution status of this task. + * Whether the output was truncated due to byte limits. */ - status: "pending" | "in_progress" | "completed"; + truncated: boolean; } /** - * Information about a command. + * Exit status of a terminal command. */ -export interface AvailableCommand { +export interface TerminalExitStatus { /** * Extension point for implementations */ @@ -1688,31 +2079,108 @@ export interface AvailableCommand { [k: string]: unknown; }; /** - * Human-readable description of what the command does. + * The process exit code (may be null if terminated by signal). */ - description: string; + exitCode?: number | null; /** - * Input for the command if required + * The signal that terminated the process (may be null if exited normally). */ - input?: AvailableCommandInput | null; + signal?: string | null; +} +/** + * Response to terminal/release method + */ +export interface ReleaseTerminalResponse { /** - * Command name (e.g., `create_plan`, `research_codebase`). + * Extension point for implementations */ - name: string; + _meta?: { + [k: string]: unknown; + }; } /** - * All text that was typed after the command name is provided as input. + * Response containing the exit status of a terminal command. */ -export interface UnstructuredCommandInput { +export interface WaitForTerminalExitResponse { /** - * A hint to display when the input hasn't been provided yet + * Extension point for implementations */ - hint: string; + _meta?: { + [k: string]: unknown; + }; + /** + * The process exit code (may be null if terminated by signal). + */ + exitCode?: number | null; + /** + * The signal that terminated the process (may be null if exited normally). + */ + signal?: string | null; +} +/** + * Response to terminal/kill command method + */ +export interface KillTerminalResponse { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; +} +export interface ExtMethodResponse1 { + [k: string]: unknown; +} +export interface Notification1 { + method: string; + params?: ClientNotification | null; +} +/** + * Cancels ongoing operations for a session. + * + * This is a notification sent by the client to cancel an ongoing prompt turn. + * + * Upon receiving this notification, the Agent SHOULD: + * - Stop all language model requests as soon as possible + * - Abort all tool call invocations in progress + * - Send any pending `session/update` notifications + * - Respond to the original `session/prompt` request with `StopReason::Cancelled` + * + * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation) + */ +export interface CancelNotification { + /** + * Extension point for implementations + */ + _meta?: { + [k: string]: unknown; + }; + /** + * The ID of the session to cancel operations for. + */ + sessionId: string; } +/** + * Handles extension notifications from the client. + * + * Extension notifications provide a way to send one-way messages for custom functionality + * while maintaining protocol compatibility. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + */ export interface ExtNotification1 { [k: string]: unknown; } +/** @internal */ +export const nullSchema = z.null(); + +/** @internal */ +export const numberSchema = z.number(); + +/** @internal */ +export const stringSchema = z.string(); + /** @internal */ export const writeTextFileRequestSchema = z.object({ _meta: z.record(z.unknown()).optional(), @@ -1803,64 +2271,61 @@ export const toolCallStatusSchema = z.union([ ]); /** @internal */ -export const writeTextFileResponseSchema = z.object({ - _meta: z.record(z.unknown()).optional(), +export const errorSchema = z.object({ + code: z.number(), + data: z.record(z.unknown()).optional(), + message: z.string(), }); /** @internal */ -export const readTextFileResponseSchema = z.object({ +export const authenticateResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), - content: z.string(), }); /** @internal */ -export const requestPermissionResponseSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - outcome: z.union([ - z.object({ - outcome: z.literal("cancelled"), - }), - z.object({ - optionId: z.string(), - outcome: z.literal("selected"), - }), - ]), +export const setSessionModeResponseSchema = z.object({ + meta: z.unknown().optional(), }); /** @internal */ -export const createTerminalResponseSchema = z.object({ +export const promptResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), - terminalId: z.string(), + stopReason: z.union([ + z.literal("end_turn"), + z.literal("max_tokens"), + z.literal("max_turn_requests"), + z.literal("refusal"), + z.literal("cancelled"), + ]), }); /** @internal */ -export const releaseTerminalResponseSchema = z.object({ +export const setSessionModelResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), }); /** @internal */ -export const waitForTerminalExitResponseSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - exitCode: z.number().optional().nullable(), - signal: z.string().optional().nullable(), -}); +export const extMethodResponseSchema = z.record(z.unknown()); /** @internal */ -export const killTerminalResponseSchema = z.object({ - _meta: z.record(z.unknown()).optional(), -}); +export const sessionModeIdSchema = z.string(); /** @internal */ -export const extMethodResponseSchema = z.record(z.unknown()); +export const extNotificationSchema = z.record(z.unknown()); /** @internal */ -export const cancelNotificationSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - sessionId: z.string(), +export const unstructuredCommandInputSchema = z.object({ + hint: z.string(), }); /** @internal */ -export const extNotificationSchema = z.record(z.unknown()); +export const null1Schema = z.null(); + +/** @internal */ +export const number1Schema = z.number(); + +/** @internal */ +export const string1Schema = z.string(); /** @internal */ export const authenticateRequestSchema = z.object({ @@ -1907,46 +2372,65 @@ export const embeddedResourceResourceSchema = z.union([ ]); /** @internal */ -export const authenticateResponseSchema = z.object({ +export const writeTextFileResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), }); /** @internal */ -export const setSessionModeResponseSchema = z.object({ - meta: z.unknown().optional(), +export const readTextFileResponseSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + content: z.string(), }); /** @internal */ -export const promptResponseSchema = z.object({ +export const requestPermissionResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), - stopReason: z.union([ - z.literal("end_turn"), - z.literal("max_tokens"), - z.literal("max_turn_requests"), - z.literal("refusal"), - z.literal("cancelled"), + outcome: z.union([ + z.object({ + outcome: z.literal("cancelled"), + }), + z.object({ + optionId: z.string(), + outcome: z.literal("selected"), + }), ]), }); /** @internal */ -export const setSessionModelResponseSchema = z.object({ +export const createTerminalResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), + terminalId: z.string(), }); /** @internal */ -export const extMethodResponse1Schema = z.record(z.unknown()); +export const releaseTerminalResponseSchema = z.object({ + _meta: z.record(z.unknown()).optional(), +}); /** @internal */ -export const sessionModeIdSchema = z.string(); +export const waitForTerminalExitResponseSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + exitCode: z.number().optional().nullable(), + signal: z.string().optional().nullable(), +}); /** @internal */ -export const extNotification1Schema = z.record(z.unknown()); +export const killTerminalResponseSchema = z.object({ + _meta: z.record(z.unknown()).optional(), +}); /** @internal */ -export const unstructuredCommandInputSchema = z.object({ - hint: z.string(), +export const extMethodResponse1Schema = z.record(z.unknown()); + +/** @internal */ +export const cancelNotificationSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + sessionId: z.string(), }); +/** @internal */ +export const extNotification1Schema = z.record(z.unknown()); + /** @internal */ export const permissionOptionSchema = z.object({ _meta: z.record(z.unknown()).optional(), @@ -2019,26 +2503,87 @@ export const toolCallContentSchema = z.union([ ]); /** @internal */ -export const toolCallLocationSchema = z.object({ +export const toolCallLocationSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + line: z.number().optional().nullable(), + path: z.string(), +}); + +/** @internal */ +export const envVariableSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + name: z.string(), + value: z.string(), +}); + +/** @internal */ +export const authMethodSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + description: z.string().optional().nullable(), + id: z.string(), + name: z.string(), +}); + +/** @internal */ +export const mcpCapabilitiesSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + http: z.boolean().optional(), + sse: z.boolean().optional(), +}); + +/** @internal */ +export const promptCapabilitiesSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + audio: z.boolean().optional(), + embeddedContext: z.boolean().optional(), + image: z.boolean().optional(), +}); + +/** @internal */ +export const modelInfoSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + description: z.string().optional().nullable(), + modelId: z.string(), + name: z.string(), +}); + +/** @internal */ +export const sessionModeSchema = z.object({ _meta: z.record(z.unknown()).optional(), - line: z.number().optional().nullable(), - path: z.string(), + description: z.string().optional().nullable(), + id: sessionModeIdSchema, + name: z.string(), }); /** @internal */ -export const envVariableSchema = z.object({ +export const sessionModelStateSchema = z.object({ _meta: z.record(z.unknown()).optional(), - name: z.string(), - value: z.string(), + availableModels: z.array(modelInfoSchema), + currentModelId: z.string(), }); /** @internal */ -export const terminalExitStatusSchema = z.object({ +export const sessionModeStateSchema = z.object({ _meta: z.record(z.unknown()).optional(), - exitCode: z.number().optional().nullable(), - signal: z.string().optional().nullable(), + availableModes: z.array(sessionModeSchema), + currentModeId: z.string(), +}); + +/** @internal */ +export const planEntrySchema = z.object({ + _meta: z.record(z.unknown()).optional(), + content: z.string(), + priority: z.union([z.literal("high"), z.literal("medium"), z.literal("low")]), + status: z.union([ + z.literal("pending"), + z.literal("in_progress"), + z.literal("completed"), + ]), }); +/** @internal */ +export const availableCommandInputSchema = unstructuredCommandInputSchema; + /** @internal */ export const fileSystemCapabilitySchema = z.object({ _meta: z.record(z.unknown()).optional(), @@ -2114,79 +2659,36 @@ export const contentBlockSchema = z.union([ ]); /** @internal */ -export const authMethodSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - description: z.string().optional().nullable(), - id: z.string(), - name: z.string(), -}); - -/** @internal */ -export const mcpCapabilitiesSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - http: z.boolean().optional(), - sse: z.boolean().optional(), -}); - -/** @internal */ -export const promptCapabilitiesSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - audio: z.boolean().optional(), - embeddedContext: z.boolean().optional(), - image: z.boolean().optional(), -}); - -/** @internal */ -export const modelInfoSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - description: z.string().optional().nullable(), - modelId: z.string(), - name: z.string(), -}); - -/** @internal */ -export const sessionModeSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - description: z.string().optional().nullable(), - id: sessionModeIdSchema, - name: z.string(), -}); - -/** @internal */ -export const sessionModelStateSchema = z.object({ +export const terminalExitStatusSchema = z.object({ _meta: z.record(z.unknown()).optional(), - availableModels: z.array(modelInfoSchema), - currentModelId: z.string(), + exitCode: z.number().optional().nullable(), + signal: z.string().optional().nullable(), }); /** @internal */ -export const sessionModeStateSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - availableModes: z.array(sessionModeSchema), - currentModeId: z.string(), -}); +export const clientNotificationSchema = z.union([ + cancelNotificationSchema, + extNotification1Schema, +]); /** @internal */ -export const planEntrySchema = z.object({ +export const requestPermissionRequestSchema = z.object({ _meta: z.record(z.unknown()).optional(), - content: z.string(), - priority: z.union([z.literal("high"), z.literal("medium"), z.literal("low")]), - status: z.union([ - z.literal("pending"), - z.literal("in_progress"), - z.literal("completed"), - ]), + options: z.array(permissionOptionSchema), + sessionId: z.string(), + toolCall: z.object({ + _meta: z.record(z.unknown()).optional(), + content: z.array(toolCallContentSchema).optional().nullable(), + kind: toolKindSchema.optional().nullable(), + locations: z.array(toolCallLocationSchema).optional().nullable(), + rawInput: z.record(z.unknown()).optional(), + rawOutput: z.record(z.unknown()).optional(), + status: toolCallStatusSchema.optional().nullable(), + title: z.string().optional().nullable(), + toolCallId: z.string(), + }), }); -/** @internal */ -export const availableCommandInputSchema = unstructuredCommandInputSchema; - -/** @internal */ -export const clientNotificationSchema = z.union([ - cancelNotificationSchema, - extNotificationSchema, -]); - /** @internal */ export const createTerminalRequestSchema = z.object({ _meta: z.record(z.unknown()).optional(), @@ -2199,11 +2701,24 @@ export const createTerminalRequestSchema = z.object({ }); /** @internal */ -export const terminalOutputResponseSchema = z.object({ +export const newSessionResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), - exitStatus: terminalExitStatusSchema.optional().nullable(), - output: z.string(), - truncated: z.boolean(), + models: sessionModelStateSchema.optional().nullable(), + modes: sessionModeStateSchema.optional().nullable(), + sessionId: z.string(), +}); + +/** @internal */ +export const loadSessionResponseSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + models: sessionModelStateSchema.optional().nullable(), + modes: sessionModeStateSchema.optional().nullable(), +}); + +/** @internal */ +export const notification1Schema = z.object({ + method: z.string(), + params: clientNotificationSchema.optional().nullable(), }); /** @internal */ @@ -2229,39 +2744,25 @@ export const promptRequestSchema = z.object({ }); /** @internal */ -export const newSessionResponseSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - models: sessionModelStateSchema.optional().nullable(), - modes: sessionModeStateSchema.optional().nullable(), - sessionId: z.string(), -}); - -/** @internal */ -export const loadSessionResponseSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - models: sessionModelStateSchema.optional().nullable(), - modes: sessionModeStateSchema.optional().nullable(), -}); - -/** @internal */ -export const toolCallUpdateSchema = z.object({ +export const terminalOutputResponseSchema = z.object({ _meta: z.record(z.unknown()).optional(), - content: z.array(toolCallContentSchema).optional().nullable(), - kind: toolKindSchema.optional().nullable(), - locations: z.array(toolCallLocationSchema).optional().nullable(), - rawInput: z.record(z.unknown()).optional(), - rawOutput: z.record(z.unknown()).optional(), - status: toolCallStatusSchema.optional().nullable(), - title: z.string().optional().nullable(), - toolCallId: z.string(), + exitStatus: terminalExitStatusSchema.optional().nullable(), + output: z.string(), + truncated: z.boolean(), }); /** @internal */ -export const clientCapabilitiesSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - fs: fileSystemCapabilitySchema.optional(), - terminal: z.boolean().optional(), -}); +export const agentRequestSchema = z.union([ + writeTextFileRequestSchema, + readTextFileRequestSchema, + requestPermissionRequestSchema, + createTerminalRequestSchema, + terminalOutputRequestSchema, + releaseTerminalRequestSchema, + waitForTerminalExitRequestSchema, + killTerminalCommandRequestSchema, + extMethodRequestSchema, +]); /** @internal */ export const agentCapabilitiesSchema = z.object({ @@ -2280,31 +2781,17 @@ export const availableCommandSchema = z.object({ }); /** @internal */ -export const clientResponseSchema = z.union([ - writeTextFileResponseSchema, - readTextFileResponseSchema, - requestPermissionResponseSchema, - createTerminalResponseSchema, - terminalOutputResponseSchema, - releaseTerminalResponseSchema, - waitForTerminalExitResponseSchema, - killTerminalResponseSchema, - extMethodResponseSchema, -]); - -/** @internal */ -export const requestPermissionRequestSchema = z.object({ +export const clientCapabilitiesSchema = z.object({ _meta: z.record(z.unknown()).optional(), - options: z.array(permissionOptionSchema), - sessionId: z.string(), - toolCall: toolCallUpdateSchema, + fs: fileSystemCapabilitySchema.optional(), + terminal: z.boolean().optional(), }); /** @internal */ -export const initializeRequestSchema = z.object({ - _meta: z.record(z.unknown()).optional(), - clientCapabilities: clientCapabilitiesSchema.optional(), - protocolVersion: z.number(), +export const requestSchema = z.object({ + id: z.union([nullSchema, numberSchema, stringSchema]), + method: z.string(), + params: agentRequestSchema.optional().nullable(), }); /** @internal */ @@ -2321,15 +2808,135 @@ export const sessionNotificationSchema = z.object({ sessionId: z.string(), update: z.union([ z.object({ - content: contentBlockSchema, + _meta: z.record(z.unknown()).optional(), + content: z.union([ + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + text: z.string(), + type: z.literal("text"), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + data: z.string(), + mimeType: z.string(), + type: z.literal("image"), + uri: z.string().optional().nullable(), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + data: z.string(), + mimeType: z.string(), + type: z.literal("audio"), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + description: z.string().optional().nullable(), + mimeType: z.string().optional().nullable(), + name: z.string(), + size: z.number().optional().nullable(), + title: z.string().optional().nullable(), + type: z.literal("resource_link"), + uri: z.string(), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + resource: embeddedResourceResourceSchema, + type: z.literal("resource"), + }), + ]), sessionUpdate: z.literal("user_message_chunk"), }), z.object({ - content: contentBlockSchema, + _meta: z.record(z.unknown()).optional(), + content: z.union([ + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + text: z.string(), + type: z.literal("text"), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + data: z.string(), + mimeType: z.string(), + type: z.literal("image"), + uri: z.string().optional().nullable(), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + data: z.string(), + mimeType: z.string(), + type: z.literal("audio"), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + description: z.string().optional().nullable(), + mimeType: z.string().optional().nullable(), + name: z.string(), + size: z.number().optional().nullable(), + title: z.string().optional().nullable(), + type: z.literal("resource_link"), + uri: z.string(), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + resource: embeddedResourceResourceSchema, + type: z.literal("resource"), + }), + ]), sessionUpdate: z.literal("agent_message_chunk"), }), z.object({ - content: contentBlockSchema, + _meta: z.record(z.unknown()).optional(), + content: z.union([ + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + text: z.string(), + type: z.literal("text"), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + data: z.string(), + mimeType: z.string(), + type: z.literal("image"), + uri: z.string().optional().nullable(), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + data: z.string(), + mimeType: z.string(), + type: z.literal("audio"), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + description: z.string().optional().nullable(), + mimeType: z.string().optional().nullable(), + name: z.string(), + size: z.number().optional().nullable(), + title: z.string().optional().nullable(), + type: z.literal("resource_link"), + uri: z.string(), + }), + z.object({ + _meta: z.record(z.unknown()).optional(), + annotations: annotationsSchema.optional().nullable(), + resource: embeddedResourceResourceSchema, + type: z.literal("resource"), + }), + ]), sessionUpdate: z.literal("agent_thought_chunk"), }), z.object({ @@ -2382,31 +2989,46 @@ export const sessionNotificationSchema = z.object({ sessionUpdate: z.literal("plan"), }), z.object({ + _meta: z.record(z.unknown()).optional(), availableCommands: z.array(availableCommandSchema), sessionUpdate: z.literal("available_commands_update"), }), z.object({ - currentModeId: sessionModeIdSchema, + _meta: z.record(z.unknown()).optional(), + currentModeId: z.string(), sessionUpdate: z.literal("current_mode_update"), }), ]), }); /** @internal */ -export const clientRequestSchema = z.union([ - writeTextFileRequestSchema, - readTextFileRequestSchema, - requestPermissionRequestSchema, - createTerminalRequestSchema, - terminalOutputRequestSchema, - releaseTerminalRequestSchema, - waitForTerminalExitRequestSchema, - killTerminalCommandRequestSchema, - extMethodRequestSchema, +export const initializeRequestSchema = z.object({ + _meta: z.record(z.unknown()).optional(), + clientCapabilities: clientCapabilitiesSchema.optional(), + protocolVersion: z.number(), +}); + +/** @internal */ +export const clientResponseSchema = z.union([ + writeTextFileResponseSchema, + readTextFileResponseSchema, + requestPermissionResponseSchema, + createTerminalResponseSchema, + terminalOutputResponseSchema, + releaseTerminalResponseSchema, + waitForTerminalExitResponseSchema, + killTerminalResponseSchema, + extMethodResponse1Schema, ]); /** @internal */ -export const agentRequestSchema = z.union([ +export const agentNotificationSchema = z.union([ + sessionNotificationSchema, + extNotificationSchema, +]); + +/** @internal */ +export const clientRequestSchema = z.union([ initializeRequestSchema, authenticateRequestSchema, newSessionRequestSchema, @@ -2417,6 +3039,12 @@ export const agentRequestSchema = z.union([ extMethodRequest1Schema, ]); +/** @internal */ +export const notificationSchema = z.object({ + method: z.string(), + params: agentNotificationSchema.optional().nullable(), +}); + /** @internal */ export const agentResponseSchema = z.union([ initializeResponseSchema, @@ -2426,21 +3054,52 @@ export const agentResponseSchema = z.union([ setSessionModeResponseSchema, promptResponseSchema, setSessionModelResponseSchema, - extMethodResponse1Schema, + extMethodResponseSchema, ]); /** @internal */ -export const agentNotificationSchema = z.union([ - sessionNotificationSchema, - extNotification1Schema, +export const request1Schema = z.object({ + id: z.union([null1Schema, number1Schema, string1Schema]), + method: z.string(), + params: clientRequestSchema.optional().nullable(), +}); + +/** @internal */ +export const response1Schema = z.union([ + z.object({ + result: clientResponseSchema, + }), + z.object({ + error: errorSchema, + }), +]); + +/** @internal */ +export const clientOutgoingMessageSchema = z.union([ + request1Schema, + response1Schema, + notification1Schema, +]); + +/** @internal */ +export const responseSchema = z.union([ + z.object({ + result: agentResponseSchema, + }), + z.object({ + error: errorSchema, + }), +]); + +/** @internal */ +export const agentOutgoingMessageSchema = z.union([ + requestSchema, + responseSchema, + notificationSchema, ]); /** @internal */ export const agentClientProtocolSchema = z.union([ - clientRequestSchema, - clientResponseSchema, - clientNotificationSchema, - agentRequestSchema, - agentResponseSchema, - agentNotificationSchema, + agentOutgoingMessageSchema, + clientOutgoingMessageSchema, ]);