@gpt-core/client 0.10.20 → 0.11.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/README.md +90 -80
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -4
- package/dist/index.mjs +14 -4
- package/package.json +13 -13
- package/dist/index.cjs +0 -4043
package/README.md
CHANGED
|
@@ -29,8 +29,11 @@ AI_CONTEXT_END -->
|
|
|
29
29
|
> **TL;DR for Claude, Cursor, Copilot, and other AI assistants:**
|
|
30
30
|
>
|
|
31
31
|
> ```typescript
|
|
32
|
-
> import { GptClient } from
|
|
33
|
-
> const client = new GptClient({
|
|
32
|
+
> import { GptClient } from "@gpt-core/client";
|
|
33
|
+
> const client = new GptClient({
|
|
34
|
+
> baseUrl: "https://api.example.com",
|
|
35
|
+
> token: "jwt",
|
|
36
|
+
> });
|
|
34
37
|
> ```
|
|
35
38
|
>
|
|
36
39
|
> **Common operations:**
|
|
@@ -70,26 +73,26 @@ pnpm add @gpt-core/client
|
|
|
70
73
|
## Quick Start
|
|
71
74
|
|
|
72
75
|
```typescript
|
|
73
|
-
import { GptClient } from
|
|
76
|
+
import { GptClient } from "@gpt-core/client";
|
|
74
77
|
|
|
75
78
|
// Initialize client
|
|
76
79
|
const client = new GptClient({
|
|
77
|
-
baseUrl:
|
|
78
|
-
apiKey:
|
|
79
|
-
token:
|
|
80
|
+
baseUrl: "https://api.gpt-core.com",
|
|
81
|
+
apiKey: "your-api-key", // For machine-to-machine
|
|
82
|
+
token: "user-jwt-token", // For user-authenticated requests
|
|
80
83
|
});
|
|
81
84
|
|
|
82
85
|
// Authenticate a user
|
|
83
86
|
const { user, token } = await client.identity.login(
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
"user@example.com",
|
|
88
|
+
"password",
|
|
86
89
|
);
|
|
87
90
|
|
|
88
91
|
console.log(`Welcome, ${user.attributes.full_name}!`);
|
|
89
92
|
|
|
90
93
|
// Use the token for subsequent requests
|
|
91
94
|
const authenticatedClient = new GptClient({
|
|
92
|
-
baseUrl:
|
|
95
|
+
baseUrl: "https://api.gpt-core.com",
|
|
93
96
|
token: token,
|
|
94
97
|
});
|
|
95
98
|
|
|
@@ -117,9 +120,9 @@ Pin a specific API version to protect your integration from breaking changes:
|
|
|
117
120
|
|
|
118
121
|
```typescript
|
|
119
122
|
const client = new GptClient({
|
|
120
|
-
baseUrl:
|
|
121
|
-
apiKey:
|
|
122
|
-
apiVersion:
|
|
123
|
+
baseUrl: "https://api.gpt-core.com",
|
|
124
|
+
apiKey: "sk_live_...",
|
|
125
|
+
apiVersion: "2025-12-03", // Pin to this version
|
|
123
126
|
});
|
|
124
127
|
```
|
|
125
128
|
|
|
@@ -153,29 +156,29 @@ This returns the full list of versions with descriptions and deprecation status.
|
|
|
153
156
|
```typescript
|
|
154
157
|
const client = new GptClient({
|
|
155
158
|
// Required: API base URL
|
|
156
|
-
baseUrl:
|
|
159
|
+
baseUrl: "https://api.gpt-core.com",
|
|
157
160
|
|
|
158
161
|
// Authentication (provide one or both)
|
|
159
|
-
apiKey:
|
|
160
|
-
token:
|
|
162
|
+
apiKey: "sk_live_...", // Application API key
|
|
163
|
+
token: "eyJhbGc...", // User JWT token
|
|
161
164
|
|
|
162
165
|
// API version (optional, uses SDK default if not specified)
|
|
163
|
-
apiVersion:
|
|
166
|
+
apiVersion: "2025-12-03",
|
|
164
167
|
|
|
165
168
|
// Security configuration (optional)
|
|
166
169
|
security: {
|
|
167
|
-
requireHttps: false,
|
|
168
|
-
warnBrowserApiKey: true,
|
|
170
|
+
requireHttps: false, // Throw error on HTTP (default: warn only)
|
|
171
|
+
warnBrowserApiKey: true, // Warn about API keys in browser (default: true)
|
|
169
172
|
},
|
|
170
173
|
|
|
171
174
|
// Retry configuration (optional)
|
|
172
175
|
retry: {
|
|
173
|
-
maxRetries: 3,
|
|
174
|
-
initialDelay: 1000,
|
|
175
|
-
maxDelay: 32000,
|
|
176
|
+
maxRetries: 3, // Default: 3
|
|
177
|
+
initialDelay: 1000, // Default: 1000ms (renamed from minTimeout)
|
|
178
|
+
maxDelay: 32000, // Default: 32000ms (renamed from maxTimeout)
|
|
176
179
|
retryableStatusCodes: [429, 500, 502, 503, 504],
|
|
177
|
-
totalTimeout: 300000,
|
|
178
|
-
maxRetryAfter: 60,
|
|
180
|
+
totalTimeout: 300000, // Total timeout across all retries (ms)
|
|
181
|
+
maxRetryAfter: 60, // Max Retry-After header value (seconds)
|
|
179
182
|
},
|
|
180
183
|
|
|
181
184
|
// Disable retries
|
|
@@ -185,24 +188,24 @@ const client = new GptClient({
|
|
|
185
188
|
|
|
186
189
|
## Security Options
|
|
187
190
|
|
|
188
|
-
| Option
|
|
189
|
-
|
|
190
|
-
| `requireHttps`
|
|
191
|
-
| `warnBrowserApiKey` | boolean | `true`
|
|
191
|
+
| Option | Type | Default | Description |
|
|
192
|
+
| ------------------- | ------- | ------- | ------------------------------------------------- |
|
|
193
|
+
| `requireHttps` | boolean | `false` | Throw `InsecureConnectionError` on non-HTTPS URLs |
|
|
194
|
+
| `warnBrowserApiKey` | boolean | `true` | Warn when API key detected in browser environment |
|
|
192
195
|
|
|
193
196
|
### HTTPS Enforcement
|
|
194
197
|
|
|
195
198
|
```typescript
|
|
196
199
|
// Development: Warns only
|
|
197
200
|
const devClient = new GptClient({
|
|
198
|
-
baseUrl:
|
|
201
|
+
baseUrl: "http://localhost:22222",
|
|
199
202
|
apiKey: process.env.API_KEY,
|
|
200
203
|
security: { requireHttps: false },
|
|
201
204
|
});
|
|
202
205
|
|
|
203
206
|
// Production: Blocks HTTP
|
|
204
207
|
const prodClient = new GptClient({
|
|
205
|
-
baseUrl:
|
|
208
|
+
baseUrl: "https://api.gpt-core.com",
|
|
206
209
|
apiKey: process.env.API_KEY,
|
|
207
210
|
security: { requireHttps: true },
|
|
208
211
|
});
|
|
@@ -211,7 +214,7 @@ try {
|
|
|
211
214
|
await prodClient.agents.list();
|
|
212
215
|
} catch (error) {
|
|
213
216
|
if (error instanceof InsecureConnectionError) {
|
|
214
|
-
console.error(
|
|
217
|
+
console.error("Cannot use HTTP in production");
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
```
|
|
@@ -225,7 +228,7 @@ The SDK validates API key format and warns about elevated privilege keys:
|
|
|
225
228
|
// sk_sys_* keys trigger warnings (elevated privileges)
|
|
226
229
|
|
|
227
230
|
const client = new GptClient({
|
|
228
|
-
apiKey:
|
|
231
|
+
apiKey: "sk_sys_abc123",
|
|
229
232
|
});
|
|
230
233
|
// [GPT Core SDK] Using system-level API key (sk_sys_).
|
|
231
234
|
// Ensure this is intended for platform operations.
|
|
@@ -242,7 +245,11 @@ Manage users, authentication, and API keys.
|
|
|
242
245
|
const { user, token } = await client.identity.login(email, password);
|
|
243
246
|
|
|
244
247
|
// Register
|
|
245
|
-
const user = await client.identity.register(
|
|
248
|
+
const user = await client.identity.register(
|
|
249
|
+
email,
|
|
250
|
+
password,
|
|
251
|
+
passwordConfirmation,
|
|
252
|
+
);
|
|
246
253
|
|
|
247
254
|
// Get current user
|
|
248
255
|
const user = await client.identity.me();
|
|
@@ -252,8 +259,8 @@ const profile = await client.identity.profile();
|
|
|
252
259
|
|
|
253
260
|
// API Keys
|
|
254
261
|
const keys = await client.identity.apiKeys.list();
|
|
255
|
-
const newKey = await client.identity.apiKeys.create(
|
|
256
|
-
await client.identity.apiKeys.allocate(
|
|
262
|
+
const newKey = await client.identity.apiKeys.create("Production Key");
|
|
263
|
+
await client.identity.apiKeys.allocate("key-id", 1000, "Monthly credits");
|
|
257
264
|
```
|
|
258
265
|
|
|
259
266
|
### Platform
|
|
@@ -264,22 +271,25 @@ Manage applications, workspaces, and tenants.
|
|
|
264
271
|
// Applications
|
|
265
272
|
const apps = await client.platform.applications.list();
|
|
266
273
|
const app = await client.platform.applications.create({
|
|
267
|
-
name:
|
|
268
|
-
slug:
|
|
274
|
+
name: "My App",
|
|
275
|
+
slug: "my-app",
|
|
269
276
|
});
|
|
270
|
-
const app = await client.platform.applications.getBySlug(
|
|
277
|
+
const app = await client.platform.applications.getBySlug("my-app");
|
|
271
278
|
|
|
272
279
|
// Workspaces
|
|
273
280
|
const workspaces = await client.platform.workspaces.list();
|
|
274
281
|
const myWorkspaces = await client.platform.workspaces.mine();
|
|
275
|
-
const workspace = await client.platform.workspaces.create(
|
|
282
|
+
const workspace = await client.platform.workspaces.create(
|
|
283
|
+
"New Workspace",
|
|
284
|
+
"new-workspace",
|
|
285
|
+
);
|
|
276
286
|
|
|
277
287
|
// Invitations
|
|
278
288
|
await client.platform.invitations.invite(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
289
|
+
"colleague@example.com",
|
|
290
|
+
"editor",
|
|
291
|
+
"workspace",
|
|
292
|
+
"workspace-id",
|
|
283
293
|
);
|
|
284
294
|
```
|
|
285
295
|
|
|
@@ -291,20 +301,20 @@ Interact with agents, threads, and semantic search.
|
|
|
291
301
|
// Agents
|
|
292
302
|
const agents = await client.ai.agents.list();
|
|
293
303
|
const agent = await client.ai.agents.create(
|
|
294
|
-
|
|
295
|
-
|
|
304
|
+
"Support Agent",
|
|
305
|
+
"You are a helpful customer support agent",
|
|
296
306
|
);
|
|
297
307
|
|
|
298
308
|
// Threads (Conversations)
|
|
299
309
|
const threads = await client.ai.threads.list();
|
|
300
|
-
const thread = await client.ai.threads.create(
|
|
301
|
-
const message = await client.ai.threads.sendMessage(thread.id,
|
|
310
|
+
const thread = await client.ai.threads.create("Bug Report Discussion");
|
|
311
|
+
const message = await client.ai.threads.sendMessage(thread.id, "Hello AI!");
|
|
302
312
|
|
|
303
313
|
// Search
|
|
304
|
-
const results = await client.ai.search(
|
|
314
|
+
const results = await client.ai.search("quarterly earnings", 10);
|
|
305
315
|
|
|
306
316
|
// Embeddings
|
|
307
|
-
const embedding = await client.ai.embed(
|
|
317
|
+
const embedding = await client.ai.embed("text to embed");
|
|
308
318
|
```
|
|
309
319
|
|
|
310
320
|
### Extraction
|
|
@@ -317,18 +327,18 @@ const documents = await client.extraction.documents.list();
|
|
|
317
327
|
|
|
318
328
|
// Upload (base64)
|
|
319
329
|
const doc = await client.extraction.documents.uploadBase64(
|
|
320
|
-
|
|
321
|
-
base64Content
|
|
330
|
+
"report.pdf",
|
|
331
|
+
base64Content,
|
|
322
332
|
);
|
|
323
333
|
|
|
324
334
|
// Analyze
|
|
325
335
|
await client.extraction.documents.analyze(doc.id);
|
|
326
336
|
|
|
327
337
|
// Retrieve
|
|
328
|
-
const doc = await client.extraction.documents.get(
|
|
338
|
+
const doc = await client.extraction.documents.get("doc-id");
|
|
329
339
|
|
|
330
340
|
// Delete
|
|
331
|
-
await client.extraction.documents.delete(
|
|
341
|
+
await client.extraction.documents.delete("doc-id");
|
|
332
342
|
|
|
333
343
|
// Results
|
|
334
344
|
const results = await client.extraction.results.list();
|
|
@@ -341,14 +351,14 @@ Manage buckets and files.
|
|
|
341
351
|
```typescript
|
|
342
352
|
// Buckets
|
|
343
353
|
const buckets = await client.storage.buckets.list();
|
|
344
|
-
const bucket = await client.storage.buckets.create(
|
|
354
|
+
const bucket = await client.storage.buckets.create("uploads", false);
|
|
345
355
|
|
|
346
356
|
// Presigned URLs
|
|
347
357
|
const uploadUrl = await client.storage.presigned.upload(
|
|
348
|
-
|
|
349
|
-
|
|
358
|
+
"image.png",
|
|
359
|
+
"image/png",
|
|
350
360
|
);
|
|
351
|
-
const downloadUrl = await client.storage.presigned.download(
|
|
361
|
+
const downloadUrl = await client.storage.presigned.download("file-id");
|
|
352
362
|
```
|
|
353
363
|
|
|
354
364
|
### Billing
|
|
@@ -377,16 +387,16 @@ import {
|
|
|
377
387
|
ValidationError,
|
|
378
388
|
RateLimitError,
|
|
379
389
|
ServerError,
|
|
380
|
-
} from
|
|
390
|
+
} from "@gpt-core/client";
|
|
381
391
|
|
|
382
392
|
try {
|
|
383
|
-
await client.identity.login(
|
|
393
|
+
await client.identity.login("user@example.com", "wrong-password");
|
|
384
394
|
} catch (error) {
|
|
385
395
|
if (error instanceof AuthenticationError) {
|
|
386
|
-
console.error(
|
|
387
|
-
console.error(
|
|
396
|
+
console.error("Invalid credentials:", error.message);
|
|
397
|
+
console.error("Request ID:", error.requestId);
|
|
388
398
|
} else if (error instanceof ValidationError) {
|
|
389
|
-
console.error(
|
|
399
|
+
console.error("Validation errors:", error.errors);
|
|
390
400
|
} else if (error instanceof RateLimitError) {
|
|
391
401
|
console.error(`Rate limited. Retry after ${error.retryAfter}s`);
|
|
392
402
|
}
|
|
@@ -398,7 +408,7 @@ try {
|
|
|
398
408
|
Easily iterate over large datasets with built-in memory protection:
|
|
399
409
|
|
|
400
410
|
```typescript
|
|
401
|
-
import { paginateAll } from
|
|
411
|
+
import { paginateAll } from "@gpt-core/client";
|
|
402
412
|
|
|
403
413
|
// Using async iteration
|
|
404
414
|
for await (const workspace of client.platform.workspaces.listAll()) {
|
|
@@ -427,18 +437,18 @@ for await (const item of paginateAll(fetcher, { pageSize: 50, limit: 1000 })) {
|
|
|
427
437
|
Stream AI responses in real-time:
|
|
428
438
|
|
|
429
439
|
```typescript
|
|
430
|
-
import { streamMessage } from
|
|
440
|
+
import { streamMessage } from "@gpt-core/client";
|
|
431
441
|
|
|
432
442
|
// Make streaming request
|
|
433
443
|
const response = await fetch(streamingEndpoint, {
|
|
434
|
-
method:
|
|
435
|
-
headers: {
|
|
436
|
-
body: JSON.stringify({ content:
|
|
444
|
+
method: "POST",
|
|
445
|
+
headers: { Accept: "text/event-stream" },
|
|
446
|
+
body: JSON.stringify({ content: "Hello AI" }),
|
|
437
447
|
});
|
|
438
448
|
|
|
439
449
|
// Stream the response
|
|
440
450
|
for await (const chunk of streamMessage(response)) {
|
|
441
|
-
if (chunk.type ===
|
|
451
|
+
if (chunk.type === "content") {
|
|
442
452
|
process.stdout.write(chunk.content); // Real-time output
|
|
443
453
|
}
|
|
444
454
|
}
|
|
@@ -451,21 +461,21 @@ Automatic retries with exponential backoff and circuit breaker:
|
|
|
451
461
|
```typescript
|
|
452
462
|
// Retries are enabled by default with circuit breaker protection
|
|
453
463
|
const client = new GptClient({
|
|
454
|
-
baseUrl:
|
|
455
|
-
token:
|
|
464
|
+
baseUrl: "https://api.gpt-core.com",
|
|
465
|
+
token: "token",
|
|
456
466
|
retry: {
|
|
457
|
-
maxRetries: 5,
|
|
458
|
-
initialDelay: 1000,
|
|
459
|
-
maxDelay: 32000,
|
|
460
|
-
totalTimeout: 300000,
|
|
461
|
-
maxRetryAfter: 60,
|
|
467
|
+
maxRetries: 5, // Retry up to 5 times
|
|
468
|
+
initialDelay: 1000, // Start with 1s delay
|
|
469
|
+
maxDelay: 32000, // Max delay between retries
|
|
470
|
+
totalTimeout: 300000, // Total timeout (5 min) prevents infinite loops
|
|
471
|
+
maxRetryAfter: 60, // Cap Retry-After header to 60s
|
|
462
472
|
},
|
|
463
473
|
});
|
|
464
474
|
|
|
465
475
|
// Disable retries for specific operations
|
|
466
476
|
const noRetryClient = new GptClient({
|
|
467
|
-
baseUrl:
|
|
468
|
-
token:
|
|
477
|
+
baseUrl: "https://api.gpt-core.com",
|
|
478
|
+
token: "token",
|
|
469
479
|
retry: false,
|
|
470
480
|
});
|
|
471
481
|
```
|
|
@@ -478,13 +488,13 @@ const noRetryClient = new GptClient({
|
|
|
478
488
|
- **Protected Status Codes**: 429, 500, 502, 503, 504
|
|
479
489
|
|
|
480
490
|
```typescript
|
|
481
|
-
import { RetryTimeoutError } from
|
|
491
|
+
import { RetryTimeoutError } from "@gpt-core/client";
|
|
482
492
|
|
|
483
493
|
try {
|
|
484
494
|
await client.agents.list();
|
|
485
495
|
} catch (error) {
|
|
486
496
|
if (error instanceof RetryTimeoutError) {
|
|
487
|
-
console.error(
|
|
497
|
+
console.error("Retry timeout exceeded:", error.message);
|
|
488
498
|
}
|
|
489
499
|
}
|
|
490
500
|
```
|
|
@@ -494,12 +504,12 @@ try {
|
|
|
494
504
|
The SDK is written in TypeScript and provides full type safety:
|
|
495
505
|
|
|
496
506
|
```typescript
|
|
497
|
-
import type { user, workspace, document } from
|
|
507
|
+
import type { user, workspace, document } from "@gpt-core/client";
|
|
498
508
|
|
|
499
509
|
const user: user = await client.identity.me();
|
|
500
510
|
// TypeScript knows: user.attributes.email, user.id, etc.
|
|
501
511
|
|
|
502
|
-
const workspace: workspace = await client.platform.workspaces.create(
|
|
512
|
+
const workspace: workspace = await client.platform.workspaces.create("Test");
|
|
503
513
|
// TypeScript enforces correct parameters
|
|
504
514
|
```
|
|
505
515
|
|
package/dist/index.d.mts
CHANGED
|
@@ -42138,7 +42138,7 @@ declare function streamSSE<T = unknown>(response: Response, options?: StreamOpti
|
|
|
42138
42138
|
* Stream AI thread messages with Server-Sent Events
|
|
42139
42139
|
*/
|
|
42140
42140
|
interface StreamMessageChunk {
|
|
42141
|
-
type:
|
|
42141
|
+
type: "content" | "done" | "error";
|
|
42142
42142
|
content?: string;
|
|
42143
42143
|
error?: string;
|
|
42144
42144
|
metadata?: Record<string, any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -42138,7 +42138,7 @@ declare function streamSSE<T = unknown>(response: Response, options?: StreamOpti
|
|
|
42138
42138
|
* Stream AI thread messages with Server-Sent Events
|
|
42139
42139
|
*/
|
|
42140
42140
|
interface StreamMessageChunk {
|
|
42141
|
-
type:
|
|
42141
|
+
type: "content" | "done" | "error";
|
|
42142
42142
|
content?: string;
|
|
42143
42143
|
error?: string;
|
|
42144
42144
|
metadata?: Record<string, any>;
|
package/dist/index.js
CHANGED
|
@@ -5405,7 +5405,9 @@ function handleApiError(error) {
|
|
|
5405
5405
|
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
5406
5406
|
const filtered = entries.filter(([key]) => {
|
|
5407
5407
|
const lowerKey = key.toLowerCase();
|
|
5408
|
-
return !sensitiveHeaderPatterns.some(
|
|
5408
|
+
return !sensitiveHeaderPatterns.some(
|
|
5409
|
+
(pattern) => lowerKey.includes(pattern)
|
|
5410
|
+
);
|
|
5409
5411
|
});
|
|
5410
5412
|
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
5411
5413
|
};
|
|
@@ -5428,7 +5430,11 @@ function handleApiError(error) {
|
|
|
5428
5430
|
throw new ValidationError(message, errors, errorOptions);
|
|
5429
5431
|
case 429: {
|
|
5430
5432
|
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
5431
|
-
throw new RateLimitError(
|
|
5433
|
+
throw new RateLimitError(
|
|
5434
|
+
message,
|
|
5435
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
5436
|
+
errorOptions
|
|
5437
|
+
);
|
|
5432
5438
|
}
|
|
5433
5439
|
case 500:
|
|
5434
5440
|
case 502:
|
|
@@ -5700,7 +5706,9 @@ async function* streamSSE(response, options = {}) {
|
|
|
5700
5706
|
const elapsed = Date.now() - startTime;
|
|
5701
5707
|
if (elapsed > timeout) {
|
|
5702
5708
|
reader.cancel();
|
|
5703
|
-
throw new Error(
|
|
5709
|
+
throw new Error(
|
|
5710
|
+
`Stream timeout exceeded after ${elapsed}ms (limit: ${timeout}ms)`
|
|
5711
|
+
);
|
|
5704
5712
|
}
|
|
5705
5713
|
if (chunkCount >= maxChunks) {
|
|
5706
5714
|
reader.cancel();
|
|
@@ -5717,7 +5725,9 @@ async function* streamSSE(response, options = {}) {
|
|
|
5717
5725
|
bufferSize += value.length;
|
|
5718
5726
|
if (bufferSize > maxBufferSize) {
|
|
5719
5727
|
reader.cancel();
|
|
5720
|
-
throw new Error(
|
|
5728
|
+
throw new Error(
|
|
5729
|
+
`Stream buffer size exceeded (${bufferSize} bytes, limit: ${maxBufferSize})`
|
|
5730
|
+
);
|
|
5721
5731
|
}
|
|
5722
5732
|
buffer += decoder.decode(value, { stream: true });
|
|
5723
5733
|
const lines = buffer.split("\n");
|
package/dist/index.mjs
CHANGED
|
@@ -4938,7 +4938,9 @@ function handleApiError(error) {
|
|
|
4938
4938
|
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
4939
4939
|
const filtered = entries.filter(([key]) => {
|
|
4940
4940
|
const lowerKey = key.toLowerCase();
|
|
4941
|
-
return !sensitiveHeaderPatterns.some(
|
|
4941
|
+
return !sensitiveHeaderPatterns.some(
|
|
4942
|
+
(pattern) => lowerKey.includes(pattern)
|
|
4943
|
+
);
|
|
4942
4944
|
});
|
|
4943
4945
|
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
4944
4946
|
};
|
|
@@ -4961,7 +4963,11 @@ function handleApiError(error) {
|
|
|
4961
4963
|
throw new ValidationError(message, errors, errorOptions);
|
|
4962
4964
|
case 429: {
|
|
4963
4965
|
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
4964
|
-
throw new RateLimitError(
|
|
4966
|
+
throw new RateLimitError(
|
|
4967
|
+
message,
|
|
4968
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
4969
|
+
errorOptions
|
|
4970
|
+
);
|
|
4965
4971
|
}
|
|
4966
4972
|
case 500:
|
|
4967
4973
|
case 502:
|
|
@@ -5233,7 +5239,9 @@ async function* streamSSE(response, options = {}) {
|
|
|
5233
5239
|
const elapsed = Date.now() - startTime;
|
|
5234
5240
|
if (elapsed > timeout) {
|
|
5235
5241
|
reader.cancel();
|
|
5236
|
-
throw new Error(
|
|
5242
|
+
throw new Error(
|
|
5243
|
+
`Stream timeout exceeded after ${elapsed}ms (limit: ${timeout}ms)`
|
|
5244
|
+
);
|
|
5237
5245
|
}
|
|
5238
5246
|
if (chunkCount >= maxChunks) {
|
|
5239
5247
|
reader.cancel();
|
|
@@ -5250,7 +5258,9 @@ async function* streamSSE(response, options = {}) {
|
|
|
5250
5258
|
bufferSize += value.length;
|
|
5251
5259
|
if (bufferSize > maxBufferSize) {
|
|
5252
5260
|
reader.cancel();
|
|
5253
|
-
throw new Error(
|
|
5261
|
+
throw new Error(
|
|
5262
|
+
`Stream buffer size exceeded (${bufferSize} bytes, limit: ${maxBufferSize})`
|
|
5263
|
+
);
|
|
5254
5264
|
}
|
|
5255
5265
|
buffer += decoder.decode(value, { stream: true });
|
|
5256
5266
|
const lines = buffer.split("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpt-core/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "TypeScript SDK for GPT Core Client API - Document extraction, AI agents, and workspace management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -46,12 +46,21 @@
|
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/GPT-Integrators/gpt-core-
|
|
50
|
-
"directory": "ts/packages/client"
|
|
49
|
+
"url": "https://github.com/GPT-Integrators/gpt-core-client-sdk.git"
|
|
51
50
|
},
|
|
51
|
+
"homepage": "https://gpt-integrators.github.io/gpt-core-client-sdk",
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"generate": "bunx openapi-ts",
|
|
57
|
+
"typecheck": "bunx tsc --noEmit",
|
|
58
|
+
"build": "bun run typecheck && bunx tsup src/index.ts --format cjs,esm --dts",
|
|
59
|
+
"test": "bunx vitest run",
|
|
60
|
+
"test:watch": "bunx vitest",
|
|
61
|
+
"test:ui": "bunx vitest --ui",
|
|
62
|
+
"test:coverage": "bunx vitest run --coverage"
|
|
63
|
+
},
|
|
55
64
|
"dependencies": {
|
|
56
65
|
"eventsource-parser": "^3.0.6",
|
|
57
66
|
"zod": "^3.25.76"
|
|
@@ -63,14 +72,5 @@
|
|
|
63
72
|
"tsup": "^8.5.1",
|
|
64
73
|
"typescript": "^5.9.3",
|
|
65
74
|
"vitest": "^4.0.15"
|
|
66
|
-
},
|
|
67
|
-
"scripts": {
|
|
68
|
-
"generate": "bunx openapi-ts",
|
|
69
|
-
"typecheck": "bunx tsc --noEmit",
|
|
70
|
-
"build": "bun run typecheck && bunx tsup src/index.ts --format cjs,esm --dts",
|
|
71
|
-
"test": "bunx vitest run",
|
|
72
|
-
"test:watch": "bunx vitest",
|
|
73
|
-
"test:ui": "bunx vitest --ui",
|
|
74
|
-
"test:coverage": "bunx vitest run --coverage"
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|