From ec1988c7ed51b668ceb3c7a04a246909a725c0ca Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Wed, 11 Nov 2026 15:48:37 -0500 Subject: [PATCH 1/7] CLI: add the MCP SDK at the desktop pin Co-Authored-By: Claude Opus 5.5 --- packages/cli/package-lock.json | 1121 ++++++++++++++++++++++++++++++++ packages/cli/package.json | 3 +- 2 files changed, 1123 insertions(+), 1 deletion(-) diff --git a/packages/cli/package-lock.json b/packages/cli/package-lock.json index 84ee264e6c..efd77bf886 100644 --- a/packages/cli/package-lock.json +++ b/packages/cli/package-lock.json @@ -16,6 +16,7 @@ "@earendil-works/pi-coding-agent": "1.4.0", "@earendil-works/pi-durable": "1.4.0", "@earendil-works/pi-mcp": "1.4.0", + "@modelcontextprotocol/sdk": "1.32.1", "@silvia-odwyer/photon-node": "0.3.4", "posthog-node": "5.56.1", "proper-lockfile": "4.1.2", @@ -1162,6 +1163,58 @@ } } }, + "node_modules/@hono/node-server": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.7.tgz", + "integrity": "sha512-Wr0E6S+v2Bw9FkpGNP5BQ5QbJvclUa06UVehd65WFZe6XeJwbrKQQ5wPDevc0IC+QyzbO7v3Llh5uo45IZcSnA==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "hono": "^4 || ^5.0.0-0" + } + }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.1.tgz", + "integrity": "sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw==", + "license": "MIT", + "dependencies": { + "@hono/node-server": "^1.19.9 || ^2.0.5", + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.2.1", + "express-rate-limit": "^8.2.1", + "hono": "^4.11.4", + "jose": "^6.1.3", + "json-schema-typed": "^8.0.2", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.25 || ^4.0", + "zod-to-json-schema": "^3.25.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@cfworker/json-schema": "^4.1.1", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@cfworker/json-schema": { + "optional": true + }, + "zod": { + "optional": false + } + } + }, "node_modules/@posthog/core": { "version": "1.59.0", "resolved": "https://registry.npmjs.org/@posthog/core/-/core-1.59.0.tgz", @@ -1368,6 +1421,19 @@ "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", "license": "MIT" }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/agent-base": { "version": "7.1.4", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", @@ -1377,6 +1443,39 @@ "node": ">= 14" } }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -1439,6 +1538,43 @@ "node": "*" } }, + "node_modules/body-parser": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", + "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.1.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.3", + "on-finished": "^2.4.1", + "qs": "^6.16.1", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/bowser": { "version": "2.14.1", "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz", @@ -1463,6 +1599,44 @@ "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", "license": "BSD-3-Clause" }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.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", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -1501,6 +1675,63 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "license": "MIT" }, + "node_modules/content-disposition": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-2.0.1.tgz", + "integrity": "sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -1550,6 +1781,15 @@ "node": ">=0.10.0" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/diff": { "version": "8.0.4", "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz", @@ -1565,6 +1805,20 @@ "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", "license": "MIT" }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -1574,12 +1828,61 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "license": "MIT" }, + "node_modules/encodeurl": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz", + "integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.28.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", @@ -1622,18 +1925,151 @@ "@esbuild/win32-x64": "0.28.1" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz", + "integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/express": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.3.0.tgz", + "integrity": "sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.3.0", + "content-disposition": "^2.0.1", + "content-type": "^2.0.0", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.8", + "qs": "^6.16.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.1.0", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "8.7.4", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.4.tgz", + "integrity": "sha512-LKBXzX700wz3zAGNNmVnjRI5mEbYkLv7UbMI4+9Xa+JPcg2UZh6AgY/2CZh9RrJjFM5ttC/N1lD+KzyFoZITCw==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "ip-address": "^10.2.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, + "node_modules/express/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "license": "MIT" }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, "node_modules/fast-sha256": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==", "license": "Unlicense" }, + "node_modules/fast-uri": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", + "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", @@ -1657,6 +2093,27 @@ "node": "^12.20 || >= 14.13" } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -1682,6 +2139,33 @@ "node": ">=12.20.0" } }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gaxios": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.3.1.tgz", @@ -1731,6 +2215,43 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/google-auth-library": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.9.1.tgz", @@ -1757,12 +2278,77 @@ "node": ">=14" } }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "license": "ISC" }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hono": { + "version": "4.13.18", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.18.tgz", + "integrity": "sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==", + "license": "MIT", + "engines": { + "node": ">=16.9.0" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/http-proxy-agent": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-9.1.0.tgz", @@ -1799,6 +2385,46 @@ "node": ">= 14" } }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ip-address": { + "version": "10.7.6", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz", + "integrity": "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -1808,12 +2434,27 @@ "node": ">=8" } }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "license": "ISC" }, + "node_modules/jose": { + "version": "6.2.17", + "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.17.tgz", + "integrity": "sha512-wOuK9V1yujQFH5S0ZWmLcDZN7+IKh9bUCC2ZPCf2HDlol3WWHy+PPyNjEI75FXRLMp3vDKQcupP59xhVU95hcg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/json-bigint": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", @@ -1836,6 +2477,18 @@ "node": ">=16" } }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, + "node_modules/json-schema-typed": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz", + "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==", + "license": "BSD-2-Clause" + }, "node_modules/jwa": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", @@ -1899,12 +2552,100 @@ "marked": ">=15.0.0" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/negotiator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", + "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/negotiator/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -1943,6 +2684,52 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz", + "integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/openai": { "version": "7.19.0", "resolved": "https://registry.npmjs.org/openai/-/openai-7.19.0.tgz", @@ -2029,6 +2816,15 @@ "node": ">=6" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/partial-json": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/partial-json/-/partial-json-0.1.7.tgz", @@ -2053,6 +2849,25 @@ "node": ">=8" } }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/pkce-challenge": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", + "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, "node_modules/pngjs": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", @@ -2129,6 +2944,23 @@ "node": ">=12.0.0" } }, + "node_modules/proxy-addr": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/proxy-agent-negotiate": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-agent-negotiate/-/proxy-agent-negotiate-1.1.0.tgz", @@ -2163,12 +2995,56 @@ "node": ">=10.13.0" } }, + "node_modules/qs": { + "version": "6.17.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz", + "integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/quickjs-wasi": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/quickjs-wasi/-/quickjs-wasi-3.6.2.tgz", "integrity": "sha512-FCqGtGOrMgzUiIrMNMA2YnsOxCNwo31dzqXvclXUC6xeT35NJLKXQJsvbeCTjvoFAwZgEAPg8U6+KAPDGXn8Mg==", "license": "MIT" }, + "node_modules/range-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2178,6 +3054,15 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -2193,6 +3078,22 @@ "node": ">= 4" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -2213,12 +3114,69 @@ ], "license": "MIT" }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "license": "ISC" }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -2333,6 +3291,78 @@ "win32" ] }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -2349,6 +3379,15 @@ "fast-sha256": "^1.3.0" } }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -2375,6 +3414,15 @@ "node": ">=8" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/ts-algebra": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", @@ -2387,6 +3435,37 @@ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/typebox": { "version": "1.3.27", "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.27.tgz", @@ -2422,6 +3501,24 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "license": "MIT" }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/web-streams-polyfill": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", @@ -2466,6 +3563,12 @@ "node": ">=8" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, "node_modules/ws": { "version": "8.22.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", @@ -2527,6 +3630,24 @@ "engines": { "node": ">=6" } + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", + "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.25.28 || ^4" + } } } } diff --git a/packages/cli/package.json b/packages/cli/package.json index 7bad552d6d..2bf4633367 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -32,7 +32,8 @@ "proper-lockfile": "4.1.2", "@earendil-works/pi-durable": "1.4.0", "@earendil-works/chord": "1.4.0", - "posthog-node": "5.56.1" + "posthog-node": "5.56.1", + "@modelcontextprotocol/sdk": "1.32.1" }, "devDependencies": { "@types/node": "22.19.19", From 985b3cf6179f1c1361bb68fc2e9fab5a5a100888 Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Wed, 11 Nov 2026 16:00:57 -0500 Subject: [PATCH 2/7] aiden serve: host the loopback /mcp endpoint, managed with aiden apps The headless server now runs the same AidenMcpHost and tool runner as the desktop, inside its Remote runtime, on loopback ports 49500-49507 so it never takes a desktop's port. It stays off until the first `aiden apps connect` or `aiden apps on`. `aiden apps list|connect|revoke|on|off` reach the running server over its control socket. Connect shows the token once, with Claude Code and Codex commands that read it from AIDEN_MCP_TOKEN. Revoke shares the Remote revocation path and refuses a phone's id. Admin commands send no analytics, and app chats and turns send no usage events, as on the desktop. Co-Authored-By: Claude Opus 5.5 --- .memory/aiden-mcp-server.md | 30 ++- docs/aiden-mcp-server.md | 21 +- docs/security/aiden-remote-threat-model.md | 1 + packages/cli/README.md | 22 +- packages/cli/package.json | 2 +- packages/cli/src/apps-display.ts | 70 ++++++ packages/cli/src/apps.ts | 112 ++++++++++ packages/cli/src/command-help.ts | 2 + packages/cli/src/commands.ts | 13 ++ packages/cli/src/parity-test-api.ts | 2 + packages/cli/src/remote-chats.ts | 2 + packages/cli/src/remote.ts | 61 +++-- packages/cli/src/serve.ts | 7 +- packages/cli/tests/mcp-apps.test.mjs | 246 +++++++++++++++++++++ 14 files changed, 567 insertions(+), 24 deletions(-) create mode 100644 packages/cli/src/apps-display.ts create mode 100644 packages/cli/src/apps.ts create mode 100644 packages/cli/tests/mcp-apps.test.mjs diff --git a/.memory/aiden-mcp-server.md b/.memory/aiden-mcp-server.md index d7798f21e9..7a8018756a 100644 --- a/.memory/aiden-mcp-server.md +++ b/.memory/aiden-mcp-server.md @@ -1,6 +1,6 @@ # Aiden MCP server for outside apps (W4a, 2026-11-11) -Core only: a loopback MCP server that lets Claude Code, Codex or any MCP client use Aiden's chats. Ported in spirit from T3 Code PR #33196 (no code copied). Off by default, with no Settings UI yet (W4b) and no `aiden serve` wiring (W4c). User docs: `docs/aiden-mcp-server.md`; threat model section 10 of `docs/security/aiden-remote-threat-model.md`. README and PRODUCT.md make no claims until W4b ships. +Core only: a loopback MCP server that lets Claude Code, Codex or any MCP client use Aiden's chats. Ported in spirit from T3 Code PR #33196 (no code copied). Off by default, with no Settings UI yet (W4b); `aiden serve` hosts it too (W4c, below). User docs: `docs/aiden-mcp-server.md`; threat model section 10 of `docs/security/aiden-remote-threat-model.md`. README and PRODUCT.md make no claims until W4b ships. ## Layout @@ -58,7 +58,31 @@ Core only: a loopback MCP server that lets Claude Code, Codex or any MCP client - Its client is `@earendil-works/pi-mcp` `McpClient`. ESLint forbids importing `@modelcontextprotocol/sdk/client*`. - A fake generation's finish must check `owner.isDestroyed()` first, because `owner.send` throws after revocation. -## Open for W4b and W4c +## Headless server (W4c, 2026-11-11) + +`aiden serve` hosts the same endpoint, and `aiden apps list|connect|revoke|on|off` manages it. + +- **Wiring:** + - `packages/cli/src/apps.ts` has `createCliMcpHost` and `cliAppsCommand`. + - `packages/cli/src/apps-display.ts` holds the connect rendering, the snippets and `CLI_MCP_DEFAULT_PORT`. It has type-only imports, so the admin client never loads the SDK. + - The SDK is pinned at `@modelcontextprotocol/sdk` 1.32.1 in `packages/cli/package.json`, the desktop pin. +- **Inside the Remote runtime.** `createCliRemote` builds the host: + - The chat runtime is shared through a memoized `loadChatApi` (a failed load is retried). + - MCP gets its own cached `AidenRemoteWorkspaceService`, so it never rebuilds Remote's host feed. + - `revokeDevice` is the one shared path that drains feeds, runs and Bot sessions and calls `revokeAidenRemoteRuntimeDevice`; `remote revoke` uses it too. + - `start()` calls `mcp.initialize()` after Remote is up, and a failure only logs. `stop()` stops MCP first. + - `--no-remote` means no MCP server: `serve.ts` refuses `apps` with a restart hint. +- **Port.** 49500–49507 (`CLI_MCP_DEFAULT_PORT`), a +100 shift from the desktop's 49400, mirroring Remote's 49220 → 49320. It is saved in `remote.json`. Tests pass `mcpPort: 0`. +- **Off by default.** `connect` calls `setEnabled(true)` before `issueApp`, so a failure to enable never loses a just-issued token. An argument error refuses before either step. The default access is Read. +- **Connect output.** On a TTY, `commands.ts` renders text with the token once and `claude mcp add --scope user --transport http aiden --header 'Authorization: Bearer ${AIDEN_MCP_TOKEN}'` / `codex mcp add aiden --url --bearer-token-env-var AIDEN_MCP_TOKEN`; this matches W4b's choice. Piped output is JSON plus a stderr warning, like pairing. +- **Analytics.** `remote-chats.ts` passes `deviceReportsAnalytics` (false for `agent` devices), matching the desktop. `aiden apps` sends nothing. +- **Docker.** Container loopback is unreachable from the host, which is documented. MCP without Remote would be a possible follow-up. +- **Tests.** `packages/cli/tests/mcp-apps.test.mjs` (in the CLI `test` script; the registry covers it through `test:cli`): + - spawned `aiden serve` end to end: off by default, connect, 401s, Read tools, a real chat through a fake provider, provenance, revoke, off/on, and the port across a restart + - in-process refusals and a phone id + - `--no-remote` + - the snippets never carrying the token + +## Open - W4b: the Settings UI and IPC over the five main exports, plus a "Started by" label from provenance (nothing reads it yet). -- W4c: `packages/cli` has no `@modelcontextprotocol/sdk` dependency and no MCP host wiring in `aiden serve`. diff --git a/docs/aiden-mcp-server.md b/docs/aiden-mcp-server.md index a173f930ea..9654442ce8 100644 --- a/docs/aiden-mcp-server.md +++ b/docs/aiden-mcp-server.md @@ -2,7 +2,7 @@ Aiden can act as a [Model Context Protocol](https://modelcontextprotocol.io) server, so another app on the same computer (Claude Code, Codex, or any MCP client) can list Aiden's workspaces and chats, read them, and, with permission, start and follow Aiden turns. -Status (2026-11-11): the server core is in the desktop main process, behind the `mcpServer` host capability (macOS and Linux desktop; see `main/services/host-platform-capabilities.ts`). It is **off by default**. The Settings screen for turning it on and connecting apps is still to come (workstream W4b), and so is a headless `aiden serve` counterpart (W4c). Until those ship, the only way to turn the server on or issue an app is through the main-process functions listed under [Main-process API](#main-process-api). +Status (2026-11-11): the server core is in the desktop main process, behind the `mcpServer` host capability (macOS and Linux desktop; see `main/services/host-platform-capabilities.ts`). It is **off by default**. The Settings screen for turning it on and connecting apps is still to come (workstream W4b); until it ships, the desktop server is turned on and apps are issued only through the main-process functions listed under [Main-process API](#main-process-api). The headless server hosts the same endpoint, managed with `aiden apps` (see [Headless server](#headless-server-aiden-serve)). ## How an app connects @@ -100,6 +100,25 @@ Privacy: The Remote Access threat model has the matching section: [`docs/security/aiden-remote-threat-model.md`](security/aiden-remote-threat-model.md#10-local-mcp-server-for-outside-apps). +## Headless server (`aiden serve`) + +`aiden serve` in `packages/cli` hosts the same server, built from the same `AidenMcpHost` and tool runner, with the same tools, access levels, limits, token handling and request checks. The differences: + +- **Port:** 49500 and the next seven ports, 100 above the desktop's range, so a desktop and a server on the same computer never take each other's port. Like the desktop, the first port that binds is saved, in the server's `remote.json`, and a busy saved port is reported as `port_in_use`. +- **Administration:** `aiden apps`, sent to the running server over its private control socket: + - `aiden apps connect [--access read|supervised]` turns the server on if it is off, issues the app (Read unless `--access supervised`) and shows its token once. + - On a terminal it also prints the `claude mcp add` and `codex mcp add` commands, which read the token from `AIDEN_MCP_TOKEN` rather than storing it in the app's config. + - Piped, it prints JSON and warns on stderr that the output holds the token. + - `aiden apps list` shows the server's status and the connected apps, revoked ones with `revokedAt`. + - `aiden apps revoke ` disconnects one app through the same revocation path as `aiden remote revoke`. A phone's or Mac's id is refused. + - `aiden apps on|off` opens or closes the listener and saves the choice. +- **Requires Remote:** the server lives in the CLI's Remote runtime, which holds the device records and chat services. `aiden serve --no-remote` has no MCP server. +- **Containers:** loopback in a container is the container's own, so apps on the host can't reach it. Run `aiden serve` on the host for outside apps. +- **Files:** the provenance note is `/aiden-mcp-chat-provenance.json`. +- **Analytics:** `aiden apps` sends nothing, and app chats and turns send no usage events, as on the desktop. + +Code: `packages/cli/src/apps.ts` (host wiring and the `apps` command), `packages/cli/src/apps-display.ts` (the connect output) and `packages/cli/src/remote.ts`. Tests: `packages/cli/tests/mcp-apps.test.mjs`. + ## Main-process API These are exported from `main/services/aiden-remote-service-main.ts` for the Settings IPC in W4b: diff --git a/docs/security/aiden-remote-threat-model.md b/docs/security/aiden-remote-threat-model.md index 1ff1524f89..0b50cf4861 100644 --- a/docs/security/aiden-remote-threat-model.md +++ b/docs/security/aiden-remote-threat-model.md @@ -194,6 +194,7 @@ Outside app (Claude Code, Codex, any MCP client) on this computer - The app that started a chat is recorded only locally (`aiden-mcp-chat-provenance.json`) and is never projected. - Logs follow section 7 and carry only content-free events. - No analytics events are sent. +- **Headless server.** `aiden serve` runs the same host and tools inside its Remote runtime, on loopback ports 49500–49507 so it never takes a desktop's port. It is administered only through `aiden apps` over the owner-private control socket, and it has no MCP server under `--no-remote`. `packages/cli/tests/mcp-apps.test.mjs` drives it end to end: off by default, 401 for a missing, wrong or revoked token, Read apps without write tools, a phone's id refused by `aiden apps revoke`, and the port kept across `off`/`on` and a restart. Required evidence: `main/services/aiden-mcp-server.test.ts` covers: diff --git a/packages/cli/README.md b/packages/cli/README.md index aa10a8629c..cb3e5a9167 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -116,6 +116,24 @@ Phones and Macs paired with the server see its workspaces, chats, Bots, schedule - **Connector-watch management.** The optional `bot:watches` surface belongs to the Electron desktop on Mac and Linux. This server does not wire or advertise it; ordinary Composio MCP tools keep their existing CLI behavior. - **Scheduled-run notifications.** Run completions show up through `aiden schedule runs `, `aiden schedule notifications` and, for tasks with `notify`, local notifications on paired phones via the Remote `scheduled-tasks/notifications` feed. +## Outside apps (MCP server) + +`aiden serve` hosts the same loopback MCP server as the desktop, so Claude Code, Codex or any MCP client on the same computer can list the server's workspaces and chats, read them, and, with Supervised access, start and follow turns. Tools, access levels, limits and the threat model are in [`docs/aiden-mcp-server.md`](../../docs/aiden-mcp-server.md). + +```bash +aiden apps connect "Claude Code" --access supervised # turns the server on, shows the token once +aiden apps list # server status and connected apps +aiden apps revoke # disconnects one app at once +aiden apps off # closes the listener; `aiden apps on` reopens it +``` + +- **Off by default.** The listener opens only after the first `aiden apps connect` or an explicit `aiden apps on`, and the choice is saved in `remote.json`. +- **Address.** `http://127.0.0.1:/mcp`, on loopback only. The server tries port 49500 and the next seven, 100 above the desktop's 49400, so a desktop and a server on one computer never collide. The first port that binds is saved, so the URL stays the same across restarts; if another program later holds it, `aiden apps list` reports `port_in_use` instead of moving. +- **Connecting.** `connect ` defaults to Read access. On a terminal it prints the token once, with `claude mcp add` and `codex mcp add` commands that read it from `AIDEN_MCP_TOKEN` instead of writing it into their config; piped, it prints JSON and warns on stderr that the output holds the token. +- **Requires Remote.** Apps share the Remote runtime's chats and device records, so `aiden serve --no-remote` has no MCP server and `aiden apps` says to restart without the flag. The listener never joins Remote's LAN or Tailscale listener. +- **Admin over the control socket.** `aiden apps` needs a running server and talks to it over the private control socket, like `aiden remote`. Admin commands send no analytics, and chats an app starts send no usage events. +- **Containers.** Loopback inside a container is the container's own, so an app on the host can't reach `/mcp` in the Docker image. Run `aiden serve` on the host for outside apps. + ## Bots `aiden serve` hosts Bots with managed homes, exact Custom grants, MCP, skills, web search, companion vision and uploaded photos. Bot subagents perform read-only investigations within the admitted file scopes. Bot fires are saved before schedule advancement and reconciled by Pi request ID after a restart; failed Bot runs record a failure kind. @@ -173,6 +191,7 @@ The desktop's per-workspace skill and connector switches (Workspace settings) ar | `remote status\|devices\|pair lan\|tailscale\|pair-status\|pair-cancel \|revoke \|roots\|approve-root ` | Pairing and paired-device administration (server must be running) | | `remote network local\|tailscale\|both` | Who can reach the server; Tailscale is set up for you (server must be running) | | `remote check` | Check each step a phone needs to reach the server, with fixes | +| `apps list\|connect [--access read\|supervised]\|revoke \|on\|off` | Outside apps (Claude Code, Codex) on the local `/mcp` endpoint (server must be running) | | `auth list\|login\|logout` | Provider credentials (OAuth or API key) | | `workspace list\|add\|remove\|access\|scratch` | Workspace registry and tool access tiers | | `mcp list\|presets\|add\|preset\|login\|logout\|remove` | MCP connectors and their OAuth sign-ins | @@ -206,7 +225,7 @@ Notes: | Path | Contents | | --- | --- | -| `~/.aiden/agent/` | Server state: `settings.json`, `auth.json`, `aiden.json` (device-local feature settings), `aiden-mcp.json`, `web-search.json`, `remote.json` (Remote identity and paired devices), `chat-read-markers.json` and `chat-triage.json` (Inbox read state and Pin, Done and Snooze), `schedules.json`, `hooks/` (hooks, approvals and run log), `sessions/`, `bots/`, `bot-service/`, `artifacts/`, `credentials/`, `serve.log` and the private control socket | +| `~/.aiden/agent/` | Server state: `settings.json`, `auth.json`, `aiden.json` (device-local feature settings), `aiden-mcp.json`, `web-search.json`, `remote.json` (Remote identity, paired devices, connected apps and the MCP server setting), `aiden-mcp-chat-provenance.json` (which app started a chat, local only), `chat-read-markers.json` and `chat-triage.json` (Inbox read state and Pin, Done and Snooze), `schedules.json`, `hooks/` (hooks, approvals and run log), `sessions/`, `bots/`, `bot-service/`, `artifacts/`, `credentials/`, `serve.log` and the private control socket | | `~/.aiden/` | Shared Aiden home (the desktop's portable `config.json`, `skills/`, `scripts/`; `memory/` is the shared desktop and server memory store, `ws-` scopes) | | `AIDEN_CODING_AGENT_DIR` | Environment override for the agent directory (mirrors Pi's `PI_CODING_AGENT_DIR`; use it for tests and for running more than one server) | @@ -218,6 +237,7 @@ New Memory databases support bounded incremental space reclamation on open and c - **Aiden usage data.** A server built from a clone or the Docker image has no project key and sends nothing. Only the `aiden serve` process of a distribution build (`npm run cli:dist`) can send the anonymous usage and crash data in [`docs/analytics.md`](../../docs/analytics.md); admin commands send nothing, apart from the one final event of `aiden telemetry off`. It sends only after its one-time notice, shown at `aiden service install` or the first `aiden serve` on a terminal; a server that never showed the notice stays silent. `aiden telemetry status|on|off` is the switch (`off` also stops a running server; a server picks up `on` at its next start). `DO_NOT_TRACK=1` and `AIDEN_ANALYTICS=0` turn it off for that process, and a service does not inherit them from your shell, so use `aiden telemetry off` there. With `CI` set nothing is ever sent. State lives in `/aiden-analytics.json`, not Pi's `settings.json`. - **Manual-only catalogs.** models.dev, Artificial Analysis and OpenRouter benchmark data are fetched only by the explicit `aiden catalog models-dev fetch` and `aiden insights aa|openrouter fetch` commands, never on startup or in the background, and the fetched data is display-only. Speech models download only with `aiden speech download`. - **Remote.** Paired devices authenticate to the server's own TLS identity. Tailscale is used only after you choose it for pairing. +- **MCP server.** Off until you connect an app. It listens on loopback only and makes no outbound requests of its own. ## Linux container diff --git a/packages/cli/package.json b/packages/cli/package.json index 2bf4633367..d0dc273004 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -17,7 +17,7 @@ ], "scripts": { "build": "node scripts/patch-branding.mjs && node scripts/build.mjs", - "test": "node --test tests/bundle.test.mjs tests/runtime.test.mjs tests/extensions.test.mjs tests/parity.test.mjs tests/serve-startup.test.mjs tests/service.test.mjs tests/reachability.test.mjs tests/inbox-host.test.mjs tests/daemon-turns.test.mjs tests/serve-lifetime.test.mjs tests/schedule-consent.test.mjs tests/analytics.test.mjs", + "test": "node --test tests/bundle.test.mjs tests/runtime.test.mjs tests/extensions.test.mjs tests/parity.test.mjs tests/serve-startup.test.mjs tests/service.test.mjs tests/reachability.test.mjs tests/inbox-host.test.mjs tests/daemon-turns.test.mjs tests/serve-lifetime.test.mjs tests/schedule-consent.test.mjs tests/analytics.test.mjs tests/mcp-apps.test.mjs", "type-check": "tsc --noEmit" }, "dependencies": { diff --git a/packages/cli/src/apps-display.ts b/packages/cli/src/apps-display.ts new file mode 100644 index 0000000000..0ae250ff92 --- /dev/null +++ b/packages/cli/src/apps-display.ts @@ -0,0 +1,70 @@ +// Kept light: `aiden apps connect` renders with this module without loading +// the MCP server or its SDK into the admin command. +import type { AidenMcpServerStatus } from "../../../main/services/aiden-mcp-server.js"; +import type { AidenRemoteAgentAppProjection } from "../../../main/services/aiden-remote-state.js"; + +/** + * The first port the server's `/mcp` endpoint tries (then the next seven). + * The desktop uses 49400 (50400 in development), so a server and a desktop on + * the same computer never take each other's port; this is the same +100 shift + * the server's Remote port has over the desktop's. The bound port is saved in + * `remote.json`, so a connected app keeps working across restarts. + */ +export const CLI_MCP_DEFAULT_PORT = 49_500; + +export interface CliAppConnection { + app: AidenRemoteAgentAppProjection; + /** Shown once; only its digest is kept. */ + token: string; + server: AidenMcpServerStatus; +} + +/** + * The commands that add Aiden to Claude Code and Codex. The token goes in an + * environment variable both clients read at connect time, so neither stores + * it in its own config file. + */ +export function aidenMcpClientSnippets(url: string, token: string): { environment: string; claude: string; codex: string } { + return { + environment: `export AIDEN_MCP_TOKEN=${token}`, + claude: `claude mcp add --scope user --transport http aiden ${url} --header 'Authorization: Bearer \${AIDEN_MCP_TOKEN}'`, + codex: `codex mcp add aiden --url ${url} --bearer-token-env-var AIDEN_MCP_TOKEN`, + }; +} + +/** What `aiden apps connect` prints on a terminal. */ +export function renderAppConnection(connection: CliAppConnection): string { + const { app, token, server } = connection; + const lines = [ + `Connected ${app.name} (${app.access === "supervised" ? "Supervised" : "Read"} access, id ${app.id}).`, + "", + "Its token is shown only this once. Keep it out of logs and chats:", + ` ${token}`, + "", + ]; + if (server.running && server.url) { + const snippets = aidenMcpClientSnippets(server.url, token); + lines.push( + `Aiden's MCP server is listening at ${server.url} (this computer only).`, + "", + "Set the token where Claude Code or Codex runs (for example in your shell profile):", + ` ${snippets.environment}`, + "", + "Claude Code:", + ` ${snippets.claude}`, + "", + "Codex:", + ` ${snippets.codex}`, + "", + ); + } else { + lines.push( + server.problem === "port_in_use" + ? `Aiden's MCP server could not start: port ${server.port ?? CLI_MCP_DEFAULT_PORT} is in use. Free it, then run \`aiden apps on\`.` + : "Aiden's MCP server could not start. Check the server's log, then run `aiden apps on`.", + "", + ); + } + lines.push(`Disconnect it any time with \`aiden apps revoke ${app.id}\`.`); + return lines.join("\n"); +} diff --git a/packages/cli/src/apps.ts b/packages/cli/src/apps.ts new file mode 100644 index 0000000000..3b8d4b7e13 --- /dev/null +++ b/packages/cli/src/apps.ts @@ -0,0 +1,112 @@ +import { join } from "node:path"; +import { AidenMcpHost } from "../../../main/services/aiden-mcp-server.js"; +import { AidenMcpToolRunner, type AidenMcpServices } from "../../../main/services/aiden-mcp-tools.js"; +import { + AidenMcpProvenanceLog, + emptyAidenMcpProvenanceDocument, + parseAidenMcpProvenanceDocument, +} from "../../../main/services/aiden-mcp-provenance.js"; +import type { + AidenRemoteAgentAccess, + AidenRemoteStateRegistry, +} from "../../../main/services/aiden-remote-state.js"; +import { hostPlatformCapabilities } from "../../../main/services/host-platform-capabilities.js"; +import { atomicJson, readJson } from "./state.ts"; +import { CLI_MCP_DEFAULT_PORT, type CliAppConnection } from "./apps-display.ts"; + +export { CLI_MCP_DEFAULT_PORT, type CliAppConnection }; + +export const CLI_MCP_PROVENANCE_FILE = "aiden-mcp-chat-provenance.json"; + +export interface CliMcpHostOptions { + agentDir: string; + state: AidenRemoteStateRegistry; + services(): Promise; + /** The Remote runtime's revocation, shared with `aiden remote revoke`. */ + revokeDevice(deviceId: string): Promise; + appVersion: string; + defaultPort?: number; +} + +/** The server's MCP host, wired like the desktop's, with its files in the agent directory. */ +export function createCliMcpHost(options: CliMcpHostOptions): AidenMcpHost { + const provenanceFile = join(options.agentDir, CLI_MCP_PROVENANCE_FILE); + const provenance = new AidenMcpProvenanceLog({ + load: async () => parseAidenMcpProvenanceDocument(readJson(provenanceFile, emptyAidenMcpProvenanceDocument())), + save: async (document) => atomicJson(provenanceFile, document), + }); + const tools = new AidenMcpToolRunner({ + services: options.services, + acquireAuthorization: (appId, tracksMutationDrain) => options.state.acquireDeviceAuthorization(appId, tracksMutationDrain), + recordProvenance: (chatId, entry) => provenance.record(chatId, entry), + appVersion: options.appVersion, + hostName: async () => (await options.state.snapshot()).displayName, + }); + return new AidenMcpHost({ + state: options.state, + tools, + supported: () => hostPlatformCapabilities().mcpServer, + defaultPort: options.defaultPort ?? CLI_MCP_DEFAULT_PORT, + revokeDevice: options.revokeDevice, + appVersion: options.appVersion, + // Category-only, as on the desktop: never a credential, app name, chat or path. + log: (event, details) => { + const problem = typeof details?.problem === "string" ? ` (${details.problem})` : ""; + if (event === "start-failed") process.stderr.write(`aiden: The MCP server could not start${problem}.\n`); + }, + }); +} + +export const CLI_APPS_USAGE = "Usage: apps list | connect [--access read|supervised] | revoke | on | off"; + +/** Daemon side of `aiden apps`. Sends no analytics. */ +export async function cliAppsCommand(host: AidenMcpHost, args: string[]): Promise { + const [action = "list", ...rest] = args; + switch (action) { + case "list": + if (rest.length) throw new Error(CLI_APPS_USAGE); + return { server: await host.status(), apps: await host.listApps() }; + case "connect": { + const { name, access } = parseConnectArgs(rest); + // The server stays off until an app is connected. Turning it on before + // the token is issued means no failure here can lose a token. + await host.setEnabled(true); + const issued = await host.issueApp({ name, access }); + const connection: CliAppConnection = { app: issued.app, token: issued.credential, server: await host.status() }; + return connection; + } + case "revoke": { + if (rest.length !== 1 || !rest[0]) throw new Error("Usage: apps revoke (see `aiden apps list`)"); + const revoked = await host.revokeApp(rest[0]); + if (!revoked) throw new Error("No connected app has that id. See `aiden apps list`."); + return { revoked }; + } + case "on": + case "off": + if (rest.length) throw new Error(CLI_APPS_USAGE); + return host.setEnabled(action === "on"); + default: + throw new Error(CLI_APPS_USAGE); + } +} + +function parseConnectArgs(args: string[]): { name: string; access: AidenRemoteAgentAccess } { + const words: string[] = []; + let access: AidenRemoteAgentAccess = "read"; + for (let index = 0; index < args.length; index += 1) { + const arg = args[index]!; + if (arg === "--access" || arg.startsWith("--access=")) { + const value = arg === "--access" ? args[++index] : arg.slice("--access=".length); + if (value !== "read" && value !== "supervised") throw new Error("Access is read or supervised."); + access = value; + } else if (arg.startsWith("--")) { + throw new Error(CLI_APPS_USAGE); + } else { + words.push(arg); + } + } + const name = words.join(" ").trim(); + if (!name) throw new Error("Name the app, for example `aiden apps connect \"Claude Code\"`."); + if (name.length > 80) throw new Error("An app name is at most 80 characters."); + return { name, access }; +} diff --git a/packages/cli/src/command-help.ts b/packages/cli/src/command-help.ts index bb68f2213c..47b235c8d4 100644 --- a/packages/cli/src/command-help.ts +++ b/packages/cli/src/command-help.ts @@ -8,6 +8,8 @@ export const CLI_COMMAND_HELP = `Aiden commands: remote status|devices|pair lan|tailscale|pair-status|pair-cancel |revoke |roots|approve-root remote network local|tailscale|both Who can reach the server; Tailscale is set up for you remote check Check each step a phone needs to reach the server, with fixes + apps list|connect [--access read|supervised]|revoke |on|off + Outside apps (Claude Code, Codex) on the local /mcp endpoint auth list|login|logout Provider credentials (OAuth or API key) provider list|import Custom OpenAI-compatible/Ollama/LM Studio providers workspace list|add|remove|access|scratch Workspace registry and tool approval tiers diff --git a/packages/cli/src/commands.ts b/packages/cli/src/commands.ts index a6ffd7d22b..1b8ee9abd5 100644 --- a/packages/cli/src/commands.ts +++ b/packages/cli/src/commands.ts @@ -65,6 +65,19 @@ export async function dispatchCommand(agentDir: string, cwd: string, args: strin } break; } + case "apps": { + // Outside apps (Claude Code, Codex) that reach this server's loopback `/mcp` endpoint. + result = await (await import("./schedules.ts")).remoteDaemonCommand(agentDir, "apps", rest); + if (rest[0] === "connect") { + if (process.stdout.isTTY) { + const { renderAppConnection } = await import("./apps-display.ts"); + process.stdout.write(renderAppConnection(result as import("./apps-display.ts").CliAppConnection) + "\n"); + return true; + } + process.stderr.write("warning: the connection below contains the app's token, shown only once — keep it out of logs.\n"); + } + break; + } case "serve": await (await import("./serve-command.ts")).serveCommand(agentDir, rest); return true; case "service": await (await import("./service.ts")).serviceCommand(agentDir, rest); return true; case "telemetry": result = await (await import("./telemetry.ts")).telemetryCommand(agentDir, rest); break; diff --git a/packages/cli/src/parity-test-api.ts b/packages/cli/src/parity-test-api.ts index f724391f25..107ca11cb6 100644 --- a/packages/cli/src/parity-test-api.ts +++ b/packages/cli/src/parity-test-api.ts @@ -20,6 +20,8 @@ export * from "./daemon-turn-lifecycle.ts"; export * from "./daemon-approvals.ts"; export * from "./speech.ts"; export * from "./remote.ts"; +export { cliAppsCommand, createCliMcpHost, CLI_MCP_DEFAULT_PORT } from "./apps.ts"; +export { aidenMcpClientSnippets, renderAppConnection } from "./apps-display.ts"; export { daemonRemoteSummary, showStartupPairing } from "./serve-command.ts"; export { resolveTailscaleBinary } from "../../../main/services/aiden-remote-tailscale.js"; export { AidenRemoteSpeechServiceCore } from "../../../main/services/aiden-remote-speech-core.js"; diff --git a/packages/cli/src/remote-chats.ts b/packages/cli/src/remote-chats.ts index 4ac4249c80..fd90e5c5fe 100644 --- a/packages/cli/src/remote-chats.ts +++ b/packages/cli/src/remote-chats.ts @@ -90,6 +90,8 @@ export async function createCliRemoteChats(agentDir: string, daemon: ReturnType< const device = (await state.snapshot()).devices.find((candidate) => candidate.id === deviceId); return device?.type === "mac" || device?.type === "linux"; }, + // An outside MCP app's chats and turns are never product analytics. + deviceReportsAnalytics: async (deviceId) => (await state.snapshot()).devices.find((candidate) => candidate.id === deviceId)?.type !== "agent", retainedBotChatAuthorizer: (input) => bots.application.authorizeRetainedChat({ ...input, audienceId: input.deviceId }), botTurnAuthorityPreflight: (input) => bots.preflight(input), // Refused before the ledger records anything, so the same key runs after `aiden bots unpause`. diff --git a/packages/cli/src/remote.ts b/packages/cli/src/remote.ts index 66b1fddb0b..70f02e1733 100644 --- a/packages/cli/src/remote.ts +++ b/packages/cli/src/remote.ts @@ -42,6 +42,7 @@ import { createAidenRemoteHostFeedSource } from "../../../main/services/aiden-re import { AidenRemoteHostRunService } from "../../../main/services/aiden-remote-host-runs.js"; import { AidenRemoteServiceError } from "../../../main/services/aiden-remote-errors.js"; import { liveRunAttention } from "../../../main/services/chat-pending-attention.js"; +import { cliAppsCommand, createCliMcpHost } from "./apps.ts"; const BONJOUR_RETRY_MS = 30_000; @@ -157,7 +158,7 @@ export async function setRemoteNetwork(service: TailscaleTransportService, tails } /** Shared protocol services retain their own identity, revision and authorization checks. */ -export async function createCliRemote(agentDir: string, chats: ReturnType, scheduler: ReturnType, options: { port?: number; discovery?: AidenRemoteBonjourPublisher; bots?: Awaited> } = {}) { +export async function createCliRemote(agentDir: string, chats: ReturnType, scheduler: ReturnType, options: { port?: number; mcpPort?: number; discovery?: AidenRemoteBonjourPublisher; bots?: Awaited> } = {}) { const bots = options.bots ?? await createCliBots(agentDir, chats); chats.setBots(bots); bots.setScheduler(scheduler); @@ -195,6 +196,10 @@ export async function createCliRemote(agentDir: string, chats: ReturnType> | undefined; + // One chat runtime for Remote and the MCP server, whichever asks first. + let chatApiLoad: Promise>> | undefined; + const loadChatApi = () => chatApiLoad ??= createCliRemoteChats(agentDir, chats, workspaces, state, idempotency, persistIdempotency, bots) + .then((api) => { chatApi = api; return api; }, (error: unknown) => { chatApiLoad = undefined; throw error; }); // Host-wide runs and the `/host/events` feed for paired desktops, rebuilt with each Remote start as on the desktop. let hostFeed: AidenRemoteHostFeedService | undefined; let hostRuns: AidenRemoteHostRunService | undefined; @@ -209,11 +214,11 @@ export async function createCliRemote(agentDir: string, chats: ReturnType loadOrCreateAidenRemoteTlsIdentity({ directory: join(agentDir, "remote-tls"), hostnames: lanHostnames.certificate, opensslPath: "openssl" }), workspaceApi: async (instanceId) => { const browser = new AidenRemoteWorkspaceBrowserService({ instanceId, state, approvalStore: agentDir }); - chatApi ??= await createCliRemoteChats(agentDir, chats, workspaces, state, idempotency, persistIdempotency, bots); + const remoteChats = await loadChatApi(); await botSessions?.close(); - const botApi = createCliRemoteBots(agentDir, instanceId, bots, chats, chatApi, idempotency, persistIdempotency); + const botApi = createCliRemoteBots(agentDir, instanceId, bots, chats, remoteChats, idempotency, persistIdempotency); botSessions = botApi.botSessions; - const api = chatApi; + const api = remoteChats; hostRuns = new AidenRemoteHostRunService({ registry: chats.runs, now: Date.now, controls: { cancel: (runId) => chats.llmClient.cancelRun(runId), // A phone-owned approval settles through the stream service so its device records stay consistent. @@ -245,8 +250,8 @@ export async function createCliRemote(agentDir: string, chats: ReturnType { for (const detach of detachers) detach(); }; return { ...botApi, - chats: chatApi.chats, streams: chatApi.streams, models: chatApi.models, hostFeed: feed, hostRuns, - schedules: new AidenRemoteScheduleService({ application: scheduleApplication, models: chatApi.models, idempotency, persistIdempotency }), + chats: remoteChats.chats, streams: remoteChats.streams, models: remoteChats.models, hostFeed: feed, hostRuns, + schedules: new AidenRemoteScheduleService({ application: scheduleApplication, models: remoteChats.models, idempotency, persistIdempotency }), workspaceBrowser: browser, workspaces: new AidenRemoteWorkspaceService({ application: workspaces.application, browser, idempotency, persistIdempotency }), files: new AidenRemoteFileService({ instanceId, application: workspaces.environment, owners }), @@ -257,13 +262,42 @@ export async function createCliRemote(agentDir: string, chats: ReturnType settings.load(), setSettings: (patch) => settings.update((value) => { Object.assign(value, patch); return value; }) }), usage: createUsageStore({ load: async () => readJson(join(agentDir, "usage.json"), createEmptyUsageDatabase()), save: async (value) => atomicJson(join(agentDir, "usage.json"), value) }), speech: speech.service, - settle: () => chatApi!.streams.settlePersistence(), + settle: () => remoteChats.streams.settlePersistence(), }; }, }); - return { service, state, workspaces, roots, bots, - async start() { await service.initialize(); await service.setEnabled(true); const status = await service.status(); if (!status.running) throw new Error(status.error ?? "Remote listeners could not start."); }, - async stop() { closeHostFeed(); chatApi?.stopInbox(); await botSessions?.close(); await chats.stop(); await service.stopAndSettle(); await speech.stop(); await scheduledMcp.close(); if (!options.bots) await bots.stop(); }, + // As on the desktop: drain host-wide and Bot subscriptions before and after the revocation fence; no run is cancelled. + const revokeDevice = async (id: string) => { + const drain = () => { hostFeed?.revokeDevice(id); hostRuns?.revokeDevice(id); botSessions?.revokeDevice(id); }; + drain(); + const revoked = await revokeAidenRemoteRuntimeDevice({ state, streams: chatApi?.streams, chats: chatApi?.chats, workspaceOwners: owners }, id); + drain(); + await bots.application.revokeNoticeAudience(id); + return revoked; + }; + // The loopback `/mcp` endpoint for outside apps. Its own services, built + // over the shared chat runtime, so an app's request never rebuilds Remote's. + let mcpWorkspaces: { instanceId: string; service: AidenRemoteWorkspaceService } | undefined; + const mcp = createCliMcpHost({ agentDir, state, revokeDevice, appVersion: VERSION, defaultPort: options.mcpPort, + services: async () => { + const api = await loadChatApi(); + const { instanceId } = await state.snapshot(); + if (mcpWorkspaces?.instanceId !== instanceId) { + const browser = new AidenRemoteWorkspaceBrowserService({ instanceId, state, approvalStore: agentDir }); + mcpWorkspaces = { instanceId, service: new AidenRemoteWorkspaceService({ application: workspaces.application, browser, idempotency, persistIdempotency }) }; + } + return { chats: api.chats, streams: api.streams, workspaces: mcpWorkspaces.service }; + }, + }); + return { service, state, workspaces, roots, bots, mcp, + async start() { + await service.initialize(); await service.setEnabled(true); const status = await service.status(); if (!status.running) throw new Error(status.error ?? "Remote listeners could not start."); + // Off until an app is connected; a port problem is reported in `aiden apps list`, never fatal. + await mcp.initialize().catch(() => process.stderr.write("aiden: The MCP server could not start.\n")); + }, + apps: (args: string[]) => cliAppsCommand(mcp, args), + // The MCP listener closes first, so no outside app starts a turn while the rest stops. + async stop() { await mcp.stop(); closeHostFeed(); chatApi?.stopInbox(); await botSessions?.close(); await chats.stop(); await service.stopAndSettle(); await speech.stop(); await scheduledMcp.close(); if (!options.bots) await bots.stop(); }, async command(args: string[]) { const [action = "status", value] = args; switch (action) { @@ -271,12 +305,7 @@ export async function createCliRemote(agentDir: string, chats: ReturnType { hostFeed?.revokeDevice(value); hostRuns?.revokeDevice(value); botSessions?.revokeDevice(value); }; - drain(); - const revoked = await revokeAidenRemoteRuntimeDevice({ state, streams: chatApi?.streams, chats: chatApi?.chats, workspaceOwners: owners }, value); - drain(); - await bots.application.revokeNoticeAudience(value); return { revoked }; + return { revoked: await revokeDevice(value) }; } case "pair": { if (value !== "lan" && value !== "tailscale") throw new Error("Usage: remote pair lan|tailscale"); return value === "tailscale" ? beginTailscalePairing(service, tailscale) : service.beginPairing(value); } case "pair-status": return service.pairingStatus() ?? { state: "none" }; diff --git a/packages/cli/src/serve.ts b/packages/cli/src/serve.ts index 9aaccf31d1..ccd6c741d3 100644 --- a/packages/cli/src/serve.ts +++ b/packages/cli/src/serve.ts @@ -86,10 +86,11 @@ async function serveOwned(agentDir: string, signal: AbortSignal, options: { remo try { if (!lifetime.acceptsCommands) throw new Error("The Aiden daemon is shutting down."); const request = JSON.parse(buffer.slice(0, end)); - if (!["schedule", "remote", "bots", "workspace", "serve", "hooks"].includes(request.command) || !Array.isArray(request.args) || request.args.some((arg: unknown) => typeof arg !== "string")) throw new Error("Invalid daemon command."); + if (!["schedule", "remote", "bots", "workspace", "serve", "hooks", "apps"].includes(request.command) || !Array.isArray(request.args) || request.args.some((arg: unknown) => typeof arg !== "string")) throw new Error("Invalid daemon command."); if (request.command === "hooks" && !hooks) throw new Error("Hooks are off on this server: they run only on macOS and Linux, and the hook store must be readable."); if (request.command === "remote" && !remote) throw new Error("Remote is off for this server. Restart it with `aiden serve` (without --no-remote) to use Remote controls."); - const result = request.command === "serve" ? await serveStatus(remote, request.args) : request.command === "hooks" ? await hooksCommand(agentDir, hooks!, request.args) : request.command === "workspace" ? await workspaceCommand(agentDir, request.args, (remote?.workspaces ?? workspaceRuntime).application) : request.command === "bots" ? await bots.command(request.args) : request.command === "remote" ? await remote!.command(request.args) : await runtime.command(request.args); + if (request.command === "apps" && !remote) throw new Error("Outside apps reach this server through Remote, which is off. Restart it with `aiden serve` (without --no-remote) to connect apps."); + const result = request.command === "serve" ? await serveStatus(remote, request.args) : request.command === "hooks" ? await hooksCommand(agentDir, hooks!, request.args) : request.command === "workspace" ? await workspaceCommand(agentDir, request.args, (remote?.workspaces ?? workspaceRuntime).application) : request.command === "bots" ? await bots.command(request.args) : request.command === "remote" ? await remote!.command(request.args) : request.command === "apps" ? await remote!.apps(request.args) : await runtime.command(request.args); await reply({ result }); } catch (error) { await reply({ error: error instanceof Error ? error.message : String(error) }); } })()); @@ -115,6 +116,8 @@ async function serveOwned(agentDir: string, signal: AbortSignal, options: { remo if (remote) { const status = await remote.service.status().catch(() => undefined); process.stderr.write(`Aiden Remote listening${status ? ` on port ${status.lanPort}${status.lanEndpoint ? ` (${status.lanEndpoint})` : ""}` : ""}. Pair a device with \`aiden remote pair lan|tailscale\`.\n`); + const mcp = await remote.mcp.status().catch(() => undefined); + if (mcp?.running && mcp.url) process.stderr.write(`Aiden MCP server listening at ${mcp.url} for connected apps (this computer only).\n`); } else process.stderr.write("Aiden Remote is off.\n"); if (signal.aborted) return; lifetime.markServing(); diff --git a/packages/cli/tests/mcp-apps.test.mjs b/packages/cli/tests/mcp-apps.test.mjs new file mode 100644 index 0000000000..1c3893e5da --- /dev/null +++ b/packages/cli/tests/mcp-apps.test.mjs @@ -0,0 +1,246 @@ +// `aiden serve` hosts the loopback `/mcp` endpoint, and `aiden apps` +// connects, lists and disconnects the outside apps that use it. Everything +// runs through the real CLI: the daemon, its control socket and the listener. +import assert from "node:assert/strict"; +import { spawn, spawnSync } from "node:child_process"; +import { once } from "node:events"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { createServer, request as httpRequest } from "node:http"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import test from "node:test"; +import * as api from "../dist/parity-test-api.js"; + +const pkg = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const cli = join(pkg, "dist", "app", "cli.js"); + +function sandbox(t) { + const root = mkdtempSync(join(tmpdir(), "aiden-mcp-apps-")); + const home = join(root, "home"), agentDir = join(root, "agent"), workspace = join(root, "project"); + mkdirSync(home, { recursive: true }); mkdirSync(workspace, { recursive: true }); + t.after(() => rmSync(root, { recursive: true, force: true })); + // CI keeps analytics off for runs nobody started; the server would send nothing anyway. + return { agentDir, workspace, env: { ...process.env, HOME: home, AIDEN_CODING_AGENT_DIR: agentDir, PI_OFFLINE: "1", AIDEN_ANALYTICS: "0" } }; +} + +function runCli(args, env) { + return spawnSync(process.execPath, [cli, ...args], { encoding: "utf8", timeout: 60_000, env }); +} + +function json(result) { + assert.equal(result.status, 0, result.stderr || result.stdout); + return JSON.parse(result.stdout); +} + +async function serve(t, env, args = []) { + const child = spawn(process.execPath, [cli, "serve", ...args], { env, stdio: ["ignore", "pipe", "pipe"] }); + const output = { text: "" }; + child.stdout.setEncoding("utf8").on("data", (chunk) => { output.text += chunk; }); + child.stderr.setEncoding("utf8").on("data", (chunk) => { output.text += chunk; }); + const stop = async () => { + if (child.exitCode !== null || child.signalCode !== null) return; + const exited = once(child, "exit"); + child.kill("SIGTERM"); + const timer = setTimeout(() => child.kill("SIGKILL"), 15_000); + await exited; + clearTimeout(timer); + }; + t.after(stop); + const ready = /Aiden Remote listening|Aiden Remote is off/; + const deadline = Date.now() + 60_000; + while (!ready.test(output.text)) { + if (child.exitCode !== null) throw new Error(`serve exited early (${child.exitCode}):\n${output.text}`); + if (Date.now() > deadline) throw new Error(`serve did not become ready:\n${output.text}`); + await new Promise((done) => setTimeout(done, 100)); + } + return { output, stop }; +} + +/** An OpenAI-compatible model that answers every turn with one line of text. */ +async function fakeProvider(t, agentDir) { + const server = createServer(async (request, response) => { + request.resume(); + await once(request, "end"); + response.writeHead(200, { "content-type": "text/event-stream" }); + response.write(`data: ${JSON.stringify({ id: "x", object: "chat.completion.chunk", choices: [{ index: 0, delta: { role: "assistant", content: "Hello from the server" }, finish_reason: null }] })}\n\n`); + response.write(`data: ${JSON.stringify({ id: "x", object: "chat.completion.chunk", choices: [{ index: 0, delta: {}, finish_reason: "stop" }] })}\n\n`); + response.end("data: [DONE]\n\n"); + }); + await new Promise((done) => server.listen(0, "127.0.0.1", done)); + t.after(() => { server.closeAllConnections(); server.close(); }); + api.atomicJson(join(agentDir, "models.json"), { providers: { "cli-test": { api: "openai-completions", baseUrl: `http://127.0.0.1:${server.address().port}/v1`, apiKey: "test-only", models: [{ id: "test", name: "Test", reasoning: false, input: ["text"], contextWindow: 32000, maxTokens: 4096, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }] } } }); +} + +let rpcId = 0; +/** One MCP JSON-RPC request over Streamable HTTP, as Claude Code or Codex would send it. */ +function mcp(url, token, method, params = {}) { + const target = new URL(url); + const body = JSON.stringify({ jsonrpc: "2.0", id: ++rpcId, method, params }); + return new Promise((done, reject) => { + const request = httpRequest({ host: target.hostname, port: target.port, path: target.pathname, method: "POST", + headers: { "content-type": "application/json", accept: "application/json, text/event-stream", "content-length": Buffer.byteLength(body), + ...(token ? { authorization: `Bearer ${token}` } : {}) } }, (response) => { + let data = ""; response.setEncoding("utf8"); response.on("data", (chunk) => { data += chunk; }); + response.on("end", () => done({ status: response.statusCode, body: response.headers["content-type"]?.includes("json") && data ? JSON.parse(data) : data })); + }); + request.setTimeout(60_000, () => request.destroy(new Error(`MCP request timed out: ${method}`))); + request.on("error", reject); + request.end(body); + }); +} + +async function callTool(url, token, name, args) { + const response = await mcp(url, token, "tools/call", { name, arguments: args }); + assert.equal(response.status, 200, JSON.stringify(response)); + assert.equal(response.body.result?.isError, undefined, JSON.stringify(response.body)); + return response.body.result.structuredContent; +} + +async function toolNames(url, token) { + const response = await mcp(url, token, "tools/list"); + assert.equal(response.status, 200, JSON.stringify(response)); + return response.body.result.tools.map((tool) => tool.name); +} + +test("aiden serve keeps /mcp off until an app is connected, then the app runs a chat until it is disconnected", async (t) => { + const { agentDir, workspace, env } = sandbox(t); + await fakeProvider(t, agentDir); + const { id: workspaceId } = json(runCli(["workspace", "add", workspace], env)); + const first = await serve(t, env); + + // Off by default: no listener, nothing saved, no app. + const before = json(runCli(["apps", "list"], env)); + assert.equal(before.server.enabled, false); + assert.equal(before.server.running, false); + assert.equal(before.server.url, undefined); + assert.deepEqual(before.apps, []); + + // Piped output is a log: the token comes as JSON with a warning on stderr. + const connectedResult = runCli(["apps", "connect", "Claude", "Code", "--access", "supervised"], env); + const connected = json(connectedResult); + assert.match(connectedResult.stderr, /token.*keep it out of logs/); + assert.equal(connected.app.name, "Claude Code"); + assert.equal(connected.app.access, "supervised"); + assert.match(connected.token, /^[A-Za-z0-9_-]{43}$/); + assert.equal(connected.server.running, true); + assert.match(connected.server.url, /^http:\/\/127\.0\.0\.1:\d+\/mcp$/); + const { url } = connected.server; + assert.match(first.output.text, /Aiden Remote listening/); + + // The token is what admits an app; nothing else does. + assert.equal((await mcp(url, undefined, "tools/list")).status, 401); + assert.equal((await mcp(url, "x".repeat(43), "tools/list")).status, 401); + + // Supervised can start chats; a Read app sees only the reading tools. + const supervisedTools = await toolNames(url, connected.token); + assert.ok(supervisedTools.includes("aiden_chat_start"), supervisedTools.join()); + const refused = runCli(["apps", "connect", "Codex", "--access", "admin"], env); + assert.notEqual(refused.status, 0, refused.stdout); + assert.match(refused.stderr, /read or supervised/); + const reader = json(runCli(["apps", "connect", "Codex"], env)); + assert.equal(reader.app.access, "read"); + const readTools = await toolNames(url, reader.token); + assert.ok(readTools.includes("aiden_chat_read"), readTools.join()); + assert.equal(readTools.includes("aiden_chat_start"), false, readTools.join()); + assert.ok(readTools.every((name) => supervisedTools.includes(name))); + + // A chat started by the app runs on the server's model and reads back. + const workspaces = await callTool(url, connected.token, "aiden_workspace_list", {}); + assert.ok(JSON.stringify(workspaces).includes(workspaceId), JSON.stringify(workspaces)); + const started = await callTool(url, connected.token, "aiden_chat_start", + { clientRequestId: "mcp-apps-test-0001", workspaceId, text: "Say hello", providerId: "cli-test", modelId: "test" }); + let run = { state: "running" }; + for (let attempt = 0; attempt < 6 && run.state === "running"; attempt += 1) { + run = await callTool(url, connected.token, "aiden_chat_wait", { chatId: started.chatId, runId: started.runId, timeoutSeconds: 10 }); + } + assert.equal(run.state, "done", JSON.stringify(run)); + const transcript = await callTool(url, connected.token, "aiden_chat_read", { chatId: started.chatId }); + assert.ok(JSON.stringify(transcript).includes("Hello from the server"), JSON.stringify(transcript)); + // The server notes, on this computer only, which app started the chat. + const provenance = JSON.parse(readFileSync(join(agentDir, "aiden-mcp-chat-provenance.json"), "utf8")); + assert.deepEqual(provenance.entries.map(({ chatId, appId, name }) => ({ chatId, appId, name })), + [{ chatId: started.chatId, appId: connected.app.id, name: "Claude Code" }]); + + // Disconnecting ends that token at once; the other app keeps working. + assert.deepEqual(json(runCli(["apps", "revoke", connected.app.id], env)), { revoked: true }); + assert.equal((await mcp(url, connected.token, "tools/list")).status, 401); + assert.ok((await toolNames(url, reader.token)).length > 0); + const listed = json(runCli(["apps", "list"], env)); + assert.ok(listed.apps.find((app) => app.id === connected.app.id).revokedAt, JSON.stringify(listed.apps)); + assert.equal(listed.apps.find((app) => app.id === reader.app.id).revokedAt, undefined); + + // Off closes the listener; the saved port comes back with it. + assert.equal(json(runCli(["apps", "off"], env)).running, false); + await assert.rejects(mcp(url, reader.token, "tools/list"), { code: "ECONNREFUSED" }); + const on = json(runCli(["apps", "on"], env)); + assert.equal(on.url, url); + assert.ok((await toolNames(url, reader.token)).length > 0); + + // A restarted server opens the same URL, so a configured app keeps working. + await first.stop(); + const second = await serve(t, env); + assert.match(second.output.text, new RegExp(`Aiden MCP server listening at ${url.replace(/[.]/g, "\\.")}`)); + assert.ok((await toolNames(url, reader.token)).length > 0); +}); + +test("aiden apps refuses what it cannot do, and never disconnects a phone", async (t) => { + const dir = mkdtempSync(join(tmpdir(), "aiden-mcp-apps-")); + t.after(() => rmSync(dir, { recursive: true, force: true })); + const original = process.env.AIDEN_CLI_ENTRY; process.env.AIDEN_CLI_ENTRY = cli; + t.after(() => { if (original === undefined) delete process.env.AIDEN_CLI_ENTRY; else process.env.AIDEN_CLI_ENTRY = original; }); + const daemon = api.createDaemonChats(dir), scheduler = api.createCliScheduler(dir); + // Distinct from the other suites' Remote ports: test files run in parallel. + const remote = await api.createCliRemote(dir, daemon, scheduler, { port: 49378, mcpPort: 0, discovery: { async start() {}, stop() {} } }); + t.after(async () => { await remote.stop(); await scheduler.service.stopAndSettle(); }); + await remote.start(); + + for (const [args, pattern] of [ + [["connect"], /Name the app/], + [["connect", "Claude", "--access", "admin"], /read or supervised/], + [["connect", "x".repeat(81)], /at most 80/], + [["connect", "Claude", "--scope", "user"], /Usage: apps/], + [["revoke", "dev_unknown"], /No connected app/], + [["rename"], /Usage: apps/], + ]) await assert.rejects(remote.apps(args), pattern, args.join(" ")); + // A refused connect turned nothing on and connected nothing. + const listed = await remote.apps(["list"]); + assert.equal(listed.server.enabled, false); + assert.equal(listed.server.running, false); + assert.deepEqual(listed.apps, []); + + // A phone's id is not an app's, so `aiden apps revoke` leaves it paired. + const phone = await remote.state.issueDevice({ name: "Phone", type: "iphone", clientVersion: "test" }); + await assert.rejects(remote.apps(["revoke", phone.device.id]), /No connected app/); + const devices = await remote.state.listDevices(); + assert.equal(devices.find((device) => device.id === phone.device.id)?.revokedAt, undefined, JSON.stringify(devices)); + // `aiden apps list` shows only the apps, never the phone. + const app = await remote.apps(["connect", "Codex"]); + assert.match(app.server.url, /^http:\/\/127\.0\.0\.1:\d+\/mcp$/); + assert.deepEqual((await remote.apps(["list"])).apps.map(({ id }) => id), [app.app.id]); +}); + +test("aiden serve --no-remote has no /mcp, and aiden apps says how to get it", async (t) => { + const { env } = sandbox(t); + await serve(t, env, ["--no-remote"]); + const result = runCli(["apps", "list"], env); + assert.notEqual(result.status, 0); + assert.match(result.stderr, /without --no-remote/); +}); + +test("the Claude Code and Codex commands keep the token out of their config files", () => { + const url = "http://127.0.0.1:49500/mcp", token = "t".repeat(43); + const snippets = api.aidenMcpClientSnippets(url, token); + assert.ok(snippets.environment.includes(token)); + for (const command of [snippets.claude, snippets.codex]) { + assert.ok(command.includes(url), command); + assert.equal(command.includes(token), false, command); + assert.ok(command.includes("AIDEN_MCP_TOKEN"), command); + } + // A server that could not start gives no commands to copy, only the way to retry. + const blocked = api.renderAppConnection({ token, app: { id: "dev_1", name: "Claude Code", access: "read" }, + server: { supported: true, enabled: true, running: false, port: 49500, problem: "port_in_use" } }); + assert.equal(blocked.includes("claude mcp add"), false); + assert.match(blocked, /aiden apps on/); + assert.equal(blocked.split(token).length - 1, 1, "the token is shown once"); +}); From 6fa6b5ac62407cf4dc8e0cd28bbad0bf5ade445e Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Wed, 11 Nov 2026 16:17:27 -0500 Subject: [PATCH 3/7] aiden apps revoke: disconnect an app while Bot storage waits for repair The MCP host revokes with the desktop's when-available mode: the token is tombstoned first, so a BotCapabilityUnavailableError while clearing Bot notices is reported on stderr instead of failing the revoke. aiden remote revoke keeps requiring the notice cleanup. Co-Authored-By: Claude Opus 5.5 --- packages/cli/src/remote.ts | 14 +++++++++++--- packages/cli/tests/mcp-apps.test.mjs | 24 +++++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/remote.ts b/packages/cli/src/remote.ts index 70f02e1733..2898e0b773 100644 --- a/packages/cli/src/remote.ts +++ b/packages/cli/src/remote.ts @@ -30,6 +30,7 @@ import { createCliSpeech } from "./speech.ts"; import { createCliRemoteChats } from "./remote-chats.ts"; import { tailscaleSetupMessage, withTailscaleSetupMessage } from "./tailscale-setup-message.ts"; import { revokeAidenRemoteRuntimeDevice } from "../../../main/services/aiden-remote-revocation.js"; +import { BotCapabilityUnavailableError } from "../../../main/services/bot-capability-store-core.js"; import { AidenRemoteScheduleService } from "../../../main/services/aiden-remote-schedules.js"; import { createScheduledTaskApplicationService } from "../../../main/services/scheduled-task-application-service.js"; import { listScheduledScripts } from "../../../main/services/schedule-script.js"; @@ -267,18 +268,25 @@ export async function createCliRemote(agentDir: string, chats: ReturnType { + const revokeDevice = async (id: string, botNotices: "required" | "when-available" = "required") => { const drain = () => { hostFeed?.revokeDevice(id); hostRuns?.revokeDevice(id); botSessions?.revokeDevice(id); }; drain(); const revoked = await revokeAidenRemoteRuntimeDevice({ state, streams: chatApi?.streams, chats: chatApi?.chats, workspaceOwners: owners }, id); drain(); - await bots.application.revokeNoticeAudience(id); + try { + await bots.application.revokeNoticeAudience(id); + } catch (error) { + // As on the desktop: an outside app's token is already tombstoned above, so + // Bot storage that is waiting for repair must not report the app as connected. + if (botNotices === "required" || !(error instanceof BotCapabilityUnavailableError)) throw error; + process.stderr.write("aiden: The app is disconnected, but Bot storage needs repair before its Bot notices can be cleared.\n"); + } return revoked; }; // The loopback `/mcp` endpoint for outside apps. Its own services, built // over the shared chat runtime, so an app's request never rebuilds Remote's. let mcpWorkspaces: { instanceId: string; service: AidenRemoteWorkspaceService } | undefined; - const mcp = createCliMcpHost({ agentDir, state, revokeDevice, appVersion: VERSION, defaultPort: options.mcpPort, + const mcp = createCliMcpHost({ agentDir, state, revokeDevice: (id) => revokeDevice(id, "when-available"), appVersion: VERSION, defaultPort: options.mcpPort, services: async () => { const api = await loadChatApi(); const { instanceId } = await state.snapshot(); diff --git a/packages/cli/tests/mcp-apps.test.mjs b/packages/cli/tests/mcp-apps.test.mjs index 1c3893e5da..b122b30101 100644 --- a/packages/cli/tests/mcp-apps.test.mjs +++ b/packages/cli/tests/mcp-apps.test.mjs @@ -4,7 +4,7 @@ import assert from "node:assert/strict"; import { spawn, spawnSync } from "node:child_process"; import { once } from "node:events"; -import { mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { createServer, request as httpRequest } from "node:http"; import { tmpdir } from "node:os"; import { dirname, join, resolve } from "node:path"; @@ -220,6 +220,28 @@ test("aiden apps refuses what it cannot do, and never disconnects a phone", asyn assert.deepEqual((await remote.apps(["list"])).apps.map(({ id }) => id), [app.app.id]); }); +test("aiden apps revoke disconnects an app while Bot storage waits for repair", async (t) => { + const dir = mkdtempSync(join(tmpdir(), "aiden-mcp-apps-")); + t.after(() => rmSync(dir, { recursive: true, force: true })); + const original = process.env.AIDEN_CLI_ENTRY; process.env.AIDEN_CLI_ENTRY = cli; + t.after(() => { if (original === undefined) delete process.env.AIDEN_CLI_ENTRY; else process.env.AIDEN_CLI_ENTRY = original; }); + const daemon = api.createDaemonChats(dir), scheduler = api.createCliScheduler(dir); + const remote = await api.createCliRemote(dir, daemon, scheduler, { port: 49380, mcpPort: 0, discovery: { async start() {}, stop() {} } }); + t.after(async () => { await remote.stop(); await scheduler.service.stopAndSettle(); }); + await remote.start(); + const app = await remote.apps(["connect", "Codex"]); + const tools = await mcp(app.server.url, app.token, "tools/list"); + assert.equal(tools.status, 200); + + // A damaged rollback checkpoint leaves Bot access unavailable until repaired. + writeFileSync(join(dir, "bot-service", "bot-capability-state-head.json"), "{}"); + await assert.rejects(remote.bots.application.revokeNoticeAudience("dev_probe"), { name: "BotCapabilityUnavailableError" }); + + assert.deepEqual(await remote.apps(["revoke", app.app.id]), { revoked: true }); + assert.equal((await mcp(app.server.url, app.token, "tools/list")).status, 401); + assert.ok((await remote.apps(["list"])).apps.find(({ id }) => id === app.app.id).revokedAt); +}); + test("aiden serve --no-remote has no /mcp, and aiden apps says how to get it", async (t) => { const { env } = sandbox(t); await serve(t, env, ["--no-remote"]); From 77378e5063b825eef7e55cdf5dd9b4819a6ac0fe Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Wed, 11 Nov 2026 16:33:36 -0500 Subject: [PATCH 4/7] aiden apps: count an app name's characters, and document the any-port fallback An app name's 80-character limit counted UTF-16 units, so 41 emoji were refused. It now counts code points, like the other names Aiden keeps. The docs said the server only ever uses 49500 and the next seven ports; on first start with all eight busy, the shared host lets the system pick a free loopback port and saves it. Co-Authored-By: Claude Opus 5.5 --- docs/aiden-mcp-server.md | 3 ++- packages/cli/README.md | 2 +- packages/cli/src/apps.ts | 2 +- packages/cli/tests/mcp-apps.test.mjs | 7 ++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/aiden-mcp-server.md b/docs/aiden-mcp-server.md index 776da1dd9d..9b61012ba4 100644 --- a/docs/aiden-mcp-server.md +++ b/docs/aiden-mcp-server.md @@ -10,6 +10,7 @@ Status (2026-11-11): the server core is in the desktop main process, behind the - **Address:** `http://127.0.0.1:/mcp`, loopback only. The server is a dedicated listener and is never served on the Remote Access LAN TLS listener, Tailscale or any other interface. - **Port:** - Release builds try 49400 first, then the next seven ports up. Development builds start at 50400. + - If every candidate is busy the first time the server starts, the system picks a free loopback port instead. - The first port that binds is saved in Aiden's Remote state file, so the URL stays the same across restarts and an app's configuration keeps working. - If another program later holds the saved port, the server reports `port_in_use` rather than moving, because moving would break every configured app silently. - **Credential:** each app gets its own bearer token, a 43-character base64url secret shown once when it is issued. Aiden stores only a hash. A token is sent as `Authorization: Bearer `. @@ -104,7 +105,7 @@ The Remote Access threat model has the matching section: [`docs/security/aiden-r `aiden serve` in `packages/cli` hosts the same server, built from the same `AidenMcpHost` and tool runner, with the same tools, access levels, limits, token handling and request checks. The differences: -- **Port:** 49500 and the next seven ports, 100 above the desktop's range, so a desktop and a server on the same computer never take each other's port. Like the desktop, the first port that binds is saved, in the server's `remote.json`, and a busy saved port is reported as `port_in_use`. +- **Port:** 49500 and the next seven ports, 100 above the desktop's range, so a desktop and a server on the same computer never take each other's port. Like the desktop, if all eight are busy on first start, the system picks a free loopback port, and the first port that binds is saved, in the server's `remote.json`, and a busy saved port is reported as `port_in_use`. - **Administration:** `aiden apps`, sent to the running server over its private control socket: - `aiden apps connect [--access read|supervised]` turns the server on if it is off, issues the app (Read unless `--access supervised`) and shows its token once. - On a terminal it also prints the `claude mcp add` and `codex mcp add` commands, which read the token from `AIDEN_MCP_TOKEN` rather than storing it in the app's config. diff --git a/packages/cli/README.md b/packages/cli/README.md index cb3e5a9167..a93de0fa62 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -128,7 +128,7 @@ aiden apps off # closes the listener; ` ``` - **Off by default.** The listener opens only after the first `aiden apps connect` or an explicit `aiden apps on`, and the choice is saved in `remote.json`. -- **Address.** `http://127.0.0.1:/mcp`, on loopback only. The server tries port 49500 and the next seven, 100 above the desktop's 49400, so a desktop and a server on one computer never collide. The first port that binds is saved, so the URL stays the same across restarts; if another program later holds it, `aiden apps list` reports `port_in_use` instead of moving. +- **Address.** `http://127.0.0.1:/mcp`, on loopback only. The server tries port 49500 and the next seven, 100 above the desktop's 49400, so a desktop and a server on one computer never collide. If all eight are busy the first time it starts, the system picks a free loopback port instead. The first port that binds is saved, so the URL stays the same across restarts; if another program later holds it, `aiden apps list` reports `port_in_use` instead of moving. - **Connecting.** `connect ` defaults to Read access. On a terminal it prints the token once, with `claude mcp add` and `codex mcp add` commands that read it from `AIDEN_MCP_TOKEN` instead of writing it into their config; piped, it prints JSON and warns on stderr that the output holds the token. - **Requires Remote.** Apps share the Remote runtime's chats and device records, so `aiden serve --no-remote` has no MCP server and `aiden apps` says to restart without the flag. The listener never joins Remote's LAN or Tailscale listener. - **Admin over the control socket.** `aiden apps` needs a running server and talks to it over the private control socket, like `aiden remote`. Admin commands send no analytics, and chats an app starts send no usage events. diff --git a/packages/cli/src/apps.ts b/packages/cli/src/apps.ts index 3b8d4b7e13..7547683ab1 100644 --- a/packages/cli/src/apps.ts +++ b/packages/cli/src/apps.ts @@ -107,6 +107,6 @@ function parseConnectArgs(args: string[]): { name: string; access: AidenRemoteAg } const name = words.join(" ").trim(); if (!name) throw new Error("Name the app, for example `aiden apps connect \"Claude Code\"`."); - if (name.length > 80) throw new Error("An app name is at most 80 characters."); + if ([...name].length > 80) throw new Error("An app name is at most 80 characters."); return { name, access }; } diff --git a/packages/cli/tests/mcp-apps.test.mjs b/packages/cli/tests/mcp-apps.test.mjs index b122b30101..28b3256a92 100644 --- a/packages/cli/tests/mcp-apps.test.mjs +++ b/packages/cli/tests/mcp-apps.test.mjs @@ -199,6 +199,8 @@ test("aiden apps refuses what it cannot do, and never disconnects a phone", asyn [["connect"], /Name the app/], [["connect", "Claude", "--access", "admin"], /read or supervised/], [["connect", "x".repeat(81)], /at most 80/], + // The limit counts characters, not UTF-16 units, like the other names Aiden keeps. + [["connect", "\u{1F916}".repeat(81)], /at most 80/], [["connect", "Claude", "--scope", "user"], /Usage: apps/], [["revoke", "dev_unknown"], /No connected app/], [["rename"], /Usage: apps/], @@ -217,7 +219,10 @@ test("aiden apps refuses what it cannot do, and never disconnects a phone", asyn // `aiden apps list` shows only the apps, never the phone. const app = await remote.apps(["connect", "Codex"]); assert.match(app.server.url, /^http:\/\/127\.0\.0\.1:\d+\/mcp$/); - assert.deepEqual((await remote.apps(["list"])).apps.map(({ id }) => id), [app.app.id]); + const robots = "\u{1F916}".repeat(80); + const emoji = await remote.apps(["connect", robots]); + assert.equal(emoji.app.name, robots, "80 emoji is an 80-character name"); + assert.deepEqual((await remote.apps(["list"])).apps.map(({ id }) => id).sort(), [app.app.id, emoji.app.id].sort()); }); test("aiden apps revoke disconnects an app while Bot storage waits for repair", async (t) => { From 35875f8c2fb04378cf4e101a6af0812fd39b782e Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Wed, 11 Nov 2026 16:38:05 -0500 Subject: [PATCH 5/7] aiden apps revoke: use the shared Bot notice revoke policy Co-Authored-By: Claude Opus 5.5 --- packages/cli/src/remote.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/remote.ts b/packages/cli/src/remote.ts index 2898e0b773..80b2280869 100644 --- a/packages/cli/src/remote.ts +++ b/packages/cli/src/remote.ts @@ -30,7 +30,7 @@ import { createCliSpeech } from "./speech.ts"; import { createCliRemoteChats } from "./remote-chats.ts"; import { tailscaleSetupMessage, withTailscaleSetupMessage } from "./tailscale-setup-message.ts"; import { revokeAidenRemoteRuntimeDevice } from "../../../main/services/aiden-remote-revocation.js"; -import { BotCapabilityUnavailableError } from "../../../main/services/bot-capability-store-core.js"; +import { revokeBotNoticeAudience, type BotNoticeRevokePolicy } from "../../../main/services/bot-capability-store-core.js"; import { AidenRemoteScheduleService } from "../../../main/services/aiden-remote-schedules.js"; import { createScheduledTaskApplicationService } from "../../../main/services/scheduled-task-application-service.js"; import { listScheduledScripts } from "../../../main/services/schedule-script.js"; @@ -268,19 +268,14 @@ export async function createCliRemote(agentDir: string, chats: ReturnType { + const revokeDevice = async (id: string, botNotices: BotNoticeRevokePolicy = "required") => { const drain = () => { hostFeed?.revokeDevice(id); hostRuns?.revokeDevice(id); botSessions?.revokeDevice(id); }; drain(); const revoked = await revokeAidenRemoteRuntimeDevice({ state, streams: chatApi?.streams, chats: chatApi?.chats, workspaceOwners: owners }, id); drain(); - try { - await bots.application.revokeNoticeAudience(id); - } catch (error) { - // As on the desktop: an outside app's token is already tombstoned above, so - // Bot storage that is waiting for repair must not report the app as connected. - if (botNotices === "required" || !(error instanceof BotCapabilityUnavailableError)) throw error; + await revokeBotNoticeAudience(() => bots.application.revokeNoticeAudience(id), botNotices, () => { process.stderr.write("aiden: The app is disconnected, but Bot storage needs repair before its Bot notices can be cleared.\n"); - } + }); return revoked; }; // The loopback `/mcp` endpoint for outside apps. Its own services, built From f6eb360e75b41dedf18124f007a7000c3df1b77e Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Wed, 11 Nov 2026 17:07:14 -0500 Subject: [PATCH 6/7] aiden apps connect prints each app's own token variable The CLI's setup commands now use core's aidenMcpTokenEnvName, the same per-app AIDEN_MCP_TOKEN__ the desktop Settings sheet prints, so connecting a second app in one shell profile no longer replaces the first app's token. A real-shell test checks each app's commands send its own token. Co-Authored-By: Claude Opus 5.5 --- .memory/aiden-mcp-server.md | 2 +- docs/aiden-mcp-server.md | 2 +- packages/cli/README.md | 2 +- packages/cli/src/apps-display.ts | 20 +++++++++++++------ packages/cli/tests/mcp-apps.test.mjs | 29 ++++++++++++++++++++++++---- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/.memory/aiden-mcp-server.md b/.memory/aiden-mcp-server.md index 7a8018756a..0219f0205b 100644 --- a/.memory/aiden-mcp-server.md +++ b/.memory/aiden-mcp-server.md @@ -74,7 +74,7 @@ Core only: a loopback MCP server that lets Claude Code, Codex or any MCP client - `--no-remote` means no MCP server: `serve.ts` refuses `apps` with a restart hint. - **Port.** 49500–49507 (`CLI_MCP_DEFAULT_PORT`), a +100 shift from the desktop's 49400, mirroring Remote's 49220 → 49320. It is saved in `remote.json`. Tests pass `mcpPort: 0`. - **Off by default.** `connect` calls `setEnabled(true)` before `issueApp`, so a failure to enable never loses a just-issued token. An argument error refuses before either step. The default access is Read. -- **Connect output.** On a TTY, `commands.ts` renders text with the token once and `claude mcp add --scope user --transport http aiden --header 'Authorization: Bearer ${AIDEN_MCP_TOKEN}'` / `codex mcp add aiden --url --bearer-token-env-var AIDEN_MCP_TOKEN`; this matches W4b's choice. Piped output is JSON plus a stderr warning, like pairing. +- **Connect output.** On a TTY, `commands.ts` renders text with the token once and `claude mcp add --scope user --transport http aiden --header 'Authorization: Bearer ${AIDEN_MCP_TOKEN__}'` / `codex mcp add aiden --url --bearer-token-env-var AIDEN_MCP_TOKEN__`, the per-app name from core's `aidenMcpTokenEnvName` (renderer/shared/aiden-mcp-token-env.ts), the same one W4b's Settings sheet prints. Piped output is JSON plus a stderr warning, like pairing. - **Analytics.** `remote-chats.ts` passes `deviceReportsAnalytics` (false for `agent` devices), matching the desktop. `aiden apps` sends nothing. - **Docker.** Container loopback is unreachable from the host, which is documented. MCP without Remote would be a possible follow-up. - **Tests.** `packages/cli/tests/mcp-apps.test.mjs` (in the CLI `test` script; the registry covers it through `test:cli`): diff --git a/docs/aiden-mcp-server.md b/docs/aiden-mcp-server.md index 1528f1b014..5216678bec 100644 --- a/docs/aiden-mcp-server.md +++ b/docs/aiden-mcp-server.md @@ -109,7 +109,7 @@ The Remote Access threat model has the matching section: [`docs/security/aiden-r - **Port:** 49500 and the next seven ports, 100 above the desktop's range, so a desktop and a server on the same computer never take each other's port. Like the desktop, if all eight are busy on first start, the system picks a free loopback port, and the first port that binds is saved, in the server's `remote.json`, and a busy saved port is reported as `port_in_use`. - **Administration:** `aiden apps`, sent to the running server over its private control socket: - `aiden apps connect [--access read|supervised]` turns the server on if it is off, issues the app (Read unless `--access supervised`) and shows its token once. - - On a terminal it also prints the `claude mcp add` and `codex mcp add` commands, which read the token from `AIDEN_MCP_TOKEN` rather than storing it in the app's config. + - On a terminal it also prints the `claude mcp add` and `codex mcp add` commands, which read the token from the app's own `AIDEN_MCP_TOKEN__` variable (the same name Settings prints) rather than storing it in the app's config. - Piped, it prints JSON and warns on stderr that the output holds the token. - `aiden apps list` shows the server's status and the connected apps, revoked ones with `revokedAt`. - `aiden apps revoke ` disconnects one app through the same revocation path as `aiden remote revoke`. A phone's or Mac's id is refused. diff --git a/packages/cli/README.md b/packages/cli/README.md index a93de0fa62..31307b22b2 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -129,7 +129,7 @@ aiden apps off # closes the listener; ` - **Off by default.** The listener opens only after the first `aiden apps connect` or an explicit `aiden apps on`, and the choice is saved in `remote.json`. - **Address.** `http://127.0.0.1:/mcp`, on loopback only. The server tries port 49500 and the next seven, 100 above the desktop's 49400, so a desktop and a server on one computer never collide. If all eight are busy the first time it starts, the system picks a free loopback port instead. The first port that binds is saved, so the URL stays the same across restarts; if another program later holds it, `aiden apps list` reports `port_in_use` instead of moving. -- **Connecting.** `connect ` defaults to Read access. On a terminal it prints the token once, with `claude mcp add` and `codex mcp add` commands that read it from `AIDEN_MCP_TOKEN` instead of writing it into their config; piped, it prints JSON and warns on stderr that the output holds the token. +- **Connecting.** `connect ` defaults to Read access. On a terminal it prints the token once, with `claude mcp add` and `codex mcp add` commands that read it from the app's own variable, such as `AIDEN_MCP_TOKEN_CLAUDE_CODE_K3J9QX` (the same name the desktop's Settings sheet prints), instead of writing it into their config, so two apps in one shell profile keep separate tokens; piped, it prints JSON and warns on stderr that the output holds the token. - **Requires Remote.** Apps share the Remote runtime's chats and device records, so `aiden serve --no-remote` has no MCP server and `aiden apps` says to restart without the flag. The listener never joins Remote's LAN or Tailscale listener. - **Admin over the control socket.** `aiden apps` needs a running server and talks to it over the private control socket, like `aiden remote`. Admin commands send no analytics, and chats an app starts send no usage events. - **Containers.** Loopback inside a container is the container's own, so an app on the host can't reach `/mcp` in the Docker image. Run `aiden serve` on the host for outside apps. diff --git a/packages/cli/src/apps-display.ts b/packages/cli/src/apps-display.ts index 0ae250ff92..451ee215dc 100644 --- a/packages/cli/src/apps-display.ts +++ b/packages/cli/src/apps-display.ts @@ -2,6 +2,7 @@ // the MCP server or its SDK into the admin command. import type { AidenMcpServerStatus } from "../../../main/services/aiden-mcp-server.js"; import type { AidenRemoteAgentAppProjection } from "../../../main/services/aiden-remote-state.js"; +import { aidenMcpTokenEnvName } from "../../../renderer/shared/aiden-mcp-token-env.js"; /** * The first port the server's `/mcp` endpoint tries (then the next seven). @@ -22,13 +23,20 @@ export interface CliAppConnection { /** * The commands that add Aiden to Claude Code and Codex. The token goes in an * environment variable both clients read at connect time, so neither stores - * it in its own config file. + * it in its own config file. The variable is the app's own + * (`aidenMcpTokenEnvName`, the same name the desktop's Settings sheet prints), + * so a second app set up in the same shell profile keeps its own token. */ -export function aidenMcpClientSnippets(url: string, token: string): { environment: string; claude: string; codex: string } { +export function aidenMcpClientSnippets( + url: string, + token: string, + app: { id: string; name: string }, +): { environment: string; claude: string; codex: string } { + const variable = aidenMcpTokenEnvName(app); return { - environment: `export AIDEN_MCP_TOKEN=${token}`, - claude: `claude mcp add --scope user --transport http aiden ${url} --header 'Authorization: Bearer \${AIDEN_MCP_TOKEN}'`, - codex: `codex mcp add aiden --url ${url} --bearer-token-env-var AIDEN_MCP_TOKEN`, + environment: `export ${variable}='${token.replace(/'/gu, "'\\''")}'`, + claude: `claude mcp add --scope user --transport http aiden ${url} --header 'Authorization: Bearer \${${variable}}'`, + codex: `codex mcp add aiden --url ${url} --bearer-token-env-var ${variable}`, }; } @@ -43,7 +51,7 @@ export function renderAppConnection(connection: CliAppConnection): string { "", ]; if (server.running && server.url) { - const snippets = aidenMcpClientSnippets(server.url, token); + const snippets = aidenMcpClientSnippets(server.url, token, app); lines.push( `Aiden's MCP server is listening at ${server.url} (this computer only).`, "", diff --git a/packages/cli/tests/mcp-apps.test.mjs b/packages/cli/tests/mcp-apps.test.mjs index 28b3256a92..45d2f5ed07 100644 --- a/packages/cli/tests/mcp-apps.test.mjs +++ b/packages/cli/tests/mcp-apps.test.mjs @@ -2,7 +2,7 @@ // connects, lists and disconnects the outside apps that use it. Everything // runs through the real CLI: the daemon, its control socket and the listener. import assert from "node:assert/strict"; -import { spawn, spawnSync } from "node:child_process"; +import { execFileSync, spawn, spawnSync } from "node:child_process"; import { once } from "node:events"; import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { createServer, request as httpRequest } from "node:http"; @@ -247,6 +247,29 @@ test("aiden apps revoke disconnects an app while Bot storage waits for repair", assert.ok((await remote.apps(["list"])).apps.find(({ id }) => id === app.app.id).revokedAt); }); +test("two apps set up in one shell profile each connect with their own token", () => { + // A real shell is the oracle. Stand-in claude and codex commands print what + // each client would send when it connects: Claude Code expands its saved + // header from the environment, and Codex reads the variable it was given. + const url = "http://127.0.0.1:49500/mcp"; + const apps = [ + { app: { id: "device_k3j9qxa1", name: "Claude Code" }, token: "a".repeat(43) }, + { app: { id: "device_p7qd2mb2", name: "Claude Code" }, token: "b".repeat(43) }, + { app: { id: "device_zz81aa03", name: "Codex" }, token: "c".repeat(43) }, + ].map((entry) => ({ ...entry, snippets: api.aidenMcpClientSnippets(url, entry.token, entry.app) })); + const script = [ + String.raw`claude() { while [ "$1" != --header ]; do shift; done; eval "printf '%s\n' \"$2\""; }`, + String.raw`codex() { while [ "$1" != --bearer-token-env-var ]; do shift; done; eval "printf 'Authorization: Bearer %s\n' \"\$$2\""; }`, + ...apps.map(({ snippets }) => snippets.environment), + ...apps.flatMap(({ snippets }) => [snippets.claude, snippets.codex]), + ].join("\n"); + const output = execFileSync("/bin/sh", ["-c", script], { encoding: "utf8" }); + assert.deepEqual( + output.trim().split("\n"), + apps.flatMap(({ token }) => [`Authorization: Bearer ${token}`, `Authorization: Bearer ${token}`]), + ); +}); + test("aiden serve --no-remote has no /mcp, and aiden apps says how to get it", async (t) => { const { env } = sandbox(t); await serve(t, env, ["--no-remote"]); @@ -257,12 +280,10 @@ test("aiden serve --no-remote has no /mcp, and aiden apps says how to get it", a test("the Claude Code and Codex commands keep the token out of their config files", () => { const url = "http://127.0.0.1:49500/mcp", token = "t".repeat(43); - const snippets = api.aidenMcpClientSnippets(url, token); - assert.ok(snippets.environment.includes(token)); + const snippets = api.aidenMcpClientSnippets(url, token, { id: "dev_1", name: "Claude Code" }); for (const command of [snippets.claude, snippets.codex]) { assert.ok(command.includes(url), command); assert.equal(command.includes(token), false, command); - assert.ok(command.includes("AIDEN_MCP_TOKEN"), command); } // A server that could not start gives no commands to copy, only the way to retry. const blocked = api.renderAppConnection({ token, app: { id: "dev_1", name: "Claude Code", access: "read" }, From 82057ddc936a360a26284d635f000c2bdc3fc837 Mon Sep 17 00:00:00 2001 From: Sambit Biswas Date: Tue, 17 Nov 2026 01:27:31 -0500 Subject: [PATCH 7/7] copy(cli): say this Mac or this computer for where the MCP server listens Match #818: server text about the computer it runs on names it with localComputerNoun, so macOS says 'this Mac only' and Linux 'this computer only'. --- packages/cli/src/apps-display.ts | 3 ++- packages/cli/src/serve.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/apps-display.ts b/packages/cli/src/apps-display.ts index 451ee215dc..4ec04f0112 100644 --- a/packages/cli/src/apps-display.ts +++ b/packages/cli/src/apps-display.ts @@ -3,6 +3,7 @@ import type { AidenMcpServerStatus } from "../../../main/services/aiden-mcp-server.js"; import type { AidenRemoteAgentAppProjection } from "../../../main/services/aiden-remote-state.js"; import { aidenMcpTokenEnvName } from "../../../renderer/shared/aiden-mcp-token-env.js"; +import { localComputerNoun } from "../../../renderer/shared/computer-noun.js"; /** * The first port the server's `/mcp` endpoint tries (then the next seven). @@ -53,7 +54,7 @@ export function renderAppConnection(connection: CliAppConnection): string { if (server.running && server.url) { const snippets = aidenMcpClientSnippets(server.url, token, app); lines.push( - `Aiden's MCP server is listening at ${server.url} (this computer only).`, + `Aiden's MCP server is listening at ${server.url} (this ${localComputerNoun(process.platform)} only).`, "", "Set the token where Claude Code or Codex runs (for example in your shell profile):", ` ${snippets.environment}`, diff --git a/packages/cli/src/serve.ts b/packages/cli/src/serve.ts index ccd6c741d3..434a77ceba 100644 --- a/packages/cli/src/serve.ts +++ b/packages/cli/src/serve.ts @@ -1,4 +1,5 @@ import { ensurePrivateDirectory } from "../../../main/services/private-storage.ts"; +import { localComputerNoun } from "../../../renderer/shared/computer-noun.ts"; import { createServer } from "node:net"; import { chmodSync, rmSync } from "node:fs"; import { join } from "node:path"; @@ -117,7 +118,7 @@ async function serveOwned(agentDir: string, signal: AbortSignal, options: { remo const status = await remote.service.status().catch(() => undefined); process.stderr.write(`Aiden Remote listening${status ? ` on port ${status.lanPort}${status.lanEndpoint ? ` (${status.lanEndpoint})` : ""}` : ""}. Pair a device with \`aiden remote pair lan|tailscale\`.\n`); const mcp = await remote.mcp.status().catch(() => undefined); - if (mcp?.running && mcp.url) process.stderr.write(`Aiden MCP server listening at ${mcp.url} for connected apps (this computer only).\n`); + if (mcp?.running && mcp.url) process.stderr.write(`Aiden MCP server listening at ${mcp.url} for connected apps (this ${localComputerNoun(process.platform)} only).\n`); } else process.stderr.write("Aiden Remote is off.\n"); if (signal.aborted) return; lifetime.markServing();