Skip to content

refactor: replace ban-types Function with real call signatures - #6671

Merged
pedrofrxncx merged 1 commit into
mainfrom
refactor/ban-types-function-to-real-signatures
Aug 28, 2026
Merged

refactor: replace ban-types Function with real call signatures#6671
pedrofrxncx merged 1 commit into
mainfrom
refactor/ban-types-function-to-real-signatures

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Two spots in the codebase type a callback as the bare Function type, which the repo's ban-types oxlint rule flags (a warn-level rule, not CI-enforced, so it accumulates as un-caught debt) — Function accepts any arity/argument types, so a caller can pass the wrong shape and only find out at runtime.

  1. packages/mcp-utils/src/sandbox/run-code.ts: executePendingJobs on QuickJSRuntime already has a real exported signature, (maxJobsToExecute?: number | void) => ExecutePendingJobsResult, from quickjs-emscripten-core's own .d.ts. Typed the inline ctx.runtime param against that instead of Function.
  2. apps/api/src/harnesses/decopilot/built-in-tools/index.ts: instrumentBuiltIns casts each AI-SDK tool's execute to read it off before wrapping. Both call sites (originalExecute.call(t, input, options)) always pass exactly two arguments, so the cast is now (input: unknown, options: unknown) => unknown instead of Function.

Why a maintainer wants this: a real signature is what bunx tsc --noEmit can actually check a call against; Function is a no-op for that in both places.

Behavior-preserving — same runtime code, only annotations changed. No test needed (pure type-level change); a reviewer confirms with:

cd packages/mcp-utils && bunx tsc --noEmit
cd apps/api && bunx tsc --noEmit
bunx oxlint packages/mcp-utils/src/sandbox/run-code.ts apps/api/src/harnesses/decopilot/built-in-tools/index.ts

Locally ran: bun run fmt, bunx tsc --noEmit in both packages/mcp-utils and apps/api (both clean), and bunx oxlint on both touched files (0 warnings/errors). Full CI validates the rest.


Summary by cubic

Replaces bare Function annotations with real call signatures in two spots so tsc can actually check callback shapes instead of accepting anything at compile time.

  • In packages/mcp-utils/src/sandbox/run-code.ts, executePendingJobs now types the runtime callback as (maxJobsToExecute?: number) => ExecutePendingJobsResult, matching quickjs-emscripten-core's exported signature.
  • In apps/api/src/harnesses/decopilot/built-in-tools/index.ts, the execute cast is now (input: unknown, options: unknown) => unknown, matching the two call sites that pass exactly those arguments.

Behavior is unchanged; this is a pure type-level refactor, so no tests or runtime effects. Verify with bunx tsc --noEmit in packages/mcp-utils and apps/api, plus bunx oxlint on both touched files.

Written for commit 529fefa. Summary will update on new commits.

Review in cubic

- packages/mcp-utils/src/sandbox/run-code.ts: executePendingJobs now
  typed against quickjs-emscripten-core's own
  (maxJobsToExecute?: number) => ExecutePendingJobsResult signature.
- apps/api/src/harnesses/decopilot/built-in-tools/index.ts: the
  instrumentBuiltIns execute-wrapper cast now types execute as
  (input: unknown, options: unknown) => unknown, matching the two call
  sites that already pass it exactly those two arguments.
@pedrofrxncx
pedrofrxncx merged commit 83aaca6 into main Aug 28, 2026
33 checks passed
@pedrofrxncx
pedrofrxncx deleted the refactor/ban-types-function-to-real-signatures branch August 28, 2026 12:06
decocms Bot pushed a commit that referenced this pull request Aug 28, 2026
PR: #6671 refactor: replace ban-types Function with real call signatures
Bump type: patch

- decocms (apps/api/package.json): 4.289.0 -> 4.289.1
- @decocms/native (apps/native/package.json): 4.289.0 -> 4.289.1
- @decocms/mcp-utils (packages/mcp-utils/package.json): 1.2.0 -> 1.2.1

Deploy-Scope: server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant