@letta-ai/letta-client 0.1.7 → 0.1.8

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 (172) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +5 -0
  3. package/api/resources/agents/client/Client.d.ts +13 -0
  4. package/api/resources/agents/client/Client.js +78 -6
  5. package/api/resources/agents/client/requests/CreateAgentRequest.d.ts +2 -2
  6. package/api/resources/agents/client/requests/ResetMessagesRequest.d.ts +13 -0
  7. package/api/resources/agents/client/requests/ResetMessagesRequest.js +5 -0
  8. package/api/resources/agents/client/requests/index.d.ts +1 -0
  9. package/api/resources/agents/resources/archivalMemory/client/Client.js +4 -4
  10. package/api/resources/agents/resources/context/client/Client.js +1 -1
  11. package/api/resources/agents/resources/coreMemory/client/Client.js +7 -7
  12. package/api/resources/agents/resources/memoryVariables/client/Client.js +1 -1
  13. package/api/resources/agents/resources/messages/client/Client.d.ts +1 -1
  14. package/api/resources/agents/resources/messages/client/Client.js +6 -6
  15. package/api/resources/agents/resources/recallMemory/client/Client.js +1 -1
  16. package/api/resources/agents/resources/sources/client/Client.js +1 -1
  17. package/api/resources/agents/resources/templates/client/Client.js +3 -3
  18. package/api/resources/agents/resources/templates/client/requests/TemplatesCreateRequest.d.ts +1 -1
  19. package/api/resources/agents/resources/tools/client/Client.js +3 -3
  20. package/api/resources/blocks/client/Client.js +7 -7
  21. package/api/resources/health/client/Client.js +1 -1
  22. package/api/resources/index.d.ts +2 -0
  23. package/api/resources/index.js +3 -1
  24. package/api/resources/jobs/client/Client.js +4 -4
  25. package/api/resources/models/client/Client.js +2 -2
  26. package/api/resources/providers/client/Client.js +4 -4
  27. package/api/resources/runs/client/Client.d.ts +115 -0
  28. package/api/resources/runs/client/Client.js +500 -0
  29. package/api/resources/runs/client/index.d.ts +1 -0
  30. package/api/resources/runs/client/index.js +17 -0
  31. package/api/resources/runs/client/requests/GetRunMessagesRequest.d.ts +50 -0
  32. package/api/resources/runs/client/requests/GetRunMessagesRequest.js +5 -0
  33. package/api/resources/runs/client/requests/index.d.ts +1 -0
  34. package/api/resources/runs/client/requests/index.js +2 -0
  35. package/api/resources/runs/index.d.ts +1 -0
  36. package/api/resources/runs/index.js +17 -0
  37. package/api/resources/sources/client/Client.js +8 -8
  38. package/api/resources/sources/resources/files/client/Client.js +3 -3
  39. package/api/resources/sources/resources/passages/client/Client.js +1 -1
  40. package/api/resources/tools/client/Client.js +12 -12
  41. package/api/resources/tools/client/requests/ToolRunFromSource.d.ts +1 -1
  42. package/api/resources/tools/client/requests/ToolUpdate.d.ts +0 -2
  43. package/api/types/Job.d.ts +2 -0
  44. package/api/types/JobType.d.ts +8 -0
  45. package/api/types/JobType.js +10 -0
  46. package/api/types/LettaSchemasToolTool.d.ts +0 -2
  47. package/api/types/Run.d.ts +34 -0
  48. package/api/types/Run.js +5 -0
  49. package/api/types/ToolCreate.d.ts +0 -2
  50. package/api/types/index.d.ts +2 -0
  51. package/api/types/index.js +2 -0
  52. package/dist/Client.d.ts +3 -0
  53. package/dist/Client.js +5 -0
  54. package/dist/api/resources/agents/client/Client.d.ts +13 -0
  55. package/dist/api/resources/agents/client/Client.js +78 -6
  56. package/dist/api/resources/agents/client/requests/CreateAgentRequest.d.ts +2 -2
  57. package/dist/api/resources/agents/client/requests/ResetMessagesRequest.d.ts +13 -0
  58. package/dist/api/resources/agents/client/requests/ResetMessagesRequest.js +5 -0
  59. package/dist/api/resources/agents/client/requests/index.d.ts +1 -0
  60. package/dist/api/resources/agents/resources/archivalMemory/client/Client.js +4 -4
  61. package/dist/api/resources/agents/resources/context/client/Client.js +1 -1
  62. package/dist/api/resources/agents/resources/coreMemory/client/Client.js +7 -7
  63. package/dist/api/resources/agents/resources/memoryVariables/client/Client.js +1 -1
  64. package/dist/api/resources/agents/resources/messages/client/Client.d.ts +1 -1
  65. package/dist/api/resources/agents/resources/messages/client/Client.js +6 -6
  66. package/dist/api/resources/agents/resources/recallMemory/client/Client.js +1 -1
  67. package/dist/api/resources/agents/resources/sources/client/Client.js +1 -1
  68. package/dist/api/resources/agents/resources/templates/client/Client.js +3 -3
  69. package/dist/api/resources/agents/resources/templates/client/requests/TemplatesCreateRequest.d.ts +1 -1
  70. package/dist/api/resources/agents/resources/tools/client/Client.js +3 -3
  71. package/dist/api/resources/blocks/client/Client.js +7 -7
  72. package/dist/api/resources/health/client/Client.js +1 -1
  73. package/dist/api/resources/index.d.ts +2 -0
  74. package/dist/api/resources/index.js +3 -1
  75. package/dist/api/resources/jobs/client/Client.js +4 -4
  76. package/dist/api/resources/models/client/Client.js +2 -2
  77. package/dist/api/resources/providers/client/Client.js +4 -4
  78. package/dist/api/resources/runs/client/Client.d.ts +115 -0
  79. package/dist/api/resources/runs/client/Client.js +500 -0
  80. package/dist/api/resources/runs/client/index.d.ts +1 -0
  81. package/dist/api/resources/runs/client/index.js +17 -0
  82. package/dist/api/resources/runs/client/requests/GetRunMessagesRequest.d.ts +50 -0
  83. package/dist/api/resources/runs/client/requests/GetRunMessagesRequest.js +5 -0
  84. package/dist/api/resources/runs/client/requests/index.d.ts +1 -0
  85. package/dist/api/resources/runs/client/requests/index.js +2 -0
  86. package/dist/api/resources/runs/index.d.ts +1 -0
  87. package/dist/api/resources/runs/index.js +17 -0
  88. package/dist/api/resources/sources/client/Client.js +8 -8
  89. package/dist/api/resources/sources/resources/files/client/Client.js +3 -3
  90. package/dist/api/resources/sources/resources/passages/client/Client.js +1 -1
  91. package/dist/api/resources/tools/client/Client.js +12 -12
  92. package/dist/api/resources/tools/client/requests/ToolRunFromSource.d.ts +1 -1
  93. package/dist/api/resources/tools/client/requests/ToolUpdate.d.ts +0 -2
  94. package/dist/api/types/Job.d.ts +2 -0
  95. package/dist/api/types/JobType.d.ts +8 -0
  96. package/dist/api/types/JobType.js +10 -0
  97. package/dist/api/types/LettaSchemasToolTool.d.ts +0 -2
  98. package/dist/api/types/Run.d.ts +34 -0
  99. package/dist/api/types/Run.js +5 -0
  100. package/dist/api/types/ToolCreate.d.ts +0 -2
  101. package/dist/api/types/index.d.ts +2 -0
  102. package/dist/api/types/index.js +2 -0
  103. package/dist/serialization/resources/agents/client/requests/CreateAgentRequest.d.ts +1 -1
  104. package/dist/serialization/resources/agents/client/requests/CreateAgentRequest.js +1 -1
  105. package/dist/serialization/resources/agents/resources/templates/client/requests/TemplatesCreateRequest.d.ts +1 -1
  106. package/dist/serialization/resources/agents/resources/templates/client/requests/TemplatesCreateRequest.js +1 -1
  107. package/dist/serialization/resources/index.d.ts +1 -0
  108. package/dist/serialization/resources/index.js +2 -1
  109. package/dist/serialization/resources/runs/client/getRunMessages.d.ts +11 -0
  110. package/dist/serialization/resources/runs/client/getRunMessages.js +32 -0
  111. package/dist/serialization/resources/runs/client/index.d.ts +3 -0
  112. package/dist/serialization/resources/runs/client/index.js +29 -0
  113. package/dist/serialization/resources/runs/client/listActiveRuns.d.ts +11 -0
  114. package/dist/serialization/resources/runs/client/listActiveRuns.js +32 -0
  115. package/dist/serialization/resources/runs/client/listRuns.d.ts +11 -0
  116. package/dist/serialization/resources/runs/client/listRuns.js +32 -0
  117. package/dist/serialization/resources/runs/index.d.ts +1 -0
  118. package/dist/serialization/resources/runs/index.js +17 -0
  119. package/dist/serialization/resources/tools/client/requests/ToolRunFromSource.d.ts +1 -1
  120. package/dist/serialization/resources/tools/client/requests/ToolRunFromSource.js +1 -1
  121. package/dist/serialization/resources/tools/client/requests/ToolUpdate.d.ts +0 -1
  122. package/dist/serialization/resources/tools/client/requests/ToolUpdate.js +0 -1
  123. package/dist/serialization/types/Job.d.ts +2 -0
  124. package/dist/serialization/types/Job.js +2 -0
  125. package/dist/serialization/types/JobType.d.ts +10 -0
  126. package/dist/serialization/types/JobType.js +34 -0
  127. package/dist/serialization/types/LettaSchemasToolTool.d.ts +0 -1
  128. package/dist/serialization/types/LettaSchemasToolTool.js +0 -1
  129. package/dist/serialization/types/Run.d.ts +22 -0
  130. package/dist/serialization/types/Run.js +43 -0
  131. package/dist/serialization/types/ToolCreate.d.ts +0 -1
  132. package/dist/serialization/types/ToolCreate.js +0 -1
  133. package/dist/serialization/types/index.d.ts +2 -0
  134. package/dist/serialization/types/index.js +2 -0
  135. package/dist/version.d.ts +1 -1
  136. package/dist/version.js +1 -1
  137. package/package.json +1 -1
  138. package/reference.md +458 -1
  139. package/serialization/resources/agents/client/requests/CreateAgentRequest.d.ts +1 -1
  140. package/serialization/resources/agents/client/requests/CreateAgentRequest.js +1 -1
  141. package/serialization/resources/agents/resources/templates/client/requests/TemplatesCreateRequest.d.ts +1 -1
  142. package/serialization/resources/agents/resources/templates/client/requests/TemplatesCreateRequest.js +1 -1
  143. package/serialization/resources/index.d.ts +1 -0
  144. package/serialization/resources/index.js +2 -1
  145. package/serialization/resources/runs/client/getRunMessages.d.ts +11 -0
  146. package/serialization/resources/runs/client/getRunMessages.js +32 -0
  147. package/serialization/resources/runs/client/index.d.ts +3 -0
  148. package/serialization/resources/runs/client/index.js +29 -0
  149. package/serialization/resources/runs/client/listActiveRuns.d.ts +11 -0
  150. package/serialization/resources/runs/client/listActiveRuns.js +32 -0
  151. package/serialization/resources/runs/client/listRuns.d.ts +11 -0
  152. package/serialization/resources/runs/client/listRuns.js +32 -0
  153. package/serialization/resources/runs/index.d.ts +1 -0
  154. package/serialization/resources/runs/index.js +17 -0
  155. package/serialization/resources/tools/client/requests/ToolRunFromSource.d.ts +1 -1
  156. package/serialization/resources/tools/client/requests/ToolRunFromSource.js +1 -1
  157. package/serialization/resources/tools/client/requests/ToolUpdate.d.ts +0 -1
  158. package/serialization/resources/tools/client/requests/ToolUpdate.js +0 -1
  159. package/serialization/types/Job.d.ts +2 -0
  160. package/serialization/types/Job.js +2 -0
  161. package/serialization/types/JobType.d.ts +10 -0
  162. package/serialization/types/JobType.js +34 -0
  163. package/serialization/types/LettaSchemasToolTool.d.ts +0 -1
  164. package/serialization/types/LettaSchemasToolTool.js +0 -1
  165. package/serialization/types/Run.d.ts +22 -0
  166. package/serialization/types/Run.js +43 -0
  167. package/serialization/types/ToolCreate.d.ts +0 -1
  168. package/serialization/types/ToolCreate.js +0 -1
  169. package/serialization/types/index.d.ts +2 -0
  170. package/serialization/types/index.js +2 -0
  171. package/version.d.ts +1 -1
  172. package/version.js +1 -1
