@sctg/cline-shared 3.84.0-beta.20260524130712

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 (83) hide show
  1. package/README.md +47 -0
  2. package/dist/agent.d.ts +388 -0
  3. package/dist/agents/index.d.ts +1 -0
  4. package/dist/agents/types.d.ts +967 -0
  5. package/dist/automation/index.d.ts +3 -0
  6. package/dist/automation/index.js +65 -0
  7. package/dist/automation/schemas.d.ts +89 -0
  8. package/dist/automation/types.d.ts +151 -0
  9. package/dist/connectors/events.d.ts +93 -0
  10. package/dist/connectors/options.d.ts +174 -0
  11. package/dist/cron/cron-spec-types.d.ts +94 -0
  12. package/dist/cron/index.d.ts +1 -0
  13. package/dist/db/index.d.ts +2 -0
  14. package/dist/db/index.js +80 -0
  15. package/dist/db/sqlite-db.d.ts +24 -0
  16. package/dist/dispose.d.ts +13 -0
  17. package/dist/extensions/context.d.ts +76 -0
  18. package/dist/extensions/contribution-registry.d.ts +195 -0
  19. package/dist/extensions/plugin.d.ts +1 -0
  20. package/dist/hooks/contracts.d.ts +9 -0
  21. package/dist/hooks/events.d.ts +194 -0
  22. package/dist/hub.d.ts +470 -0
  23. package/dist/index.browser.d.ts +61 -0
  24. package/dist/index.browser.js +76 -0
  25. package/dist/index.d.ts +69 -0
  26. package/dist/index.js +163 -0
  27. package/dist/llms/ai-sdk-format.d.ts +55 -0
  28. package/dist/llms/gateway.d.ts +145 -0
  29. package/dist/llms/messages.d.ts +149 -0
  30. package/dist/llms/model-info.d.ts +120 -0
  31. package/dist/llms/reasoning-effort.d.ts +21 -0
  32. package/dist/llms/requests.d.ts +2 -0
  33. package/dist/llms/tokens.d.ts +7 -0
  34. package/dist/llms/tools.d.ts +86 -0
  35. package/dist/logging/logger.d.ts +37 -0
  36. package/dist/parse/error.d.ts +2 -0
  37. package/dist/parse/headers/utils.d.ts +1 -0
  38. package/dist/parse/json.d.ts +3 -0
  39. package/dist/parse/shell.d.ts +2 -0
  40. package/dist/parse/string.d.ts +4 -0
  41. package/dist/parse/time.d.ts +9 -0
  42. package/dist/parse/zod.d.ts +12 -0
  43. package/dist/prompt/cline.d.ts +24 -0
  44. package/dist/prompt/format.d.ts +11 -0
  45. package/dist/prompt/system.d.ts +2 -0
  46. package/dist/remote-config/artifact-store.d.ts +13 -0
  47. package/dist/remote-config/blob-storage.d.ts +47 -0
  48. package/dist/remote-config/bundle.d.ts +136 -0
  49. package/dist/remote-config/constants.d.ts +5 -0
  50. package/dist/remote-config/index.d.ts +9 -0
  51. package/dist/remote-config/index.js +76 -0
  52. package/dist/remote-config/materializer.d.ts +4 -0
  53. package/dist/remote-config/paths.d.ts +10 -0
  54. package/dist/remote-config/runtime.d.ts +20 -0
  55. package/dist/remote-config/schema.d.ts +408 -0
  56. package/dist/remote-config/telemetry.d.ts +9 -0
  57. package/dist/rpc/index.d.ts +5 -0
  58. package/dist/rpc/runtime.d.ts +322 -0
  59. package/dist/rpc/team-progress.d.ts +53 -0
  60. package/dist/runtime/build-env.d.ts +13 -0
  61. package/dist/runtime/cline-environment.d.ts +17 -0
  62. package/dist/runtime/hub-daemon-env.d.ts +2 -0
  63. package/dist/services/telemetry-config.d.ts +6 -0
  64. package/dist/services/telemetry.d.ts +133 -0
  65. package/dist/session/hook-context.d.ts +12 -0
  66. package/dist/session/index.d.ts +1 -0
  67. package/dist/session/records.d.ts +31 -0
  68. package/dist/session/runtime-config.d.ts +26 -0
  69. package/dist/session/runtime-env.d.ts +8 -0
  70. package/dist/session/workspace.d.ts +28 -0
  71. package/dist/storage/index.d.ts +2 -0
  72. package/dist/storage/index.js +1 -0
  73. package/dist/storage/path-resolution.d.ts +11 -0
  74. package/dist/storage/paths.d.ts +86 -0
  75. package/dist/team/index.d.ts +2 -0
  76. package/dist/team/schema.d.ts +411 -0
  77. package/dist/team/types.d.ts +196 -0
  78. package/dist/tools/create.d.ts +22 -0
  79. package/dist/types/auth.d.ts +20 -0
  80. package/dist/types/index.d.ts +2 -0
  81. package/dist/types/vcr.d.ts +14 -0
  82. package/dist/vcr.d.ts +41 -0
  83. package/package.json +63 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Sanitizes unpaired/lone Unicode surrogates in text content.
