diff --git a/docs/developers/sdk-typescript.md b/docs/developers/sdk-typescript.md index d071f7d618..2fcccb3a8c 100644 --- a/docs/developers/sdk-typescript.md +++ b/docs/developers/sdk-typescript.md @@ -60,7 +60,7 @@ Creates a new query session with the Qwen Code. | `cwd` | `string` | `process.cwd()` | The working directory for the query session. Determines the context in which file operations and commands are executed. | | `model` | `string` | - | The AI model to use (e.g., `'qwen-max'`, `'qwen-plus'`, `'qwen-turbo'`). Takes precedence over `OPENAI_MODEL` and `QWEN_MODEL` environment variables. | | `pathToQwenExecutable` | `string` | Auto-detected | Path to the Qwen Code executable. Supports multiple formats: `'qwen'` (native binary from PATH), `'/path/to/qwen'` (explicit path), `'/path/to/cli.js'` (Node.js bundle), `'node:/path/to/cli.js'` (force Node.js runtime), `'bun:/path/to/cli.js'` (force Bun runtime). If not provided, auto-detects from: `QWEN_CODE_CLI_PATH` env var, `~/.volta/bin/qwen`, `~/.npm-global/bin/qwen`, `/usr/local/bin/qwen`, `~/.local/bin/qwen`, `~/node_modules/.bin/qwen`, `~/.yarn/bin/qwen`. | -| `permissionMode` | `'default' \| 'plan' \| 'auto-edit' \| 'yolo'` | `'default'` | Permission mode controlling tool execution approval. See [Permission Modes](#permission-modes) for details. | +| `permissionMode` | `'default' \| 'plan' \| 'auto-edit' \| 'auto' \| 'yolo'` | `'default'` | Permission mode controlling tool execution approval. See [Permission Modes](#permission-modes) for details. | | `canUseTool` | `CanUseTool` | - | Custom permission handler for tool execution approval. Invoked when a tool requires confirmation. Must respond within 60 seconds or the request will be auto-denied. See [Custom Permission Handler](#custom-permission-handler). | | `env` | `Record` | - | Environment variables to pass to the Qwen Code process. Merged with the current process environment. | | `systemPrompt` | `string \| QuerySystemPromptPreset` | - | System prompt configuration for the main session. Use a string to fully override the built-in Qwen Code system prompt, or a preset object to keep the built-in prompt and append extra instructions. | @@ -164,6 +164,7 @@ The SDK supports different permission modes for controlling tool execution: - **`default`**: Write tools are denied unless approved via `canUseTool` callback or in `allowedTools`. Read-only tools execute without confirmation. - **`plan`**: Blocks all write tools, instructing AI to present a plan first. - **`auto-edit`**: Auto-approve edit tools (`edit`, `write_file`, `notebook_edit`) while other tools require confirmation. +- **`auto`**: Uses the built-in classifier to auto-approve safe tool calls and block risky ones, with manual-approval fallback after repeated policy blocks or classifier outages. - **`yolo`**: All tools execute automatically without confirmation. ### Permission Priority Chain @@ -177,8 +178,9 @@ The first matching rule wins. 3. `permissionMode: 'plan'` - Blocks all non-read-only tools 4. `permissionMode: 'yolo'` - Auto-approves all tools 5. `allowedTools` / `permissions.allow` - Auto-approves matching tools -6. `canUseTool` callback - Custom approval logic (if provided, not called for allowed tools) -7. Default behavior - Auto-deny in SDK mode (write tools require explicit approval) +6. `permissionMode: 'auto'` - Classifier-mediated approval for remaining tools +7. `canUseTool` callback - Custom approval logic (if provided, not called for allowed tools) +8. Default behavior - Auto-deny in SDK mode (write tools require explicit approval) ## Examples diff --git a/docs/users/integration-github-action.md b/docs/users/integration-github-action.md index cc1812c178..5edcfd9e24 100644 --- a/docs/users/integration-github-action.md +++ b/docs/users/integration-github-action.md @@ -112,32 +112,32 @@ This type of action can be used to invoke a general-purpose, conversational Qwen -- qwen*api_key: *(Optional)\_ The API key for the Qwen API. +- qwen_api_key: _(Optional)_ The API key for the Qwen API. -- qwen*cli_version: *(Optional, default: `latest`)\_ The version of the Qwen Code CLI to install. Can be "latest", "preview", "nightly", a specific version number, or a git branch, tag, or commit. For more information, see [Qwen Code CLI releases](https://github.com/QwenLM/qwen-code-action/blob/main/docs/releases.md). +- qwen_cli_version: _(Optional, default: `latest`)_ The version of the Qwen Code CLI to install. Can be "latest", "preview", "nightly", a specific version number, or a git branch, tag, or commit. For more information, see [Qwen Code CLI releases](https://github.com/QwenLM/qwen-code-action/blob/main/docs/releases.md). -- qwen*debug: *(Optional)\_ Enable debug logging and output streaming. +- qwen_debug: _(Optional)_ Enable debug logging and output streaming. -- qwen*model: *(Optional)\_ The model to use with Qwen Code. +- qwen_model: _(Optional)_ The model to use with Qwen Code. - prompt: _(Optional, default: `You are a helpful assistant.`)_ A string passed to the Qwen Code CLI's [`--prompt` argument](https://github.com/QwenLM/qwen-code-action/blob/main/docs/cli/configuration.md#command-line-arguments). - settings: _(Optional)_ A JSON string written to `.qwen/settings.json` to configure the CLI's _project_ settings. For more details, see the documentation on [settings files](https://github.com/QwenLM/qwen-code-action/blob/main/docs/cli/configuration.md#settings-files). -- use*qwen_code_assist: *(Optional, default: `false`)\_ Whether to use Code Assist for Qwen Code model access instead of the default Qwen Code API key. +- use_qwen_code_assist: _(Optional, default: `false`)_ Whether to use Code Assist for Qwen Code model access instead of the default Qwen Code API key. For more information, see the [Qwen Code CLI documentation](https://github.com/QwenLM/qwen-code-action/blob/main/docs/cli/authentication.md). -- use*vertex_ai: *(Optional, default: `false`)\_ Whether to use Vertex AI for Qwen Code model access instead of the default Qwen Code API key. +- use_vertex_ai: _(Optional, default: `false`)_ Whether to use Vertex AI for Qwen Code model access instead of the default Qwen Code API key. For more information, see the [Qwen Code CLI documentation](https://github.com/QwenLM/qwen-code-action/blob/main/docs/cli/authentication.md). - extensions: _(Optional)_ A list of Qwen Code CLI extensions to install. -- upload*artifacts: *(Optional, default: `false`)\_ Whether to upload artifacts to the github action. +- upload_artifacts: _(Optional, default: `false`)_ Whether to upload artifacts to the github action. -- use*pnpm: *(Optional, default: `false`)\_ Whether or not to use pnpm instead of npm to install qwen-code-cli +- use_pnpm: _(Optional, default: `false`)_ Whether or not to use pnpm instead of npm to install qwen-code-cli -- workflow*name: *(Optional, default: `${{ github.workflow }}`)\_ The GitHub workflow name, used for telemetry purposes. +- workflow_name: _(Optional, default: `${{ github.workflow }}`)_ The GitHub workflow name, used for telemetry purposes. diff --git a/packages/channels/weixin/src/media.test.ts b/packages/channels/weixin/src/media.test.ts index 28b42467a9..de8f79f0fd 100644 --- a/packages/channels/weixin/src/media.test.ts +++ b/packages/channels/weixin/src/media.test.ts @@ -1,29 +1,12 @@ import { describe, it, expect } from 'vitest'; import { createDecipheriv, createCipheriv } from 'node:crypto'; -import { encryptAesEcb, computeMd5 } from './media.js'; +import { encryptAesEcb, computeMd5, parseAesKey } from './media.js'; /** * Test the AES key parsing and decryption logic used in media.ts. - * We test the pure crypto functions by reimplementing them here - * since they're not exported, but the behavior must match. + * decryptAesEcb remains private, so keep only that helper here. */ -function parseAesKey(aesKeyBase64: string): Buffer { - const decoded = Buffer.from(aesKeyBase64, 'base64'); - if (decoded.length === 16) { - return decoded; - } - if ( - decoded.length === 32 && - /^[0-9a-fA-F]{32}$/.test(decoded.toString('ascii')) - ) { - return Buffer.from(decoded.toString('ascii'), 'hex'); - } - throw new Error( - `Invalid aes_key: expected 16 raw bytes or 32 hex chars, got ${decoded.length} bytes`, - ); -} - function decryptAesEcb(ciphertext: Buffer, key: Buffer): Buffer { const decipher = createDecipheriv('aes-128-ecb', key, null); return Buffer.concat([decipher.update(ciphertext), decipher.final()]); diff --git a/packages/sdk-typescript/README.md b/packages/sdk-typescript/README.md index 1b6f5980f7..f796936351 100644 --- a/packages/sdk-typescript/README.md +++ b/packages/sdk-typescript/README.md @@ -57,7 +57,7 @@ Creates a new query session with the Qwen Code. | `cwd` | `string` | `process.cwd()` | The working directory for the query session. Determines the context in which file operations and commands are executed. | | `model` | `string` | - | The AI model to use (e.g., `'qwen-max'`, `'qwen-plus'`, `'qwen-turbo'`). Takes precedence over `OPENAI_MODEL` and `QWEN_MODEL` environment variables. | | `pathToQwenExecutable` | `string` | Auto-detected | Path to the Qwen Code executable. Supports multiple formats: `'qwen'` (native binary from PATH), `'/path/to/qwen'` (explicit path), `'/path/to/cli.js'` (Node.js bundle), `'node:/path/to/cli.js'` (force Node.js runtime), `'bun:/path/to/cli.js'` (force Bun runtime). If not provided, auto-detects from: `QWEN_CODE_CLI_PATH` env var, `~/.volta/bin/qwen`, `~/.npm-global/bin/qwen`, `/usr/local/bin/qwen`, `~/.local/bin/qwen`, `~/node_modules/.bin/qwen`, `~/.yarn/bin/qwen`. | -| `permissionMode` | `'default' \| 'plan' \| 'auto-edit' \| 'yolo'` | `'default'` | Permission mode controlling tool execution approval. See [Permission Modes](#permission-modes) for details. | +| `permissionMode` | `'default' \| 'plan' \| 'auto-edit' \| 'auto' \| 'yolo'` | `'default'` | Permission mode controlling tool execution approval. See [Permission Modes](#permission-modes) for details. | | `canUseTool` | `CanUseTool` | - | Custom permission handler for tool execution approval. Invoked when a tool requires confirmation. Must respond within 60 seconds or the request will be auto-denied. See [Custom Permission Handler](#custom-permission-handler). | | `env` | `Record` | - | Environment variables to pass to the Qwen Code process. Merged with the current process environment. | | `systemPrompt` | `string \| QuerySystemPromptPreset` | - | System prompt configuration for the main session. Use a string to fully override the built-in Qwen Code system prompt, or a preset object to keep the built-in prompt and append extra instructions. | @@ -256,6 +256,7 @@ The SDK supports different permission modes for controlling tool execution: - **`default`**: Write tools are denied unless approved via `canUseTool` callback or in `allowedTools`. Read-only tools execute without confirmation. - **`plan`**: Blocks all write tools, instructing AI to present a plan first. - **`auto-edit`**: Auto-approve edit tools (`edit`, `write_file`, `notebook_edit`) while other tools require confirmation. +- **`auto`**: Uses the built-in classifier to auto-approve safe tool calls and block risky ones, with manual-approval fallback after repeated policy blocks or classifier outages. - **`yolo`**: All tools execute automatically without confirmation. ### Permission Priority Chain @@ -269,8 +270,9 @@ The first matching rule wins. 3. `permissionMode: 'plan'` - Blocks all non-read-only tools 4. `permissionMode: 'yolo'` - Auto-approves all tools 5. `allowedTools` / `permissions.allow` - Auto-approves matching tools -6. `canUseTool` callback - Custom approval logic (if provided, not called for allowed tools) -7. Default behavior - Auto-deny in SDK mode (write tools require explicit approval) +6. `permissionMode: 'auto'` - Classifier-mediated approval for remaining tools +7. `canUseTool` callback - Custom approval logic (if provided, not called for allowed tools) +8. Default behavior - Auto-deny in SDK mode (write tools require explicit approval) ## Examples