@caitlyn-ai/sdk 0.0.1 → 0.1.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.
Files changed (43) hide show
  1. package/README.md +39 -7
  2. package/dist-browser/sdk/index.mjs +59 -33
  3. package/dist-browser/sdk/index.mjs.map +3 -3
  4. package/dist-cjs/sdk/index.cjs +59 -32
  5. package/dist-cjs/sdk/index.cjs.map +3 -3
  6. package/dist-es/sdk/index.mjs +59 -33
  7. package/dist-es/sdk/index.mjs.map +3 -3
  8. package/dist-types/sdk/index.d.ts +5376 -8
  9. package/package.json +2 -3
  10. package/dist-types/Caitlyn.d.ts +0 -76
  11. package/dist-types/CaitlynClient.d.ts +0 -160
  12. package/dist-types/auth/httpAuthExtensionConfiguration.d.ts +0 -29
  13. package/dist-types/auth/httpAuthSchemeProvider.d.ts +0 -81
  14. package/dist-types/commandBuilder.d.ts +0 -18
  15. package/dist-types/commands/CreateDocumentCommand.d.ts +0 -190
  16. package/dist-types/commands/CreateUploadCommand.d.ts +0 -165
  17. package/dist-types/commands/GetAgentVersionCommand.d.ts +0 -177
  18. package/dist-types/commands/ListDocumentsCommand.d.ts +0 -176
  19. package/dist-types/commands/ResumeConversationStreamCommand.d.ts +0 -146
  20. package/dist-types/commands/SendMessageCommand.d.ts +0 -183
  21. package/dist-types/commands/UpdateDraftVersionCommand.d.ts +0 -202
  22. package/dist-types/commands/index.d.ts +0 -7
  23. package/dist-types/endpoint/EndpointParameters.d.ts +0 -32
  24. package/dist-types/endpoint/bdd.d.ts +0 -2
  25. package/dist-types/endpoint/endpointResolver.d.ts +0 -8
  26. package/dist-types/extensionConfiguration.d.ts +0 -8
  27. package/dist-types/index.d.ts +0 -22
  28. package/dist-types/models/CaitlynServiceException.d.ts +0 -15
  29. package/dist-types/models/enums.d.ts +0 -148
  30. package/dist-types/models/errors.d.ts +0 -659
  31. package/dist-types/models/models_0.d.ts +0 -754
  32. package/dist-types/pagination/Interfaces.d.ts +0 -8
  33. package/dist-types/pagination/ListDocumentsPaginator.d.ts +0 -7
  34. package/dist-types/pagination/index.d.ts +0 -2
  35. package/dist-types/runtimeConfig.browser.d.ts +0 -50
  36. package/dist-types/runtimeConfig.d.ts +0 -50
  37. package/dist-types/runtimeConfig.native.d.ts +0 -49
  38. package/dist-types/runtimeConfig.shared.d.ts +0 -36
  39. package/dist-types/runtimeExtensions.d.ts +0 -17
  40. package/dist-types/schemas/schemas_0.d.ts +0 -51
  41. package/dist-types/sdk/client.d.ts +0 -47
  42. package/dist-types/sdk/events.d.ts +0 -163
  43. package/dist-types/sdk/operations.d.ts +0 -70
@@ -78,19 +78,19 @@ import { TypeRegistry } from "@smithy/core/schema";
78
78
  import {
79
79
  ServiceException as __ServiceException
80
80
  } from "@smithy/core/client";
