@qoder-ai/qoder-agent-sdk 1.0.15 → 1.0.17
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 +159 -24
- package/dist/auth.d.ts +4 -1
- package/dist/core/constants.d.ts +7 -2
- package/dist/core/deferred-transport.d.ts +23 -0
- package/dist/core/errors.d.ts +0 -8
- package/dist/core/process-transport.d.ts +3 -0
- package/dist/core/runtime-launch-options.d.ts +10 -1
- package/dist/core/transport.d.ts +2 -4
- package/dist/index.d.ts +13 -13
- package/dist/index.js +27 -22
- package/dist/mcp/sdk-mcp-server.d.ts +13 -1
- package/dist/mcp/tool-policy.d.ts +6 -0
- package/dist/protocol/agents.d.ts +0 -3
- package/dist/protocol/common.d.ts +27 -9
- package/dist/protocol/control.d.ts +40 -12
- package/dist/protocol/index.d.ts +4 -3
- package/dist/protocol/index.js +1 -1
- package/dist/protocol/mcp.d.ts +29 -0
- package/dist/protocol/messages.d.ts +38 -18
- package/dist/protocol/model-prompt-patches.d.ts +18 -0
- package/dist/protocol/version.d.ts +1 -1
- package/dist/query/query-runner.d.ts +16 -6
- package/dist/session/session-fork.d.ts +1 -27
- package/dist/session/session-import.d.ts +10 -0
- package/dist/session/session-manager.d.ts +3 -1
- package/dist/session/session-materializer.d.ts +15 -0
- package/dist/session/session-store.d.ts +45 -0
- package/dist/session/transcript-mirror.d.ts +25 -0
- package/dist/session/transcript-paths.d.ts +1 -2
- package/dist/types/auth.d.ts +27 -2
- package/dist/types/common.d.ts +1 -1
- package/dist/types/control.d.ts +13 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/mcp.d.ts +9 -3
- package/dist/types/messages.d.ts +21 -2
- package/dist/types/options.d.ts +50 -10
- package/dist/types/session.d.ts +17 -7
- package/dist/types/settings.d.ts +19 -232
- package/package.json +4 -14
- package/dist/bridge/bridge-api.d.ts +0 -14
- package/dist/bridge/bridge-session.d.ts +0 -6
- package/dist/bridge/ccr-client.d.ts +0 -72
- package/dist/bridge/index.d.ts +0 -9
- package/dist/bridge/index.js +0 -3
- package/dist/bridge/sse-transport.d.ts +0 -37
- package/dist/browser/browser-query.d.ts +0 -24
- package/dist/browser/index.d.ts +0 -14
- package/dist/browser/index.js +0 -9
- package/dist/browser/websocket-transport.d.ts +0 -40
- package/dist/direct-connect/direct-connect-transport.d.ts +0 -31
- package/dist/direct-connect/url-parser.d.ts +0 -14
- package/dist/embed/embed.d.ts +0 -2
- package/dist/embed/embed.js +0 -1
- package/dist/embed/extract-from-bunfs.d.ts +0 -5
- package/dist/types/bridge.d.ts +0 -62
- package/dist/types/browser.d.ts +0 -26
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SessionStore } from './session-store.js';
|
|
2
|
+
export type MaterializedSession = {
|
|
3
|
+
configDir: string;
|
|
4
|
+
projectKey: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
cleanup(): Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare function materializeSessionFromStore(options: {
|
|
9
|
+
store: SessionStore;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
resume?: string;
|
|
12
|
+
continue?: boolean;
|
|
13
|
+
loadTimeoutMs?: number;
|
|
14
|
+
env?: Record<string, string | undefined>;
|
|
15
|
+
}): Promise<MaterializedSession | undefined>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type SessionStoreEntry = {
|
|
2
|
+
type: string;
|
|
3
|
+
uuid?: string;
|
|
4
|
+
timestamp?: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type SessionKey = {
|
|
8
|
+
projectKey: string;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
/** Opaque transcript suffix such as `subagents/agent-<id>` (without `.jsonl`). */
|
|
11
|
+
subpath?: string;
|
|
12
|
+
};
|
|
13
|
+
export type SessionStoreFlush = 'batched' | 'eager';
|
|
14
|
+
export interface SessionStore {
|
|
15
|
+
append(key: SessionKey, entries: SessionStoreEntry[]): Promise<void>;
|
|
16
|
+
load(key: SessionKey): Promise<SessionStoreEntry[] | null>;
|
|
17
|
+
listSessions?(projectKey: string): Promise<Array<{
|
|
18
|
+
sessionId: string;
|
|
19
|
+
mtime: number;
|
|
20
|
+
}>>;
|
|
21
|
+
delete?(key: SessionKey): Promise<void>;
|
|
22
|
+
listSubkeys?(key: Omit<SessionKey, 'subpath'>): Promise<string[]>;
|
|
23
|
+
}
|
|
24
|
+
/** Reference store for tests, examples, and process-local integrations. */
|
|
25
|
+
export declare class InMemorySessionStore implements SessionStore {
|
|
26
|
+
private readonly entries;
|
|
27
|
+
private readonly keys;
|
|
28
|
+
private readonly modifiedAt;
|
|
29
|
+
private lastModifiedAt;
|
|
30
|
+
append(key: SessionKey, entries: SessionStoreEntry[]): Promise<void>;
|
|
31
|
+
load(key: SessionKey): Promise<SessionStoreEntry[] | null>;
|
|
32
|
+
listSessions(projectKey: string): Promise<Array<{
|
|
33
|
+
sessionId: string;
|
|
34
|
+
mtime: number;
|
|
35
|
+
}>>;
|
|
36
|
+
delete(key: SessionKey): Promise<void>;
|
|
37
|
+
listSubkeys(key: Omit<SessionKey, 'subpath'>): Promise<string[]>;
|
|
38
|
+
/** Return all entries for a key. Intended for tests and local development. */
|
|
39
|
+
getEntries(key: SessionKey): SessionStoreEntry[];
|
|
40
|
+
/** Number of stored main transcripts. */
|
|
41
|
+
get size(): number;
|
|
42
|
+
/** Remove all stored entries. */
|
|
43
|
+
clear(): void;
|
|
44
|
+
private deleteSerialized;
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DiagnosticsSink } from '../core/sdk-diagnostics.js';
|
|
2
|
+
import type { SDKMirrorErrorMessage } from '../types/messages.js';
|
|
3
|
+
import type { SessionKey, SessionStore, SessionStoreEntry, SessionStoreFlush } from './session-store.js';
|
|
4
|
+
export type TranscriptMirrorMessage = {
|
|
5
|
+
type: 'transcript_mirror';
|
|
6
|
+
filePath: string;
|
|
7
|
+
entries: SessionStoreEntry[];
|
|
8
|
+
};
|
|
9
|
+
export declare function isTranscriptMirrorMessage(value: unknown): value is TranscriptMirrorMessage;
|
|
10
|
+
export declare class TranscriptMirrorBatcher {
|
|
11
|
+
private readonly options;
|
|
12
|
+
private readonly states;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
store: SessionStore;
|
|
15
|
+
flushMode: SessionStoreFlush;
|
|
16
|
+
onMirrorError: (message: SDKMirrorErrorMessage) => void;
|
|
17
|
+
diagnostics?: DiagnosticsSink;
|
|
18
|
+
appendTimeoutMs?: number;
|
|
19
|
+
retryDelaysMs?: readonly number[];
|
|
20
|
+
});
|
|
21
|
+
enqueue(message: TranscriptMirrorMessage): void;
|
|
22
|
+
flush(): Promise<void>;
|
|
23
|
+
private drain;
|
|
24
|
+
}
|
|
25
|
+
export declare function sessionKeyFromTranscriptPath(filePath: string): SessionKey;
|
|
@@ -7,8 +7,7 @@ export declare function homedir(): string;
|
|
|
7
7
|
* Resolve the config directory that contains `projects/`.
|
|
8
8
|
*
|
|
9
9
|
* Resolution order:
|
|
10
|
-
* 1. `QODER_CONFIG_DIR` — full path override
|
|
11
|
-
* tests / sandboxed setups; qodercli does not read this). When set,
|
|
10
|
+
* 1. `QODER_CONFIG_DIR` — full path override shared with qodercli. When set,
|
|
12
11
|
* `BRAND_CONFIG_DIR_INTERNAL` is NOT appended — the value is used as-is.
|
|
13
12
|
* 2. `<homedir()>/<BRAND_CONFIG_DIR_INTERNAL>` — default, aligned with
|
|
14
13
|
* qodercli's `Storage.getGlobalConfigDir()`.
|
package/dist/types/auth.d.ts
CHANGED
|
@@ -9,12 +9,31 @@
|
|
|
9
9
|
export type AccessTokenInput = string | {
|
|
10
10
|
envVar: string;
|
|
11
11
|
};
|
|
12
|
+
export type ServiceAccountKeyInput = string | {
|
|
13
|
+
envVar: string;
|
|
14
|
+
};
|
|
15
|
+
export type ServiceAccountTokenResult = {
|
|
16
|
+
token: string;
|
|
17
|
+
/** Absolute expiration time as a Unix timestamp in milliseconds. */
|
|
18
|
+
expiresAt?: number;
|
|
19
|
+
};
|
|
20
|
+
export type FetchServiceAccountToken = () => Promise<ServiceAccountTokenResult | null>;
|
|
21
|
+
export type ServiceAccountCredentials = {
|
|
22
|
+
serviceAccountKey: ServiceAccountKeyInput;
|
|
23
|
+
fetchServiceAccountToken?: never;
|
|
24
|
+
} | {
|
|
25
|
+
serviceAccountKey?: never;
|
|
26
|
+
fetchServiceAccountToken: FetchServiceAccountToken;
|
|
27
|
+
};
|
|
28
|
+
export type ServiceAccountAuthOptions = {
|
|
29
|
+
type: 'serviceAccount';
|
|
30
|
+
} & ServiceAccountCredentials;
|
|
12
31
|
export type AuthOptions = {
|
|
13
32
|
type: 'accessToken';
|
|
14
33
|
accessToken: AccessTokenInput;
|
|
15
34
|
} | {
|
|
16
35
|
type: 'qodercli';
|
|
17
|
-
};
|
|
36
|
+
} | ServiceAccountAuthOptions;
|
|
18
37
|
export type JobTokenRequest = {
|
|
19
38
|
requestId: string;
|
|
20
39
|
reason: 'initial' | 'unauthorized';
|
|
@@ -47,5 +66,11 @@ export type SdkAuthPayload = {
|
|
|
47
66
|
type: 'qodercli';
|
|
48
67
|
} | {
|
|
49
68
|
type: 'jobToken';
|
|
50
|
-
|
|
69
|
+
jobTokenProvider: 'host';
|
|
70
|
+
} | {
|
|
71
|
+
type: 'serviceAccount';
|
|
72
|
+
serviceAccountKey: string;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'serviceAccount';
|
|
75
|
+
serviceAccountTokenProvider: 'host';
|
|
51
76
|
};
|
package/dist/types/common.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* shim so existing SDK consumer imports (`'./types/common.js'` paths)
|
|
6
6
|
* keep working.
|
|
7
7
|
*/
|
|
8
|
-
export type { UUID, BetaMessage, BetaRawMessageStreamEvent, BetaUsage, BetaStopReason, MessageParam, NonNullableUsage, AccountInfo, UsageAddOnQuotaBucket, UsageInfo, UsageOrgResourcePackage, UsageQuotaBucket, ApiKeySource, ExitReason, FastModeState, ConfigScope, SettingSource, SDKAssistantMessageError, SDKStatus, EffortLevel, ThinkingAdaptive, ThinkingEnabled, ThinkingDisabled, ThinkingConfig,
|
|
8
|
+
export type { UUID, BetaMessage, BetaRawMessageStreamEvent, BetaUsage, BetaStopReason, MessageParam, NonNullableUsage, 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, PluginInfo, ModelUsage, SlashCommand, ToolConfig, SdkPluginConfig, } from '../protocol/index.js';
|
package/dist/types/control.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* shim so existing SDK consumer imports keep working.
|
|
6
6
|
*/
|
|
7
7
|
export type { QoderModelPurpose } from '../protocol/index.js';
|
|
8
|
-
export type { SDKControlRequest, SDKControlResponse, SDKControlCancelRequest, SDKControlInterruptRequest, SDKControlPermissionRequest, SDKControlInitializeRequest, SDKControlSetPermissionModeRequest, SDKControlSetModelRequest, SDKControlGenerateSessionTitleRequest, SDKControlGenerateSessionTitleResponse, SDKControlAddDirectoriesRequest, SDKControlAddDirectoriesResponse, SDKControlGetModelPolicyRequest, SDKControlGetByokConfigRequest, SDKControlGetByokConfigResponse, SDKControlValidateByokModelRequest, SDKControlValidateByokModelResponse, SDKControlSetMaxThinkingTokensRequest, SDKControlMcpStatusRequest, SDKControlGetContextUsageRequest, SDKControlGetUsageInfoRequest, SDKControlGetUsageInfoResponse, SDKControlAccountInfoRequest, SDKHookCallbackRequest, SDKControlMcpMessageRequest, SDKControlRewindFilesRequest, SDKControlCancelAsyncMessageRequest, SDKControlSeedReadStateRequest, SDKControlMcpSetServersRequest, SDKControlReloadPluginsRequest, SDKControlMcpReconnectRequest, SDKControlMcpToggleRequest, SDKControlApplyFlagSettingsRequest, SDKControlGetSettingsRequest, SDKControlElicitationRequest, SDKControlEndSessionRequest, SDKControlChannelEnableRequest, SDKControlMcpInjectTokenRequest, SDKControlMcpAuthenticateRequest, SDKControlMcpOAuthCallbackUrlRequest, SDKControlMcpClearAuthRequest, SDKControlRequestInner, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlReloadPluginsResponse, SDKControlListPluginsRequest, SDKControlListPluginsResponse, SDKControlMcpStatusResponse, SDKControlMcpSetServersResponse, SDKKeepAliveMessage, StdoutMessage, ControlMcpServerConfig, BYOKModelValidationInput, } from '../protocol/index.js';
|
|
8
|
+
export type { SDKControlRequest, SDKControlResponse, SDKControlCancelRequest, SDKControlInterruptRequest, SDKControlInterruptResponse, SDKControlPermissionRequest, SDKControlInitializeRequest, SDKControlSetPermissionModeRequest, SDKControlSetModelRequest, SDKControlGenerateSessionTitleRequest, SDKControlGenerateSessionTitleResponse, SDKControlAddDirectoriesRequest, SDKControlAddDirectoriesResponse, SDKControlGetModelPolicyRequest, SDKControlGetByokConfigRequest, SDKControlGetByokConfigResponse, SDKControlValidateByokModelRequest, SDKControlValidateByokModelResponse, SDKControlSetMaxThinkingTokensRequest, SDKControlMcpStatusRequest, SDKControlGetContextUsageRequest, SDKControlGetUsageInfoRequest, SDKControlGetUsageInfoResponse, SDKControlAccountInfoRequest, SDKHookCallbackRequest, SDKControlMcpMessageRequest, SDKControlRewindFilesRequest, SDKControlCancelAsyncMessageRequest, SDKControlSeedReadStateRequest, SDKControlMcpSetServersRequest, SDKControlReloadPluginsRequest, SDKControlMcpReconnectRequest, SDKControlMcpToggleRequest, SDKControlApplyFlagSettingsRequest, SDKControlGetSettingsRequest, SDKControlElicitationRequest, SDKControlEndSessionRequest, SDKControlChannelEnableRequest, SDKControlMcpInjectTokenRequest, SDKControlMcpAuthenticateRequest, SDKControlMcpOAuthCallbackUrlRequest, SDKControlMcpClearAuthRequest, SDKControlRequestInner, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlReloadPluginsResponse, SDKControlListPluginsRequest, SDKControlListPluginsResponse, SDKControlMcpStatusResponse, SDKControlMcpSetServersResponse, SDKKeepAliveMessage, StdoutMessage, ControlMcpServerConfig, BYOKModelValidationInput, } from '../protocol/index.js';
|
|
9
9
|
/** Wire format for fetch_job_token inbound control request from CLI. */
|
|
10
10
|
export type FetchJobTokenWireRequest = {
|
|
11
11
|
subtype: 'fetch_job_token';
|
|
@@ -15,4 +15,16 @@ export type FetchJobTokenWireRequest = {
|
|
|
15
15
|
/** Wire format for fetch_job_token success response. */
|
|
16
16
|
export type FetchJobTokenWireResponse = {
|
|
17
17
|
token: string;
|
|
18
|
+
};
|
|
19
|
+
/** Wire format for Service Account token requests sent by qodercli. */
|
|
20
|
+
export type FetchServiceAccountTokenWireRequest = {
|
|
21
|
+
subtype: 'fetch_service_account_token';
|
|
22
|
+
reason: 'initial' | 'expiring' | 'unauthorized';
|
|
23
|
+
required_scopes: string[];
|
|
24
|
+
session_id?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Wire format for successful Service Account token responses. */
|
|
27
|
+
export type FetchServiceAccountTokenWireResponse = {
|
|
28
|
+
token: string;
|
|
29
|
+
expires_at?: number;
|
|
18
30
|
};
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `../protocol/`. The SDK-local HookEvent/HookInput contract is
|
|
6
6
|
* intentionally narrowed to events supported by SDK user configuration.
|
|
7
7
|
*/
|
|
8
|
-
export type { BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, SessionStartHookInput, SessionEndHookInput, StopHookInput, SubagentStartHookInput, SubagentStopHookInput, PreCompactHookInput, PostCompactHookInput, PermissionRequestHookInput, InstructionsLoadedHookInput, CwdChangedHookInput, FileChangedHookInput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, SessionStartHookSpecificOutput, SubagentStartHookSpecificOutput, PermissionRequestHookSpecificOutput, CwdChangedHookSpecificOutput, FileChangedHookSpecificOutput, } from '../protocol/index.js';
|
|
8
|
+
export type { BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, SessionStartHookInput, SessionEndHookInput, StopHookInput, SubagentStartHookInput, SubagentStopHookInput, PreCompactHookInput, PostCompactHookInput, PermissionRequestHookInput, PermissionDeniedHookInput, InstructionsLoadedHookInput, CwdChangedHookInput, FileChangedHookInput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, SessionStartHookSpecificOutput, SubagentStartHookSpecificOutput, PermissionRequestHookSpecificOutput, CwdChangedHookSpecificOutput, FileChangedHookSpecificOutput, } from '../protocol/index.js';
|
|
9
9
|
import type { AsyncHookJSONOutput as ProtocolAsyncHookJSONOutput, CwdChangedHookSpecificOutput, FileChangedHookSpecificOutput, HookInput as ProtocolHookInput, PostToolUseHookSpecificOutput as ProtocolPostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, PreToolUseHookSpecificOutput as ProtocolPreToolUseHookSpecificOutput, PermissionRequestHookSpecificOutput, SessionStartHookSpecificOutput, SubagentStartHookSpecificOutput, SyncHookJSONOutput as ProtocolSyncHookJSONOutput, UserPromptSubmitHookSpecificOutput } from '../protocol/index.js';
|
|
10
10
|
import type { HookEventConst } from '../core/constants.js';
|
|
11
11
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,11 +15,10 @@ export type { HookEvent, HookPermissionDecision, HookCallback, HookCallbackMatch
|
|
|
15
15
|
export * from './mcp.js';
|
|
16
16
|
export * from './agents.js';
|
|
17
17
|
export * from './session.js';
|
|
18
|
+
export type { SessionKey, SessionStore, SessionStoreEntry, SessionStoreFlush, } from '../session/session-store.js';
|
|
18
19
|
export * from './settings.js';
|
|
19
20
|
export * from './cloud-agent.js';
|
|
20
21
|
export * from './control.js';
|
|
21
22
|
export * from './model-policy-provider.js';
|
|
22
|
-
export * from './bridge.js';
|
|
23
|
-
export * from './browser.js';
|
|
24
23
|
export * from './tools.js';
|
|
25
|
-
export type { AccessTokenInput, AuthOptions, FetchJobToken, JobTokenAuthOptions, JobTokenRequest, JobTokenResult, } from './auth.js';
|
|
24
|
+
export type { AccessTokenInput, AuthOptions, FetchServiceAccountToken, FetchJobToken, JobTokenAuthOptions, JobTokenRequest, JobTokenResult, ServiceAccountAuthOptions, ServiceAccountCredentials, ServiceAccountKeyInput, ServiceAccountTokenResult, } from './auth.js';
|
package/dist/types/mcp.d.ts
CHANGED
|
@@ -9,16 +9,22 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
9
9
|
import type { McpStdioServerConfig as ProtocolMcpStdioServerConfig, McpSSEServerConfig as ProtocolMcpSSEServerConfig, McpHttpServerConfig as ProtocolMcpHttpServerConfig, McpSdkServerConfig as ProtocolMcpSdkServerConfig } from '../protocol/index.js';
|
|
10
10
|
export type McpServerToolPolicy = {
|
|
11
11
|
name: string;
|
|
12
|
-
permission_policy
|
|
12
|
+
permission_policy?: 'always_allow' | 'always_ask' | 'always_deny';
|
|
13
|
+
exposedName?: string;
|
|
14
|
+
alwaysLoad?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type McpStdioServerConfig = ProtocolMcpStdioServerConfig & {
|
|
17
|
+
tools?: McpServerToolPolicy[];
|
|
13
18
|
};
|
|
14
|
-
export type McpStdioServerConfig = ProtocolMcpStdioServerConfig;
|
|
15
19
|
export type McpSSEServerConfig = ProtocolMcpSSEServerConfig & {
|
|
16
20
|
tools?: McpServerToolPolicy[];
|
|
17
21
|
};
|
|
18
22
|
export type McpHttpServerConfig = ProtocolMcpHttpServerConfig & {
|
|
19
23
|
tools?: McpServerToolPolicy[];
|
|
20
24
|
};
|
|
21
|
-
export type McpSdkServerConfig = ProtocolMcpSdkServerConfig
|
|
25
|
+
export type McpSdkServerConfig = ProtocolMcpSdkServerConfig & {
|
|
26
|
+
tools?: McpServerToolPolicy[];
|
|
27
|
+
};
|
|
22
28
|
export type McpServerConfigForProcessTransport = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfig;
|
|
23
29
|
export type McpServerStatusConfig = McpServerConfigForProcessTransport;
|
|
24
30
|
export type { McpServerStatus, McpSetServersResult, OAuthToken, } from '../protocol/index.js';
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -8,14 +8,25 @@
|
|
|
8
8
|
import type { SDKMessage as ProtocolSDKMessage, SDKStatusMessage as ProtocolSDKStatusMessage, SDKSystemMessage as ProtocolSDKSystemMessage, SDKUserMessage as ProtocolSDKUserMessage, SDKUserMessageReplay as ProtocolSDKUserMessageReplay } from '../protocol/index.js';
|
|
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, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKPermissionDenial, } from '../protocol/index.js';
|
|
12
13
|
export type SDKUserMessage = {
|
|
13
14
|
type: 'user';
|
|
14
15
|
message: MessageParam;
|
|
15
16
|
parent_tool_use_id: string | null;
|
|
16
17
|
isSynthetic?: boolean;
|
|
17
18
|
tool_use_result?: unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Delivery priority. `next` is the default; `now` interrupts the active
|
|
21
|
+
* turn, while `later` waits for the session to become idle.
|
|
22
|
+
*/
|
|
18
23
|
priority?: 'now' | 'next' | 'later';
|
|
24
|
+
/**
|
|
25
|
+
* When false, do not start an assistant turn while the session is idle.
|
|
26
|
+
* Delivery still follows `priority`: `next` can inject at a safe boundary,
|
|
27
|
+
* `later` waits for idle, and `now` interrupts the active turn.
|
|
28
|
+
*/
|
|
29
|
+
shouldQuery?: boolean;
|
|
19
30
|
timestamp?: string;
|
|
20
31
|
uuid?: UUID;
|
|
21
32
|
session_id?: string;
|
|
@@ -43,7 +54,15 @@ export type SDKPermissionDeniedMessage = {
|
|
|
43
54
|
uuid: string;
|
|
44
55
|
session_id: string;
|
|
45
56
|
};
|
|
46
|
-
export type
|
|
57
|
+
export type SDKMirrorErrorMessage = {
|
|
58
|
+
type: 'system';
|
|
59
|
+
subtype: 'mirror_error';
|
|
60
|
+
error: string;
|
|
61
|
+
key: SessionKey;
|
|
62
|
+
uuid: string;
|
|
63
|
+
session_id: string;
|
|
64
|
+
};
|
|
65
|
+
export type SDKMessage = Exclude<ProtocolSDKMessage, ProtocolSDKSystemMessage | ProtocolSDKStatusMessage | ProtocolSDKUserMessage | ProtocolSDKUserMessageReplay> | SDKUserMessage | SDKUserMessageReplay | SDKSystemInitMessage | SDKStatusMessage | SDKPermissionDeniedMessage | SDKMirrorErrorMessage;
|
|
47
66
|
export type SDKSystemMessage = Extract<SDKMessage, {
|
|
48
67
|
type: 'system';
|
|
49
68
|
}>;
|
package/dist/types/options.d.ts
CHANGED
|
@@ -8,13 +8,15 @@ 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 { SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlGenerateSessionTitleResponse, SDKControlAddDirectoriesResponse, SDKControlReloadPluginsResponse, StdoutMessage } from './control.js';
|
|
11
|
+
import type { SDKControlInterruptResponse, SDKControlInitializeResponse, SDKControlGetContextUsageResponse, SDKControlGenerateSessionTitleResponse, 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 } from './session.js';
|
|
15
15
|
import type { CloudAgentOptions } from './cloud-agent.js';
|
|
16
16
|
import type { QueryTransportProviderOption } from '../core/query-transport.js';
|
|
17
17
|
import type { PluginDetails } from './plugins.js';
|
|
18
|
+
import type { SessionStore, SessionStoreFlush } from '../session/session-store.js';
|
|
19
|
+
import type { ModelPromptPatches } from '../protocol/model-prompt-patches.js';
|
|
18
20
|
export type { CanUseTool };
|
|
19
21
|
export type { AuthOptions };
|
|
20
22
|
export type ElicitationRequest = {
|
|
@@ -64,6 +66,12 @@ export type Options = {
|
|
|
64
66
|
* Prefer the `accessTokenFromEnv()` helper in host code.
|
|
65
67
|
* - `{ type: 'qodercli' }` - Read-only reuse of local `qodercli login`
|
|
66
68
|
* state. Prefer the `qodercliAuth()` helper in host code.
|
|
69
|
+
* - `{ type: 'serviceAccount', serviceAccountKey }` - Exchange a Service
|
|
70
|
+
* Account key for short-lived model access. Prefer `serviceAccount()` or
|
|
71
|
+
* `serviceAccountFromEnv()`.
|
|
72
|
+
* - `{ type: 'serviceAccount', fetchServiceAccountToken }` - Let the host
|
|
73
|
+
* supply and refresh short-lived Service Account tokens through
|
|
74
|
+
* `serviceAccount()`.
|
|
67
75
|
* - `{ type: 'jobToken', fetchJobToken }` - Internal first-party host
|
|
68
76
|
* integration. Prefer the `jobToken(fetchJobToken)` helper in host code.
|
|
69
77
|
*
|
|
@@ -109,9 +117,9 @@ export type Options = {
|
|
|
109
117
|
* `name` / directory name, or `plugin:skill` for plugin-qualified skills.
|
|
110
118
|
* Adds `"Skill(<name>)"` for each entry to allowedTools.
|
|
111
119
|
*
|
|
112
|
-
* This is a context filter, not a
|
|
113
|
-
* the model's listing and rejected by the Skill tool, but their
|
|
114
|
-
* remain on disk and are reachable via Read/Bash.
|
|
120
|
+
* This is a context filter, not a security boundary: unlisted skills are
|
|
121
|
+
* hidden from the model's listing and rejected by the Skill tool, but their
|
|
122
|
+
* files remain on disk and are reachable via Read/Bash.
|
|
115
123
|
*/
|
|
116
124
|
skills?: string[] | 'all';
|
|
117
125
|
extensions?: string[];
|
|
@@ -167,11 +175,6 @@ export type Options = {
|
|
|
167
175
|
model?: string;
|
|
168
176
|
pathToQoderCLIExecutable?: string;
|
|
169
177
|
permissionMode?: PermissionMode;
|
|
170
|
-
/**
|
|
171
|
-
* Custom workflow instructions for plan mode. When `permissionMode` is
|
|
172
|
-
* `plan`, the CLI uses this text as the plan-mode workflow body.
|
|
173
|
-
*/
|
|
174
|
-
planModeInstructions?: string;
|
|
175
178
|
allowDangerouslySkipPermissions?: boolean;
|
|
176
179
|
/**
|
|
177
180
|
* MCP tool name to use for permission prompts. Mutually exclusive with
|
|
@@ -180,7 +183,21 @@ export type Options = {
|
|
|
180
183
|
permissionPromptToolName?: string;
|
|
181
184
|
plugins?: SdkPluginConfig[];
|
|
182
185
|
promptSuggestions?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Persist the local session transcript. Defaults to true.
|
|
188
|
+
*
|
|
189
|
+
* Set to false for an ephemeral query that cannot be resumed. This option
|
|
190
|
+
* cannot be combined with sessionStore because external mirroring consumes
|
|
191
|
+
* locally committed transcript entries.
|
|
192
|
+
*/
|
|
193
|
+
persistSession?: boolean;
|
|
183
194
|
resume?: string;
|
|
195
|
+
/** Mirrors locally committed transcript entries to an external store. */
|
|
196
|
+
sessionStore?: SessionStore;
|
|
197
|
+
/** `batched` flushes at result boundaries; `eager` drains every CLI frame. */
|
|
198
|
+
sessionStoreFlush?: SessionStoreFlush;
|
|
199
|
+
/** Timeout for loading a session from an external store. Defaults to 60 seconds. */
|
|
200
|
+
loadTimeoutMs?: number;
|
|
184
201
|
sessionId?: string;
|
|
185
202
|
settings?: string | Settings;
|
|
186
203
|
settingSources?: SettingSource[];
|
|
@@ -191,6 +208,11 @@ export type Options = {
|
|
|
191
208
|
preset: 'qodercli';
|
|
192
209
|
append?: string;
|
|
193
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Prompt patches forwarded to the model service for model-aware system
|
|
213
|
+
* prompt selection. Route keys are interpreted by the service.
|
|
214
|
+
*/
|
|
215
|
+
modelRequestPatches?: ModelPromptPatches;
|
|
194
216
|
/**
|
|
195
217
|
* Pull-mode model selection callback.
|
|
196
218
|
*
|
|
@@ -263,7 +285,25 @@ export interface SpawnedProcess {
|
|
|
263
285
|
* 配置 MCP servers 请通过 `Options.mcpServers`(启动时一次性配置)。
|
|
264
286
|
*/
|
|
265
287
|
export interface Query extends AsyncGenerator<SDKMessage, void> {
|
|
266
|
-
|
|
288
|
+
/**
|
|
289
|
+
* Request interruption of the active turn.
|
|
290
|
+
*
|
|
291
|
+
* CLIs advertising `interrupt_receipt_v1` return UUIDs of queued messages
|
|
292
|
+
* that survive the interrupt. Older CLIs return `undefined`.
|
|
293
|
+
*/
|
|
294
|
+
interrupt(): Promise<SDKControlInterruptResponse | undefined>;
|
|
295
|
+
/**
|
|
296
|
+
* Remove a UUID-stamped async user message while it is still queued.
|
|
297
|
+
*
|
|
298
|
+
* Returns `true` only when the CLI removes that UUID from the queue.
|
|
299
|
+
*
|
|
300
|
+
* After messages have been dequeued into the in-flight coalesced batch, this
|
|
301
|
+
* method returns `false`. While that reservation remains active, cancelling
|
|
302
|
+
* the last UUID-bearing message marks the batch to be dropped; cancelling a
|
|
303
|
+
* non-representative UUID is a no-op. `false` alone does not prove a batch
|
|
304
|
+
* was dropped.
|
|
305
|
+
*/
|
|
306
|
+
cancelAsyncMessage(messageUuid: string): Promise<boolean>;
|
|
267
307
|
setPermissionMode(mode: PermissionMode): Promise<void>;
|
|
268
308
|
setModel(model?: string): Promise<void>;
|
|
269
309
|
/**
|
package/dist/types/session.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ export type SessionMessage = {
|
|
|
26
26
|
session_id: string;
|
|
27
27
|
message: unknown;
|
|
28
28
|
parent_tool_use_id: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Agent ID of the subagent that spawned this subagent. Null for main-session
|
|
31
|
+
* messages, depth-one subagents, and transcripts without this metadata.
|
|
32
|
+
*/
|
|
33
|
+
parent_agent_id: string | null;
|
|
29
34
|
/**
|
|
30
35
|
* ISO 8601 timestamp of when this transcript entry was written to the
|
|
31
36
|
* jsonl file. Mirrors the on-disk `timestamp` field. Optional because
|
|
@@ -61,16 +66,19 @@ export type SessionMessage = {
|
|
|
61
66
|
};
|
|
62
67
|
};
|
|
63
68
|
};
|
|
64
|
-
|
|
69
|
+
type SessionStoreOptions = {
|
|
70
|
+
sessionStore?: SessionStore;
|
|
71
|
+
};
|
|
72
|
+
export type ListSessionsOptions = SessionStoreOptions & {
|
|
65
73
|
dir?: string;
|
|
66
74
|
limit?: number;
|
|
67
75
|
offset?: number;
|
|
68
76
|
includeWorktrees?: boolean;
|
|
69
77
|
};
|
|
70
|
-
export type GetSessionInfoOptions = {
|
|
78
|
+
export type GetSessionInfoOptions = SessionStoreOptions & {
|
|
71
79
|
dir?: string;
|
|
72
80
|
};
|
|
73
|
-
export type GetSessionMessagesOptions = {
|
|
81
|
+
export type GetSessionMessagesOptions = SessionStoreOptions & {
|
|
74
82
|
dir?: string;
|
|
75
83
|
limit?: number;
|
|
76
84
|
offset?: number;
|
|
@@ -80,15 +88,15 @@ export type GetSessionMessagesOptions = {
|
|
|
80
88
|
*/
|
|
81
89
|
includeSystemMessages?: boolean;
|
|
82
90
|
};
|
|
83
|
-
export type GetSubagentMessagesOptions = {
|
|
91
|
+
export type GetSubagentMessagesOptions = SessionStoreOptions & {
|
|
84
92
|
dir?: string;
|
|
85
93
|
limit?: number;
|
|
86
94
|
offset?: number;
|
|
87
95
|
};
|
|
88
|
-
export type ListSubagentsOptions = {
|
|
96
|
+
export type ListSubagentsOptions = SessionStoreOptions & {
|
|
89
97
|
dir?: string;
|
|
90
98
|
};
|
|
91
|
-
export type SessionMutationOptions = {
|
|
99
|
+
export type SessionMutationOptions = SessionStoreOptions & {
|
|
92
100
|
dir?: string;
|
|
93
101
|
};
|
|
94
102
|
export type ForkSessionOptions = SessionMutationOptions & {
|
|
@@ -106,4 +114,6 @@ export type RewindFilesResult = {
|
|
|
106
114
|
filesChanged?: string[];
|
|
107
115
|
insertions?: number;
|
|
108
116
|
deletions?: number;
|
|
109
|
-
};
|
|
117
|
+
};
|
|
118
|
+
import type { SessionStore } from '../session/session-store.js';
|
|
119
|
+
export {};
|