@devries-cameron20 / composio Mirror · read-only / commits / 0979159e1
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 18:30 UTC

refactor(cli): activate the try/catch and env ban and pin the boundary ratchet (#3885)

This PR: - activates the final rule group: `TryStatement` and `process.env` are now ESLint-banned in CLI source, completing the enforcement ramp started in the first PR of this stack; the env guard covers dot access, bracket access, and object destructuring - migrates the residual files (auth-config create, trigger create, toolkit search, runtime debug flags, master detection, import-time UI setup) off try/catch and ad-hoc env reads - every surviving violation sits at a declared runtime boundary (bin.ts bootstrap, child-process companion runtime, import-time UI setup, environment writes and whole-environment enumeration, spawn-time env handshakes) with an inline `// eslint-disable-next-line <rule> -- <reason>` justification - adds `eslint-boundaries.json` — the checked-in manifest of the 46 sanctioned disables across 22 files — and `validate:boundaries` (part of `pnpm test`), which scans both `.ts` and `.tsx` sources and fails on undeclared, missing, relocated, bare, or file-wide disables - pins each registered boundary by rule, justification, and governed next-line target, with regression coverage for TSX discovery, same-file retargeting, and duplicate semantic sites - documents the Effect Boundary Policy in the CLI `AGENTS.md` and the `cli-command` skill reference, and drops the gitleaks test-file allowlist --- **Stack** (re-slice of https://github.com/ComposioHQ/composio/pull/3859; each PR targets its parent and auto-retargets to `next` as parents merge): 1. https://github.com/ComposioHQ/composio/pull/3877 — guidelines + inert rule groups 2. https://github.com/ComposioHQ/composio/pull/3878 — `new Function()` eval security fix 3. https://github.com/ComposioHQ/composio/pull/3879 — behavioral fix pack 4. https://github.com/ComposioHQ/composio/pull/3880 — platform-imports rule + migration 5. https://github.com/ComposioHQ/composio/pull/3881 — terminal-streams rule + TerminalUI boundary 6. https://github.com/ComposioHQ/composio/pull/3882 — descriptor seam + zod→Schema 7. https://github.com/ComposioHQ/composio/pull/3883 — test-tree lint + deterministic suites 8. https://github.com/ComposioHQ/composio/pull/3884 — typed error boundaries + v4 seams 9. https://github.com/ComposioHQ/composio/pull/3885 — try/catch+env ban + boundary ratchet ← **this PR** On stacked bases CI runs lint/build and the CLI Docker e2e job; unit tests and typecheck are verified locally per PR and re-verified by full CI when each PR is retargeted to `next`.

Alberto Schiabel committed Jul 21, 2026 at 11:36 UTC 0979159e104b5eeee480fe1f79d90b9c547a04bf
31 files changed +684 -35
.agents/skills/cli-command/references/implementation.md
+4 -4
@@ -27,15 +27,15 @@ Follow existing local patterns before introducing new service abstractions.
27
28 ## Effect Platform Boundaries
29
30 -`node:path`, `node:fs`, `node:os`, `node:child_process`, `process.env`, and `try`/`catch` are banned policy for new code in `src/` (ESLint rule groups are defined in the root `eslint.config.mjs` and activated group-by-group over the guardrails PR stack):
30 +`node:path`, `node:fs`, `node:os`, `node:child_process`, `process.env`, and `try`/`catch` are eslint-banned in `src/`:
31
32 - Path arithmetic → `Path` service from `@effect/platform` (`const path = yield* Path.Path`).
33 - Filesystem I/O → `FileSystem` service from `@effect/platform`.
34 -- homedir/tmpdir/platform/arch → the `NodeOs` service; subprocesses → platform `Command`.
35 -- Environment reads → `effect/Config`; sync fallible ops (`JSON.parse`, `new URL`) → `Either.try` with a `Data.TaggedError`.
34 +- homedir/tmpdir/platform/arch → the `NodeOs` service; subprocesses → platform `Command` or `services/detached-process.ts`.
35 +- Environment reads → `effect/Config`; sync fallible ops (`JSON.parse`, `new URL`) → `Either.try` with a `Data.TaggedError` (JSON records via `parseJsonRecord` in `src/utils/parse-json.ts`).
36 - Helpers that cannot become Effects (sync callbacks, promise pipelines) take the resolved service instance as a plain parameter instead of importing Node builtins.
37
38 -Never add an `eslint-disable` for these rules in new code — thread the service instead. Full policy: `ts/packages/cli/AGENTS.md`.
38 +Never add an `eslint-disable`: `pnpm run validate:boundaries` (CI-blocking via `pnpm test`) rejects any disable not registered in `eslint-boundaries.json`. Genuine new runtime boundaries require regenerating the manifest with `pnpm run validate:boundaries -- --update` plus a justification in the PR. Full policy: "Effect Boundary Policy" in `ts/packages/cli/AGENTS.md`.
39
40 ## Required Checks
41
.gitleaks.toml
-6
@@ -1,8 +1,2 @@
1 [extend]
2 useDefault = true
3 -
4 -[allowlist]
5 -description = "Ignore test fixtures and assertions in TypeScript test files"
6 -paths = [
7 - '''\.test\.ts$''',
8 -]
eslint.config.mjs
+16 -6
@@ -20,16 +20,27 @@ const portableRestrictedImportPaths = [
20 },
21 ];
22
23 +const cliProcessEnvMessage =
24 + 'Read environment variables through effect/Config instead of process.env.';
25 +
26 +const cliProcessEnvRestrictions = [
27 + "MemberExpression[object.name='process'][computed=false][property.name='env']",
28 + "MemberExpression[object.name='process'][computed=true][property.value='env']",
29 + "VariableDeclarator[init.name='process'] > ObjectPattern > Property[key.name='env']",
30 + "VariableDeclarator[init.name='process'] > ObjectPattern > Property[key.value='env']",
31 + "AssignmentExpression[right.name='process'] > ObjectPattern > Property[key.name='env']",
32 + "AssignmentExpression[right.name='process'] > ObjectPattern > Property[key.value='env']",
33 + "AssignmentPattern[right.name='process'] > ObjectPattern > Property[key.name='env']",
34 + "AssignmentPattern[right.name='process'] > ObjectPattern > Property[key.value='env']",
35 +].map(selector => ({ selector, message: cliProcessEnvMessage }));
36 +
37 const cliRestrictedSyntax = [
38 {
39 selector: 'TryStatement',
40 message:
41 'Use Effect.try, Effect.tryPromise, or typed Effect error recovery instead of try/catch.',
42 },
29 - {
30 - selector: "MemberExpression[object.name='process'][property.name='env']",
31 - message: 'Read environment variables through effect/Config instead of process.env.',
32 - },
43 + ...cliProcessEnvRestrictions,
44 ];
45
46 const cliProcessStreamRestrictions = [
@@ -217,8 +228,7 @@ export default [
228 ],
229 'no-restricted-syntax': [
230 'error',
220 - // uncommented by the boundary-ratchet PR of this stack
221 - // ...cliRestrictedSyntax,
231 + ...cliRestrictedSyntax,
232 ...cliProcessStreamRestrictions,
233 ...cliDescriptorSeamRestrictedSyntax,
234 ],
ts/packages/cli/AGENTS.md
+24 -1
@@ -142,7 +142,30 @@ Key patterns: `Effect.all([...], { concurrency: 'unbounded' })` for parallel wor
142 - Treat `unknown`, JSON, persisted state, and API payloads as trust boundaries. Decode them with `Schema` or narrow them with `Predicate`; an `as` assertion is not validation.
143 - Do not inspect private `@effect/cli` descriptor shapes. Use public `CommandDescriptor` operations or keep declarative command metadata that can move to Effect v4's public command tree.
144 - Prefer `Effect.mapError`, `Effect.matchEffect`, and typed recovery over `catchAll` blocks that flatten distinct failures into one message-only error.
145 -- Prefer Effect services over Node builtins for platform access in new code: `Path`/`FileSystem`/`Command` from `@effect/platform` instead of `node:path`/`node:fs`/`node:child_process`, and `effect/Config` instead of `process.env`. These rules are policy for new CLI code effective now; the matching ESLint rule groups are defined (commented out) in the root `eslint.config.mjs` and are activated group-by-group over the guardrails PR stack as existing code migrates.
145 +
146 +### Effect Boundary Policy
147 +
148 +All platform access goes through Effect services. `node:path`, `node:fs`, `node:os`, `node:child_process`, `process.env`, and `try`/`catch` are eslint-banned in `src/`. Use the sanctioned equivalents:
149 +
150 +| Need | Use |
151 +| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
152 +| Path arithmetic (join/resolve/dirname/…) | `Path` service from `@effect/platform` (`const path = yield* Path.Path`) |
153 +| Filesystem I/O | `FileSystem` service from `@effect/platform` |
154 +| homedir / tmpdir / platform / arch | `NodeOs` service (`src/services/node-os.ts`, the sole `node:os` boundary) |
155 +| Subprocesses | `Command` from `@effect/platform`; children that outlive the CLI via `src/services/detached-process.ts` (sole detached-spawn boundary) |
156 +| Environment reads | `effect/Config` |
157 +| Sync fallible ops (`JSON.parse`, `new URL`, `JSON.stringify`) | `Either.try` with a `Data.TaggedError`; JSON records via `parseJsonRecord` (`src/utils/parse-json.ts`) |
158 +
159 +Conversion patterns, in order of preference:
160 +
161 +1. Yield the service inside existing Effect code.
162 +2. Convert a plain helper into an Effect when its callers are Effect-hosted (`Either` is a subtype of `Effect`, so both compose with `yield*`).
163 +3. Pass the resolved service instance (e.g. `Path.Path`, `FileSystem.FileSystem`) as a plain parameter into sync callbacks or promise pipelines that cannot become Effects (see `tool-permissions.ts`, `generation/typescript/virtual-compiler-host.ts`).
164 +4. Modules that self-provide layers add `Path.layer` / `BunFileSystem.layer` / `NodeOs.Default` to their stack instead of reaching for Node builtins.
165 +
166 +The only code allowed to bypass services sits at declared runtime boundaries: the `bin.ts` bootstrap, the child-process companion runtime (`run-helpers-runtime.ts`, `run-subagent-*` — bundled into `.mjs` files that run in the user's spawned process), import-time UI setup (`ui/colors.ts`, `ui/redact.ts`), environment **writes** and whole-environment enumeration (which `effect/Config` cannot express), and spawn-time env handshakes between parent and child `composio run` processes. Every such boundary is an inline `// eslint-disable-next-line <rule> -- <reason>` comment registered in `eslint-boundaries.json`.
167 +
168 +**Enforcement**: `pnpm run validate:boundaries` (part of `pnpm test`, CI-blocking) fails when any eslint-disable in `src/` is missing from the manifest, lacks a `-- reason`, or uses a file-wide form. Do not add new disables — thread the service instead. If code genuinely cannot run inside the Effect runtime, that is a new boundary: regenerate the manifest with `pnpm run validate:boundaries -- --update` and justify the boundary in the PR. Never add entries to `eslint-suppressions.json`.
169
170 ## Vendor Reference Sources
171
ts/packages/cli/eslint-boundaries.json new
+276
@@ -0,0 +1,276 @@
1 +{
2 + "src/analytics/events.ts": [
3 + {
4 + "rule": "no-restricted-syntax",
5 + "reason": "spawn-time env handoff from parent run",
6 + "target": "(process.env.COMPOSIO_CLI_PARENT_RUN_ID ?? crypto.randomUUID())"
7 + },
8 + {
9 + "rule": "no-restricted-syntax",
10 + "reason": "spawn-time env handoff read outside Effect",
11 + "target": "const getInvocationOrigin = (): string => process.env.COMPOSIO_CLI_INVOCATION_ORIGIN ?? 'cli';"
12 + },
13 + {
14 + "rule": "no-restricted-syntax",
15 + "reason": "spawn-time env handoff read outside Effect",
16 + "target": "const getParentRunId = (): string | undefined => process.env.COMPOSIO_CLI_PARENT_RUN_ID;"
17 + }
18 + ],
19 + "src/bin.ts": [
20 + {
21 + "rule": "no-restricted-syntax",
22 + "reason": "pre-runtime env write during bootstrap",
23 + "target": "process.env[CLI_TELEMETRY_DEBUG_ENV_VAR] = 'true';"
24 + }
25 + ],
26 + "src/cli-main.ts": [
27 + {
28 + "rule": "no-restricted-syntax",
29 + "reason": "env write propagates run id to children",
30 + "target": "process.env.COMPOSIO_CLI_PARENT_RUN_ID = commandTelemetryContext.runId;"
31 + }
32 + ],
33 + "src/commands/index.ts": [
34 + {
35 + "rule": "no-restricted-syntax",
36 + "reason": "env delete clears a stale hidden-flag value",
37 + "target": "delete process.env.COMPOSIO_RUN_ACP_ONLY;"
38 + },
39 + {
40 + "rule": "no-restricted-syntax",
41 + "reason": "env write hands the stripped flag to run.cmd",
42 + "target": "process.env.COMPOSIO_RUN_ACP_ONLY = acpOnly ? '1' : '0';"
43 + }
44 + ],
45 + "src/commands/install.cmd.ts": [
46 + {
47 + "rule": "no-restricted-syntax",
48 + "reason": "$SHELL is read inside a plain synchronous helper that mirrors install.sh's shell detection, outside any Effect context",
49 + "target": "const shellEnv = process.env.SHELL ?? '';"
50 + },
51 + {
52 + "rule": "no-restricted-syntax",
53 + "reason": "COMPOSIO_INSTALL_DIR is the handoff variable set by the install.sh bootstrapper for this one-shot post-install step; read directly to stay byte-compatible with the script",
54 + "target": "const installDir = process.env.COMPOSIO_INSTALL_DIR ?? path.join(os.homedir, '.composio');"
55 + }
56 + ],
57 + "src/commands/run.cmd.ts": [
58 + {
59 + "rule": "no-restricted-imports",
60 + "reason": "os.tmpdir and os.homedir locate the preload scratch directory and ~/.composio in the same synchronous helpers",
61 + "target": "import * as os from 'node:os';"
62 + },
63 + {
64 + "rule": "no-restricted-imports",
65 + "reason": "synchronous fs (mkdtempSync/writeFileSync/rmSync/existsSync) builds and tears down the run preload files in plain helpers that execute outside the Effect runtime",
66 + "target": "import * as fs from 'node:fs';"
67 + },
68 + {
69 + "rule": "no-restricted-syntax",
70 + "reason": "honors the same COMPOSIO_CACHE_DIR/CACHE_DIR overrides the run-helpers child runtime reads, so the sandbox read roots match the child's cache location",
71 + "target": "process.env.COMPOSIO_CACHE_DIR?.trim() || process.env.CACHE_DIR?.trim() || defaultComposioDir;"
72 + },
73 + {
74 + "rule": "no-restricted-syntax",
75 + "reason": "reads the COMPOSIO_RUN_ACP_ONLY flag a parent process sets to force the ACP-only subagent path in the child run",
76 + "target": "const acpOnly = process.env.COMPOSIO_RUN_ACP_ONLY === '1';"
77 + },
78 + {
79 + "rule": "no-restricted-syntax",
80 + "reason": "reuses the run ID a parent `composio run` process passed via env so nested runs share one run identity",
81 + "target": "const runId = process.env.COMPOSIO_CLI_PARENT_RUN_ID ?? crypto.randomUUID();"
82 + },
83 + {
84 + "rule": "no-restricted-syntax",
85 + "reason": "spreads the caller's full environment into the spawned script so user-provided variables reach the child process",
86 + "target": "...process.env,"
87 + },
88 + {
89 + "rule": "no-restricted-syntax",
90 + "reason": "try/finally removes the temp preload and wrapper files around the imperative Bun.spawn block, whose success path ends in process.exit",
91 + "target": "try {"
92 + }
93 + ],
94 + "src/commands/tools/commands/tools.execute.cmd.ts": [
95 + {
96 + "rule": "no-restricted-syntax",
97 + "reason": "COMPOSIO_CLI_INVOCATION_ORIGIN is a spawn-time handshake the parent `composio run` process injects into nested CLI invocations, not user configuration, and it must be read fresh at call time",
98 + "target": "const shouldStoreLargeExecuteOutput = () => process.env.COMPOSIO_CLI_INVOCATION_ORIGIN !== 'run';"
99 + },
100 + {
101 + "rule": "no-restricted-syntax",
102 + "reason": "COMPOSIO_RUN_OUTPUT_DIR is injected per-subprocess by the parent `composio run` and must take precedence over the session artifacts directory; inter-process plumbing, not user configuration",
103 + "target": "process.env.COMPOSIO_RUN_OUTPUT_DIR?.trim() ||"
104 + },
105 + {
106 + "rule": "no-restricted-syntax",
107 + "reason": "COMPOSIO_RUN_OUTPUT_DIR is injected per-subprocess by the parent `composio run` so nested executions share one output directory; it is inter-process plumbing, not user configuration",
108 + "target": "directoryPath: sharedDirectory?.trim() || process.env.COMPOSIO_RUN_OUTPUT_DIR?.trim(),"
109 + },
110 + {
111 + "rule": "no-restricted-syntax",
112 + "reason": "COMPOSIO_RUN_OUTPUT_DIR is injected per-subprocess by the parent `composio run` so nested local-tool executions write into its shared output directory; inter-process plumbing, not user configuration",
113 + "target": "executeOutputDir: process.env.COMPOSIO_RUN_OUTPUT_DIR?.trim() || undefined,"
114 + }
115 + ],
116 + "src/commands/triggers/commands/triggers.listen.cmd.ts": [
117 + {
118 + "rule": "no-restricted-syntax",
119 + "reason": "re-checks the same raw env var to tell the user whether they supplied a secret or this session generated one",
120 + "target": "if (process.env.COMPOSIO_WEBHOOK_SECRET) {"
121 + },
122 + {
123 + "rule": "no-restricted-syntax",
124 + "reason": "the forward signing secret is an optional raw passthrough from the user's shell; its literal presence/absence selects the generated-secret fallback",
125 + "target": "const webhookSecret = process.env.COMPOSIO_WEBHOOK_SECRET ?? generatedWebhookSecret;"
126 + }
127 + ],
128 + "src/services/agents.ts": [
129 + {
130 + "rule": "no-restricted-syntax",
131 + "reason": "read lazily at request time inside a plain sync helper so tests can repoint agents.composio.dev per call without rebuilding a Config layer",
132 + "target": "(process.env.COMPOSIO_AGENTS_BASE_URL ?? DEFAULT_AGENTS_BASE_URL).replace(/\\/+$/, '');"
133 + }
134 + ],
135 + "src/services/cli-session-artifacts.ts": [
136 + {
137 + "rule": "no-restricted-syntax",
138 + "reason": "COMPOSIO_CACHE_DIR is the second rung of the same fall-through chain: env overrides must beat the persisted artifactDirectory before the tmpdir default",
139 + "target": "process.env.COMPOSIO_CACHE_DIR?.trim() ||"
140 + },
141 + {
142 + "rule": "no-restricted-syntax",
143 + "reason": "read inline so a blank/whitespace-only COMPOSIO_SESSION_DIR falls through the || precedence chain (session dir > cache dir > user config > tmpdir)",
144 + "target": "process.env.COMPOSIO_SESSION_DIR?.trim() ||"
145 + }
146 + ],
147 + "src/services/cli-user-config.ts": [
148 + {
149 + "rule": "no-restricted-imports",
150 + "reason": "os.homedir feeds resolveCliConfigDirectorySync, which runs from synchronous non-Effect call sites (dev.cmd messages, run-helpers-runtime readFileSync) where the NodeOs service is unavailable",
151 + "target": "import os from 'node:os';"
152 + },
153 + {
154 + "rule": "no-restricted-syntax",
155 + "reason": "this resolver is called from synchronous non-Effect code, so the COMPOSIO_CACHE_DIR override cannot come from effect/Config here",
156 + "target": "process.env.COMPOSIO_CACHE_DIR?.trim() ||"
157 + }
158 + ],
159 + "src/services/detached-process.ts": [
160 + {
161 + "rule": "no-restricted-imports",
162 + "reason": "This Effect helper is the sole detached-spawn boundary for CLI source: @effect/platform Command processes are scope-bound and are killed when their scope closes, while these children must outlive the CLI process.",
163 + "target": "import { spawn } from 'node:child_process';"
164 + }
165 + ],
166 + "src/services/master-detector.ts": [
167 + {
168 + "rule": "no-restricted-syntax",
169 + "reason": "classifies the driving agent by scanning every env key for CODEX_/CLAUDE_ prefixes; effect/Config reads known keys and cannot enumerate the whole environment",
170 + "target": "export const detectMaster = (env: Record<string, string | undefined> = process.env): MasterKind => {"
171 + }
172 + ],
173 + "src/services/native-ui-sidecar.ts": [
174 + {
175 + "rule": "no-restricted-syntax",
176 + "reason": "Sole raw-env boundary of this module: prefix scanning needs the full environment map, which effect/Config cannot enumerate.",
177 + "target": "const rawProcessEnv: NodeJS.ProcessEnv = process.env;"
178 + }
179 + ],
180 + "src/services/node-os.ts": [
181 + {
182 + "rule": "no-restricted-imports",
183 + "reason": "This Effect service is the sole node:os boundary for CLI source.",
184 + "target": "import os from 'node:os';"
185 + }
186 + ],
187 + "src/services/project-environment-detector.ts": [
188 + {
189 + "rule": "no-restricted-syntax",
190 + "reason": "npm_config_user_agent is transient metadata injected by the package manager that spawned this process, not CLI configuration; read once as the last-resort heuristic when no lockfile or manifest evidence exists",
191 + "target": "const userAgent = parseUserAgent(process.env.npm_config_user_agent);"
192 + }
193 + ],
194 + "src/services/run-helpers-runtime.ts": [
195 + {
196 + "rule": "no-restricted-imports",
197 + "reason": "os.tmpdir() locates the fallback run-files directory in the child process, outside the Effect runtime",
198 + "target": "import * as os from 'node:os';"
199 + },
200 + {
201 + "rule": "no-restricted-imports",
202 + "reason": "sync fs for run-log appends, run-file writes, and CLI config reads in the child process, outside the Effect runtime",
203 + "target": "import * as fs from 'node:fs';"
204 + },
205 + {
206 + "rule": "no-restricted-syntax",
207 + "reason": "JSON.stringify throws on circular user values in this sync formatter injected into user code; String() is the entire fallback",
208 + "target": "try {"
209 + },
210 + {
211 + "rule": "no-restricted-syntax",
212 + "reason": "async fallback chain in the user's child process: ACP invoke errors route to the legacy sub-agent path, everything else rethrows",
213 + "target": "try {"
214 + },
215 + {
216 + "rule": "no-restricted-syntax",
217 + "reason": "debug flag reaches the child process via inherited environment; the CLI's Config provider is not available here",
218 + "target": "helperContext.perfDebug === true || process.env.COMPOSIO_PERF_DEBUG === '1';"
219 + },
220 + {
221 + "rule": "no-restricted-syntax",
222 + "reason": "debug flag reaches the child process via inherited environment; the CLI's Config provider is not available here",
223 + "target": "helperContext.toolDebug === true || process.env.COMPOSIO_TOOL_DEBUG === '1';"
224 + },
225 + {
226 + "rule": "no-restricted-syntax",
227 + "reason": "sync config read at the child-process boundary; a missing or malformed CLI config file just means the 'auto' target",
228 + "target": "try {"
229 + },
230 + {
231 + "rule": "no-restricted-syntax",
232 + "reason": "the spawned CLI child must inherit the caller's full environment before Composio-specific overrides are layered on top",
233 + "target": "...process.env,"
234 + }
235 + ],
236 + "src/services/run-subagent-output-mcp.ts": [
237 + {
238 + "rule": "no-restricted-imports",
239 + "reason": "standalone MCP stdio sidecar entrypoint runs outside the CLI's Effect runtime; sync fs reads the schema file and writes the structured result file",
240 + "target": "import * as fs from 'node:fs';"
241 + }
242 + ],
243 + "src/services/runtime-debug-flags.ts": [
244 + {
245 + "rule": "no-restricted-syntax",
246 + "reason": "called from sync non-Effect helper code in spawned child processes, where the flag arrives via inherited environment rather than a Config provider",
247 + "target": "runtimeDebugFlags.perfDebug || process.env.COMPOSIO_PERF_DEBUG === '1';"
248 + },
249 + {
250 + "rule": "no-restricted-syntax",
251 + "reason": "called from sync non-Effect helper code in spawned child processes, where the flag arrives via inherited environment rather than a Config provider",
252 + "target": "runtimeDebugFlags.toolDebug || process.env.COMPOSIO_TOOL_DEBUG === '1';"
253 + }
254 + ],
255 + "src/services/tool-permissions.ts": [
256 + {
257 + "rule": "no-restricted-syntax",
258 + "reason": "node:http listen callback inside a Promise executor: on failure to open the browser, close the server and reject the surrounding Promise; Effect's error channel is not available here",
259 + "target": "try {"
260 + }
261 + ],
262 + "src/ui/colors.ts": [
263 + {
264 + "rule": "no-restricted-syntax",
265 + "reason": "palette is created eagerly at import time, before any Effect runtime; honors the NO_COLOR convention",
266 + "target": "} = color.createColors(!Boolean(process.env.NO_COLOR));"
267 + }
268 + ],
269 + "src/ui/redact.ts": [
270 + {
271 + "rule": "no-restricted-syntax",
272 + "reason": "plain sync string helper called from formatting code; CI flag toggles redaction in recorded CLI output",
273 + "target": "if (process.env.CI !== 'true') return value as `${Prefix}${string}`;"
274 + }
275 + ]
276 +}
ts/packages/cli/package.json
+2 -1
@@ -33,13 +33,14 @@
33 "build:binary:checksums": "bun run ./scripts/generate-checksums.ts",
34 "build:skills": "tsx ./scripts/build-skills.ts",
35 "validate:skills": "tsx ./scripts/validate-skills.ts",
36 + "validate:boundaries": "tsx ./scripts/validate-eslint-boundaries.ts",
37 "install:binary": "bun run ./scripts/install-binary.ts ./dist/composio",
38 "table:metrics": "bun run ./scripts/optimize-metrics-table.ts",
39 "mock": "bun run ./scripts/copy-mocks-from-cache.ts",
40 "prebuild": "pnpm run typecheck",
41 "build": "tsdown && bun run ./scripts/copy-local-tools-assets.ts ./dist",
42 "bin": "./dist/composio",
42 - "test": "pnpm run validate:skills && vitest run",
43 + "test": "pnpm run validate:skills && pnpm run validate:boundaries && vitest run",
44 "prepublishOnly": "pnpm run build && pnpm run build:binary",
45 "typecheck:src": "pnpm exec tsgo --noEmit -p ./tsconfig.src.json",
46 "typecheck:test": "pnpm exec tsgo --noEmit -p ./tsconfig.test.json",
ts/packages/cli/scripts/eslint-boundaries.ts new
+149
@@ -0,0 +1,149 @@
1 +import * as fs from 'node:fs';
2 +import * as path from 'node:path';
3 +
4 +export interface BoundarySite {
5 + readonly rule: string;
6 + readonly reason: string;
7 + readonly target: string;
8 +}
9 +
10 +export type BoundaryManifest = Record<string, BoundarySite[]>;
11 +
12 +export interface CollectedBoundaries {
13 + readonly manifest: BoundaryManifest;
14 + readonly errors: readonly string[];
15 +}
16 +
17 +const NEXT_LINE_FORM = /\/\/ eslint-disable-next-line (?<rules>[\w@/,\- ]+?) -- (?<reason>.+?)\s*$/;
18 +
19 +const boundarySiteKey = (site: BoundarySite): string =>
20 + JSON.stringify([site.rule, site.reason, site.target]);
21 +
22 +const compareBoundarySites = (left: BoundarySite, right: BoundarySite): number => {
23 + const leftKey = boundarySiteKey(left);
24 + const rightKey = boundarySiteKey(right);
25 + return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
26 +};
27 +
28 +const formatBoundarySite = (site: BoundarySite): string =>
29 + `"${site.rule}" -- ${site.reason} -> ${JSON.stringify(site.target)}`;
30 +
31 +export const listSourceFiles = (dir: string): string[] =>
32 + fs.readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
33 + const full = path.join(dir, entry.name);
34 + if (entry.isDirectory()) return listSourceFiles(full);
35 + return entry.isFile() && /\.tsx?$/.test(entry.name) ? [full] : [];
36 + });
37 +
38 +export const parseBoundarySites = (
39 + relativePath: string,
40 + source: string
41 +): { readonly sites: readonly BoundarySite[]; readonly errors: readonly string[] } => {
42 + const lines = source.split('\n');
43 + const sites: BoundarySite[] = [];
44 + const errors: string[] = [];
45 +
46 + lines.forEach((line, index) => {
47 + if (!line.includes('eslint-disable')) return;
48 +
49 + const location = `${relativePath}:${index + 1}`;
50 + const match = NEXT_LINE_FORM.exec(line);
51 + if (!match?.groups) {
52 + errors.push(
53 + `${location}: only "// eslint-disable-next-line <rules> -- <reason>" is allowed ` +
54 + '(no file-wide disables, no bare disables without a justification).'
55 + );
56 + return;
57 + }
58 +
59 + const target = lines[index + 1]?.trim();
60 + if (!target) {
61 + errors.push(`${location}: eslint-disable-next-line must govern a non-empty next line.`);
62 + return;
63 + }
64 +
65 + const reason = match.groups.reason.trim();
66 + for (const rule of match.groups.rules.split(',').map(rule => rule.trim())) {
67 + sites.push({ rule, reason, target });
68 + }
69 + });
70 +
71 + return { errors, sites };
72 +};
73 +
74 +export const collectBoundaryManifest = (
75 + packageRoot: string,
76 + srcRoot: string
77 +): CollectedBoundaries => {
78 + const manifest: BoundaryManifest = {};
79 + const errors: string[] = [];
80 +
81 + for (const file of listSourceFiles(srcRoot).sort()) {
82 + const relative = path.relative(packageRoot, file).split(path.sep).join('/');
83 + const parsed = parseBoundarySites(relative, fs.readFileSync(file, 'utf8'));
84 + errors.push(...parsed.errors);
85 +
86 + if (parsed.sites.length > 0) {
87 + manifest[relative] = [...parsed.sites].sort(compareBoundarySites);
88 + }
89 + }
90 +
91 + return { errors, manifest };
92 +};
93 +
94 +const countSites = (sites: readonly BoundarySite[]): Map<string, number> => {
95 + const counts = new Map<string, number>();
96 + for (const site of sites) {
97 + const key = boundarySiteKey(site);
98 + counts.set(key, (counts.get(key) ?? 0) + 1);
99 + }
100 + return counts;
101 +};
102 +
103 +export const compareBoundaryManifests = (
104 + found: BoundaryManifest,
105 + registered: BoundaryManifest
106 +): readonly string[] => {
107 + const errors: string[] = [];
108 + const files = [...new Set([...Object.keys(found), ...Object.keys(registered)])].sort();
109 +
110 + for (const file of files) {
111 + const foundSites = found[file] ?? [];
112 + const registeredSites = registered[file] ?? [];
113 + const foundCounts = countSites(foundSites);
114 + const registeredCounts = countSites(registeredSites);
115 + const sitesByKey = new Map(
116 + [...foundSites, ...registeredSites].map(site => [boundarySiteKey(site), site])
117 + );
118 +
119 + for (const key of [...sitesByKey.keys()].sort()) {
120 + const site = sitesByKey.get(key)!;
121 + const foundCount = foundCounts.get(key) ?? 0;
122 + const registeredCount = registeredCounts.get(key) ?? 0;
123 +
124 + if (foundCount > registeredCount) {
125 + errors.push(
126 + `${file}: ${foundCount}x ${formatBoundarySite(site)} found, ${registeredCount} registered. ` +
127 + 'New or relocated eslint-disables are not allowed in CLI src: thread the ' +
128 + '@effect/platform service (Path, FileSystem), effect/Config, or Either.try instead — ' +
129 + 'see "Effect Boundary Policy" in ts/packages/cli/AGENTS.md. If this is genuinely a new ' +
130 + 'runtime boundary, regenerate the manifest with ' +
131 + '`pnpm run validate:boundaries -- --update` and justify the boundary in your PR.'
132 + );
133 + }
134 +
135 + if (foundCount < registeredCount) {
136 + errors.push(
137 + `${file}: manifest registers ${registeredCount}x ${formatBoundarySite(site)} but only ` +
138 + `${foundCount} exist. Nice — a boundary went away or moved. Regenerate the manifest ` +
139 + 'with `pnpm run validate:boundaries -- --update`.'
140 + );
141 + }
142 + }
143 + }
144 +
145 + return errors;
146 +};
147 +
148 +export const countBoundarySites = (manifest: BoundaryManifest): number =>
149 + Object.values(manifest).reduce((sum, sites) => sum + sites.length, 0);
ts/packages/cli/scripts/validate-eslint-boundaries.ts new
+53
@@ -0,0 +1,53 @@
1 +// Guards the CLI's Effect platform boundaries: every eslint-disable comment in
2 +// src/ must be a single-line `eslint-disable-next-line` with a `-- reason`
3 +// justification, and must be registered in eslint-boundaries.json. The manifest
4 +// pins each rule, justification, and governed next-line target, so adding or
5 +// relocating a disable fails until the manifest is regenerated on purpose (see
6 +// AGENTS.md, "Effect Boundary Policy").
7 +//
8 +// Usage:
9 +// tsx ./scripts/validate-eslint-boundaries.ts # verify (CI)
10 +// tsx ./scripts/validate-eslint-boundaries.ts --update # regenerate manifest
11 +import * as fs from 'node:fs';
12 +import * as path from 'node:path';
13 +
14 +import {
15 + collectBoundaryManifest,
16 + compareBoundaryManifests,
17 + countBoundarySites,
18 + type BoundaryManifest,
19 +} from './eslint-boundaries';
20 +
21 +const scriptDir = import.meta.dirname ?? path.dirname(new URL(import.meta.url).pathname);
22 +const packageRoot = path.resolve(scriptDir, '..');
23 +const srcRoot = path.join(packageRoot, 'src');
24 +const manifestPath = path.join(packageRoot, 'eslint-boundaries.json');
25 +
26 +const collected = collectBoundaryManifest(packageRoot, srcRoot);
27 +const errors = [...collected.errors];
28 +const found = collected.manifest;
29 +
30 +if (process.argv.includes('--update')) {
31 + if (errors.length > 0) {
32 + console.error(errors.join('\n'));
33 + console.error('\nFix the malformed disables above before regenerating the manifest.');
34 + process.exit(1);
35 + }
36 + fs.writeFileSync(manifestPath, `${JSON.stringify(found, null, 2)}\n`);
37 + console.log(
38 + `Wrote ${path.relative(packageRoot, manifestPath)} (${Object.keys(found).length} files).`
39 + );
40 + process.exit(0);
41 +}
42 +
43 +const manifest: BoundaryManifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
44 +errors.push(...compareBoundaryManifests(found, manifest));
45 +
46 +if (errors.length > 0) {
47 + console.error(errors.join('\n'));
48 + process.exit(1);
49 +}
50 +
51 +console.log(
52 + `eslint boundaries OK: ${countBoundarySites(found)} registered disables across ${Object.keys(found).length} files.`
53 +);
ts/packages/cli/src/analytics/events.ts
+4 -1
@@ -90,7 +90,9 @@ const TOOL_VALIDATION_CODES: ReadonlySet<number> = new Set([
90 // A parent `composio run` process hands these values to child CLI invocations through the
91 // environment at spawn time; the event builders below are plain synchronous functions that
92 // run outside any Effect context, so effect/Config is not available here.
93 +// eslint-disable-next-line no-restricted-syntax -- spawn-time env handoff read outside Effect
94 const getInvocationOrigin = (): string => process.env.COMPOSIO_CLI_INVOCATION_ORIGIN ?? 'cli';
95 +// eslint-disable-next-line no-restricted-syntax -- spawn-time env handoff read outside Effect
96 const getParentRunId = (): string | undefined => process.env.COMPOSIO_CLI_PARENT_RUN_ID;
97
98 const extractCommandPath = (argv: ReadonlyArray<string>): string => {
@@ -353,7 +355,8 @@ export const createCliCommandTelemetryContext = (
355 startedAt: Date.now(),
356 runId:
357 extractCommandPath(argv) === 'run'
356 - ? (process.env.COMPOSIO_CLI_PARENT_RUN_ID ?? crypto.randomUUID())
358 + ? // eslint-disable-next-line no-restricted-syntax -- spawn-time env handoff from parent run
359 + (process.env.COMPOSIO_CLI_PARENT_RUN_ID ?? crypto.randomUUID())
360 : undefined,
361 });
362
ts/packages/cli/src/bin.ts
+1
@@ -19,6 +19,7 @@ const stripTelemetryDebugFlag = (argv: ReadonlyArray<string>): string[] => {
19 normalizedArgv.splice(flagIndex, 1);
20 // Bootstrap runs before the Effect runtime and ConfigProvider exist; the stripped flag is
21 // persisted as an env var so later effect/Config reads and child processes observe it.
22 + // eslint-disable-next-line no-restricted-syntax -- pre-runtime env write during bootstrap
23 process.env[CLI_TELEMETRY_DEBUG_ENV_VAR] = 'true';
24 return normalizedArgv;
25 };
ts/packages/cli/src/cli-main.ts
+1
@@ -152,6 +152,7 @@ const runWithTelemetry = Effect.gen(function* () {
152 if (commandTelemetryContext.commandPath === 'run' && commandTelemetryContext.runId) {
153 // effect/Config is read-only; the run id must be written into the environment so the run
154 // command and the child processes it spawns observe the same telemetry run id.
155 + // eslint-disable-next-line no-restricted-syntax -- env write propagates run id to children
156 process.env.COMPOSIO_CLI_PARENT_RUN_ID = commandTelemetryContext.runId;
157 }
158
ts/packages/cli/src/commands/auth-configs/commands/auth-configs.create.cmd.ts
+5 -4
@@ -1,6 +1,7 @@
1 import { Args, Command, Options } from '@effect/cli';
2 -import { Effect, Option } from 'effect';
2 +import { Effect, Either, Option } from 'effect';
3 import type { AuthConfigCreateParams } from '@composio/client/resources/auth-configs';
4 +import { parseJsonRecord } from 'src/utils/parse-json';
5 import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 import { TerminalUI } from 'src/services/terminal-ui';
7 import { requireAuth } from 'src/effects/require-auth';
@@ -62,15 +63,15 @@ export const authConfigsCmd$Create = Command.make(
63 // Parse custom credentials JSON if provided
64 let parsedCustomCredentials: Record<string, unknown> | undefined;
65 if (Option.isSome(customCredentials)) {
65 - try {
66 - parsedCustomCredentials = JSON.parse(customCredentials.value) as Record<string, unknown>;
67 - } catch {
66 + const parsed = parseJsonRecord(customCredentials.value);
67 + if (Either.isLeft(parsed)) {
68 yield* ui.log.error('Invalid JSON in --custom-credentials. Please provide valid JSON.');
69 yield* ui.log.step(
70 'Example:\n> composio dev auth-configs create "name" --toolkit "gmail" --custom-credentials \'{"client_id":"...","client_secret":"..."}\''
71 );
72 return;
73 }
74 + parsedCustomCredentials = parsed.right;
75 }
76
77 // Parse scopes into array
ts/packages/cli/src/commands/index.ts
+2
@@ -316,8 +316,10 @@ const normalizeHiddenDebugFlags = (argv: ReadonlyArray<string>): ReadonlyArray<s
316 // The hidden --acp-only flag is stripped from argv before @effect/cli parses it, so its value
317 // travels to run.cmd.ts through the environment; effect/Config cannot write or delete env vars.
318 if (acpOnly === undefined) {
319 + // eslint-disable-next-line no-restricted-syntax -- env delete clears a stale hidden-flag value
320 delete process.env.COMPOSIO_RUN_ACP_ONLY;
321 } else {
322 + // eslint-disable-next-line no-restricted-syntax -- env write hands the stripped flag to run.cmd
323 process.env.COMPOSIO_RUN_ACP_ONLY = acpOnly ? '1' : '0';
324 }
325
ts/packages/cli/src/commands/install.cmd.ts
+2
@@ -48,6 +48,7 @@ const UNSAFE_PATH_CHARS = /[;`$|&"'()\n\r\\]/;
48 const isUnsafePath = (p: string): boolean => UNSAFE_PATH_CHARS.test(p);
49
50 const detectShell = (path: Path.Path): Shell | undefined => {
51 + // eslint-disable-next-line no-restricted-syntax -- $SHELL is read inside a plain synchronous helper that mirrors install.sh's shell detection, outside any Effect context
52 const shellEnv = process.env.SHELL ?? '';
53 const base = path.basename(shellEnv);
54 if (base === 'zsh') return 'zsh';
@@ -161,6 +162,7 @@ export const installShellIntegration = (params: {
162 yield* ui.intro('composio install');
163
164 // Detect install directory — either from env or default ~/.composio
165 + // eslint-disable-next-line no-restricted-syntax -- COMPOSIO_INSTALL_DIR is the handoff variable set by the install.sh bootstrapper for this one-shot post-install step; read directly to stay byte-compatible with the script
166 const installDir = process.env.COMPOSIO_INSTALL_DIR ?? path.join(os.homedir, '.composio');
167
168 if (isUnsafePath(installDir)) {
ts/packages/cli/src/commands/run.cmd.ts
+5
@@ -301,6 +301,7 @@ const resolveRunHelperContext = () =>
301 const orgId = Option.getOrUndefined(userContext.data.orgId);
302 const defaultComposioDir = path.join(os.homedir(), USER_COMPOSIO_DIR);
303 const configuredCacheDir =
304 + // eslint-disable-next-line no-restricted-syntax -- honors the same COMPOSIO_CACHE_DIR/CACHE_DIR overrides the run-helpers child runtime reads, so the sandbox read roots match the child's cache location
305 process.env.COMPOSIO_CACHE_DIR?.trim() || process.env.CACHE_DIR?.trim() || defaultComposioDir;
306 const baseReadAccessRoots = [
307 ...new Set([defaultComposioDir, configuredCacheDir].map(value => path.resolve(value))),
@@ -429,9 +430,11 @@ export const runCmd = Command.make('run', {
430 }) =>
431 Effect.gen(function* () {
432 const path = yield* Path.Path;
433 + // eslint-disable-next-line no-restricted-syntax -- reuses the run ID a parent `composio run` process passed via env so nested runs share one run identity
434 const runId = process.env.COMPOSIO_CLI_PARENT_RUN_ID ?? crypto.randomUUID();
435 const perfDebug = isPerfDebugEnabled();
436 const toolDebug = isToolDebugEnabled();
437 + // eslint-disable-next-line no-restricted-syntax -- reads the COMPOSIO_RUN_ACP_ONLY flag a parent process sets to force the ACP-only subagent path in the child run
438 const acpOnly = process.env.COMPOSIO_RUN_ACP_ONLY === '1';
439 if (Option.isNone(file)) {
440 const [inlineCode] = args;
@@ -474,6 +477,7 @@ export const runCmd = Command.make('run', {
477 );
478 const ui = yield* TerminalUI;
479 let cleanupPaths: ReadonlyArray<string> = [];
480 + // eslint-disable-next-line no-restricted-syntax -- try/finally removes the temp preload and wrapper files around the imperative Bun.spawn block, whose success path ends in process.exit
481 try {
482 yield* appendCliSessionHistory({
483 orgId: helperContext.orgId,
@@ -498,6 +502,7 @@ export const runCmd = Command.make('run', {
502 const child = Bun.spawn({
503 cmd: runCommand.cmd,
504 env: {
505 + // eslint-disable-next-line no-restricted-syntax -- spreads the caller's full environment into the spawned script so user-provided variables reach the child process
506 ...process.env,
507 BUN_BE_BUN: '1',
508 COMPOSIO_CLI_PARENT_RUN_ID: runId,
ts/packages/cli/src/commands/toolkits/commands/toolkits.search.cmd.ts
+1 -1
@@ -1,6 +1,6 @@
1 import process from 'node:process';
2 import { Args, Command, Options } from '@effect/cli';
3 -import { Effect, Option } from 'effect';
3 +import { Effect } from 'effect';
4 import { ComposioToolkitsRepository } from 'src/services/composio-clients';
5 import { TerminalUI } from 'src/services/terminal-ui';
6 import { requireAuth } from 'src/effects/require-auth';
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+4
@@ -316,6 +316,7 @@ const getExecuteOutputEncoder = () => {
316 return executeOutputEncoder;
317 };
318
319 +// eslint-disable-next-line no-restricted-syntax -- COMPOSIO_CLI_INVOCATION_ORIGIN is a spawn-time handshake the parent `composio run` process injects into nested CLI invocations, not user configuration, and it must be read fresh at call time
320 const shouldStoreLargeExecuteOutput = () => process.env.COMPOSIO_CLI_INVOCATION_ORIGIN !== 'run';
321
322 type StoredExecuteOutputSummary = {
@@ -366,6 +367,7 @@ const persistLargeExecuteOutput = (toolSlug: string, json: string, sharedDirecto
367 contents: json,
368 name: `${toolSlug}_OUTPUT`,
369 extension: 'json',
370 + // eslint-disable-next-line no-restricted-syntax -- COMPOSIO_RUN_OUTPUT_DIR is injected per-subprocess by the parent `composio run` so nested executions share one output directory; it is inter-process plumbing, not user configuration
371 directoryPath: sharedDirectory?.trim() || process.env.COMPOSIO_RUN_OUTPUT_DIR?.trim(),
372 });
373
@@ -1067,6 +1069,7 @@ const resolveExecuteContext = (params: RunToolsExecuteParams) =>
1069 args: parsedArgs,
1070 resolvedUserId: 'local',
1071 selectedConnectedAccountId: undefined,
1072 + // eslint-disable-next-line no-restricted-syntax -- COMPOSIO_RUN_OUTPUT_DIR is injected per-subprocess by the parent `composio run` so nested local-tool executions write into its shared output directory; inter-process plumbing, not user configuration
1073 executeOutputDir: process.env.COMPOSIO_RUN_OUTPUT_DIR?.trim() || undefined,
1074 executeParams: {
1075 userId: 'local',
@@ -1139,6 +1142,7 @@ const resolveExecuteContext = (params: RunToolsExecuteParams) =>
1142 )
1143 : parsedArgs;
1144 const executeOutputDir =
1145 + // eslint-disable-next-line no-restricted-syntax -- COMPOSIO_RUN_OUTPUT_DIR is injected per-subprocess by the parent `composio run` and must take precedence over the session artifacts directory; inter-process plumbing, not user configuration
1146 process.env.COMPOSIO_RUN_OUTPUT_DIR?.trim() ||
1147 Option.getOrUndefined(
1148 yield* resolveCliSessionArtifacts({
ts/packages/cli/src/commands/triggers/commands/triggers.create.cmd.ts
+11 -11
@@ -1,5 +1,6 @@
1 import { Args, Command, Options } from '@effect/cli';
2 -import { Effect, Option } from 'effect';
2 +import { Effect, Either, Option } from 'effect';
3 +import { parseJsonRecord } from 'src/utils/parse-json';
4 import { requireAuth } from 'src/effects/require-auth';
5 import { handleHttpServerError } from 'src/effects/handle-http-error';
6 import { ComposioToolkitsRepository } from 'src/services/composio-clients';
@@ -43,22 +44,21 @@ export const triggersCmd$Create = Command.make(
44
45 let parsedTriggerConfig: Record<string, unknown> | undefined;
46 if (Option.isSome(triggerConfig)) {
46 - try {
47 - const parsed: unknown = JSON.parse(triggerConfig.value);
48 - if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
47 + const parsed = parseJsonRecord(triggerConfig.value);
48 + if (Either.isLeft(parsed)) {
49 + if (parsed.left.reason === 'not-a-record') {
50 yield* ui.log.error(
51 '--trigger-config must be a JSON object (e.g. \'{"key":"value"}\').'
52 );
52 - return;
53 + } else {
54 + yield* ui.log.error('Invalid JSON in --trigger-config. Please provide valid JSON.');
55 + yield* ui.log.step(
56 + 'Example:\n> composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --trigger-config \'{"label":"inbox"}\''
57 + );
58 }
54 - parsedTriggerConfig = parsed as Record<string, unknown>;
55 - } catch {
56 - yield* ui.log.error('Invalid JSON in --trigger-config. Please provide valid JSON.');
57 - yield* ui.log.step(
58 - 'Example:\n> composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --trigger-config \'{"label":"inbox"}\''
59 - );
59 return;
60 }
61 + parsedTriggerConfig = parsed.right;
62 }
63
64 const createdOpt = yield* ui
ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
+2
@@ -184,6 +184,7 @@ export const triggersCmd$Listen = Command.make(
184 const runtime = yield* Effect.runtime<never>();
185 const forwardUrl = Option.getOrUndefined(forward);
186 const generatedWebhookSecret = `composio-forward-secret-${randomUUID()}`;
187 + // eslint-disable-next-line no-restricted-syntax -- the forward signing secret is an optional raw passthrough from the user's shell; its literal presence/absence selects the generated-secret fallback
188 const webhookSecret = process.env.COMPOSIO_WEBHOOK_SECRET ?? generatedWebhookSecret;
189 const outputFilePathOption = Option.getOrUndefined(out);
190 const outputFilePath = outputFilePathOption ? path.resolve(outputFilePathOption) : undefined;
@@ -210,6 +211,7 @@ export const triggersCmd$Listen = Command.make(
211
212 yield* ui.intro('composio dev triggers listen');
213 if (forwardUrl) {
214 + // eslint-disable-next-line no-restricted-syntax -- re-checks the same raw env var to tell the user whether they supplied a secret or this session generated one
215 if (process.env.COMPOSIO_WEBHOOK_SECRET) {
216 yield* ui.note(
217 `Forward URL: ${forwardUrl}\nSigning secret: ${webhookSecret}`,
ts/packages/cli/src/services/agents.ts
+1
@@ -80,6 +80,7 @@ export class AgentResponseDecodeError extends Data.TaggedError(
80 }> {}
81
82 const agentsBaseURL = (): string =>
83 + // eslint-disable-next-line no-restricted-syntax -- read lazily at request time inside a plain sync helper so tests can repoint agents.composio.dev per call without rebuilding a Config layer
84 (process.env.COMPOSIO_AGENTS_BASE_URL ?? DEFAULT_AGENTS_BASE_URL).replace(/\/+$/, '');
85
86 const decodeAgentResponse =
ts/packages/cli/src/services/cli-session-artifacts.ts
+2
@@ -10,7 +10,9 @@ export const resolveArtifactsRoot = Effect.gen(function* () {
10 const cliUserConfig = yield* ComposioCliUserConfig;
11
12 return (
13 + // eslint-disable-next-line no-restricted-syntax -- read inline so a blank/whitespace-only COMPOSIO_SESSION_DIR falls through the || precedence chain (session dir > cache dir > user config > tmpdir)
14 process.env.COMPOSIO_SESSION_DIR?.trim() ||
15 + // eslint-disable-next-line no-restricted-syntax -- COMPOSIO_CACHE_DIR is the second rung of the same fall-through chain: env overrides must beat the persisted artifactDirectory before the tmpdir default
16 process.env.COMPOSIO_CACHE_DIR?.trim() ||
17 cliUserConfig.data.artifactDirectory?.trim() ||
18 path.join(os.tmpdir, 'composio')
ts/packages/cli/src/services/cli-user-config.ts
+1
@@ -54,6 +54,7 @@ const decodeConfigJson = Schema.decodeUnknown(Schema.parseJson(JsonRecordSchema)
54 const syncPath = Effect.runSync(Path.Path.pipe(Effect.provide(Path.layer)));
55
56 export const resolveCliConfigDirectorySync = (): string =>
57 + // eslint-disable-next-line no-restricted-syntax -- this resolver is called from synchronous non-Effect code, so the COMPOSIO_CACHE_DIR override cannot come from effect/Config here
58 process.env.COMPOSIO_CACHE_DIR?.trim() ||
59 syncPath.join(os.homedir(), constants.USER_COMPOSIO_DIR);
60
ts/packages/cli/src/services/master-detector.ts
+1
@@ -3,6 +3,7 @@ export type MasterKind = 'claude' | 'codex' | 'user';
3 export const hasEnvPrefix = (env: Record<string, string | undefined>, prefix: string): boolean =>
4 Object.keys(env).some(key => key.startsWith(prefix));
5
6 +// eslint-disable-next-line no-restricted-syntax -- classifies the driving agent by scanning every env key for CODEX_/CLAUDE_ prefixes; effect/Config reads known keys and cannot enumerate the whole environment
7 export const detectMaster = (env: Record<string, string | undefined> = process.env): MasterKind => {
8 if (hasEnvPrefix(env, 'CODEX_')) {
9 return 'codex';
ts/packages/cli/src/services/native-ui-sidecar.ts
+1
@@ -65,6 +65,7 @@ export class NativeUiDecisionMissingError extends Data.TaggedError(
65 // prefixes (OPENCLAW_*, CLAUDE_*, CODEX_*). effect/Config can only read named
66 // keys, so this module keeps a single raw-env boundary, mirroring the
67 // node-os.ts precedent.
68 +// eslint-disable-next-line no-restricted-syntax -- Sole raw-env boundary of this module: prefix scanning needs the full environment map, which effect/Config cannot enumerate.
69 const rawProcessEnv: NodeJS.ProcessEnv = process.env;
70
71 const FALSY_ENV_FLAG_VALUES: ReadonlyArray<string> = ['0', 'false', 'no', 'off'];
ts/packages/cli/src/services/project-environment-detector.ts
+1
@@ -498,6 +498,7 @@ const detectJsPackageManager = (fs: FileSystem.FileSystem, cwd: string) =>
498 if (fileSet.has('pnpm-workspace.yaml')) return 'pnpm' as const;
499 }
500
501 + // eslint-disable-next-line no-restricted-syntax -- npm_config_user_agent is transient metadata injected by the package manager that spawned this process, not CLI configuration; read once as the last-resort heuristic when no lockfile or manifest evidence exists
502 const userAgent = parseUserAgent(process.env.npm_config_user_agent);
503 if (userAgent) return userAgent;
504
ts/packages/cli/src/services/run-helpers-runtime.ts
+6
@@ -262,6 +262,7 @@ const stringifyForPrompt = (value: unknown): string => {
262 if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
263 return String(value);
264 }
265 + // eslint-disable-next-line no-restricted-syntax -- JSON.stringify throws on circular user values in this sync formatter injected into user code; String() is the entire fallback
266 try {
267 return JSON.stringify(value, null, 2);
268 } catch {
@@ -318,6 +319,7 @@ const summarizeCliResultPreview = (result: RunCliResult): unknown => {
319 };
320
321 const readConfiguredExperimentalSubagentTarget = (): 'auto' | 'claude' | 'codex' => {
322 + // eslint-disable-next-line no-restricted-syntax -- sync config read at the child-process boundary; a missing or malformed CLI config file just means the 'auto' target
323 try {
324 const raw = fs.readFileSync(resolveCliConfigPathSync(), 'utf8');
325 const parsed = decodeExperimentalSubagentConfig(raw);
@@ -614,6 +616,7 @@ const createCliRunner = (params: {
616 const requestId = `${args[0] ?? 'cli'}#${++perfDebugSeq}`;
617 helperDebugLog('cli.start', { requestId, args });
618 const env: Record<string, string | undefined> = {
619 + // eslint-disable-next-line no-restricted-syntax -- the spawned CLI child must inherit the caller's full environment before Composio-specific overrides are layered on top
620 ...process.env,
621 ...(helperContext.apiKey ? { COMPOSIO_USER_API_KEY: helperContext.apiKey } : {}),
622 ...(helperContext.baseURL ? { COMPOSIO_BASE_URL: helperContext.baseURL } : {}),
@@ -802,6 +805,7 @@ const createExperimentalSubAgent = (params: {
805 resolvedTarget: target,
806 master,
807 });
808 + // eslint-disable-next-line no-restricted-syntax -- async fallback chain in the user's child process: ACP invoke errors route to the legacy sub-agent path, everything else rethrows
809 try {
810 const response = await invokeAcpSubAgent({
811 prompt: prompt.trim(),
@@ -967,8 +971,10 @@ export const installRunHelpers = async ({
971 Reflect.set(globalThis, 'zod', z);
972
973 const perfDebugEnabled =
974 + // eslint-disable-next-line no-restricted-syntax -- debug flag reaches the child process via inherited environment; the CLI's Config provider is not available here
975 helperContext.perfDebug === true || process.env.COMPOSIO_PERF_DEBUG === '1';
976 const toolDebugEnabled =
977 + // eslint-disable-next-line no-restricted-syntax -- debug flag reaches the child process via inherited environment; the CLI's Config provider is not available here
978 helperContext.toolDebug === true || process.env.COMPOSIO_TOOL_DEBUG === '1';
979 const perfDebugStart = Date.now();
980 const composioBaseURL = (helperContext.baseURL || 'https://backend.composio.dev').replace(
ts/packages/cli/src/services/runtime-debug-flags.ts
+2
@@ -23,7 +23,9 @@ export const resetRuntimeDebugFlags = () => {
23 };
24
25 export const isPerfDebugEnabled = () =>
26 + // eslint-disable-next-line no-restricted-syntax -- called from sync non-Effect helper code in spawned child processes, where the flag arrives via inherited environment rather than a Config provider
27 runtimeDebugFlags.perfDebug || process.env.COMPOSIO_PERF_DEBUG === '1';
28
29 export const isToolDebugEnabled = () =>
30 + // eslint-disable-next-line no-restricted-syntax -- called from sync non-Effect helper code in spawned child processes, where the flag arrives via inherited environment rather than a Config provider
31 runtimeDebugFlags.toolDebug || process.env.COMPOSIO_TOOL_DEBUG === '1';
ts/packages/cli/src/services/tool-permissions.ts
+1
@@ -1007,6 +1007,7 @@ const requestPermissionInBrowser = (params: {
1007 reject(error);
1008 });
1009 server.listen(0, '127.0.0.1', async () => {
1010 + // eslint-disable-next-line no-restricted-syntax -- node:http listen callback inside a Promise executor: on failure to open the browser, close the server and reject the surrounding Promise; Effect's error channel is not available here
1011 try {
1012 const address = server.address();
1013 const port = typeof address === 'object' && address ? address.port : undefined;
ts/packages/cli/src/ui/colors.ts
+1
@@ -14,4 +14,5 @@ export const {
14 white,
15 blue,
16 cyanBright,
17 + // eslint-disable-next-line no-restricted-syntax -- palette is created eagerly at import time, before any Effect runtime; honors the NO_COLOR convention
18 } = color.createColors(!Boolean(process.env.NO_COLOR));
ts/packages/cli/src/ui/redact.ts
+1
@@ -12,6 +12,7 @@ export function redact<const Prefix extends string = string>({
12 value: string;
13 prefix?: Prefix;
14 }): `${Prefix}${string}` {
15 + // eslint-disable-next-line no-restricted-syntax -- plain sync string helper called from formatting code; CI flag toggles redaction in recorded CLI output
16 if (process.env.CI !== 'true') return value as `${Prefix}${string}`;
17 return `${prefix ?? ''}<REDACTED>` as `${Prefix}${string}`;
18 }
ts/packages/cli/test/src/scripts/validate-eslint-boundaries.test.ts new
+104
@@ -0,0 +1,104 @@
1 +import * as fs from 'node:fs';
2 +import * as os from 'node:os';
3 +import * as path from 'node:path';
4 +
5 +import { afterEach, describe, expect, it } from 'vitest';
6 +
7 +import {
8 + collectBoundaryManifest,
9 + compareBoundaryManifests,
10 + parseBoundarySites,
11 +} from '../../../scripts/eslint-boundaries';
12 +
13 +const temporaryDirectories: string[] = [];
14 +
15 +afterEach(() => {
16 + for (const directory of temporaryDirectories.splice(0)) {
17 + fs.rmSync(directory, { force: true, recursive: true });
18 + }
19 +});
20 +
21 +describe('eslint boundary manifest', () => {
22 + it('includes both TypeScript and TSX source files', () => {
23 + const packageRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'composio-eslint-boundaries-'));
24 + const sourceRoot = path.join(packageRoot, 'src');
25 + temporaryDirectories.push(packageRoot);
26 + fs.mkdirSync(sourceRoot);
27 + fs.writeFileSync(path.join(sourceRoot, 'plain.ts'), 'export const plain = true;\n');
28 + fs.writeFileSync(
29 + path.join(sourceRoot, 'component.tsx'),
30 + [
31 + '// eslint-disable-next-line no-restricted-syntax -- import-time runtime bridge',
32 + 'export const Component = () => process.env.COMPONENT_NAME;',
33 + ].join('\n')
34 + );
35 + fs.writeFileSync(
36 + path.join(sourceRoot, 'ignored.js'),
37 + [
38 + '// eslint-disable-next-line no-restricted-syntax -- should not be scanned',
39 + 'export const ignored = process.env.IGNORED;',
40 + ].join('\n')
41 + );
42 +
43 + expect(collectBoundaryManifest(packageRoot, sourceRoot)).toEqual({
44 + errors: [],
45 + manifest: {
46 + 'src/component.tsx': [
47 + {
48 + reason: 'import-time runtime bridge',
49 + rule: 'no-restricted-syntax',
50 + target: 'export const Component = () => process.env.COMPONENT_NAME;',
51 + },
52 + ],
53 + },
54 + });
55 + });
56 +
57 + it('rejects moving a registered disable to another target in the same file', () => {
58 + const registered = parseBoundarySites(
59 + 'src/example.ts',
60 + [
61 + '// eslint-disable-next-line no-restricted-syntax -- runtime environment bridge',
62 + 'const apiKey = process.env.COMPOSIO_API_KEY;',
63 + ].join('\n')
64 + );
65 + const relocated = parseBoundarySites(
66 + 'src/example.ts',
67 + [
68 + '// eslint-disable-next-line no-restricted-syntax -- runtime environment bridge',
69 + 'const debug = process.env.DEBUG;',
70 + ].join('\n')
71 + );
72 +
73 + const errors = compareBoundaryManifests(
74 + { 'src/example.ts': [...relocated.sites] },
75 + { 'src/example.ts': [...registered.sites] }
76 + );
77 +
78 + expect(errors).toHaveLength(2);
79 + expect(errors).toEqual(
80 + expect.arrayContaining([
81 + expect.stringContaining('process.env.COMPOSIO_API_KEY'),
82 + expect.stringContaining('process.env.DEBUG'),
83 + ])
84 + );
85 + });
86 +
87 + it('preserves duplicate semantic sites as a deterministic multiset', () => {
88 + const directive =
89 + '// eslint-disable-next-line no-restricted-syntax -- runtime environment bridge';
90 + const target = 'process.env.COMPOSIO_API_KEY = apiKey;';
91 + const registered = parseBoundarySites(
92 + 'src/example.ts',
93 + [directive, target, directive, target].join('\n')
94 + );
95 + const found = parseBoundarySites('src/example.ts', [directive, target].join('\n'));
96 +
97 + expect(
98 + compareBoundaryManifests(
99 + { 'src/example.ts': [...found.sites] },
100 + { 'src/example.ts': [...registered.sites] }
101 + )
102 + ).toEqual([expect.stringContaining('manifest registers 2x "no-restricted-syntax"')]);
103 + });
104 +});