codemie-sdk 0.1.339 → 0.1.341

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -116,6 +116,161 @@ interface Integration {
116
116
  setting_type: IntegrationTypeType;
117
117
  }
118
118
 
119
+ /**
120
+ * Error models for structured error handling in CodeMie SDK responses.
121
+ *
122
+ * This module provides error classification and structured error details that match
123
+ * the CodeMie API error response format, enabling proper error handling without
124
+ * parsing error messages.
125
+ */
126
+ /**
127
+ * High-level categorization of errors in the CodeMie system.
128
+ *
129
+ * Separates errors by their source to enable proper handling and debugging.
130
+ */
131
+ declare enum ErrorCategory {
132
+ AGENT = "agent",// Agent-level errors (execution, callbacks, etc.)
133
+ TOOL = "tool",// Tool execution errors (HTTP errors, timeouts, etc.)
134
+ LLM = "llm",// LLM provider errors (rate limits, content policy, etc.)
135
+ VALIDATION = "validation"
136
+ }
137
+ /**
138
+ * Specific error codes for detailed error classification.
139
+ *
140
+ * These codes enable clients to programmatically handle different error scenarios
141
+ * without parsing error messages.
142
+ */
143
+ declare enum ErrorCode {
144
+ AGENT_TIMEOUT = "agent_timeout",
145
+ AGENT_TOKEN_LIMIT = "agent_token_limit",
146
+ AGENT_BUDGET_EXCEEDED = "agent_budget_exceeded",
147
+ AGENT_CALLBACK_FAILURE = "agent_callback_failure",
148
+ AGENT_NETWORK_ERROR = "agent_network_error",
149
+ AGENT_CONFIGURATION_ERROR = "agent_configuration_error",
150
+ AGENT_INTERNAL_ERROR = "agent_internal_error",
151
+ TOOL_AUTHENTICATION = "tool_authentication",// 401 Unauthorized
152
+ TOOL_AUTHORIZATION = "tool_authorization",// 403 Forbidden
153
+ TOOL_NOT_FOUND = "tool_not_found",// 404 Not Found
154
+ TOOL_CONFLICT = "tool_conflict",// 409 Conflict
155
+ TOOL_RATE_LIMITED = "tool_rate_limited",// 429 Too Many Requests
156
+ TOOL_SERVER_ERROR = "tool_server_error",// 5xx Server Error
157
+ TOOL_TIMEOUT = "tool_timeout",
158
+ TOOL_VALIDATION = "tool_validation",// Invalid tool input
159
+ TOOL_NETWORK_ERROR = "tool_network_error",
160
+ TOOL_EXECUTION_FAILED = "tool_execution_failed",// Generic tool failure
161
+ LLM_CONTENT_POLICY = "llm_content_policy",
162
+ LLM_CONTEXT_LENGTH = "llm_context_length",
163
+ LLM_UNAVAILABLE = "llm_unavailable",
164
+ LLM_RATE_LIMITED = "llm_rate_limited",
165
+ LLM_INVALID_REQUEST = "llm_invalid_request",
166
+ VALIDATION_INPUT = "validation_input",
167
+ VALIDATION_OUTPUT = "validation_output",
168
+ VALIDATION_SCHEMA = "validation_schema"
169
+ }
170
+ /**
171
+ * Structured details for a tool execution error.
172
+ *
173
+ * Captures comprehensive information about tool failures to enable proper
174
+ * debugging and error handling without relying on the LLM to interpret errors.
175
+ */
176
+ interface ToolErrorDetails {
177
+ /** Name of the tool that encountered an error */
178
+ tool_name: string;
179
+ /** Unique identifier for the tool call */
180
+ tool_call_id?: string;
181
+ /** Classified error code for programmatic handling */
182
+ error_code: ErrorCode;
183
+ /** Human-readable error message */
184
+ message: string;
185
+ /** HTTP status code if applicable (401, 403, 404, 5xx, etc.) */
186
+ http_status?: number;
187
+ /** Additional error context (integration name, action, etc.) */
188
+ details?: Record<string, unknown>;
189
+ /** ISO 8601 timestamp of when error occurred */
190
+ timestamp: string;
191
+ }
192
+ /**
193
+ * Error verbosity level for API responses.
194
+ *
195
+ * Controls how much detail is included in tool error responses:
196
+ * - Minimal: Only error code and message (for production clients)
197
+ * - Standard: Adds HTTP status and tool_call_id (default, for debugging)
198
+ * - Full: Includes all details including timestamp (for development)
199
+ */
200
+ declare enum ErrorDetailLevel {
201
+ Minimal = "minimal",
202
+ Standard = "standard",
203
+ Full = "full"
204
+ }
205
+ /**
206
+ * Structured details for an agent-level error.
207
+ *
208
+ * Captures agent execution failures that are not related to specific tools,
209
+ * such as token limits, budget constraints, or internal errors.
210
+ */
211
+ interface AgentErrorDetails {
212
+ /** Classified error code for programmatic handling */
213
+ error_code: ErrorCode;
214
+ /** Human-readable error message */
215
+ message: string;
216
+ /** Additional error context */
217
+ details?: Record<string, unknown>;
218
+ /** Full stacktrace for debugging (only in debug mode) */
219
+ stacktrace?: string;
220
+ }
221
+ /**
222
+ * Complete error response with separated agent and tool errors.
223
+ *
224
+ * This structure ensures that errors from different sources are clearly
225
+ * distinguished and not absorbed by the LLM's response text.
226
+ */
227
+ interface ErrorResponse {
228
+ /** High-level error category */
229
+ category: ErrorCategory;
230
+ /** Agent-level error details (if applicable) */
231
+ agent_error?: AgentErrorDetails;
232
+ /** Tool error details (multiple tools can fail) */
233
+ tool_errors?: ToolErrorDetails[];
234
+ /** Whether the error is recoverable */
235
+ is_recoverable: boolean;
236
+ }
237
+ /**
238
+ * Format tool error details to minimal format (code + message only).
239
+ */
240
+ declare function formatToolErrorMinimal(error: ToolErrorDetails): Record<string, unknown>;
241
+ /**
242
+ * Format tool error details to standard format (+ http_status, tool_call_id).
243
+ */
244
+ declare function formatToolErrorStandard(error: ToolErrorDetails): Record<string, unknown>;
245
+ /**
246
+ * Format tool error details to full format (all fields).
247
+ */
248
+ declare function formatToolErrorFull(error: ToolErrorDetails): Record<string, unknown>;
249
+ /**
250
+ * Format tool error details based on verbosity level.
251
+ */
252
+ declare function formatToolErrorForLevel(error: ToolErrorDetails, level: ErrorDetailLevel): Record<string, unknown>;
253
+ /**
254
+ * HTTP status code to error code mapping.
255
+ */
256
+ declare const HTTP_STATUS_TO_ERROR_CODE: Record<number, ErrorCode>;
257
+ /**
258
+ * Error message keywords to error code mapping.
259
+ */
260
+ declare const ERROR_MESSAGE_PATTERNS: Record<string, ErrorCode>;
261
+ /**
262
+ * Classify HTTP status codes into appropriate ErrorCode values.
263
+ *
264
+ * Uses a two-stage classification approach:
265
+ * 1. Primary: Classification by HTTP status code using dictionary mapping
266
+ * 2. Fallback: If status yields generic result, analyze error message content
267
+ */
268
+ declare function classifyHttpError(statusCode: number, errorMessage?: string): ErrorCode;
269
+ /**
270
+ * Determine if an error is recoverable (can be retried).
271
+ */
272
+ declare function isRecoverableError(errorCode: ErrorCode): boolean;
273
+
119
274
  /** Models for assistant-related data structures. */
