@caitlyn-ai/sdk 0.0.2 → 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
@@ -22,6 +22,7 @@ var sdk_exports = {};
22
22
  __export(sdk_exports, {
23
23
  Caitlyn: () => Caitlyn,
24
24
  CaitlynAuthError: () => import_sdk_core5.CaitlynAuthError,
25
+ CaitlynConnectionError: () => CaitlynConnectionError,
25
26
  CaitlynError: () => CaitlynServiceException,
26
27
  ClearableDraftField: () => ClearableDraftField,
27
28
  ConflictError: () => ConflictError,
@@ -126,19 +127,19 @@ var import_schema = require("@smithy/core/schema");
126
127
 
127
128
  // packages/sdk/src/models/CaitlynServiceException.ts
128
129
  var import_client2 = require("@smithy/core/client");
129
- var CaitlynServiceException = class _CaitlynServiceException extends import_client2.ServiceException {
130
+ var CaitlynServiceException = class extends import_client2.ServiceException {
130
131
  static shapeId = "smithy.ts.sdk.synthetic.ai.caitlyn.v3#CaitlynServiceException";
131
132
  /**
132
133
  * @internal
133
134
  */
134
135
  constructor(options) {
135
136
  super(options);
136
- Object.setPrototypeOf(this, _CaitlynServiceException.prototype);
137
+ Object.setPrototypeOf(this, new.target.prototype);
137
138
  }
138
139
  };
139
140
 
140
141
  // packages/sdk/src/models/errors.ts
141
- var InternalError = class _InternalError extends CaitlynServiceException {
142
+ var InternalError = class extends CaitlynServiceException {
142
143
  static shapeId = "ai.caitlyn.v3#InternalError";
143
144
  name = "InternalError";
144
145
  $fault = "server";
@@ -191,7 +192,7 @@ var InternalError = class _InternalError extends CaitlynServiceException {
191
192
  $fault: "server",
192
193
  ...opts
193
194
  });
194
- Object.setPrototypeOf(this, _InternalError.prototype);
195
+ Object.setPrototypeOf(this, new.target.prototype);
195
196
  this.type = opts.type;
196
197
  this.title = opts.title;
197
198
  this.status = opts.status;
@@ -201,7 +202,7 @@ var InternalError = class _InternalError extends CaitlynServiceException {
201
202
  this.errors = opts.errors;
202
203
  }
203
204
  };
204
- var NotFoundError = class _NotFoundError extends CaitlynServiceException {
205
+ var NotFoundError = class extends CaitlynServiceException {
205
206
  static shapeId = "ai.caitlyn.v3#NotFoundError";
206
207
  name = "NotFoundError";
207
208
  $fault = "client";
@@ -254,7 +255,7 @@ var NotFoundError = class _NotFoundError extends CaitlynServiceException {
254
255
  $fault: "client",
255
256
  ...opts
256
257
  });
257
- Object.setPrototypeOf(this, _NotFoundError.prototype);
258
+ Object.setPrototypeOf(this, new.target.prototype);
258
259
  this.type = opts.type;
259
260
  this.title = opts.title;
260
261
  this.status = opts.status;
@@ -264,7 +265,7 @@ var NotFoundError = class _NotFoundError extends CaitlynServiceException {
264
265
  this.errors = opts.errors;
265
266
  }
266
267
  };
267
- var PermissionDeniedError = class _PermissionDeniedError extends CaitlynServiceException {
268
+ var PermissionDeniedError = class extends CaitlynServiceException {
268
269
  static shapeId = "ai.caitlyn.v3#PermissionDeniedError";
269
270
  name = "PermissionDeniedError";
270
271
  $fault = "client";
@@ -317,7 +318,7 @@ var PermissionDeniedError = class _PermissionDeniedError extends CaitlynServiceE
317
318
  $fault: "client",
318
319
  ...opts
319
320
  });
320
- Object.setPrototypeOf(this, _PermissionDeniedError.prototype);
321
+ Object.setPrototypeOf(this, new.target.prototype);
321
322
  this.type = opts.type;
322
323
  this.title = opts.title;
323
324
  this.status = opts.status;
@@ -327,7 +328,7 @@ var PermissionDeniedError = class _PermissionDeniedError extends CaitlynServiceE
327
328
  this.errors = opts.errors;
328
329
  }
329
330
  };
330
- var PreconditionFailedError = class _PreconditionFailedError extends CaitlynServiceException {
331
+ var PreconditionFailedError = class extends CaitlynServiceException {
331
332
  static shapeId = "ai.caitlyn.v3#PreconditionFailedError";
332
333
  name = "PreconditionFailedError";
333
334
  $fault = "client";
@@ -380,7 +381,7 @@ var PreconditionFailedError = class _PreconditionFailedError extends CaitlynServ
380
381
  $fault: "client",
381
382
  ...opts
382
383
  });
383
- Object.setPrototypeOf(this, _PreconditionFailedError.prototype);
384
+ Object.setPrototypeOf(this, new.target.prototype);
384
385
  this.type = opts.type;
385
386
  this.title = opts.title;
386
387
  this.status = opts.status;
@@ -390,7 +391,7 @@ var PreconditionFailedError = class _PreconditionFailedError extends CaitlynServ
390
391
  this.errors = opts.errors;
391
392
  }