81
- var CaitlynServiceException = class _CaitlynServiceException extends __ServiceException {
81
+ var CaitlynServiceException = class extends __ServiceException {
82
82
  static shapeId = "smithy.ts.sdk.synthetic.ai.caitlyn.v3#CaitlynServiceException";
83
83
  /**
84
84
  * @internal
85
85
  */
86
86
  constructor(options) {
87
87
  super(options);
88
- Object.setPrototypeOf(this, _CaitlynServiceException.prototype);
88
+ Object.setPrototypeOf(this, new.target.prototype);
89
89
  }
90
90
  };
91
91
 
92
92
  // packages/sdk/src/models/errors.ts
93
- var InternalError = class _InternalError extends CaitlynServiceException {
93
+ var InternalError = class extends CaitlynServiceException {
94
94
  static shapeId = "ai.caitlyn.v3#InternalError";
95
95
  name = "InternalError";
96
96
  $fault = "server";
@@ -143,7 +143,7 @@ var InternalError = class _InternalError extends CaitlynServiceException {
143
143
  $fault: "server",
144
144
  ...opts
145
145
  });
146
- Object.setPrototypeOf(this, _InternalError.prototype);
146
+ Object.setPrototypeOf(this, new.target.prototype);
147
147
  this.type = opts.type;
148
148
  this.title = opts.title;
149
149
  this.status = opts.status;
@@ -153,7 +153,7 @@ var InternalError = class _InternalError extends CaitlynServiceException {
153
153
  this.errors = opts.errors;
154
154
  }
155
155
  };
156
- var NotFoundError = class _NotFoundError extends CaitlynServiceException {
156
+ var NotFoundError = class extends CaitlynServiceException {
157
157
  static shapeId = "ai.caitlyn.v3#NotFoundError";
158
158
  name = "NotFoundError";
159
159
  $fault = "client";
@@ -206,7 +206,7 @@ var NotFoundError = class _NotFoundError extends CaitlynServiceException {
206
206
  $fault: "client",
207
207
  ...opts
208
208
  });
209
- Object.setPrototypeOf(this, _NotFoundError.prototype);
209
+ Object.setPrototypeOf(this, new.target.prototype);
210
210
  this.type = opts.type;
211
211
  this.title = opts.title;
212
212
  this.status = opts.status;
@@ -216,7 +216,7 @@ var NotFoundError = class _NotFoundError extends CaitlynServiceException {
216
216
  this.errors = opts.errors;
217
217
  }
218
218
  };
219
- var PermissionDeniedError = class _PermissionDeniedError extends CaitlynServiceException {
219
+ var PermissionDeniedError = class extends CaitlynServiceException {
220
220
  static shapeId = "ai.caitlyn.v3#PermissionDeniedError";
221
221
  name = "PermissionDeniedError";
222
222
  $fault = "client";
@@ -269,7 +269,7 @@ var PermissionDeniedError = class _PermissionDeniedError extends CaitlynServiceE
269
269
  $fault: "client",
270
270
  ...opts
271
271
  });
272
- Object.setPrototypeOf(this, _PermissionDeniedError.prototype);
272
+ Object.setPrototypeOf(this, new.target.prototype);
273
273
  this.type = opts.type;
274
274
  this.title = opts.title;
275
275
  this.status = opts.status;
@@ -279,7 +279,7 @@ var PermissionDeniedError = class _PermissionDeniedError extends CaitlynServiceE
279
279
  this.errors = opts.errors;
280
280
  }
281
281
  };
282
- var PreconditionFailedError = class _PreconditionFailedError extends CaitlynServiceException {
282
+ var PreconditionFailedError = class extends CaitlynServiceException {
283
283
  static shapeId = "ai.caitlyn.v3#PreconditionFailedError";
284
284
  name = "PreconditionFailedError";
285
285
  $fault = "client";
@@ -332,7 +332,7 @@ var PreconditionFailedError = class _PreconditionFailedError extends CaitlynServ
332
332
  $fault: "client",
333
333
  ...opts
334
334
  });
335
- Object.setPrototypeOf(this, _PreconditionFailedError.prototype);
335
+ Object.setPrototypeOf(this, new.target.prototype);
336
336
  this.type = opts.type;
337
337
  this.title = opts.title;
338
338
  this.status = opts.status;
@@ -342,7 +342,7 @@ var PreconditionFailedError = class _PreconditionFailedError extends CaitlynServ
342
342
  this.errors = opts.errors;
343
343
  }
344
344
  };
345
- var PreconditionRequiredError = class _PreconditionRequiredError extends CaitlynServiceException {
345
+ var PreconditionRequiredError = class extends CaitlynServiceException {
346
346
  static shapeId = "ai.caitlyn.v3#PreconditionRequiredError";
347
347
  name = "PreconditionRequiredError";
348
348
  $fault = "client";
@@ -395,7 +395,7 @@ var PreconditionRequiredError = class _PreconditionRequiredError extends Caitlyn
395
395
  $fault: "client",
396
396
  ...opts
397
397
  });
398
- Object.setPrototypeOf(this, _PreconditionRequiredError.prototype);
398
+ Object.setPrototypeOf(this, new.target.prototype);
399
399
  this.type = opts.type;
400
400
  this.title = opts.title;
401
401
  this.status = opts.status;
@@ -405,7 +405,7 @@ var PreconditionRequiredError = class _PreconditionRequiredError extends Caitlyn
405
405
  this.errors = opts.errors;
406
406
  }
407
407
  };
