…326)
* fix(sdk): honor canUseTool timeout in CLI control requests
Ported from QwenLM#4491. The SDK already honored
`options.timeout.canUseTool` for its own local permission callback, but never
forwarded it to the CLI: the CLI's permission control request used a hardcoded
default, so a long-running `canUseTool` handler could be timed out by the CLI
before the SDK's own timeout elapsed.
- SDK Query now sends `timeout.canUseTool` in the `initialize` control request.
- The CLI's SystemController reads it on initialize, validates it (finite, > 0,
<= 10min cap to avoid setTimeout 32-bit overflow), and stores it on the
control context.
- PermissionController uses the context value (falling back to a 60s default)
instead of the unconditional default when issuing the can_use_tool request.
- types/protocol gain the `timeout` field on CLIControlInitializeRequest.
Tests: SDK Query.test asserts the timeout is sent on initialize (and omitted
when unset). 55 Query tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(sdk): copy CLI chunks into the SDK package bundle
Ported from QwenLM#4541. Both SDK CLI-bundling scripts now copy an
adjacent `chunks/` directory (via a shared `copyOptionalDir` helper that also
covers vendor/ and locales/). If the CLI bundle is ever code-split, its chunk
files must ship in the SDK package or the bundled CLI fails at runtime on
missing imports. Our bundle is currently single-file, so this is a guarded
no-op today — included for parity and to remove the latent footgun.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Automaker <automaker@localhost>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Summary
chunks/directory alongsidecli.js,vendor/, andlocales/for both local repo packaging and CLI-package-based packaging../chunks. The preview SDK package includeddist/cli/cli.jswithout those chunk files, so SDKquery()failed when the embedded CLI started.Validation
query-init-smoke.mjsimportsqueryfrom the locally packed SDK tarball and waits for SDK/CLI initialization.dist/cli/chunks/*.js; the embedded CLI starts withoutERR_MODULE_NOT_FOUND; SDKquery()initializes.npm pack --jsonlisteddist/cli/chunks/*entries, embedded CLI printed0.16.1, andquery-init-smoke.mjsprintedSDK_QUERY_INITIALIZED.cd packages/sdk-typescript && npm pack --json, install the generated tarball in a temp project, then runnode node_modules/@qwen-code/sdk/dist/cli/cli.js --version.@qwen-code/sdk@0.1.8-preview.0fails withERR_MODULE_NOT_FOUND ... dist/cli/chunks/chunk-C6WMLUNB.js; after the fix, the local tarball includes chunk files and the embedded CLI starts successfully.Scope / Risk
Testing Matrix
Testing matrix notes:
Linked Issues / Bugs