Multiplayer agent harness for work.
Preinstall connector SDK bundles in Sprites and Modal (#1278)
Regan Bella83118e9bb86
diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.ymlindex 440a64902..0c4ec43b4 100644--- a/.github/workflows/cicd.yml+++ b/.github/workflows/cicd.yml@@ -42,6 +42,8 @@ jobs:cache-dependency-path: package-lock.json- name: Installrun: npm ci+ - name: Build connector SDK+ run: npm run build:connector-sdk- name: Verify root test shard planif: matrix.shard == 1run: npm run test:root:shard:check@@ -173,6 +175,8 @@ jobs:cache-dependency-path: package-lock.json- name: Installrun: npm ci+ - name: Build connector SDK+ run: npm run build:connector-sdk- name: Postgres-backed tests (durability + cross-process)env:DATABASE_URL: postgres://postgres:postgres@localhost:5432/qmdiff --git a/.prettierignore b/.prettierignoreindex 99e71e23e..cb82e0ee5 100644--- a/.prettierignore+++ b/.prettierignore@@ -7,3 +7,5 @@ data/test/live-slack/out/deploy/stacks/.generated/deploy/helm/templates/++.generated/diff --git a/deploy/connector-sdk/build.mjs b/deploy/connector-sdk/build.mjsnew file mode 100644index 000000000..b6e0470c9--- /dev/null+++ b/deploy/connector-sdk/build.mjs@@ -0,0 +1,37 @@+import { build } from "esbuild";+import { mkdir, writeFile, readdir, readFile } from "node:fs/promises";+import { fileURLToPath } from "node:url";+import { resolve } from "node:path";+import { createHash } from "node:crypto";++const root = fileURLToPath(new URL(".", import.meta.url));+const output = process.argv[2]+ ? resolve(process.argv[2])+ : fileURLToPath(new URL("../../.generated/connector-sdk/", import.meta.url));+const result = await build({+ stdin: { contents: 'export { Composio } from "@composio/core";', resolveDir: root },+ bundle: true,+ platform: "node",+ target: "node22",+ format: "cjs",+ minify: true,+ legalComments: "none",+ write: false,+});+const data = result.outputFiles[0].contents;+const sha = createHash("sha256").update(data).digest("hex");+await mkdir(output, { recursive: true });+await writeFile(`${output}/sdk.cjs`, data);+await writeFile(`${output}/sha256`, `${sha}\n`);+console.log(`Connector SDK: ${data.length} bytes, sha256 ${sha}`);++const lock = JSON.parse(await readFile(`${root}/package-lock.json`, "utf8"));+const licenses = [];+for (const [path, entry] of Object.entries(lock.packages)) {+ if (!path || entry.dev || entry.devOptional) continue;+ const names = await readdir(`${root}/${path}`);+ for (const name of names.filter((name) => /^licen[sc]e(?:\.|$)/i.test(name))) {+ licenses.push(`${path}@${entry.version}\n${await readFile(`${root}/${path}/${name}`, "utf8")}`);+ }+}+await writeFile(`${output}/LICENSES.txt`, licenses.join("\n\n"));diff --git a/deploy/connector-sdk/package-lock.json b/deploy/connector-sdk/package-lock.jsonnew file mode 100644index 000000000..7cc1be4d7--- /dev/null+++ b/deploy/connector-sdk/package-lock.json@@ -0,0 +1,675 @@+{+ "name": "qm-connector-sdk",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "qm-connector-sdk",+ "dependencies": {+ "@composio/core": "0.18.1"+ },+ "devDependencies": {+ "esbuild": "0.25.12"+ }+ },+ "node_modules/@cfworker/json-schema": {+ "version": "4.1.1",+ "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.1.tgz",+ "integrity": "sha512-gAmrUZSGtKc3AiBL71iNWxDsyUC5uMaKKGdvzYsBoTW/xi42JQHl7eKV2OYzCUqvc+D2RCcf7EXY2iCyFIk6og==",+ "license": "MIT"+ },+ "node_modules/@composio/client": {+ "version": "0.1.0-alpha.76",+ "resolved": "https://registry.npmjs.org/@composio/client/-/client-0.1.0-alpha.76.tgz",+ "integrity": "sha512-MXC5JGRVdiQ4EgLricy9o/mqBa1+1T7wHFZ6Q4ZJkrjzZqOMvxTgy21Zlb5J/1oGkB2bg9UDzpH8PkXCp/D4zA==",+ "license": "Apache-2.0"+ },+ "node_modules/@composio/core": {+ "version": "0.18.1",+ "resolved": "https://registry.npmjs.org/@composio/core/-/core-0.18.1.tgz",+ "integrity": "sha512-VEg6F92cMG/4uhRfX6O4SRd+0Pnd4L67tF+Az/EXQ/+aPfDasW5GMTzkiSUSArGDyiMfEsLUYaTYizfnEw2usw==",+ "license": "ISC",+ "dependencies": {+ "@composio/client": "0.1.0-alpha.76",+ "@composio/json-schema-to-zod": "0.3.2",+ "@types/json-schema": "^7.0.15",+ "is-fs-case-sensitive": "^2.0.0",+ "openai": "^7.2.0",+ "picocolors": "^1.1.1",+ "pusher-js": "^8.6.0",+ "semver": "^7.8.5",+ "undici": "^7.29.0",+ "zod-to-json-schema": "^3.25.2"+ },+ "engines": {+ "node": ">=22.22.3"+ },+ "peerDependencies": {+ "zod": ">=3.25.76 <5"+ }+ },+ "node_modules/@composio/json-schema-to-zod": {+ "version": "0.3.2",+ "resolved": "https://registry.npmjs.org/@composio/json-schema-to-zod/-/json-schema-to-zod-0.3.2.tgz",+ "integrity": "sha512-TUUzu4uQH6esokVd6LD0SK4oIz8WaYRtU0cnuj0rmxbiHS0VbhN1qdvj2gIvrIWDdNyvQUIalO63YT/lNx46Gw==",+ "license": "ISC",+ "dependencies": {+ "@cfworker/json-schema": "^4.1.1",+ "dequal": "^2.0.3"+ },+ "engines": {+ "node": ">=22.22.3"+ },+ "peerDependencies": {+ "zod": ">=3.25.76 <5"+ }+ },+ "node_modules/@esbuild/aix-ppc64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz",+ "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "aix"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/android-arm": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz",+ "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/android-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz",+ "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/android-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz",+ "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/darwin-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz",+ "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/darwin-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz",+ "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/freebsd-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz",+ "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/freebsd-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz",+ "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-arm": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz",+ "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz",+ "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-ia32": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz",+ "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-loong64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz",+ "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==",+ "cpu": [+ "loong64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-mips64el": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz",+ "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==",+ "cpu": [+ "mips64el"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-ppc64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz",+ "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-riscv64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz",+ "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==",+ "cpu": [+ "riscv64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-s390x": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz",+ "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/linux-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz",+ "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/netbsd-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz",+ "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "netbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/netbsd-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz",+ "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "netbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/openbsd-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz",+ "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/openbsd-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz",+ "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openbsd"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/openharmony-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz",+ "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/sunos-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz",+ "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "sunos"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/win32-arm64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz",+ "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/win32-ia32": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz",+ "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==",+ "cpu": [+ "ia32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@esbuild/win32-x64": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz",+ "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@types/json-schema": {+ "version": "7.0.15",+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",+ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",+ "license": "MIT"+ },+ "node_modules/dequal": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/esbuild": {+ "version": "0.25.12",+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz",+ "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "bin": {+ "esbuild": "bin/esbuild"+ },+ "engines": {+ "node": ">=18"+ },+ "optionalDependencies": {+ "@esbuild/aix-ppc64": "0.25.12",+ "@esbuild/android-arm": "0.25.12",+ "@esbuild/android-arm64": "0.25.12",+ "@esbuild/android-x64": "0.25.12",+ "@esbuild/darwin-arm64": "0.25.12",+ "@esbuild/darwin-x64": "0.25.12",+ "@esbuild/freebsd-arm64": "0.25.12",+ "@esbuild/freebsd-x64": "0.25.12",+ "@esbuild/linux-arm": "0.25.12",+ "@esbuild/linux-arm64": "0.25.12",+ "@esbuild/linux-ia32": "0.25.12",+ "@esbuild/linux-loong64": "0.25.12",+ "@esbuild/linux-mips64el": "0.25.12",+ "@esbuild/linux-ppc64": "0.25.12",+ "@esbuild/linux-riscv64": "0.25.12",+ "@esbuild/linux-s390x": "0.25.12",+ "@esbuild/linux-x64": "0.25.12",+ "@esbuild/netbsd-arm64": "0.25.12",+ "@esbuild/netbsd-x64": "0.25.12",+ "@esbuild/openbsd-arm64": "0.25.12",+ "@esbuild/openbsd-x64": "0.25.12",+ "@esbuild/openharmony-arm64": "0.25.12",+ "@esbuild/sunos-x64": "0.25.12",+ "@esbuild/win32-arm64": "0.25.12",+ "@esbuild/win32-ia32": "0.25.12",+ "@esbuild/win32-x64": "0.25.12"+ }+ },+ "node_modules/is-fs-case-sensitive": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/is-fs-case-sensitive/-/is-fs-case-sensitive-2.0.0.tgz",+ "integrity": "sha512-JoCsyGITdYPM+pUbeMQ4IiEuQ4wjPdeWORlG7n644isewbcxiQIr+9gmF5k7UabTP/jLBRkbgydEamR7JZBKHA==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/privatenumber/is-fs-case-sensitive?sponsor=1"+ }+ },+ "node_modules/openai": {+ "version": "7.15.0",+ "resolved": "https://registry.npmjs.org/openai/-/openai-7.15.0.tgz",+ "integrity": "sha512-2DIwesnPSduw68MFx7nAdgvshrgvS8WOan5W8+tgUMlAy/tY+Q41g80Pa+w/v64rHA6rtn+dketa8QvMVxU96w==",+ "license": "Apache-2.0",+ "engines": {+ "node": ">=22.0.0"+ },+ "peerDependencies": {+ "@aws-sdk/credential-provider-node": ">=3.972.0 <4",+ "@smithy/hash-node": ">=4.3.0 <5",+ "@smithy/signature-v4": ">=5.4.0 <6",+ "undici": ">=5 <9",+ "ws": "^8.21.0",+ "zod": "^3.25 || ^4.0"+ },+ "peerDependenciesMeta": {+ "@aws-sdk/credential-provider-node": {+ "optional": true+ },+ "@smithy/hash-node": {+ "optional": true+ },+ "@smithy/signature-v4": {+ "optional": true+ },+ "undici": {+ "optional": true+ },+ "ws": {+ "optional": true+ },+ "zod": {+ "optional": true+ }+ }+ },+ "node_modules/picocolors": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",+ "license": "ISC"+ },+ "node_modules/pusher-js": {+ "version": "8.6.0",+ "resolved": "https://registry.npmjs.org/pusher-js/-/pusher-js-8.6.0.tgz",+ "integrity": "sha512-wShJPfCS/kYkCBVzVW67wa9cnQIgHTszEK2XHNrFkOgGruuGw081aERAxfRjfdFU+WcIt8x6dvbwkTW4iZuQ8Q==",+ "license": "MIT",+ "dependencies": {+ "tweetnacl": "^1.0.3"+ }+ },+ "node_modules/semver": {+ "version": "7.8.5",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",+ "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",+ "license": "ISC",+ "bin": {+ "semver": "bin/semver.js"+ },+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/tweetnacl": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",+ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",+ "license": "Unlicense"+ },+ "node_modules/undici": {+ "version": "7.29.1",+ "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.1.tgz",+ "integrity": "sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==",+ "license": "MIT",+ "peer": true,+ "engines": {+ "node": ">=20.18.1"+ }+ },+ "node_modules/zod": {+ "version": "4.6.5",+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz",+ "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==",+ "license": "MIT",+ "peer": true,+ "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/deploy/connector-sdk/package.json b/deploy/connector-sdk/package.jsonnew file mode 100644index 000000000..256540e61--- /dev/null+++ b/deploy/connector-sdk/package.json@@ -0,0 +1,11 @@+{+ "name": "qm-connector-sdk",+ "private": true,+ "type": "module",+ "dependencies": {+ "@composio/core": "0.18.1"+ },+ "devDependencies": {+ "esbuild": "0.25.12"+ }+}diff --git a/deploy/core/Dockerfile b/deploy/core/Dockerfileindex f7d154836..12975872a 100644--- a/deploy/core/Dockerfile+++ b/deploy/core/Dockerfile@@ -3,6 +3,12 @@ FROM node:24-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432RUN apk add --no-cache go \&& CGO_ENABLED=0 GOBIN=/out go install github.com/windtf/wireproxy/cmd/[email protected]+FROM node:24-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd AS connector-sdk-build+WORKDIR /app+COPY deploy/connector-sdk ./deploy/connector-sdk+RUN npm ci --prefix deploy/connector-sdk --ignore-scripts --no-audit --no-fund \+ && node deploy/connector-sdk/build.mjs+FROM node:24-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfdRUN apk add --no-cache ca-certificates curl git git-daemon docker-cli@@ -16,6 +22,7 @@ COPY .husky/install.mjs .husky/install.mjsRUN npm ci --omit=dev && npm audit --omit=dev --audit-level=moderate \&& rm -rf /root/.npm /tmp/node-compile-cache+COPY --from=connector-sdk-build /app/.generated/connector-sdk ./.generated/connector-sdkCOPY src ./srcCOPY scripts/migrate-transcript-tape.ts ./scripts/migrate-transcript-tape.tsCOPY scripts/lib/transcript-tape-migration.ts ./scripts/lib/transcript-tape-migration.tsdiff --git a/docs/composio.md b/docs/composio.mdindex 443e07862..a8a7f0010 100644--- a/docs/composio.md+++ b/docs/composio.md@@ -6,7 +6,7 @@ QM uses Composio from its computer, through a skill and the official SDK.Register an ordinary personal keychain credential named `composio` with env key `COMPOSIO_API_KEY`, or use an existing org service credential with `delivery: "env"` and that env key. Set the normal credential grants. No provider flag is needed. Never paste the key into a conversation, a script or a repository.-The existing credential machinery delivers the key only where authorized. The `composio` skill discovers apps and tools, starts consent, chooses connections and makes SDK calls. Onboarding and app skills prefer it when an authorized credential is available; otherwise direct OAuth remains unchanged. The SDK is installed on demand in the computer, not in the harness package.+The existing credential machinery delivers the key only where authorized. The `composio` skill discovers apps and tools, starts consent, chooses connections and makes SDK calls. Onboarding and app skills prefer it when an authorized credential is available; otherwise direct OAuth remains unchanged. Sprites and Modal receive a pinned, prebuilt SDK bundle during provisioning. The core image carries this credential-free asset; SDK calls still run only in the scoped computer. Other sandbox backends retain the on-demand install described by the skill.## Access model@@ -25,3 +25,9 @@ No live key, grant or project setting is changed by adding these skills. Test ap## RollbackSeed removal does not delete an already-published skill. When replacing the earlier prototype, archive its obsolete `integrations` skill if installed. To roll this version back, restore the previous app/onboarding skills, archive the published `composio` skill and stop workflows using it. Revoke any separately enabled credential grants; rotate or revoke the provider key if previously delivered copies must stop working. Do not delete provider connections without authorization.++## SDK provisioning++For source development, `npm start`, `npm run dev`, `npm run worker`, and the dev-instance launcher build the bundle automatically. When launching the core directly with Node, first run `npm run build:connector-sdk`. The core Dockerfile builds the same asset automatically. The published CLI deploys this core image; it does not run the connector SDK itself. The standalone lockfile in `deploy/connector-sdk` pins the SDK and all build dependencies. Its build produces portable Node JavaScript plus third-party licenses in `.generated/connector-sdk`; no native modules or credentials are included. Rebuild after changing the lockfile.++Provisioning checks the SDK's SHA-256, reuses a matching `/opt/qm/composio/sdk.cjs` from a baked image, or transfers the bundle to `$HOME/.qm/composio/<sha>/`. It atomically activates `$HOME/.qm/composio/current`. Concurrent provisioning can transfer duplicate bytes, but only verified complete files become active. Interrupted transfers are retried on the next provision. No npm registry connection or dependency resolution occurs in the sandbox. Home restoration runs before provisioning, so a restored older bundle is upgraded automatically; previous versions remain available for rollback. Node 22.22.3 or newer is required.diff --git a/eslint.config.mjs b/eslint.config.mjsindex cc40069e9..d5d80a6aa 100644--- a/eslint.config.mjs+++ b/eslint.config.mjs@@ -14,6 +14,7 @@ export default tseslint.config("plugins/web-ui/public/",".claude/",".context/",+ ".generated/",],},js.configs.recommended,diff --git a/knip.json b/knip.jsonindex c3a96f5b5..0cb2469aa 100644--- a/knip.json+++ b/knip.json@@ -59,6 +59,9 @@"hljs-real-sql","hljs-real-markdown"]+ },+ "deploy/connector-sdk": {+ "ignoreDependencies": ["@composio/core"]}}}diff --git a/package.json b/package.jsonindex fd1adff2b..ad0f46c15 100644--- a/package.json+++ b/package.json@@ -10,6 +10,11 @@"npm": ">=11.10.0"},"scripts": {+ "build:connector-sdk": "npm ci --prefix deploy/connector-sdk --ignore-scripts --no-audit --no-fund && node deploy/connector-sdk/build.mjs",+ "prestart": "npm run build:connector-sdk",+ "predev": "npm run build:connector-sdk",+ "preworker": "npm run build:connector-sdk",+ "pretest": "npm run build:connector-sdk","start": "node --env-file-if-exists=.env src/index.ts","dev": "SHUTDOWN_DRAIN_MS=2000 node --env-file-if-exists=.env --watch src/index.ts","dev-instance": "bash scripts/dev-instance.sh up",diff --git a/scripts/dev-instance.sh b/scripts/dev-instance.shindex 962e88eba..e223ca076 100755--- a/scripts/dev-instance.sh+++ b/scripts/dev-instance.sh@@ -1,4 +1,7 @@#!/usr/bin/env bashset -euo pipefailroot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+if [[ "${1:-up}" == "up" ]]; then+ npm --prefix "$root" run build:connector-sdk+fiexec node "$root/scripts/dev/cli.ts" "$@"diff --git a/skills-seed/composio/SKILL.md b/skills-seed/composio/SKILL.mdindex efeb9ebc6..ed9abb615 100644--- a/skills-seed/composio/SKILL.md+++ b/skills-seed/composio/SKILL.md@@ -21,16 +21,10 @@ Write the directive directly, without a code fence or quotation. The web UI rend## SDK-Install the SDK in a workspace tool directory, not the harness:--```sh-npm install --prefix .tools/composio --no-save --ignore-scripts @composio/[email protected]-```--Run Node snippets from `.tools/composio` with the credential supplied to that command. Start with:+Sprites and Modal provision the pinned SDK before commands run. Use the preinstalled bundle directly; do not install npm packages or inspect the environment first. Supply the credential to the command as usual:```js-import { Composio } from "@composio/core";+const { Composio } = await import(`${process.env.HOME}/.qm/composio/current/sdk.cjs`);const composio = new Composio({apiKey: process.env.COMPOSIO_API_KEY,allowTracking: false,@@ -43,7 +37,9 @@ client.timeout = 30_000;client.logLevel = "off";```-Read the installed SDK types or [official docs](https://docs.composio.dev) when needed. Do not invent tool names or schemas, or guess existing user IDs or auth-config IDs. The snippets below are separate operations to compose for the task, not a script to run blindly.+On other sandbox backends without this bundle, install `@composio/[email protected]` once into `.tools/composio` with `npm install --prefix .tools/composio --no-save --ignore-scripts @composio/[email protected]`, run from that directory, and import `@composio/core`.++Read [official docs](https://docs.composio.dev) when needed. Do not invent tool names or schemas, or guess existing user IDs or auth-config IDs. The snippets below are separate operations to compose for the task, not a script to run blindly.## Workflowdiff --git a/src/sandbox/connector-sdk.ts b/src/sandbox/connector-sdk.tsnew file mode 100644index 000000000..5dd055612--- /dev/null+++ b/src/sandbox/connector-sdk.ts@@ -0,0 +1,78 @@+import { createHash, randomUUID } from "node:crypto";+import { readFile } from "node:fs/promises";+import { shq } from "../util/shell.ts";+import type { LayerToolInstaller, LayerToolInstallIo } from "./layer-tool-install.ts";++export interface ConnectorSdkBundle {+ sdk: Uint8Array;+ licenses: Uint8Array;+ sha: string;+}++export async function loadConnectorSdk(): Promise<ConnectorSdkBundle> {+ const base = new URL("../../.generated/connector-sdk/", import.meta.url);+ const [sdk, licenses, hash] = await Promise.all([+ readFile(new URL("sdk.cjs", base)),+ readFile(new URL("LICENSES.txt", base)),+ readFile(new URL("sha256", base), "utf8"),+ ]).catch((cause) => {+ throw new Error("Connector SDK bundle missing; run npm run build:connector-sdk before starting QM", { cause });+ });+ const sha = createHash("sha256").update(sdk).digest("hex");+ if (hash.trim() !== sha) throw new Error("Connector SDK bundle checksum mismatch");+ return { sdk, licenses, sha };+}++export function withConnectorSdk(+ home: string,+ installTools: LayerToolInstaller,+ load?: () => Promise<ConnectorSdkBundle>,+): LayerToolInstaller {+ return async (io, prepare) => {+ await installTools(io, prepare);+ if (load) await installConnectorSdk(io, home, await load());+ };+}++export async function installConnectorSdk(+ io: LayerToolInstallIo,+ home: string,+ bundle: ConnectorSdkBundle,+): Promise<void> {+ if (!/^[a-f0-9]{64}$/.test(bundle.sha) || createHash("sha256").update(bundle.sdk).digest("hex") !== bundle.sha)+ throw new Error("Connector SDK bundle checksum mismatch");+ const root = `${home}/.qm/composio`;+ const target = `${root}/${bundle.sha}`;+ const current = `${root}/current`;+ const nonce = randomUUID();+ const link = `${root}/.link-${nonce}`;+ const baked = "/opt/qm/composio";+ const probe = (dir: string) => `printf '%s\\n' ${shq(`${bundle.sha} ${dir}/sdk.cjs`)} | sha256sum -c --status`;+ const activate = (dir: string) =>+ `node -e ${shq(`const fs = require('node:fs'); fs.symlinkSync(${JSON.stringify(dir)}, ${JSON.stringify(link)}); fs.renameSync(${JSON.stringify(link)}, ${JSON.stringify(current)});`)}`;+ const result = await io.exec(+ `mkdir -p ${shq(root)} && { if ${probe(current)}; then exit 0; fi; if ${probe(baked)}; then ${activate(baked)}; elif ${probe(target)}; then ${activate(target)}; else exit 44; fi; }`,+ 60,+ );+ if (result.code === 0) return;+ if (result.code !== 44) throw new Error(`Connector SDK probe failed (rc=${result.code})`);+ const stage = `${root}/.stage-${nonce}`;+ try {+ const prep = await io.exec(`mkdir -p ${shq(stage)} ${shq(target)}`, 60);+ if (prep.code !== 0) throw new Error(`Connector SDK staging failed (rc=${prep.code})`);+ await io.writeAbs(`${stage}/sdk.cjs`, bundle.sdk);+ await io.writeAbs(`${stage}/LICENSES.txt`, bundle.licenses);+ const commit = await io.exec(+ `${probe(stage)} && node -e ${shq(`if(typeof require(${JSON.stringify(`${stage}/sdk.cjs`)}).Composio !== 'function') process.exit(1)`)} && chmod 0644 ${shq(stage)}/sdk.cjs ${shq(stage)}/LICENSES.txt && mv -f ${shq(stage)}/LICENSES.txt ${shq(target)}/LICENSES.txt && mv -f ${shq(stage)}/sdk.cjs ${shq(target)}/sdk.cjs && ${activate(target)} && ${probe(current)}`,+ 60,+ );+ if (commit.code !== 0) throw new Error(`Connector SDK installation failed (rc=${commit.code})`);+ } finally {+ await io+ .exec(+ `rm -f ${shq(stage)}/sdk.cjs ${shq(stage)}/LICENSES.txt ${shq(link)}; rmdir ${shq(stage)} 2>/dev/null || true`,+ 60,+ )+ .catch(() => {});+ }+}diff --git a/src/sandbox/modal-sandbox.ts b/src/sandbox/modal-sandbox.tsindex 6f233e0bf..698566603 100644--- a/src/sandbox/modal-sandbox.ts+++ b/src/sandbox/modal-sandbox.ts@@ -11,6 +11,7 @@ import { shq } from "../util/shell.ts";import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV, forceThroughProxyEnv } from "./sandbox-env.ts";import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";import { materializeRoLayers } from "./ro-layers.ts";+import { withConnectorSdk, type ConnectorSdkBundle } from "./connector-sdk.ts";import { createLayerToolInstaller } from "./layer-tool-install.ts";import type { LayerInstallFile } from "../deployment/load-layer.ts";import {@@ -84,6 +85,7 @@ export interface ModalSandboxOptions extends BlobStagingOptions {egressProxyUrl?: string;extraTools?: string[];credentialPaths?: CredentialPathSpec[];+ connectorSdk?: () => Promise<ConnectorSdkBundle>;layerToolFiles?: () => readonly LayerInstallFile[];fileChunkBytes?: number;rotationHoldMs?: number;@@ -455,7 +457,11 @@ export function createModalSandbox(workspace: WorkspaceStore, opts: ModalSandboxwithSession(name, (session) => session.writeFileBytes(absPath, data));const readAbsBytes = (name: string, absPath: string): Promise<Uint8Array | null> =>withSession(name, (session) => session.readFileBytes(absPath));- const installLayerTools = createLayerToolInstaller(opts.layerToolFiles ?? (() => []));+ const installLayerTools = withConnectorSdk(+ HOME_DIR,+ createLayerToolInstaller(opts.layerToolFiles ?? (() => [])),+ opts.connectorSdk,+ );const execFileOps = createExecFileOps({combineRemoveAndList: true,diff --git a/src/sandbox/sprites-sandbox.ts b/src/sandbox/sprites-sandbox.tsindex 20de650d1..9c64e5f74 100644--- a/src/sandbox/sprites-sandbox.ts+++ b/src/sandbox/sprites-sandbox.ts@@ -16,6 +16,7 @@ import type { CredentialPathSpec } from "../credentials/resident-paths.ts";import { ephemeralCredLinkPaths } from "../credentials/resident-paths.ts";import { visibleNotInstalled, visibleTools } from "./sandbox.ts";import { createExecSandboxBase, sandboxScopeName } from "./exec-sandbox-base.ts";+import { withConnectorSdk, type ConnectorSdkBundle } from "./connector-sdk.ts";import { createLayerToolInstaller } from "./layer-tool-install.ts";import type { LayerInstallFile } from "../deployment/load-layer.ts";import type { AgentComputerProfile, ExecPressure, ExecResult, Sandbox } from "./sandbox.ts";@@ -66,6 +67,7 @@ export interface SpritesSandboxOptions extends BlobStagingOptions {egressProxyUrl?: string;extraTools?: string[];credentialPaths?: CredentialPathSpec[];+ connectorSdk?: () => Promise<ConnectorSdkBundle>;layerToolFiles?: () => readonly LayerInstallFile[];client?: SpritesClientLike;fetchImpl?: typeof fetch;@@ -268,7 +270,11 @@ export function createSpritesSandbox(workspace: WorkspaceStore, opts: SpritesSanhomeDir: HOME_DIR,defaultTimeoutSec,credentialPaths: opts.credentialPaths ?? [],- installLayerTools: createLayerToolInstaller(opts.layerToolFiles ?? (() => [])),+ installLayerTools: withConnectorSdk(+ HOME_DIR,+ createLayerToolInstaller(opts.layerToolFiles ?? (() => [])),+ opts.connectorSdk,+ ),combineLayerToolPrep: true,egressProxyUrl: opts.egressProxyUrl,deleteFailureCode: "sprite_delete_failed",diff --git a/src/wiring.ts b/src/wiring.tsindex 09dbc5652..698578712 100644--- a/src/wiring.ts+++ b/src/wiring.ts@@ -1,3 +1,4 @@+import { loadConnectorSdk } from "./sandbox/connector-sdk.ts";import { createFlyTunnelManager, parseFlyWireguardPeers } from "./deploy/fly-tunnel-manager.ts";import type { FlyPeerClaim } from "./deploy/fly-peer-claims.ts";import { createMemoryEventBus } from "./util/event-bus.ts";@@ -778,6 +779,7 @@ export function buildApp(blobTransfer,extraTools: deploymentLayer.advertisedTools,credentialPaths: deploymentLayer.credentialPaths,+ connectorSdk: loadConnectorSdk,layerToolFiles: () => deploymentLayer.installFiles,...(config.signingSecret ? { signingSecret: config.signingSecret } : {}),...(config.capabilitySecret ? { capabilitySecret: config.capabilitySecret } : {}),@@ -856,6 +858,7 @@ export function buildApp(...(modal.egressProxyUrl ? { egressProxyUrl: modal.egressProxyUrl } : {}),extraTools: deploymentLayer.advertisedTools,credentialPaths: deploymentLayer.credentialPaths,+ connectorSdk: loadConnectorSdk,layerToolFiles: () => deploymentLayer.installFiles,blobTransfer,...(config.signingSecret ? { signingSecret: config.signingSecret } : {}),diff --git a/test/connector-sdk.test.ts b/test/connector-sdk.test.tsnew file mode 100644index 000000000..b2f302b72--- /dev/null+++ b/test/connector-sdk.test.ts@@ -0,0 +1,125 @@+import { test, type TestContext } from "node:test";+import assert from "node:assert/strict";+import { createHash } from "node:crypto";+import { execFile } from "node:child_process";+import { promisify } from "node:util";+import { mkdtemp, readFile, rm, writeFile, mkdir, symlink } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { createServer } from "node:http";+import { installConnectorSdk, loadConnectorSdk, withConnectorSdk } from "../src/sandbox/connector-sdk.ts";+import type { LayerToolInstallIo } from "../src/sandbox/layer-tool-install.ts";++const exec = promisify(execFile);++async function localIo(t: TestContext) {+ const home = await mkdtemp(join(tmpdir(), "qm-sdk-"));+ t.after(() => rm(home, { recursive: true, force: true }));+ const bin = join(home, "bin");+ await mkdir(bin);+ if (process.platform === "darwin") {+ await symlink((await exec("which", ["gsha256sum"])).stdout.trim(), join(bin, "sha256sum"));+ }+ let writes = 0;+ const io: LayerToolInstallIo = {+ async exec(script, timeoutSec) {+ try {+ const result = await exec("sh", ["-c", script], {+ env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },+ timeout: timeoutSec * 1_000,+ });+ return { code: 0, ...result };+ } catch (error) {+ const result = error as Error & { code: number; stdout: string; stderr: string };+ return { code: result.code, stdout: result.stdout, stderr: result.stderr };+ }+ },+ async writeAbs(path, data) {+ writes++;+ await writeFile(path, data);+ },+ };+ return { home, io, writes: () => writes };+}++const fixture = () => {+ const sdk = Buffer.from("exports.Composio = class Composio {};");+ return { sdk, sha: createHash("sha256").update(sdk).digest("hex"), licenses: Buffer.from("license") };+};++test("concurrent installation activates complete bytes and subsequent provision does not upload", async (t) => {+ const { home, io, writes } = await localIo(t);+ const bundle = fixture();+ await Promise.all([installConnectorSdk(io, home, bundle), installConnectorSdk(io, home, bundle)]);+ assert.deepEqual(await readFile(`${home}/.qm/composio/current/sdk.cjs`), bundle.sdk);+ const before = writes();+ await installConnectorSdk(io, home, bundle);+ assert.equal(writes(), before);+ await writeFile(`${home}/.qm/composio/current/sdk.cjs`, "broken");+ await installConnectorSdk(io, home, bundle);+ assert.equal(writes(), before + 2);+ assert.deepEqual(await readFile(`${home}/.qm/composio/current/sdk.cjs`), bundle.sdk);+});++test("corrupt transfers never replace the previously active bundle", async (t) => {+ const { home, io } = await localIo(t);+ const first = fixture();+ await installConnectorSdk(io, home, first);+ const sdk = Buffer.from("exports.Composio = class Next {};");+ const next = { ...first, sdk, sha: createHash("sha256").update(sdk).digest("hex") };+ await assert.rejects(+ installConnectorSdk({ ...io, writeAbs: (path) => writeFile(path, "corrupt") }, home, next),+ /installation failed/,+ );+ assert.deepEqual(await readFile(`${home}/.qm/composio/current/sdk.cjs`), first.sdk);+ await installConnectorSdk(io, home, next);+ assert.deepEqual(await readFile(`${home}/.qm/composio/current/sdk.cjs`), sdk);+});++test("SDK setup follows layer preparation and rejects invalid local bytes before remote commands", async () => {+ const steps: string[] = [];+ const install = withConnectorSdk(+ "/home/test",+ async () => {+ steps.push("layer");+ },+ async () => {+ steps.push("bundle");+ return { ...fixture(), sha: "bad" };+ },+ );+ await assert.rejects(+ install({+ exec: async () => {+ throw new Error("unexpected remote exec");+ },+ writeAbs: async () => {},+ }),+ /checksum mismatch/,+ );+ assert.deepEqual(steps, ["layer", "bundle"]);+});++test("built bundle performs an SDK request without node_modules or external network", async (t) => {+ const bundle = await loadConnectorSdk();+ const { home, io } = await localIo(t);+ await installConnectorSdk(io, home, bundle);+ const requests: string[] = [];+ const server = createServer((req, res) => {+ requests.push(req.url ?? "");+ assert.equal(req.headers["x-api-key"], "test-only");+ res.setHeader("content-type", "application/json");+ res.end(JSON.stringify({ items: [], total_pages: 1, current_page: 1, total_items: 0 }));+ });+ t.after(() => new Promise<void>((resolve) => server.close(() => resolve())));+ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));+ const address = server.address();+ assert.ok(address && typeof address !== "string");+ const script = `const { Composio } = await import(${JSON.stringify(`${home}/.qm/composio/current/sdk.cjs`)});+const c = new Composio({apiKey:'test-only',allowTracking:false,disableVersionCheck:true,dangerouslyAllowAutoUploadDownloadFiles:false});+const client = c.getClient(); client.baseURL = 'http://127.0.0.1:${address.port}'; client.maxRetries = 0;+const result = await client.toolkits.list({limit:1}); if(result.items.length !== 0) process.exit(1);`;+ await exec(process.execPath, ["--input-type=module", "-e", script], { cwd: home });+ assert.equal(requests.length, 1);+ assert.match(requests[0]!, /toolkits\?limit=1/);+});