Skip to content

Commit 7d50f53

Browse files
authored
Merge pull request #1726 from QwenLM/mingholy/fix/sdk-resume-usage
feat(sdk): add resume, continue options and extend authType support
2 parents 03b2cfb + 675a8fd commit 7d50f53

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎packages/sdk-typescript/src/transport/ProcessTransport.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ export class ProcessTransport implements Transport {
263263

264264
if (this.options.resume) {
265265
args.push('--resume', this.options.resume);
266+
} else if (this.options.continue) {
267+
args.push('--continue');
266268
}
267269

268270
return args;

‎packages/sdk-typescript/src/types/protocol.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,17 @@ export interface SDKPartialAssistantMessage {
232232

233233
export type PermissionMode = 'default' | 'plan' | 'auto-edit' | 'yolo';
234234

235+
/**
236+
* Authentication types supported by the CLI.
237+
* Aligns with CLI's --auth-type parameter.
238+
*/
239+
export type AuthType =
240+
| 'openai'
241+
| 'anthropic'
242+
| 'qwen-oauth'
243+
| 'gemini'
244+
| 'vertex-ai';
245+
235246
/**
236247
* TODO: Align with `ToolCallConfirmationDetails`
237248
*/

‎packages/sdk-typescript/src/types/queryOptionsSchema.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ export const QueryOptionsSchema = z
148148
coreTools: z.array(z.string()).optional(),
149149
excludeTools: z.array(z.string()).optional(),
150150
allowedTools: z.array(z.string()).optional(),
151-
authType: z.enum(['openai', 'qwen-oauth']).optional(),
151+
authType: z
152+
.enum(['openai', 'anthropic', 'qwen-oauth', 'gemini', 'vertex-ai'])
153+
.optional(),
152154
agents: z
153155
.array(
154156
z.custom<SubagentConfig>(

‎packages/sdk-typescript/src/types/types.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import type {
33
PermissionSuggestion,
44
SubagentConfig,
55
SDKMcpServerConfig,
6+
AuthType,
67
} from './protocol.js';
78
import type { SpawnInfo } from '../utils/cliPath.js';
89

9-
export type { PermissionMode };
10+
export type { PermissionMode, AuthType };
1011

1112
export type TransportOptions = {
1213
pathToQwenExecutable?: string;
@@ -23,8 +24,19 @@ export type TransportOptions = {
2324
coreTools?: string[];
2425
excludeTools?: string[];
2526
allowedTools?: string[];
26-
authType?: string;
27+
authType?: AuthType;
2728
includePartialMessages?: boolean;
29+
/**
30+
* Resume the most recent session for the current project.
31+
* Equivalent to CLI's --continue flag.
32+
* @default false
33+
*/
34+
continue?: boolean;
35+
/**
36+
* Resume a specific session by its ID.
37+
* Equivalent to CLI's --resume flag.
38+
* When provided, takes precedence over `continue`.
39+
*/
2840
resume?: string;
2941
};
3042

@@ -385,7 +397,7 @@ export interface QueryOptions {
385397
* Though we support 'qwen-oauth', it's not recommended to use it in the SDK.
386398
* Because the credentials are stored in `~/.qwen` and may need to refresh periodically.
387399
*/
388-
authType?: 'openai' | 'qwen-oauth';
400+
authType?: AuthType;
389401

390402
/**
391403
* Configuration for subagents that can be invoked during the session.

0 commit comments

Comments
 (0)