@qoder-ai/qoder-agent-sdk 1.0.17 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,16 +23,10 @@ installed if your application uses SDK tools or MCP integration.
23
23
 
24
24
  ## Runtime Behavior
25
25
 
26
- The standard npm package keeps the existing process runtime behavior:
27
- `query()` launches `qodercli` as a child process by default. During
28
- `npm install`, the postinstall script downloads the platform-specific CLI into
29
- `dist/_bundled`.
30
-
31
- Packages built with the Worker runtime bundle bake that choice into the SDK:
32
- their default `query()` transport is `WorkerTransport.default`, and install
33
- does not download the process CLI unless `QODER_INSTALL_BUNDLED_CLI=1` is set.
34
- Worker runtime assets can either be packaged into the tarball or downloaded by
35
- postinstall, depending on the release pipeline.
26
+ The npm package uses `WorkerTransport.default` for `query()` by default. During
27
+ `npm install`, its postinstall script downloads the Worker runtime selected by
28
+ the package's pinned CLI version into `dist/_worker`. It does not download the
29
+ process CLI unless `QODER_INSTALL_BUNDLED_CLI=1` is set.
36
30
 
37
31
  You can still select a transport explicitly on the same `query()` entry:
38
32
 
@@ -52,17 +46,15 @@ const q = query({
52
46
  });
53
47
  ```
54
48
 
55
- When the package includes `dist/_worker/qoder-worker-runtime.obf.mjs`, the
56
- worker transport uses that embedded runtime; otherwise set
49
+ The worker transport uses the runtime installed at
50
+ `dist/_worker/qoder-worker-runtime.obf.mjs`. You can instead set
57
51
  `QODER_WORKER_RUNTIME_PATH` or pass
58
52
  `new WorkerTransport({ pathToQoderWorkerRuntime })`.
59
53
 
60
- Worker-bundled packages include a `dist/runtime-manifest.json` that records the
61
- default runtime and whether the Worker runtime is packaged or installed by
62
- postinstall. Install-delivered packages can also pin the qodercli Worker runtime
63
- archive URL in that manifest; the SDK package itself does not need to host a
64
- copy of the archive. The presence of `dist/_worker` is used as an integrity
65
- check after installation, not as the mode selector.
54
+ The package includes a `dist/runtime-manifest.json` that records the default
55
+ runtime and pins the qodercli Worker runtime archive URL. The SDK package itself
56
+ does not need to host a copy of the archive. The presence of `dist/_worker` is
57
+ used as an integrity check after installation, not as the mode selector.
66
58
 
67
59
  The packaged Worker runtime is built as a self-contained universal profile by
68
60
  default. Runtime assets such as native keychain bindings, PTY bindings, image
@@ -86,11 +78,16 @@ export QODERCLI_PATH=/absolute/path/to/qodercli
86
78
  export QODER_WORKER_RUNTIME_PATH=/absolute/path/to/qoder-worker-runtime.obf.mjs
87
79
  ```
88
80
 
89
- `query()` is the only query entry point. Standard packages default to process;
90
- Worker-bundled packages default to Worker. Pass `transport: ProcessTransport.default`,
81
+ `query()` is the only query entry point and defaults to Worker. Pass
82
+ `transport: ProcessTransport.default`,
91
83
  `transport: WorkerTransport.default`, or a custom transport provider when a
92
84
  single call needs to override the package default.
93
85
 
86
+ `pathToQoderCLIExecutable` accepts either local runtime form. Native binaries
87
+ and ordinary CLI `.js`/`.mjs` entries use the process transport; recognized
88
+ `qoder-worker-runtime*.mjs` entries use the Worker transport. An explicit
89
+ `transport` provider always takes precedence over automatic path selection.
90
+
94
91
  ## Authentication
95
92
 
96
93
  Every SDK query needs an explicit authentication option.
