@chrt-inc/typescript-sdk 1.1025.0 → 1.1026.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 (131) hide show
  1. package/README.md +12 -9
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/resources/chrtGpt/client/Client.d.ts +6 -13
  4. package/dist/cjs/api/resources/chrtGpt/client/Client.js +24 -17
  5. package/dist/cjs/api/resources/chrtGpt/client/requests/{ChrtGptMessageReq.d.ts → ChrtGptReq.d.ts} +1 -1
  6. package/dist/cjs/api/resources/chrtGpt/client/requests/index.d.ts +1 -1
  7. package/dist/cjs/api/resources/chrtGpt/index.d.ts +1 -0
  8. package/dist/cjs/api/resources/chrtGpt/index.js +1 -0
  9. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/Client.d.ts +65 -0
  10. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/Client.js +205 -0
  11. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/index.d.ts +2 -0
  12. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/index.js +17 -0
  13. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/requests/ConversationsListV1Request.d.ts +21 -0
  14. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/requests/index.d.ts +1 -0
  15. package/dist/cjs/api/resources/chrtGpt/resources/conversations/client/requests/index.js +2 -0
  16. package/dist/cjs/api/resources/chrtGpt/resources/conversations/index.d.ts +1 -0
  17. package/dist/cjs/api/resources/chrtGpt/resources/conversations/index.js +17 -0
  18. package/dist/cjs/api/resources/chrtGpt/resources/index.d.ts +2 -0
  19. package/dist/cjs/api/resources/chrtGpt/resources/index.js +41 -0
  20. package/dist/cjs/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.d.ts +1 -0
  21. package/dist/cjs/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.js +1 -0
  22. package/dist/cjs/api/types/ChrtGptAssistantMessageItem.d.ts +8 -0
  23. package/dist/cjs/api/types/ChrtGptAssistantMessageItem.js +5 -0
  24. package/dist/cjs/api/types/ChrtGptCompletedEvent.d.ts +11 -0
  25. package/dist/cjs/api/types/ChrtGptCompletedEvent.js +5 -0
  26. package/dist/cjs/api/types/ChrtGptConversation1.d.ts +14 -0
  27. package/dist/cjs/api/types/ChrtGptConversation1.js +5 -0
  28. package/dist/cjs/api/types/ChrtGptConversationListRes.d.ts +8 -0
  29. package/dist/cjs/api/types/ChrtGptConversationListRes.js +5 -0
  30. package/dist/cjs/api/types/ChrtGptConversationRes.d.ts +9 -0
  31. package/dist/cjs/api/types/ChrtGptConversationRes.js +5 -0
  32. package/dist/cjs/api/types/ChrtGptConversationSortByEnum.d.ts +8 -0
  33. package/dist/cjs/api/types/ChrtGptConversationSortByEnum.js +10 -0
  34. package/dist/cjs/api/types/ChrtGptErrorEvent.d.ts +9 -0
  35. package/dist/cjs/api/types/ChrtGptErrorEvent.js +5 -0
  36. package/dist/cjs/api/types/ChrtGptEvent.d.ts +31 -0
  37. package/dist/cjs/api/types/ChrtGptEvent.js +5 -0
  38. package/dist/cjs/api/types/ChrtGptHistoryItem.d.ts +22 -0
  39. package/dist/cjs/api/types/ChrtGptHistoryItem.js +5 -0
  40. package/dist/{esm/api/types/ChrtGptMessageRes.d.mts → cjs/api/types/ChrtGptStartedEvent.d.ts} +4 -2
  41. package/dist/cjs/api/types/ChrtGptStartedEvent.js +5 -0
  42. package/dist/cjs/api/types/ChrtGptTextDeltaEvent.d.ts +8 -0
  43. package/dist/cjs/api/types/ChrtGptTextDeltaEvent.js +5 -0
  44. package/dist/cjs/api/types/ChrtGptTitleEvent.d.ts +11 -0
  45. package/dist/cjs/api/types/ChrtGptTitleEvent.js +5 -0
  46. package/dist/cjs/api/types/ChrtGptToolCalledEvent.d.ts +12 -0
  47. package/dist/cjs/api/types/ChrtGptToolCalledEvent.js +5 -0
  48. package/dist/cjs/api/types/ChrtGptToolOutputEvent.d.ts +9 -0
  49. package/dist/cjs/api/types/ChrtGptToolOutputEvent.js +5 -0
  50. package/dist/cjs/api/types/ChrtGptUserMessageItem.d.ts +6 -0
  51. package/dist/cjs/api/types/ChrtGptUserMessageItem.js +5 -0
  52. package/dist/cjs/api/types/ChrtGptWebSearchEvent.d.ts +18 -0
  53. package/dist/cjs/api/types/ChrtGptWebSearchEvent.js +5 -0
  54. package/dist/cjs/api/types/index.d.ts +16 -1
  55. package/dist/cjs/api/types/index.js +16 -1
  56. package/dist/cjs/core/index.d.ts +1 -0
  57. package/dist/cjs/core/index.js +1 -0
  58. package/dist/cjs/core/stream/Stream.d.ts +46 -0
  59. package/dist/cjs/core/stream/Stream.js +169 -0
  60. package/dist/cjs/core/stream/index.d.ts +1 -0
  61. package/dist/cjs/core/stream/index.js +5 -0
  62. package/dist/cjs/version.d.ts +1 -1
  63. package/dist/cjs/version.js +1 -1
  64. package/dist/esm/Client.mjs +2 -2
  65. package/dist/esm/api/resources/chrtGpt/client/Client.d.mts +6 -13
  66. package/dist/esm/api/resources/chrtGpt/client/Client.mjs +24 -17
  67. package/dist/esm/api/resources/chrtGpt/client/requests/{ChrtGptMessageReq.d.mts → ChrtGptReq.d.mts} +1 -1
  68. package/dist/esm/api/resources/chrtGpt/client/requests/index.d.mts +1 -1
  69. package/dist/esm/api/resources/chrtGpt/index.d.mts +1 -0
  70. package/dist/esm/api/resources/chrtGpt/index.mjs +1 -0
  71. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/Client.d.mts +65 -0
  72. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/Client.mjs +168 -0
  73. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/index.d.mts +2 -0
  74. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/index.mjs +1 -0
  75. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/requests/ConversationsListV1Request.d.mts +21 -0
  76. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/requests/index.d.mts +1 -0
  77. package/dist/esm/api/resources/chrtGpt/resources/conversations/client/requests/index.mjs +1 -0
  78. package/dist/esm/api/resources/chrtGpt/resources/conversations/index.d.mts +1 -0
  79. package/dist/esm/api/resources/chrtGpt/resources/conversations/index.mjs +1 -0
  80. package/dist/esm/api/resources/chrtGpt/resources/index.d.mts +2 -0
  81. package/dist/esm/api/resources/chrtGpt/resources/index.mjs +2 -0
  82. package/dist/esm/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.d.mts +1 -0
  83. package/dist/esm/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.mjs +1 -0
  84. package/dist/esm/api/types/ChrtGptAssistantMessageItem.d.mts +8 -0
  85. package/dist/esm/api/types/ChrtGptAssistantMessageItem.mjs +4 -0
  86. package/dist/esm/api/types/ChrtGptCompletedEvent.d.mts +11 -0
  87. package/dist/esm/api/types/ChrtGptCompletedEvent.mjs +4 -0
  88. package/dist/esm/api/types/ChrtGptConversation1.d.mts +14 -0
  89. package/dist/esm/api/types/ChrtGptConversation1.mjs +4 -0
  90. package/dist/esm/api/types/ChrtGptConversationListRes.d.mts +8 -0
  91. package/dist/esm/api/types/ChrtGptConversationListRes.mjs +4 -0
  92. package/dist/esm/api/types/ChrtGptConversationRes.d.mts +9 -0
  93. package/dist/esm/api/types/ChrtGptConversationRes.mjs +4 -0
  94. package/dist/esm/api/types/ChrtGptConversationSortByEnum.d.mts +8 -0
  95. package/dist/esm/api/types/ChrtGptConversationSortByEnum.mjs +7 -0
  96. package/dist/esm/api/types/ChrtGptErrorEvent.d.mts +9 -0
  97. package/dist/esm/api/types/ChrtGptErrorEvent.mjs +4 -0
  98. package/dist/esm/api/types/ChrtGptEvent.d.mts +31 -0
  99. package/dist/esm/api/types/ChrtGptEvent.mjs +4 -0
  100. package/dist/esm/api/types/ChrtGptHistoryItem.d.mts +22 -0
  101. package/dist/esm/api/types/ChrtGptHistoryItem.mjs +4 -0
  102. package/dist/{cjs/api/types/ChrtGptMessageRes.d.ts → esm/api/types/ChrtGptStartedEvent.d.mts} +4 -2
  103. package/dist/esm/api/types/ChrtGptStartedEvent.mjs +4 -0
  104. package/dist/esm/api/types/ChrtGptTextDeltaEvent.d.mts +8 -0
  105. package/dist/esm/api/types/ChrtGptTextDeltaEvent.mjs +4 -0
  106. package/dist/esm/api/types/ChrtGptTitleEvent.d.mts +11 -0
  107. package/dist/esm/api/types/ChrtGptTitleEvent.mjs +4 -0
  108. package/dist/esm/api/types/ChrtGptToolCalledEvent.d.mts +12 -0
  109. package/dist/esm/api/types/ChrtGptToolCalledEvent.mjs +4 -0
  110. package/dist/esm/api/types/ChrtGptToolOutputEvent.d.mts +9 -0
  111. package/dist/esm/api/types/ChrtGptToolOutputEvent.mjs +4 -0
  112. package/dist/esm/api/types/ChrtGptUserMessageItem.d.mts +6 -0
  113. package/dist/esm/api/types/ChrtGptUserMessageItem.mjs +4 -0
  114. package/dist/esm/api/types/ChrtGptWebSearchEvent.d.mts +18 -0
  115. package/dist/esm/api/types/ChrtGptWebSearchEvent.mjs +4 -0
  116. package/dist/esm/api/types/index.d.mts +16 -1
  117. package/dist/esm/api/types/index.mjs +16 -1
  118. package/dist/esm/core/index.d.mts +1 -0
  119. package/dist/esm/core/index.mjs +1 -0
  120. package/dist/esm/core/stream/Stream.d.mts +46 -0
  121. package/dist/esm/core/stream/Stream.mjs +164 -0
  122. package/dist/esm/core/stream/index.d.mts +1 -0
  123. package/dist/esm/core/stream/index.mjs +1 -0
  124. package/dist/esm/version.d.mts +1 -1
  125. package/dist/esm/version.mjs +1 -1
  126. package/package.json +1 -1
  127. package/reference.md +141 -4
  128. /package/dist/cjs/api/resources/chrtGpt/client/requests/{ChrtGptMessageReq.js → ChrtGptReq.js} +0 -0
  129. /package/dist/cjs/api/{types/ChrtGptMessageRes.js → resources/chrtGpt/resources/conversations/client/requests/ConversationsListV1Request.js} +0 -0
  130. /package/dist/esm/api/resources/chrtGpt/client/requests/{ChrtGptMessageReq.mjs → ChrtGptReq.mjs} +0 -0
  131. /package/dist/esm/api/{types/ChrtGptMessageRes.mjs → resources/chrtGpt/resources/conversations/client/requests/ConversationsListV1Request.mjs} +0 -0
