sylix 3.1.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,13 +1,112 @@
1
+ /**
2
+ * Sylix SDK Client
3
+ * OpenAI-compatible HTTP client with retries, timeout, and configuration
4
+ *
5
+ * Owned by Sylix Technologies © 2026
6
+ */
1
7
  import { AxiosInstance } from "axios";
2
- import { SylixConfig } from "./types.js";
8
+ /**
9
+ * Client configuration (OpenAI-compatible)
10
+ */
11
+ export interface SylixConfig {
12
+ /**
13
+ * API Key for authentication
14
+ */
15
+ apiKey: string;
16
+ /**
17
+ * Organization ID (optional)
18
+ */
19
+ organization?: string;
20
+ /**
21
+ * Project ID (optional)
22
+ */
23
+ project?: string;
24
+ /**
25
+ * Base URL for API requests
26
+ * @default "https://api.sylixide.com/v1"
27
+ */
28
+ baseURL?: string;
29
+ /**
30
+ * Request timeout in milliseconds
31
+ * @default 600000 (10 minutes)
32
+ */
33
+ timeout?: number;
34
+ /**
35
+ * Maximum number of retries for failed requests
36
+ * @default 2
37
+ */
38
+ maxRetries?: number;
39
+ /**
40
+ * Default headers to include in requests
41
+ */
42
+ defaultHeaders?: Record<string, string>;
43
+ /**
44
+ * Default query parameters
45
+ */
46
+ defaultQuery?: Record<string, string>;
47
+ /**
48
+ * Custom fetch implementation
49
+ */
50
+ fetch?: typeof fetch;
51
+ /**
52
+ * Allow browser usage (for client-side apps)
53
+ * @default false
54
+ */
55
+ dangerouslyAllowBrowser?: boolean;
56
+ }
3
57
  export declare class SylixClient {
4
58
  private client;
5
59
  private apiKey;
6
60
  private baseURL;
61
+ private organization?;
62
+ private project?;
63
+ private maxRetries;
64
+ private timeout;
65
+ private customFetch?;
7
66
  constructor(config: SylixConfig);
67
+ /**
68
+ * Setup automatic retry logic with exponential backoff
69
+ */
70
+ private setupRetryInterceptor;
71
+ /**
72
+ * Determine if request should be retried
73
+ */
74
+ private shouldRetry;
75
+ /**
76
+ * Sleep helper
77
+ */
78
+ private sleep;
79
+ /**
80
+ * Wrap axios errors in API error types
81
+ */
82
+ private wrapError;
83
+ /**
84
+ * Validate model ID
85
+ */
8
86
  validateModel(model: string): void;
87
+ /**
88
+ * Get axios client instance
89
+ */
9
90
  getClient(): AxiosInstance;
91
+ /**
92
+ * Get base URL
93
+ */
10
94
  getBaseURL(): string;
95
+ /**
96
+ * Get API key
97
+ */
11
98
  getApiKey(): string;
99
+ /**
100
+ * Get custom fetch if provided
101
+ */
102
+ getFetch(): typeof fetch;
103
+ /**
104
+ * Get organization ID
105
+ */
106
+ getOrganization(): string | undefined;
107
+ /**
108
+ * Get project ID
109
+ */
110
+ getProject(): string | undefined;
12
111
  }
13
112
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAiC,MAAM,YAAY,CAAC;AAExE,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,WAAW;IA+C/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWlC,SAAS,IAAI,aAAa;IAI1B,UAAU,IAAI,MAAM;IAIpB,SAAS,IAAI,MAAM;CAGpB"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AAUjE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,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ANGED
@@ -1,51 +1,157 @@
1
+ /**
2
+ * Sylix SDK Client
3
+ * OpenAI-compatible HTTP client with retries, timeout, and configuration
4
+ *
5
+ * Owned by Sylix Technologies © 2026
6
+ */
1
7
  import axios from "axios";
