Skip to content

feat(sdk): expose sandbox, safe_mode, insecure, worktree CLI flags - #6479

Closed
juhuan wants to merge 1 commit into
QwenLM:mainfrom
juhuan:feat/sdk-cli-flags-batch
Closed

feat(sdk): expose sandbox, safe_mode, insecure, worktree CLI flags#6479
juhuan wants to merge 1 commit into
QwenLM:mainfrom
juhuan:feat/sdk-cli-flags-batch

Conversation

@juhuan

@juhuan juhuan commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add sandbox (Python) / sandbox (TS) → CLI --sandbox flag
  • Add safe_mode (Python) / safeMode (TS) → CLI --safe-mode flag
  • Add insecure → CLI --insecure flag (skip TLS verification)
  • Add worktree → CLI --worktree flag (Git worktree mode)
  • All four are simple boolean options implemented in both Python SDK and TS SDK
  • Unit tests added for both SDKs covering flag presence when true and absence when false

Test plan

  • Python SDK unit tests pass (36 tests)
  • TS SDK unit tests pass (76 tests)
  • Boolean flags present in CLI args when set to true
  • Boolean flags absent from CLI args when set to false

Add boolean options to both Python and TS SDKs:
- sandbox (--sandbox): run in sandbox mode
- safe_mode (--safe-mode): disable all customizations for troubleshooting
- insecure (--insecure): skip TLS certificate verification
- worktree (--worktree): enable Git worktree mode

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @juhuan — thanks for the PR! Before we dive into the code, we need the PR body to follow the PR template. The current description uses ## Summary / ## Test plan headings, but the template requires:

  • ## What this PR does — describe the change in prose
  • ## Why it's needed — motivation and user-facing benefit
  • ## Reviewer Test Plan with ### How to verify, ### Evidence (Before & After), and ### Tested on subsections
  • ## Risk & Scope — main risks, out-of-scope items, breaking changes
  • ## Linked Issues — related issues
  • Chinese translation in a <details> block

These headings aren't bureaucracy — they help reviewers understand why the change exists and how to verify it without guessing. Could you update the PR body to match the template?

中文说明

@juhuan 你好,感谢你的 PR!在审查代码之前,需要 PR 正文遵循 PR 模板。当前描述使用了 ## Summary / ## Test plan 标题,但模板要求:

  • ## What this PR does — 用文字描述变更内容
  • ## Why it's needed — 动机和用户价值
  • ## Reviewer Test Plan 包含 ### How to verify### Evidence (Before & After)### Tested on 子章节
  • ## Risk & Scope — 主要风险、不在范围内的内容、破坏性变更
  • ## Linked Issues — 关联的 issue
  • 中文翻译 放在 <details> 块中

这些标题不是形式主义——它们帮助 reviewer 理解为什么要做这个改动以及如何验证,而不是靠猜。能否按模板更新 PR 正文?

Qwen Code · qwen3.7-max

}

if (this.options.worktree) {
args.push('--worktree');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Suggestion] The CLI defines --worktree as type: 'string' in yargs (config.ts:881), but the SDK appends it as a bare --worktree with no value. This works today because --worktree is the last argument — yargs treats the missing value as "". However, if any future change appends another flag after --worktree, yargs will silently consume it as the worktree slug.

Passing an explicit empty string makes this position-independent:

Suggested change
args.push('--worktree');
if (this.options.worktree) {
args.push('--worktree', '');
}

Additionally, the CLI supports slug (--worktree my-feature) and PR reference (--worktree=#123) modes that the SDK's boolean type cannot express. Consider typing worktree as boolean | string to expose the CLI's full capability, and emitting --worktree <value> when a string is provided.

The same fix should be applied to the Python SDK's transport.py.

— qwen3.7-max via Qwen Code /review

}

if (this.options.insecure) {
args.push('--insecure');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Suggestion] The CLI logs a prominent warning to stderr when --insecure is passed, but the SDK's default stderr handling ('ignore' unless debug: true or a stderr callback is configured) silently discards it. An SDK consumer enabling insecure: true programmatically gets no visible indication that TLS verification is disabled.

Consider emitting an SDK-side warning:

if (this.options.insecure) {
  console.warn('[qwen-code-sdk] TLS certificate verification is disabled (--insecure)');
}

The same concern applies to the Python SDK's transport.py, where stderr defaults to subprocess.DEVNULL.

— qwen3.7-max via Qwen Code /review

* When resume is provided, this should match the resume ID.
*/
sessionId?: string;
sandbox?: boolean;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Suggestion] These four new fields in TransportOptions lack JSDoc, while the same fields in QueryOptions (lines 469-503) have full documentation with descriptions, @default values, and a security warning on insecure. Neighboring fields in this same type (continue, resume, sessionId) all have JSDoc blocks.

Consider adding JSDoc to match QueryOptions, or at minimum a one-line description and @default false for each. The insecure field especially benefits from the MITM warning at the type surface.

— qwen3.7-max via Qwen Code /review

@wenshao

wenshao commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

💡 Suggestion: Consolidate SDK PRs

Hi @juhuan, thanks for the comprehensive SDK work! We noticed you have 15 open PRs that all modify the same core files (transport.py, types.py, queryOptionsSchema.ts, types.ts, ProcessTransport.ts, createQuery.ts) and were created on the same day.

The problem

  • Merge conflicts: Since all 15 PRs touch the same files, whichever merges first will cause conflicts in the remaining 14.
  • Review overhead: Reviewing 15 near-identical PRs separately is inefficient and risks fatigue.
  • CI cost: 15 separate CI runs for the same lint/typecheck passes.

Suggestion: regroup into 2 PRs

We recommend closing the current 15 PRs and reopening them as 2 consolidated PRs:

PR 1 — feat(sdk): expose transport and query options in both SDKs

Covers pure SDK-side option additions (~9 current PRs):

PR 2 — feat(sdk): add control request methods to both SDKs

Covers features that also involve CLI-side ControlDispatcher changes (~4 current PRs):

This keeps a reasonable separation of concerns while eliminating the merge-conflict chain and making review much more manageable.

/cc @juhuan

@wenshao

wenshao commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Closing in favor of consolidated PRs (see suggestion comment above). Please reopen as 2 grouped PRs.

@wenshao wenshao closed this Jul 7, 2026
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