@@ -146,7 +143,7 @@ short-lived SATs for qodercli. See the
146
143
  [host callback example](examples/service-account-token-demo/demo.mjs) for a
147
144
  complete Token exchange and query. To reuse a signed-in developer
148
145
  workstation, use `qodercliAuth()`. See the
149
- [SDK authentication guide](docs/public/en/cli/sdk/authentication.mdx) for
146
+ [SDK authentication guide](docs/public/global/cli/sdk/authentication.mdx) for
150
147
  complete setup instructions and security guidance.
151
148
 
152
149
  ## Quick Start
package/dist/auth.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { AuthOptions, FetchJobToken, JobTokenAuthOptions, ServiceAccountAuthOptions, ServiceAccountCredentials } from './types/auth.js';
2
- export declare const DEFAULT_ACCESS_TOKEN_ENV_VAR = "QODER_PERSONAL_ACCESS_TOKEN";
3
- export declare const DEFAULT_SERVICE_ACCOUNT_ENV_VAR = "QODER_SERVICE_ACCOUNT_KEY";
2
+ export declare const DEFAULT_ACCESS_TOKEN_ENV_VAR: string;
3
+ export declare const DEFAULT_SERVICE_ACCOUNT_ENV_VAR: string;
4
4
  export declare function accessToken(token: string): AuthOptions;
5
5
  export declare function accessTokenFromEnv(envVar?: string): AuthOptions;
6
6
  export declare function qodercliAuth(): AuthOptions;
@@ -0,0 +1,22 @@
1
+ export type SdkBrand = 'global' | 'cn';
2
+ export declare const SDK_BRAND: SdkBrand;
3
+ export declare const IS_CN_SDK: boolean;
4
+ export declare const SDK_BRAND_CONFIG: {
5
+ productName: string;
6
+ packageName: string;
7
+ cliCommands: readonly ["qoderclicn", "qodercn"];
8
+ configDirName: string;
9
+ configDirEnv: string;
10
+ cliHomeEnv: string;
11
+ accessTokenEnv: string;
12
+ serviceAccountEnv: string;
13
+ } | {
14
+ productName: string;
15
+ packageName: string;
16
+ cliCommands: readonly ["qodercli", "qoder"];
17
+ configDirName: string;
18
+ configDirEnv: string;
19
+ cliHomeEnv: string;
20
+ accessTokenEnv: string;
21
+ serviceAccountEnv: string;
22
+ };
@@ -21,10 +21,7 @@ export declare const CLOSE_GRACE_MS = 2000;
21
21
  * If the process hasn't exited after SIGTERM within this window, force-kill it.
22
22
  */
23
23
  export declare const KILL_GRACE_MS = 5000;
24
- /**
25
- * Current SDK version, sent to CLI as QODER_AGENT_SDK_VERSION environment variable.
26
- */
27
- export declare const SDK_VERSION = "1.0.16";
24
+ export declare const SDK_VERSION: string;
28
25
  /**
29
26
  * Value for the `--permission-prompt-tool` CLI flag.
30
27
  *
@@ -44,10 +41,18 @@ export declare const CLI_EXIT_CODE_AUTH_ERROR = 41;
44
41
  *
45
42
  * Keep this list explicit so new qodercli built-ins do not automatically
46
43
  * become SDK-visible. Goal, cron, workflow, plan-mode transition, Bash PTY,
47
- * worktree, tracker, topic, and task-control tools remain opt-in via
44
+ * worktree, topic, and background-task control tools remain opt-in via
48
45
  * `options.tools`.
49
46
  */