2
- import { SylixError, CHARLES_MODEL_IDS } from "./types.js";
8
+ import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from "./errors.js";
9
+ import { CHARLES_MODEL_IDS } from "./types.js";
3
10
  export class SylixClient {
4
11
  constructor(config) {
5
12
  if (!config.apiKey) {
6
- throw new SylixError("MISSING_API_KEY", "apiKey is required. Get your API key from https://sylixide.com");
13
+ throw new AuthenticationError(401, { message: "Missing API key" }, "apiKey is required. Get your API key from https://sylixide.com", undefined);
14
+ }
15
+ // Browser check
16
+ if (typeof globalThis !== 'undefined' && typeof globalThis.window !== 'undefined' && !config.dangerouslyAllowBrowser) {
17
+ console.warn("Sylix SDK: It looks like you're running in a browser. " +
18
+ "Set dangerouslyAllowBrowser: true to suppress this warning.");
7
19
  }
8
20
  this.apiKey = config.apiKey;
9
21
  this.baseURL = config.baseURL || "https://api.sylixide.com/v1";
22
+ this.organization = config.organization;
23
+ this.project = config.project;
24
+ this.maxRetries = config.maxRetries ?? 2;
25
+ this.timeout = config.timeout ?? 600000; // 10 minutes default like OpenAI
26
+ this.customFetch = config.fetch;
10
27
  const headers = {
11
28
  "Content-Type": "application/json",
29
+ "Authorization": `Bearer ${this.apiKey}`,
12
30
  "x-api-key": this.apiKey,
13
- ...(config.headers || {}),
31
+ ...(config.organization && { "Sylix-Organization": config.organization }),
32
+ ...(config.project && { "Sylix-Project": config.project }),
33
+ ...(config.defaultHeaders || {}),
14
34
  };
15
35
  this.client = axios.create({
16
36
  baseURL: this.baseURL,
17
- timeout: config.timeout || 30000,
37
+ timeout: this.timeout,
18
38
  headers,
39
+ params: config.defaultQuery,
19
40
  });
20
- // Add retry interceptor for 5xx errors
41
+ // Add retry interceptor
42
+ this.setupRetryInterceptor();
43
+ }
44
+ /**
45
+ * Setup automatic retry logic with exponential backoff
46
+ */
47
+ setupRetryInterceptor() {
21
48
  this.client.interceptors.response.use((response) => response, async (error) => {
22
49
  const config = error.config;
23
- if (!config)
24
- return Promise.reject(error);
25
- // Retry up to 3 times for 5xx errors
26
- config.retryCount = config.retryCount || 0;
27
- if (error.response?.status >= 500 && config.retryCount < 3) {
28
- config.retryCount++;
29
- // Exponential backoff: 1s, 2s, 4s
30
- const delay = Math.pow(2, config.retryCount - 1) * 1000;
31
- await new Promise((resolve) => setTimeout(resolve, delay));
50
+ if (!config) {
51
+ return Promise.reject(this.wrapError(error));
52
+ }
53
+ config._retryCount = config._retryCount || 0;
54
+ // Check if we should retry
55
+ const shouldRetry = this.shouldRetry(error, config._retryCount);
56
+ if (shouldRetry) {
57
+ config._retryCount++;
58
+ // Exponential backoff: 1s, 2s, 4s...
59
+ const delay = Math.pow(2, config._retryCount - 1) * 1000;
60
+ await this.sleep(delay);
32
61
  return this.client(config);
33
62
  }
34
- return Promise.reject(error);
63
+ return Promise.reject(this.wrapError(error));
35
64
  });
36
65
  }
66
+ /**
67
+ * Determine if request should be retried
68
+ */
69
+ shouldRetry(error, retryCount) {
70
+ if (retryCount >= this.maxRetries)
71
+ return false;
72
+ // Retry on network errors
73
+ if (!error.response)
74
+ return true;
75
+ // Retry on 5xx errors
76
+ if (error.response.status >= 500)
77
+ return true;
78
+ // Retry on 429 rate limit
79
+ if (error.response.status === 429)
80
+ return true;
81
+ return false;
82
+ }
83
+ /**
84
+ * Sleep helper
85
+ */
86
+ sleep(ms) {
87
+ return new Promise((resolve) => setTimeout(resolve, ms));
88
+ }
89
+ /**
90
+ * Wrap axios errors in API error types
91
+ */
92
+ wrapError(error) {
93
+ if (error.code === 'ECONNABORTED') {
94
+ return new APIConnectionTimeoutError({ message: error.message });
95
+ }
96
+ if (error.code === 'ERR_CANCELED' || error.name === 'AbortError') {
97
+ return new APIUserAbortError({ message: error.message });
98
+ }
99
+ if (!error.response) {
100
+ return new APIConnectionError({ cause: error });
101
+ }
102
+ const status = error.response.status;
103
+ const data = error.response.data;
104
+ const message = data?.error?.message || error.message;
105
+ const headers = error.response.headers;
106
+ return APIError.generate(status, data?.error, message, headers);
107
+ }
108
+ /**
109
+ * Validate model ID
110
+ */
37
111
  validateModel(model) {
112
+ // Skip validation for custom models
113
+ if (model.includes(':') || model.includes('/'))
114
+ return;
38
115
  if (!CHARLES_MODEL_IDS.includes(model)) {
39
- throw new SylixError("INVALID_MODEL", `Model "${model}" is not available in v1.0.0. Available models: ${CHARLES_MODEL_IDS.join(", ")}. To use custom models, see https://github.com/sylix-ide/sylix-sdk#custom-models`);
116
+ console.warn(`Model "${model}" may not be available. Known models: ${CHARLES_MODEL_IDS.join(", ")}`);
40
117
  }
41
118
  }
119
+ /**
120
+ * Get axios client instance
121
+ */
42
122
  getClient() {
43
123
  return this.client;
44
124
  }
125
+ /**
126
+ * Get base URL
127
+ */
45
128
  getBaseURL() {
46
129
  return this.baseURL;
47
130
  }
131
+ /**
132
+ * Get API key
133
+ */
48
134
  getApiKey() {
49
135
  return this.apiKey;
50
136
  }
137
+ /**
138
+ * Get custom fetch if provided
139
+ */
140
+ getFetch() {
141
+ return this.customFetch || fetch;
142
+ }
143
+ /**
144
+ * Get organization ID
145
+ */
146
+ getOrganization() {
147
+ return this.organization;
148
+ }
149
+ /**
150
+ * Get project ID
151
+ */
152
+ getProject() {
153
+ return this.project;
154
+ }
51
155
  }
156
+ // Re-export error for backwards compatibility
157
+ import { AuthenticationError } from "./errors.js";
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Sylix SDK Error Types
3
+ * Full OpenAI-compatible error hierarchy
4
+ *
5
+ * Owned by Sylix Technologies © 2026
6
+ */
7
+ /**
8
+ * Base API Error
9
+ */
10
+ export declare class APIError extends Error {
11
+ readonly status: number | undefined;
12
+ readonly headers: Record<string, string> | undefined;
13
+ readonly error: any;
14
+ readonly code: string | null;
15
+ readonly param: string | null;
16
+ readonly type: string | undefined;
17
+ constructor(status: number | undefined, error: any, message: string | undefined, headers: Record<string, string> | undefined);
18
+ static generate(status: number | undefined, error: any, message: string | undefined, headers: Record<string, string> | undefined): APIError;
19
+ }
20
+ /**
21
+ * Connection Error - Network issues
22
+ */
23
+ export declare class APIConnectionError extends APIError {
24
+ constructor({ cause, message }?: {
25
+ cause?: Error;
26
+ message?: string;
27
+ });
28
+ }
29
+ /**
30
+ * Connection Timeout Error
31
+ */
32
+ export declare class APIConnectionTimeoutError extends APIConnectionError {
33
+ constructor({ message }?: {
34
+ message?: string;
35
+ });
36
+ }
37
+ /**
38
+ * User Abort Error
39
+ */
40
+ export declare class APIUserAbortError extends APIError {
41
+ constructor({ message }?: {
42
+ message?: string;
43
+ });
44
+ }
45
+ /**
46
+ * 400 Bad Request
47
+ */
48
+ export declare class BadRequestError extends APIError {
49
+ readonly status: 400;
50
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
51
+ }
52
+ /**
53
+ * 401 Authentication Error
54
+ */
55
+ export declare class AuthenticationError extends APIError {
56
+ readonly status: 401;
57
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
58
+ }
59
+ /**
60
+ * 403 Permission Denied
61
+ */
62
+ export declare class PermissionDeniedError extends APIError {
63
+ readonly status: 403;
64
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
65
+ }
66
+ /**
67
+ * 404 Not Found
68
+ */
69
+ export declare class NotFoundError extends APIError {
70
+ readonly status: 404;
71
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
72
+ }
73
+ /**
74
+ * 409 Conflict
75
+ */
76
+ export declare class ConflictError extends APIError {
77
+ readonly status: 409;
78
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
79
+ }
80
+ /**
81
+ * 422 Unprocessable Entity
82
+ */
83
+ export declare class UnprocessableEntityError extends APIError {
84
+ readonly status: 422;
85
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
86
+ }
87
+ /**
88
+ * 429 Rate Limit Error
89
+ */
90
+ export declare class RateLimitError extends APIError {
91
+ readonly status: 429;
92
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
93
+ }
94
+ /**
95
+ * 5xx Internal Server Error
96
+ */
97
+ export declare class InternalServerError extends APIError {
98
+ constructor(status: number, error: any, message: string | undefined, headers: Record<string, string> | undefined);
99
+ }
100
+ /**
101
+ * Legacy SylixError for backwards compatibility
102
+ */
103
+ export declare class SylixError extends Error {
104
+ code: string;
105
+ raw?: any | undefined;
106
+ constructor(code: string, message: string, raw?: any | undefined);
107
+ }
108
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;gBAG9B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;IAY/C,MAAM,CAAC,QAAQ,CACX,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,CA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W,SAAQ,KAAK;IAEtB,IAAI,EAAE,MAAM;IAEZ,GAAG,CAAC,EAAE,GAAG;gBAFT,IAAI,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACR,GAAG,CAAC,EAAE,GAAG,YAAA;CAKvB"}
package/dist/errors.js ADDED
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Sylix SDK Error Types
3
+ * Full OpenAI-compatible error hierarchy
4
+ *
5
+ * Owned by Sylix Technologies © 2026
6
+ */
7
+ /**
8
+ * Base API Error
9
+ */
10
+ export class APIError extends Error {
11
+ constructor(status, error, message, headers) {
12
+ super(message || 'An error occurred');
13
+ this.status = status;
14
+ this.headers = headers;
15
+ this.error = error;
16
+ this.code = error?.code || null;
17
+ this.param = error?.param || null;
18
+ this.type = error?.type;
19
+ this.name = 'APIError';
20
+ }
21
+ static generate(status, error, message, headers) {
22
+ if (!status)
23
+ return new APIConnectionError({ cause: error });
24
+ if (status === 400)
25
+ return new BadRequestError(status, error, message, headers);
26
+ if (status === 401)
27
+ return new AuthenticationError(status, error, message, headers);
28
+ if (status === 403)
29
+ return new PermissionDeniedError(status, error, message, headers);
30
+ if (status === 404)
31
+ return new NotFoundError(status, error, message, headers);
32
+ if (status === 409)
33
+ return new ConflictError(status, error, message, headers);
34
+ if (status === 422)
35
+ return new UnprocessableEntityError(status, error, message, headers);
36
+ if (status === 429)
37
+ return new RateLimitError(status, error, message, headers);
38
+ if (status >= 500)
39
+ return new InternalServerError(status, error, message, headers);
40
+ return new APIError(status, error, message, headers);
41
+ }
42
+ }
43
+ /**
44
+ * Connection Error - Network issues
45
+ */
46
+ export class APIConnectionError extends APIError {
47
+ constructor({ cause, message } = {}) {
48
+ super(undefined, cause, message || 'Connection error', undefined);
49
+ this.name = 'APIConnectionError';
50
+ }
51
+ }
52
+ /**
53
+ * Connection Timeout Error
54
+ */
55
+ export class APIConnectionTimeoutError extends APIConnectionError {
56
+ constructor({ message } = {}) {
57
+ super({ message: message || 'Request timed out' });
58
+ this.name = 'APIConnectionTimeoutError';
59
+ }
60
+ }
61
+ /**
62
+ * User Abort Error
63
+ */
64
+ export class APIUserAbortError extends APIError {
65
+ constructor({ message } = {}) {
66
+ super(undefined, undefined, message || 'Request was aborted', undefined);
67
+ this.name = 'APIUserAbortError';
68
+ }
69
+ }
70
+ /**
71
+ * 400 Bad Request
72
+ */
73
+ export class BadRequestError extends APIError {
74
+ constructor(status, error, message, headers) {
75
+ super(status, error, message, headers);
76
+ this.status = 400;
77
+ this.name = 'BadRequestError';
78
+ }
79
+ }
80
+ /**
81
+ * 401 Authentication Error
82
+ */
83
+ export class AuthenticationError extends APIError {
84
+ constructor(status, error, message, headers) {
85
+ super(status, error, message, headers);
86
+ this.status = 401;
87
+ this.name = 'AuthenticationError';
88
+ }
89
+ }
90
+ /**
91
+ * 403 Permission Denied
92
+ */
93
+ export class PermissionDeniedError extends APIError {
94
+ constructor(status, error, message, headers) {
95
+ super(status, error, message, headers);
96
+ this.status = 403;
97
+ this.name = 'PermissionDeniedError';
98
+ }
99
+ }
100
+ /**
101
+ * 404 Not Found
102
+ */
103
+ export class NotFoundError extends APIError {
104
+ constructor(status, error, message, headers) {
105
+ super(status, error, message, headers);
106
+ this.status = 404;
107
+ this.name = 'NotFoundError';
108
+ }
109
+ }
110
+ /**
111
+ * 409 Conflict
112
+ */
113
+ export class ConflictError extends APIError {
114
+ constructor(status, error, message, headers) {
115
+ super(status, error, message, headers);
116
+ this.status = 409;
117
+ this.name = 'ConflictError';
118
+ }
119
+ }
120
+ /**
121
+ * 422 Unprocessable Entity
122
+ */
123
+ export class UnprocessableEntityError extends APIError {
124
+ constructor(status, error, message, headers) {
125
+ super(status, error, message, headers);
126
+ this.status = 422;
127
+ this.name = 'UnprocessableEntityError';
128
+ }
129
+ }
130
+ /**
131
+ * 429 Rate Limit Error
132
+ */
133
+ export class RateLimitError extends APIError {
134
+ constructor(status, error, message, headers) {
135
+ super(status, error, message, headers);
136
+ this.status = 429;
137
+ this.name = 'RateLimitError';
138
+ }
139
+ }
140
+ /**
141
+ * 5xx Internal Server Error
142
+ */
143
+ export class InternalServerError extends APIError {
144
+ constructor(status, error, message, headers) {
145
+ super(status, error, message, headers);
146
+ this.name = 'InternalServerError';
147
+ }
148
+ }
149
+ /**
150
+ * Legacy SylixError for backwards compatibility
151
+ */
152
+ export class SylixError extends Error {
153
+ constructor(code, message, raw) {
154
+ super(message);
155
+ this.code = code;
156
+ this.raw = raw;
157
+ this.name = "SylixError";
158
+ }
159
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SylixClient } from "./client.js";
2
- import { ChatRequest, ChatResponse, VisionRequest, VisionResponse, CodeRequest, CodeResponse, ReasonRequest, ReasonResponse, ModelInfo, SylixConfig, CharlesModel, CharlesModelsListResponse, CharlesEmbeddingRequest, CharlesEmbeddingResponse, CharlesChatRequest, ChatStreamChunk } from "./types.js";
1
+ import { SylixClient, SylixConfig } from "./client.js";
2
+ import { ChatRequest, ChatResponse, VisionRequest, VisionResponse, CodeRequest, CodeResponse, ReasonRequest, ReasonResponse, ModelInfo, CharlesModel, CharlesModelsListResponse, CharlesEmbeddingRequest, CharlesEmbeddingResponse, CharlesChatRequest, ChatStreamChunk } from "./types.js";
3
3
  import { readFile, fileToBase64 } from "./utils.js";
4
4
  /**
5
5
  * Chat completions namespace
@@ -37,37 +37,95 @@ declare class Reason {
37
37
  process(payload: ReasonRequest): Promise<ReasonResponse>;
38
38
  private handleError;
39
39
  }
40
+ /**
41
+ * Stream response wrapper with controller
42
+ */
43
+ declare class Stream<T> implements AsyncIterable<T> {
44
+ private iterator;
45
+ controller: AbortController;
46
+ constructor(iterator: AsyncGenerator<T, void, unknown>, controller: AbortController);
47
+ [Symbol.asyncIterator](): AsyncIterator<T>;
48
+ /**
49
+ * Abort the stream
50
+ */
51
+ abort(): void;
52
+ /**
53
+ * Convert stream to array
54
+ */
55
+ toArray(): Promise<T[]>;
56
+ /**
57
+ * Get final message by accumulating all chunks
58
+ */
59
+ finalMessage(): Promise<string>;
60
+ }
40
61
  /**
41
62
  * Charles chat completions namespace
42
63
  * Usage: sylix.charles.chat.completions.create()
64
+ *
65
+ * OpenAI-compatible API with streaming, abort controller, and tool calls
43
66
  */
44
67
  declare class CharlesChatCompletions {
45
68
  private client;
46
69
  constructor(client: SylixClient);
47
70
  /**
48
- * Create a chat completion
49
- * @param payload - Chat request parameters
50
- * @returns Chat completion response
51
- */
52
- create(payload: CharlesChatRequest): Promise<ChatResponse>;
53
- /**
54
- * Create a streaming chat completion
71
+ * Create a chat completion (OpenAI-compatible)
72
+ *
55
73
  * @param payload - Chat request parameters
56
- * @returns Async iterator of chat completion chunks
74
+ * @param options - Additional options (signal for abort)
75
+ * @returns Chat response or Stream if stream: true
57
76
  *
58
77
  * @example
59
78
  * ```typescript
60
- * const stream = await sylix.charles.chat.completions.stream({
79
+ * // Non-streaming
80
+ * const response = await sylix.charles.chat.completions.create({
61
81
  * model: 'charles-v3:latest',
62
82
  * messages: [{ role: 'user', content: 'Hello!' }]
63
83
  * });
64
84
  *
85
+ * // Streaming (OpenAI-style)
86
+ * const stream = await sylix.charles.chat.completions.create({
87
+ * model: 'charles-v3:latest',
88
+ * messages: [{ role: 'user', content: 'Hello!' }],
89
+ * stream: true
90
+ * });
65
91
  * for await (const chunk of stream) {
66
92
  * process.stdout.write(chunk.choices[0]?.delta?.content || '');
67
93
  * }
94
+ *
95
+ * // With abort controller
96
+ * const stream = await sylix.charles.chat.completions.create({
97
+ * model: 'charles-v3:latest',
98
+ * messages: [...],
99
+ * stream: true
100
+ * });
101
+ * setTimeout(() => stream.abort(), 5000); // Cancel after 5s
68
102
  * ```
69
103
  */
70
- stream(payload: CharlesChatRequest): AsyncGenerator<ChatStreamChunk, void, unknown>;
104
+ create(payload: CharlesChatRequest & {
105
+ stream: true;
106
+ }, options?: {
107
+ signal?: AbortSignal;
108
+ }): Promise<Stream<ChatStreamChunk>>;
109
+ create(payload: CharlesChatRequest & {
110
+ stream?: false;
111
+ }, options?: {
112
+ signal?: AbortSignal;
113
+ }): Promise<ChatResponse>;
114
+ create(payload: CharlesChatRequest, options?: {
115
+ signal?: AbortSignal;
116
+ }): Promise<ChatResponse | Stream<ChatStreamChunk>>;
117
+ /**
118
+ * Non-streaming completion
119
+ */
120
+ private createNonStream;
121
+ /**
122
+ * Streaming completion with OpenAI-compatible interface
123
+ */
124
+ private createStream;
125
+ /**
126
+ * Parse Server-Sent Events stream
127
+ */
128
+ private parseSSE;
71
129
  private handleError;
72
130
  }
73
131
  /**
@@ -162,7 +220,8 @@ export declare class Sylix {
162
220
  */
163
221
  getModel(id: string): ModelInfo | undefined;
164
222
  }
