@qoder-ai/qoder-agent-sdk 1.0.58 → 1.0.59

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
@@ -6,6 +6,8 @@ The SDK starts `qodercli` for you, streams agent messages back to Node.js, and
6
6
  lets your application configure tools, permissions, working directories, MCP
7
7
  servers, hooks, and interactive sessions.
8
8
 
9
+ For compression billing messages, see [压缩费用消息接口](doc/compact-usage.md).
10
+
9
11
  ## Installation
10
12
 
11
13
  ```bash
@@ -56,6 +58,22 @@ the CLI process, such as `pathToQoderCLIExecutable`, `executable`,
56
58
  shared daemon instead. Because the daemon is shared, every query in one process
57
59
  must pass compatible daemon-level options.
58
60
 
61
+ `options.extraHeaders` accepts a `Record<string, string>` for the first Qoder
62
+ main-model request of the first queryable input and its network retries. Later
63
+ tool continuations, subagents, and queries do not inherit these headers. Existing
64
+ built-in headers take precedence. Use a paired CLI build with `extra_headers`
65
+ support. For example, after the host obtains the user's paid-usage confirmation:
66
+
67
+ ```ts
68
+ query({
69
+ prompt,
70
+ options: {
71
+ ...options,
72
+ extraHeaders: { "Cosy-Paid-Confirmed": "true" },
73
+ },
74
+ });
75
+ ```
76
+
59
77
  If your environment blocks install scripts or network downloads, skip postinstall
60
78
  runtime downloads:
61
79
 
@@ -189,6 +207,11 @@ for await (const message of q) {
189
207
  }
190
208
  ```
191
209
 
210
+ ## Business Attribution
211
+
212
+ For Qoder integrations, set product on the daemon and type on each query.
213
+ See the [short integration guide](doc/business-context.md).
214
+
192
215
  ## Code Security
193
216
 
194
217
  Built-in code security is disabled by default in SDK sessions. Enable only the
@@ -18,6 +18,9 @@ type ToolsOption = string[] | {
18
18
  preset: 'qodercli';
19
19
  };