408
- var ServiceUnavailableError = class _ServiceUnavailableError extends CaitlynServiceException {
408
+ var ServiceUnavailableError = class extends CaitlynServiceException {
409
409
  static shapeId = "ai.caitlyn.v3#ServiceUnavailableError";
410
410
  name = "ServiceUnavailableError";
411
411
  $fault = "server";
@@ -464,7 +464,7 @@ var ServiceUnavailableError = class _ServiceUnavailableError extends CaitlynServ
464
464
  $fault: "server",
465
465
  ...opts
466
466
  });
467
- Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
467
+ Object.setPrototypeOf(this, new.target.prototype);
468
468
  this.type = opts.type;
469
469
  this.title = opts.title;
470
470
  this.status = opts.status;
@@ -475,7 +475,7 @@ var ServiceUnavailableError = class _ServiceUnavailableError extends CaitlynServ
475
475
  this.retryAfterSeconds = opts.retryAfterSeconds;
476
476
  }
477
477
  };
478
- var TooManyRequestsError = class _TooManyRequestsError extends CaitlynServiceException {
478
+ var TooManyRequestsError = class extends CaitlynServiceException {
479
479
  static shapeId = "ai.caitlyn.v3#TooManyRequestsError";
480
480
  name = "TooManyRequestsError";
481
481
  $fault = "client";
@@ -536,7 +536,7 @@ var TooManyRequestsError = class _TooManyRequestsError extends CaitlynServiceExc
536
536
  $fault: "client",
537
537
  ...opts
538
538
  });
539
- Object.setPrototypeOf(this, _TooManyRequestsError.prototype);
539
+ Object.setPrototypeOf(this, new.target.prototype);
540
540
  this.type = opts.type;
541
541
  this.title = opts.title;
542
542
  this.status = opts.status;
@@ -547,7 +547,7 @@ var TooManyRequestsError = class _TooManyRequestsError extends CaitlynServiceExc
547
547
  this.retryAfterSeconds = opts.retryAfterSeconds;
548
548
  }
549
549
  };
550
- var UnauthenticatedError = class _UnauthenticatedError extends CaitlynServiceException {
550
+ var UnauthenticatedError = class extends CaitlynServiceException {
551
551
  static shapeId = "ai.caitlyn.v3#UnauthenticatedError";
552
552
  name = "UnauthenticatedError";
553
553
  $fault = "client";
@@ -600,7 +600,7 @@ var UnauthenticatedError = class _UnauthenticatedError extends CaitlynServiceExc
600
600
  $fault: "client",
601
601
  ...opts
602
602
  });
603
- Object.setPrototypeOf(this, _UnauthenticatedError.prototype);
603
+ Object.setPrototypeOf(this, new.target.prototype);
604
604
  this.type = opts.type;
605
605
  this.title = opts.title;
606
606
  this.status = opts.status;
@@ -610,7 +610,7 @@ var UnauthenticatedError = class _UnauthenticatedError extends CaitlynServiceExc
610
610
  this.errors = opts.errors;
611
611
  }
612
612
  };
613
- var ValidationError = class _ValidationError extends CaitlynServiceException {
613
+ var ValidationError = class extends CaitlynServiceException {
614
614
  static shapeId = "ai.caitlyn.v3#ValidationError";
615
615
  name = "ValidationError";
616
616
  $fault = "client";
@@ -663,7 +663,7 @@ var ValidationError = class _ValidationError extends CaitlynServiceException {
663
663
  $fault: "client",
664
664
  ...opts
665
665
  });
666
- Object.setPrototypeOf(this, _ValidationError.prototype);
666
+ Object.setPrototypeOf(this, new.target.prototype);
667
667
  this.type = opts.type;
668
668
  this.title = opts.title;
669
669
  this.status = opts.status;
@@ -673,7 +673,7 @@ var ValidationError = class _ValidationError extends CaitlynServiceException {
673
673
  this.errors = opts.errors;
674
674
  }
675
675
  };
676
- var ConflictError = class _ConflictError extends CaitlynServiceException {
676
+ var ConflictError = class extends CaitlynServiceException {
677
677
  static shapeId = "ai.caitlyn.v3#ConflictError";
678
678
  name = "ConflictError";
679
679
  $fault = "client";
@@ -726,7 +726,7 @@ var ConflictError = class _ConflictError extends CaitlynServiceException {
726
726
  $fault: "client",
727
727
  ...opts
728
728
  });
729
- Object.setPrototypeOf(this, _ConflictError.prototype);
729
+ Object.setPrototypeOf(this, new.target.prototype);
730
730
  this.type = opts.type;
731
731
  this.title = opts.title;
732
732
  this.status = opts.status;
@@ -736,7 +736,7 @@ var ConflictError = class _ConflictError extends CaitlynServiceException {
736
736
  this.errors = opts.errors;
737
737
  }
738
738
  };
