Skip to content

Fix: missing SDKControlInitializeRequest exports in the CLI print module#948

Open
kauanunesz wants to merge 1 commit intoGitlawb:mainfrom
kauanunesz:fix-export-types-sdk
Open

Fix: missing SDKControlInitializeRequest exports in the CLI print module#948
kauanunesz wants to merge 1 commit intoGitlawb:mainfrom
kauanunesz:fix-export-types-sdk

Conversation

@kauanunesz
Copy link
Copy Markdown

@kauanunesz kauanunesz commented Apr 29, 2026

Summary

What changed: Fixed broken type exports in src/entrypoints/sdk/controlTypes.js and ensured the print.ts CLI module correctly imports SDKControlInitializeRequest.

Why it changed: The CLI was failing to compile because it was attempting to import members that were not being correctly exported or recognized by the TypeScript compiler in the SDK entrypoint.

Impact

User-facing impact: None directly, but this fix is essential for the stability of the CLI build and prevents crashes during SDK initialization.

Developer/maintainer impact: Fixes build errors (TS2305) and improves type safety across the CLI and SDK boundaries.

Testing

  • bun run build
  • bun run smoke
  • focused tests: focused tests: Verified that the print.ts module no longer shows TS2305 errors in the editor and during compilation.

Notes

Provider/model path tested: N/A (Build/Type fix).
Screenshots attached: See image_c4d99f.jpg for the original error.
Follow-up work or known limitations: None.

Copy link
Copy Markdown
Collaborator

@gnanam1990 gnanam1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The controlTypes.ts half is fine — adding stub = any types for SDKControlInitializeRequest, SDKControlInitializeResponse, SDKControlMcpSetServersResponse, SDKControlReloadPluginsResponse matches the existing stub pattern in that file and resolves the TS2305 in print.ts. Good find.

The print.ts change is wrong though, and needs to be reverted/redone:

  1. @anthropic-ai/claude-agent/sdk (with a slash) is not a published package. The original @anthropic-ai/claude-agent-sdk (with a dash) is the real npm package name, but neither is listed in this repo's package.json dependencies and neither is installed in node_modules. The original line was a dangling reference; the rename makes it more wrong, not less. Build only passes because it's a type-only import (TypeScript erases it).

  2. The right fix is one of:

    • Define a local stub for PermissionMode in src/entrypoints/sdk/controlTypes.ts (same = any pattern as the others) and import it from there, or
    • Drop the import entirely and use the already-imported InternalPermissionMode from src/types/permissions.js at the cast site (line 1068) — that's likely the actually-correct type anyway.
  3. Minor: trailing whitespace on the four new lines in controlTypes.ts and missing newline at EOF — could you clean those up while you're in there?

Could you split this into the controlTypes stub additions (good as-is, modulo whitespace) and a proper fix for the PermissionMode import? Happy to re-review.

@Vasanthdev2004
Copy link
Copy Markdown
Collaborator

Thanks for the PR. This still needs a fresh pass before it can be reviewed/merged.

Current state:

  • There is an active changes-requested review from Gnanam.
  • main has moved a lot around the SDK/control type surface since this PR was opened.
  • The print.ts import issue still needs to follow the requested direction: avoid switching to @anthropic-ai/claude-agent/sdk, and either use the local/internal permission type path or add the matching local stub cleanly.

Could you rebase this onto latest main, address the existing review feedback, and push a fresh head? Once that is done, I can re-review the current diff instead of judging the stale branch.

Copy link
Copy Markdown
Collaborator

@Vasanthdev2004 Vasanthdev2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I did a targeted current-head review of ff7bb8b and I agree with the existing blocker: this still needs changes before merge.

Review scope: Targeted review of the SDK control type export/import fix only.

Verdict: Needs changes

Blocking issue:

  1. src/cli/print.ts changes the type import to @anthropic-ai/claude-agent/sdk, but that package path is not a valid dependency in this repo. Since this is a type-only import, the build can miss it, but it still leaves a stale/invalid type boundary in source. Please do not introduce this external package path.

Suggested fix:

  • Keep the local controlTypes.ts stub additions, but clean the trailing whitespace/newline.
  • For PermissionMode, either use the already-imported InternalPermissionMode from src/types/permissions.js at the cast site, or define/export a local stub from src/entrypoints/sdk/controlTypes.ts and import from there.
  • Rebase onto latest main, because the SDK/control surface has moved significantly since this branch was opened.

Non-blocking note:

  • The added SDKControl* stubs are fine in principle and match the existing stub style; the blocker is the invalid PermissionMode import plus the stale branch state.

Happy to re-review once this is rebased and the import is fixed.

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.

3 participants