@slates/client 1.0.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,409 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ SlateProtocolError: () => SlateProtocolError,
24
+ SlatesProtocolClient: () => SlatesProtocolClient,
25
+ createLocalSlateTransport: () => createLocalSlateTransport,
26
+ createSlatesClient: () => createSlatesClient
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/client.ts
31
+ var import_proto = require("@slates/proto");
32
+ var import_crypto = require("crypto");
33
+
34
+ // src/error.ts
35
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
36
+ var isSlateErrorResponse = (error) => isRecord(error) && typeof error.code === "string" && typeof error.message === "string";
37
+ var inferKindFromCode = (code) => {
38
+ if (code.startsWith("declaration.")) return "declaration";
39
+ if (code.startsWith("input.")) return "validation";
40
+ if (code.startsWith("request.")) return "request";
41
+ if (code.startsWith("config.")) return "config";
42
+ if (code.startsWith("auth.") || code.startsWith("permission.")) return "auth";
43
+ if (code.startsWith("resource.")) return "resource";
44
+ if (code.startsWith("payment.")) return "payment";
45
+ if (code.startsWith("transport.")) return "transport";
46
+ if (code.startsWith("upstream.")) return "upstream";
47
+ return "internal";
48
+ };
49
+ var normalizeResponse = (error, source, defaults = {}) => {
50
+ if (isSlateErrorResponse(error)) {
51
+ return {
52
+ ...defaults,
53
+ ...error,
54
+ kind: error.kind ?? inferKindFromCode(error.code)
55
+ };
56
+ }
57
+ if (isRecord(error) && typeof error.message === "string") {
58
+ let code2 = typeof error.code === "string" ? error.code : defaults.code ?? (source === "transport" ? "transport.invoke_failed" : "internal.unexpected");
59
+ return {
60
+ ...defaults,
61
+ ...error,
62
+ code: code2,
63
+ message: error.message,
64
+ kind: (typeof error.kind === "string" ? error.kind : defaults.kind) ?? inferKindFromCode(code2)
65
+ };
66
+ }
67
+ let code = defaults.code ?? (source === "transport" ? "transport.invoke_failed" : "internal.unexpected");
68
+ return {
69
+ ...defaults,
70
+ code,
71
+ message: error instanceof Error ? error.message : defaults.message ?? "The slate returned an unexpected error.",
72
+ kind: defaults.kind ?? inferKindFromCode(code),
73
+ baggage: {
74
+ ...defaults.baggage ?? {},
75
+ ...error instanceof Error ? { originalName: error.name } : { originalValue: error }
76
+ }
77
+ };
78
+ };
79
+ var SlateProtocolError = class _SlateProtocolError extends Error {
80
+ cause;
81
+ data;
82
+ source;
83
+ constructor(data, source = "provider", cause) {
84
+ super(data.message);
85
+ this.name = "SlateProtocolError";
86
+ this.data = data;
87
+ this.source = source;
88
+ this.cause = cause;
89
+ }
90
+ get code() {
91
+ return this.data.code;
92
+ }
93
+ get kind() {
94
+ return this.data.kind;
95
+ }
96
+ get retryable() {
97
+ return this.data.retryable;
98
+ }
99
+ get status() {
100
+ return this.data.status;
101
+ }
102
+ toJSON() {
103
+ return {
104
+ ...this.data,
105
+ source: this.source
106
+ };
107
+ }
108
+ static is(error) {
109
+ return error instanceof _SlateProtocolError;
110
+ }
111
+ static fromResponse(error, source = "provider") {
112
+ if (_SlateProtocolError.is(error)) return error;
113
+ return new _SlateProtocolError(normalizeResponse(error, source), source, error);
114
+ }
115
+ static fromUnknown(error, defaults = {}, source = "transport") {
116
+ if (_SlateProtocolError.is(error)) return error;
117
+ return new _SlateProtocolError(normalizeResponse(error, source, defaults), source, error);
118
+ }
119
+ };
120
+
121
+ // src/client.ts
122
+ var createDefaultParticipants = () => [
123
+ {
124
+ type: "consumer",
125
+ id: "slates-client",
126
+ name: "Slates Client"
127
+ }
128
+ ];
129
+ var SlatesProtocolClient = class {
130
+ transport;
131
+ state;
132
+ constructor(opts) {
133
+ this.transport = opts.transport;
134
+ this.state = {
135
+ protocol: import_proto.SLATES_PROTOCOL_VERSION,
136
+ participants: opts.participants ?? createDefaultParticipants(),
137
+ config: opts.state?.config ?? null,
138
+ auth: opts.state?.auth ?? null,
139
+ session: opts.state?.session ?? null
140
+ };
141
+ }
142
+ setParticipants(participants) {
143
+ this.state.participants = participants;
144
+ return this;
145
+ }
146
+ setConfig(config) {
147
+ this.state.config = config;
148
+ return this;
149
+ }
150
+ setAuth(auth) {
151
+ this.state.auth = auth;
152
+ return this;
153
+ }
154
+ clearAuth() {
155
+ this.state.auth = null;
156
+ return this;
157
+ }
158
+ setSession(session) {
159
+ this.state.session = session;
160
+ return this;
161
+ }
162
+ ensureSession() {
163
+ if (!this.state.session) {
164
+ this.state.session = {
165
+ id: (0, import_crypto.randomUUID)(),
166
+ state: {}
167
+ };
168
+ }
169
+ return this.state.session;
170
+ }
171
+ buildStateMessages() {
172
+ return [
173
+ {
174
+ jsonrpc: "2.0",
175
+ method: "slates/hello",
176
+ params: { protocol: this.state.protocol }
177
+ },
178
+ {
179
+ jsonrpc: "2.0",
180
+ method: "slates/participant.set",
181
+ params: { participants: this.state.participants }
182
+ },
183
+ ...this.state.config ? [
184
+ {
185
+ jsonrpc: "2.0",
186
+ method: "slates/config.set",
187
+ params: { config: this.state.config }
188
+ }
189
+ ] : [],
190
+ ...this.state.auth ? [
191
+ {
192
+ jsonrpc: "2.0",
193
+ method: "slates/auth.set",
194
+ params: {
195
+ authenticationMethodId: this.state.auth.authenticationMethodId,
196
+ output: this.state.auth.output
197
+ }
198
+ }
199
+ ] : [],
200
+ ...this.state.session ? [
201
+ {
202
+ jsonrpc: "2.0",
203
+ method: "slates/session.start",
204
+ params: {
205
+ sessionId: this.state.session.id,
206
+ state: this.state.session.state
207
+ }
208
+ }
209
+ ] : []
210
+ ];
211
+ }
212
+ async request(method, params) {
213
+ let id = (0, import_crypto.randomUUID)();
214
+ let responses = await this.transport.send([
215
+ ...this.buildStateMessages(),
216
+ {
217
+ jsonrpc: "2.0",
218
+ id,
219
+ method,
220
+ params
221
+ }
222
+ ]);
223
+ let response = responses.find((message) => "id" in message && message.id === id);
224
+ if (!response) {
225
+ throw new Error(`No response was returned for method ${String(method)}.`);
226
+ }
227
+ if (response.error) {
228
+ throw SlateProtocolError.fromResponse(response.error);
229
+ }
230
+ return response.result;
231
+ }
232
+ async identify() {
233
+ return this.request("slates/provider.identify", {});
234
+ }
235
+ async listActions() {
236
+ return this.request("slates/actions.list", {});
237
+ }
238
+ async listTools() {
239
+ let result = await this.listActions();
240
+ return result.actions.filter((action) => action.type === "action.tool");
241
+ }
242
+ async listTriggers() {
243
+ let result = await this.listActions();
244
+ return result.actions.filter((action) => action.type === "action.trigger");
245
+ }
246
+ async getAction(actionId) {
247
+ return this.request("slates/action.get", { actionId });
248
+ }
249
+ async getTool(actionId) {
250
+ let result = await this.getAction(actionId);
251
+ if (result.action.type !== "action.tool") {
252
+ throw new Error(`Action ${actionId} is not a tool.`);
253
+ }
254
+ return result.action;
255
+ }
256
+ async getTrigger(actionId) {
257
+ let result = await this.getAction(actionId);
258
+ if (result.action.type !== "action.trigger") {
259
+ throw new Error(`Action ${actionId} is not a trigger.`);
260
+ }
261
+ return result.action;
262
+ }
263
+ async getConfigSchema() {
264
+ return this.request("slates/config.schema.get", {});
265
+ }
266
+ async getDefaultConfig() {
267
+ return this.request("slates/config.get_default", {});
268
+ }
269
+ async updateConfig(previousConfig, newConfig) {
270
+ return this.request("slates/config.changed", {
271
+ previousConfig,
272
+ newConfig
273
+ });
274
+ }
275
+ async listAuthMethods() {
276
+ return this.request("slates/auth.methods.list", {});
277
+ }
278
+ async getAuthMethod(authenticationMethodId) {
279
+ return this.request("slates/auth.method.get", {
280
+ authenticationMethodId
281
+ });
282
+ }
283
+ async getDefaultAuthInput(authenticationMethodId) {
284
+ return this.request("slates/auth.input.get_default", {
285
+ authenticationMethodId
286
+ });
287
+ }
288
+ async updateAuthInput(d) {
289
+ return this.request("slates/auth.input.changed", {
290
+ authenticationMethodId: d.authenticationMethodId,
291
+ previousInput: d.previousInput,
292
+ newInput: d.newInput
293
+ });
294
+ }
295
+ async getAuthOutput(d) {
296
+ return this.request("slates/auth.output.get", {
297
+ authenticationMethodId: d.authenticationMethodId,
298
+ input: d.input
299
+ });
300
+ }
301
+ async getAuthorizationUrl(d) {
302
+ return this.request("slates/auth.authorization_url.get", d);
303
+ }
304
+ async handleAuthorizationCallback(d) {
305
+ return this.request("slates/auth.authorization_callback.handle", d);
306
+ }
307
+ async refreshToken(d) {
308
+ return this.request("slates/auth.token_refresh.handle", d);
309
+ }
310
+ async getAuthProfile(d) {
311
+ return this.request("slates/auth.profile.get", d);
312
+ }
313
+ async invokeTool(actionId, input) {
314
+ this.ensureSession();
315
+ return this.request("slates/action.tool.invoke", {
316
+ actionId,
317
+ input
318
+ });
319
+ }
320
+ async mapTriggerEvent(actionId, input) {
321
+ this.ensureSession();
322
+ return this.request("slates/action.trigger.map_event", {
323
+ actionId,
324
+ input
325
+ });
326
+ }
327
+ async registerTriggerWebhook(actionId, webhookBaseUrl) {
328
+ this.ensureSession();
329
+ return this.request("slates/action.trigger.webhook_register", {
330
+ actionId,
331
+ webhookBaseUrl
332
+ });
333
+ }
334
+ async handleTriggerWebhook(d) {
335
+ this.ensureSession();
336
+ let encodedBody = typeof d.body === "string" ? Buffer.from(d.body, "utf-8").toString("base64") : d.body ? Buffer.from(d.body).toString("base64") : null;
337
+ return this.request("slates/action.trigger.webhook_handle", {
338
+ actionId: d.actionId,
339
+ url: d.url,
340
+ method: d.method,
341
+ headers: d.headers ?? {},
342
+ body: encodedBody ? {
343
+ encoding: "base64",
344
+ content: encodedBody
345
+ } : null,
346
+ state: d.state ?? null
347
+ });
348
+ }
349
+ async unregisterTriggerWebhook(d) {
350
+ this.ensureSession();
351
+ return this.request("slates/action.trigger.webhook_unregister", {
352
+ actionId: d.actionId,
353
+ webhookBaseUrl: d.webhookBaseUrl,
354
+ registrationDetails: d.registrationDetails,
355
+ state: d.state ?? null
356
+ });
357
+ }
358
+ async close() {
359
+ await this.transport.close?.();
360
+ }
361
+ };
362
+
363
+ // src/transport.ts
364
+ var import_proto2 = require("@slates/proto");
365
+ var import_provider_handler = require("@slates/provider-handler");
366
+ var toTransportError = (value, defaultMessage) => SlateProtocolError.fromUnknown(
367
+ value,
368
+ {
369
+ code: "transport.invoke_failed",
370
+ kind: "transport",
371
+ message: defaultMessage,
372
+ retryable: true,
373
+ baggage: {
374
+ response: value
375
+ }
376
+ },
377
+ "transport"
378
+ );
379
+ var createLocalSlateTransport = (d) => {
380
+ let managerPromise = (0, import_provider_handler.createProviderHandler)(d.slate, d.listeners ?? []).run();
381
+ return {
382
+ async send(messages) {
383
+ let manager = await managerPromise;
384
+ let responses = [];
385
+ for (let message of messages) {
386
+ let response;
387
+ try {
388
+ response = await import_proto2.SlatesProviderProtoHandlerManager.handleInput(manager, message);
389
+ } catch (error) {
390
+ throw toTransportError(error, "Local slate invocation failed");
391
+ }
392
+ if (response) {
393
+ responses.push(response);
394
+ }
395
+ }
396
+ return responses;
397
+ }
398
+ };
399
+ };
400
+
401
+ // src/index.ts
402
+ var createSlatesClient = (opts) => new SlatesProtocolClient(opts);
403
+ // Annotate the CommonJS export names for ESM import in node:
404
+ 0 && (module.exports = {
405
+ SlateProtocolError,
406
+ SlatesProtocolClient,
407
+ createLocalSlateTransport,
408
+ createSlatesClient
409
+ });
@@ -0,0 +1,227 @@
1
+ import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageActionTriggerWebhookRegisterResponse, SlatesMessageActionTriggerWebhookHandleResponse, SlatesMessageActionTriggerWebhookUnregisterResponse } from '@slates/proto';
2
+ import { Slate, SlateLogListener } from '@slates/provider';
3
+
4
+ type SlatesJsonObject = Record<string, any>;
5
+ type SlatesProtocolMessage = SlatesNotifications | SlatesRequests;
6
+ type SlatesProtocolResponse = SlatesNotifications | SlatesResponses;
7
+ interface SlatesClientState {
8
+ protocol: SlatesProtocolVersion;
9
+ participants: SlatesParticipant[];
10
+ config: SlatesJsonObject | null;
11
+ auth: {
12
+ authenticationMethodId: string;
13
+ output: SlatesJsonObject;
14
+ } | null;
15
+ session: {
16
+ id: string;
17
+ state: SlatesJsonObject;
18
+ } | null;
19
+ }
20
+ interface SlatesMessageTransport {
21
+ send(messages: SlatesProtocolMessage[]): Promise<SlatesProtocolResponse[]>;
22
+ close?(): Promise<void> | void;
23
+ }
24
+ interface SlatesProtocolClientOptions {
25
+ transport: SlatesMessageTransport;
26
+ participants?: SlatesParticipant[];
27
+ state?: Partial<SlatesClientState>;
28
+ }
29
+
30
+ declare class SlatesProtocolClient {
31
+ readonly transport: SlatesProtocolClientOptions['transport'];
32
+ state: SlatesClientState;
33
+ constructor(opts: SlatesProtocolClientOptions);
34
+ setParticipants(participants: SlatesParticipant[]): this;
35
+ setConfig(config: Record<string, any> | null): this;
36
+ setAuth(auth: SlatesClientState['auth']): this;
37
+ clearAuth(): this;
38
+ setSession(session: SlatesClientState['session']): this;
39
+ ensureSession(): {
40
+ id: string;
41
+ state: SlatesJsonObject;
42
+ };
43
+ private buildStateMessages;
44
+ request<Key extends keyof SlatesResponsesByMethod & SlatesRequests['method']>(method: Key, params: Extract<SlatesRequests, {
45
+ method: Key;
46
+ }>['params']): Promise<SlatesResponsesByMethod[Key]['result']>;
47
+ identify(): Promise<SlatesMessageProviderIdentifyResponse['result']>;
48
+ listActions(): Promise<SlatesMessageActionsListResponse['result']>;
49
+ listTools(): Promise<SlatesAction[]>;
50
+ listTriggers(): Promise<SlatesAction[]>;
51
+ getAction(actionId: string): Promise<SlatesMessageActionGetResponse['result']>;
52
+ getTool(actionId: string): Promise<{
53
+ id: string;
54
+ name: string;
55
+ inputSchema: Record<string, any>;
56
+ outputSchema: Record<string, any>;
57
+ type: "action.tool";
58
+ capabilities: Record<string, never>;
59
+ description?: string | undefined;
60
+ instructions?: string[] | undefined;
61
+ constraints?: string[] | undefined;
62
+ tags?: {
63
+ destructive?: boolean | undefined;
64
+ readOnly?: boolean | undefined;
65
+ } | undefined;
66
+ metadata?: Record<string, any> | undefined;
67
+ scopes?: {
68
+ AND: {
69
+ OR: string[];
70
+ }[];
71
+ } | undefined;
72
+ }>;
73
+ getTrigger(actionId: string): Promise<{
74
+ id: string;
75
+ name: string;
76
+ inputSchema: Record<string, any>;
77
+ outputSchema: Record<string, any>;
78
+ type: "action.trigger";
79
+ capabilities: Record<string, never>;
80
+ invocation: {
81
+ type: "polling";
82
+ intervalSeconds: number;
83
+ } | {
84
+ type: "webhook";
85
+ autoRegistration: boolean;
86
+ autoUnregistration: boolean;
87
+ };
88
+ description?: string | undefined;
89
+ instructions?: string[] | undefined;
90
+ constraints?: string[] | undefined;
91
+ tags?: {
92
+ destructive?: boolean | undefined;
93
+ readOnly?: boolean | undefined;
94
+ } | undefined;
95
+ metadata?: Record<string, any> | undefined;
96
+ scopes?: {
97
+ AND: {
98
+ OR: string[];
99
+ }[];
100
+ } | undefined;
101
+ }>;
102
+ getConfigSchema(): Promise<SlatesMessageConfigSchemaGetResponse['result']>;
103
+ getDefaultConfig(): Promise<SlatesMessageConfigDefaultGetResponse['result']>;
104
+ updateConfig(previousConfig: Record<string, any> | null, newConfig: Record<string, any>): Promise<SlatesMessageConfigChangedResponse['result']>;
105
+ listAuthMethods(): Promise<{
106
+ authenticationMethods: SlateAuthenticationMethod[];
107
+ }>;
108
+ getAuthMethod(authenticationMethodId: string): Promise<SlatesMessageAuthMethodGetResponse['result']>;
109
+ getDefaultAuthInput(authenticationMethodId: string): Promise<SlatesMessageAuthDefaultInputGetResponse['result']>;
110
+ updateAuthInput(d: {
111
+ authenticationMethodId: string;
112
+ previousInput: Record<string, any> | null;
113
+ newInput: Record<string, any>;
114
+ }): Promise<SlatesMessageAuthInputChangedResponse['result']>;
115
+ getAuthOutput(d: {
116
+ authenticationMethodId: string;
117
+ input: Record<string, any>;
118
+ }): Promise<SlatesMessageAuthOutputGetResponse['result']>;
119
+ getAuthorizationUrl(d: {
120
+ authenticationMethodId: string;
121
+ redirectUri: string;
122
+ state: string;
123
+ input: Record<string, any>;
124
+ clientId: string;
125
+ clientSecret: string;
126
+ scopes: string[];
127
+ }): Promise<SlatesMessageAuthAuthorizationUrlGetResponse['result']>;
128
+ handleAuthorizationCallback(d: {
129
+ authenticationMethodId: string;
130
+ code: string;
131
+ state: string;
132
+ redirectUri: string;
133
+ input: Record<string, any>;
134
+ clientId: string;
135
+ clientSecret: string;
136
+ scopes: string[];
137
+ callbackParams?: Record<string, string>;
138
+ callbackState?: Record<string, any>;
139
+ }): Promise<{
140
+ output: Record<string, any>;
141
+ input?: Record<string, any>;
142
+ scopes?: string[];
143
+ }>;
144
+ refreshToken(d: {
145
+ authenticationMethodId: string;
146
+ output: Record<string, any>;
147
+ input: Record<string, any>;
148
+ clientId: string;
149
+ clientSecret: string;
150
+ scopes: string[];
151
+ }): Promise<SlatesMessageAuthTokenRefreshHandleResponse['result']>;
152
+ getAuthProfile(d: {
153
+ authenticationMethodId: string;
154
+ output: Record<string, any>;
155
+ input: Record<string, any>;
156
+ scopes: string[];
157
+ }): Promise<SlatesMessageAuthProfileGetResponse['result']>;
158
+ invokeTool(actionId: string, input: Record<string, any>): Promise<SlatesMessageActionInvokeResponse['result']>;
159
+ mapTriggerEvent(actionId: string, input: Record<string, any>): Promise<SlatesMessageActionTriggerEventMapResponse['result']>;
160
+ registerTriggerWebhook(actionId: string, webhookBaseUrl: string): Promise<SlatesMessageActionTriggerWebhookRegisterResponse['result']>;
161
+ handleTriggerWebhook(d: {
162
+ actionId: string;
163
+ url: string;
164
+ method: string;
165
+ headers?: Record<string, string>;
166
+ body?: string | Uint8Array | null;
167
+ state?: any;
168
+ }): Promise<SlatesMessageActionTriggerWebhookHandleResponse['result']>;
169
+ unregisterTriggerWebhook(d: {
170
+ actionId: string;
171
+ webhookBaseUrl: string;
172
+ registrationDetails: any;
173
+ state?: any;
174
+ }): Promise<SlatesMessageActionTriggerWebhookUnregisterResponse['result']>;
175
+ close(): Promise<void>;
176
+ }
177
+
178
+ type SlateProtocolErrorSource = 'provider' | 'transport';
179
+ type SlateProtocolErrorKind = 'declaration' | 'validation' | 'request' | 'auth' | 'config' | 'resource' | 'payment' | 'upstream' | 'transport' | 'internal';
180
+ interface SlateProtocolErrorResponse {
181
+ code: string;
182
+ message: string;
183
+ kind: SlateProtocolErrorKind;
184
+ retryable?: boolean;
185
+ status?: number;
186
+ issues?: Record<string, unknown>[];
187
+ provider?: Record<string, unknown>;
188
+ upstream?: Record<string, unknown>;
189
+ baggage?: Record<string, unknown>;
190
+ requestTraces?: Record<string, unknown>[];
191
+ [key: string]: unknown;
192
+ }
193
+ declare class SlateProtocolError extends Error {
194
+ cause?: unknown;
195
+ data: SlateProtocolErrorResponse;
196
+ source: SlateProtocolErrorSource;
197
+ constructor(data: SlateProtocolErrorResponse, source?: SlateProtocolErrorSource, cause?: unknown);
198
+ get code(): string;
199
+ get kind(): SlateProtocolErrorKind;
200
+ get retryable(): boolean | undefined;
201
+ get status(): number | undefined;
202
+ toJSON(): {
203
+ source: SlateProtocolErrorSource;
204
+ code: string;
205
+ message: string;
206
+ kind: SlateProtocolErrorKind;
207
+ retryable?: boolean;
208
+ status?: number;
209
+ issues?: Record<string, unknown>[];
210
+ provider?: Record<string, unknown>;
211
+ upstream?: Record<string, unknown>;
212
+ baggage?: Record<string, unknown>;
213
+ requestTraces?: Record<string, unknown>[];
214
+ };
215
+ static is(error: unknown): error is SlateProtocolError;
216
+ static fromResponse(error: unknown, source?: SlateProtocolErrorSource): SlateProtocolError;
217
+ static fromUnknown(error: unknown, defaults?: Partial<SlateProtocolErrorResponse>, source?: SlateProtocolErrorSource): SlateProtocolError;
218
+ }
219
+
220
+ declare let createLocalSlateTransport: <ConfigType extends {}, AuthType extends {}>(d: {
221
+ slate: Slate<ConfigType, AuthType>;
222
+ listeners?: SlateLogListener[];
223
+ }) => SlatesMessageTransport;
224
+
225
+ declare let createSlatesClient: (opts: SlatesProtocolClientOptions) => SlatesProtocolClient;
226
+
227
+ export { SlateProtocolError, type SlateProtocolErrorKind, type SlateProtocolErrorResponse, type SlateProtocolErrorSource, type SlatesClientState, type SlatesJsonObject, type SlatesMessageTransport, SlatesProtocolClient, type SlatesProtocolClientOptions, type SlatesProtocolMessage, type SlatesProtocolResponse, createLocalSlateTransport, createSlatesClient };