392
393
  };
393
- var PreconditionRequiredError = class _PreconditionRequiredError extends CaitlynServiceException {
394
+ var PreconditionRequiredError = class extends CaitlynServiceException {
394
395
  static shapeId = "ai.caitlyn.v3#PreconditionRequiredError";
395
396
  name = "PreconditionRequiredError";
396
397
  $fault = "client";
@@ -443,7 +444,7 @@ var PreconditionRequiredError = class _PreconditionRequiredError extends Caitlyn
443
444
  $fault: "client",
444
445
  ...opts
445
446
  });
446
- Object.setPrototypeOf(this, _PreconditionRequiredError.prototype);
447
+ Object.setPrototypeOf(this, new.target.prototype);
447
448
  this.type = opts.type;
448
449
  this.title = opts.title;
449
450
  this.status = opts.status;
@@ -453,7 +454,7 @@ var PreconditionRequiredError = class _PreconditionRequiredError extends Caitlyn
453
454
  this.errors = opts.errors;
454
455
  }
455
456
  };
456
- var ServiceUnavailableError = class _ServiceUnavailableError extends CaitlynServiceException {
457
+ var ServiceUnavailableError = class extends CaitlynServiceException {
457
458
  static shapeId = "ai.caitlyn.v3#ServiceUnavailableError";
458
459
  name = "ServiceUnavailableError";
459
460
  $fault = "server";
@@ -512,7 +513,7 @@ var ServiceUnavailableError = class _ServiceUnavailableError extends CaitlynServ
512
513
  $fault: "server",
513
514
  ...opts
514
515
  });
515
- Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
516
+ Object.setPrototypeOf(this, new.target.prototype);
516
517
  this.type = opts.type;
517
518
  this.title = opts.title;
518
519
  this.status = opts.status;
@@ -523,7 +524,7 @@ var ServiceUnavailableError = class _ServiceUnavailableError extends CaitlynServ
523
524
  this.retryAfterSeconds = opts.retryAfterSeconds;
524
525
  }
525
526
  };
526
- var TooManyRequestsError = class _TooManyRequestsError extends CaitlynServiceException {
527
+ var TooManyRequestsError = class extends CaitlynServiceException {
527
528
  static shapeId = "ai.caitlyn.v3#TooManyRequestsError";
528
529
  name = "TooManyRequestsError";
529
530
  $fault = "client";
@@ -584,7 +585,7 @@ var TooManyRequestsError = class _TooManyRequestsError extends CaitlynServiceExc
584
585
  $fault: "client",
585
586
  ...opts
586
587
  });