50
- export declare const SDK_DEFAULT_TOOLS: readonly ["Agent", "AskUserQuestion", "Bash", "Edit", "Glob", "Grep", "ImageGen", "ImageSearch", "NotebookEdit", "Read", "Skill", "TodoWrite", "WebFetch", "WebSearch", "Write"];
47
+ export declare const SDK_DEFAULT_TOOLS: readonly ["Agent", "AskUserQuestion", "Bash", "Edit", "Glob", "Grep", "ImageGen", "ImageSearch", "NotebookEdit", "Read", "Skill", "TaskCreate", "TaskGet", "TaskUpdate", "TaskList", "WebFetch", "WebSearch", "Write"];
48
+ export declare const SDK_TASK_TOOLS: readonly ["TaskCreate", "TaskGet", "TaskUpdate", "TaskList"];
49
+ /**
50
+ * Resolve the SDK's curated default tool surface against qodercli's Task
51
+ * feature flag. qodercli replaces the persistent Task tools with TodoWrite
52
+ * when QODER_FEATURE_TASKS is explicitly disabled, so the SDK must make the
53
+ * same replacement before it writes its explicit --tools allowlist.
54
+ */
55
+ export declare function resolveSdkDefaultTools(env: Record<string, string | undefined>): string[];
51
56
  /**
52
57
  * Tool names with SDK-side enrichment. Tracked as constants so callers and
53
58
  * the runner agree on the exact string the CLI emits.
@@ -32,4 +32,12 @@ export declare class ProtocolVersionMismatchError extends Error {
32
32
  readonly cliProtocolVersion: string;
33
33
  readonly sdkProtocolVersion: string;
34
34
  constructor(cliProtocolVersion: string, sdkProtocolVersion: string);
35
+ }
36
+ /**
37
+ * Thrown when an SDK operation requires a protocol capability that the
38
+ * running qodercli process did not advertise in its system/init message.
39
+ */
40
+ export declare class UnsupportedCliCapabilityError extends Error {
41
+ readonly capability: string;
42
+ constructor(capability: string);
35
43
  }
@@ -61,6 +61,7 @@ export interface RuntimeLaunchConfig {
61
61
  }
62
62
  export declare function isScriptFile(filePath: string): boolean;
63
63
  export declare function resolveDefaultCliPath(): string;