739
- var PayloadTooLargeError = class _PayloadTooLargeError extends CaitlynServiceException {
739
+ var PayloadTooLargeError = class extends CaitlynServiceException {
740
740
  static shapeId = "ai.caitlyn.v3#PayloadTooLargeError";
741
741
  name = "PayloadTooLargeError";
742
742
  $fault = "client";
@@ -789,7 +789,7 @@ var PayloadTooLargeError = class _PayloadTooLargeError extends CaitlynServiceExc
789
789
  $fault: "client",
790
790
  ...opts
791
791
  });
792
- Object.setPrototypeOf(this, _PayloadTooLargeError.prototype);
792
+ Object.setPrototypeOf(this, new.target.prototype);
793
793
  this.type = opts.type;
794
794
  this.title = opts.title;
795
795
  this.status = opts.status;
@@ -799,7 +799,7 @@ var PayloadTooLargeError = class _PayloadTooLargeError extends CaitlynServiceExc
799
799
  this.errors = opts.errors;
800
800
  }
801
801
  };
802
- var UnprocessableContentError = class _UnprocessableContentError extends CaitlynServiceException {
802
+ var UnprocessableContentError = class extends CaitlynServiceException {
803
803
  static shapeId = "ai.caitlyn.v3#UnprocessableContentError";
804
804
  name = "UnprocessableContentError";
805
805
  $fault = "client";
@@ -852,7 +852,7 @@ var UnprocessableContentError = class _UnprocessableContentError extends Caitlyn
852
852
  $fault: "client",
853
853
  ...opts
854
854
  });
855
- Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
855
+ Object.setPrototypeOf(this, new.target.prototype);
856
856
  this.type = opts.type;
857
857
  this.title = opts.title;
858
858
  this.status = opts.status;