20
20
  export interface ProcessTransportOptions {
21
+ business?: {
22
+ type: string;
23
+ };
21
24
  /** Path to the Qoder CLI executable (binary or script) */
22
25
  pathToQoderCLIExecutable?: string;
23
26
  /** Override executable name (node, bun, deno) for script entry points */
@@ -18,6 +18,9 @@ type ToolsOption = string[] | {
18
18
  preset: 'qodercli';
19
19
  };
20
20
  export interface RuntimeLaunchOptions {
21
+ business?: {
22
+ type: string;
23
+ };
21
24
  cwd?: string;
22
25
  env?: Record<string, string | undefined>;
23
26
  proxy?: string;
@@ -17,12 +17,6 @@ export declare const SESSION_STORE_FORK_BARRIER_CAPABILITY = "session_store_fork
17
17
  */
18
18
  export declare const DAEMON_HEARTBEAT_TIMEOUT_MS = 120000;
19
19
  export declare const DAEMON_KEEP_ALIVE_CAPABILITY = "daemon_keep_alive_v1";
20
- /**
21
- * daemon 会话 close 改成「关信道即回包、后台排干 teardown」的能力位(CLI 仓镜像)。
22
- * 会话 initialize 回包声明它时,QueryRunner.close 不再隐式等 memory / evolution
23
- * flush;旧 CLI 不声明则保持原有等待语义(版本错配保护)。
24
- */
25
- export declare const DAEMON_ASYNC_SESSION_TEARDOWN_CAPABILITY = "daemon_async_session_teardown_v1";
26
20
  export interface DaemonConnectionOptions {
27
21
  input: Writable;
28
22
  output: Readable;
@@ -52,6 +46,9 @@ export interface DaemonConnectionOptions {
52
46
  heartbeatTimeoutMs?: number;
53
47
  }
54
48
  export interface DaemonInitializeOptions {
49
+ business?: {
50
+ product: string;
51
+ };
55
52
  /** Advertised in addition to the capability this SDK cannot work without. */
56
53
  capabilities?: readonly string[];
57
54
  timeoutMs?: number;
@@ -4,6 +4,9 @@ import type { DaemonWireSessionMessage } from './protocol.js';
4
4
  import type { DaemonConnection, DaemonSessionIdClaim } from './daemon-connection.js';
5
5
  import type { DiagnosticsSink } from '../core/sdk-diagnostics.js';
6
6
  export type DaemonSessionTransportOptions = {
7
+ business?: {
8
+ type: string;
9
+ };
7
10
  workerArgs: string[];
8
11
  cwd?: string;
9
12
  configDir?: string;
@@ -3,6 +3,10 @@ import type { QueryTransportProvider } from '../core/transport.js';
3
3
  import type { DaemonQueryTransportOptions } from '../core/query-transport.js';
4
4
  import { type Daemon } from './start-daemon.js';
5
5
  export interface InitDaemonOptions {
6
+ /** daemon 全局产品身份;初始化后不能由 Query 覆盖。 */
7
+ business?: {
8
+ product: string;
9
+ };
6
10
  auth: InternalAuthOptions;
7
11
  pathToQoderCLIExecutable?: string;
8
12
  /** 语义同 `StartDaemonOptions.executable`。 */
@@ -106,6 +106,9 @@ export type DaemonWireSessionMessage = JsonObject & {
106
106
  };
107
107
  export type DaemonProtocolFrame = DaemonControlRequestFrame | DaemonControlResponseFrame | DaemonSessionUpdatedStatusEventFrame | KeepAliveFrame | DaemonProtocolErrorFrame | DaemonWireSessionMessage;
108
108
  export type InitializeDaemonParams = {
109
+ business?: {
110
+ product: string;
111
+ };
109
112
  daemon_protocol_version: typeof DAEMON_PROTOCOL_VERSION;
110
113
  sdk_version: string;
111
114
  capabilities: string[];
@@ -136,6 +139,9 @@ export type InitializeDaemonResult = {
136
139
  capabilities: string[];
137
140
  };
138
141
  export type OpenSessionParams = {
142
+ business?: {
143
+ type: string;
144
+ };
139
145
  worker_args: string[];
140
146
  cwd?: string;
141
147
  config_dir?: string;
@@ -16,6 +16,10 @@ export interface DaemonSessionInfo {
16
16
  updatedAt: string;
17
17
  }
18
18
  export interface StartDaemonOptions {
19
+ /** daemon 全局产品身份;不同产品使用不同 daemon。 */
20
+ business?: {
21
+ product: string;
22
+ };
19
23
  /**
20
24
  * Credentials for the daemon's own account plane and its in-process Sessions.
21
25
  *
package/dist/index.d.ts CHANGED
@@ -96,7 +96,7 @@ export type { AccessTokenInput, AuthOptions, FetchServiceAccountToken, ServiceAc
96
96
  */
97
97
  export type { FetchJobToken, JobTokenAuthOptions, JobTokenRequest, JobTokenResult, } from './types/auth.js';
98
98
  export type { Base64ImageSource, UrlImageSource, URLImageSource, ImageSource, ImageContentBlock, ImageBlockParam, ContentBlock, MessageParam, 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';
99
- export type { SDKMessage, SDKAssistantMessage, SDKToolNonExecutionKind, SDKToolResultMeta, SDKMessageOrigin, SDKSelectedSkill, SDKArtifactInfo, SDKArtifactUpdateMessage, SDKAvailableModelsUpdateMessage, SDKCommandsChangedMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultMessage, SDKResultSuccess, SDKResultError, SDKSystemMessage, SDKSystemInitMessage, SDKSystemMessageSubtype, SDKSystemMessageBySubtype, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKModelQueueStatusMessage, SDKControlRequestProgressMessage, SDKCommandLifecycleMessage, SDKToolProgressMessage, SDKHookDiagnosticsMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKMirrorErrorMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKPlanModeChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKMemoryGenerationMessage, SDKMemoryConsumptionMessage, SDKSkillEvolutionMessage, SDKAgentsMdSizeWarningMessage, SDKPermissionDenial, } from './types/messages.js';
99
+ export type { SDKMessage, SDKAssistantMessage, SDKHostToolUseMessage, SDKHostToolResultMessage, SDKCodeModeHostResult, SDKToolNonExecutionKind, SDKToolResultMeta, SDKMessageOrigin, SDKSelectedSkill, SDKArtifactInfo, SDKArtifactUpdateMessage, SDKAvailableModelsUpdateMessage, SDKCommandsChangedMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultMessage, SDKResultSuccess, SDKResultError, SDKSystemMessage, SDKSystemInitMessage, SDKSystemMessageSubtype, SDKSystemMessageBySubtype, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKModelQueueStatusMessage, SDKControlRequestProgressMessage, SDKCommandLifecycleMessage, SDKToolProgressMessage, SDKHookDiagnosticsMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKMirrorErrorMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKPlanModeChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKMemoryGenerationMessage, SDKMemoryConsumptionMessage, SDKSkillEvolutionMessage, SDKAgentsMdSizeWarningMessage, SDKPermissionDenial, } from './types/messages.js';
100
100
  export type { DefaultRuntimeTransport, } from './core/default-runtime.js';
101
101
  export type { ProcessTransportOptions } from './core/process-transport.js';
102
102
  export type { WorkerRuntimeTransportOptions, WorkerTransportOptions, } from './core/worker-transport.js';