165
- export { ChatRequest, ChatResponse, VisionRequest, VisionResponse, CodeRequest, CodeResponse, ReasonRequest, ReasonResponse, ModelInfo, SylixError, CHARLES_MODELS, CHARLES_MODEL_IDS, CharlesModel, CharlesModelsListResponse, CharlesEmbeddingRequest, CharlesEmbeddingResponse, CharlesChatRequest, } from "./types.js";
166
- export type { ChatMessage } from "./types.js";
223
+ export { ChatRequest, ChatResponse, VisionRequest, VisionResponse, CodeRequest, CodeResponse, ReasonRequest, ReasonResponse, ModelInfo, CHARLES_MODELS, CHARLES_MODEL_IDS, CharlesModel, CharlesModelsListResponse, CharlesEmbeddingRequest, CharlesEmbeddingResponse, CharlesChatRequest, } from "./types.js";
224
+ export type { ChatMessage, SylixConfig } from "./types.js";
225
+ export { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, SylixError, } from "./errors.js";
167
226
  export { readFile, fileToBase64 };
168
227
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb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AM,GAAG,SAAS,GAAG,SAAS;CAG5C;AAGD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,EACd,iBAAiB,EAEjB,YAAY,EACZ,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG3D,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,UAAU,GACX,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SylixClient } from "./client.js";
2
- import { SylixError, } from "./types.js";
2
+ import { SylixError, } from "./errors.js";
3
3
  import { readFile, fileToBase64 } from "./utils.js";