@@ -0,0 +1,500 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.Runs = void 0;
42
+ const environments = __importStar(require("../../../../environments"));
43
+ const core = __importStar(require("../../../../core"));
44
+ const Letta = __importStar(require("../../../index"));
45
+ const url_join_1 = __importDefault(require("url-join"));
46
+ const serializers = __importStar(require("../../../../serialization/index"));
47
+ const errors = __importStar(require("../../../../errors/index"));
48
+ class Runs {
49
+ constructor(_options = {}) {
50
+ this._options = _options;
51
+ }
52
+ /**
53
+ * List all runs.
54
+ *
55
+ * @param {Runs.RequestOptions} requestOptions - Request-specific configuration.
56
+ *
57
+ * @throws {@link Letta.UnprocessableEntityError}
58
+ *
59
+ * @example
60
+ * await client.runs.listRuns()
61
+ */
62
+ listRuns(requestOptions) {
63
+ var _a, _b;
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
66
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.LettaEnvironment.LettaCloud, "v1/runs/"),
67
+ method: "GET",
68
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.8", "User-Agent": "@letta-ai/letta-client/0.1.8", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
69
+ contentType: "application/json",
70
+ requestType: "json",
71
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
72
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
73
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
74
+ });
75
+ if (_response.ok) {
76
+ return serializers.runs.listRuns.Response.parseOrThrow(_response.body, {
77
+ unrecognizedObjectKeys: "passthrough",
78
+ allowUnrecognizedUnionMembers: true,
79
+ allowUnrecognizedEnumValues: true,
80
+ skipValidation: true,
81
+ breadcrumbsPrefix: ["response"],
82
+ });
83
+ }
84
+ if (_response.error.reason === "status-code") {
85
+ switch (_response.error.statusCode) {
86
+ case 422:
87
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
88
+ unrecognizedObjectKeys: "passthrough",
89
+ allowUnrecognizedUnionMembers: true,
90
+ allowUnrecognizedEnumValues: true,
91
+ skipValidation: true,
92
+ breadcrumbsPrefix: ["response"],
93
+ }));
94
+ default:
95
+ throw new errors.LettaError({
96
+ statusCode: _response.error.statusCode,
97
+ body: _response.error.body,
98
+ });
99
+ }
100
+ }
101
+ switch (_response.error.reason) {
102
+ case "non-json":
103
+ throw new errors.LettaError({
104
+ statusCode: _response.error.statusCode,
105
+ body: _response.error.rawBody,
106
+ });
107
+ case "timeout":
108
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/runs/.");
109
+ case "unknown":
110
+ throw new errors.LettaError({
111
+ message: _response.error.errorMessage,
112
+ });
113
+ }
114
+ });
115
+ }
116
+ /**
117
+ * List all active runs.
118
+ *
119
+ * @param {Runs.RequestOptions} requestOptions - Request-specific configuration.
120
+ *
121
+ * @throws {@link Letta.UnprocessableEntityError}
122
+ *
123
+ * @example
124
+ * await client.runs.listActiveRuns()
125
+ */
126
+ listActiveRuns(requestOptions) {
127
+ var _a, _b;
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
130
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.LettaEnvironment.LettaCloud, "v1/runs/active"),
131
+ method: "GET",
132
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.8", "User-Agent": "@letta-ai/letta-client/0.1.8", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
133
+ contentType: "application/json",
134
+ requestType: "json",
135
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
136
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
137
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
138
+ });
139
+ if (_response.ok) {
140
+ return serializers.runs.listActiveRuns.Response.parseOrThrow(_response.body, {
141
+ unrecognizedObjectKeys: "passthrough",
142
+ allowUnrecognizedUnionMembers: true,
143
+ allowUnrecognizedEnumValues: true,
144
+ skipValidation: true,
145
+ breadcrumbsPrefix: ["response"],
146
+ });
147
+ }
148
+ if (_response.error.reason === "status-code") {
149
+ switch (_response.error.statusCode) {
150
+ case 422:
151
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
152
+ unrecognizedObjectKeys: "passthrough",
153
+ allowUnrecognizedUnionMembers: true,
154
+ allowUnrecognizedEnumValues: true,
155
+ skipValidation: true,
156
+ breadcrumbsPrefix: ["response"],
157
+ }));
158
+ default:
159
+ throw new errors.LettaError({
160
+ statusCode: _response.error.statusCode,
161
+ body: _response.error.body,
162
+ });
163
+ }
164
+ }
165
+ switch (_response.error.reason) {
166
+ case "non-json":
167
+ throw new errors.LettaError({
168
+ statusCode: _response.error.statusCode,
169
+ body: _response.error.rawBody,
170
+ });
171
+ case "timeout":
172
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/runs/active.");
173
+ case "unknown":
174
+ throw new errors.LettaError({
175
+ message: _response.error.errorMessage,
176
+ });
177
+ }
178
+ });
179
+ }
180
+ /**
181
+ * Get the status of a run.
182
+ *
183
+ * @param {string} runId
184
+ * @param {Runs.RequestOptions} requestOptions - Request-specific configuration.
185
+ *
186
+ * @throws {@link Letta.UnprocessableEntityError}
187
+ *
188
+ * @example
189
+ * await client.runs.getRun("run_id")
190
+ */
191
+ getRun(runId, requestOptions) {
192
+ var _a, _b;
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
195
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.LettaEnvironment.LettaCloud, `v1/runs/${encodeURIComponent(runId)}`),
196
+ method: "GET",
197
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.8", "User-Agent": "@letta-ai/letta-client/0.1.8", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
198
+ contentType: "application/json",
199
+ requestType: "json",
200
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
201
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
202
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
203
+ });
204
+ if (_response.ok) {
205
+ return serializers.Run.parseOrThrow(_response.body, {
206
+ unrecognizedObjectKeys: "passthrough",
207
+ allowUnrecognizedUnionMembers: true,
208
+ allowUnrecognizedEnumValues: true,
209
+ skipValidation: true,
210
+ breadcrumbsPrefix: ["response"],
211
+ });
212
+ }
213
+ if (_response.error.reason === "status-code") {
214
+ switch (_response.error.statusCode) {
215
+ case 422:
216
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
217
+ unrecognizedObjectKeys: "passthrough",
218
+ allowUnrecognizedUnionMembers: true,
219
+ allowUnrecognizedEnumValues: true,
220
+ skipValidation: true,
221
+ breadcrumbsPrefix: ["response"],
222
+ }));
223
+ default:
224
+ throw new errors.LettaError({
225
+ statusCode: _response.error.statusCode,
226
+ body: _response.error.body,
227
+ });
228
+ }
229
+ }
230
+ switch (_response.error.reason) {
231
+ case "non-json":
232
+ throw new errors.LettaError({
233
+ statusCode: _response.error.statusCode,
234
+ body: _response.error.rawBody,
235
+ });
236
+ case "timeout":
237
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/runs/{run_id}.");
238
+ case "unknown":
239
+ throw new errors.LettaError({
240
+ message: _response.error.errorMessage,
241
+ });
242
+ }
243
+ });
244
+ }
245
+ /**
246
+ * Delete a run by its run_id.
247
+ *
248
+ * @param {string} runId
249
+ * @param {Runs.RequestOptions} requestOptions - Request-specific configuration.
250
+ *
251
+ * @throws {@link Letta.UnprocessableEntityError}
252
+ *
253
+ * @example
254
+ * await client.runs.deleteRun("run_id")
255
+ */
256
+ deleteRun(runId, requestOptions) {
257
+ var _a, _b;
258
+ return __awaiter(this, void 0, void 0, function* () {
259
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
260
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.LettaEnvironment.LettaCloud, `v1/runs/${encodeURIComponent(runId)}`),
261
+ method: "DELETE",
262
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.8", "User-Agent": "@letta-ai/letta-client/0.1.8", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
263
+ contentType: "application/json",
264
+ requestType: "json",
265
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
266
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
267
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
268
+ });
269
+ if (_response.ok) {
270
+ return serializers.Run.parseOrThrow(_response.body, {
271
+ unrecognizedObjectKeys: "passthrough",
272
+ allowUnrecognizedUnionMembers: true,
273
+ allowUnrecognizedEnumValues: true,
274
+ skipValidation: true,
275
+ breadcrumbsPrefix: ["response"],
276
+ });
277
+ }
278
+ if (_response.error.reason === "status-code") {
279
+ switch (_response.error.statusCode) {
280
+ case 422:
281
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
282
+ unrecognizedObjectKeys: "passthrough",
283
+ allowUnrecognizedUnionMembers: true,
284
+ allowUnrecognizedEnumValues: true,
285
+ skipValidation: true,
286
+ breadcrumbsPrefix: ["response"],
287
+ }));
288
+ default:
289
+ throw new errors.LettaError({
290
+ statusCode: _response.error.statusCode,
291
+ body: _response.error.body,
292
+ });
293
+ }
294
+ }
295
+ switch (_response.error.reason) {
296
+ case "non-json":
297
+ throw new errors.LettaError({
298
+ statusCode: _response.error.statusCode,
299
+ body: _response.error.rawBody,
300
+ });
301
+ case "timeout":
302
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling DELETE /v1/runs/{run_id}.");
303
+ case "unknown":
304
+ throw new errors.LettaError({
305
+ message: _response.error.errorMessage,
306
+ });
307
+ }
308
+ });
309
+ }
310
+ /**
311
+ * Get messages associated with a run with filtering options.
312
+ *
313
+ * Args:
314
+ * run_id: ID of the run
315
+ * cursor: Cursor for pagination
316
+ * start_date: Filter messages after this date
317
+ * end_date: Filter messages before this date
318
+ * limit: Maximum number of messages to return
319
+ * query_text: Search text in message content
320
+ * ascending: Sort order by creation time
321
+ * tags: Filter by message tags
322
+ * match_all_tags: If true, match all tags. If false, match any tag
323
+ * role: Filter by message role (user/assistant/system/tool)
324
+ * tool_name: Filter by tool call name
325
+ * user_id: ID of the user making the request
326
+ *
327
+ * @param {string} runId
328
+ * @param {Letta.GetRunMessagesRequest} request
329
+ * @param {Runs.RequestOptions} requestOptions - Request-specific configuration.
330
+ *
331
+ * @throws {@link Letta.UnprocessableEntityError}
332
+ *
333
+ * @example
334
+ * await client.runs.getRunMessages("run_id")
335
+ */
336
+ getRunMessages(runId, request = {}, requestOptions) {
337
+ var _a, _b;
338
+ return __awaiter(this, void 0, void 0, function* () {
339
+ const { cursor, startDate, endDate, limit, queryText, ascending, tags, matchAllTags, role, toolName } = request;
340
+ const _queryParams = {};
341
+ if (cursor != null) {
342
+ _queryParams["cursor"] = cursor;
343
+ }
344
+ if (startDate != null) {
345
+ _queryParams["start_date"] = startDate.toISOString();
346
+ }
347
+ if (endDate != null) {
348
+ _queryParams["end_date"] = endDate.toISOString();
349
+ }
350
+ if (limit != null) {
351
+ _queryParams["limit"] = limit.toString();
352
+ }
353
+ if (queryText != null) {
354
+ _queryParams["query_text"] = queryText;
355
+ }
356
+ if (ascending != null) {
357
+ _queryParams["ascending"] = ascending.toString();
358
+ }
359
+ if (tags != null) {
360
+ if (Array.isArray(tags)) {
361
+ _queryParams["tags"] = tags.map((item) => item);
362
+ }
363
+ else {
364
+ _queryParams["tags"] = tags;
365
+ }
366
+ }
367
+ if (matchAllTags != null) {
368
+ _queryParams["match_all_tags"] = matchAllTags.toString();
369
+ }
370
+ if (role != null) {
371
+ _queryParams["role"] = role;
372
+ }
373
+ if (toolName != null) {
374
+ _queryParams["tool_name"] = toolName;
375
+ }
376
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
377
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.LettaEnvironment.LettaCloud, `v1/runs/${encodeURIComponent(runId)}/messages`),
378
+ method: "GET",
379
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.8", "User-Agent": "@letta-ai/letta-client/0.1.8", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
380
+ contentType: "application/json",
381
+ queryParameters: _queryParams,
382
+ requestType: "json",
383
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
384
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
385
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
386
+ });
387
+ if (_response.ok) {
388
+ return serializers.runs.getRunMessages.Response.parseOrThrow(_response.body, {
389
+ unrecognizedObjectKeys: "passthrough",
390
+ allowUnrecognizedUnionMembers: true,
391
+ allowUnrecognizedEnumValues: true,
392
+ skipValidation: true,
393
+ breadcrumbsPrefix: ["response"],
394
+ });
395
+ }
396
+ if (_response.error.reason === "status-code") {
397
+ switch (_response.error.statusCode) {
398
+ case 422:
399
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
400
+ unrecognizedObjectKeys: "passthrough",
401
+ allowUnrecognizedUnionMembers: true,
402
+ allowUnrecognizedEnumValues: true,
403
+ skipValidation: true,
404
+ breadcrumbsPrefix: ["response"],
405
+ }));
406
+ default:
407
+ throw new errors.LettaError({
408
+ statusCode: _response.error.statusCode,
409
+ body: _response.error.body,
410
+ });
411
+ }
412
+ }
413
+ switch (_response.error.reason) {
414
+ case "non-json":
415
+ throw new errors.LettaError({
416
+ statusCode: _response.error.statusCode,
417
+ body: _response.error.rawBody,
418
+ });
419
+ case "timeout":
420
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/runs/{run_id}/messages.");
421
+ case "unknown":
422
+ throw new errors.LettaError({
423
+ message: _response.error.errorMessage,
424
+ });
425
+ }
426
+ });
427
+ }
428
+ /**
429
+ * Get usage statistics for a run.
430
+ *
431
+ * @param {string} runId
432
+ * @param {Runs.RequestOptions} requestOptions - Request-specific configuration.
433
+ *
434
+ * @throws {@link Letta.UnprocessableEntityError}
435
+ *
436
+ * @example
437
+ * await client.runs.getRunUsage("run_id")
438
+ */
439
+ getRunUsage(runId, requestOptions) {
440
+ var _a, _b;
441
+ return __awaiter(this, void 0, void 0, function* () {
442
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
443
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.LettaEnvironment.LettaCloud, `v1/runs/${encodeURIComponent(runId)}/usage`),
444
+ method: "GET",
445
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.8", "User-Agent": "@letta-ai/letta-client/0.1.8", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
446
+ contentType: "application/json",
447
+ requestType: "json",
448
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
449
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
450
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
451
+ });
452
+ if (_response.ok) {
453
+ return serializers.UsageStatistics.parseOrThrow(_response.body, {
454
+ unrecognizedObjectKeys: "passthrough",
455
+ allowUnrecognizedUnionMembers: true,
456
+ allowUnrecognizedEnumValues: true,
457
+ skipValidation: true,
458
+ breadcrumbsPrefix: ["response"],
459
+ });
460
+ }
461
+ if (_response.error.reason === "status-code") {
462
+ switch (_response.error.statusCode) {
463
+ case 422:
464
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
465
+ unrecognizedObjectKeys: "passthrough",
466
+ allowUnrecognizedUnionMembers: true,
467
+ allowUnrecognizedEnumValues: true,
468
+ skipValidation: true,
469
+ breadcrumbsPrefix: ["response"],
470
+ }));
471
+ default:
472
+ throw new errors.LettaError({
473
+ statusCode: _response.error.statusCode,
474
+ body: _response.error.body,
475
+ });
476
+ }
477
+ }
478
+ switch (_response.error.reason) {
479
+ case "non-json":
480
+ throw new errors.LettaError({
481
+ statusCode: _response.error.statusCode,
482
+ body: _response.error.rawBody,
483
+ });
484
+ case "timeout":
485
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/runs/{run_id}/usage.");
486
+ case "unknown":
487
+ throw new errors.LettaError({
488
+ message: _response.error.errorMessage,
489
+ });
490
+ }
491
+ });
492
+ }
493
+ _getCustomAuthorizationHeaders() {
494
+ return __awaiter(this, void 0, void 0, function* () {
495
+ const tokenValue = yield core.Supplier.get(this._options.token);
496
+ return { Authorization: `Bearer ${tokenValue}` };
497
+ });
498
+ }
499
+ }
500
+ exports.Runs = Runs;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Letta from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface GetRunMessagesRequest {
10
+ /**
11
+ * Cursor for pagination
12
+ */
13
+ cursor?: string;
14
+ /**
15
+ * Filter messages after this date
16
+ */
17
+ startDate?: Date;
18
+ /**
19
+ * Filter messages before this date
20
+ */
21
+ endDate?: Date;
22
+ /**
23
+ * Maximum number of messages to return
24
+ */
25
+ limit?: number;
26
+ /**
27
+ * Search text in message content
28
+ */
29
+ queryText?: string;
30
+ /**
31
+ * Sort order by creation time
32
+ */
33
+ ascending?: boolean;
34
+ /**
35
+ * Filter by message tags
36
+ */
37
+ tags?: string | string[];
38
+ /**
39
+ * If true, match all tags. If false, match any tag
40
+ */
41
+ matchAllTags?: boolean;
42
+ /**
43
+ * Filter by message role
44
+ */
45
+ role?: Letta.MessageRole;
46
+ /**
47
+ * Filter by tool call name
48
+ */
49
+ toolName?: string;
50
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type GetRunMessagesRequest } from "./GetRunMessagesRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client"), exports);