3
+ *
4
+ * Lone surrogates (high surrogates without matching low surrogates, or vice versa)
5
+ * can cause JSON serialization issues and downstream processing errors when sending
6
+ * text to LLM providers. This function replaces them with the Unicode replacement
7
+ * character (U+FFFD).
8
+ *
9
+ * @param content - The string to sanitize
10
+ * @returns The string with lone surrogates replaced by U+FFFD
11
+ */
12
+ export declare function sanitizeSurrogates(content: string): string;
13
+ export type AiSdkFormatterMessageRole = "user" | "assistant" | "tool";
14
+ export type AiSdkFormatterPart = {
15
+ type: "text";
16
+ text: string;
17
+ providerOptions?: Record<string, Record<string, unknown>>;
18
+ } | {
19
+ type: "reasoning";
20
+ text: string;
21
+ providerOptions?: Record<string, Record<string, unknown>>;
22
+ } | {
23
+ type: "image";
24
+ image: string | Uint8Array | ArrayBuffer | URL;
25
+ mediaType?: string;
26
+ } | {
27
+ type: "file";
28
+ path: string;
29
+ content: string;
30
+ } | {
31
+ type: "tool-call";
32
+ toolCallId: string;
33
+ toolName: string;
34
+ input: unknown;
35
+ providerOptions?: Record<string, Record<string, unknown>>;
36
+ } | {
37
+ type: "tool-result";
38
+ toolCallId: string;
39
+ toolName: string;
40
+ output: unknown;
41
+ isError?: boolean;
42
+ };
43
+ export interface AiSdkFormatterMessage {
44
+ role: AiSdkFormatterMessageRole;
45
+ content: string | AiSdkFormatterPart[];
46
+ }
47
+ export type AiSdkMessagePart = Record<string, unknown>;
48
+ export type AiSdkMessage = {
49
+ role: "system" | "user" | "assistant" | "tool";
50
+ content: string | AiSdkMessagePart[];
51
+ };
52
+ export declare function toAiSdkToolResultOutput(output: unknown, isError?: boolean): Record<string, unknown>;
53
+ export declare function formatMessagesForAiSdk(systemContent: string | AiSdkMessagePart[] | undefined, messages: readonly AiSdkFormatterMessage[], options?: {
54
+ assistantToolCallArgKey?: "args" | "input";
55
+ }): AiSdkMessage[];
@@ -0,0 +1,145 @@
1
+ import type { AgentMessage, AgentModelEvent, AgentToolDefinition } from "../agent";
2
+ import type { BasicLogger } from "../logging/logger";
3
+ import type { ProviderCapability } from "../rpc/runtime";
4
+ import type { ITelemetryService } from "../services/telemetry";
5
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
6
+ [key: string]: JsonValue | undefined;
7
+ };
8
+ export type GatewayModelCapability = "text" | "tools" | "reasoning" | "prompt-cache" | "images" | "audio" | "structured-output";
9
+ export type GatewayPromptCacheStrategy = "anthropic-automatic";
10
+ export type GatewayUsageCostDisplay = "show" | "hide";
11
+ export type GatewayPromptCacheFormat = "anthropic-cache-control";
12
+ export type GatewayReasoningFormat = "anthropic-thinking" | "glm-thinking";
13
+ export type GatewayModelRoute = {
14
+ matcher: "anthropic-compatible";
15
+ } | {
16
+ matcher: "model-family";
17
+ family: string;
18
+ requiredCapability?: GatewayModelCapability;
19
+ } | {
20
+ matcher: "model-id";
21
+ modelId: string;
22
+ requiredCapability?: GatewayModelCapability;
23
+ };
24
+ export interface GatewayProviderRouting {
25
+ promptCache?: {
26
+ format: GatewayPromptCacheFormat;
27
+ routes: GatewayModelRoute[];
28
+ };
29
+ reasoning?: {
30
+ format: GatewayReasoningFormat;
31
+ routes: GatewayModelRoute[];
32
+ };
33
+ }
34
+ export interface GatewayProviderMetadata {
35
+ promptCacheStrategy?: GatewayPromptCacheStrategy;
36
+ usageCostDisplay?: GatewayUsageCostDisplay;
37
+ routing?: GatewayProviderRouting;
38
+ [key: string]: JsonValue | GatewayProviderRouting | undefined;
39
+ }
40
+ export interface GatewayModelDefinition {
41
+ id: string;
42
+ name: string;
43
+ providerId: string;
44
+ description?: string;
45
+ contextWindow?: number;
46
+ maxInputTokens?: number;
47
+ maxOutputTokens?: number;
48
+ capabilities?: readonly GatewayModelCapability[];
49
+ metadata?: Record<string, JsonValue | undefined>;
50
+ }
51
+ export interface GatewayProviderManifest {
52
+ id: string;
53
+ name: string;
54
+ description?: string;
55
+ defaultModelId: string;
56
+ models: readonly GatewayModelDefinition[];
57
+ capabilities?: readonly ProviderCapability[];
58
+ env?: readonly ("browser" | "node")[];
59
+ api?: string;
60
+ apiKeyEnv?: readonly string[];
61
+ docsUrl?: string;
62
+ metadata?: GatewayProviderMetadata;
63
+ }
64
+ export interface GatewayProviderSettings {
65
+ apiKey?: string;
66
+ apiKeyResolver?: () => string | undefined | Promise<string | undefined>;
67
+ apiKeyEnv?: readonly string[];
68
+ baseUrl?: string;
69
+ headers?: Record<string, string>;
70
+ timeoutMs?: number;
71
+ fetch?: typeof fetch;
72
+ options?: Record<string, unknown>;
73
+ metadata?: GatewayProviderMetadata;
74
+ }
75
+ export interface GatewayResolvedProviderConfig extends GatewayProviderSettings {
76
+ providerId: string;
77
+ }
78
+ export interface GatewayProviderConfig extends GatewayProviderSettings {
79
+ providerId: string;
80
+ enabled?: boolean;
81
+ defaultModelId?: string;
82
+ models?: readonly Omit<GatewayModelDefinition, "providerId">[];
83
+ }
84
+ export interface GatewayModelSelection {
85
+ providerId: string;
86
+ modelId?: string;
87
+ }
88
+ export interface GatewayResolvedModel {
89
+ provider: GatewayProviderManifest;
90
+ model: GatewayModelDefinition;
91
+ }
92
+ export interface GatewayProviderContext {
93
+ provider: GatewayProviderManifest;
94
+ model: GatewayModelDefinition;
95
+ config: GatewayResolvedProviderConfig;
96
+ signal?: AbortSignal;
97
+ logger?: BasicLogger;
98
+ telemetry?: ITelemetryService;
99
+ }
100
+ export interface GatewayStreamRequest {
101
+ providerId: string;
102
+ modelId: string;
103
+ systemPrompt?: string;
104
+ messages: readonly AgentMessage[];
105
+ tools?: readonly AgentToolDefinition[];
106
+ temperature?: number;
107
+ maxTokens?: number;
108
+ metadata?: Record<string, unknown>;
109
+ reasoning?: {
110
+ enabled?: boolean;
111
+ effort?: "low" | "medium" | "high";
112
+ budgetTokens?: number;
113
+ };
114
+ signal?: AbortSignal;
115
+ }
116
+ export interface GatewayProvider {
117
+ stream(request: GatewayStreamRequest, context: GatewayProviderContext): AsyncIterable<AgentModelEvent> | Promise<AsyncIterable<AgentModelEvent>>;
118
+ }
119
+ export type GatewayProviderFactory = (config: GatewayResolvedProviderConfig) => GatewayProvider | Promise<GatewayProvider>;
120
+ export interface GatewayProviderRegistration {
121
+ manifest: GatewayProviderManifest;
122
+ defaults?: GatewayProviderSettings;
123
+ createProvider?: GatewayProviderFactory;
124
+ loadProvider?: () => Promise<Pick<GatewayProviderRegistration, "createProvider">>;
125
+ }
126
+ export interface GatewayModelHandleOptions {
127
+ tools?: readonly AgentToolDefinition[];
128
+ temperature?: number;
129
+ maxTokens?: number;
130
+ metadata?: Record<string, unknown>;
131
+ reasoning?: {
132
+ enabled?: boolean;
133
+ effort?: "low" | "medium" | "high";
134
+ budgetTokens?: number;
135
+ };
136
+ signal?: AbortSignal;
137
+ }
138
+ export interface GatewayConfig {
139
+ builtins?: false | readonly string[];
140
+ providers?: readonly GatewayProviderRegistration[];
141
+ providerConfigs?: readonly GatewayProviderConfig[];
142
+ fetch?: typeof fetch;
143
+ logger?: BasicLogger;
144
+ telemetry?: ITelemetryService;
145
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Message Types
3
+ *
4
+ * Standardized message format for input to providers.
5
+ * This is a simplified, provider-agnostic format that can be
6
+ * converted to any provider's native format.
7
+ */
8
+ /**
9
+ * Message roles
10
+ */
11
+ export type MessageRole = "user" | "assistant";
12
+ /**
13
+ * Text content block
14
+ */
15
+ export interface TextContent {
16
+ type: "text";
17
+ text: string;
18
+ /** Thought signature for this text part (Gemini) */
19
+ signature?: string;
20
+ }
21
+ /**
22
+ * File content block for Cline
23
+ */
24
+ export interface FileContent {
25
+ type: "file";
26
+ content: string;
27
+ /** Absolute Path */
28
+ path: string;
29
+ source?: string;
30
+ }
31
+ /**
32
+ * Image content block
33
+ */
34
+ export interface ImageContent {
35
+ type: "image";
36
+ /** Base64 encoded image data */
37
+ data: string;
38
+ /** MIME type (e.g., "image/png", "image/jpeg") */
39
+ mediaType: string;
40
+ }
41
+ /**
42
+ * Tool use content block (assistant's tool call)
43
+ */
44
+ export interface ToolUseContent {
45
+ type: "tool_use";
46
+ /** Unique ID for this tool call */
47
+ id: string;
48
+ /** Provider-native call ID for this tool call (if available) */
49
+ call_id?: string;
50
+ /** Name of the tool being called */
51
+ name: string;
52
+ /** Arguments for the tool call */
53
+ input: Record<string, unknown>;
54
+ /** Thought signature for this function call part (Gemini) */
55
+ signature?: string;
56
+ }
57
+ /**
58
+ * Tool result content block (user's response to tool call)
59
+ */
60
+ export interface ToolResultContent {
61
+ type: "tool_result";
62
+ /** ID of the tool call this is responding to */
63
+ tool_use_id: string;
64
+ /** Name of the tool that generated this result */
65
+ name: string;
66
+ /** Result content (can be text or error) */
67
+ content: string | Array<TextContent | ImageContent | FileContent>;
68
+ /** Whether this result represents an error */
69
+ is_error?: boolean;
70
+ }
71
+ /**
72
+ * Thinking/reasoning content block
73
+ */
74
+ export interface ThinkingContent {
75
+ type: "thinking";
76
+ /** The thinking/reasoning text */
77
+ thinking: string;
78
+ /** Signature for the thinking block (provider-specific) */
79
+ signature?: string;
80
+ /** Provider-native call ID for this reasoning block (if available) */
81
+ call_id?: string;
82
+ /** Structured reasoning details that can be replayed for tool-call continuation */
83
+ details?: unknown[];
84
+ /** Backward-compatible alias used by some internal processors */
85
+ summary?: unknown[];
86
+ }
87
+ /**
88
+ * Redacted thinking content block
89
+ */
90
+ export interface RedactedThinkingContent {
91
+ type: "redacted_thinking";
92
+ /** Encrypted/redacted data */
93
+ data: string;
94
+ /** Provider-native call ID for this reasoning block (if available) */
95
+ call_id?: string;
96
+ }
97
+ /**
98
+ * Union of all content block types
99
+ */
100
+ export type ContentBlock = TextContent | ImageContent | ToolUseContent | ToolResultContent | ThinkingContent | FileContent | RedactedThinkingContent;
101
+ /**
102
+ * A single message in the conversation
103
+ */
104
+ export interface Message {
105
+ /** Message role */
106
+ role: MessageRole;
107
+ /** Message content - can be a simple string or array of content blocks */
108
+ content: string | ContentBlock[];
109
+ }
110
+ /**
111
+ * Extended message with metadata (used for storage/history)
112
+ */
113
+ export interface MessageWithMetadata extends Message {
114
+ /** Unique message ID */
115
+ id?: string;
116
+ /** Logical agent kind for persisted session/history consumers */
117
+ agent?: string;
118
+ /** Concrete session id that owns this persisted message */
119
+ sessionId?: string;
120
+ /** Additional message metadata for storage/history consumers */
121
+ metadata?: Record<string, unknown>;
122
+ /** Model info at the time of generation */
123
+ modelInfo?: {
124
+ id: string;
125
+ provider: string;
126
+ family?: string;
127
+ };
128
+ /** Token usage metrics */
129
+ metrics?: {
130
+ inputTokens?: number;
131
+ outputTokens?: number;
132
+ cacheReadTokens?: number;
133
+ cacheWriteTokens?: number;
134
+ cost?: number;
135
+ };
136
+ /** Timestamp of when the message was created */
137
+ ts?: number;
138
+ }
139
+ /**
140
+ * Tool definition for native tool calling
141
+ */
142
+ export interface ToolDefinition {
143
+ /** Tool name */
144
+ name: string;
145
+ /** Tool description */
146
+ description: string;
147
+ /** JSON Schema for the tool's input parameters */
148
+ inputSchema: Record<string, unknown>;
149
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Model Information Types
3
+ *
4
+ * Zod schemas and inferred types for model capabilities, pricing,
5
+ * and metadata. These live in shared so that agent types can reference
6
+ * ModelInfo without depending on @cline/llms.
7
+ */
8
+ import { z } from "zod";
9
+ export declare const ApiFormatSchema: z.ZodEnum<{
10
+ default: "default";
11
+ "openai-responses": "openai-responses";
12
+ r1: "r1";
13
+ }>;
14
+ export type ApiFormat = z.infer<typeof ApiFormatSchema>;
15
+ export declare const ApiFormat: {
16
+ readonly DEFAULT: "default";
17
+ readonly OPENAI_RESPONSES: "openai-responses";
18
+ readonly R1: "r1";
19
+ };
20
+ export declare const ModelCapabilitySchema: z.ZodEnum<{
21
+ images: "images";
22
+ tools: "tools";
23
+ streaming: "streaming";
24
+ "prompt-cache": "prompt-cache";
25
+ reasoning: "reasoning";
26
+ "reasoning-effort": "reasoning-effort";
27
+ "computer-use": "computer-use";
28
+ "global-endpoint": "global-endpoint";
29
+ structured_output: "structured_output";
30
+ temperature: "temperature";
31
+ files: "files";
32
+ }>;
33
+ export type ModelCapability = z.infer<typeof ModelCapabilitySchema>;
34
+ export declare const ModelStatusSchema: z.ZodEnum<{
35
+ active: "active";
36
+ preview: "preview";
37
+ deprecated: "deprecated";
38
+ legacy: "legacy";
39
+ }>;
40
+ export type ModelStatus = z.infer<typeof ModelStatusSchema>;
41
+ export declare const ModelPricingSchema: z.ZodObject<{
42
+ input: z.ZodOptional<z.ZodNumber>;
43
+ output: z.ZodOptional<z.ZodNumber>;
44
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
45
+ cacheRead: z.ZodOptional<z.ZodNumber>;
46
+ }, z.core.$strip>;
47
+ export type ModelPricing = z.infer<typeof ModelPricingSchema>;
48
+ export declare const ThinkingConfigSchema: z.ZodObject<{
49
+ maxBudget: z.ZodOptional<z.ZodNumber>;
50
+ outputPrice: z.ZodOptional<z.ZodNumber>;
51
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
52
+ low: "low";
53
+ high: "high";
54
+ }>>;
55
+ }, z.core.$strip>;
56
+ export type ThinkingConfig = z.infer<typeof ThinkingConfigSchema>;
57
+ export declare const ModelMetadataSchema: z.ZodObject<{
58
+ reasoningDefaultOn: z.ZodOptional<z.ZodBoolean>;
59
+ }, z.core.$catchall<z.ZodUnknown>>;
60
+ export type ModelMetadata = z.infer<typeof ModelMetadataSchema>;
61
+ export declare const ModelInfoSchema: z.ZodObject<{
62
+ id: z.ZodString;
63
+ name: z.ZodOptional<z.ZodString>;
64
+ description: z.ZodOptional<z.ZodString>;
65
+ maxTokens: z.ZodOptional<z.ZodNumber>;
66
+ contextWindow: z.ZodOptional<z.ZodNumber>;
67
+ maxInputTokens: z.ZodOptional<z.ZodNumber>;
68
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
69
+ images: "images";
70
+ tools: "tools";
71
+ streaming: "streaming";
72
+ "prompt-cache": "prompt-cache";
73
+ reasoning: "reasoning";
74
+ "reasoning-effort": "reasoning-effort";
75
+ "computer-use": "computer-use";
76
+ "global-endpoint": "global-endpoint";
77
+ structured_output: "structured_output";
78
+ temperature: "temperature";
79
+ files: "files";
80
+ }>>>;
81
+ apiFormat: z.ZodOptional<z.ZodEnum<{
82
+ default: "default";
83
+ "openai-responses": "openai-responses";
84
+ r1: "r1";
85
+ }>>;
86
+ systemRole: z.ZodOptional<z.ZodEnum<{
87
+ system: "system";
88
+ developer: "developer";
89
+ }>>;
90
+ temperature: z.ZodOptional<z.ZodNumber>;
91
+ pricing: z.ZodOptional<z.ZodObject<{
92
+ input: z.ZodOptional<z.ZodNumber>;
93
+ output: z.ZodOptional<z.ZodNumber>;
94
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
95
+ cacheRead: z.ZodOptional<z.ZodNumber>;
96
+ }, z.core.$strip>>;
97
+ thinkingConfig: z.ZodOptional<z.ZodObject<{
98
+ maxBudget: z.ZodOptional<z.ZodNumber>;
99
+ outputPrice: z.ZodOptional<z.ZodNumber>;
100
+ thinkingLevel: z.ZodOptional<z.ZodEnum<{
101
+ low: "low";
102
+ high: "high";
103
+ }>>;
104
+ }, z.core.$strip>>;
105
+ status: z.ZodOptional<z.ZodEnum<{
106
+ active: "active";
107
+ preview: "preview";
108
+ deprecated: "deprecated";
109
+ legacy: "legacy";
110
+ }>>;
111
+ deprecationNotice: z.ZodOptional<z.ZodString>;
112
+ replacedBy: z.ZodOptional<z.ZodString>;
113
+ releaseDate: z.ZodOptional<z.ZodString>;
114
+ deprecationDate: z.ZodOptional<z.ZodString>;
115
+ family: z.ZodOptional<z.ZodString>;
116
+ metadata: z.ZodOptional<z.ZodObject<{
117
+ reasoningDefaultOn: z.ZodOptional<z.ZodBoolean>;
118
+ }, z.core.$catchall<z.ZodUnknown>>>;
119
+ }, z.core.$strip>;
120
+ export type ModelInfo = z.infer<typeof ModelInfoSchema>;
@@ -0,0 +1,21 @@
1
+ export declare const REASONING_EFFORT_RATIOS: {
2
+ readonly xhigh: 0.95;
3
+ readonly high: 0.8;
4
+ readonly medium: 0.5;
5
+ readonly low: 0.2;
6
+ readonly minimal: 0.1;
7
+ readonly none: 0;
8
+ };
9
+ export type ReasoningEffortValue = keyof typeof REASONING_EFFORT_RATIOS;
10
+ export declare const DEFAULT_REASONING_EFFORT: ReasoningEffortValue | undefined;
11
+ export declare function resolveEffectiveReasoningEffort(reasoningEffort?: string, thinking?: boolean): ReasoningEffortValue | undefined;
12
+ export declare function resolveReasoningEffortRatio(effort?: string, options?: {
13
+ fallbackEffort?: ReasoningEffortValue;
14
+ }): number | undefined;
15
+ export declare function resolveReasoningBudgetFromRatio(options: {
16
+ effort?: string;
17
+ maxBudget: number;
18
+ scaleTokens?: number;
19
+ minimumBudget?: number;
20
+ fallbackEffort?: ReasoningEffortValue;
21
+ }): number | undefined;
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_REQUEST_HEADERS: Record<string, string>;
2
+ export declare function serializeAbortReason(reason: unknown): unknown;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Conservative chars-per-token approximation used for compaction triggering
3
+ * and request-size diagnostics. Uses 3 chars/token (slightly over-counts vs
4
+ * the conventional 4) so trigger thresholds fire before provider rejection
5
+ * rather than after.
6
+ */
7
+ export declare function estimateTokens(chars: number): number;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Shared tool policy and execution record types.
3
+ */
4
+ import { z } from "zod";
5
+ export interface ToolPolicy {
6
+ /**
7
+ * Whether the tool can be executed at all.
8
+ * @default true
9
+ */
10
+ enabled?: boolean;
11
+ /**
12
+ * Whether this tool can run without asking the client for approval.
13
+ * @default true
14
+ */
15
+ autoApprove?: boolean;
16
+ }
17
+ /**
18
+ * Record of a tool call execution
19
+ */
20
+ export interface ToolCallRecord {
21
+ /** Unique identifier for this tool call */
22
+ id: string;
23
+ /** Name of the tool that was called */
24
+ name: string;
25
+ /** Input passed to the tool */
26
+ input: unknown;
27
+ /** Output returned from the tool (if successful) */
28
+ output: unknown;
29
+ /** Error message (if the tool failed) */
30
+ error?: string;
31
+ /** Time taken to execute the tool in milliseconds */
32
+ durationMs: number;
33
+ /** Timestamp when the tool call started */
34
+ startedAt: Date;
35
+ /** Timestamp when the tool call ended */
36
+ endedAt: Date;
37
+ }
38
+ export interface ToolApprovalRequest {
39
+ /**
40
+ * Core/hub runtime session identifier.
41
+ *
42
+ * This is the routing and lifecycle id for the task/session that owns the
43
+ * tool call. Hosts and hub transports use it to deliver approval events to
44
+ * clients subscribed to that session and to correlate approval responses
45
+ * with the pending runtime session. It should not be used as the transcript
46
+ * id for model history.
47
+ */
48
+ sessionId: string;
49
+ /**
50
+ * Agent instance identifier.
51
+ *
52
+ * This identifies the lead or delegated agent that requested the tool call.
53
+ * It is used for attribution in approval prompts, events, telemetry, and
54
+ * team/sub-agent flows. It is not a hub routing key and should not be used
55
+ * to find the owning runtime session.
56
+ */
57
+ agentId: string;
58
+ /**
59
+ * Agent conversation/transcript identifier.
60
+ *
61
+ * This identifies the model conversation that produced the tool call. Tools,
62
+ * hooks, telemetry, and persisted session metadata use it to correlate work
63
+ * with the agent's message history. It is contextual data, not the hub event
64
+ * routing key.
65
+ */
66
+ conversationId: string;
67
+ iteration: number;
68
+ toolCallId: string;
69
+ toolName: string;
70
+ input: unknown;
71
+ policy: ToolPolicy;
72
+ }
73
+ export interface ToolApprovalResult {
74
+ approved: boolean;
75
+ reason?: string;
76
+ }
77
+ export declare const ToolCallRecordSchema: z.ZodObject<{
78
+ id: z.ZodString;
79
+ name: z.ZodString;
80
+ input: z.ZodUnknown;
81
+ output: z.ZodUnknown;
82
+ error: z.ZodOptional<z.ZodString>;
83
+ durationMs: z.ZodNumber;
84
+ startedAt: z.ZodDate;
85
+ endedAt: z.ZodDate;
86
+ }, z.core.$strip>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Cross-package logging surface for hosts that inject their own logger (for example `pino` or the VS Code API).
3
+ *
4
+ * {@link BasicLogger.debug} is for verbose diagnostics (hosts typically gate this behind a debug log level).
5
+ * {@link BasicLogger.log} is the primary channel for operational messages that are not errors.
6
+ * {@link BasicLogger.error} is optional; when omitted, hosts may route failures through {@link BasicLogger.log}
7
+ * with {@link BasicLogMetadata.severity} `"error"` or handle errors elsewhere.
8
+ *
9
+ * Use {@link noopBasicLogger} when you need a fully-defined no-op implementation.
10
+ */
11
+ /**
12
+ * Optional structured fields used across the SDK and recommended for host log backends.
13
+ * Callers may add other keys freely; these names are the shared convention for cross-component queries.
14
+ */
15
+ export interface BasicLogMetadata extends Record<string, unknown> {
16
+ sessionId?: string;
17
+ runId?: string;
18
+ providerId?: string;
19
+ toolName?: string;
20
+ durationMs?: number;
21
+ /**
22
+ * When using {@link BasicLogger.log}, disambiguates severity for backends that map a single `log`
23
+ * method onto multiple output levels (for example Pino `info` vs `warn`).
24
+ */
25
+ severity?: "info" | "warn" | "error";
26
+ }
27
+ export interface BasicLogger {
28
+ /** Verbose diagnostics; hosts should no-op or filter when not in debug mode. */
29
+ debug: (message: string, metadata?: BasicLogMetadata) => void;
30
+ /** Operational messages (replaces former `info` / non-error `warn` split). */
31
+ log: (message: string, metadata?: BasicLogMetadata) => void;
32
+ error?: (message: string, metadata?: BasicLogMetadata & {
33
+ error?: unknown;
34
+ }) => void;
35
+ }
36
+ /** All levels implemented as no-ops; safe default when no logger is injected. */
37
+ export declare const noopBasicLogger: BasicLogger;
@@ -0,0 +1,2 @@
1
+ export declare function getErrorMessage(error: unknown): string;
2
+ export declare function getErrorCode(error: unknown): string;
@@ -0,0 +1 @@
1
+ export declare function parseKeyPairsIntoRecord(value?: string): Record<string, string>;
@@ -0,0 +1,3 @@
1
+ export declare function parseJsonStream(input: unknown): unknown;
2
+ export declare function safeJsonStringify(input: unknown): string;
3
+ export declare function safeJsonParse<T>(raw: string): T | undefined;
@@ -0,0 +1,2 @@
1
+ export declare function getDefaultShell(platform: string): string;
2
+ export declare function getShellArgs(shell: string, command: string): string[];
@@ -0,0 +1,4 @@
1
+ export declare function sanitizeFileName(value: string): string;
2
+ export declare function truncateStr(str: string, maxLen: number): string;
3
+ export declare function truncateSplit(str?: string, splitBy?: string, maxLen?: number): string;
4
+ export declare function maskSecret(value: string): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parses a date string and returns a human-readable format.
3
+ * If the input is invalid, it returns the original string or a placeholder.
4
+ *
5
+ * @param dateStr - The date string to parse.
6
+ * @returns A human-readable date string or the original input if invalid.
7
+ */
8
+ export declare function formatHumanReadableDate(dateStr?: string): string;
9
+ export declare function formatUptime(ms: number): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Zod Utilities
3
+ *
4
+ * Helper functions for working with Zod schemas.
5
+ */
6
+ import { z } from "zod";
7
+ /**
8
+ * Validate input using a Zod schema
9
+ * Throws a formatted error if validation fails
10
+ */
11
+ export declare function validateWithZod<T>(schema: z.ZodType<T>, input: unknown): T;
12
+ export declare function zodToJsonSchema(schema: z.ZodTypeAny): Record<string, unknown>;