@@ -26,8 +26,8 @@ export class ChrtClient {
26
26
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
27
27
  "X-Fern-Language": "JavaScript",
28
28
  "X-Fern-SDK-Name": "@chrt-inc/typescript-sdk",
29
- "X-Fern-SDK-Version": "1.1025.0",
30
- "User-Agent": "@chrt-inc/typescript-sdk/1.1025.0",
29
+ "X-Fern-SDK-Version": "1.1026.0",
30
+ "User-Agent": "@chrt-inc/typescript-sdk/1.1026.0",
31
31
  "X-Fern-Runtime": core.RUNTIME.type,
32
32
  "X-Fern-Runtime-Version": core.RUNTIME.version,
33
33
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -4,6 +4,7 @@
4
4
  import * as environments from "../../../../environments.mjs";
5
5
  import * as core from "../../../../core/index.mjs";
6
6
  import * as Chrt from "../../../index.mjs";
7
+ import { Conversations } from "../resources/conversations/client/Client.mjs";
7
8
  export declare namespace ChrtGpt {
8
9
  interface Options {
9
10
  environment?: core.Supplier<environments.ChrtEnvironment | string>;
@@ -29,21 +30,13 @@ export declare namespace ChrtGpt {
29
30
  }
30
31
  export declare class ChrtGpt {
31
32
  protected readonly _options: ChrtGpt.Options;
33
+ protected _conversations: Conversations | undefined;
32
34
  constructor(_options?: ChrtGpt.Options);
35
+ get conversations(): Conversations;
33
36
  /**
34
- * Sends a message to ChrtGPT and returns its reply, starting a new conversation when no conversation_id is given. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | (ChrtGPTMessageReq) -> (ChrtGPTMessageRes)
35
- *
36
- * @param {Chrt.ChrtGptMessageReq} request
37
- * @param {ChrtGpt.RequestOptions} requestOptions - Request-specific configuration.
38
- *
39
- * @throws {@link Chrt.UnprocessableEntityError}
40
- *
41
- * @example
42
- * await client.chrtGpt.messageV1({
43
- * message: "message"
44
- * })
37
+ * Sends a message to ChrtGPT and streams its reply, starting and titling a new conversation when no conversation_id is given. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | (ChrtGPTReq) -> (stream[ChrtGPTEvent])
45
38
  */
46
- messageV1(request: Chrt.ChrtGptMessageReq, requestOptions?: ChrtGpt.RequestOptions): core.HttpResponsePromise<Chrt.ChrtGptMessageRes>;
47
- private __messageV1;
39
+ postV1(request: Chrt.ChrtGptReq, requestOptions?: ChrtGpt.RequestOptions): core.HttpResponsePromise<core.Stream<Chrt.ChrtGptEvent>>;
40
+ private __postV1;
48
41
  protected _getAuthorizationHeader(): Promise<string | undefined>;
49
42
  }
@@ -15,44 +15,51 @@ import * as core from "../../../../core/index.mjs";
15
15
  import * as Chrt from "../../../index.mjs";
16
16
  import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
17
17
  import * as errors from "../../../../errors/index.mjs";
18
+ import { Conversations } from "../resources/conversations/client/Client.mjs";
18
19
  export class ChrtGpt {
19
20
  constructor(_options = {}) {
20
21
  this._options = _options;
21
22
  }
23
+ get conversations() {
24
+ var _a;
25
+ return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new Conversations(this._options)));
26
+ }
22
27
  /**
23
- * Sends a message to ChrtGPT and returns its reply, starting a new conversation when no conversation_id is given. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | (ChrtGPTMessageReq) -> (ChrtGPTMessageRes)
24
- *
25
- * @param {Chrt.ChrtGptMessageReq} request
26
- * @param {ChrtGpt.RequestOptions} requestOptions - Request-specific configuration.
27
- *
28
- * @throws {@link Chrt.UnprocessableEntityError}
29
- *
30
- * @example
31
- * await client.chrtGpt.messageV1({
32
- * message: "message"
33
- * })
28
+ * Sends a message to ChrtGPT and streams its reply, starting and titling a new conversation when no conversation_id is given. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | (ChrtGPTReq) -> (stream[ChrtGPTEvent])
34
29
  */
35
- messageV1(request, requestOptions) {
36
- return core.HttpResponsePromise.fromPromise(this.__messageV1(request, requestOptions));
30
+ postV1(request, requestOptions) {
31
+ return core.HttpResponsePromise.fromPromise(this.__postV1(request, requestOptions));
37
32
  }
38
- __messageV1(request, requestOptions) {
33
+ __postV1(request, requestOptions) {
39
34
  return __awaiter(this, void 0, void 0, function* () {
40
35
  var _a, _b, _c, _d;
41
36
  let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
42
37
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
43
- url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ChrtEnvironment.Local, "chrt_gpt/message/v1"),
38
+ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ChrtEnvironment.Local, "chrt_gpt/v1"),
44
39
  method: "POST",
45
40
  headers: _headers,
46
41
  contentType: "application/json",
47
42
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
48
43
  requestType: "json",
49
44
  body: request,
45
+ responseType: "sse",
50
46
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
51
47
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
52
48
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
53
49
  });
54
50
  if (_response.ok) {
55
- return { data: _response.body, rawResponse: _response.rawResponse };
51
+ return {
52
+ data: new core.Stream({
53
+ stream: _response.body,
54
+ parse: (data) => data,
55
+ signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
56
+ eventShape: {
57
+ type: "sse",
58
+ streamTerminator: "[DONE]",
59
+ },
60
+ }),
61
+ rawResponse: _response.rawResponse,
62
+ };
56
63
  }
57
64
  if (_response.error.reason === "status-code") {
58
65
  switch (_response.error.statusCode) {
@@ -74,7 +81,7 @@ export class ChrtGpt {
74
81
  rawResponse: _response.rawResponse,
75
82
  });
76
83
  case "timeout":
77
- throw new errors.ChrtTimeoutError("Timeout exceeded when calling POST /chrt_gpt/message/v1.");
84
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling POST /chrt_gpt/v1.");
78
85
  case "unknown":
79
86
  throw new errors.ChrtError({
80
87
  message: _response.error.errorMessage,
@@ -7,7 +7,7 @@
7
7
  * message: "message"
8
8
  * }
9
9
  */
10
- export interface ChrtGptMessageReq {
10
+ export interface ChrtGptReq {
11
11
  /** Omit to start a new conversation. */
12
12
  conversation_id?: string | null;
13
13
  message: string;
@@ -1 +1 @@
1
- export { type ChrtGptMessageReq } from "./ChrtGptMessageReq.mjs";
1
+ export { type ChrtGptReq } from "./ChrtGptReq.mjs";
@@ -1 +1,2 @@
1
1
  export * from "./client/index.mjs";
2
+ export * from "./resources/index.mjs";
@@ -1 +1,2 @@
1
1
  export * from "./client/index.mjs";
2
+ export * from "./resources/index.mjs";
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../../../environments.mjs";
5
+ import * as core from "../../../../../../core/index.mjs";
6
+ import * as Chrt from "../../../../../index.mjs";
7
+ export declare namespace Conversations {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.ChrtEnvironment | string>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ token?: core.Supplier<core.BearerToken | undefined>;
13
+ /** Additional headers to include in requests. */
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
+ fetcher?: core.FetchFunction;
16
+ }
17
+ interface RequestOptions {
18
+ /** The maximum time to wait for a response in seconds. */
19
+ timeoutInSeconds?: number;
20
+ /** The number of times to retry the request. Defaults to 2. */
21
+ maxRetries?: number;
22
+ /** A hook to abort the request. */
23
+ abortSignal?: AbortSignal;
24
+ /** Additional query string parameters to include in the request. */
25
+ queryParams?: Record<string, unknown>;
26
+ /** Additional headers to include in the request. */
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
+ }
29
+ }
30
+ export declare class Conversations {
31
+ protected readonly _options: Conversations.Options;
32
+ constructor(_options?: Conversations.Options);
33
+ /**
34
+ * Lists the caller's ChrtGPT conversations, most recently active first by default. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | () -> (ChrtGPTConversationListRes)
35
+ *
36
+ * @param {Chrt.chrtGpt.ConversationsListV1Request} request
37
+ * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration.
38
+ *
39
+ * @throws {@link Chrt.UnprocessableEntityError}
40
+ *
41
+ * @example
42
+ * await client.chrtGpt.conversations.listV1({
43
+ * sort_by: "updated_at",
44
+ * sort_order: "asc",
45
+ * page: 1,
46
+ * page_size: 1
47
+ * })
48
+ */
49
+ listV1(request?: Chrt.chrtGpt.ConversationsListV1Request, requestOptions?: Conversations.RequestOptions): core.HttpResponsePromise<Chrt.ChrtGptConversationListRes>;
50
+ private __listV1;
51
+ /**
52
+ * Gets one of the caller's ChrtGPT conversations with its history of messages, tool calls, and web searches. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | () -> (ChrtGPTConversationRes)
53
+ *
54
+ * @param {string} conversationId
55
+ * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration.
56
+ *
57
+ * @throws {@link Chrt.UnprocessableEntityError}
58
+ *
59
+ * @example
60
+ * await client.chrtGpt.conversations.getV1("conversation_id")
61
+ */
62
+ getV1(conversationId: string, requestOptions?: Conversations.RequestOptions): core.HttpResponsePromise<Chrt.ChrtGptConversationRes>;
63
+ private __getV1;
64
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
65
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ import * as environments from "../../../../../../environments.mjs";
14
+ import * as core from "../../../../../../core/index.mjs";
15
+ import * as Chrt from "../../../../../index.mjs";
16
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.mjs";
17
+ import * as errors from "../../../../../../errors/index.mjs";
18
+ export class Conversations {
19
+ constructor(_options = {}) {
20
+ this._options = _options;
21
+ }
22
+ /**
23
+ * Lists the caller's ChrtGPT conversations, most recently active first by default. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | () -> (ChrtGPTConversationListRes)
24
+ *
25
+ * @param {Chrt.chrtGpt.ConversationsListV1Request} request
26
+ * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration.
27
+ *
28
+ * @throws {@link Chrt.UnprocessableEntityError}
29
+ *
30
+ * @example
31
+ * await client.chrtGpt.conversations.listV1({
32
+ * sort_by: "updated_at",
33
+ * sort_order: "asc",
34
+ * page: 1,
35
+ * page_size: 1
36
+ * })
37
+ */
38
+ listV1(request = {}, requestOptions) {
39
+ return core.HttpResponsePromise.fromPromise(this.__listV1(request, requestOptions));
40
+ }
41
+ __listV1() {
42
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
43
+ var _a, _b, _c, _d, _e, _f;
44
+ const { sort_by: sortBy, sort_order: sortOrder, page, page_size: pageSize } = request;
45
+ const _queryParams = {};
46
+ if (sortBy !== undefined) {
47
+ _queryParams["sort_by"] = sortBy;
48
+ }
49
+ if (sortOrder !== undefined) {
50
+ _queryParams["sort_order"] = sortOrder;
51
+ }
52
+ if (page !== undefined) {
53
+ _queryParams["page"] = (_a = page === null || page === void 0 ? void 0 : page.toString()) !== null && _a !== void 0 ? _a : null;
54
+ }
55
+ if (pageSize !== undefined) {
56
+ _queryParams["page_size"] = (_b = pageSize === null || pageSize === void 0 ? void 0 : pageSize.toString()) !== null && _b !== void 0 ? _b : null;
57
+ }
58
+ let _headers = mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
59
+ const _response = yield ((_d = this._options.fetcher) !== null && _d !== void 0 ? _d : core.fetcher)({
60
+ url: core.url.join((_f = (_e = (yield core.Supplier.get(this._options.baseUrl))) !== null && _e !== void 0 ? _e : (yield core.Supplier.get(this._options.environment))) !== null && _f !== void 0 ? _f : environments.ChrtEnvironment.Local, "chrt_gpt/conversations/list/v1"),
61
+ method: "GET",
62
+ headers: _headers,
63
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
64
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
65
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
66
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
67
+ });
68
+ if (_response.ok) {
69
+ return { data: _response.body, rawResponse: _response.rawResponse };
70
+ }
71
+ if (_response.error.reason === "status-code") {
72
+ switch (_response.error.statusCode) {
73
+ case 422:
74
+ throw new Chrt.UnprocessableEntityError(_response.error.body, _response.rawResponse);
75
+ default:
76
+ throw new errors.ChrtError({
77
+ statusCode: _response.error.statusCode,
78
+ body: _response.error.body,
79
+ rawResponse: _response.rawResponse,
80
+ });
81
+ }
82
+ }
83
+ switch (_response.error.reason) {
84
+ case "non-json":
85
+ throw new errors.ChrtError({
86
+ statusCode: _response.error.statusCode,
87
+ body: _response.error.rawBody,
88
+ rawResponse: _response.rawResponse,
89
+ });
90
+ case "timeout":
91
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling GET /chrt_gpt/conversations/list/v1.");
92
+ case "unknown":
93
+ throw new errors.ChrtError({
94
+ message: _response.error.errorMessage,
95
+ rawResponse: _response.rawResponse,
96
+ });
97
+ }
98
+ });
99
+ }
100
+ /**
101
+ * Gets one of the caller's ChrtGPT conversations with its history of messages, tool calls, and web searches. | authz: allowed_org_types=[shipper, provider], min_org_role=operator | () -> (ChrtGPTConversationRes)
102
+ *
103
+ * @param {string} conversationId
104
+ * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration.
105
+ *
106
+ * @throws {@link Chrt.UnprocessableEntityError}
107
+ *
108
+ * @example
109
+ * await client.chrtGpt.conversations.getV1("conversation_id")
110
+ */
111
+ getV1(conversationId, requestOptions) {
112
+ return core.HttpResponsePromise.fromPromise(this.__getV1(conversationId, requestOptions));
113
+ }
114
+ __getV1(conversationId, requestOptions) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ var _a, _b, _c, _d;
117
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
118
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
119
+ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ChrtEnvironment.Local, `chrt_gpt/conversations/v1/${encodeURIComponent(conversationId)}`),
120
+ method: "GET",
121
+ headers: _headers,
122
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
123
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
124
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
125
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
126
+ });
127
+ if (_response.ok) {
128
+ return { data: _response.body, rawResponse: _response.rawResponse };
129
+ }
130
+ if (_response.error.reason === "status-code") {
131
+ switch (_response.error.statusCode) {
132
+ case 422:
133
+ throw new Chrt.UnprocessableEntityError(_response.error.body, _response.rawResponse);
134
+ default:
135
+ throw new errors.ChrtError({
136
+ statusCode: _response.error.statusCode,
137
+ body: _response.error.body,
138
+ rawResponse: _response.rawResponse,
139
+ });
140
+ }
141
+ }
142
+ switch (_response.error.reason) {
143
+ case "non-json":
144
+ throw new errors.ChrtError({
145
+ statusCode: _response.error.statusCode,
146
+ body: _response.error.rawBody,
147
+ rawResponse: _response.rawResponse,
148
+ });
149
+ case "timeout":
150
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling GET /chrt_gpt/conversations/v1/{conversation_id}.");
151
+ case "unknown":
152
+ throw new errors.ChrtError({
153
+ message: _response.error.errorMessage,
154
+ rawResponse: _response.rawResponse,
155
+ });
156
+ }
157
+ });
158
+ }
159
+ _getAuthorizationHeader() {
160
+ return __awaiter(this, void 0, void 0, function* () {
161
+ const bearer = yield core.Supplier.get(this._options.token);
162
+ if (bearer != null) {
163
+ return `Bearer ${bearer}`;
164
+ }
165
+ return undefined;
166
+ });
167
+ }
168
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ export * from "./requests/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Chrt from "../../../../../../index.mjs";
5
+ /**
6
+ * @example
7
+ * {
8
+ * sort_by: "updated_at",
9
+ * sort_order: "asc",
10
+ * page: 1,
11
+ * page_size: 1
12
+ * }
13
+ */
14
+ export interface ConversationsListV1Request {
15
+ /** Field to sort by */
16
+ sort_by?: Chrt.ChrtGptConversationSortByEnum | null;
17
+ /** Sort order (asc or desc) */
18
+ sort_order?: Chrt.SortOrderEnum | null;
19
+ page?: number | null;
20
+ page_size?: number | null;
21
+ }
@@ -0,0 +1 @@
1
+ export { type ConversationsListV1Request } from "./ConversationsListV1Request.mjs";
@@ -0,0 +1 @@
1
+ export * from "./client/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./client/index.mjs";
@@ -0,0 +1,2 @@
1
+ export * as conversations from "./conversations/index.mjs";
2
+ export * from "./conversations/client/requests/index.mjs";
@@ -0,0 +1,2 @@
1
+ export * as conversations from "./conversations/index.mjs";
2
+ export * from "./conversations/client/requests/index.mjs";
@@ -65,6 +65,7 @@ export declare class S3Object {
65
65
  * location_identifiers: ["location_identifiers"],
66
66
  * model: "gpt-6-astra",
67
67
  * package_appearance: "package_appearance",
68
+ * package_count: undefined,
68
69
  * package_types: ["package_types"],
69
70
  * proof_notes: ["proof_notes"],
70
71
  * readable_package_text: ["readable_package_text"],
@@ -106,6 +106,7 @@ export class S3Object {
106
106
  * location_identifiers: ["location_identifiers"],
107
107
  * model: "gpt-6-astra",
108
108
  * package_appearance: "package_appearance",
109
+ * package_count: undefined,
109
110
  * package_types: ["package_types"],
110
111
  * proof_notes: ["proof_notes"],
111
112
  * readable_package_text: ["readable_package_text"],
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface ChrtGptAssistantMessageItem {
5
+ /** Matches the item_id of the text_delta events that streamed it. */
6
+ item_id: string;
7
+ text: string;
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Last event of a successful stream.
6
+ */
7
+ export interface ChrtGptCompletedEvent {
8
+ conversation_id: string;
9
+ /** The turn's final message. Earlier messages in the turn only arrive as text deltas. */
10
+ response_text: string;
11
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface ChrtGptConversation1 {
5
+ _id: string;
6
+ created_at: string;
7
+ /** Must be a string starting with `org_` */
8
+ org_id: string;
9
+ schema_version: number;
10
+ title: string;
11
+ updated_at: string;
12
+ /** Must be a string starting with `user_` */
13
+ user_id: string;
14
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Chrt from "../index.mjs";
5
+ export interface ChrtGptConversationListRes {
6
+ items: Chrt.ChrtGptConversation1[];
7
+ total_count: number;
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Chrt from "../index.mjs";
5
+ export interface ChrtGptConversationRes {
6
+ conversation: Chrt.ChrtGptConversation1;
7
+ /** The conversation's history, oldest first. Reasoning is omitted. */
8
+ items: Chrt.ChrtGptHistoryItem[];
9
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type ChrtGptConversationSortByEnum = "updated_at" | "created_at";
5
+ export declare const ChrtGptConversationSortByEnum: {
6
+ readonly UpdatedAt: "updated_at";
7
+ readonly CreatedAt: "created_at";
8
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export const ChrtGptConversationSortByEnum = {
5
+ UpdatedAt: "updated_at",
6
+ CreatedAt: "created_at",
7
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * Last event of a failed stream.
6
+ */
7
+ export interface ChrtGptErrorEvent {
8
+ message: string;
9
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Chrt from "../index.mjs";
5
+ export type ChrtGptEvent = Chrt.ChrtGptEvent.Completed | Chrt.ChrtGptEvent.Error_ | Chrt.ChrtGptEvent.Started | Chrt.ChrtGptEvent.TextDelta | Chrt.ChrtGptEvent.Title | Chrt.ChrtGptEvent.ToolCalled | Chrt.ChrtGptEvent.ToolOutput | Chrt.ChrtGptEvent.WebSearch;
6
+ export declare namespace ChrtGptEvent {
7
+ interface Completed extends Chrt.ChrtGptCompletedEvent {
8
+ type: "completed";
9
+ }
10
+ interface Error_ extends Chrt.ChrtGptErrorEvent {
11
+ type: "error";
12
+ }
13
+ interface Started extends Chrt.ChrtGptStartedEvent {
14
+ type: "started";
15
+ }
16
+ interface TextDelta extends Chrt.ChrtGptTextDeltaEvent {
17
+ type: "text_delta";
18
+ }
19
+ interface Title extends Chrt.ChrtGptTitleEvent {
20
+ type: "title";
21
+ }
22
+ interface ToolCalled extends Chrt.ChrtGptToolCalledEvent {
23
+ type: "tool_called";
24
+ }
25
+ interface ToolOutput extends Chrt.ChrtGptToolOutputEvent {
26
+ type: "tool_output";
27
+ }
28
+ interface WebSearch extends Chrt.ChrtGptWebSearchEvent {
29
+ type: "web_search";
30
+ }
31
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Chrt from "../index.mjs";
5
+ export type ChrtGptHistoryItem = Chrt.ChrtGptHistoryItem.AssistantMessage | Chrt.ChrtGptHistoryItem.ToolCalled | Chrt.ChrtGptHistoryItem.ToolOutput | Chrt.ChrtGptHistoryItem.UserMessage | Chrt.ChrtGptHistoryItem.WebSearch;
6
+ export declare namespace ChrtGptHistoryItem {
7
+ interface AssistantMessage extends Chrt.ChrtGptAssistantMessageItem {
8
+ type: "assistant_message";
9
+ }
10
+ interface ToolCalled extends Chrt.ChrtGptToolCalledEvent {
11
+ type: "tool_called";
12
+ }
13
+ interface ToolOutput extends Chrt.ChrtGptToolOutputEvent {
14
+ type: "tool_output";
15
+ }
16
+ interface UserMessage extends Chrt.ChrtGptUserMessageItem {
17
+ type: "user_message";
18
+ }
19
+ interface WebSearch extends Chrt.ChrtGptWebSearchEvent {
20
+ type: "web_search";
21
+ }
22
+ }