120
275
 
121
276
  declare enum ContextType {
@@ -215,19 +370,36 @@ interface Assistant extends AssistantBase {
215
370
  user_abilities?: unknown[];
216
371
  version_count?: number;
217
372
  }
373
+ /**
374
+ * API response for assistant chat (camelCase format from API).
375
+ *
376
+ * Error fields expose agent and tool errors.
377
+ */
218
378
  interface BaseModelApiResponse {
219
379
  generated: string;
220
380
  timeElapsed?: number;
221
381
  tokensUsed?: number;
222
382
  thoughts?: Record<string, unknown>[];
223
383
  taskId?: string;
384
+ success?: boolean;
385
+ agentError?: AgentErrorDetails;
386
+ toolErrors?: ToolErrorDetails[];
224
387
  }
388
+ /**
389
+ * Client-facing response for assistant chat (snake_case format).
390
+ *
391
+ * Error fields expose agent and tool errors without breaking backward
392
+ * compatibility (all error fields optional).
393
+ */
225
394
  interface BaseModelResponse {
226
395
  generated: string | object | unknown;
227
396
  time_elapsed?: number;
228
397
  tokens_used?: number;
229
398
  thoughts?: Record<string, unknown>[];
230
399
  task_id?: string;
400
+ success?: boolean;
401
+ agent_error?: AgentErrorDetails;
402
+ tool_errors?: ToolErrorDetails[];
231
403
  }
232
404
  interface AssistantVersion {
233
405
  version_number: number;
@@ -1800,4 +1972,4 @@ declare class NotFoundError extends ApiError {
1800
1972
  constructor(resourceType: string, resourceId: string);
1801
1973
  }
1802
1974
 
1803
- export { type AboutUser, type AboutUserResponse, type AnyJson, ApiError, type Assistant, type AssistantBase, type AssistantCategory, type AssistantChatParams, AssistantChatParamsSchema, type AssistantCreateParams, AssistantCreateParamsSchema, type AssistantCreateResponse, type AssistantDataItem, type AssistantDetailsData, type AssistantListParams, AssistantListParamsSchema, type AssistantUpdateParams, AssistantUpdateParamsSchema, type AssistantUpdateResponse, type AssistantVersion, type AssistantVersionsListParams, AssistantVersionsListParamsSchema, type AuthConfig, type BackgroundTaskEntity, BackgroundTaskStatus, type BackgroundTaskStatusType, type BaseCodeParams, type BaseConfluenceParams, type BaseDataSourceCreateDto, type BaseDataSourceCreateParams, type BaseDataSourceResponse, type BaseDataSourceUpdateDto, type BaseDataSourceUpdateParams, type BaseFileParams, type BaseGoogleParams, type BaseJiraParams, type BaseModelApiResponse, type BaseModelResponse, type BaseUser, ChatRole, type Code, type CodeDataSourceCreateDto, type CodeDataSourceCreateParams, type CodeDataSourceResponse, CodeDataSourceType, type CodeDataSourceTypeType, type CodeDataSourceUpdateDto, type CodeDataSourceUpdateParams, CodeMieClient, type CodeMieClientConfig, CodeMieError, type Confluence, type ConfluenceDataSourceCreateDto, type ConfluenceDataSourceCreateParams, type ConfluenceDataSourceUpdateDto, type ConfluenceDataSourceUpdateParams, type Context, type ContextItem, ContextType, type Conversation, type ConversationCreateParams, ConversationCreateParamsSchema, type ConversationCreateRequest, type ConversationDetails, type ConversationDetailsData, type CostConfig, CredentialTypes, type CredentialTypesType, type CredentialValues, type DataSource, type DataSourceCreateDto, type DataSourceCreateParams, type DataSourceListParams, type DataSourceProcessingInfo, type DataSourceProcessingInfoResponse, type DataSourceResponse, DataSourceStatus, type DataSourceStatusType, DataSourceType, type DataSourceTypeType, type DataSourceUpdateDto, type DataSourceUpdateParams, ExecutionStatus, type ExecutionStatusType, type File, type FileDataSourceCreateDto, type FileDataSourceCreateParams, type FileDataSourceUpdateDto, type FileDataSourceUpdateParams, type Files, type Google, type GoogleDataSourceCreateDto, type GoogleDataSourceCreateParams, type GoogleDataSourceUpdateDto, type GoogleDataSourceUpdateParams, type HistoryItem, type HistoryMark, type Integration, type IntegrationCreateParams, IntegrationCreateParamsSchema, type IntegrationGetByAliasParams, IntegrationGetByAliasParamsSchema, type IntegrationGetParams, IntegrationGetParamsSchema, type IntegrationListParams, IntegrationListParamsSchema, IntegrationType, type IntegrationTypeType, type IntegrationUpdateParams, IntegrationUpdateParamsSchema, type IntegrationValidationResult, type Jira, type JiraDataSourceCreateDto, type JiraDataSourceCreateParams, type JiraDataSourceUpdateDto, type JiraDataSourceUpdateParams, type LLMFeatures, type LLMModel, LLMProvider, type LLMProviderType, type MCPServerConfig, type MCPServerDetails, type Mark, type MissingIntegration, type MissingIntegrationsByCredentialType, NotFoundError, type Operator, type OtherDataSourceCreateParams, type OtherDataSourceUpdateParams, type PaginatedResponse, type PaginationParams, type PromptVariable, type SortOrder, type SystemPromptHistory, type TaskUser, type Thought, type TokensUsage, type ToolDetails, type ToolItem, type ToolKitDetails, type UserData, type Workflow, type WorkflowCreateParams, WorkflowCreateParamsSchema, type WorkflowExecution, type WorkflowExecutionCreateParams, WorkflowExecutionCreateParamsSchema, type WorkflowExecutionListParams, WorkflowExecutionListParamsSchema, type WorkflowExecutionResponse, type WorkflowExecutionState, type WorkflowExecutionStateListParams, WorkflowExecutionStateListParamsSchema, type WorkflowExecutionStateOutput, type WorkflowExecutionStateThought, type WorkflowListParams, WorkflowListParamsSchema, WorkflowMode, type WorkflowModeType, type WorkflowResponse, type WorkflowUpdateParams, WorkflowUpdateParamsSchema, formatCookies };
1975
+ export { type AboutUser, type AboutUserResponse, type AgentErrorDetails, type AnyJson, ApiError, type Assistant, type AssistantBase, type AssistantCategory, type AssistantChatParams, AssistantChatParamsSchema, type AssistantCreateParams, AssistantCreateParamsSchema, type AssistantCreateResponse, type AssistantDataItem, type AssistantDetailsData, type AssistantListParams, AssistantListParamsSchema, type AssistantUpdateParams, AssistantUpdateParamsSchema, type AssistantUpdateResponse, type AssistantVersion, type AssistantVersionsListParams, AssistantVersionsListParamsSchema, type AuthConfig, type BackgroundTaskEntity, BackgroundTaskStatus, type BackgroundTaskStatusType, type BaseCodeParams, type BaseConfluenceParams, type BaseDataSourceCreateDto, type BaseDataSourceCreateParams, type BaseDataSourceResponse, type BaseDataSourceUpdateDto, type BaseDataSourceUpdateParams, type BaseFileParams, type BaseGoogleParams, type BaseJiraParams, type BaseModelApiResponse, type BaseModelResponse, type BaseUser, ChatRole, type Code, type CodeDataSourceCreateDto, type CodeDataSourceCreateParams, type CodeDataSourceResponse, CodeDataSourceType, type CodeDataSourceTypeType, type CodeDataSourceUpdateDto, type CodeDataSourceUpdateParams, CodeMieClient, type CodeMieClientConfig, CodeMieError, type Confluence, type ConfluenceDataSourceCreateDto, type ConfluenceDataSourceCreateParams, type ConfluenceDataSourceUpdateDto, type ConfluenceDataSourceUpdateParams, type Context, type ContextItem, ContextType, type Conversation, type ConversationCreateParams, ConversationCreateParamsSchema, type ConversationCreateRequest, type ConversationDetails, type ConversationDetailsData, type CostConfig, CredentialTypes, type CredentialTypesType, type CredentialValues, type DataSource, type DataSourceCreateDto, type DataSourceCreateParams, type DataSourceListParams, type DataSourceProcessingInfo, type DataSourceProcessingInfoResponse, type DataSourceResponse, DataSourceStatus, type DataSourceStatusType, DataSourceType, type DataSourceTypeType, type DataSourceUpdateDto, type DataSourceUpdateParams, ERROR_MESSAGE_PATTERNS, ErrorCategory, ErrorCode, ErrorDetailLevel, type ErrorResponse, ExecutionStatus, type ExecutionStatusType, type File, type FileDataSourceCreateDto, type FileDataSourceCreateParams, type FileDataSourceUpdateDto, type FileDataSourceUpdateParams, type Files, type Google, type GoogleDataSourceCreateDto, type GoogleDataSourceCreateParams, type GoogleDataSourceUpdateDto, type GoogleDataSourceUpdateParams, HTTP_STATUS_TO_ERROR_CODE, type HistoryItem, type HistoryMark, type Integration, type IntegrationCreateParams, IntegrationCreateParamsSchema, type IntegrationGetByAliasParams, IntegrationGetByAliasParamsSchema, type IntegrationGetParams, IntegrationGetParamsSchema, type IntegrationListParams, IntegrationListParamsSchema, IntegrationType, type IntegrationTypeType, type IntegrationUpdateParams, IntegrationUpdateParamsSchema, type IntegrationValidationResult, type Jira, type JiraDataSourceCreateDto, type JiraDataSourceCreateParams, type JiraDataSourceUpdateDto, type JiraDataSourceUpdateParams, type LLMFeatures, type LLMModel, LLMProvider, type LLMProviderType, type MCPServerConfig, type MCPServerDetails, type Mark, type MissingIntegration, type MissingIntegrationsByCredentialType, NotFoundError, type Operator, type OtherDataSourceCreateParams, type OtherDataSourceUpdateParams, type PaginatedResponse, type PaginationParams, type PromptVariable, type SortOrder, type SystemPromptHistory, type TaskUser, type Thought, type TokensUsage, type ToolDetails, type ToolErrorDetails, type ToolItem, type ToolKitDetails, type UserData, type Workflow, type WorkflowCreateParams, WorkflowCreateParamsSchema, type WorkflowExecution, type WorkflowExecutionCreateParams, WorkflowExecutionCreateParamsSchema, type WorkflowExecutionListParams, WorkflowExecutionListParamsSchema, type WorkflowExecutionResponse, type WorkflowExecutionState, type WorkflowExecutionStateListParams, WorkflowExecutionStateListParamsSchema, type WorkflowExecutionStateOutput, type WorkflowExecutionStateThought, type WorkflowListParams, WorkflowListParamsSchema, WorkflowMode, type WorkflowModeType, type WorkflowResponse, type WorkflowUpdateParams, WorkflowUpdateParamsSchema, classifyHttpError, formatCookies, formatToolErrorForLevel, formatToolErrorFull, formatToolErrorMinimal, formatToolErrorStandard, isRecoverableError };
package/dist/index.d.ts CHANGED
@@ -116,6 +116,161 @@ interface Integration {
116
116
  setting_type: IntegrationTypeType;
117
117
  }
118
118
 
119
+ /**
120
+ * Error models for structured error handling in CodeMie SDK responses.
121
+ *
122
+ * This module provides error classification and structured error details that match
123
+ * the CodeMie API error response format, enabling proper error handling without
124
+ * parsing error messages.
125
+ */
126
+ /**
127
+ * High-level categorization of errors in the CodeMie system.
128
+ *
129
+ * Separates errors by their source to enable proper handling and debugging.
130
+ */
131
+ declare enum ErrorCategory {
132
+ AGENT = "agent",// Agent-level errors (execution, callbacks, etc.)
133
+ TOOL = "tool",// Tool execution errors (HTTP errors, timeouts, etc.)
134
+ LLM = "llm",// LLM provider errors (rate limits, content policy, etc.)
135
+ VALIDATION = "validation"
136
+ }
137
+ /**
138
+ * Specific error codes for detailed error classification.
139
+ *
140
+ * These codes enable clients to programmatically handle different error scenarios
141
+ * without parsing error messages.
142
+ */
143
+ declare enum ErrorCode {
144
+ AGENT_TIMEOUT = "agent_timeout",
145
+ AGENT_TOKEN_LIMIT = "agent_token_limit",
146
+ AGENT_BUDGET_EXCEEDED = "agent_budget_exceeded",
147
+ AGENT_CALLBACK_FAILURE = "agent_callback_failure",
148
+ AGENT_NETWORK_ERROR = "agent_network_error",
149
+ AGENT_CONFIGURATION_ERROR = "agent_configuration_error",
150
+ AGENT_INTERNAL_ERROR = "agent_internal_error",
151
+ TOOL_AUTHENTICATION = "tool_authentication",// 401 Unauthorized
152
+ TOOL_AUTHORIZATION = "tool_authorization",// 403 Forbidden
153
+ TOOL_NOT_FOUND = "tool_not_found",// 404 Not Found
154
+ TOOL_CONFLICT = "tool_conflict",// 409 Conflict
155
+ TOOL_RATE_LIMITED = "tool_rate_limited",// 429 Too Many Requests
156
+ TOOL_SERVER_ERROR = "tool_server_error",// 5xx Server Error
157
+ TOOL_TIMEOUT = "tool_timeout",
158
+ TOOL_VALIDATION = "tool_validation",// Invalid tool input
159
+ TOOL_NETWORK_ERROR = "tool_network_error",
160
+ TOOL_EXECUTION_FAILED = "tool_execution_failed",// Generic tool failure
161
+ LLM_CONTENT_POLICY = "llm_content_policy",
162
+ LLM_CONTEXT_LENGTH = "llm_context_length",
163
+ LLM_UNAVAILABLE = "llm_unavailable",
164
+ LLM_RATE_LIMITED = "llm_rate_limited",
165
+ LLM_INVALID_REQUEST = "llm_invalid_request",
166
+ VALIDATION_INPUT = "validation_input",
167
+ VALIDATION_OUTPUT = "validation_output",
168
+ VALIDATION_SCHEMA = "validation_schema"
169
+ }
170
+ /**
171
+ * Structured details for a tool execution error.
172
+ *
173
+ * Captures comprehensive information about tool failures to enable proper
174
+ * debugging and error handling without relying on the LLM to interpret errors.
175
+ */
176
+ interface ToolErrorDetails {
177
+ /** Name of the tool that encountered an error */
178
+ tool_name: string;
179
+ /** Unique identifier for the tool call */
180
+ tool_call_id?: string;
181
+ /** Classified error code for programmatic handling */
182
+ error_code: ErrorCode;
183
+ /** Human-readable error message */
184
+ message: string;
185
+ /** HTTP status code if applicable (401, 403, 404, 5xx, etc.) */
186
+ http_status?: number;
187
+ /** Additional error context (integration name, action, etc.) */
188
+ details?: Record<string, unknown>;
189
+ /** ISO 8601 timestamp of when error occurred */
190
+ timestamp: string;
191
+ }
192
+ /**
193
+ * Error verbosity level for API responses.
194
+ *
195
+ * Controls how much detail is included in tool error responses:
196
+ * - Minimal: Only error code and message (for production clients)
197
+ * - Standard: Adds HTTP status and tool_call_id (default, for debugging)
198
+ * - Full: Includes all details including timestamp (for development)
199
+ */
200
+ declare enum ErrorDetailLevel {
201
+ Minimal = "minimal",
202
+ Standard = "standard",
203
+ Full = "full"
204
+ }
205
+ /**
206
+ * Structured details for an agent-level error.
207
+ *
208
+ * Captures agent execution failures that are not related to specific tools,
209
+ * such as token limits, budget constraints, or internal errors.
210
+ */
211
+ interface AgentErrorDetails {
212
+ /** Classified error code for programmatic handling */
213
+ error_code: ErrorCode;
214
+ /** Human-readable error message */
215
+ message: string;
216
+ /** Additional error context */
217
+ details?: Record<string, unknown>;
218
+ /** Full stacktrace for debugging (only in debug mode) */
219
+ stacktrace?: string;
220
+ }
221
+ /**
222
+ * Complete error response with separated agent and tool errors.
223
+ *
224
+ * This structure ensures that errors from different sources are clearly
225
+ * distinguished and not absorbed by the LLM's response text.
226
+ */
227
+ interface ErrorResponse {
228
+ /** High-level error category */
229
+ category: ErrorCategory;
230
+ /** Agent-level error details (if applicable) */
231
+ agent_error?: AgentErrorDetails;
232
+ /** Tool error details (multiple tools can fail) */
233
+ tool_errors?: ToolErrorDetails[];
234
+ /** Whether the error is recoverable */
235
+ is_recoverable: boolean;
236
+ }
237
+ /**
238
+ * Format tool error details to minimal format (code + message only).
239
+ */
240
+ declare function formatToolErrorMinimal(error: ToolErrorDetails): Record<string, unknown>;
241
+ /**
242
+ * Format tool error details to standard format (+ http_status, tool_call_id).
243
+ */
244
+ declare function formatToolErrorStandard(error: ToolErrorDetails): Record<string, unknown>;
245
+ /**
246
+ * Format tool error details to full format (all fields).
247
+ */
248
+ declare function formatToolErrorFull(error: ToolErrorDetails): Record<string, unknown>;
249
+ /**
250
+ * Format tool error details based on verbosity level.
251
+ */
252
+ declare function formatToolErrorForLevel(error: ToolErrorDetails, level: ErrorDetailLevel): Record<string, unknown>;
253
+ /**
254
+ * HTTP status code to error code mapping.
255
+ */
256
+ declare const HTTP_STATUS_TO_ERROR_CODE: Record<number, ErrorCode>;
257
+ /**
258
+ * Error message keywords to error code mapping.
259
+ */
260
+ declare const ERROR_MESSAGE_PATTERNS: Record<string, ErrorCode>;
261
+ /**
262
+ * Classify HTTP status codes into appropriate ErrorCode values.
263
+ *
264
+ * Uses a two-stage classification approach:
265
+ * 1. Primary: Classification by HTTP status code using dictionary mapping
266
+ * 2. Fallback: If status yields generic result, analyze error message content
267
+ */
268
+ declare function classifyHttpError(statusCode: number, errorMessage?: string): ErrorCode;
269
+ /**
270
+ * Determine if an error is recoverable (can be retried).
271
+ */
272
+ declare function isRecoverableError(errorCode: ErrorCode): boolean;
273
+
119
274
  /** Models for assistant-related data structures. */
120
275
 
121
276
  declare enum ContextType {
@@ -215,19 +370,36 @@ interface Assistant extends AssistantBase {
215
370
  user_abilities?: unknown[];
216
371
  version_count?: number;
217
372
  }
373
+ /**
374
+ * API response for assistant chat (camelCase format from API).
375
+ *
376
+ * Error fields expose agent and tool errors.
377
+ */
218
378
  interface BaseModelApiResponse {
219
379
  generated: string;
220
380
  timeElapsed?: number;
221
381
  tokensUsed?: number;
222
382
  thoughts?: Record<string, unknown>[];
223
383
  taskId?: string;
384
+ success?: boolean;
385
+ agentError?: AgentErrorDetails;
386
+ toolErrors?: ToolErrorDetails[];
224
387
  }
388
+ /**
389
+ * Client-facing response for assistant chat (snake_case format).
390
+ *
391
+ * Error fields expose agent and tool errors without breaking backward
392
+ * compatibility (all error fields optional).
393
+ */
225
394
  interface BaseModelResponse {
226
395
  generated: string | object | unknown;
227
396
  time_elapsed?: number;
228
397
  tokens_used?: number;
229
398
  thoughts?: Record<string, unknown>[];
230
399
  task_id?: string;
400
+ success?: boolean;
401
+ agent_error?: AgentErrorDetails;
402
+ tool_errors?: ToolErrorDetails[];
231
403
  }
232
404
  interface AssistantVersion {
233
405
  version_number: number;
@@ -1800,4 +1972,4 @@ declare class NotFoundError extends ApiError {
1800
1972
  constructor(resourceType: string, resourceId: string);
1801
1973
  }
1802
1974
 
1803
- export { type AboutUser, type AboutUserResponse, type AnyJson, ApiError, type Assistant, type AssistantBase, type AssistantCategory, type AssistantChatParams, AssistantChatParamsSchema, type AssistantCreateParams, AssistantCreateParamsSchema, type AssistantCreateResponse, type AssistantDataItem, type AssistantDetailsData, type AssistantListParams, AssistantListParamsSchema, type AssistantUpdateParams, AssistantUpdateParamsSchema, type AssistantUpdateResponse, type AssistantVersion, type AssistantVersionsListParams, AssistantVersionsListParamsSchema, type AuthConfig, type BackgroundTaskEntity, BackgroundTaskStatus, type BackgroundTaskStatusType, type BaseCodeParams, type BaseConfluenceParams, type BaseDataSourceCreateDto, type BaseDataSourceCreateParams, type BaseDataSourceResponse, type BaseDataSourceUpdateDto, type BaseDataSourceUpdateParams, type BaseFileParams, type BaseGoogleParams, type BaseJiraParams, type BaseModelApiResponse, type BaseModelResponse, type BaseUser, ChatRole, type Code, type CodeDataSourceCreateDto, type CodeDataSourceCreateParams, type CodeDataSourceResponse, CodeDataSourceType, type CodeDataSourceTypeType, type CodeDataSourceUpdateDto, type CodeDataSourceUpdateParams, CodeMieClient, type CodeMieClientConfig, CodeMieError, type Confluence, type ConfluenceDataSourceCreateDto, type ConfluenceDataSourceCreateParams, type ConfluenceDataSourceUpdateDto, type ConfluenceDataSourceUpdateParams, type Context, type ContextItem, ContextType, type Conversation, type ConversationCreateParams, ConversationCreateParamsSchema, type ConversationCreateRequest, type ConversationDetails, type ConversationDetailsData, type CostConfig, CredentialTypes, type CredentialTypesType, type CredentialValues, type DataSource, type DataSourceCreateDto, type DataSourceCreateParams, type DataSourceListParams, type DataSourceProcessingInfo, type DataSourceProcessingInfoResponse, type DataSourceResponse, DataSourceStatus, type DataSourceStatusType, DataSourceType, type DataSourceTypeType, type DataSourceUpdateDto, type DataSourceUpdateParams, ExecutionStatus, type ExecutionStatusType, type File, type FileDataSourceCreateDto, type FileDataSourceCreateParams, type FileDataSourceUpdateDto, type FileDataSourceUpdateParams, type Files, type Google, type GoogleDataSourceCreateDto, type GoogleDataSourceCreateParams, type GoogleDataSourceUpdateDto, type GoogleDataSourceUpdateParams, type HistoryItem, type HistoryMark, type Integration, type IntegrationCreateParams, IntegrationCreateParamsSchema, type IntegrationGetByAliasParams, IntegrationGetByAliasParamsSchema, type IntegrationGetParams, IntegrationGetParamsSchema, type IntegrationListParams, IntegrationListParamsSchema, IntegrationType, type IntegrationTypeType, type IntegrationUpdateParams, IntegrationUpdateParamsSchema, type IntegrationValidationResult, type Jira, type JiraDataSourceCreateDto, type JiraDataSourceCreateParams, type JiraDataSourceUpdateDto, type JiraDataSourceUpdateParams, type LLMFeatures, type LLMModel, LLMProvider, type LLMProviderType, type MCPServerConfig, type MCPServerDetails, type Mark, type MissingIntegration, type MissingIntegrationsByCredentialType, NotFoundError, type Operator, type OtherDataSourceCreateParams, type OtherDataSourceUpdateParams, type PaginatedResponse, type PaginationParams, type PromptVariable, type SortOrder, type SystemPromptHistory, type TaskUser, type Thought, type TokensUsage, type ToolDetails, type ToolItem, type ToolKitDetails, type UserData, type Workflow, type WorkflowCreateParams, WorkflowCreateParamsSchema, type WorkflowExecution, type WorkflowExecutionCreateParams, WorkflowExecutionCreateParamsSchema, type WorkflowExecutionListParams, WorkflowExecutionListParamsSchema, type WorkflowExecutionResponse, type WorkflowExecutionState, type WorkflowExecutionStateListParams, WorkflowExecutionStateListParamsSchema, type WorkflowExecutionStateOutput, type WorkflowExecutionStateThought, type WorkflowListParams, WorkflowListParamsSchema, WorkflowMode, type WorkflowModeType, type WorkflowResponse, type WorkflowUpdateParams, WorkflowUpdateParamsSchema, formatCookies };
1975
+ export { type AboutUser, type AboutUserResponse, type AgentErrorDetails, type AnyJson, ApiError, type Assistant, type AssistantBase, type AssistantCategory, type AssistantChatParams, AssistantChatParamsSchema, type AssistantCreateParams, AssistantCreateParamsSchema, type AssistantCreateResponse, type AssistantDataItem, type AssistantDetailsData, type AssistantListParams, AssistantListParamsSchema, type AssistantUpdateParams, AssistantUpdateParamsSchema, type AssistantUpdateResponse, type AssistantVersion, type AssistantVersionsListParams, AssistantVersionsListParamsSchema, type AuthConfig, type BackgroundTaskEntity, BackgroundTaskStatus, type BackgroundTaskStatusType, type BaseCodeParams, type BaseConfluenceParams, type BaseDataSourceCreateDto, type BaseDataSourceCreateParams, type BaseDataSourceResponse, type BaseDataSourceUpdateDto, type BaseDataSourceUpdateParams, type BaseFileParams, type BaseGoogleParams, type BaseJiraParams, type BaseModelApiResponse, type BaseModelResponse, type BaseUser, ChatRole, type Code, type CodeDataSourceCreateDto, type CodeDataSourceCreateParams, type CodeDataSourceResponse, CodeDataSourceType, type CodeDataSourceTypeType, type CodeDataSourceUpdateDto, type CodeDataSourceUpdateParams, CodeMieClient, type CodeMieClientConfig, CodeMieError, type Confluence, type ConfluenceDataSourceCreateDto, type ConfluenceDataSourceCreateParams, type ConfluenceDataSourceUpdateDto, type ConfluenceDataSourceUpdateParams, type Context, type ContextItem, ContextType, type Conversation, type ConversationCreateParams, ConversationCreateParamsSchema, type ConversationCreateRequest, type ConversationDetails, type ConversationDetailsData, type CostConfig, CredentialTypes, type CredentialTypesType, type CredentialValues, type DataSource, type DataSourceCreateDto, type DataSourceCreateParams, type DataSourceListParams, type DataSourceProcessingInfo, type DataSourceProcessingInfoResponse, type DataSourceResponse, DataSourceStatus, type DataSourceStatusType, DataSourceType, type DataSourceTypeType, type DataSourceUpdateDto, type DataSourceUpdateParams, ERROR_MESSAGE_PATTERNS, ErrorCategory, ErrorCode, ErrorDetailLevel, type ErrorResponse, ExecutionStatus, type ExecutionStatusType, type File, type FileDataSourceCreateDto, type FileDataSourceCreateParams, type FileDataSourceUpdateDto, type FileDataSourceUpdateParams, type Files, type Google, type GoogleDataSourceCreateDto, type GoogleDataSourceCreateParams, type GoogleDataSourceUpdateDto, type GoogleDataSourceUpdateParams, HTTP_STATUS_TO_ERROR_CODE, type HistoryItem, type HistoryMark, type Integration, type IntegrationCreateParams, IntegrationCreateParamsSchema, type IntegrationGetByAliasParams, IntegrationGetByAliasParamsSchema, type IntegrationGetParams, IntegrationGetParamsSchema, type IntegrationListParams, IntegrationListParamsSchema, IntegrationType, type IntegrationTypeType, type IntegrationUpdateParams, IntegrationUpdateParamsSchema, type IntegrationValidationResult, type Jira, type JiraDataSourceCreateDto, type JiraDataSourceCreateParams, type JiraDataSourceUpdateDto, type JiraDataSourceUpdateParams, type LLMFeatures, type LLMModel, LLMProvider, type LLMProviderType, type MCPServerConfig, type MCPServerDetails, type Mark, type MissingIntegration, type MissingIntegrationsByCredentialType, NotFoundError, type Operator, type OtherDataSourceCreateParams, type OtherDataSourceUpdateParams, type PaginatedResponse, type PaginationParams, type PromptVariable, type SortOrder, type SystemPromptHistory, type TaskUser, type Thought, type TokensUsage, type ToolDetails, type ToolErrorDetails, type ToolItem, type ToolKitDetails, type UserData, type Workflow, type WorkflowCreateParams, WorkflowCreateParamsSchema, type WorkflowExecution, type WorkflowExecutionCreateParams, WorkflowExecutionCreateParamsSchema, type WorkflowExecutionListParams, WorkflowExecutionListParamsSchema, type WorkflowExecutionResponse, type WorkflowExecutionState, type WorkflowExecutionStateListParams, WorkflowExecutionStateListParamsSchema, type WorkflowExecutionStateOutput, type WorkflowExecutionStateThought, type WorkflowListParams, WorkflowListParamsSchema, WorkflowMode, type WorkflowModeType, type WorkflowResponse, type WorkflowUpdateParams, WorkflowUpdateParamsSchema, classifyHttpError, formatCookies, formatToolErrorForLevel, formatToolErrorFull, formatToolErrorMinimal, formatToolErrorStandard, isRecoverableError };
package/dist/index.js CHANGED
@@ -1570,6 +1570,143 @@ var ChatRole = /* @__PURE__ */ ((ChatRole2) => {
1570
1570
  return ChatRole2;
1571
1571
  })(ChatRole || {});
1572
1572
 
1573
+ // src/models/errors.ts
1574
+ var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
1575
+ ErrorCategory2["AGENT"] = "agent";
1576
+ ErrorCategory2["TOOL"] = "tool";
1577
+ ErrorCategory2["LLM"] = "llm";
1578
+ ErrorCategory2["VALIDATION"] = "validation";
1579
+ return ErrorCategory2;
1580
+ })(ErrorCategory || {});
1581
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
1582
+ ErrorCode2["AGENT_TIMEOUT"] = "agent_timeout";
1583
+ ErrorCode2["AGENT_TOKEN_LIMIT"] = "agent_token_limit";
1584
+ ErrorCode2["AGENT_BUDGET_EXCEEDED"] = "agent_budget_exceeded";
1585
+ ErrorCode2["AGENT_CALLBACK_FAILURE"] = "agent_callback_failure";
1586
+ ErrorCode2["AGENT_NETWORK_ERROR"] = "agent_network_error";
1587
+ ErrorCode2["AGENT_CONFIGURATION_ERROR"] = "agent_configuration_error";
1588
+ ErrorCode2["AGENT_INTERNAL_ERROR"] = "agent_internal_error";
1589
+ ErrorCode2["TOOL_AUTHENTICATION"] = "tool_authentication";
1590
+ ErrorCode2["TOOL_AUTHORIZATION"] = "tool_authorization";
1591
+ ErrorCode2["TOOL_NOT_FOUND"] = "tool_not_found";
1592
+ ErrorCode2["TOOL_CONFLICT"] = "tool_conflict";
1593
+ ErrorCode2["TOOL_RATE_LIMITED"] = "tool_rate_limited";
1594
+ ErrorCode2["TOOL_SERVER_ERROR"] = "tool_server_error";
1595
+ ErrorCode2["TOOL_TIMEOUT"] = "tool_timeout";
1596
+ ErrorCode2["TOOL_VALIDATION"] = "tool_validation";
1597
+ ErrorCode2["TOOL_NETWORK_ERROR"] = "tool_network_error";
1598
+ ErrorCode2["TOOL_EXECUTION_FAILED"] = "tool_execution_failed";
1599
+ ErrorCode2["LLM_CONTENT_POLICY"] = "llm_content_policy";
1600
+ ErrorCode2["LLM_CONTEXT_LENGTH"] = "llm_context_length";
1601
+ ErrorCode2["LLM_UNAVAILABLE"] = "llm_unavailable";
1602
+ ErrorCode2["LLM_RATE_LIMITED"] = "llm_rate_limited";
1603
+ ErrorCode2["LLM_INVALID_REQUEST"] = "llm_invalid_request";
1604
+ ErrorCode2["VALIDATION_INPUT"] = "validation_input";
1605
+ ErrorCode2["VALIDATION_OUTPUT"] = "validation_output";
1606
+ ErrorCode2["VALIDATION_SCHEMA"] = "validation_schema";
1607
+ return ErrorCode2;
1608
+ })(ErrorCode || {});
1609
+ var ErrorDetailLevel = /* @__PURE__ */ ((ErrorDetailLevel2) => {
1610
+ ErrorDetailLevel2["Minimal"] = "minimal";
1611
+ ErrorDetailLevel2["Standard"] = "standard";
1612
+ ErrorDetailLevel2["Full"] = "full";
1613
+ return ErrorDetailLevel2;
1614
+ })(ErrorDetailLevel || {});
1615
+ function formatToolErrorMinimal(error) {
1616
+ return {
1617
+ tool_name: error.tool_name,
1618
+ error_code: error.error_code,
1619
+ message: error.message
1620
+ };
1621
+ }
1622
+ function formatToolErrorStandard(error) {
1623
+ return {
1624
+ tool_name: error.tool_name,
1625
+ tool_call_id: error.tool_call_id,
1626
+ error_code: error.error_code,
1627
+ message: error.message,
1628
+ http_status: error.http_status
1629
+ };
1630
+ }
1631
+ function formatToolErrorFull(error) {
1632
+ return { ...error };
1633
+ }
1634
+ function formatToolErrorForLevel(error, level) {
1635
+ switch (level) {
1636
+ case "minimal" /* Minimal */:
1637
+ return formatToolErrorMinimal(error);
1638
+ case "standard" /* Standard */:
1639
+ return formatToolErrorStandard(error);
1640
+ case "full" /* Full */:
1641
+ return formatToolErrorFull(error);
1642
+ }
1643
+ }
1644
+ var HTTP_STATUS_TO_ERROR_CODE = {
1645
+ // Client errors (4xx)
1646
+ 401: "tool_authentication" /* TOOL_AUTHENTICATION */,
1647
+ 403: "tool_authorization" /* TOOL_AUTHORIZATION */,
1648
+ 404: "tool_not_found" /* TOOL_NOT_FOUND */,
1649
+ 409: "tool_conflict" /* TOOL_CONFLICT */,
1650
+ 429: "tool_rate_limited" /* TOOL_RATE_LIMITED */,
1651
+ // Server errors (5xx)
1652
+ 500: "tool_server_error" /* TOOL_SERVER_ERROR */,
1653
+ 501: "tool_server_error" /* TOOL_SERVER_ERROR */,
1654
+ 502: "tool_server_error" /* TOOL_SERVER_ERROR */,
1655
+ 503: "tool_server_error" /* TOOL_SERVER_ERROR */,
1656
+ 504: "tool_server_error" /* TOOL_SERVER_ERROR */,
1657
+ 505: "tool_server_error" /* TOOL_SERVER_ERROR */,
1658
+ 506: "tool_server_error" /* TOOL_SERVER_ERROR */,
1659
+ 507: "tool_server_error" /* TOOL_SERVER_ERROR */,
1660
+ 508: "tool_server_error" /* TOOL_SERVER_ERROR */,
1661
+ 509: "tool_server_error" /* TOOL_SERVER_ERROR */,
1662
+ 510: "tool_server_error" /* TOOL_SERVER_ERROR */,
1663
+ 511: "tool_server_error" /* TOOL_SERVER_ERROR */
1664
+ };
1665
+ var ERROR_MESSAGE_PATTERNS = {
1666
+ timeout: "tool_timeout" /* TOOL_TIMEOUT */,
1667
+ network: "tool_network_error" /* TOOL_NETWORK_ERROR */,
1668
+ connection: "tool_network_error" /* TOOL_NETWORK_ERROR */,
1669
+ validation: "tool_validation" /* TOOL_VALIDATION */,
1670
+ invalid: "tool_validation" /* TOOL_VALIDATION */
1671
+ };
1672
+ function classifyByHttpStatus(statusCode) {
1673
+ if (statusCode in HTTP_STATUS_TO_ERROR_CODE) {
1674
+ return HTTP_STATUS_TO_ERROR_CODE[statusCode];
1675
+ }
1676
+ if (statusCode >= 500 && statusCode < 600) {
1677
+ return "tool_server_error" /* TOOL_SERVER_ERROR */;
1678
+ }
1679
+ return "tool_execution_failed" /* TOOL_EXECUTION_FAILED */;
1680
+ }
1681
+ function classifyByMessage(errorMessage) {
1682
+ const errorLower = errorMessage.toLowerCase();
1683
+ for (const [keyword, errorCode] of Object.entries(ERROR_MESSAGE_PATTERNS)) {
1684
+ if (errorLower.includes(keyword)) {
1685
+ return errorCode;
1686
+ }
1687
+ }
1688
+ return "tool_execution_failed" /* TOOL_EXECUTION_FAILED */;
1689
+ }
1690
+ function classifyHttpError(statusCode, errorMessage = "") {
1691
+ let errorCode = classifyByHttpStatus(statusCode);
1692
+ if (errorCode === "tool_execution_failed" /* TOOL_EXECUTION_FAILED */ && errorMessage) {
1693
+ errorCode = classifyByMessage(errorMessage);
1694
+ }
1695
+ return errorCode;
1696
+ }
1697
+ function isRecoverableError(errorCode) {
1698
+ const recoverableErrors = /* @__PURE__ */ new Set([
1699
+ "tool_timeout" /* TOOL_TIMEOUT */,
1700
+ "tool_rate_limited" /* TOOL_RATE_LIMITED */,
1701
+ "tool_server_error" /* TOOL_SERVER_ERROR */,
1702
+ "tool_network_error" /* TOOL_NETWORK_ERROR */,
1703
+ "agent_network_error" /* AGENT_NETWORK_ERROR */,
1704
+ "llm_rate_limited" /* LLM_RATE_LIMITED */,
1705
+ "llm_unavailable" /* LLM_UNAVAILABLE */
1706
+ ]);
1707
+ return recoverableErrors.has(errorCode);
1708
+ }
1709
+
1573
1710
  // src/models/llm.ts
