@cadraos/sdk 0.1.10 → 0.1.11-test
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/chat/index.cjs +157 -50
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +58 -23
- package/dist/chat/index.d.ts +58 -23
- package/dist/chat/index.js +156 -51
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -0
- package/dist/index.cjs +52 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -29
- package/dist/index.d.ts +29 -29
- package/dist/index.js +49 -29
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.d.cts
CHANGED
|
@@ -1901,17 +1901,17 @@ declare class SessionsAPI extends BaseResourceAPI {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
|
|
1903
1903
|
/**
|
|
1904
|
-
*
|
|
1904
|
+
* Cadra Client
|
|
1905
1905
|
*
|
|
1906
1906
|
* Main entry point for the SDK. Provides access to all resource APIs.
|
|
1907
1907
|
*
|
|
1908
1908
|
* @example
|
|
1909
1909
|
* ```typescript
|
|
1910
|
-
* import {
|
|
1910
|
+
* import { CadraClient } from '@cadraos/sdk';
|
|
1911
1911
|
*
|
|
1912
|
-
* const client = new
|
|
1913
|
-
* apiKey: process.env.
|
|
1914
|
-
* orgId: Number(process.env.
|
|
1912
|
+
* const client = new CadraClient({
|
|
1913
|
+
* apiKey: process.env.CADRA_API_KEY,
|
|
1914
|
+
* orgId: Number(process.env.CADRA_ORG_ID),
|
|
1915
1915
|
* });
|
|
1916
1916
|
*
|
|
1917
1917
|
* // List agents
|
|
@@ -1937,12 +1937,12 @@ declare class SessionsAPI extends BaseResourceAPI {
|
|
|
1937
1937
|
/**
|
|
1938
1938
|
* Client options for API key authentication
|
|
1939
1939
|
*/
|
|
1940
|
-
interface
|
|
1940
|
+
interface CadraClientOptionsApiKey {
|
|
1941
1941
|
/** API key for authentication */
|
|
1942
1942
|
apiKey: string;
|
|
1943
1943
|
/** Organization ID */
|
|
1944
1944
|
orgId: number;
|
|
1945
|
-
/** Base URL for API (default: https://api.
|
|
1945
|
+
/** Base URL for API (default: https://api.cadraos.com) */
|
|
1946
1946
|
baseUrl?: string;
|
|
1947
1947
|
/** Request timeout in milliseconds (default: 30000) */
|
|
1948
1948
|
timeout?: number;
|
|
@@ -1954,12 +1954,12 @@ interface AISaaSClientOptionsApiKey {
|
|
|
1954
1954
|
/**
|
|
1955
1955
|
* Client options for OAuth token authentication
|
|
1956
1956
|
*/
|
|
1957
|
-
interface
|
|
1957
|
+
interface CadraClientOptionsToken {
|
|
1958
1958
|
/** OAuth token for authentication */
|
|
1959
1959
|
token: string;
|
|
1960
1960
|
/** Organization ID */
|
|
1961
1961
|
orgId: number;
|
|
1962
|
-
/** Base URL for API (default: https://api.
|
|
1962
|
+
/** Base URL for API (default: https://api.cadraos.com) */
|
|
1963
1963
|
baseUrl?: string;
|
|
1964
1964
|
/** Request timeout in milliseconds (default: 30000) */
|
|
1965
1965
|
timeout?: number;
|
|
@@ -1971,12 +1971,12 @@ interface AISaaSClientOptionsToken {
|
|
|
1971
1971
|
/**
|
|
1972
1972
|
* Client options for token provider authentication
|
|
1973
1973
|
*/
|
|
1974
|
-
interface
|
|
1974
|
+
interface CadraClientOptionsTokenProvider {
|
|
1975
1975
|
/** Token provider callback (called before each request) */
|
|
1976
1976
|
tokenProvider: () => Promise<string>;
|
|
1977
1977
|
/** Organization ID */
|
|
1978
1978
|
orgId: number;
|
|
1979
|
-
/** Base URL for API (default: https://api.
|
|
1979
|
+
/** Base URL for API (default: https://api.cadraos.com) */
|
|
1980
1980
|
baseUrl?: string;
|
|
1981
1981
|
/** Request timeout in milliseconds (default: 30000) */
|
|
1982
1982
|
timeout?: number;
|
|
@@ -1988,14 +1988,14 @@ interface AISaaSClientOptionsTokenProvider {
|
|
|
1988
1988
|
/**
|
|
1989
1989
|
* All client options
|
|
1990
1990
|
*/
|
|
1991
|
-
type
|
|
1991
|
+
type CadraClientOptions = CadraClientOptionsApiKey | CadraClientOptionsToken | CadraClientOptionsTokenProvider;
|
|
1992
1992
|
/**
|
|
1993
1993
|
* AI SaaS Client
|
|
1994
1994
|
*
|
|
1995
1995
|
* Main class for interacting with the AI SaaS API.
|
|
1996
1996
|
* Provides access to all resource APIs (agents, skills, tools, artifacts, sessions).
|
|
1997
1997
|
*/
|
|
1998
|
-
declare class
|
|
1998
|
+
declare class CadraClient {
|
|
1999
1999
|
private readonly httpClient;
|
|
2000
2000
|
private readonly config;
|
|
2001
2001
|
/**
|
|
@@ -2026,25 +2026,25 @@ declare class AISaaSClient {
|
|
|
2026
2026
|
* @example
|
|
2027
2027
|
* ```typescript
|
|
2028
2028
|
* // API key authentication
|
|
2029
|
-
* const client = new
|
|
2029
|
+
* const client = new CadraClient({
|
|
2030
2030
|
* apiKey: 'sk_...',
|
|
2031
2031
|
* orgId: 123,
|
|
2032
2032
|
* });
|
|
2033
2033
|
*
|
|
2034
2034
|
* // OAuth token authentication
|
|
2035
|
-
* const client = new
|
|
2035
|
+
* const client = new CadraClient({
|
|
2036
2036
|
* token: 'eyJ...',
|
|
2037
2037
|
* orgId: 123,
|
|
2038
2038
|
* });
|
|
2039
2039
|
*
|
|
2040
2040
|
* // Token provider (for automatic refresh)
|
|
2041
|
-
* const client = new
|
|
2041
|
+
* const client = new CadraClient({
|
|
2042
2042
|
* tokenProvider: async () => myAuth.getAccessToken(),
|
|
2043
2043
|
* orgId: 123,
|
|
2044
2044
|
* });
|
|
2045
2045
|
* ```
|
|
2046
2046
|
*/
|
|
2047
|
-
constructor(options:
|
|
2047
|
+
constructor(options: CadraClientOptions);
|
|
2048
2048
|
/**
|
|
2049
2049
|
* Validate client options
|
|
2050
2050
|
*/
|
|
@@ -2055,12 +2055,12 @@ declare class AISaaSClient {
|
|
|
2055
2055
|
* SDK Error Classes
|
|
2056
2056
|
*
|
|
2057
2057
|
* Typed error hierarchy for all SDK operations.
|
|
2058
|
-
* All errors extend
|
|
2058
|
+
* All errors extend CadraError and include code, status, and optional details.
|
|
2059
2059
|
*/
|
|
2060
2060
|
/**
|
|
2061
2061
|
* Base error class for all SDK errors
|
|
2062
2062
|
*/
|
|
2063
|
-
declare class
|
|
2063
|
+
declare class CadraError extends Error {
|
|
2064
2064
|
/** Error code */
|
|
2065
2065
|
readonly code: string;
|
|
2066
2066
|
/** HTTP status code */
|
|
@@ -2075,28 +2075,28 @@ declare class AISaaSError extends Error {
|
|
|
2075
2075
|
* Authentication error (401)
|
|
2076
2076
|
* Thrown when API key is invalid, expired, or missing
|
|
2077
2077
|
*/
|
|
2078
|
-
declare class AuthenticationError extends
|
|
2078
|
+
declare class AuthenticationError extends CadraError {
|
|
2079
2079
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2080
2080
|
}
|
|
2081
2081
|
/**
|
|
2082
2082
|
* Authorization error (403)
|
|
2083
2083
|
* Thrown when user lacks permission for the requested operation
|
|
2084
2084
|
*/
|
|
2085
|
-
declare class AuthorizationError extends
|
|
2085
|
+
declare class AuthorizationError extends CadraError {
|
|
2086
2086
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2087
2087
|
}
|
|
2088
2088
|
/**
|
|
2089
2089
|
* Not found error (404)
|
|
2090
2090
|
* Thrown when requested resource does not exist
|
|
2091
2091
|
*/
|
|
2092
|
-
declare class NotFoundError extends
|
|
2092
|
+
declare class NotFoundError extends CadraError {
|
|
2093
2093
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2094
2094
|
}
|
|
2095
2095
|
/**
|
|
2096
2096
|
* Validation error (400/422)
|
|
2097
2097
|
* Thrown when request input is invalid
|
|
2098
2098
|
*/
|
|
2099
|
-
declare class ValidationError extends
|
|
2099
|
+
declare class ValidationError extends CadraError {
|
|
2100
2100
|
/** Field-level validation errors */
|
|
2101
2101
|
readonly errors: Array<{
|
|
2102
2102
|
field: string;
|
|
@@ -2111,7 +2111,7 @@ declare class ValidationError extends AISaaSError {
|
|
|
2111
2111
|
* Rate limit error (429)
|
|
2112
2112
|
* Thrown when rate limit is exceeded
|
|
2113
2113
|
*/
|
|
2114
|
-
declare class RateLimitError extends
|
|
2114
|
+
declare class RateLimitError extends CadraError {
|
|
2115
2115
|
/** Seconds until rate limit resets */
|
|
2116
2116
|
readonly retryAfter?: number;
|
|
2117
2117
|
constructor(message?: string, retryAfter?: number, details?: Record<string, unknown>, requestId?: string);
|
|
@@ -2120,29 +2120,29 @@ declare class RateLimitError extends AISaaSError {
|
|
|
2120
2120
|
* Server error (5xx)
|
|
2121
2121
|
* Thrown for server-side errors
|
|
2122
2122
|
*/
|
|
2123
|
-
declare class ServerError extends
|
|
2123
|
+
declare class ServerError extends CadraError {
|
|
2124
2124
|
constructor(message?: string, status?: number, details?: Record<string, unknown>, requestId?: string);
|
|
2125
2125
|
}
|
|
2126
2126
|
/**
|
|
2127
2127
|
* Conflict error (409)
|
|
2128
2128
|
* Thrown when there is a resource conflict
|
|
2129
2129
|
*/
|
|
2130
|
-
declare class ConflictError extends
|
|
2130
|
+
declare class ConflictError extends CadraError {
|
|
2131
2131
|
constructor(message?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2132
2132
|
}
|
|
2133
2133
|
/**
|
|
2134
2134
|
* Timeout error
|
|
2135
2135
|
* Thrown when a request or operation times out
|
|
2136
2136
|
*/
|
|
2137
|
-
declare class TimeoutError extends
|
|
2137
|
+
declare class TimeoutError extends CadraError {
|
|
2138
2138
|
constructor(message?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2139
2139
|
}
|
|
2140
2140
|
/**
|
|
2141
2141
|
* Network error
|
|
2142
2142
|
* Thrown when there is a network connectivity issue
|
|
2143
2143
|
*/
|
|
2144
|
-
declare class NetworkError extends
|
|
2144
|
+
declare class NetworkError extends CadraError {
|
|
2145
2145
|
constructor(message?: string, details?: Record<string, unknown>);
|
|
2146
2146
|
}
|
|
2147
2147
|
|
|
2148
|
-
export { AISaaSClient, type AISaaSClientOptions, AISaaSError, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentStatus, type AgentType, type AgentUpdateInput, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, AuthenticationError, AuthorizationError, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type JSONSchema, type ListOptions, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError };
|
|
2148
|
+
export { CadraClient as AISaaSClient, type CadraClientOptions as AISaaSClientOptions, CadraError as AISaaSError, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentStatus, type AgentType, type AgentUpdateInput, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, AuthenticationError, AuthorizationError, CadraClient, type CadraClientOptions, CadraError, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type JSONSchema, type ListOptions, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1901,17 +1901,17 @@ declare class SessionsAPI extends BaseResourceAPI {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
|
|
1903
1903
|
/**
|
|
1904
|
-
*
|
|
1904
|
+
* Cadra Client
|
|
1905
1905
|
*
|
|
1906
1906
|
* Main entry point for the SDK. Provides access to all resource APIs.
|
|
1907
1907
|
*
|
|
1908
1908
|
* @example
|
|
1909
1909
|
* ```typescript
|
|
1910
|
-
* import {
|
|
1910
|
+
* import { CadraClient } from '@cadraos/sdk';
|
|
1911
1911
|
*
|
|
1912
|
-
* const client = new
|
|
1913
|
-
* apiKey: process.env.
|
|
1914
|
-
* orgId: Number(process.env.
|
|
1912
|
+
* const client = new CadraClient({
|
|
1913
|
+
* apiKey: process.env.CADRA_API_KEY,
|
|
1914
|
+
* orgId: Number(process.env.CADRA_ORG_ID),
|
|
1915
1915
|
* });
|
|
1916
1916
|
*
|
|
1917
1917
|
* // List agents
|
|
@@ -1937,12 +1937,12 @@ declare class SessionsAPI extends BaseResourceAPI {
|
|
|
1937
1937
|
/**
|
|
1938
1938
|
* Client options for API key authentication
|
|
1939
1939
|
*/
|
|
1940
|
-
interface
|
|
1940
|
+
interface CadraClientOptionsApiKey {
|
|
1941
1941
|
/** API key for authentication */
|
|
1942
1942
|
apiKey: string;
|
|
1943
1943
|
/** Organization ID */
|
|
1944
1944
|
orgId: number;
|
|
1945
|
-
/** Base URL for API (default: https://api.
|
|
1945
|
+
/** Base URL for API (default: https://api.cadraos.com) */
|
|
1946
1946
|
baseUrl?: string;
|
|
1947
1947
|
/** Request timeout in milliseconds (default: 30000) */
|
|
1948
1948
|
timeout?: number;
|
|
@@ -1954,12 +1954,12 @@ interface AISaaSClientOptionsApiKey {
|
|
|
1954
1954
|
/**
|
|
1955
1955
|
* Client options for OAuth token authentication
|
|
1956
1956
|
*/
|
|
1957
|
-
interface
|
|
1957
|
+
interface CadraClientOptionsToken {
|
|
1958
1958
|
/** OAuth token for authentication */
|
|
1959
1959
|
token: string;
|
|
1960
1960
|
/** Organization ID */
|
|
1961
1961
|
orgId: number;
|
|
1962
|
-
/** Base URL for API (default: https://api.
|
|
1962
|
+
/** Base URL for API (default: https://api.cadraos.com) */
|
|
1963
1963
|
baseUrl?: string;
|
|
1964
1964
|
/** Request timeout in milliseconds (default: 30000) */
|
|
1965
1965
|
timeout?: number;
|
|
@@ -1971,12 +1971,12 @@ interface AISaaSClientOptionsToken {
|
|
|
1971
1971
|
/**
|
|
1972
1972
|
* Client options for token provider authentication
|
|
1973
1973
|
*/
|
|
1974
|
-
interface
|
|
1974
|
+
interface CadraClientOptionsTokenProvider {
|
|
1975
1975
|
/** Token provider callback (called before each request) */
|
|
1976
1976
|
tokenProvider: () => Promise<string>;
|
|
1977
1977
|
/** Organization ID */
|
|
1978
1978
|
orgId: number;
|
|
1979
|
-
/** Base URL for API (default: https://api.
|
|
1979
|
+
/** Base URL for API (default: https://api.cadraos.com) */
|
|
1980
1980
|
baseUrl?: string;
|
|
1981
1981
|
/** Request timeout in milliseconds (default: 30000) */
|
|
1982
1982
|
timeout?: number;
|
|
@@ -1988,14 +1988,14 @@ interface AISaaSClientOptionsTokenProvider {
|
|
|
1988
1988
|
/**
|
|
1989
1989
|
* All client options
|
|
1990
1990
|
*/
|
|
1991
|
-
type
|
|
1991
|
+
type CadraClientOptions = CadraClientOptionsApiKey | CadraClientOptionsToken | CadraClientOptionsTokenProvider;
|
|
1992
1992
|
/**
|
|
1993
1993
|
* AI SaaS Client
|
|
1994
1994
|
*
|
|
1995
1995
|
* Main class for interacting with the AI SaaS API.
|
|
1996
1996
|
* Provides access to all resource APIs (agents, skills, tools, artifacts, sessions).
|
|
1997
1997
|
*/
|
|
1998
|
-
declare class
|
|
1998
|
+
declare class CadraClient {
|
|
1999
1999
|
private readonly httpClient;
|
|
2000
2000
|
private readonly config;
|
|
2001
2001
|
/**
|
|
@@ -2026,25 +2026,25 @@ declare class AISaaSClient {
|
|
|
2026
2026
|
* @example
|
|
2027
2027
|
* ```typescript
|
|
2028
2028
|
* // API key authentication
|
|
2029
|
-
* const client = new
|
|
2029
|
+
* const client = new CadraClient({
|
|
2030
2030
|
* apiKey: 'sk_...',
|
|
2031
2031
|
* orgId: 123,
|
|
2032
2032
|
* });
|
|
2033
2033
|
*
|
|
2034
2034
|
* // OAuth token authentication
|
|
2035
|
-
* const client = new
|
|
2035
|
+
* const client = new CadraClient({
|
|
2036
2036
|
* token: 'eyJ...',
|
|
2037
2037
|
* orgId: 123,
|
|
2038
2038
|
* });
|
|
2039
2039
|
*
|
|
2040
2040
|
* // Token provider (for automatic refresh)
|
|
2041
|
-
* const client = new
|
|
2041
|
+
* const client = new CadraClient({
|
|
2042
2042
|
* tokenProvider: async () => myAuth.getAccessToken(),
|
|
2043
2043
|
* orgId: 123,
|
|
2044
2044
|
* });
|
|
2045
2045
|
* ```
|
|
2046
2046
|
*/
|
|
2047
|
-
constructor(options:
|
|
2047
|
+
constructor(options: CadraClientOptions);
|
|
2048
2048
|
/**
|
|
2049
2049
|
* Validate client options
|
|
2050
2050
|
*/
|
|
@@ -2055,12 +2055,12 @@ declare class AISaaSClient {
|
|
|
2055
2055
|
* SDK Error Classes
|
|
2056
2056
|
*
|
|
2057
2057
|
* Typed error hierarchy for all SDK operations.
|
|
2058
|
-
* All errors extend
|
|
2058
|
+
* All errors extend CadraError and include code, status, and optional details.
|
|
2059
2059
|
*/
|
|
2060
2060
|
/**
|
|
2061
2061
|
* Base error class for all SDK errors
|
|
2062
2062
|
*/
|
|
2063
|
-
declare class
|
|
2063
|
+
declare class CadraError extends Error {
|
|
2064
2064
|
/** Error code */
|
|
2065
2065
|
readonly code: string;
|
|
2066
2066
|
/** HTTP status code */
|
|
@@ -2075,28 +2075,28 @@ declare class AISaaSError extends Error {
|
|
|
2075
2075
|
* Authentication error (401)
|
|
2076
2076
|
* Thrown when API key is invalid, expired, or missing
|
|
2077
2077
|
*/
|
|
2078
|
-
declare class AuthenticationError extends
|
|
2078
|
+
declare class AuthenticationError extends CadraError {
|
|
2079
2079
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2080
2080
|
}
|
|
2081
2081
|
/**
|
|
2082
2082
|
* Authorization error (403)
|
|
2083
2083
|
* Thrown when user lacks permission for the requested operation
|
|
2084
2084
|
*/
|
|
2085
|
-
declare class AuthorizationError extends
|
|
2085
|
+
declare class AuthorizationError extends CadraError {
|
|
2086
2086
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2087
2087
|
}
|
|
2088
2088
|
/**
|
|
2089
2089
|
* Not found error (404)
|
|
2090
2090
|
* Thrown when requested resource does not exist
|
|
2091
2091
|
*/
|
|
2092
|
-
declare class NotFoundError extends
|
|
2092
|
+
declare class NotFoundError extends CadraError {
|
|
2093
2093
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2094
2094
|
}
|
|
2095
2095
|
/**
|
|
2096
2096
|
* Validation error (400/422)
|
|
2097
2097
|
* Thrown when request input is invalid
|
|
2098
2098
|
*/
|
|
2099
|
-
declare class ValidationError extends
|
|
2099
|
+
declare class ValidationError extends CadraError {
|
|
2100
2100
|
/** Field-level validation errors */
|
|
2101
2101
|
readonly errors: Array<{
|
|
2102
2102
|
field: string;
|
|
@@ -2111,7 +2111,7 @@ declare class ValidationError extends AISaaSError {
|
|
|
2111
2111
|
* Rate limit error (429)
|
|
2112
2112
|
* Thrown when rate limit is exceeded
|
|
2113
2113
|
*/
|
|
2114
|
-
declare class RateLimitError extends
|
|
2114
|
+
declare class RateLimitError extends CadraError {
|
|
2115
2115
|
/** Seconds until rate limit resets */
|
|
2116
2116
|
readonly retryAfter?: number;
|
|
2117
2117
|
constructor(message?: string, retryAfter?: number, details?: Record<string, unknown>, requestId?: string);
|
|
@@ -2120,29 +2120,29 @@ declare class RateLimitError extends AISaaSError {
|
|
|
2120
2120
|
* Server error (5xx)
|
|
2121
2121
|
* Thrown for server-side errors
|
|
2122
2122
|
*/
|
|
2123
|
-
declare class ServerError extends
|
|
2123
|
+
declare class ServerError extends CadraError {
|
|
2124
2124
|
constructor(message?: string, status?: number, details?: Record<string, unknown>, requestId?: string);
|
|
2125
2125
|
}
|
|
2126
2126
|
/**
|
|
2127
2127
|
* Conflict error (409)
|
|
2128
2128
|
* Thrown when there is a resource conflict
|
|
2129
2129
|
*/
|
|
2130
|
-
declare class ConflictError extends
|
|
2130
|
+
declare class ConflictError extends CadraError {
|
|
2131
2131
|
constructor(message?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2132
2132
|
}
|
|
2133
2133
|
/**
|
|
2134
2134
|
* Timeout error
|
|
2135
2135
|
* Thrown when a request or operation times out
|
|
2136
2136
|
*/
|
|
2137
|
-
declare class TimeoutError extends
|
|
2137
|
+
declare class TimeoutError extends CadraError {
|
|
2138
2138
|
constructor(message?: string, details?: Record<string, unknown>, requestId?: string);
|
|
2139
2139
|
}
|
|
2140
2140
|
/**
|
|
2141
2141
|
* Network error
|
|
2142
2142
|
* Thrown when there is a network connectivity issue
|
|
2143
2143
|
*/
|
|
2144
|
-
declare class NetworkError extends
|
|
2144
|
+
declare class NetworkError extends CadraError {
|
|
2145
2145
|
constructor(message?: string, details?: Record<string, unknown>);
|
|
2146
2146
|
}
|
|
2147
2147
|
|
|
2148
|
-
export { AISaaSClient, type AISaaSClientOptions, AISaaSError, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentStatus, type AgentType, type AgentUpdateInput, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, AuthenticationError, AuthorizationError, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type JSONSchema, type ListOptions, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError };
|
|
2148
|
+
export { CadraClient as AISaaSClient, type CadraClientOptions as AISaaSClientOptions, CadraError as AISaaSError, type Agent, type AgentConfig, type AgentConfigUpdateInput, type AgentExecution, type AgentListOptions, type AgentStatus, type AgentType, type AgentUpdateInput, type Artifact, type ArtifactDownloadOptions, type ArtifactListOptions, type ArtifactType, type ArtifactUploadInput, AuthenticationError, AuthorizationError, CadraClient, type CadraClientOptions, CadraError, type CompleteEvent, ConflictError, type ConnectionChangeEvent, type DelegationCompletedEvent, type DelegationStartedEvent, type ErrorEvent, type ExecuteInput, type ExecuteOptions, type ExecuteResponse, type ExecuteToolDirectRequest, type ExecuteToolDirectResponse, type ExecutionLog, type ExecutionStatus, type ExecutionStreamController, type ExecutionStreamControllerOptions, type JSONSchema, type ListOptions, NetworkError, NotFoundError, type PaginatedResponse, type PaginationInfo, type PausedEvent, type PlanEvent, type ProgressEvent, RateLimitError, type SendMessageInput, ServerError, type Session, type SessionArtifact, type SessionArtifactListOptions, type SessionArtifactType, type SessionArtifactVariantType, type SessionCreateInput, type SessionHistory, type SessionListOptions, type SessionMessage, type SignedUrlResponse, type Skill, type SkillDetails, type SkillExecuteInput, type SkillExecution, type SkillListOptions, type SkillTool, type SkillUpdateInput, type SkillVariable, type StartedEvent, type StreamController, type StreamEventMap, type TextDeltaEvent, TimeoutError, type TokenUsage, type Tool, type ToolCallEvent, type ToolConfigUpdateInput, type ToolExecution, type ToolListOptions, type ToolResultEvent, type ToolUpdateInput, type ToolValidationResult, ValidationError };
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ var BaseResourceAPI = class {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
// src/errors/sdk-errors.ts
|
|
55
|
-
var
|
|
55
|
+
var CadraError = class extends Error {
|
|
56
56
|
/** Error code */
|
|
57
57
|
code;
|
|
58
58
|
/** HTTP status code */
|
|
@@ -63,7 +63,7 @@ var AISaaSError = class extends Error {
|
|
|
63
63
|
requestId;
|
|
64
64
|
constructor(message, code, status, details, requestId) {
|
|
65
65
|
super(message);
|
|
66
|
-
this.name = "
|
|
66
|
+
this.name = "CadraError";
|
|
67
67
|
this.code = code;
|
|
68
68
|
this.status = status;
|
|
69
69
|
this.details = details;
|
|
@@ -73,25 +73,25 @@ var AISaaSError = class extends Error {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
var AuthenticationError = class extends
|
|
76
|
+
var AuthenticationError = class extends CadraError {
|
|
77
77
|
constructor(message = "Authentication failed", code = "authentication_error", details, requestId) {
|
|
78
78
|
super(message, code, 401, details, requestId);
|
|
79
79
|
this.name = "AuthenticationError";
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
var AuthorizationError = class extends
|
|
82
|
+
var AuthorizationError = class extends CadraError {
|
|
83
83
|
constructor(message = "Access denied", code = "authorization_error", details, requestId) {
|
|
84
84
|
super(message, code, 403, details, requestId);
|
|
85
85
|
this.name = "AuthorizationError";
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
var NotFoundError = class extends
|
|
88
|
+
var NotFoundError = class extends CadraError {
|
|
89
89
|
constructor(message = "Resource not found", code = "not_found", details, requestId) {
|
|
90
90
|
super(message, code, 404, details, requestId);
|
|
91
91
|
this.name = "NotFoundError";
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
var ValidationError = class extends
|
|
94
|
+
var ValidationError = class extends CadraError {
|
|
95
95
|
/** Field-level validation errors */
|
|
96
96
|
errors;
|
|
97
97
|
constructor(message = "Validation failed", errors = [], details, requestId) {
|
|
@@ -100,7 +100,7 @@ var ValidationError = class extends AISaaSError {
|
|
|
100
100
|
this.errors = errors;
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
var RateLimitError = class extends
|
|
103
|
+
var RateLimitError = class extends CadraError {
|
|
104
104
|
/** Seconds until rate limit resets */
|
|
105
105
|
retryAfter;
|
|
106
106
|
constructor(message = "Rate limit exceeded", retryAfter, details, requestId) {
|
|
@@ -109,25 +109,25 @@ var RateLimitError = class extends AISaaSError {
|
|
|
109
109
|
this.retryAfter = retryAfter;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
var ServerError = class extends
|
|
112
|
+
var ServerError = class extends CadraError {
|
|
113
113
|
constructor(message = "Server error", status = 500, details, requestId) {
|
|
114
114
|
super(message, "server_error", status, details, requestId);
|
|
115
115
|
this.name = "ServerError";
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
var ConflictError = class extends
|
|
118
|
+
var ConflictError = class extends CadraError {
|
|
119
119
|
constructor(message = "Resource conflict", details, requestId) {
|
|
120
120
|
super(message, "conflict", 409, details, requestId);
|
|
121
121
|
this.name = "ConflictError";
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
var TimeoutError = class extends
|
|
124
|
+
var TimeoutError = class extends CadraError {
|
|
125
125
|
constructor(message = "Request timed out", details, requestId) {
|
|
126
126
|
super(message, "timeout", 408, details, requestId);
|
|
127
127
|
this.name = "TimeoutError";
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
var NetworkError = class extends
|
|
130
|
+
var NetworkError = class extends CadraError {
|
|
131
131
|
constructor(message = "Network error", details) {
|
|
132
132
|
super(message, "network_error", 0, details);
|
|
133
133
|
this.name = "NetworkError";
|
|
@@ -169,7 +169,7 @@ function parseApiError(status, body, requestId) {
|
|
|
169
169
|
if (status >= 500) {
|
|
170
170
|
return new ServerError(message, status, details, requestId);
|
|
171
171
|
}
|
|
172
|
-
return new
|
|
172
|
+
return new CadraError(message, code, status, details, requestId);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -257,15 +257,21 @@ var HttpClient = class {
|
|
|
257
257
|
* Build full URL with query parameters
|
|
258
258
|
*/
|
|
259
259
|
buildUrl(path, query) {
|
|
260
|
-
const
|
|
260
|
+
const base = this.config.baseUrl.replace(/\/+$/, "");
|
|
261
|
+
let url = `${base}${path}`;
|
|
261
262
|
if (query) {
|
|
263
|
+
const params = new URLSearchParams();
|
|
262
264
|
for (const [key, value] of Object.entries(query)) {
|
|
263
265
|
if (value !== void 0) {
|
|
264
|
-
|
|
266
|
+
params.set(key, String(value));
|
|
265
267
|
}
|
|
266
268
|
}
|
|
269
|
+
const qs = params.toString();
|
|
270
|
+
if (qs) {
|
|
271
|
+
url += `?${qs}`;
|
|
272
|
+
}
|
|
267
273
|
}
|
|
268
|
-
return url
|
|
274
|
+
return url;
|
|
269
275
|
}
|
|
270
276
|
/**
|
|
271
277
|
* Make an HTTP request
|
|
@@ -665,7 +671,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
665
671
|
return Promise.resolve(this.finalExecution);
|
|
666
672
|
}
|
|
667
673
|
if (this.finalError) {
|
|
668
|
-
return Promise.reject(new
|
|
674
|
+
return Promise.reject(new CadraError(
|
|
669
675
|
this.finalError.error,
|
|
670
676
|
this.finalError.errorCode ?? "execution_error",
|
|
671
677
|
500
|
|
@@ -684,7 +690,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
684
690
|
* Connect to SSE endpoint
|
|
685
691
|
*/
|
|
686
692
|
async connectSSE() {
|
|
687
|
-
const
|
|
693
|
+
const base = this.options.baseUrl.replace(/\/+$/, "");
|
|
694
|
+
const url = `${base}/api/v1/agents/runs/${this.options.executionId}/stream`;
|
|
688
695
|
let authToken = this.options.apiKey;
|
|
689
696
|
if (!authToken && this.options.tokenProvider) {
|
|
690
697
|
authToken = await this.options.tokenProvider();
|
|
@@ -919,7 +926,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
919
926
|
this.finalError = error;
|
|
920
927
|
this.emit("error", error);
|
|
921
928
|
if (this.waitReject) {
|
|
922
|
-
this.waitReject(new
|
|
929
|
+
this.waitReject(new CadraError(
|
|
923
930
|
error.error,
|
|
924
931
|
error.errorCode ?? "execution_error",
|
|
925
932
|
500
|
|
@@ -1037,7 +1044,7 @@ function createExecutionStreamController(options) {
|
|
|
1037
1044
|
// src/resources/agents.ts
|
|
1038
1045
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1039
1046
|
constructor(http, getStreamConfig) {
|
|
1040
|
-
super(http, "/agents");
|
|
1047
|
+
super(http, "/api/v1/agents");
|
|
1041
1048
|
this.getStreamConfig = getStreamConfig;
|
|
1042
1049
|
}
|
|
1043
1050
|
// ===== LIST Operations =====
|
|
@@ -1313,7 +1320,7 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1313
1320
|
// src/resources/skills.ts
|
|
1314
1321
|
var SkillsAPI = class extends BaseResourceAPI {
|
|
1315
1322
|
constructor(http) {
|
|
1316
|
-
super(http, "/skills");
|
|
1323
|
+
super(http, "/api/v1/skills");
|
|
1317
1324
|
}
|
|
1318
1325
|
// ===== LIST Operations =====
|
|
1319
1326
|
/**
|
|
@@ -1457,7 +1464,7 @@ var SkillsAPI = class extends BaseResourceAPI {
|
|
|
1457
1464
|
// src/resources/tools.ts
|
|
1458
1465
|
var ToolsAPI = class extends BaseResourceAPI {
|
|
1459
1466
|
constructor(http) {
|
|
1460
|
-
super(http, "/tools");
|
|
1467
|
+
super(http, "/api/v1/tools");
|
|
1461
1468
|
}
|
|
1462
1469
|
// ===== LIST Operations =====
|
|
1463
1470
|
/**
|
|
@@ -1620,7 +1627,7 @@ var ToolsAPI = class extends BaseResourceAPI {
|
|
|
1620
1627
|
// src/resources/artifacts.ts
|
|
1621
1628
|
var ArtifactsAPI = class extends BaseResourceAPI {
|
|
1622
1629
|
constructor(http) {
|
|
1623
|
-
super(http, "/artifacts");
|
|
1630
|
+
super(http, "/api/v1/artifacts");
|
|
1624
1631
|
}
|
|
1625
1632
|
// ===== LIST Operations =====
|
|
1626
1633
|
/**
|
|
@@ -1816,7 +1823,7 @@ var ArtifactsAPI = class extends BaseResourceAPI {
|
|
|
1816
1823
|
// src/resources/sessions.ts
|
|
1817
1824
|
var SessionsAPI = class extends BaseResourceAPI {
|
|
1818
1825
|
constructor(http, getStreamConfig) {
|
|
1819
|
-
super(http, "/sessions");
|
|
1826
|
+
super(http, "/api/v1/sessions");
|
|
1820
1827
|
this.getStreamConfig = getStreamConfig;
|
|
1821
1828
|
}
|
|
1822
1829
|
// ===== LIST Operations =====
|
|
@@ -2047,9 +2054,9 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2047
2054
|
};
|
|
2048
2055
|
|
|
2049
2056
|
// src/client.ts
|
|
2050
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
2057
|
+
var DEFAULT_BASE_URL = "https://api.cadraos.com";
|
|
2051
2058
|
var DEFAULT_TIMEOUT = 3e4;
|
|
2052
|
-
var
|
|
2059
|
+
var CadraClient = class {
|
|
2053
2060
|
httpClient;
|
|
2054
2061
|
config;
|
|
2055
2062
|
/**
|
|
@@ -2080,19 +2087,19 @@ var AISaaSClient = class {
|
|
|
2080
2087
|
* @example
|
|
2081
2088
|
* ```typescript
|
|
2082
2089
|
* // API key authentication
|
|
2083
|
-
* const client = new
|
|
2090
|
+
* const client = new CadraClient({
|
|
2084
2091
|
* apiKey: 'sk_...',
|
|
2085
2092
|
* orgId: 123,
|
|
2086
2093
|
* });
|
|
2087
2094
|
*
|
|
2088
2095
|
* // OAuth token authentication
|
|
2089
|
-
* const client = new
|
|
2096
|
+
* const client = new CadraClient({
|
|
2090
2097
|
* token: 'eyJ...',
|
|
2091
2098
|
* orgId: 123,
|
|
2092
2099
|
* });
|
|
2093
2100
|
*
|
|
2094
2101
|
* // Token provider (for automatic refresh)
|
|
2095
|
-
* const client = new
|
|
2102
|
+
* const client = new CadraClient({
|
|
2096
2103
|
* tokenProvider: async () => myAuth.getAccessToken(),
|
|
2097
2104
|
* orgId: 123,
|
|
2098
2105
|
* });
|
|
@@ -2100,6 +2107,19 @@ var AISaaSClient = class {
|
|
|
2100
2107
|
*/
|
|
2101
2108
|
constructor(options) {
|
|
2102
2109
|
this.validateOptions(options);
|
|
2110
|
+
if (options.baseUrl) {
|
|
2111
|
+
try {
|
|
2112
|
+
const parsed = new URL(options.baseUrl);
|
|
2113
|
+
if (/\/(api|v\d)/.test(parsed.pathname)) {
|
|
2114
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
2115
|
+
console.warn(
|
|
2116
|
+
`[CadraOS SDK] baseUrl should be the origin only (e.g., "https://api.cadraos.com" or "http://localhost:3000"). The SDK automatically prepends "/api/v1/" to all requests. Received: "${options.baseUrl}"`
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
} catch {
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2103
2123
|
this.config = {
|
|
2104
2124
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
2105
2125
|
orgId: options.orgId,
|
|
@@ -2162,6 +2182,6 @@ var AISaaSClient = class {
|
|
|
2162
2182
|
}
|
|
2163
2183
|
};
|
|
2164
2184
|
|
|
2165
|
-
export { AISaaSClient, AISaaSError, AuthenticationError, AuthorizationError, ConflictError, NetworkError, NotFoundError, RateLimitError, ServerError, TimeoutError, ValidationError };
|
|
2185
|
+
export { CadraClient as AISaaSClient, CadraError as AISaaSError, AuthenticationError, AuthorizationError, CadraClient, CadraError, ConflictError, NetworkError, NotFoundError, RateLimitError, ServerError, TimeoutError, ValidationError };
|
|
2166
2186
|
//# sourceMappingURL=index.js.map
|
|
2167
2187
|
//# sourceMappingURL=index.js.map
|