@@ -1440,7 +1440,7 @@ var getRuntimeConfig = (config) => {
1440
1440
  apiVersion: "3.0.0",
1441
1441
  base64Decoder: config?.base64Decoder ?? fromBase64,
1442
1442
  base64Encoder: config?.base64Encoder ?? toBase64,
1443
- caitlynSdkVersion: config?.caitlynSdkVersion ?? "0.0.1",
1443
+ caitlynSdkVersion: config?.caitlynSdkVersion ?? "0.1.0",
1444
1444
  disableHostPrefix: config?.disableHostPrefix ?? false,
1445
1445
  endpointProvider: config?.endpointProvider ?? caitlynEndpointProvider,
1446
1446
  extensions: config?.extensions ?? [],
@@ -1585,7 +1585,24 @@ var CaitlynClient = class extends __Client {
1585
1585
  };
1586
1586
 
1587
1587
  // packages/sdk/src/sdk/client.ts
1588
- import { clientConfig, createAuth, getCaitlynAuthPlugin, getCaitlynTelemetryPlugin } from "@caitlyn-ai/sdk-core";
1588
+ import { clientConfig, createAuth, getCaitlynAuthPlugin, getCaitlynConnectionErrorPlugin, getCaitlynTelemetryPlugin } from "@caitlyn-ai/sdk-core";
1589
+
1590
+ // packages/sdk/src/sdk/connection.ts
1591
+ var CaitlynConnectionError = class _CaitlynConnectionError extends CaitlynServiceException {
1592
+ status = 0;
1593
+ code = "CONNECTION_ERROR";
1594
+ title;
1595
+ requestId = void 0;
1596
+ rawBody = "";
1597
+ rawBodyTruncated = false;
1598
+ constructor(operation, cause) {
1599
+ const reason = cause instanceof Error ? cause.message : String(cause);
1600
+ super({ name: "CaitlynConnectionError", $fault: "client", $metadata: {}, message: `${operation}: no response: ${reason}` });
1601
+ Object.setPrototypeOf(this, _CaitlynConnectionError.prototype);
1602
+ this.title = `${operation}: no response`;
1603
+ this.cause = cause;
1604
+ }
1605
+ };
1589
1606
 
1590
1607
  // packages/sdk/src/sdk/operations.ts
1591
1608
  import { SseStream, uploadFile } from "@caitlyn-ai/sdk-core";
@@ -1689,7 +1706,7 @@ var toError = (problem) => {
1689
1706
  const fault = status >= 500 ? "server" : "client";
1690
1707
  const message = String(problem.detail ?? problem.title ?? problem.code);
1691
1708
  const Typed = ERROR_CLASSES[status];
1692
- const error = Typed ? new Typed({ $fault: fault, $metadata: {}, message }) : new CaitlynServiceException({ name: String(problem.code ?? "Error"), $fault: fault, $metadata: {}, message });
1709
+ const error = Typed ? new Typed({ $fault: fault, $metadata: {}, message }) : new CaitlynServiceException({ name: "CaitlynError", $fault: fault, $metadata: {}, message });
1693
1710
  return Object.assign(error, problem, { message });
1694
1711
  };
1695
1712
  function createDocument(client, input, options = {}) {
@@ -1717,7 +1734,7 @@ function resumeConversationStream(client, conversationId, input, options = {}) {
1717
1734
  const { signal, ...rest } = options;
1718
1735
  return new SseStream(
1719
1736
  { known: ConversationEventNames, final: { event: "message.completed", member: "message" }, errorEvent: "message.failed", toError },
1720
- async () => (await client.send(new ResumeConversationStreamCommand({ ...input, conversationId, ...rest }), { abortSignal: signal })).events,
1737
+ () => client.send(new ResumeConversationStreamCommand({ ...input, conversationId, ...rest }), { abortSignal: signal }),
1721
1738
  void 0,
1722
1739
  signal
1723
1740
  );
@@ -1726,8 +1743,8 @@ function sendMessage(client, conversationId, input, options = {}) {
1726
1743
  const { signal, ...rest } = options;
1727
1744
  return new SseStream(
1728
1745
  { known: ConversationEventNames, final: { event: "message.completed", member: "message" }, errorEvent: "message.failed", toError },
1729
- async () => (await client.send(new SendMessageCommand({ ...input, conversationId, ...rest }), { abortSignal: signal })).events,
1730
- async (lastEventId) => (await client.send(new ResumeConversationStreamCommand({ conversationId, lastEventId }), { abortSignal: signal })).events,
1746
+ () => client.send(new SendMessageCommand({ ...input, conversationId, ...rest }), { abortSignal: signal }),
1747
+ (lastEventId) => client.send(new ResumeConversationStreamCommand({ conversationId, lastEventId }), { abortSignal: signal }),
1731
1748
  signal
1732
1749
  );
1733
1750
  }
@@ -1737,7 +1754,14 @@ function updateDraftVersion(client, agentId, input, options) {
1737
1754
  }
1738
1755
  function createUploadFromFile(client, input, options = {}) {
1739
1756
  const { file, fileName, ...rest } = input;
1740
- return uploadFile(file, fileName, (meta) => createUpload(client, { ...rest, ...meta }, options), toError, options.signal);
1757
+ return uploadFile(
1758
+ file,
1759
+ fileName,
1760
+ (meta) => createUpload(client, { ...rest, ...meta }, options),
1761
+ toError,
1762
+ options.signal,
1763
+ client.config.caitlynTracer
1764
+ );
1741
1765
  }
1742
1766
  async function uploadDocument(client, input, options = {}) {
1743
1767
  const { file, fileName, ...rest } = input;
@@ -1750,6 +1774,7 @@ function createCaitlynClient(options, auth = createAuth(options)) {
1750
1774
  const client = new CaitlynClient(clientConfig(options, auth));
1751
1775
  client.middlewareStack.use(getCaitlynAuthPlugin(auth));
1752
1776
  if (options.telemetry?.enabled !== false) client.middlewareStack.use(getCaitlynTelemetryPlugin(options.telemetry?.tracerProvider));
1777
+ client.middlewareStack.use(getCaitlynConnectionErrorPlugin((operation, cause) => new CaitlynConnectionError(operation, cause)));
1753
1778
  return client;
1754
1779
  }
1755
1780
  var Caitlyn = class {
@@ -1886,6 +1911,7 @@ import { NotSupportedByServer, SseStream as SseStream2, CaitlynAuthError, Waiter
1886
1911
  export {
1887
1912
  Caitlyn,
1888
1913
  CaitlynAuthError,
1914
+ CaitlynConnectionError,
1889
1915
  CaitlynServiceException as CaitlynError,
1890
1916
  ClearableDraftField,
1891
1917
  ConflictError,