587
- Object.setPrototypeOf(this, _TooManyRequestsError.prototype);
588
+ Object.setPrototypeOf(this, new.target.prototype);
588
589
  this.type = opts.type;
589
590
  this.title = opts.title;
590
591
  this.status = opts.status;
@@ -595,7 +596,7 @@ var TooManyRequestsError = class _TooManyRequestsError extends CaitlynServiceExc
595
596
  this.retryAfterSeconds = opts.retryAfterSeconds;
596
597
  }
597
598
  };
598
- var UnauthenticatedError = class _UnauthenticatedError extends CaitlynServiceException {
599
+ var UnauthenticatedError = class extends CaitlynServiceException {
599
600
  static shapeId = "ai.caitlyn.v3#UnauthenticatedError";
600
601
  name = "UnauthenticatedError";
601
602
  $fault = "client";
@@ -648,7 +649,7 @@ var UnauthenticatedError = class _UnauthenticatedError extends CaitlynServiceExc
648
649
  $fault: "client",
649
650
  ...opts
650
651
  });
651
- Object.setPrototypeOf(this, _UnauthenticatedError.prototype);
652
+ Object.setPrototypeOf(this, new.target.prototype);
652
653
  this.type = opts.type;
653
654
  this.title = opts.title;
654
655
  this.status = opts.status;
@@ -658,7 +659,7 @@ var UnauthenticatedError = class _UnauthenticatedError extends CaitlynServiceExc
658
659
  this.errors = opts.errors;
659
660
  }
660
661
  };
661
- var ValidationError = class _ValidationError extends CaitlynServiceException {
662
+ var ValidationError = class extends CaitlynServiceException {
662
663
  static shapeId = "ai.caitlyn.v3#ValidationError";
663
664
  name = "ValidationError";
664
665
  $fault = "client";
@@ -711,7 +712,7 @@ var ValidationError = class _ValidationError extends CaitlynServiceException {
711
712
  $fault: "client",
712
713
  ...opts
713
714
  });
714
- Object.setPrototypeOf(this, _ValidationError.prototype);
715
+ Object.setPrototypeOf(this, new.target.prototype);
715
716
  this.type = opts.type;
716
717
  this.title = opts.title;
717
718
  this.status = opts.status;
@@ -721,7 +722,7 @@ var ValidationError = class _ValidationError extends CaitlynServiceException {
721
722
  this.errors = opts.errors;
722
723
  }
723
724
  };
724
- var ConflictError = class _ConflictError extends CaitlynServiceException {
725
+ var ConflictError = class extends CaitlynServiceException {
725
726
  static shapeId = "ai.caitlyn.v3#ConflictError";
726
727
  name = "ConflictError";
727
728
  $fault = "client";
@@ -774,7 +775,7 @@ var ConflictError = class _ConflictError extends CaitlynServiceException {
774
775
  $fault: "client",
775
776
  ...opts
776
777
  });
777
- Object.setPrototypeOf(this, _ConflictError.prototype);
778
+ Object.setPrototypeOf(this, new.target.prototype);
778
779
  this.type = opts.type;
779
780
  this.title = opts.title;
780
781
  this.status = opts.status;
@@ -784,7 +785,7 @@ var ConflictError = class _ConflictError extends CaitlynServiceException {
784
785
  this.errors = opts.errors;
785
786
  }
786
787
  };
787
- var PayloadTooLargeError = class _PayloadTooLargeError extends CaitlynServiceException {
788
+ var PayloadTooLargeError = class extends CaitlynServiceException {
788
789
  static shapeId = "ai.caitlyn.v3#PayloadTooLargeError";
789
790
  name = "PayloadTooLargeError";
790
791
  $fault = "client";
@@ -837,7 +838,7 @@ var PayloadTooLargeError = class _PayloadTooLargeError extends CaitlynServiceExc
837
838
  $fault: "client",
838
839
  ...opts
839
840
  });