4
4
  /**
5
5
  * Chat completions namespace
@@ -108,24 +108,70 @@ class Reason {
108
108
  }
109
109
  // ============================================================================
110
110
  // CHARLES v1 NAMESPACE (OpenAI-compatible)
111
- // Owned by Sylix © 2025
111
+ // Owned by Sylix © 2026
112
112
  // ============================================================================
113
+ /**
114
+ * Stream response wrapper with controller
115
+ */
116
+ class Stream {
117
+ constructor(iterator, controller) {
118
+ this.iterator = iterator;
119
+ this.controller = controller;
120
+ }
121
+ [Symbol.asyncIterator]() {
122
+ return this.iterator;
123
+ }
124
+ /**
125
+ * Abort the stream
126
+ */
127
+ abort() {
128
+ this.controller.abort();
129
+ }
130
+ /**
131
+ * Convert stream to array
132
+ */
133
+ async toArray() {
134
+ const chunks = [];
135
+ for await (const chunk of this) {
136
+ chunks.push(chunk);
137
+ }
138
+ return chunks;
139
+ }
140
+ /**
141
+ * Get final message by accumulating all chunks
142
+ */
143
+ async finalMessage() {
144
+ let content = '';
145
+ for await (const chunk of this) {
146
+ const delta = chunk.choices?.[0]?.delta?.content;
147
+ if (delta)
148
+ content += delta;
149
+ }
150
+ return content;
151
+ }
152
+ }
113
153
  /**
114
154
  * Charles chat completions namespace
115
155
  * Usage: sylix.charles.chat.completions.create()
156
+ *
157
+ * OpenAI-compatible API with streaming, abort controller, and tool calls
116
158
  */