64
+ export declare function resolveUserInstalledCliPath(): string | null;
64
65
  export declare class RuntimeLaunchOptionsBuilder {
65
66
  private readonly options;
66
67
  private readonly diagnostics?;
@@ -0,0 +1,24 @@
1
+ import type { DefaultRuntimeTransport } from './default-runtime.js';
2
+ export interface ImplicitRuntimeOptions {
3
+ pathToQoderCLIExecutable?: string;
4
+ executable?: string;
5
+ executableArgs?: readonly string[];
6
+ spawnQoderCLIProcess?: unknown;
7
+ }
8
+ export type ImplicitRuntimeSelection = {
9
+ transport: 'process';
10
+ } | {
11
+ transport: 'worker';
12
+ pathToQoderWorkerRuntime?: string;
13
+ };
14
+ /**
15
+ * Distinguish a Qoder Worker entry from a CLI native binary or script entry.
16
+ * Unrecognized JavaScript paths remain process CLI entries for compatibility.
17
+ */
18
+ export declare function isQoderWorkerRuntimePath(candidate: string): boolean;
19
+ /**
20
+ * Select the local runtime when the caller has not supplied an explicit
21
+ * transport provider. Explicit paths and process-only launch options override
22
+ * the transport baked into the SDK package.
23
+ */
24
+ export declare function resolveImplicitRuntimeSelection(options: ImplicitRuntimeOptions, packageDefault: DefaultRuntimeTransport, environment?: NodeJS.ProcessEnv): ImplicitRuntimeSelection;
package/dist/index.d.ts CHANGED
@@ -70,7 +70,7 @@ export { listPlugins, enablePlugin, disablePlugin, installPlugin, uninstallPlugi
70
70
  export type { PluginDetails, PluginResources, InstallPluginResult, UninstallPluginResult } from './types/plugins.js';
71
71
  export { submitFeedback } from './feedback.js';
72
72
  export type { SubmitFeedbackParams, SubmitFeedbackOptions, IntegrationMode, } from './feedback.js';
73
- export { AbortError, ModelPolicyTimeoutError, ProtocolVersionMismatchError, } from './core/errors.js';
73
+ export { AbortError, ModelPolicyTimeoutError, ProtocolVersionMismatchError, UnsupportedCliCapabilityError, } from './core/errors.js';
74
74
  export { AuthAccessTokenEnvVarError, AuthServiceAccountEnvVarError, } from './core/runtime-launch-options.js';
75
75
  export { WIRE_PROTOCOL_VERSION } from './protocol/version.js';
76
76
  export type { ModelPromptPatch, ModelPromptPatches, } from './protocol/model-prompt-patches.js';
@@ -83,7 +83,7 @@ export type { AccessTokenInput, AuthOptions, FetchServiceAccountToken, ServiceAc
83
83
  */
84
84
  export type { FetchJobToken, JobTokenAuthOptions, JobTokenRequest, JobTokenResult, } from './types/auth.js';
85
85
  export type { AccountInfo, UsageAddOnQuotaBucket, UsageInfo, UsageOrgResourcePackage, UsageQuotaBucket, SessionCreditsUsage, ApiKeySource, ExitReason, FastModeState, ConfigScope, SettingSource, SDKAssistantMessageError, SDKStatus, EffortLevel, ThinkingAdaptive, ThinkingEnabled, ThinkingDisabled, ThinkingConfig, ModelInfo, ModelSource, ServerModelJson, ServerModelJsonValue, ModelStrategy, ModelPromotion, LocalizedModelText, ModelContextConfig, ModelContextWindowEntry, ModelEffortEntry, ModelThinkingConfig, ModelThinkingDisabled, ModelThinkingEnabled, ModelUsage, NonNullableUsage, SlashCommand, ToolConfig, SdkPluginConfig, } from './types/common.js';
86
- export type { SDKMessage, SDKAssistantMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultMessage, SDKResultSuccess, SDKResultError, SDKSystemMessage, SDKSystemInitMessage, SDKSystemMessageSubtype, SDKSystemMessageBySubtype, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKMirrorErrorMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, } from './types/messages.js';
86
+ export type { SDKMessage, SDKAssistantMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultMessage, SDKResultSuccess, SDKResultError, SDKSystemMessage, SDKSystemInitMessage, SDKSystemMessageSubtype, SDKSystemMessageBySubtype, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKMirrorErrorMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, } from './types/messages.js';
87
87
  export type { DefaultRuntimeTransport, } from './core/default-runtime.js';
88
88
  export type { QueryTransportCreateOptions, QueryTransportProviderOption, } from './core/query-transport.js';
89
89
  export type { ProcessTransportOptions } from './core/process-transport.js';
@@ -95,13 +95,13 @@ export type { SettingSource as SettingSourceFromOptions } from './types/options.
95
95
  export type { PermissionMode, PermissionBehavior, PermissionDecisionClassification, PermissionUpdateDestination, PermissionRuleValue, PermissionUpdate, PermissionResult, CanUseToolOptions, } from './types/permissions.js';
96
96
  export type { HookEvent, HookPermissionDecision, HookCallback, HookCallbackMatcher, HookInput, HookSpecificOutput, HookJSONOutput, AsyncHookJSONOutput, SyncHookJSONOutput, BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, SessionStartHookInput, SessionEndHookInput, StopHookInput, SubagentStartHookInput, SubagentStopHookInput, PreCompactHookInput, PostCompactHookInput, PermissionRequestHookInput, InstructionsLoadedHookInput, CwdChangedHookInput, FileChangedHookInput, PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, SessionStartHookSpecificOutput, SubagentStartHookSpecificOutput, PermissionRequestHookSpecificOutput, CwdChangedHookSpecificOutput, FileChangedHookSpecificOutput, } from './types/hooks.js';
97
97
  export type { McpStdioServerConfig, McpSSEServerConfig, McpHttpServerConfig, McpSdkServerConfig, McpSdkServerConfigWithInstance, McpServerConfig, McpServerToolPolicy, McpServerConfigForProcessTransport, McpServerStatus, McpServerStatusConfig, } from './types/mcp.js';
98
- export type { AgentDefinition, AgentInfo, AgentMcpServerSpec, } from './types/agents.js';
99
- export type { SDKSessionInfo, SessionMessage, ListSessionsOptions, GetSessionInfoOptions, GetSessionMessagesOptions, GetSubagentMessagesOptions, ListSubagentsOptions, SessionMutationOptions, ForkSessionOptions, ForkSessionResult, RewindFilesResult, } from './types/session.js';
98
+ export type { AgentDefinition, AgentInfo, AgentMemoryScope, AgentMcpServerSpec, } from './types/agents.js';
99
+ export type { SDKSessionInfo, SessionMessage, ListSessionsOptions, GetSessionInfoOptions, GetSessionMessagesOptions, GetSubagentMessagesOptions, ListSubagentsOptions, SessionMutationOptions, ForkSessionOptions, ForkSessionResult, RewindFilesResult, RewindScope, RewindStatus, RewindFileFailure, RewindResult, } from './types/session.js';
100
100
  export type { Settings, ResolvedSettings, ResolvedSettingsSource, } from './types/settings.js';
101
101
  export { filterEscalatingDefaultMode } from './types/settings.js';
102
102
  export type { QoderModelPurpose } from './types/control.js';
103
- export type { SDKControlRequest, SDKControlResponse, SDKControlInterruptResponse, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlGetUsageInfoRequest, SDKControlGetUsageInfoResponse, SDKControlAddDirectoriesResponse, SDKControlReloadPluginsResponse, } from './types/control.js';
103
+ export type { SDKControlRequest, SDKControlResponse, SDKControlInterruptResponse, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlGetUsageInfoRequest, SDKControlGetUsageInfoResponse, SDKControlAddDirectoriesResponse, SDKControlReloadPluginsResponse, SDKControlStopTaskRequest, SDKControlBackgroundTasksRequest, SDKControlBackgroundTasksResponse, } from './types/control.js';
104
104
  export type { SDKControlGetModelPolicyRequest, SDKControlGetModelPolicyResponse, SDKCapabilities, ModelPolicyContext, ModelPolicyResult, ModelPolicyProvider, } from './types/model-policy-provider.js';
105
105
  export type { SDKControlGetByokConfigRequest, SDKControlGetByokConfigResponse, SDKControlValidateByokModelRequest, SDKControlValidateByokModelResponse, BYOKModelValidationInput, BYOKProviderInfo, BYOKModelTypeInfo, BYOKModelInfo, CustomModel, } from './types/byok.js';
106
- export type { AgentInput, AgentOutput, BashInput, FileReadInput, FileReadOutput, FileEditInput, FileWriteInput, GlobInput, GrepInput, WebFetchInput, WebSearchInput, AskUserQuestionInput, NotebookEditInput, ExitPlanModeInput, TodoWriteInput, ToolInputSchemas, ToolOutputSchemas, } from './types/tools.js';
106
+ export type { AgentInput, AgentOutput, AgentToolCompletionResult, AgentToolBackgroundLaunchResult, AgentToolTeammateSpawnedResult, BashInput, FileReadInput, FileReadOutput, FileEditInput, FileWriteInput, GlobInput, GrepInput, WebFetchInput, WebSearchInput, AskUserQuestionInput, NotebookEditInput, TaskCreateInput, TaskCreateOutput, TaskGetInput, TaskGetOutput, TaskUpdateInput, TaskUpdateOutput, TaskListInput, TaskListOutput, ExitPlanModeInput, TodoWriteInput, ToolInputSchemas, ToolOutputSchemas, } from './types/tools.js';
107
107
  export type { FeedbackResult } from './types/account.js';