840
- Object.setPrototypeOf(this, _PayloadTooLargeError.prototype);
841
+ Object.setPrototypeOf(this, new.target.prototype);
841
842
  this.type = opts.type;
842
843
  this.title = opts.title;
843
844
  this.status = opts.status;
@@ -847,7 +848,7 @@ var PayloadTooLargeError = class _PayloadTooLargeError extends CaitlynServiceExc
847
848
  this.errors = opts.errors;
848
849
  }
849
850
  };
850
- var UnprocessableContentError = class _UnprocessableContentError extends CaitlynServiceException {
851
+ var UnprocessableContentError = class extends CaitlynServiceException {
851
852
  static shapeId = "ai.caitlyn.v3#UnprocessableContentError";
852
853
  name = "UnprocessableContentError";
853
854
  $fault = "client";
@@ -900,7 +901,7 @@ var UnprocessableContentError = class _UnprocessableContentError extends Caitlyn
900
901
  $fault: "client",
901
902
  ...opts
902
903
  });
903
- Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
904
+ Object.setPrototypeOf(this, new.target.prototype);
904
905
  this.type = opts.type;
905
906
  this.title = opts.title;
906
907
  this.status = opts.status;
@@ -1488,7 +1489,7 @@ var getRuntimeConfig = (config) => {
1488
1489
  apiVersion: "3.0.0",
1489
1490
  base64Decoder: config?.base64Decoder ?? import_serde.fromBase64,
1490
1491
  base64Encoder: config?.base64Encoder ?? import_serde.toBase64,
1491
- caitlynSdkVersion: config?.caitlynSdkVersion ?? "0.0.2",
1492
+ caitlynSdkVersion: config?.caitlynSdkVersion ?? "0.1.0",
1492
1493
  disableHostPrefix: config?.disableHostPrefix ?? false,
1493
1494
  endpointProvider: config?.endpointProvider ?? import_sdk_core.caitlynEndpointProvider,
1494
1495
  extensions: config?.extensions ?? [],
@@ -1635,6 +1636,23 @@ var CaitlynClient = class extends import_client6.Client {
1635
1636
  // packages/sdk/src/sdk/client.ts
1636
1637
  var import_sdk_core4 = require("@caitlyn-ai/sdk-core");
1637
1638
 
1639
+ // packages/sdk/src/sdk/connection.ts
1640
+ var CaitlynConnectionError = class _CaitlynConnectionError extends CaitlynServiceException {
1641
+ status = 0;
1642
+ code = "CONNECTION_ERROR";
1643
+ title;
1644
+ requestId = void 0;
1645
+ rawBody = "";
1646
+ rawBodyTruncated = false;
1647
+ constructor(operation, cause) {
1648
+ const reason = cause instanceof Error ? cause.message : String(cause);
1649
+ super({ name: "CaitlynConnectionError", $fault: "client", $metadata: {}, message: `${operation}: no response: ${reason}` });
1650
+ Object.setPrototypeOf(this, _CaitlynConnectionError.prototype);
1651
+ this.title = `${operation}: no response`;
1652
+ this.cause = cause;
1653
+ }
1654
+ };
1655
+
1638
1656
  // packages/sdk/src/sdk/operations.ts
1639
1657
  var import_sdk_core3 = require("@caitlyn-ai/sdk-core");
1640
1658
 
@@ -1737,7 +1755,7 @@ var toError = (problem) => {
1737
1755
  const fault = status >= 500 ? "server" : "client";
1738
1756
  const message = String(problem.detail ?? problem.title ?? problem.code);
1739
1757
  const Typed = ERROR_CLASSES[status];
1740
- const error = Typed ? new Typed({ $fault: fault, $metadata: {}, message }) : new CaitlynServiceException({ name: String(problem.code ?? "Error"), $fault: fault, $metadata: {}, message });
1758
+ const error = Typed ? new Typed({ $fault: fault, $metadata: {}, message }) : new CaitlynServiceException({ name: "CaitlynError", $fault: fault, $metadata: {}, message });
1741
1759
  return Object.assign(error, problem, { message });
1742
1760
  };
1743
1761
  function createDocument(client, input, options = {}) {
@@ -1765,7 +1783,7 @@ function resumeConversationStream(client, conversationId, input, options = {}) {
1765
1783
  const { signal, ...rest } = options;
1766
1784
  return new import_sdk_core3.SseStream(
1767
1785
  { known: ConversationEventNames, final: { event: "message.completed", member: "message" }, errorEvent: "message.failed", toError },
1768
- async () => (await client.send(new ResumeConversationStreamCommand({ ...input, conversationId, ...rest }), { abortSignal: signal })).events,
1786
+ () => client.send(new ResumeConversationStreamCommand({ ...input, conversationId, ...rest }), { abortSignal: signal }),
1769
1787
  void 0,
1770
1788
  signal
1771
1789
  );
@@ -1774,8 +1792,8 @@ function sendMessage(client, conversationId, input, options = {}) {
1774
1792
  const { signal, ...rest } = options;
1775
1793
  return new import_sdk_core3.SseStream(
1776
1794
  { known: ConversationEventNames, final: { event: "message.completed", member: "message" }, errorEvent: "message.failed", toError },
1777
- async () => (await client.send(new SendMessageCommand({ ...input, conversationId, ...rest }), { abortSignal: signal })).events,
1778
- async (lastEventId) => (await client.send(new ResumeConversationStreamCommand({ conversationId, lastEventId }), { abortSignal: signal })).events,
1795
+ () => client.send(new SendMessageCommand({ ...input, conversationId, ...rest }), { abortSignal: signal }),
1796
+ (lastEventId) => client.send(new ResumeConversationStreamCommand({ conversationId, lastEventId }), { abortSignal: signal }),
1779
1797
  signal
1780
1798
  );
1781
1799
  }
@@ -1785,7 +1803,14 @@ function updateDraftVersion(client, agentId, input, options) {
1785
1803
  }
1786
1804
  function createUploadFromFile(client, input, options = {}) {
1787
1805
  const { file, fileName, ...rest } = input;
1788
- return (0, import_sdk_core3.uploadFile)(file, fileName, (meta) => createUpload(client, { ...rest, ...meta }, options), toError, options.signal);
1806
+ return (0, import_sdk_core3.uploadFile)(
1807
+ file,
1808
+ fileName,
1809
+ (meta) => createUpload(client, { ...rest, ...meta }, options),
1810
+ toError,
1811
+ options.signal,
1812
+ client.config.caitlynTracer
1813
+ );
1789
1814
  }
1790
1815
  async function uploadDocument(client, input, options = {}) {
1791
1816
  const { file, fileName, ...rest } = input;
@@ -1798,6 +1823,7 @@ function createCaitlynClient(options, auth = (0, import_sdk_core4.createAuth)(op
1798
1823
  const client = new CaitlynClient((0, import_sdk_core4.clientConfig)(options, auth));
1799
1824
  client.middlewareStack.use((0, import_sdk_core4.getCaitlynAuthPlugin)(auth));
1800
1825
  if (options.telemetry?.enabled !== false) client.middlewareStack.use((0, import_sdk_core4.getCaitlynTelemetryPlugin)(options.telemetry?.tracerProvider));
1826
+ client.middlewareStack.use((0, import_sdk_core4.getCaitlynConnectionErrorPlugin)((operation, cause) => new CaitlynConnectionError(operation, cause)));
1801
1827
  return client;
1802
1828
  }
1803
1829
  var Caitlyn = class {
@@ -1935,6 +1961,7 @@ var import_sdk_core5 = require("@caitlyn-ai/sdk-core");
1935
1961
  0 && (module.exports = {
1936
1962
  Caitlyn,
1937
1963
  CaitlynAuthError,
1964
+ CaitlynConnectionError,
1938
1965
  CaitlynError,
1939
1966
  ClearableDraftField,
1940
1967
  ConflictError,