117
159
  class CharlesChatCompletions {
118
160
  constructor(client) {
119
161
  this.client = client;
120
162
  }
163
+ async create(payload, options) {
164
+ if (payload.stream) {
165
+ return this.createStream(payload, options);
166
+ }
167
+ return this.createNonStream(payload, options);
168
+ }
121
169
  /**
122
- * Create a chat completion
123
- * @param payload - Chat request parameters
124
- * @returns Chat completion response
170
+ * Non-streaming completion
125
171
  */
126
- async create(payload) {
172
+ async createNonStream(payload, options) {
127
173
  try {
128
- const response = await this.client.getClient().post("/charles/chat/completions", { ...payload, stream: false });
174
+ const response = await this.client.getClient().post("/charles/chat/completions", { ...payload, stream: false }, { signal: options?.signal });
129
175
  return response.data;
130
176
  }
131
177
  catch (error) {
@@ -133,25 +179,16 @@ class CharlesChatCompletions {
133
179
  }
134
180
  }
135
181
  /**
136
- * Create a streaming chat completion
137
- * @param payload - Chat request parameters
138
- * @returns Async iterator of chat completion chunks
139
- *
140
- * @example
141
- * ```typescript
142
- * const stream = await sylix.charles.chat.completions.stream({
143
- * model: 'charles-v3:latest',
144
- * messages: [{ role: 'user', content: 'Hello!' }]
145
- * });
146
- *
147
- * for await (const chunk of stream) {
148
- * process.stdout.write(chunk.choices[0]?.delta?.content || '');
149
- * }
150
- * ```
182
+ * Streaming completion with OpenAI-compatible interface
151
183
  */
152
- async *stream(payload) {
184
+ async createStream(payload, options) {
185
+ const controller = new AbortController();
153
186
  const baseURL = this.client.getBaseURL();
154
187
  const apiKey = this.client.getApiKey();
188
+ // Link external signal to internal controller
189
+ if (options?.signal) {
190
+ options.signal.addEventListener('abort', () => controller.abort());
191
+ }
155
192
  const response = await fetch(`${baseURL}/charles/chat/completions`, {
156
193
  method: 'POST',
157
194
  headers: {
@@ -159,6 +196,7 @@ class CharlesChatCompletions {
159
196
  'x-api-key': apiKey,
160
197
  },
161
198
  body: JSON.stringify({ ...payload, stream: true }),
199
+ signal: controller.signal,
162
200
  });
163
201
  if (!response.ok) {
164
202
  throw new SylixError('STREAM_ERROR', `Stream request failed: ${response.status} ${response.statusText}`);
@@ -166,11 +204,20 @@ class CharlesChatCompletions {
166
204
  if (!response.body) {
167
205
  throw new SylixError('STREAM_ERROR', 'No response body');
168
206
  }
169
- const reader = response.body.getReader();
207
+ const iterator = this.parseSSE(response.body, controller);
208
+ return new Stream(iterator, controller);
209
+ }
210
+ /**
211
+ * Parse Server-Sent Events stream
212
+ */
213
+ async *parseSSE(body, controller) {
214
+ const reader = body.getReader();
170
215
  const decoder = new TextDecoder();
171
216
  let buffer = '';
172
217
  try {
173
218
  while (true) {
219
+ if (controller.signal.aborted)
220
+ break;
174
221
  const { done, value } = await reader.read();
175
222
  if (done)
176
223
  break;
@@ -184,6 +231,11 @@ class CharlesChatCompletions {
184
231
  if (trimmed.startsWith('data: ')) {
185
232
  try {
186
233
  const json = JSON.parse(trimmed.slice(6));
234
+ // Parse tool calls if present
235
+ const choice = json.choices?.[0];
236
+ if (choice?.delta && choice.delta.tool_calls) {
237
+ // Tool calls are already parsed in the chunk
238
+ }
187
239
  yield json;
188
240
  }
189
241
  catch (e) {
@@ -198,6 +250,9 @@ class CharlesChatCompletions {
198
250
  }
199
251
  }
200
252
  handleError(error) {
253
+ if (error.name === 'AbortError') {
254
+ return new SylixError('ABORTED', 'Request was aborted');
255
+ }
201
256
  const message = error.response?.data?.error?.message || error.message || "Unknown error";
202
257
  const code = error.response?.data?.error?.code || error.code || "UNKNOWN_ERROR";
203
258
  return new SylixError(code, message, error.response?.data);
@@ -375,7 +430,9 @@ export class Sylix {
375
430
  return this.models().find((m) => m.id === id || m.displayName === id);
376
431
  }
377
432
  }
378
- // Exports
379
- export { SylixError, CHARLES_MODELS, CHARLES_MODEL_IDS, } from "./types.js";
433
+ // Type exports
434
+ export { CHARLES_MODELS, CHARLES_MODEL_IDS, } from "./types.js";
435
+ // Error exports (OpenAI-compatible)
436
+ export { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, SylixError, } from "./errors.js";
380
437
  // Utilities
381
438
  export { readFile, fileToBase64 };
package/dist/types.d.ts CHANGED
@@ -1,13 +1,10 @@
1
1
  /**
2
2
  * Sylix SDK Type Definitions
3
- * OpenAI-style types for Charles models
3
+ * OpenAI-compatible types for Charles models
4
+ *
5
+ * Owned by Sylix Technologies © 2026
4
6
  */
5
- export interface SylixConfig {
6
- apiKey: string;
7
- baseURL?: string;
8
- timeout?: number;
9
- headers?: Record<string, string>;
10
- }
7
+ export type { SylixConfig } from "./client.js";
11
8
  export interface ChatMessage {
12
9
  role: "system" | "user" | "assistant";
13
10
  content: string;
@@ -119,11 +116,7 @@ export interface SylixResponse<T> {
119
116
  status: number;
120
117
  data: T;
121
118
  }
122
- export declare class SylixError extends Error {
123
- code: string;
124
- raw?: any | undefined;
125
- constructor(code: string, message: string, raw?: any | undefined);
126
- }
119
+ export { SylixError } from "./errors.js";
127
120
  export declare const CHARLES_MODELS: {
128
121
  readonly MINI: "charles-mini:latest";
129
122
  readonly S1: "charles-s1:latest";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC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CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACjF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
package/dist/types.js CHANGED
@@ -1,15 +1,11 @@
1
1
  /**
2
2
  * Sylix SDK Type Definitions
3
- * OpenAI-style types for Charles models
3
+ * OpenAI-compatible types for Charles models
4
+ *
5
+ * Owned by Sylix Technologies © 2026
4
6
  */
5
- export class SylixError extends Error {
6
- constructor(code, message, raw) {
7
- super(message);
8
- this.code = code;
9
- this.raw = raw;
10
- this.name = "SylixError";
11
- }
12
- }
7
+ // Re-export errors from errors.ts
8
+ export { SylixError } from "./errors.js";
13
9
  export const CHARLES_MODELS = {
14
10
  MINI: "charles-mini:latest",
15
11
  S1: "charles-s1:latest",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sylix",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "description": "The official Sylix AI SDK for TypeScript and JavaScript. Build intelligent applications with Charles v3 models featuring multi-model consensus, intelligent routing, vision understanding, deep reasoning, and OpenAI-compatible APIs. Enterprise-grade AI infrastructure for developers.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",