1574
1711
  var LLMProvider = {
1575
1712
  AZURE_OPENAI: "azure_openai",
@@ -1600,7 +1737,12 @@ export {
1600
1737
  CredentialTypes,
1601
1738
  DataSourceStatus,
1602
1739
  DataSourceType,
1740
+ ERROR_MESSAGE_PATTERNS,
1741
+ ErrorCategory,
1742
+ ErrorCode,
1743
+ ErrorDetailLevel,
1603
1744
  ExecutionStatus,
1745
+ HTTP_STATUS_TO_ERROR_CODE,
1604
1746
  IntegrationCreateParamsSchema,
1605
1747
  IntegrationGetByAliasParamsSchema,
1606
1748
  IntegrationGetParamsSchema,
@@ -1616,6 +1758,12 @@ export {
1616
1758
  WorkflowListParamsSchema,
1617
1759
  WorkflowMode,
1618
1760
  WorkflowUpdateParamsSchema,
1619
- formatCookies
1761
+ classifyHttpError,
1762
+ formatCookies,
1763
+ formatToolErrorForLevel,
1764
+ formatToolErrorFull,
1765
+ formatToolErrorMinimal,
1766
+ formatToolErrorStandard,
1767
+ isRecoverableError
1620
1768
  };
1621
1769
  //# sourceMappingURL=index.js.map