@qoder-ai/qoder-agent-sdk 1.0.50 → 1.0.52
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/dist/core/bounded-line-transform.d.ts +3 -9
- package/dist/core/close-diagnostics.d.ts +4 -0
- package/dist/core/errors.d.ts +20 -0
- package/dist/core/sdk-diagnostics.d.ts +7 -0
- package/dist/daemon/daemon-connection.d.ts +35 -3
- package/dist/daemon/daemon-session-transport.d.ts +10 -0
- package/dist/daemon/global-daemon.d.ts +6 -0
- package/dist/daemon/protocol.d.ts +18 -1
- package/dist/daemon/start-daemon.d.ts +50 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +35 -30
- package/dist/protocol/control.d.ts +1 -0
- package/dist/query/daemon-account-queries.d.ts +57 -0
- package/dist/query/query-runner.d.ts +21 -2
- package/dist/runtime-manifest.json +5 -5
- package/dist/types/close-diagnostics.d.ts +10 -0
- package/dist/types/options.d.ts +7 -1
- package/package.json +2 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* daemon 账号级查询面(窄接口)。
|
|
3
|
+
*
|
|
4
|
+
* 这是 QueryRunner 在「daemon 绑定的 Query」上把账号级查询改道到守护进程时唯一依赖的
|
|
5
|
+
* 契约。它只暴露 10 个账号级查询;**不包含** `Daemon` 的生命周期与写操作成员
|
|
6
|
+
* (`stop()` / `state` / `renameSession()` / `deleteSession()`),也**不包含**
|
|
7
|
+
* daemon 专属的会话目录查询 `listSessions`。
|
|
8
|
+
*
|
|
9
|
+
* 为什么 `listSessions` 不进这里:它是 **daemon 专属接口**,`Query` 上没有对应成员,
|
|
10
|
+
* 因此不存在「把 Query 的既有接口代理到 daemon」这回事。本接口的职责只有一件——把
|
|
11
|
+
* `Query` **本来就有**的账号级查询在 daemon 形态下改道到 `daemon.*`,绝不借它给
|
|
12
|
+
* `Query` 扩新能力。要给 `Query` 加成员,就得同时实现它的每一个实现者
|
|
13
|
+
* (`QueryRunner` 与 `CloudAgentQuery`),漏一个就是编译期破坏;需要会话目录的宿主
|
|
14
|
+
* 直接用 `Daemon.listSessions(cwd?)`,那条不经本接口。
|
|
15
|
+
*
|
|
16
|
+
* 同理 rename/delete 虽然也接受 cwd,但它们是**写操作**(改标题、删记录),属于宿主经
|
|
17
|
+
* `Daemon` 直接掌握的能力,绝不下放给 QueryRunner。
|
|
18
|
+
*
|
|
19
|
+
* 也**不包含** `listPlugins`——它看着像账号级查询,其实是会话级的。worker 协议里
|
|
20
|
+
* `list_plugins` 读的是会话自己的 Config(headlessSession.ts:9198),而 daemon 的
|
|
21
|
+
* `daemon.list_plugins` 读 daemon 根 Config;用户经 `--plugin-dir`(即 Query 的
|
|
22
|
+
* `plugins` 选项)配置的插件只装进会话 Config,根 Config 永远看不到。把它列进来会
|
|
23
|
+
* 让 daemon 绑定的 Query 静默返回一份缺了会话插件的清单——比报错更难发现。
|
|
24
|
+
* 故 `Query.listPlugins()` 一律走会话面(CLI 侧已注册会话级 `list_plugins`);
|
|
25
|
+
* 需要账号级清单的宿主直接用 `Daemon.listPlugins()`,那条不经本接口。
|
|
26
|
+
*
|
|
27
|
+
* 为什么是窄接口而不是直接传整个 `Daemon`:
|
|
28
|
+
*
|
|
29
|
+
* 1. 职责隔离。QueryRunner 只负责把只读查询路由到 daemon 面,它不该、也不能持有
|
|
30
|
+
* 或操作 daemon 的生命周期。把整个 `Daemon` 塞进来会让 QueryRunner 凭空获得关闭
|
|
31
|
+
* daemon、改名/删除会话等与本职责无关的权力——那是 startDaemon() 的调用方
|
|
32
|
+
* (宿主)才应该掌握的能力。
|
|
33
|
+
* 2. 可测性。窄接口让单测可以用一个只实现这些方法的假对象钉住路由,不必启动
|
|
34
|
+
* 真实 daemon 进程,也不必构造完整的 `Daemon`。
|
|
35
|
+
* 3. 结构化兼容。TypeScript 是结构化类型:真正的 `Daemon` 天然满足这个更窄的接口,
|
|
36
|
+
* 所以 `query()` 在 daemon 绑定分支里直接把 `options.daemon` 传进来即可,无需适配层。
|
|
37
|
+
*
|
|
38
|
+
* 方法名与签名刻意与 `Daemon`(`../daemon/start-daemon.js`)保持一致,而不是与 `Query`
|
|
39
|
+
* 的对外方法名一致——这样 `Daemon` 能被直接赋值给本接口。QueryRunner 负责把 Query 的
|
|
40
|
+
* 对外语义(吞错、可空性、入参形状)适配到这些 daemon 方法上,契约差异收敛在
|
|
41
|
+
* QueryRunner 一侧,不外泄到本接口。
|
|
42
|
+
*/
|
|
43
|
+
import type { DaemonGetModelsParams, DaemonValidateByokModelParams } from '../daemon/protocol.js';
|
|
44
|
+
import type { BYOKProviderInfo, ByokConfigCheckResult, ByokConfigInfo, ByokConfigReference, CheckByokConfigInput, CreateByokConfigInput, DeleteByokConfigInput, UpdateByokConfigInput } from '../protocol/control.js';
|
|
45
|
+
import type { AccountInfo, ModelInfo, UsageInfo } from '../protocol/common.js';
|
|
46
|
+
export interface DaemonAccountQueryPlane {
|
|
47
|
+
getModels(options?: DaemonGetModelsParams): Promise<ModelInfo[]>;
|
|
48
|
+
getByokConfig(): Promise<BYOKProviderInfo[]>;
|
|
49
|
+
validateByokModel(input: DaemonValidateByokModelParams): Promise<boolean>;
|
|
50
|
+
listByokConfigs(): Promise<ByokConfigInfo[]>;
|
|
51
|
+
createByokConfig(input: CreateByokConfigInput): Promise<ByokConfigReference>;
|
|
52
|
+
updateByokConfig(input: UpdateByokConfigInput): Promise<void>;
|
|
53
|
+
deleteByokConfig(target: DeleteByokConfigInput): Promise<void>;
|
|
54
|
+
checkByokConfig(input: CheckByokConfigInput): Promise<ByokConfigCheckResult>;
|
|
55
|
+
getUsageInfo(): Promise<UsageInfo | null>;
|
|
56
|
+
accountInfo(): Promise<AccountInfo>;
|
|
57
|
+
}
|
|
@@ -32,6 +32,7 @@ import type { SDKPlanModeSnapshot, SDKGoalSnapshot, SDKGoalStatus, SDKControlInt
|
|
|
32
32
|
import type { PermissionMode, CanUseTool } from '../types/permissions.js';
|
|
33
33
|
import type { HookCallbackMatcher } from '../types/hooks.js';
|
|
34
34
|
import type { HookEvent as InternalHookEvent } from '../protocol/index.js';
|
|
35
|
+
import type { DaemonAccountQueryPlane } from './daemon-account-queries.js';
|
|
35
36
|
import type { McpServerConfig, McpServerStatus, McpSetServersResult, OAuthToken } from '../types/mcp.js';
|
|
36
37
|
import type { McpToolRuntimeOverride } from '../protocol/mcp.js';
|
|
37
38
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
@@ -119,10 +120,24 @@ export declare class QueryRunner implements InternalQuery {
|
|
|
119
120
|
private readonly skillEvolutionCallbacks?;
|
|
120
121
|
private readonly hostActionFallback?;
|
|
121
122
|
private readonly resolveSessionArtifacts?;
|
|
123
|
+
/**
|
|
124
|
+
* daemon 绑定时注入的账号级查询窄接口。存在即表示这条 Query 挂在守护进程上,
|
|
125
|
+
* 10 个账号级方法(getAvailableModels / listByokProviders / validateByokModel /
|
|
126
|
+
* 4 个 BYOK 配置管理 / accountInfo / getUsageInfo)必须改道到 daemon 面,
|
|
127
|
+
* 而不是往会话面发控制请求——CLI 按设计不在会话面注册这些方法,
|
|
128
|
+
* 落到会话面只会回 `Unsupported control request type`。缺省(普通 worker /
|
|
129
|
+
* process Query)时这些方法照旧走会话面。
|
|
130
|
+
*
|
|
131
|
+
* `listPlugins` 刻意**不在**这 10 个里:它是会话级语义(读会话自己的 Config),
|
|
132
|
+
* 改道到账号级 `daemon.list_plugins` 会静默漏掉用户经 `plugins` 选项 /
|
|
133
|
+
* `--plugin-dir` 配置的插件。详见 DaemonAccountQueryPlane 的头注释。
|
|
134
|
+
*/
|
|
135
|
+
private readonly daemonAccountQueries?;
|
|
122
136
|
private resolveStreamInitialization;
|
|
123
137
|
private initResponse?;
|
|
124
138
|
private latestCommands;
|
|
125
139
|
private initializationPromise?;
|
|
140
|
+
private rejectInitialization?;
|
|
126
141
|
private resultMessage?;
|
|
127
142
|
/**
|
|
128
143
|
* True only while the latest completed turn is an error result and no newer
|
|
@@ -145,7 +160,7 @@ export declare class QueryRunner implements InternalQuery {
|
|
|
145
160
|
private closePromise?;
|
|
146
161
|
private sessionStoreForkBarrierComplete;
|
|
147
162
|
private inputEnded;
|
|
148
|
-
constructor(transport: Transport, isSingleTurn: boolean, canUseTool?: CanUseTool, hooks?: Partial<Record<InternalHookEvent, HookCallbackMatcher[]>>, abortController?: AbortController, sdkMcpServers?: Map<string, McpServer>, initConfig?: InitConfig, onElicitation?: OnElicitation, diagnostics?: DiagnosticsSink, onAuthExpired?: () => void, controlRequestTimeoutMs?: number, sdkMcpTransports?: Map<string, SdkMcpTransport>, pendingMcpResponses?: Map<string, PendingMcpResponse>, fetchJobToken?: FetchJobToken, resolveModel?: ModelPolicyProvider, resolveModelTimeoutMs?: number, sessionStore?: SessionStore, sessionStoreFlush?: SessionStoreFlush, sdkMcpToolOverrides?: Record<string, Record<string, McpToolRuntimeOverride>>, fetchServiceAccountToken?: FetchServiceAccountToken, memoryCallbacks?: MemoryRuntimeCallbacks, skillEvolutionCallbacks?: SkillEvolutionRuntimeCallbacks, resolveSessionArtifacts?: ResolveSessionArtifacts, hostActionFallback?: (event: HostActionEvent) => Promise<void>, hostActionDirect?: boolean);
|
|
163
|
+
constructor(transport: Transport, isSingleTurn: boolean, canUseTool?: CanUseTool, hooks?: Partial<Record<InternalHookEvent, HookCallbackMatcher[]>>, abortController?: AbortController, sdkMcpServers?: Map<string, McpServer>, initConfig?: InitConfig, onElicitation?: OnElicitation, diagnostics?: DiagnosticsSink, onAuthExpired?: () => void, controlRequestTimeoutMs?: number, sdkMcpTransports?: Map<string, SdkMcpTransport>, pendingMcpResponses?: Map<string, PendingMcpResponse>, fetchJobToken?: FetchJobToken, resolveModel?: ModelPolicyProvider, resolveModelTimeoutMs?: number, sessionStore?: SessionStore, sessionStoreFlush?: SessionStoreFlush, sdkMcpToolOverrides?: Record<string, Record<string, McpToolRuntimeOverride>>, fetchServiceAccountToken?: FetchServiceAccountToken, memoryCallbacks?: MemoryRuntimeCallbacks, skillEvolutionCallbacks?: SkillEvolutionRuntimeCallbacks, resolveSessionArtifacts?: ResolveSessionArtifacts, hostActionFallback?: (event: HostActionEvent) => Promise<void>, hostActionDirect?: boolean, daemonAccountQueries?: DaemonAccountQueryPlane);
|
|
149
164
|
private getRecord;
|
|
150
165
|
private normalizeLogPreview;
|
|
151
166
|
private extractMessagePreview;
|
|
@@ -242,6 +257,8 @@ export declare class QueryRunner implements InternalQuery {
|
|
|
242
257
|
* CLI and waits for the system init message.
|
|
243
258
|
*/
|
|
244
259
|
initialize(): Promise<SDKControlInitializeResponse>;
|
|
260
|
+
private startInitialization;
|
|
261
|
+
private failInitialization;
|
|
245
262
|
private performInitialize;
|
|
246
263
|
private completeSessionStoreForkBarrier;
|
|
247
264
|
private flushTranscriptMirrorForLifecycle;
|
|
@@ -360,7 +377,9 @@ export declare class QueryRunner implements InternalQuery {
|
|
|
360
377
|
* Validate a BYOK provider/model/API-key combination through the CLI.
|
|
361
378
|
*/
|
|
362
379
|
validateByokModel(input: BYOKModelValidationInput): Promise<boolean | null>;
|
|
363
|
-
listByokConfigs(
|
|
380
|
+
listByokConfigs(options?: {
|
|
381
|
+
uid: string;
|
|
382
|
+
}): Promise<ByokConfigInfo[]>;
|
|
364
383
|
createByokConfig(input: CreateByokConfigInput): Promise<ByokConfigReference>;
|
|
365
384
|
updateByokConfig(input: UpdateByokConfigInput): Promise<void>;
|
|
366
385
|
deleteByokConfig(target: DeleteByokConfigInput): Promise<void>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
3
|
"brand": "global",
|
|
4
|
-
"sdkVersion": "1.0.
|
|
5
|
-
"qoderCliVersion": "1.1.
|
|
4
|
+
"sdkVersion": "1.0.52",
|
|
5
|
+
"qoderCliVersion": "1.1.69",
|
|
6
6
|
"defaultTransport": "worker",
|
|
7
7
|
"workerRuntime": {
|
|
8
8
|
"packaged": false,
|
|
9
9
|
"delivery": "install",
|
|
10
10
|
"source": "qodercli-worker-runtime",
|
|
11
|
-
"urlTemplate": "https://download.qoder.com/qodercli/releases/1.1.
|
|
11
|
+
"urlTemplate": "https://download.qoder.com/qodercli/releases/1.1.69/qodercli-worker-runtime-{target}.tgz",
|
|
12
12
|
"artifactNameTemplate": "qodercli-worker-runtime-{target}.tgz",
|
|
13
|
-
"sdkVersion": "1.0.
|
|
14
|
-
"qoderCliVersion": "1.1.
|
|
13
|
+
"sdkVersion": "1.0.52",
|
|
14
|
+
"qoderCliVersion": "1.1.69"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 关闭诊断仅包含 SDK 生成的标识和固定阶段,不携带输入、路径或原始异常。 */
|
|
2
|
+
export interface CloseDiagnosticEvent {
|
|
3
|
+
readonly correlationId: string;
|
|
4
|
+
readonly component: 'query' | 'worker';
|
|
5
|
+
readonly stage: 'close' | 'flush' | 'memory_flush' | 'skill_flush' | 'mcp_close' | 'transport_close' | 'read_loop' | 'transcript_flush' | 'initialize' | 'worker_exit' | 'worker_exit_observed' | 'terminate' | 'artifacts';
|
|
6
|
+
readonly outcome: 'started' | 'completed' | 'failed';
|
|
7
|
+
readonly elapsedMs: number;
|
|
8
|
+
readonly exitCode?: number;
|
|
9
|
+
readonly errorCode?: 'SDK_CLOSE_STAGE_FAILED';
|
|
10
|
+
}
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Readable, Writable } from 'stream';
|
|
2
|
+
import type { CloseDiagnosticEvent } from './close-diagnostics.js';
|
|
2
3
|
import type { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
4
|
import type { AuthOptions, InternalAuthOptions } from './auth.js';
|
|
4
5
|
import type { AgentDefinition, AgentInfo } from './agents.js';
|
|
@@ -345,6 +346,8 @@ export type Options = {
|
|
|
345
346
|
* @default 500
|
|
346
347
|
*/
|
|
347
348
|
resolveModelTimeoutMs?: number;
|
|
349
|
+
/** 脱敏的关闭阶段通知;无需启用 debug,不等待回调完成,回调错误不影响关闭。 */
|
|
350
|
+
onCloseDiagnostic?: (event: CloseDiagnosticEvent) => void;
|
|
348
351
|
/**
|
|
349
352
|
* Enable SDK debug logging and forward `--debug` to the qodercli child
|
|
350
353
|
* process. Without `debugFile`, SDK debug output is written to `stderr`
|
|
@@ -553,8 +556,11 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
|
553
556
|
* List persisted UID-scoped BYOK models plus User-scope Custom Providers.
|
|
554
557
|
* Credentials are never returned. Use listByokProviders() for the server
|
|
555
558
|
* provider/model catalog.
|
|
559
|
+
* 传入 UID 时要求只读能力,供 bare 查询本地摘要;省略时沿用完整管理通道。
|
|
556
560
|
*/
|
|
557
|
-
listByokConfigs(
|
|
561
|
+
listByokConfigs(options?: {
|
|
562
|
+
uid: string;
|
|
563
|
+
}): Promise<ByokConfigInfo[]>;
|
|
558
564
|
/** Persist a server BYOK model or User-scope Custom Provider. */
|
|
559
565
|
createByokConfig(input: CreateByokConfigInput): Promise<ByokConfigReference>;
|
|
560
566
|
/** Update an existing BYOK entry by its stable storage key/provider id. */
|
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.52",
|
|
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.69",
|
|
54
54
|
"qoderSdkBrand": "global",
|
|
55
55
|
"license": "SEE LICENSE IN LICENSE"
|
|
56
56
|
}
|