@qoder-ai/qoder-agent-sdk 1.0.23 → 1.0.25
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 +24 -0
- package/dist/core/brand.d.ts +10 -0
- package/dist/core/constants.d.ts +5 -4
- package/dist/core/process-transport.d.ts +7 -1
- package/dist/core/runtime-command.d.ts +14 -0
- package/dist/core/runtime-launch-options.d.ts +4 -1
- package/dist/core/security-scan-options.d.ts +7 -0
- package/dist/core/worker-runtime-launch.d.ts +16 -0
- package/dist/core/worker-runtime-path.d.ts +2 -0
- package/dist/core/worker-transport.d.ts +3 -3
- package/dist/global/plugins.d.ts +3 -9
- package/dist/index.d.ts +5 -4
- package/dist/index.js +30 -30
- package/dist/memory/memory-options.d.ts +7 -0
- package/dist/protocol/control.d.ts +95 -1
- package/dist/protocol/index.d.ts +3 -2
- package/dist/protocol/index.js +1 -1
- package/dist/protocol/launch.d.ts +4 -0
- package/dist/protocol/memory.d.ts +137 -0
- package/dist/protocol/messages.d.ts +70 -1
- package/dist/query/query-runner.d.ts +39 -2
- package/dist/runtime-manifest.json +5 -5
- package/dist/types/control.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/memory.d.ts +74 -0
- package/dist/types/messages.d.ts +2 -1
- package/dist/types/options.d.ts +75 -1
- package/dist/types/plugins.d.ts +12 -0
- package/dist/types/session.d.ts +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { MemoryConsumptionFile, MemoryConsumptionResult, MemoryGenerationGateInput, MemoryGenerationGateResult, MemoryGenerationResult, MemoryRoot } from '../protocol/memory.js';
|
|
2
|
+
export type { EffectiveMemoryConfig, MemoryConsumptionFile, MemoryConsumptionResult, MemoryGenerationGateInput, MemoryGenerationGateResult, MemoryGenerationResult, MemoryGenerationFailedFile, MemoryMode, MemoryRoot, MemoryRootAccess, SerializableMemoryConfig, SerializableMemoryConsumptionOptions, SerializableMemoryGenerationOptions, } from '../protocol/memory.js';
|
|
3
|
+
/** Product-side decision invoked before TurnComplete memory generation starts. */
|
|
4
|
+
export type MemoryShouldGenerate = (input: MemoryGenerationGateInput, options: {
|
|
5
|
+
signal: AbortSignal;
|
|
6
|
+
}) => Promise<MemoryGenerationGateResult>;
|
|
7
|
+
export type MemoryGenerationOptions = {
|
|
8
|
+
/** Enables automatic and active memory generation. Defaults to true. */
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
/** Memory directories available to the main agent and background memory agent. CLI defaults are used when omitted. */
|
|
11
|
+
roots?: MemoryRoot[];
|
|
12
|
+
/** Generation instructions. The CLI-owned default prompt is used when omitted. */
|
|
13
|
+
prompt?: string;
|
|
14
|
+
/** Controls generation started from the real CLI TurnComplete event. */
|
|
15
|
+
turnComplete?: {
|
|
16
|
+
/** Defaults to true when generation is enabled. */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
/** Product-side gate called before the background memory agent starts. Omit to use only CLI built-in guards. */
|
|
19
|
+
shouldGenerate?: MemoryShouldGenerate;
|
|
20
|
+
/** Maximum time allowed for shouldGenerate. The CLI default is 10 seconds. */
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
/** Whether callback errors/timeouts produce a skipped or failed generation result. Defaults to "skip". */
|
|
23
|
+
onGateError?: 'skip' | 'report_failed';
|
|
24
|
+
};
|
|
25
|
+
/** Called for every completed generation attempt, including saved, partial, no-change, skipped, and failed outcomes. */
|
|
26
|
+
onResult?: (result: MemoryGenerationResult) => void | Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
export type MemoryConsumptionOptions = {
|
|
29
|
+
/** Enables memory consumption. Defaults to true. */
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
/** Explicit files to inject in array order. They replace CLI native auto-memory; static instructions remain. CLI native auto-memory is used when omitted. */
|
|
32
|
+
files?: MemoryConsumptionFile[];
|
|
33
|
+
/** Shared token budget for all explicit files. Omit for no explicit SDK budget. */
|
|
34
|
+
maxTokens?: number;
|
|
35
|
+
/** Behavior when explicit file content exceeds maxTokens. Defaults to "truncate". */
|
|
36
|
+
overflow?: 'truncate' | 'fail_query';
|
|
37
|
+
/** Read-failure behavior. Only required files fail the query in "fail_query" mode. Defaults to "best_effort". */
|
|
38
|
+
failureMode?: 'best_effort' | 'fail_query';
|
|
39
|
+
/** Receives per-file load status after initialization and explicit refreshes. */
|
|
40
|
+
onResult?: (result: MemoryConsumptionResult) => void | Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
export type MemoryOptions = {
|
|
43
|
+
/** An empty object disables SDK memory, equivalent to omitting options.memory. */
|
|
44
|
+
mode?: never;
|
|
45
|
+
projectScope?: never;
|
|
46
|
+
userScope?: never;
|
|
47
|
+
generation?: never;
|
|
48
|
+
consumption?: never;
|
|
49
|
+
} | {
|
|
50
|
+
/** Uses CLI-native generation and consumption; only scope switches and result callbacks are configurable. */
|
|
51
|
+
mode: 'native';
|
|
52
|
+
/** Enables or disables the CLI PROJECT scope for this Query. Defaults to `true`. */
|
|
53
|
+
projectScope?: boolean;
|
|
54
|
+
/** Enables or disables the CLI USER scope for this Query. Defaults to `true`. */
|
|
55
|
+
userScope?: boolean;
|
|
56
|
+
generation?: Pick<MemoryGenerationOptions, 'onResult'>;
|
|
57
|
+
consumption?: Pick<MemoryConsumptionOptions, 'onResult'>;
|
|
58
|
+
} | {
|
|
59
|
+
/** Applies supplied overrides and inherits omitted behavior from the CLI. */
|
|
60
|
+
mode: 'custom';
|
|
61
|
+
/** Enables or disables the CLI PROJECT scope for inherited native behavior. Defaults to `true`. */
|
|
62
|
+
projectScope?: boolean;
|
|
63
|
+
/** Enables or disables the CLI USER scope for inherited native behavior. Defaults to `true`. */
|
|
64
|
+
userScope?: boolean;
|
|
65
|
+
/** Memory generation overrides. Omit to use CLI generation defaults. */
|
|
66
|
+
generation?: MemoryGenerationOptions;
|
|
67
|
+
/** Memory consumption overrides. Omit to use CLI consumption defaults. */
|
|
68
|
+
consumption?: MemoryConsumptionOptions;
|
|
69
|
+
};
|
|
70
|
+
export type MemoryRuntimeCallbacks = {
|
|
71
|
+
shouldGenerateCallbacks: ReadonlyMap<string, MemoryShouldGenerate>;
|
|
72
|
+
onGenerationResult?: MemoryGenerationOptions['onResult'];
|
|
73
|
+
onConsumptionResult?: MemoryConsumptionOptions['onResult'];
|
|
74
|
+
};
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -9,11 +9,12 @@ import type { SDKMessage as ProtocolSDKMessage, SDKStatusMessage as ProtocolSDKS
|
|
|
9
9
|
import type { MessageParam, UUID } from './common.js';
|
|
10
10
|
import type { PermissionMode } from './permissions.js';
|
|
11
11
|
import type { SessionKey } from '../session/session-store.js';
|
|
12
|
-
export type { SDKAssistantMessage, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKAPIRetryMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, SDKToolNonExecutionKind, SDKToolResultMeta, } from '../protocol/index.js';
|
|
12
|
+
export type { SDKAssistantMessage, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKAPIRetryMessage, SDKModelQueueStatusMessage, SDKControlRequestProgressMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKMemoryGenerationMessage, SDKMemoryConsumptionMessage, SDKPermissionDenial, SDKToolNonExecutionKind, SDKToolResultMeta, } from '../protocol/index.js';
|
|
13
13
|
export type SDKUserMessage = {
|
|
14
14
|
type: 'user';
|
|
15
15
|
message: MessageParam;
|
|
16
16
|
parent_tool_use_id: string | null;
|
|
17
|
+
custom_context?: Record<string, string>;
|
|
17
18
|
isSynthetic?: boolean;
|
|
18
19
|
tool_use_result?: unknown;
|
|
19
20
|
/** CLI-stamped display metadata for tool results that did not execute. */
|
package/dist/types/options.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { HookCallbackMatcher, HookEvent } from './hooks.js';
|
|
|
8
8
|
import type { McpServerConfig, McpServerStatus, McpSetServersResult, OAuthToken } from './mcp.js';
|
|
9
9
|
import type { SDKMessage, SDKUserMessage } from './messages.js';
|
|
10
10
|
import type { Settings } from './settings.js';
|
|
11
|
-
import type { SDKControlInterruptResponse, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlGenerateSessionTitleResponse, SDKControlAddDirectoriesResponse, SDKControlReloadPluginsResponse, StdoutMessage } from './control.js';
|
|
11
|
+
import type { SDKControlInterruptResponse, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlGenerateSessionTitleResponse, AskSideQuestionOptions, SideQuestionResult, SDKControlAddDirectoriesResponse, SDKControlReloadPluginsResponse, StdoutMessage } from './control.js';
|
|
12
12
|
import type { ModelPolicyProvider } from './model-policy-provider.js';
|
|
13
13
|
import type { BYOKModelValidationInput, BYOKProviderInfo } from './byok.js';
|
|
14
14
|
import type { RewindFilesResult, RewindResult, RewindScope } from './session.js';
|
|
@@ -17,6 +17,8 @@ import type { QueryTransportProviderOption } from '../core/query-transport.js';
|
|
|
17
17
|
import type { PluginDetails } from './plugins.js';
|
|
18
18
|
import type { SessionStore, SessionStoreFlush } from '../session/session-store.js';
|
|
19
19
|
import type { ModelPromptPatches } from '../protocol/model-prompt-patches.js';
|
|
20
|
+
import type { MemoryOptions } from './memory.js';
|
|
21
|
+
import type { SDKGoalSnapshot, SDKGoalStatus } from '../protocol/control.js';
|
|
20
22
|
export type { CanUseTool };
|
|
21
23
|
export type { AuthOptions };
|
|
22
24
|
export type ElicitationRequest = {
|
|
@@ -50,6 +52,15 @@ export type PromptResponse = {
|
|
|
50
52
|
};
|
|
51
53
|
export type SettingSource = 'user' | 'project' | 'local';
|
|
52
54
|
export type QueryTransportOptions = QueryTransportProviderOption;
|
|
55
|
+
/** Built-in code security capabilities. All switches default to false. */
|
|
56
|
+
export type SecurityScanOptions = {
|
|
57
|
+
/** Run the static security check after supported file edits. */
|
|
58
|
+
l1StaticCheck?: boolean;
|
|
59
|
+
/** Allow lightweight repository security scans. */
|
|
60
|
+
l2LightweightScan?: boolean;
|
|
61
|
+
/** Allow deep repository security scans. */
|
|
62
|
+
l3DeepScan?: boolean;
|
|
63
|
+
};
|
|
53
64
|
export type Options = {
|
|
54
65
|
/**
|
|
55
66
|
* Optional controller for defining when the host ends the session. Calling
|
|
@@ -80,6 +91,18 @@ export type Options = {
|
|
|
80
91
|
*/
|
|
81
92
|
auth?: InternalAuthOptions;
|
|
82
93
|
additionalDirectories?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* Opaque business identifiers forwarded to every local qodercli inference
|
|
96
|
+
* request unless a user message supplies its own `custom_context`.
|
|
97
|
+
*
|
|
98
|
+
* Backend-enforced limits are 1–8 string entries, keys up to 32 Unicode code
|
|
99
|
+
* points, values up to 128 Unicode code points, and at most 1024 UTF-8 bytes
|
|
100
|
+
* for the serialized JSON object. Do not include tokens, Service Account
|
|
101
|
+
* keys, email addresses, phone numbers, other credentials, or sensitive
|
|
102
|
+
* personal data. Backend acceptance requires Service Account authentication
|
|
103
|
+
* and a qoder VPC deployment.
|
|
104
|
+
*/
|
|
105
|
+
customContext?: Record<string, string>;
|
|
83
106
|
/**
|
|
84
107
|
* @experimental
|
|
85
108
|
* @unstable Cloud Agent runtime is experimental and may change without
|
|
@@ -132,6 +155,22 @@ export type Options = {
|
|
|
132
155
|
* environment.
|
|
133
156
|
*/
|
|
134
157
|
proxy?: string;
|
|
158
|
+
/**
|
|
159
|
+
* VPC private-deployment endpoint for the qodercli child process (CN
|
|
160
|
+
* deployments only).
|
|
161
|
+
*
|
|
162
|
+
* Accepts either a bare instance name (`acme`) or a full VPC domain
|
|
163
|
+
* (`acme.vpc.qoder.com.cn`, `acme-gateway.vpc.qoder.com.cn`,
|
|
164
|
+
* `acme-openapi.vpc.qoder.com.cn`). When set, the SDK writes this value to
|
|
165
|
+
* the `QODERCN_VPC_ENDPOINT` (CN) / `QODER_VPC_ENDPOINT` (Global)
|
|
166
|
+
* environment variable, which the CLI reads at highest priority — above any
|
|
167
|
+
* `vpcInstanceName` in `settings.json` — to derive its inference, OpenAPI,
|
|
168
|
+
* and base endpoints locally without remote endpoint election.
|
|
169
|
+
*
|
|
170
|
+
* VPC mode only activates in CN builds of the CLI; the value is ignored by
|
|
171
|
+
* Global builds.
|
|
172
|
+
*/
|
|
173
|
+
vpcEndpoint?: string;
|
|
135
174
|
env?: {
|
|
136
175
|
[envVar: string]: string | undefined;
|
|
137
176
|
};
|
|
@@ -161,6 +200,11 @@ export type Options = {
|
|
|
161
200
|
*/
|
|
162
201
|
resumeDropsTurn?: string;
|
|
163
202
|
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
203
|
+
/**
|
|
204
|
+
* Configure QoderCLI-owned memory generation and consumption for this query.
|
|
205
|
+
* Functions stay in the SDK process and are bridged through control requests.
|
|
206
|
+
*/
|
|
207
|
+
memory?: MemoryOptions;
|
|
164
208
|
onElicitation?: OnElicitation;
|
|
165
209
|
/**
|
|
166
210
|
* Called when the SDK detects that authentication has expired or
|
|
@@ -226,6 +270,11 @@ export type Options = {
|
|
|
226
270
|
loadTimeoutMs?: number;
|
|
227
271
|
sessionId?: string;
|
|
228
272
|
settings?: string | Settings;
|
|
273
|
+
/**
|
|
274
|
+
* Enables built-in code security capabilities for this SDK session.
|
|
275
|
+
* Omitted switches are disabled. This option is authoritative when provided.
|
|
276
|
+
*/
|
|
277
|
+
securityScan?: SecurityScanOptions;
|
|
229
278
|
settingSources?: SettingSource[];
|
|
230
279
|
stderr?: (data: string) => void;
|
|
231
280
|
strictMcpConfig?: boolean;
|
|
@@ -338,6 +387,22 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
|
338
387
|
* eligible foreground executions are targeted.
|
|
339
388
|
*/
|
|
340
389
|
backgroundTasks(toolUseId?: string): Promise<boolean>;
|
|
390
|
+
/**
|
|
391
|
+
* Create, redirect, transition, or re-budget the session goal. Omitted
|
|
392
|
+
* fields are left unchanged; `creditsBudget: null` explicitly clears the
|
|
393
|
+
* budget. Setting `status: 'active'` while the session is idle starts the
|
|
394
|
+
* goal loop. Requires the CLI `goal_v1` capability. Only present on the
|
|
395
|
+
* local CLI transport; absent on cloud-agent queries.
|
|
396
|
+
*/
|
|
397
|
+
setGoal?(params: {
|
|
398
|
+
objective?: string;
|
|
399
|
+
status?: SDKGoalStatus;
|
|
400
|
+
creditsBudget?: number | null;
|
|
401
|
+
}): Promise<SDKGoalSnapshot | null>;
|
|
402
|
+
/** Read the current goal, or null when the session has none. */
|
|
403
|
+
getGoal?(): Promise<SDKGoalSnapshot | null>;
|
|
404
|
+
/** Clear the session goal; returns whether a goal was cleared. */
|
|
405
|
+
clearGoal?(): Promise<boolean>;
|
|
341
406
|
setPermissionMode(mode: PermissionMode): Promise<void>;
|
|
342
407
|
setModel(model?: string): Promise<void>;
|
|
343
408
|
/**
|
|
@@ -358,6 +423,11 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
|
358
423
|
generateSessionTitle(description: string, options?: {
|
|
359
424
|
persist?: boolean;
|
|
360
425
|
}): Promise<SDKControlGenerateSessionTitleResponse['title']>;
|
|
426
|
+
/**
|
|
427
|
+
* Ask a one-off question using the current conversation context without
|
|
428
|
+
* interrupting or mutating the main agent turn.
|
|
429
|
+
*/
|
|
430
|
+
askSideQuestion?(question: string, options?: AskSideQuestionOptions): Promise<SideQuestionResult | null>;
|
|
361
431
|
/**
|
|
362
432
|
* Add directories to the running session's workspace context.
|
|
363
433
|
*
|
|
@@ -417,6 +487,10 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
|
417
487
|
dryRun?: boolean;
|
|
418
488
|
}): Promise<RewindResult>;
|
|
419
489
|
seedReadState(path: string, mtime: number): Promise<void>;
|
|
490
|
+
/** Wait until pending TurnComplete memory generation has finished. */
|
|
491
|
+
flushMemory(): Promise<void>;
|
|
492
|
+
/** Reload configured memory consumption files without changing config. */
|
|
493
|
+
refreshMemory(): Promise<void>;
|
|
420
494
|
/**
|
|
421
495
|
* 主动驱动 MCP OAuth:拉起 OAuth 流程,返回授权 URL 让 host 引导用户跳转。
|
|
422
496
|
*
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { PluginInfo } from '../protocol/common.js';
|
|
2
|
+
/** Plugin installation scopes that can be changed through the CLI. */
|
|
3
|
+
export type PluginScope = 'user' | 'project' | 'local';
|
|
4
|
+
export type PluginToggleOptions = {
|
|
5
|
+
/** Directory used to resolve project and local plugin state. */
|
|
6
|
+
cwd?: string;
|
|
7
|
+
/** Omit to let qodercli infer the installed plugin's scope. */
|
|
8
|
+
scope?: PluginScope;
|
|
9
|
+
/** Optional qodercli executable or qoder Worker runtime entry override. */
|
|
10
|
+
cliPath?: string;
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
};
|
|
2
13
|
export type PluginResources = {
|
|
3
14
|
skills: {
|
|
4
15
|
name: string;
|
|
@@ -97,6 +108,7 @@ export type PluginValidationReport = {
|
|
|
97
108
|
resources?: PluginResources;
|
|
98
109
|
};
|
|
99
110
|
export type ValidatePluginOptions = {
|
|
111
|
+
/** Optional qodercli executable or qoder Worker runtime entry override. */
|
|
100
112
|
cliPath?: string;
|
|
101
113
|
env?: Record<string, string>;
|
|
102
114
|
signal?: AbortSignal;
|
package/dist/types/session.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export type SessionMessage = {
|
|
|
36
36
|
isApiErrorMessage?: true;
|
|
37
37
|
/** CLI-stamped display metadata for tool results that did not execute. */
|
|
38
38
|
tool_result_meta?: SDKToolResultMeta[];
|
|
39
|
+
/**
|
|
40
|
+
* Structured tool result persisted by qodercli alongside a user
|
|
41
|
+
* `tool_result` message. When one transcript entry contains multiple
|
|
42
|
+
* `tool_result` blocks, this is an array aligned with those blocks by index.
|
|
43
|
+
*/
|
|
44
|
+
tool_use_result?: unknown;
|
|
39
45
|
/**
|
|
40
46
|
* ISO 8601 timestamp of when this transcript entry was written to the
|
|
41
47
|
* jsonl file. Mirrors the on-disk `timestamp` field. Optional because
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qoder-ai/qoder-agent-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "TypeScript SDK for building Qoder-powered coding agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^3.25.0 || ^4.0.0"
|
|
52
52
|
},
|
|
53
|
-
"qoderCliVersion": "1.1.
|
|
53
|
+
"qoderCliVersion": "1.1.26",
|
|
54
54
|
"qoderSdkBrand": "global",
|
|
55
55
|
"license": "SEE LICENSE IN LICENSE"
|
|
56
56
|
}
|