mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
chore: rename @qwen-code/sdk-typescript to @qwen-code/sdk
This commit is contained in:
parent
0e9255b122
commit
96d458fa8c
20 changed files with 31 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# @qwen-code/sdk-typescript
|
||||
# @qwen-code/sdk
|
||||
|
||||
A minimum experimental TypeScript SDK for programmatic access to Qwen Code.
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ Feel free to submit a feature request/issue/PR.
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @qwen-code/sdk-typescript
|
||||
npm install @qwen-code/sdk
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
|
@ -20,7 +20,7 @@ npm install @qwen-code/sdk-typescript
|
|||
## Quick Start
|
||||
|
||||
```typescript
|
||||
import { query } from '@qwen-code/sdk-typescript';
|
||||
import { query } from '@qwen-code/sdk';
|
||||
|
||||
// Single-turn query
|
||||
const result = query({
|
||||
|
|
@ -107,7 +107,7 @@ import {
|
|||
isSDKSystemMessage,
|
||||
isSDKResultMessage,
|
||||
isSDKPartialAssistantMessage,
|
||||
} from '@qwen-code/sdk-typescript';
|
||||
} from '@qwen-code/sdk';
|
||||
|
||||
for await (const message of result) {
|
||||
if (isSDKAssistantMessage(message)) {
|
||||
|
|
@ -167,7 +167,7 @@ The SDK supports different permission modes for controlling tool execution:
|
|||
### Multi-turn Conversation
|
||||
|
||||
```typescript
|
||||
import { query, type SDKUserMessage } from '@qwen-code/sdk-typescript';
|
||||
import { query, type SDKUserMessage } from '@qwen-code/sdk';
|
||||
|
||||
async function* generateMessages(): AsyncIterable<SDKUserMessage> {
|
||||
yield {
|
||||
|
|
@ -201,7 +201,7 @@ for await (const message of result) {
|
|||
### Custom Permission Handler
|
||||
|
||||
```typescript
|
||||
import { query, type CanUseTool } from '@qwen-code/sdk-typescript';
|
||||
import { query, type CanUseTool } from '@qwen-code/sdk';
|
||||
|
||||
const canUseTool: CanUseTool = async (toolName, input, { signal }) => {
|
||||
// Allow all read operations
|
||||
|
|
@ -230,7 +230,7 @@ const result = query({
|
|||
### With External MCP Servers
|
||||
|
||||
```typescript
|
||||
import { query } from '@qwen-code/sdk-typescript';
|
||||
import { query } from '@qwen-code/sdk';
|
||||
|
||||
const result = query({
|
||||
prompt: 'Use the custom tool from my MCP server',
|
||||
|
|
@ -290,7 +290,7 @@ Returns a `McpSdkServerConfigWithInstance` object that can be passed directly to
|
|||
|
||||
```typescript
|
||||
import { z } from 'zod';
|
||||
import { query, tool, createSdkMcpServer } from '@qwen-code/sdk-typescript';
|
||||
import { query, tool, createSdkMcpServer } from '@qwen-code/sdk';
|
||||
|
||||
// Define a tool with Zod schema
|
||||
const calculatorTool = tool(
|
||||
|
|
@ -327,7 +327,7 @@ for await (const message of result) {
|
|||
### Abort a Query
|
||||
|
||||
```typescript
|
||||
import { query, isAbortError } from '@qwen-code/sdk-typescript';
|
||||
import { query, isAbortError } from '@qwen-code/sdk';
|
||||
|
||||
const abortController = new AbortController();
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ try {
|
|||
The SDK provides an `AbortError` class for handling aborted queries:
|
||||
|
||||
```typescript
|
||||
import { AbortError, isAbortError } from '@qwen-code/sdk-typescript';
|
||||
import { AbortError, isAbortError } from '@qwen-code/sdk';
|
||||
|
||||
try {
|
||||
// ... query operations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue