qlogicagent 2.3.0 → 2.4.0

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.
Files changed (65) hide show
  1. package/dist/agent.js +6 -6
  2. package/dist/cli.js +212 -211
  3. package/dist/index.js +211 -210
  4. package/dist/orchestration.js +2 -2
  5. package/dist/protocol.js +1 -0
  6. package/dist/types/agent/tunable-defaults.d.ts +4 -0
  7. package/dist/types/agent/types.d.ts +24 -100
  8. package/dist/types/cli/stdio-server.d.ts +7 -0
  9. package/dist/types/cli/tool-bootstrap.d.ts +6 -0
  10. package/dist/types/contracts/index.d.ts +2 -3
  11. package/dist/types/llm/provider-def.d.ts +3 -0
  12. package/dist/types/llm/transport.d.ts +25 -25
  13. package/dist/types/llm/transports/anthropic-messages.d.ts +2 -2
  14. package/dist/types/llm/transports/gemini-generatecontent.d.ts +2 -2
  15. package/dist/types/llm/transports/openai-chat.d.ts +2 -2
  16. package/dist/types/llm/transports/openai-responses.d.ts +9 -9
  17. package/dist/types/llm/transports/volcengine-responses.d.ts +11 -11
  18. package/dist/types/orchestration/agent-instance.d.ts +15 -0
  19. package/dist/types/orchestration/solo-evaluator.d.ts +7 -0
  20. package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +1 -1
  21. package/dist/types/protocol/methods.d.ts +143 -53
  22. package/dist/types/protocol/notifications.d.ts +4 -514
  23. package/dist/types/protocol/wire/acp-protocol.d.ts +411 -0
  24. package/dist/types/protocol/wire/agent-events.d.ts +32 -0
  25. package/dist/types/protocol/wire/agent-methods.d.ts +587 -0
  26. package/dist/types/protocol/wire/agent-rpc.d.ts +97 -0
  27. package/dist/types/protocol/wire/capability-manifest.d.ts +111 -0
  28. package/dist/types/protocol/wire/capability-transport.d.ts +207 -0
  29. package/dist/types/protocol/wire/channel-ingress.d.ts +29 -0
  30. package/dist/types/protocol/wire/channel.d.ts +89 -0
  31. package/dist/types/protocol/wire/chat-types.d.ts +87 -0
  32. package/dist/types/protocol/wire/checkpoint-runtime.d.ts +61 -0
  33. package/dist/types/protocol/wire/checkpoint.d.ts +72 -0
  34. package/dist/types/protocol/wire/execution.d.ts +391 -0
  35. package/dist/types/protocol/wire/gateway-rpc.d.ts +314 -0
  36. package/dist/types/protocol/wire/gateway.d.ts +62 -0
  37. package/dist/types/protocol/wire/hook-protocol.d.ts +37 -0
  38. package/dist/types/protocol/wire/index.d.ts +25 -0
  39. package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +80 -0
  40. package/dist/types/protocol/wire/notification-payloads.d.ts +581 -0
  41. package/dist/types/protocol/wire/provider-runtime-contract.d.ts +66 -0
  42. package/dist/types/protocol/wire/provider-runtime-core.d.ts +147 -0
  43. package/dist/types/protocol/wire/provider-runtime-io.d.ts +20 -0
  44. package/dist/types/protocol/wire/resource-manifest.d.ts +68 -0
  45. package/dist/types/protocol/wire/session.d.ts +32 -0
  46. package/dist/types/protocol/wire/thread-protocol.d.ts +157 -0
  47. package/dist/types/protocol/wire/transport.d.ts +57 -0
  48. package/dist/types/protocol/wire/turn.d.ts +208 -0
  49. package/dist/types/protocol/wire/web-capability.d.ts +51 -0
  50. package/dist/types/runtime/hooks/memory-hooks.d.ts +2 -2
  51. package/dist/types/runtime/infra/acp-types.d.ts +3 -142
  52. package/dist/types/runtime/infra/token-budget.d.ts +3 -3
  53. package/dist/types/runtime/session/index.d.ts +1 -1
  54. package/dist/types/runtime/session/session-memory.d.ts +46 -0
  55. package/dist/types/runtime/session/session-persistence.d.ts +34 -8
  56. package/dist/types/runtime/session/session-state.d.ts +4 -4
  57. package/dist/types/skills/memory/memory-tool.d.ts +1 -1
  58. package/dist/types/skills/memory/qmemory-adapter.d.ts +1 -1
  59. package/dist/types/skills/permissions/hook-runner.d.ts +4 -4
  60. package/dist/types/skills/permissions/permission-classifier.d.ts +2 -2
  61. package/dist/types/skills/tools/project-switch-tool.d.ts +24 -0
  62. package/dist/types/skills/tools.d.ts +5 -5
  63. package/dist/types/transport/acp-event-emitter.d.ts +1 -1
  64. package/dist/types/transport/acp-server.d.ts +17 -10
  65. package/package.json +14 -3
@@ -0,0 +1,147 @@
1
+ import type { ProviderRuntimeResolvedAuthContract, ProviderRuntimeVaultErrorType } from "./provider-runtime-contract.js";
2
+ export declare const PROVIDER_RUNTIME_OPENAI_CODEX_PROVIDER_ID = "openai-codex";
3
+ export declare function normalizeProviderRuntimeId(provider: string): string;
4
+ export declare function normalizeProviderRuntimeIdForAuth(provider: string): string;
5
+ export declare const resolveProviderRuntimeKeyFamily: typeof normalizeProviderRuntimeIdForAuth;
6
+ export type ProviderRuntimeCapabilities = {
7
+ anthropicToolSchemaMode: "native" | "openai-functions";
8
+ anthropicToolChoiceMode: "native" | "openai-string-modes";
9
+ providerFamily: "default" | "openai" | "anthropic";
10
+ preserveAnthropicThinkingSignatures: boolean;
11
+ openAiCompatTurnValidation: boolean;
12
+ providerThoughtSignatureSanitization: boolean;
13
+ transcriptToolCallIdMode: "default" | "strict9";
14
+ transcriptToolCallIdModelHints: string[];
15
+ providerThoughtSignatureModelHints: string[];
16
+ dropThinkingBlockModelHints: string[];
17
+ };
18
+ export declare function resolveProviderRuntimeCapabilities(provider?: string | null): ProviderRuntimeCapabilities;
19
+ export declare function preservesProviderRuntimeAnthropicThinkingSignatures(provider?: string | null): boolean;
20
+ export declare function requiresOpenAiCompatibleAnthropicToolPayloadForProviderRuntime(provider?: string | null): boolean;
21
+ export declare function usesOpenAiFunctionAnthropicToolSchemaForProviderRuntime(provider?: string | null): boolean;
22
+ export declare function usesOpenAiStringModeAnthropicToolChoiceForProviderRuntime(provider?: string | null): boolean;
23
+ export declare function supportsOpenAiCompatTurnValidationForProviderRuntime(provider?: string | null): boolean;
24
+ export declare function isOpenAiProviderRuntimeFamily(provider?: string | null): boolean;
25
+ export declare function isAnthropicProviderRuntimeFamily(provider?: string | null): boolean;
26
+ export declare function shouldDropThinkingBlocksForProviderRuntimeModel(params: {
27
+ provider?: string | null;
28
+ modelId?: string | null;
29
+ }): boolean;
30
+ export declare function shouldSanitizeProviderRuntimeThoughtSignaturesForModel(params: {
31
+ provider?: string | null;
32
+ modelId?: string | null;
33
+ }): boolean;
34
+ export declare function resolveProviderRuntimeTranscriptToolCallIdMode(provider?: string | null, modelId?: string | null): "strict9" | undefined;
35
+ export type ProviderRuntimeCredentialRecord = {
36
+ type: "api_key";
37
+ key: string;
38
+ } | {
39
+ type: string;
40
+ access: string;
41
+ };
42
+ export type ProviderRuntimeCredentialMap = Record<string, ProviderRuntimeCredentialRecord>;
43
+ type InMemoryAuthStorageBackendLike = {
44
+ withLock<T>(update: (current: string) => {
45
+ result: T;
46
+ next?: string;
47
+ }): T;
48
+ };
49
+ export declare function createProviderRuntimeInMemoryAuthStorageBackend(initialData: ProviderRuntimeCredentialMap): InMemoryAuthStorageBackendLike;
50
+ export declare function createProviderRuntimeAuthStorage<TAuthStorage>(params: {
51
+ AuthStorageLike: unknown;
52
+ authPath: string;
53
+ credentials: ProviderRuntimeCredentialMap;
54
+ createBackend?: () => InMemoryAuthStorageBackendLike;
55
+ }): TAuthStorage;
56
+ export type ProviderRuntimeEnvApiKeyResult = {
57
+ apiKey: string;
58
+ source: string;
59
+ };
60
+ export type ProviderRuntimeResolvedAuthMode = "api-key" | "oauth" | "token" | "mixed" | "aws-sdk" | "unknown";
61
+ export type ProviderRuntimeResolvedAuth = ProviderRuntimeResolvedAuthContract & {
62
+ apiKey?: string;
63
+ profileId?: string;
64
+ source: string;
65
+ mode: "api-key" | "oauth" | "token" | "aws-sdk";
66
+ vaultRelease?: () => void;
67
+ vaultReportSuccess?: () => void;
68
+ vaultReportError?: (errorType?: ProviderRuntimeVaultErrorType) => void;
69
+ };
70
+ export type ProviderRuntimePlatformKey = {
71
+ key: string;
72
+ source: string;
73
+ release?: () => void;
74
+ reportSuccess?: () => void;
75
+ reportError?: (errorType?: ProviderRuntimeVaultErrorType) => void;
76
+ };
77
+ export declare function resolveProviderRuntimeAwsSdkEnvVarName(env?: NodeJS.ProcessEnv): string | undefined;
78
+ export declare function resolveProviderRuntimeAwsSdkAuthInfo(params?: {
79
+ env?: NodeJS.ProcessEnv;
80
+ appliedEnvKeys?: Iterable<string>;
81
+ }): {
82
+ mode: "aws-sdk";
83
+ source: string;
84
+ };
85
+ export declare const PROVIDER_RUNTIME_ENV_API_KEY_CANDIDATES: Record<string, readonly string[]>;
86
+ export declare function listProviderRuntimeEnvApiKeyNames(): string[];
87
+ export declare function resolveProviderRuntimeEnvApiKey(params: {
88
+ provider: string;
89
+ env?: NodeJS.ProcessEnv;
90
+ appliedEnvKeys?: Iterable<string>;
91
+ resolveSpecialApiKey?: (normalizedProvider: string, env: NodeJS.ProcessEnv, appliedEnvKeys: Set<string>) => ProviderRuntimeEnvApiKeyResult | null | undefined;
92
+ }): ProviderRuntimeEnvApiKeyResult | null;
93
+ export interface ProviderRuntimeAuthProfileDeps<TConfig, TStore> {
94
+ ensureAuthProfileStore: (agentDir?: string) => TStore;
95
+ listProfilesForProvider: (store: TStore, provider: string) => string[];
96
+ resolveAuthProfileOrder: (params: {
97
+ cfg?: TConfig;
98
+ store: TStore;
99
+ provider: string;
100
+ preferredProfile?: string;
101
+ }) => string[];
102
+ resolveApiKeyForProfile: (params: {
103
+ cfg?: TConfig;
104
+ store: TStore;
105
+ profileId: string;
106
+ agentDir?: string;
107
+ }) => Promise<{
108
+ apiKey: string;
109
+ } | null | undefined>;
110
+ getProfileType: (store: TStore, profileId: string) => string | undefined;
111
+ }
112
+ export interface ProviderRuntimeAuthCoreDeps<TConfig, TStore, TModel> {
113
+ isHubManagedProviderPathActive: () => boolean;
114
+ profileDeps: ProviderRuntimeAuthProfileDeps<TConfig, TStore>;
115
+ getCustomProviderApiKey: (cfg: TConfig | undefined, provider: string) => string | undefined;
116
+ resolveProviderAuthOverride: (cfg: TConfig | undefined, provider: string) => Extract<ProviderRuntimeResolvedAuthMode, "api-key" | "oauth" | "token" | "aws-sdk"> | undefined;
117
+ resolveEnvApiKey: (provider: string) => ProviderRuntimeEnvApiKeyResult | null | undefined;
118
+ normalizeProviderId?: (provider: string) => string;
119
+ resolveKeyFamily?: (provider: string) => string;
120
+ getAppliedShellEnvKeys?: () => Iterable<string>;
121
+ getFallbackProviders?: (provider: string) => string[];
122
+ tryGetPlatformKey?: (provider: string) => ProviderRuntimePlatformKey | null | undefined;
123
+ onPlatformKeyError?: (provider: string, error: unknown) => void;
124
+ getModelProvider?: (model: TModel) => string;
125
+ normalizeSecretInput?: (value: string | undefined) => string | undefined;
126
+ }
127
+ export declare function createProviderRuntimeAuthCore<TConfig, TStore, TModel>(deps: ProviderRuntimeAuthCoreDeps<TConfig, TStore, TModel>): {
128
+ getApiKeyForModel: (params: {
129
+ model: TModel;
130
+ cfg?: TConfig;
131
+ profileId?: string;
132
+ preferredProfile?: string;
133
+ store?: TStore;
134
+ agentDir?: string;
135
+ }) => Promise<ProviderRuntimeResolvedAuth>;
136
+ requireApiKey: (auth: ProviderRuntimeResolvedAuth, provider: string) => string;
137
+ resolveApiKeyForProvider: (params: {
138
+ provider: string;
139
+ cfg?: TConfig;
140
+ profileId?: string;
141
+ preferredProfile?: string;
142
+ store?: TStore;
143
+ agentDir?: string;
144
+ }) => Promise<ProviderRuntimeResolvedAuth>;
145
+ resolveModelAuthMode: (provider?: string, cfg?: TConfig, store?: TStore) => ProviderRuntimeResolvedAuthMode | undefined;
146
+ };
147
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type ProviderRuntimeCredentialMap } from "./provider-runtime-core.js";
2
+ export declare function scrubProviderRuntimeStaticAuthJsonEntries(pathname: string): void;
3
+ type InMemoryAuthStorageBackendLike = {
4
+ withLock<T>(update: (current: string) => {
5
+ result: T;
6
+ next?: string;
7
+ }): T;
8
+ };
9
+ export declare function discoverProviderRuntimeAuthStorage<TAuthStorage>(params: {
10
+ agentDir: string;
11
+ AuthStorageLike: unknown;
12
+ credentials: ProviderRuntimeCredentialMap;
13
+ createBackend?: () => InMemoryAuthStorageBackendLike;
14
+ }): TAuthStorage;
15
+ export declare function createProviderRuntimeModelRegistry<TAuthStorage, TModelRegistry>(params: {
16
+ authStorage: TAuthStorage;
17
+ ModelRegistryLike: new (authStorage: TAuthStorage, modelsPath: string) => TModelRegistry;
18
+ agentDir: string;
19
+ }): TModelRegistry;
20
+ export {};
@@ -0,0 +1,68 @@
1
+ export declare const RESOURCE_MANIFEST_SCHEMA_VERSION = 2;
2
+ export declare const RUNTIME_ASSET_IDS: {
3
+ readonly gatewayImage: "gateway.image.desktop-slim";
4
+ readonly whisperModelTiny: "speech.whisper.model.tiny";
5
+ readonly ffmpegWin32X64: "runtime.ffmpeg.win32-x64";
6
+ readonly nodeWin32X64: "runtime.node.win32-x64";
7
+ readonly dockerDesktopWin32X64: "runtime.docker-desktop.win32-x64";
8
+ readonly dockerDesktopDarwinX64: "runtime.docker-desktop.darwin-x64";
9
+ readonly dockerDesktopDarwinArm64: "runtime.docker-desktop.darwin-arm64";
10
+ };
11
+ export declare const RUNTIME_PROFILE_IDS: {
12
+ readonly desktopDockerBridge: "desktop.docker-bridge";
13
+ readonly desktopEmbeddedWin32X64: "desktop.embedded.win32-x64";
14
+ };
15
+ export type RuntimeResourcePlatform = 'any' | 'win32-x64' | 'win32-arm64' | 'darwin-x64' | 'darwin-arm64' | 'linux-x64' | 'linux-arm64';
16
+ export type RuntimeResourceAssetKind = 'container-image' | 'model' | 'runtime' | 'installer';
17
+ export type RuntimeResourceAssetDelivery = 'remote' | 'bundled';
18
+ export interface RuntimeResourceArtifact {
19
+ label?: string;
20
+ fileName: string;
21
+ size?: number;
22
+ sha256?: string;
23
+ url?: string;
24
+ relativePath?: string;
25
+ }
26
+ export interface RuntimeResourceAsset {
27
+ id: string;
28
+ version: string;
29
+ title: string;
30
+ kind: RuntimeResourceAssetKind;
31
+ delivery: RuntimeResourceAssetDelivery;
32
+ platform: RuntimeResourcePlatform;
33
+ description?: string;
34
+ artifacts: RuntimeResourceArtifact[];
35
+ }
36
+ export interface RuntimeResourceProfile {
37
+ id: string;
38
+ title: string;
39
+ platform: RuntimeResourcePlatform;
40
+ assetIds: string[];
41
+ description?: string;
42
+ }
43
+ export type RuntimeResourceAssetMap = Record<string, RuntimeResourceAsset>;
44
+ export type RuntimeResourceProfileMap = Record<string, RuntimeResourceProfile>;
45
+ export interface RuntimeManifestShortcutEntry {
46
+ version: string;
47
+ sha256: string;
48
+ size: number;
49
+ url: string;
50
+ }
51
+ export interface RuntimeResourceManifest {
52
+ schemaVersion: number;
53
+ channel?: string;
54
+ publishedAt?: string;
55
+ minElectronVersion?: string;
56
+ releaseNotes?: string;
57
+ assets: RuntimeResourceAssetMap;
58
+ profiles: RuntimeResourceProfileMap;
59
+ gateway?: RuntimeManifestShortcutEntry;
60
+ whisperModel?: RuntimeManifestShortcutEntry;
61
+ }
62
+ export declare function createDefaultRuntimeResourceProfiles(): RuntimeResourceProfileMap;
63
+ export declare function getRuntimeResourceAsset(manifest: Pick<RuntimeResourceManifest, 'assets'>, assetId: string): RuntimeResourceAsset | undefined;
64
+ export declare function getRuntimeResourceProfile(manifest: Pick<RuntimeResourceManifest, 'profiles'>, profileId: string): RuntimeResourceProfile | undefined;
65
+ export declare function getRuntimeResourceProfileAssets(manifest: Pick<RuntimeResourceManifest, 'assets' | 'profiles'>, profileId: string): RuntimeResourceAsset[];
66
+ export declare function upsertRuntimeResourceAsset(manifest: RuntimeResourceManifest, asset: RuntimeResourceAsset): RuntimeResourceManifest;
67
+ export declare function getManifestShortcutEntry(asset?: RuntimeResourceAsset): RuntimeManifestShortcutEntry | undefined;
68
+ export declare function normalizeRuntimeResourceManifest(raw: unknown): RuntimeResourceManifest;
@@ -0,0 +1,32 @@
1
+ export interface SessionIdentityContract {
2
+ sessionId: string;
3
+ sessionKey: string;
4
+ }
5
+ export type ModelSelectionReason = "user-selected" | "auto-default" | "failover" | "fallback" | "manual-switch";
6
+ export interface RuntimeCapabilitySummaryContract {
7
+ installedCapabilities: string[];
8
+ enabledCapabilities: string[];
9
+ eligibleToolCount?: number;
10
+ ineligibleToolCount?: number;
11
+ }
12
+ export interface ApprovalRequiredToolContract {
13
+ toolName: string;
14
+ reasonCodes?: string[];
15
+ }
16
+ export interface RuntimeSessionContract extends SessionIdentityContract {
17
+ createdAt: number;
18
+ lastTouchedAt: number;
19
+ activeRunId: string | null;
20
+ requestedModel?: string;
21
+ resolvedModel?: string;
22
+ modelSelectionReason?: ModelSelectionReason;
23
+ capabilitySnapshotVersion?: string;
24
+ capabilitySummary?: RuntimeCapabilitySummaryContract;
25
+ approvalRequiredTools?: ApprovalRequiredToolContract[];
26
+ }
27
+ export interface PendingPromptContract extends SessionIdentityContract {
28
+ idempotencyKey: string;
29
+ sentTextLength?: number;
30
+ sentText?: string;
31
+ toolCallIds?: string[];
32
+ }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Thread Protocol — Codex app-server style three-layer abstraction.
3
+ *
4
+ * Thread → Turn → Item
5
+ *
6
+ * Thread: persistent conversation container (maps to a session)
7
+ * Turn: one user request → agent response cycle
8
+ * Item: individual components within a turn (message, tool_call, tool_result, etc.)
9
+ *
10
+ * This module defines the wire types. The existing `agent.turn` RPC continues
11
+ * to work; these types provide the foundation for `thread/*` methods.
12
+ */
13
+ export type ItemType = "message" | "tool_call" | "tool_result" | "tool_blocked" | "recovery" | "plan_update" | "skill_instruction";
14
+ export type ItemRole = "user" | "assistant" | "system";
15
+ /** A single atomic event within a turn. */
16
+ export interface ThreadItem {
17
+ /** Unique item ID. */
18
+ id: string;
19
+ /** Item type (discriminator). */
20
+ type: ItemType;
21
+ /** Role of the actor. */
22
+ role: ItemRole;
23
+ /** Text content (for message items). */
24
+ text?: string;
25
+ /** Tool name (for tool_call / tool_result items). */
26
+ toolName?: string;
27
+ /** Tool call ID (LLM-assigned). */
28
+ toolCallId?: string;
29
+ /** Serialized arguments (for tool_call). */
30
+ arguments?: string;
31
+ /** Tool output (for tool_result). */
32
+ output?: string;
33
+ /** Whether the tool was approved. */
34
+ approved?: boolean;
35
+ /** Recovery strategy used (for recovery items). */
36
+ strategy?: string;
37
+ /** Timestamp (ISO 8601). */
38
+ createdAt: string;
39
+ }
40
+ export type TurnStatus = "pending" | "in_progress" | "completed" | "failed" | "aborted";
41
+ /** Represents one user request → agent response cycle. */
42
+ export interface ThreadTurn {
43
+ /** Unique turn ID. */
44
+ id: string;
45
+ /** Thread this turn belongs to. */
46
+ threadId: string;
47
+ /** Turn status. */
48
+ status: TurnStatus;
49
+ /** Items produced during this turn. */
50
+ items: ThreadItem[];
51
+ /** Model used for this turn. */
52
+ model?: string;
53
+ /** Token usage. */
54
+ usage?: {
55
+ promptTokens: number;
56
+ completionTokens: number;
57
+ totalTokens: number;
58
+ };
59
+ /** Cost in USD. */
60
+ costUSD?: number;
61
+ /** Turn creation time. */
62
+ createdAt: string;
63
+ /** Turn completion time. */
64
+ completedAt?: string;
65
+ }
66
+ export type ThreadStatus = "active" | "archived" | "deleted";
67
+ /** Persistent conversation container. */
68
+ export interface Thread {
69
+ /** Unique thread ID (maps to session ID). */
70
+ id: string;
71
+ /** Display title (auto-generated or user-set). */
72
+ title?: string;
73
+ /** Thread status. */
74
+ status: ThreadStatus;
75
+ /** All turns in this thread. */
76
+ turns: ThreadTurn[];
77
+ /** Working directory. */
78
+ cwd?: string;
79
+ /** Thread creation time. */
80
+ createdAt: string;
81
+ /** Last activity time. */
82
+ lastActiveAt: string;
83
+ }
84
+ /**
85
+ * `initialize` request params — superset of agent.hello.
86
+ * Sent by host as the first message after transport connects.
87
+ */
88
+ export interface InitializeParams {
89
+ /** Protocol version. */
90
+ protocolVersion: string;
91
+ /** Host application info. */
92
+ host: {
93
+ name: string;
94
+ version: string;
95
+ };
96
+ /** Host capabilities. */
97
+ capabilities?: {
98
+ /** Host can receive streaming deltas. */
99
+ streaming?: boolean;
100
+ /** Host supports tool approval flow. */
101
+ toolApproval?: boolean;
102
+ /** Host supports thread persistence. */
103
+ threads?: boolean;
104
+ };
105
+ /** Optional initial configuration. */
106
+ config?: Record<string, unknown>;
107
+ }
108
+ /** `initialize` response result. */
109
+ export interface InitializeResult {
110
+ /** Agent protocol version. */
111
+ protocolVersion: string;
112
+ /** Agent info. */
113
+ agent: {
114
+ name: string;
115
+ version: string;
116
+ };
117
+ /** Agent capabilities. */
118
+ capabilities: {
119
+ tools: string[];
120
+ streaming: boolean;
121
+ threads: boolean;
122
+ };
123
+ }
124
+ /** `thread/create` params. */
125
+ export interface ThreadCreateParams {
126
+ /** Optional thread ID (auto-generated if not provided). */
127
+ id?: string;
128
+ /** Optional title. */
129
+ title?: string;
130
+ /** Working directory. */
131
+ cwd?: string;
132
+ /** LLM configuration. */
133
+ config?: Record<string, unknown>;
134
+ }
135
+ /** `thread/turn` params — submit a user message to a thread. */
136
+ export interface ThreadTurnParams {
137
+ /** Thread ID. */
138
+ threadId: string;
139
+ /** User message(s). */
140
+ messages: Array<{
141
+ role: "user";
142
+ content: string;
143
+ }>;
144
+ /** Override LLM config for this turn. */
145
+ config?: Record<string, unknown>;
146
+ }
147
+ /** `thread/list` result. */
148
+ export interface ThreadListResult {
149
+ threads: Array<{
150
+ id: string;
151
+ title?: string;
152
+ status: ThreadStatus;
153
+ turnCount: number;
154
+ createdAt: string;
155
+ lastActiveAt: string;
156
+ }>;
157
+ }
@@ -0,0 +1,57 @@
1
+ export type ProxyLocale = "cn" | "intl";
2
+ export type ProxyKeySource = "managed" | "user";
3
+ export type ProxyQuotaSource = "subscription" | "topup" | "free" | "own-key";
4
+ export type ProxyRequestCategory = "text" | "image" | "video" | "music" | "audio" | "vision";
5
+ export interface TransportUsageInfo {
6
+ input: number;
7
+ output: number;
8
+ cacheRead?: number;
9
+ }
10
+ export interface TransportResponsePayload {
11
+ statusCode: number;
12
+ body: string;
13
+ usage?: TransportUsageInfo;
14
+ }
15
+ export interface TransportResponseMsg {
16
+ type: "proxy.response";
17
+ id: string;
18
+ payload: TransportResponsePayload;
19
+ }
20
+ export interface TransportErrorPayload {
21
+ error: string;
22
+ code: string;
23
+ retryable: boolean;
24
+ }
25
+ export interface TransportErrorMsg {
26
+ type: "proxy.error";
27
+ id: string;
28
+ payload: TransportErrorPayload;
29
+ }
30
+ export interface TransportBillingInfo {
31
+ premiumCost: number;
32
+ tier: string;
33
+ provider: string;
34
+ model: string;
35
+ requestCategory?: ProxyRequestCategory;
36
+ quotaSource?: ProxyQuotaSource;
37
+ keySource?: ProxyKeySource;
38
+ }
39
+ export interface AgentExecutionRefs {
40
+ executionId?: string;
41
+ rootExecutionId?: string;
42
+ parentExecutionId?: string;
43
+ sidechainId?: string;
44
+ attemptId?: string;
45
+ outcomeId?: string;
46
+ }
47
+ export type AgentExecutionSource = "turn" | "resume" | "replay" | "sidechain";
48
+ export type AgentAttemptSource = "primary" | "retry" | "fallback" | "repair";
49
+ export type AgentSidechainType = "research" | "planner" | "plan-repair" | "code-repair" | "media-prep" | "custom";
50
+ export type AgentSidechainRole = "leaf" | "orchestrator";
51
+ export type AgentSidechainMergePolicy = "summary-only" | "append-messages" | "replace-context" | "manual";
52
+ export type AgentExecutionSessionStatus = "running" | "interrupted" | "completed" | "failed" | "cancelled";
53
+ export type ControlApprovalDecision = "approved" | "denied" | "expired" | "cancelled";
54
+ export type ControlApprovalSource = "user" | "policy" | "system" | "replay";
55
+ export type ExecutionInterruptReason = "approval-wait" | "gateway-disconnected" | "policy-pause" | "user-pause" | "tool-backpressure" | "lease-expired";
56
+ export type ExecutionResumeSource = "user" | "gateway-reconnect" | "policy" | "system";
57
+ export type ExecutionCancelReason = "user-cancel" | "policy-cancel" | "lease-expired" | "superseded" | "branch-cancel";
@@ -0,0 +1,208 @@
1
+ import type { AgentExecutionRefs, TransportResponsePayload, TransportUsageInfo, TransportBillingInfo } from "./transport.js";
2
+ import type { ModelSelectionReason } from "./session.js";
3
+ import type { TransportCapabilitySummaryContract, TransportApprovalRequiredToolHintEntry, TransportToolEligibilitySummaryEntry, ToolExecutionStepContext, ToolInvokeApprovalDescriptor, AgentTurnConversation, AgentTurnExperience, AgentTurnRequestSpec, AgentTurnLocalContext, AgentTurnClientHints } from "./capability-transport.js";
4
+ export interface AgentTurnStartPayload extends AgentExecutionRefs {
5
+ sessionId: string;
6
+ turnId: string;
7
+ deviceId?: string;
8
+ principalId?: string;
9
+ entitlementId?: string;
10
+ subscriptionKey?: string;
11
+ conversation: AgentTurnConversation;
12
+ experience?: AgentTurnExperience;
13
+ request?: AgentTurnRequestSpec;
14
+ localContext?: AgentTurnLocalContext;
15
+ clientHints?: AgentTurnClientHints;
16
+ }
17
+ export interface AgentTurnStartMsg extends AgentTurnStartPayload {
18
+ type: "agent.turn.start";
19
+ id: string;
20
+ }
21
+ export interface AgentTurnThinkingPayload extends AgentExecutionRefs {
22
+ sessionId: string;
23
+ turnId: string;
24
+ stage?: "routing" | "execution" | "tool-wait";
25
+ message?: string;
26
+ }
27
+ export interface AgentTurnThinkingMsg {
28
+ type: "agent.turn.thinking";
29
+ id: string;
30
+ payload: AgentTurnThinkingPayload;
31
+ }
32
+ export interface AgentTurnDeltaPayload extends AgentExecutionRefs {
33
+ sessionId: string;
34
+ turnId: string;
35
+ chunk: string;
36
+ }
37
+ export interface AgentTurnDeltaMsg {
38
+ type: "agent.turn.delta";
39
+ id: string;
40
+ payload: AgentTurnDeltaPayload;
41
+ }
42
+ export interface AgentTurnToolPlannedPayload extends AgentExecutionRefs {
43
+ sessionId: string;
44
+ turnId: string;
45
+ callId: string;
46
+ toolName: string;
47
+ arguments?: Record<string, unknown>;
48
+ approvalMode?: "user-confirm" | "pre-authorized";
49
+ }
50
+ export interface AgentTurnToolPlannedMsg {
51
+ type: "agent.turn.tool-planned";
52
+ id: string;
53
+ payload: AgentTurnToolPlannedPayload;
54
+ }
55
+ export interface AgentTurnToolRunningPayload extends AgentExecutionRefs {
56
+ sessionId: string;
57
+ turnId: string;
58
+ callId: string;
59
+ toolName: string;
60
+ }
61
+ export interface AgentTurnToolRunningMsg {
62
+ type: "agent.turn.tool-running";
63
+ id: string;
64
+ payload: AgentTurnToolRunningPayload;
65
+ }
66
+ export interface AgentTurnCompletedPayload extends AgentExecutionRefs {
67
+ sessionId: string;
68
+ turnId: string;
69
+ outcomeId: string;
70
+ resolvedModel?: string;
71
+ modelSelectionReason?: ModelSelectionReason;
72
+ capabilitySummary?: TransportCapabilitySummaryContract;
73
+ approvalRequiredToolHint?: TransportApprovalRequiredToolHintEntry[];
74
+ eligibleToolSummary?: TransportToolEligibilitySummaryEntry[];
75
+ ineligibleToolSummary?: TransportToolEligibilitySummaryEntry[];
76
+ response?: TransportResponsePayload;
77
+ usage?: TransportUsageInfo;
78
+ billed?: TransportBillingInfo | null;
79
+ }
80
+ export interface AgentTurnCompletedMsg {
81
+ type: "agent.turn.completed";
82
+ id: string;
83
+ payload: AgentTurnCompletedPayload;
84
+ }
85
+ export interface BillingRecordedPayload extends AgentExecutionRefs {
86
+ sessionId: string;
87
+ turnId: string;
88
+ outcomeId: string;
89
+ billed: TransportBillingInfo;
90
+ }
91
+ export interface BillingRecordedMsg {
92
+ type: "billing.recorded";
93
+ id: string;
94
+ payload: BillingRecordedPayload;
95
+ }
96
+ export interface AgentTurnFailedPayload extends AgentExecutionRefs {
97
+ sessionId: string;
98
+ turnId: string;
99
+ outcomeId: string;
100
+ code: string;
101
+ error: string;
102
+ retryable: boolean;
103
+ }
104
+ export interface AgentTurnFailedMsg {
105
+ type: "agent.turn.failed";
106
+ id: string;
107
+ payload: AgentTurnFailedPayload;
108
+ }
109
+ export interface ToolInvokePlannedPayload extends AgentExecutionRefs, ToolExecutionStepContext {
110
+ sessionId: string;
111
+ turnId: string;
112
+ callId: string;
113
+ toolName: string;
114
+ arguments?: Record<string, unknown>;
115
+ approvalMode?: "user-confirm" | "pre-authorized";
116
+ }
117
+ export interface ToolInvokePlannedMsg {
118
+ type: "tool.invoke.planned";
119
+ id: string;
120
+ payload: ToolInvokePlannedPayload;
121
+ }
122
+ export interface ToolInvokeStartedPayload extends AgentExecutionRefs, ToolExecutionStepContext {
123
+ sessionId: string;
124
+ turnId: string;
125
+ callId: string;
126
+ toolName: string;
127
+ }
128
+ export interface ToolInvokeStartedMsg {
129
+ type: "tool.invoke.started";
130
+ id: string;
131
+ payload: ToolInvokeStartedPayload;
132
+ }
133
+ export interface ToolInvokeRequestPayload extends AgentExecutionRefs, ToolExecutionStepContext {
134
+ sessionId: string;
135
+ turnId: string;
136
+ callId: string;
137
+ tool: {
138
+ name: string;
139
+ arguments: Record<string, unknown>;
140
+ };
141
+ approval?: ToolInvokeApprovalDescriptor;
142
+ }
143
+ export interface ToolInvokeRequestMsg {
144
+ type: "tool.invoke.request";
145
+ id: string;
146
+ payload: ToolInvokeRequestPayload;
147
+ }
148
+ export interface ToolInvokeResultPayload extends AgentExecutionRefs, ToolExecutionStepContext {
149
+ sessionId: string;
150
+ turnId: string;
151
+ callId: string;
152
+ outcomeId: string;
153
+ ok: boolean;
154
+ payload?: unknown;
155
+ error?: string;
156
+ }
157
+ export interface ToolInvokeResultMsg {
158
+ type: "tool.invoke.result";
159
+ id: string;
160
+ payload: ToolInvokeResultPayload;
161
+ }
162
+ export type LocalExecutionEnvelopeKind = "started" | "partial" | "checkpoint" | "artifact" | "final" | "error";
163
+ export type LocalExecutionEnvelopeStage = "turn" | "tool" | "checkpoint" | "artifact" | "control" | "memory";
164
+ export interface LocalExecutionEnvelopePayload extends AgentExecutionRefs, ToolExecutionStepContext {
165
+ sessionId: string;
166
+ turnId?: string;
167
+ kind: LocalExecutionEnvelopeKind;
168
+ stage: LocalExecutionEnvelopeStage;
169
+ eventType: string;
170
+ emittedAtMs: number;
171
+ callId?: string;
172
+ approvalId?: string;
173
+ checkpointId?: string;
174
+ restoreId?: string;
175
+ summary?: string;
176
+ data?: Record<string, unknown>;
177
+ }
178
+ export interface LocalExecutionEnvelopeMsg {
179
+ type: "local.execution.envelope";
180
+ id: string;
181
+ payload: LocalExecutionEnvelopePayload;
182
+ }
183
+ export interface AgentSkillCreatePayload {
184
+ sessionId: string;
185
+ turnId: string;
186
+ executionId?: string;
187
+ suggestedName: string;
188
+ description: string;
189
+ tools: string[];
190
+ stepCount: number;
191
+ }
192
+ export interface AgentSkillCreateMsg {
193
+ type: "agent.skill.create";
194
+ id: string;
195
+ payload: AgentSkillCreatePayload;
196
+ }
197
+ export interface AgentSkillImprovePayload {
198
+ sessionId: string;
199
+ turnId: string;
200
+ executionId?: string;
201
+ skillName: string;
202
+ reason: string;
203
+ }
204
+ export interface AgentSkillImproveMsg {
205
+ type: "agent.skill.improve";
206
+ id: string;
207
+ payload: AgentSkillImprovePayload;
208
+ }