@gpt-platform/client 0.10.4 → 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/dist/_internal/client/client.gen.d.ts +3 -0
- package/dist/_internal/client/client.gen.d.ts.map +1 -0
- package/dist/_internal/client/index.d.ts +9 -0
- package/dist/_internal/client/index.d.ts.map +1 -0
- package/dist/_internal/client/types.gen.d.ts +118 -0
- package/dist/_internal/client/types.gen.d.ts.map +1 -0
- package/dist/_internal/client/utils.gen.d.ts +34 -0
- package/dist/_internal/client/utils.gen.d.ts.map +1 -0
- package/dist/_internal/client.gen.d.ts +13 -0
- package/dist/_internal/client.gen.d.ts.map +1 -0
- package/dist/_internal/core/auth.gen.d.ts +19 -0
- package/dist/_internal/core/auth.gen.d.ts.map +1 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts +26 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/params.gen.d.ts +44 -0
- package/dist/_internal/core/params.gen.d.ts.map +1 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts +34 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/_internal/core/types.gen.d.ts +79 -0
- package/dist/_internal/core/types.gen.d.ts.map +1 -0
- package/dist/_internal/core/utils.gen.d.ts +20 -0
- package/dist/_internal/core/utils.gen.d.ts.map +1 -0
- package/dist/_internal/index.d.ts +3 -0
- package/dist/_internal/index.d.ts.map +1 -0
- package/dist/_internal/sdk.gen.d.ts +7053 -0
- package/dist/_internal/sdk.gen.d.ts.map +1 -0
- package/dist/_internal/types.gen.d.ts +146633 -0
- package/dist/_internal/types.gen.d.ts.map +1 -0
- package/dist/base-client.d.ts +199 -0
- package/dist/base-client.d.ts.map +1 -0
- package/dist/errors/index.d.ts +128 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events.d.ts +69 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/execution-events.d.ts +95 -0
- package/dist/execution-events.d.ts.map +1 -0
- package/dist/gpt-client.d.ts +2175 -0
- package/dist/gpt-client.d.ts.map +1 -0
- package/dist/index.d.ts +51 -30308
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +775 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +775 -14
- package/dist/index.mjs.map +1 -1
- package/dist/json-api.d.ts +26 -0
- package/dist/json-api.d.ts.map +1 -0
- package/dist/logging.d.ts +22 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/namespace-types.d.ts +79 -0
- package/dist/namespace-types.d.ts.map +1 -0
- package/dist/namespaces/access-grants.d.ts +71 -0
- package/dist/namespaces/access-grants.d.ts.map +1 -0
- package/dist/namespaces/agents.d.ts +1406 -0
- package/dist/namespaces/agents.d.ts.map +1 -0
- package/dist/namespaces/ai.d.ts +407 -0
- package/dist/namespaces/ai.d.ts.map +1 -0
- package/dist/namespaces/audit.d.ts +83 -0
- package/dist/namespaces/audit.d.ts.map +1 -0
- package/dist/namespaces/billing.d.ts +854 -0
- package/dist/namespaces/billing.d.ts.map +1 -0
- package/dist/namespaces/campaigns.d.ts +973 -0
- package/dist/namespaces/campaigns.d.ts.map +1 -0
- package/dist/namespaces/catalog.d.ts +964 -0
- package/dist/namespaces/catalog.d.ts.map +1 -0
- package/dist/namespaces/channels.d.ts +162 -0
- package/dist/namespaces/channels.d.ts.map +1 -0
- package/dist/namespaces/clinical.d.ts +2443 -0
- package/dist/namespaces/clinical.d.ts.map +1 -0
- package/dist/namespaces/communication.d.ts +439 -0
- package/dist/namespaces/communication.d.ts.map +1 -0
- package/dist/namespaces/compliance.d.ts +2310 -0
- package/dist/namespaces/compliance.d.ts.map +1 -0
- package/dist/namespaces/connectors.d.ts +1368 -0
- package/dist/namespaces/connectors.d.ts.map +1 -0
- package/dist/namespaces/content.d.ts +188 -0
- package/dist/namespaces/content.d.ts.map +1 -0
- package/dist/namespaces/crawler.d.ts +408 -0
- package/dist/namespaces/crawler.d.ts.map +1 -0
- package/dist/namespaces/crm-clusters.d.ts +31 -0
- package/dist/namespaces/crm-clusters.d.ts.map +1 -0
- package/dist/namespaces/crm.d.ts +1539 -0
- package/dist/namespaces/crm.d.ts.map +1 -0
- package/dist/namespaces/documents.d.ts +136 -0
- package/dist/namespaces/documents.d.ts.map +1 -0
- package/dist/namespaces/email.d.ts +550 -0
- package/dist/namespaces/email.d.ts.map +1 -0
- package/dist/namespaces/extraction.d.ts +1249 -0
- package/dist/namespaces/extraction.d.ts.map +1 -0
- package/dist/namespaces/identity.d.ts +411 -0
- package/dist/namespaces/identity.d.ts.map +1 -0
- package/dist/namespaces/imports.d.ts +177 -0
- package/dist/namespaces/imports.d.ts.map +1 -0
- package/dist/namespaces/index.d.ts +119 -0
- package/dist/namespaces/index.d.ts.map +1 -0
- package/dist/namespaces/memory.d.ts +105 -0
- package/dist/namespaces/memory.d.ts.map +1 -0
- package/dist/namespaces/models.d.ts +75 -0
- package/dist/namespaces/models.d.ts.map +1 -0
- package/dist/namespaces/permissions.d.ts +75 -0
- package/dist/namespaces/permissions.d.ts.map +1 -0
- package/dist/namespaces/pipeline-executions.d.ts +130 -0
- package/dist/namespaces/pipeline-executions.d.ts.map +1 -0
- package/dist/namespaces/pipelines.d.ts +120 -0
- package/dist/namespaces/pipelines.d.ts.map +1 -0
- package/dist/namespaces/platform.d.ts +1430 -0
- package/dist/namespaces/platform.d.ts.map +1 -0
- package/dist/namespaces/portal.d.ts +198 -0
- package/dist/namespaces/portal.d.ts.map +1 -0
- package/dist/namespaces/projects.d.ts +553 -0
- package/dist/namespaces/projects.d.ts.map +1 -0
- package/dist/namespaces/roles.d.ts +65 -0
- package/dist/namespaces/roles.d.ts.map +1 -0
- package/dist/namespaces/scheduling.d.ts +944 -0
- package/dist/namespaces/scheduling.d.ts.map +1 -0
- package/dist/namespaces/search.d.ts +224 -0
- package/dist/namespaces/search.d.ts.map +1 -0
- package/dist/namespaces/session-notes.d.ts +67 -0
- package/dist/namespaces/session-notes.d.ts.map +1 -0
- package/dist/namespaces/social.d.ts +330 -0
- package/dist/namespaces/social.d.ts.map +1 -0
- package/dist/namespaces/storage.d.ts +378 -0
- package/dist/namespaces/storage.d.ts.map +1 -0
- package/dist/namespaces/support.d.ts +427 -0
- package/dist/namespaces/support.d.ts.map +1 -0
- package/dist/namespaces/threads.d.ts +596 -0
- package/dist/namespaces/threads.d.ts.map +1 -0
- package/dist/namespaces/training.d.ts +358 -0
- package/dist/namespaces/training.d.ts.map +1 -0
- package/dist/namespaces/voice.d.ts +752 -0
- package/dist/namespaces/voice.d.ts.map +1 -0
- package/dist/namespaces/watcher.d.ts +425 -0
- package/dist/namespaces/watcher.d.ts.map +1 -0
- package/dist/namespaces/webhooks-ns.d.ts +3 -0
- package/dist/namespaces/webhooks-ns.d.ts.map +1 -0
- package/dist/pagination.d.ts +57 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/request-builder.d.ts +95 -0
- package/dist/request-builder.d.ts.map +1 -0
- package/dist/security.d.ts +32 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/streaming.d.ts +135 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/utils/retry.d.ts +63 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/webhook-signature.d.ts +109 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/llms.txt +40 -1
- package/package.json +286 -36
- package/dist/index.d.mts +0 -30308
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { Client } from "./_internal/client/index";
|
|
2
|
+
import { RetryConfig } from "./utils/retry";
|
|
3
|
+
import { SdkEventEmitter } from "./events";
|
|
4
|
+
import type { Logger, LogLevel } from "./logging";
|
|
5
|
+
export { InsecureConnectionError, BrowserApiKeyError } from "./security";
|
|
6
|
+
export type { Logger, LogLevel } from "./logging";
|
|
7
|
+
/** SDK version and default API version — sourced from generated version.ts */
|
|
8
|
+
import { SDK_VERSION, DEFAULT_API_VERSION } from "./version";
|
|
9
|
+
export { SDK_VERSION, DEFAULT_API_VERSION };
|
|
10
|
+
/** Security configuration options */
|
|
11
|
+
export interface SecurityConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Require HTTPS for all requests (except localhost).
|
|
14
|
+
* When true, throws an error instead of just warning.
|
|
15
|
+
* Recommended for production environments.
|
|
16
|
+
* Default: false (warning only)
|
|
17
|
+
*/
|
|
18
|
+
requireHttps?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Warn when using API keys in browser environment.
|
|
21
|
+
* API keys should only be used server-side.
|
|
22
|
+
* Default: true
|
|
23
|
+
* @deprecated Use `dangerouslyAllowBrowser` instead
|
|
24
|
+
*/
|
|
25
|
+
warnBrowserApiKey?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Application info for User-Agent (Stripe-style) */
|
|
28
|
+
export interface AppInfo {
|
|
29
|
+
/** Application name */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Application version */
|
|
32
|
+
version?: string;
|
|
33
|
+
/** Application URL */
|
|
34
|
+
url?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Request options that can be passed to individual namespace methods */
|
|
37
|
+
export interface RequestOptions {
|
|
38
|
+
/** AbortSignal for cancellation */
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
/** Idempotency key override */
|
|
41
|
+
idempotencyKey?: string;
|
|
42
|
+
/** Additional headers for this request */
|
|
43
|
+
headers?: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
export interface BaseClientConfig {
|
|
46
|
+
/** Base URL of the GPT Core API */
|
|
47
|
+
baseUrl?: string;
|
|
48
|
+
/** User JWT token (Bearer auth) */
|
|
49
|
+
token?: string;
|
|
50
|
+
/** Application API key (x-application-key header) */
|
|
51
|
+
apiKey?: string;
|
|
52
|
+
/** Retry configuration, or `false` to disable retries */
|
|
53
|
+
retry?: Partial<RetryConfig> | false;
|
|
54
|
+
/**
|
|
55
|
+
* API version date to use for requests (e.g., "2025-12-03").
|
|
56
|
+
* Defaults to the version this SDK was built against.
|
|
57
|
+
* Pin this to a specific date to prevent breaking changes
|
|
58
|
+
* when upgrading the SDK.
|
|
59
|
+
*/
|
|
60
|
+
apiVersion?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Security configuration options.
|
|
63
|
+
* Controls HTTPS enforcement and browser warnings.
|
|
64
|
+
*/
|
|
65
|
+
security?: SecurityConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Request timeout in milliseconds.
|
|
68
|
+
* Applies to all requests made by this client.
|
|
69
|
+
* Default: no timeout (0 = disabled)
|
|
70
|
+
*/
|
|
71
|
+
timeout?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Custom fetch implementation.
|
|
74
|
+
* Useful for testing or custom network layers.
|
|
75
|
+
* Default: globalThis.fetch
|
|
76
|
+
*/
|
|
77
|
+
fetch?: typeof fetch;
|
|
78
|
+
/**
|
|
79
|
+
* Default headers sent with every request.
|
|
80
|
+
* Auth headers and Content-Type are not overridden.
|
|
81
|
+
*/
|
|
82
|
+
defaultHeaders?: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Default workspace ID appended as `?workspace_id=` to every request that
|
|
85
|
+
* doesn't already carry one.
|
|
86
|
+
*
|
|
87
|
+
* **When to use:**
|
|
88
|
+
* - Server-side service clients where ALL operations target a single known
|
|
89
|
+
* workspace (e.g., a background job scoped to one tenant's workspace).
|
|
90
|
+
*
|
|
91
|
+
* **When NOT to use:**
|
|
92
|
+
* - Single-workspace apps (`workspace_mode: "single"`): the platform
|
|
93
|
+
* auto-resolves the default workspace — this field is unnecessary.
|
|
94
|
+
* - Multi-workspace apps with per-user routing: set `workspace_id` on the
|
|
95
|
+
* API key itself via the platform dashboard instead. The key-level
|
|
96
|
+
* `workspace_id` takes precedence and correctly scopes each key to its
|
|
97
|
+
* own workspace without leaking across users.
|
|
98
|
+
*/
|
|
99
|
+
workspaceId?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Allow API key usage in browser environments.
|
|
102
|
+
* By default, using an API key in a browser throws an error.
|
|
103
|
+
* Set to true to suppress this safety check.
|
|
104
|
+
* Default: false
|
|
105
|
+
*/
|
|
106
|
+
dangerouslyAllowBrowser?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Log level for SDK operations.
|
|
109
|
+
* Default: 'warn'
|
|
110
|
+
*/
|
|
111
|
+
logLevel?: LogLevel;
|
|
112
|
+
/**
|
|
113
|
+
* Custom logger implementation.
|
|
114
|
+
* Default: console
|
|
115
|
+
*/
|
|
116
|
+
logger?: Logger;
|
|
117
|
+
/**
|
|
118
|
+
* Application info for User-Agent header (Stripe-style).
|
|
119
|
+
* Used by platform integrators to identify their app.
|
|
120
|
+
*/
|
|
121
|
+
appInfo?: AppInfo;
|
|
122
|
+
}
|
|
123
|
+
export declare abstract class BaseClient {
|
|
124
|
+
protected retryConfig: Partial<RetryConfig> | false;
|
|
125
|
+
protected config: BaseClientConfig;
|
|
126
|
+
/** Per-instance client from @hey-api/openapi-ts */
|
|
127
|
+
protected clientInstance: Client;
|
|
128
|
+
/** The effective API version used by this client instance */
|
|
129
|
+
readonly apiVersion: string;
|
|
130
|
+
/** SDK lifecycle event emitter */
|
|
131
|
+
readonly events: SdkEventEmitter;
|
|
132
|
+
/** WeakMap to track request start times without mutating Request objects */
|
|
133
|
+
private readonly requestTimings;
|
|
134
|
+
/** Structured logger */
|
|
135
|
+
protected log: {
|
|
136
|
+
debug: (...args: unknown[]) => void;
|
|
137
|
+
info: (...args: unknown[]) => void;
|
|
138
|
+
warn: (...args: unknown[]) => void;
|
|
139
|
+
error: (...args: unknown[]) => void;
|
|
140
|
+
};
|
|
141
|
+
constructor(config?: BaseClientConfig);
|
|
142
|
+
/** Get the per-instance client for use in namespace methods */
|
|
143
|
+
getClientInstance(): Client;
|
|
144
|
+
/** Get headers for requests (used by namespaces) */
|
|
145
|
+
protected getHeaders(): Record<string, string>;
|
|
146
|
+
/**
|
|
147
|
+
* Unwrap a JSON:API response envelope.
|
|
148
|
+
* Extracts nested data and flattens JSON:API resources:
|
|
149
|
+
* { id, type, attributes, relationships } → { id, type, ...attributes, ...relationships }
|
|
150
|
+
* Also handles arrays of resources.
|
|
151
|
+
*/
|
|
152
|
+
protected unwrap<T>(resource: unknown): T;
|
|
153
|
+
/**
|
|
154
|
+
* Flatten a single JSON:API resource: { id, type, attributes, relationships } → { id, type, ...attributes, ...relationships }
|
|
155
|
+
*/
|
|
156
|
+
private flattenResource;
|
|
157
|
+
protected handleError(error: unknown): never;
|
|
158
|
+
/**
|
|
159
|
+
* Execute an API call with retry logic.
|
|
160
|
+
* Used by namespace methods to automatically retry on transient failures.
|
|
161
|
+
*/
|
|
162
|
+
protected requestWithRetry<T>(fn: () => Promise<T>): Promise<T>;
|
|
163
|
+
/**
|
|
164
|
+
* Update the authentication token (e.g., after login or token refresh).
|
|
165
|
+
* The interceptor reads from this.config dynamically, so changes take effect immediately.
|
|
166
|
+
*/
|
|
167
|
+
setToken(token: string): void;
|
|
168
|
+
/**
|
|
169
|
+
* Clear the authentication token (e.g., on logout).
|
|
170
|
+
*/
|
|
171
|
+
clearToken(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Switch the workspace context for all subsequent requests.
|
|
174
|
+
*
|
|
175
|
+
* Sets the `workspace_id` query parameter appended to every request.
|
|
176
|
+
* Use this after creating a new workspace or switching workspace context
|
|
177
|
+
* without constructing a new client instance.
|
|
178
|
+
*
|
|
179
|
+
* @param workspaceId - The workspace UUID to scope requests to, or
|
|
180
|
+
* `undefined` to clear workspace scoping.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const org = await sdk.platform.tenants.createOrg({ name: 'Acme' });
|
|
185
|
+
* const workspaces = await sdk.platform.workspaces.mine();
|
|
186
|
+
* const ws = workspaces.find(w => w.tenant_id === org.id);
|
|
187
|
+
*
|
|
188
|
+
* sdk.setWorkspaceId(ws.id);
|
|
189
|
+
* // All subsequent calls are scoped to the new workspace
|
|
190
|
+
* await sdk.scheduling.events.create({ ... });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
setWorkspaceId(workspaceId: string | undefined): void;
|
|
194
|
+
/**
|
|
195
|
+
* Get the current workspace ID, if set.
|
|
196
|
+
*/
|
|
197
|
+
getWorkspaceId(): string | undefined;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=base-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-client.d.ts","sourceRoot":"","sources":["../src/base-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,WAAW,EAGZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAS3C,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGlD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACzE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAElD,8EAA8E;AAC9E,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;AAE5C,qCAAqC;AACrC,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,qDAAqD;AACrD,MAAM,WAAW,OAAO;IACtB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0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,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAI5D;;OAEG;IACI,cAAc,IAAI,MAAM,GAAG,SAAS;CAG5C"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all GPT Core SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class GptCoreError extends Error {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly statusCode?: number;
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly requestId?: string;
|
|
9
|
+
readonly headers?: Record<string, string>;
|
|
10
|
+
readonly body?: unknown;
|
|
11
|
+
cause?: Error;
|
|
12
|
+
constructor(message: string, options?: {
|
|
13
|
+
statusCode?: number;
|
|
14
|
+
code?: string;
|
|
15
|
+
requestId?: string;
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
body?: unknown;
|
|
18
|
+
cause?: Error;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Serialize error to plain object for logging/debugging
|
|
22
|
+
*/
|
|
23
|
+
toJSON(): {
|
|
24
|
+
name: string;
|
|
25
|
+
message: string;
|
|
26
|
+
statusCode?: number;
|
|
27
|
+
code: string;
|
|
28
|
+
requestId?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Authentication errors (401)
|
|
33
|
+
*/
|
|
34
|
+
export declare class AuthenticationError extends GptCoreError {
|
|
35
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Authorization/Permission errors (403)
|
|
39
|
+
*/
|
|
40
|
+
export declare class AuthorizationError extends GptCoreError {
|
|
41
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resource not found errors (404)
|
|
45
|
+
*/
|
|
46
|
+
export declare class NotFoundError extends GptCoreError {
|
|
47
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validation errors (400, 422)
|
|
51
|
+
*/
|
|
52
|
+
export declare class ValidationError extends GptCoreError {
|
|
53
|
+
readonly errors?: Array<{
|
|
54
|
+
field?: string;
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
constructor(message?: string, errors?: Array<{
|
|
58
|
+
field?: string;
|
|
59
|
+
message: string;
|
|
60
|
+
}>, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Rate limiting errors (429)
|
|
64
|
+
*/
|
|
65
|
+
export declare class RateLimitError extends GptCoreError {
|
|
66
|
+
readonly retryAfter?: number;
|
|
67
|
+
constructor(message?: string, retryAfter?: number, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Network/connection errors
|
|
71
|
+
*/
|
|
72
|
+
export declare class NetworkError extends GptCoreError {
|
|
73
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Timeout errors
|
|
77
|
+
*/
|
|
78
|
+
export declare class TimeoutError extends GptCoreError {
|
|
79
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Server errors (500+)
|
|
83
|
+
*/
|
|
84
|
+
export declare class ServerError extends GptCoreError {
|
|
85
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Conflict errors (409)
|
|
89
|
+
*/
|
|
90
|
+
export declare class ConflictError extends GptCoreError {
|
|
91
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Payment required errors (402) — insufficient balance or payment needed.
|
|
95
|
+
*
|
|
96
|
+
* Thrown when the workspace has insufficient credits for the requested operation.
|
|
97
|
+
* Prompt the user to purchase credits or upgrade their plan.
|
|
98
|
+
*/
|
|
99
|
+
export declare class PaymentRequiredError extends GptCoreError {
|
|
100
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Card declined errors (402 with code "card_declined") — the payment gateway
|
|
104
|
+
* rejected the card.
|
|
105
|
+
*
|
|
106
|
+
* Check `declineCode` for the machine-readable reason (e.g., "insufficient_funds",
|
|
107
|
+
* "do_not_honor"). Display a user-friendly message and prompt for a different card.
|
|
108
|
+
*/
|
|
109
|
+
export declare class CardDeclinedError extends GptCoreError {
|
|
110
|
+
/** Machine-readable decline reason from the payment gateway, if available. */
|
|
111
|
+
readonly declineCode?: string;
|
|
112
|
+
constructor(message?: string, declineCode?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Subscription conflict errors (409 with code "subscription_conflict") — a plan
|
|
116
|
+
* change was requested but conflicts with the current subscription state.
|
|
117
|
+
*
|
|
118
|
+
* This is distinct from a generic ConflictError. Occurs when attempting to
|
|
119
|
+
* downgrade while add-ons or usage exceed the target plan's limits.
|
|
120
|
+
*/
|
|
121
|
+
export declare class SubscriptionConflictError extends GptCoreError {
|
|
122
|
+
constructor(message?: string, options?: ConstructorParameters<typeof GptCoreError>[1]);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parse error response and throw appropriate error class
|
|
126
|
+
*/
|
|
127
|
+
export declare function handleApiError(error: unknown): never;
|
|
128
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,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,CAAC,CAAC,CAAC,CAAC;CAI1D;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;gBAElD,OAAO,SAAqB,EAC5B,OAAO,CAAC,EAAE,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;CAQ1D;AAED;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,8EAA8E;IAC9E,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAGnC,OAAO,SAAkB,EACzB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;CAS1D;AAED;;;;;;GAMG;AACH,qBAAa,yBAA0B,SAAQ,YAAY;gBAEvD,OAAO,SAA0B,EACjC,OAAO,CAAC,EAAE,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;CAQ1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAqMpD"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK lifecycle events.
|
|
3
|
+
* Stripe-style hooks for monitoring request/response/retry cycles.
|
|
4
|
+
*/
|
|
5
|
+
export interface SdkRequestEvent {
|
|
6
|
+
/** HTTP method */
|
|
7
|
+
method: string;
|
|
8
|
+
/** Request URL */
|
|
9
|
+
url: string;
|
|
10
|
+
/** Request headers (auth headers redacted) */
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
/** Timestamp when request was initiated */
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SdkResponseEvent {
|
|
16
|
+
/** HTTP method */
|
|
17
|
+
method: string;
|
|
18
|
+
/** Request URL */
|
|
19
|
+
url: string;
|
|
20
|
+
/** HTTP status code */
|
|
21
|
+
status: number;
|
|
22
|
+
/** Response headers */
|
|
23
|
+
headers: Record<string, string>;
|
|
24
|
+
/** Request ID from x-request-id header */
|
|
25
|
+
requestId?: string;
|
|
26
|
+
/** Duration in milliseconds */
|
|
27
|
+
duration: number;
|
|
28
|
+
/** API version from response */
|
|
29
|
+
apiVersion?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface SdkRetryEvent {
|
|
32
|
+
/** Current retry attempt (1-based) */
|
|
33
|
+
attempt: number;
|
|
34
|
+
/** Maximum retries configured */
|
|
35
|
+
maxRetries: number;
|
|
36
|
+
/** Delay before next retry in ms */
|
|
37
|
+
delay: number;
|
|
38
|
+
/** The error that triggered the retry */
|
|
39
|
+
error: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface SdkErrorEvent {
|
|
42
|
+
/** HTTP method */
|
|
43
|
+
method: string;
|
|
44
|
+
/** Request URL */
|
|
45
|
+
url: string;
|
|
46
|
+
/** The error */
|
|
47
|
+
error: unknown;
|
|
48
|
+
/** Duration in milliseconds */
|
|
49
|
+
duration: number;
|
|
50
|
+
}
|
|
51
|
+
export type SdkEvents = {
|
|
52
|
+
request: SdkRequestEvent;
|
|
53
|
+
response: SdkResponseEvent;
|
|
54
|
+
retry: SdkRetryEvent;
|
|
55
|
+
error: SdkErrorEvent;
|
|
56
|
+
};
|
|
57
|
+
type EventHandler<T> = (event: T) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Type-safe event emitter for SDK lifecycle events.
|
|
60
|
+
*/
|
|
61
|
+
export declare class SdkEventEmitter {
|
|
62
|
+
private handlers;
|
|
63
|
+
on<K extends keyof SdkEvents>(event: K, handler: EventHandler<SdkEvents[K]>): () => void;
|
|
64
|
+
off<K extends keyof SdkEvents>(event: K, handler: EventHandler<SdkEvents[K]>): void;
|
|
65
|
+
emit<K extends keyof SdkEvents>(event: K, data: SdkEvents[K]): void;
|
|
66
|
+
removeAllListeners(event?: keyof SdkEvents): void;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -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AAC;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAE1C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAET;IAEP,EAAE,CAAC,CAAC,SAAS,MAAM,SAAS,EAC1B,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAClC,MAAM,IAAI;IAcb,GAAG,CAAC,CAAC,SAAS,MAAM,SAAS,EAC3B,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAClC,IAAI;IAIP,IAAI,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI;IAkBnE,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,SAAS,GAAG,IAAI;CAOlD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed events emitted by the agent execution SSE stream.
|
|
3
|
+
*
|
|
4
|
+
* Each event corresponds to a lifecycle stage of an agent execution.
|
|
5
|
+
* Use the `type` discriminant to narrow the union in switch statements.
|
|
6
|
+
*
|
|
7
|
+
* Field names match the backend SSE controller exactly:
|
|
8
|
+
* - token_delta → { content, index }
|
|
9
|
+
* - tool_call → { name, arguments }
|
|
10
|
+
* - tool_result → { name, summary }
|
|
11
|
+
* - iteration_complete → { iteration, tokens }
|
|
12
|
+
* - approval_required → { tool_name, arguments, classification }
|
|
13
|
+
* - done → { status, total_tokens, total_credits }
|
|
14
|
+
* - error → { error_type, message }
|
|
15
|
+
*/
|
|
16
|
+
/** Token fragment from LLM streaming output. */
|
|
17
|
+
export interface TokenDeltaEvent {
|
|
18
|
+
type: "token_delta";
|
|
19
|
+
data: {
|
|
20
|
+
content: string;
|
|
21
|
+
index: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Tool invocation started. */
|
|
25
|
+
export interface ToolCallEvent {
|
|
26
|
+
type: "tool_call";
|
|
27
|
+
data: {
|
|
28
|
+
name: string;
|
|
29
|
+
arguments: Record<string, unknown>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Tool invocation completed. */
|
|
33
|
+
export interface ToolResultEvent {
|
|
34
|
+
type: "tool_result";
|
|
35
|
+
data: {
|
|
36
|
+
name: string;
|
|
37
|
+
summary: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** LLM loop iteration completed. */
|
|
41
|
+
export interface IterationCompleteEvent {
|
|
42
|
+
type: "iteration_complete";
|
|
43
|
+
data: {
|
|
44
|
+
iteration: number;
|
|
45
|
+
tokens: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Human-in-the-loop approval required for a tool call. */
|
|
49
|
+
export interface ApprovalRequiredEvent {
|
|
50
|
+
type: "approval_required";
|
|
51
|
+
data: {
|
|
52
|
+
tool_name: string;
|
|
53
|
+
arguments: Record<string, unknown>;
|
|
54
|
+
classification: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Execution completed successfully. */
|
|
58
|
+
export interface DoneEvent {
|
|
59
|
+
type: "done";
|
|
60
|
+
data: {
|
|
61
|
+
status: string;
|
|
62
|
+
total_tokens: number;
|
|
63
|
+
total_credits: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Execution failed with an error. */
|
|
67
|
+
export interface ErrorEvent {
|
|
68
|
+
type: "error";
|
|
69
|
+
data: {
|
|
70
|
+
error_type: string;
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Union of all execution SSE event types.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* for await (const event of stream) {
|
|
80
|
+
* switch (event.type) {
|
|
81
|
+
* case "token_delta":
|
|
82
|
+
* process.stdout.write(event.data.content);
|
|
83
|
+
* break;
|
|
84
|
+
* case "tool_call":
|
|
85
|
+
* console.log(`Calling tool: ${event.data.name}`);
|
|
86
|
+
* break;
|
|
87
|
+
* case "done":
|
|
88
|
+
* console.log(`Complete: ${event.data.status}, tokens: ${event.data.total_tokens}`);
|
|
89
|
+
* break;
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export type ExecutionEvent = TokenDeltaEvent | ToolCallEvent | ToolResultEvent | IterationCompleteEvent | ApprovalRequiredEvent | DoneEvent | ErrorEvent;
|
|
95
|
+
//# sourceMappingURL=execution-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-events.d.ts","sourceRoot":"","sources":["../src/execution-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C;AAED,+BAA+B;AAC/B,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAC5D;AAED,iCAAiC;AACjC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,IAAI,E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