@letta-ai/letta-client 0.1.160 → 0.1.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.d.ts +3 -0
- package/Client.js +43 -38
- package/api/resources/agents/client/Client.js +13 -13
- package/api/resources/agents/resources/blocks/client/Client.js +5 -5
- package/api/resources/agents/resources/context/client/Client.js +1 -1
- package/api/resources/agents/resources/coreMemory/client/Client.js +1 -1
- package/api/resources/agents/resources/groups/client/Client.js +1 -1
- package/api/resources/agents/resources/memoryVariables/client/Client.js +1 -1
- package/api/resources/agents/resources/messages/client/Client.js +8 -8
- package/api/resources/agents/resources/passages/client/Client.js +4 -4
- package/api/resources/agents/resources/sources/client/Client.js +3 -3
- package/api/resources/agents/resources/templates/client/Client.js +3 -3
- package/api/resources/agents/resources/tools/client/Client.js +3 -3
- package/api/resources/batches/client/Client.js +4 -4
- package/api/resources/blocks/client/Client.js +6 -6
- package/api/resources/blocks/resources/agents/client/Client.js +1 -1
- package/api/resources/clientSideAccessTokens/client/Client.js +3 -3
- package/api/resources/embeddingModels/client/Client.js +1 -1
- package/api/resources/folders/client/Client.d.ts +206 -0
- package/api/resources/folders/client/Client.js +981 -0
- package/api/resources/folders/client/index.d.ts +1 -0
- package/api/resources/folders/client/index.js +17 -0
- package/api/resources/folders/client/requests/BodyUploadFileToFolder.d.ts +14 -0
- package/api/resources/folders/client/requests/BodyUploadFileToFolder.js +5 -0
- package/api/resources/folders/client/requests/FolderCreate.d.ts +26 -0
- package/api/resources/folders/client/requests/FolderCreate.js +5 -0
- package/api/resources/folders/client/requests/FolderUpdate.d.ts +20 -0
- package/api/resources/folders/client/requests/FolderUpdate.js +5 -0
- package/api/resources/folders/client/requests/GetFoldersMetadataRequest.d.ts +10 -0
- package/api/resources/folders/client/requests/GetFoldersMetadataRequest.js +5 -0
- package/api/resources/folders/client/requests/ListFolderFilesRequest.d.ts +21 -0
- package/api/resources/folders/client/requests/ListFolderFilesRequest.js +5 -0
- package/api/resources/folders/client/requests/ListFolderPassagesRequest.d.ts +21 -0
- package/api/resources/folders/client/requests/ListFolderPassagesRequest.js +5 -0
- package/api/resources/folders/client/requests/index.d.ts +6 -0
- package/api/resources/folders/client/requests/index.js +2 -0
- package/api/resources/folders/index.d.ts +1 -0
- package/api/resources/folders/index.js +17 -0
- package/api/resources/groups/client/Client.js +6 -6
- package/api/resources/groups/resources/messages/client/Client.js +5 -5
- package/api/resources/health/client/Client.js +1 -1
- package/api/resources/identities/client/Client.js +7 -7
- package/api/resources/identities/resources/properties/client/Client.js +1 -1
- package/api/resources/index.d.ts +2 -0
- package/api/resources/index.js +3 -1
- package/api/resources/jobs/client/Client.js +5 -5
- package/api/resources/messages/client/Client.js +1 -1
- package/api/resources/models/client/Client.js +1 -1
- package/api/resources/projects/client/Client.js +1 -1
- package/api/resources/providers/client/Client.js +5 -5
- package/api/resources/runs/client/Client.js +4 -4
- package/api/resources/runs/resources/messages/client/Client.js +1 -1
- package/api/resources/runs/resources/steps/client/Client.js +1 -1
- package/api/resources/runs/resources/usage/client/Client.js +1 -1
- package/api/resources/sources/client/Client.js +10 -10
- package/api/resources/sources/resources/files/client/Client.js +3 -3
- package/api/resources/sources/resources/passages/client/Client.js +1 -1
- package/api/resources/steps/client/Client.js +2 -2
- package/api/resources/steps/resources/feedback/client/Client.js +1 -1
- package/api/resources/tags/client/Client.js +1 -1
- package/api/resources/telemetry/client/Client.js +1 -1
- package/api/resources/templates/client/Client.js +1 -1
- package/api/resources/templates/resources/agents/client/Client.js +1 -1
- package/api/resources/tools/client/Client.js +19 -19
- package/api/resources/voice/client/Client.js +1 -1
- package/api/types/Folder.d.ts +37 -0
- package/api/types/Folder.js +5 -0
- package/api/types/index.d.ts +1 -0
- package/api/types/index.js +1 -0
- package/dist/Client.d.ts +3 -0
- package/dist/Client.js +43 -38
- package/dist/api/resources/agents/client/Client.js +13 -13
- package/dist/api/resources/agents/resources/blocks/client/Client.js +5 -5
- package/dist/api/resources/agents/resources/context/client/Client.js +1 -1
- package/dist/api/resources/agents/resources/coreMemory/client/Client.js +1 -1
- package/dist/api/resources/agents/resources/groups/client/Client.js +1 -1
- package/dist/api/resources/agents/resources/memoryVariables/client/Client.js +1 -1
- package/dist/api/resources/agents/resources/messages/client/Client.js +8 -8
- package/dist/api/resources/agents/resources/passages/client/Client.js +4 -4
- package/dist/api/resources/agents/resources/sources/client/Client.js +3 -3
- package/dist/api/resources/agents/resources/templates/client/Client.js +3 -3
- package/dist/api/resources/agents/resources/tools/client/Client.js +3 -3
- package/dist/api/resources/batches/client/Client.js +4 -4
- package/dist/api/resources/blocks/client/Client.js +6 -6
- package/dist/api/resources/blocks/resources/agents/client/Client.js +1 -1
- package/dist/api/resources/clientSideAccessTokens/client/Client.js +3 -3
- package/dist/api/resources/embeddingModels/client/Client.js +1 -1
- package/dist/api/resources/folders/client/Client.d.ts +206 -0
- package/dist/api/resources/folders/client/Client.js +981 -0
- package/dist/api/resources/folders/client/index.d.ts +1 -0
- package/dist/api/resources/folders/client/index.js +17 -0
- package/dist/api/resources/folders/client/requests/BodyUploadFileToFolder.d.ts +14 -0
- package/dist/api/resources/folders/client/requests/BodyUploadFileToFolder.js +5 -0
- package/dist/api/resources/folders/client/requests/FolderCreate.d.ts +26 -0
- package/dist/api/resources/folders/client/requests/FolderCreate.js +5 -0
- package/dist/api/resources/folders/client/requests/FolderUpdate.d.ts +20 -0
- package/dist/api/resources/folders/client/requests/FolderUpdate.js +5 -0
- package/dist/api/resources/folders/client/requests/GetFoldersMetadataRequest.d.ts +10 -0
- package/dist/api/resources/folders/client/requests/GetFoldersMetadataRequest.js +5 -0
- package/dist/api/resources/folders/client/requests/ListFolderFilesRequest.d.ts +21 -0
- package/dist/api/resources/folders/client/requests/ListFolderFilesRequest.js +5 -0
- package/dist/api/resources/folders/client/requests/ListFolderPassagesRequest.d.ts +21 -0
- package/dist/api/resources/folders/client/requests/ListFolderPassagesRequest.js +5 -0
- package/dist/api/resources/folders/client/requests/index.d.ts +6 -0
- package/dist/api/resources/folders/client/requests/index.js +2 -0
- package/dist/api/resources/folders/index.d.ts +1 -0
- package/dist/api/resources/folders/index.js +17 -0
- package/dist/api/resources/groups/client/Client.js +6 -6
- package/dist/api/resources/groups/resources/messages/client/Client.js +5 -5
- package/dist/api/resources/health/client/Client.js +1 -1
- package/dist/api/resources/identities/client/Client.js +7 -7
- package/dist/api/resources/identities/resources/properties/client/Client.js +1 -1
- package/dist/api/resources/index.d.ts +2 -0
- package/dist/api/resources/index.js +3 -1
- package/dist/api/resources/jobs/client/Client.js +5 -5
- package/dist/api/resources/messages/client/Client.js +1 -1
- package/dist/api/resources/models/client/Client.js +1 -1
- package/dist/api/resources/projects/client/Client.js +1 -1
- package/dist/api/resources/providers/client/Client.js +5 -5
- package/dist/api/resources/runs/client/Client.js +4 -4
- package/dist/api/resources/runs/resources/messages/client/Client.js +1 -1
- package/dist/api/resources/runs/resources/steps/client/Client.js +1 -1
- package/dist/api/resources/runs/resources/usage/client/Client.js +1 -1
- package/dist/api/resources/sources/client/Client.js +10 -10
- package/dist/api/resources/sources/resources/files/client/Client.js +3 -3
- package/dist/api/resources/sources/resources/passages/client/Client.js +1 -1
- package/dist/api/resources/steps/client/Client.js +2 -2
- package/dist/api/resources/steps/resources/feedback/client/Client.js +1 -1
- package/dist/api/resources/tags/client/Client.js +1 -1
- package/dist/api/resources/telemetry/client/Client.js +1 -1
- package/dist/api/resources/templates/client/Client.js +1 -1
- package/dist/api/resources/templates/resources/agents/client/Client.js +1 -1
- package/dist/api/resources/tools/client/Client.js +19 -19
- package/dist/api/resources/voice/client/Client.js +1 -1
- package/dist/api/types/Folder.d.ts +37 -0
- package/dist/api/types/Folder.js +5 -0
- package/dist/api/types/index.d.ts +1 -0
- package/dist/api/types/index.js +1 -0
- package/dist/serialization/resources/folders/client/countFolders.d.ts +9 -0
- package/dist/serialization/resources/folders/client/countFolders.js +41 -0
- package/dist/serialization/resources/folders/client/getAgentsForFolder.d.ts +9 -0
- package/dist/serialization/resources/folders/client/getAgentsForFolder.js +41 -0
- package/dist/serialization/resources/folders/client/getFolderIdByName.d.ts +9 -0
- package/dist/serialization/resources/folders/client/getFolderIdByName.js +41 -0
- package/dist/serialization/resources/folders/client/index.d.ts +7 -0
- package/dist/serialization/resources/folders/client/index.js +46 -0
- package/dist/serialization/resources/folders/client/listFolderFiles.d.ts +11 -0
- package/dist/serialization/resources/folders/client/listFolderFiles.js +42 -0
- package/dist/serialization/resources/folders/client/listFolderPassages.d.ts +11 -0
- package/dist/serialization/resources/folders/client/listFolderPassages.js +42 -0
- package/dist/serialization/resources/folders/client/listFolders.d.ts +11 -0
- package/dist/serialization/resources/folders/client/listFolders.js +42 -0
- package/dist/serialization/resources/folders/client/requests/FolderCreate.d.ts +19 -0
- package/dist/serialization/resources/folders/client/requests/FolderCreate.js +50 -0
- package/dist/serialization/resources/folders/client/requests/FolderUpdate.d.ts +17 -0
- package/dist/serialization/resources/folders/client/requests/FolderUpdate.js +48 -0
- package/dist/serialization/resources/folders/client/requests/index.d.ts +2 -0
- package/dist/serialization/resources/folders/client/requests/index.js +7 -0
- package/dist/serialization/resources/folders/index.d.ts +1 -0
- package/dist/serialization/resources/folders/index.js +17 -0
- package/dist/serialization/resources/index.d.ts +2 -0
- package/dist/serialization/resources/index.js +3 -1
- package/dist/serialization/types/Folder.d.ts +22 -0
- package/dist/serialization/types/Folder.js +53 -0
- package/dist/serialization/types/index.d.ts +1 -0
- package/dist/serialization/types/index.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/reference.md +861 -0
- package/serialization/resources/folders/client/countFolders.d.ts +9 -0
- package/serialization/resources/folders/client/countFolders.js +41 -0
- package/serialization/resources/folders/client/getAgentsForFolder.d.ts +9 -0
- package/serialization/resources/folders/client/getAgentsForFolder.js +41 -0
- package/serialization/resources/folders/client/getFolderIdByName.d.ts +9 -0
- package/serialization/resources/folders/client/getFolderIdByName.js +41 -0
- package/serialization/resources/folders/client/index.d.ts +7 -0
- package/serialization/resources/folders/client/index.js +46 -0
- package/serialization/resources/folders/client/listFolderFiles.d.ts +11 -0
- package/serialization/resources/folders/client/listFolderFiles.js +42 -0
- package/serialization/resources/folders/client/listFolderPassages.d.ts +11 -0
- package/serialization/resources/folders/client/listFolderPassages.js +42 -0
- package/serialization/resources/folders/client/listFolders.d.ts +11 -0
- package/serialization/resources/folders/client/listFolders.js +42 -0
- package/serialization/resources/folders/client/requests/FolderCreate.d.ts +19 -0
- package/serialization/resources/folders/client/requests/FolderCreate.js +50 -0
- package/serialization/resources/folders/client/requests/FolderUpdate.d.ts +17 -0
- package/serialization/resources/folders/client/requests/FolderUpdate.js +48 -0
- package/serialization/resources/folders/client/requests/index.d.ts +2 -0
- package/serialization/resources/folders/client/requests/index.js +7 -0
- package/serialization/resources/folders/index.d.ts +1 -0
- package/serialization/resources/folders/index.js +17 -0
- package/serialization/resources/index.d.ts +2 -0
- package/serialization/resources/index.js +3 -1
- package/serialization/types/Folder.d.ts +22 -0
- package/serialization/types/Folder.js +53 -0
- package/serialization/types/index.d.ts +1 -0
- package/serialization/types/index.js +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,981 @@
|
|
|
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 () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.Folders = void 0;
|
|
52
|
+
const environments = __importStar(require("../../../../environments"));
|
|
53
|
+
const core = __importStar(require("../../../../core"));
|
|
54
|
+
const Letta = __importStar(require("../../../index"));
|
|
55
|
+
const url_join_1 = __importDefault(require("url-join"));
|
|
56
|
+
const serializers = __importStar(require("../../../../serialization/index"));
|
|
57
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
58
|
+
class Folders {
|
|
59
|
+
constructor(_options = {}) {
|
|
60
|
+
this._options = _options;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Count all data folders created by a user.
|
|
64
|
+
*
|
|
65
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
66
|
+
*
|
|
67
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* await client.folders.countFolders()
|
|
71
|
+
*/
|
|
72
|
+
countFolders(requestOptions) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
76
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, "v1/folders/count"),
|
|
77
|
+
method: "GET",
|
|
78
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
79
|
+
? yield core.Supplier.get(this._options.project)
|
|
80
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
81
|
+
contentType: "application/json",
|
|
82
|
+
requestType: "json",
|
|
83
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
84
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
85
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
86
|
+
});
|
|
87
|
+
if (_response.ok) {
|
|
88
|
+
return serializers.folders.countFolders.Response.parseOrThrow(_response.body, {
|
|
89
|
+
unrecognizedObjectKeys: "passthrough",
|
|
90
|
+
allowUnrecognizedUnionMembers: true,
|
|
91
|
+
allowUnrecognizedEnumValues: true,
|
|
92
|
+
skipValidation: true,
|
|
93
|
+
breadcrumbsPrefix: ["response"],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (_response.error.reason === "status-code") {
|
|
97
|
+
switch (_response.error.statusCode) {
|
|
98
|
+
case 422:
|
|
99
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
100
|
+
unrecognizedObjectKeys: "passthrough",
|
|
101
|
+
allowUnrecognizedUnionMembers: true,
|
|
102
|
+
allowUnrecognizedEnumValues: true,
|
|
103
|
+
skipValidation: true,
|
|
104
|
+
breadcrumbsPrefix: ["response"],
|
|
105
|
+
}));
|
|
106
|
+
default:
|
|
107
|
+
throw new errors.LettaError({
|
|
108
|
+
statusCode: _response.error.statusCode,
|
|
109
|
+
body: _response.error.body,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
switch (_response.error.reason) {
|
|
114
|
+
case "non-json":
|
|
115
|
+
throw new errors.LettaError({
|
|
116
|
+
statusCode: _response.error.statusCode,
|
|
117
|
+
body: _response.error.rawBody,
|
|
118
|
+
});
|
|
119
|
+
case "timeout":
|
|
120
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/count.");
|
|
121
|
+
case "unknown":
|
|
122
|
+
throw new errors.LettaError({
|
|
123
|
+
message: _response.error.errorMessage,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get a folder by ID
|
|
130
|
+
*
|
|
131
|
+
* @param {string} folderId
|
|
132
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
133
|
+
*
|
|
134
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* await client.folders.retrieveFolder("folder_id")
|
|
138
|
+
*/
|
|
139
|
+
retrieveFolder(folderId, requestOptions) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
var _a, _b, _c;
|
|
142
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
143
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}`),
|
|
144
|
+
method: "GET",
|
|
145
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
146
|
+
? yield core.Supplier.get(this._options.project)
|
|
147
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
148
|
+
contentType: "application/json",
|
|
149
|
+
requestType: "json",
|
|
150
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
151
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
152
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
153
|
+
});
|
|
154
|
+
if (_response.ok) {
|
|
155
|
+
return serializers.Folder.parseOrThrow(_response.body, {
|
|
156
|
+
unrecognizedObjectKeys: "passthrough",
|
|
157
|
+
allowUnrecognizedUnionMembers: true,
|
|
158
|
+
allowUnrecognizedEnumValues: true,
|
|
159
|
+
skipValidation: true,
|
|
160
|
+
breadcrumbsPrefix: ["response"],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (_response.error.reason === "status-code") {
|
|
164
|
+
switch (_response.error.statusCode) {
|
|
165
|
+
case 422:
|
|
166
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
167
|
+
unrecognizedObjectKeys: "passthrough",
|
|
168
|
+
allowUnrecognizedUnionMembers: true,
|
|
169
|
+
allowUnrecognizedEnumValues: true,
|
|
170
|
+
skipValidation: true,
|
|
171
|
+
breadcrumbsPrefix: ["response"],
|
|
172
|
+
}));
|
|
173
|
+
default:
|
|
174
|
+
throw new errors.LettaError({
|
|
175
|
+
statusCode: _response.error.statusCode,
|
|
176
|
+
body: _response.error.body,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
switch (_response.error.reason) {
|
|
181
|
+
case "non-json":
|
|
182
|
+
throw new errors.LettaError({
|
|
183
|
+
statusCode: _response.error.statusCode,
|
|
184
|
+
body: _response.error.rawBody,
|
|
185
|
+
});
|
|
186
|
+
case "timeout":
|
|
187
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/{folder_id}.");
|
|
188
|
+
case "unknown":
|
|
189
|
+
throw new errors.LettaError({
|
|
190
|
+
message: _response.error.errorMessage,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Delete a data folder.
|
|
197
|
+
*
|
|
198
|
+
* @param {string} folderId
|
|
199
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
200
|
+
*
|
|
201
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* await client.folders.deleteFolder("folder_id")
|
|
205
|
+
*/
|
|
206
|
+
deleteFolder(folderId, requestOptions) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
var _a, _b, _c;
|
|
209
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
210
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}`),
|
|
211
|
+
method: "DELETE",
|
|
212
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
213
|
+
? yield core.Supplier.get(this._options.project)
|
|
214
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
215
|
+
contentType: "application/json",
|
|
216
|
+
requestType: "json",
|
|
217
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
218
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
219
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
220
|
+
});
|
|
221
|
+
if (_response.ok) {
|
|
222
|
+
return _response.body;
|
|
223
|
+
}
|
|
224
|
+
if (_response.error.reason === "status-code") {
|
|
225
|
+
switch (_response.error.statusCode) {
|
|
226
|
+
case 422:
|
|
227
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
228
|
+
unrecognizedObjectKeys: "passthrough",
|
|
229
|
+
allowUnrecognizedUnionMembers: true,
|
|
230
|
+
allowUnrecognizedEnumValues: true,
|
|
231
|
+
skipValidation: true,
|
|
232
|
+
breadcrumbsPrefix: ["response"],
|
|
233
|
+
}));
|
|
234
|
+
default:
|
|
235
|
+
throw new errors.LettaError({
|
|
236
|
+
statusCode: _response.error.statusCode,
|
|
237
|
+
body: _response.error.body,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
switch (_response.error.reason) {
|
|
242
|
+
case "non-json":
|
|
243
|
+
throw new errors.LettaError({
|
|
244
|
+
statusCode: _response.error.statusCode,
|
|
245
|
+
body: _response.error.rawBody,
|
|
246
|
+
});
|
|
247
|
+
case "timeout":
|
|
248
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling DELETE /v1/folders/{folder_id}.");
|
|
249
|
+
case "unknown":
|
|
250
|
+
throw new errors.LettaError({
|
|
251
|
+
message: _response.error.errorMessage,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Update the name or documentation of an existing data folder.
|
|
258
|
+
*
|
|
259
|
+
* @param {string} folderId
|
|
260
|
+
* @param {Letta.FolderUpdate} request
|
|
261
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
262
|
+
*
|
|
263
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* await client.folders.modifyFolder("folder_id")
|
|
267
|
+
*/
|
|
268
|
+
modifyFolder(folderId_1) {
|
|
269
|
+
return __awaiter(this, arguments, void 0, function* (folderId, request = {}, requestOptions) {
|
|
270
|
+
var _a, _b, _c;
|
|
271
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
272
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}`),
|
|
273
|
+
method: "PATCH",
|
|
274
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
275
|
+
? yield core.Supplier.get(this._options.project)
|
|
276
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
277
|
+
contentType: "application/json",
|
|
278
|
+
requestType: "json",
|
|
279
|
+
body: serializers.FolderUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
280
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
281
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
282
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
283
|
+
});
|
|
284
|
+
if (_response.ok) {
|
|
285
|
+
return serializers.Folder.parseOrThrow(_response.body, {
|
|
286
|
+
unrecognizedObjectKeys: "passthrough",
|
|
287
|
+
allowUnrecognizedUnionMembers: true,
|
|
288
|
+
allowUnrecognizedEnumValues: true,
|
|
289
|
+
skipValidation: true,
|
|
290
|
+
breadcrumbsPrefix: ["response"],
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (_response.error.reason === "status-code") {
|
|
294
|
+
switch (_response.error.statusCode) {
|
|
295
|
+
case 422:
|
|
296
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
297
|
+
unrecognizedObjectKeys: "passthrough",
|
|
298
|
+
allowUnrecognizedUnionMembers: true,
|
|
299
|
+
allowUnrecognizedEnumValues: true,
|
|
300
|
+
skipValidation: true,
|
|
301
|
+
breadcrumbsPrefix: ["response"],
|
|
302
|
+
}));
|
|
303
|
+
default:
|
|
304
|
+
throw new errors.LettaError({
|
|
305
|
+
statusCode: _response.error.statusCode,
|
|
306
|
+
body: _response.error.body,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
switch (_response.error.reason) {
|
|
311
|
+
case "non-json":
|
|
312
|
+
throw new errors.LettaError({
|
|
313
|
+
statusCode: _response.error.statusCode,
|
|
314
|
+
body: _response.error.rawBody,
|
|
315
|
+
});
|
|
316
|
+
case "timeout":
|
|
317
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling PATCH /v1/folders/{folder_id}.");
|
|
318
|
+
case "unknown":
|
|
319
|
+
throw new errors.LettaError({
|
|
320
|
+
message: _response.error.errorMessage,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Get a folder by name
|
|
327
|
+
*
|
|
328
|
+
* @param {string} folderName
|
|
329
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
330
|
+
*
|
|
331
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* await client.folders.getFolderIdByName("folder_name")
|
|
335
|
+
*/
|
|
336
|
+
getFolderIdByName(folderName, requestOptions) {
|
|
337
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
338
|
+
var _a, _b, _c;
|
|
339
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
340
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/name/${encodeURIComponent(folderName)}`),
|
|
341
|
+
method: "GET",
|
|
342
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
343
|
+
? yield core.Supplier.get(this._options.project)
|
|
344
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
345
|
+
contentType: "application/json",
|
|
346
|
+
requestType: "json",
|
|
347
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
348
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
349
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
350
|
+
});
|
|
351
|
+
if (_response.ok) {
|
|
352
|
+
return serializers.folders.getFolderIdByName.Response.parseOrThrow(_response.body, {
|
|
353
|
+
unrecognizedObjectKeys: "passthrough",
|
|
354
|
+
allowUnrecognizedUnionMembers: true,
|
|
355
|
+
allowUnrecognizedEnumValues: true,
|
|
356
|
+
skipValidation: true,
|
|
357
|
+
breadcrumbsPrefix: ["response"],
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (_response.error.reason === "status-code") {
|
|
361
|
+
switch (_response.error.statusCode) {
|
|
362
|
+
case 422:
|
|
363
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
364
|
+
unrecognizedObjectKeys: "passthrough",
|
|
365
|
+
allowUnrecognizedUnionMembers: true,
|
|
366
|
+
allowUnrecognizedEnumValues: true,
|
|
367
|
+
skipValidation: true,
|
|
368
|
+
breadcrumbsPrefix: ["response"],
|
|
369
|
+
}));
|
|
370
|
+
default:
|
|
371
|
+
throw new errors.LettaError({
|
|
372
|
+
statusCode: _response.error.statusCode,
|
|
373
|
+
body: _response.error.body,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
switch (_response.error.reason) {
|
|
378
|
+
case "non-json":
|
|
379
|
+
throw new errors.LettaError({
|
|
380
|
+
statusCode: _response.error.statusCode,
|
|
381
|
+
body: _response.error.rawBody,
|
|
382
|
+
});
|
|
383
|
+
case "timeout":
|
|
384
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/name/{folder_name}.");
|
|
385
|
+
case "unknown":
|
|
386
|
+
throw new errors.LettaError({
|
|
387
|
+
message: _response.error.errorMessage,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get aggregated metadata for all folders in an organization.
|
|
394
|
+
*
|
|
395
|
+
* Returns structured metadata including:
|
|
396
|
+
* - Total number of folders
|
|
397
|
+
* - Total number of files across all folders
|
|
398
|
+
* - Total size of all files
|
|
399
|
+
* - Per-source breakdown with file details (file_name, file_size per file) if include_detailed_per_source_metadata is True
|
|
400
|
+
*
|
|
401
|
+
* @param {Letta.GetFoldersMetadataRequest} request
|
|
402
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
403
|
+
*
|
|
404
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* await client.folders.getFoldersMetadata()
|
|
408
|
+
*/
|
|
409
|
+
getFoldersMetadata() {
|
|
410
|
+
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
411
|
+
var _a, _b, _c;
|
|
412
|
+
const { includeDetailedPerSourceMetadata } = request;
|
|
413
|
+
const _queryParams = {};
|
|
414
|
+
if (includeDetailedPerSourceMetadata != null) {
|
|
415
|
+
_queryParams["include_detailed_per_source_metadata"] = includeDetailedPerSourceMetadata.toString();
|
|
416
|
+
}
|
|
417
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
418
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, "v1/folders/metadata"),
|
|
419
|
+
method: "GET",
|
|
420
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
421
|
+
? yield core.Supplier.get(this._options.project)
|
|
422
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
423
|
+
contentType: "application/json",
|
|
424
|
+
queryParameters: _queryParams,
|
|
425
|
+
requestType: "json",
|
|
426
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
427
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
428
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
429
|
+
});
|
|
430
|
+
if (_response.ok) {
|
|
431
|
+
return serializers.OrganizationSourcesStats.parseOrThrow(_response.body, {
|
|
432
|
+
unrecognizedObjectKeys: "passthrough",
|
|
433
|
+
allowUnrecognizedUnionMembers: true,
|
|
434
|
+
allowUnrecognizedEnumValues: true,
|
|
435
|
+
skipValidation: true,
|
|
436
|
+
breadcrumbsPrefix: ["response"],
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
if (_response.error.reason === "status-code") {
|
|
440
|
+
switch (_response.error.statusCode) {
|
|
441
|
+
case 422:
|
|
442
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
443
|
+
unrecognizedObjectKeys: "passthrough",
|
|
444
|
+
allowUnrecognizedUnionMembers: true,
|
|
445
|
+
allowUnrecognizedEnumValues: true,
|
|
446
|
+
skipValidation: true,
|
|
447
|
+
breadcrumbsPrefix: ["response"],
|
|
448
|
+
}));
|
|
449
|
+
default:
|
|
450
|
+
throw new errors.LettaError({
|
|
451
|
+
statusCode: _response.error.statusCode,
|
|
452
|
+
body: _response.error.body,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
switch (_response.error.reason) {
|
|
457
|
+
case "non-json":
|
|
458
|
+
throw new errors.LettaError({
|
|
459
|
+
statusCode: _response.error.statusCode,
|
|
460
|
+
body: _response.error.rawBody,
|
|
461
|
+
});
|
|
462
|
+
case "timeout":
|
|
463
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/metadata.");
|
|
464
|
+
case "unknown":
|
|
465
|
+
throw new errors.LettaError({
|
|
466
|
+
message: _response.error.errorMessage,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* List all data folders created by a user.
|
|
473
|
+
*
|
|
474
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
475
|
+
*
|
|
476
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* await client.folders.listFolders()
|
|
480
|
+
*/
|
|
481
|
+
listFolders(requestOptions) {
|
|
482
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
483
|
+
var _a, _b, _c;
|
|
484
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
485
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, "v1/folders/"),
|
|
486
|
+
method: "GET",
|
|
487
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
488
|
+
? yield core.Supplier.get(this._options.project)
|
|
489
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
490
|
+
contentType: "application/json",
|
|
491
|
+
requestType: "json",
|
|
492
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
493
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
494
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
495
|
+
});
|
|
496
|
+
if (_response.ok) {
|
|
497
|
+
return serializers.folders.listFolders.Response.parseOrThrow(_response.body, {
|
|
498
|
+
unrecognizedObjectKeys: "passthrough",
|
|
499
|
+
allowUnrecognizedUnionMembers: true,
|
|
500
|
+
allowUnrecognizedEnumValues: true,
|
|
501
|
+
skipValidation: true,
|
|
502
|
+
breadcrumbsPrefix: ["response"],
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (_response.error.reason === "status-code") {
|
|
506
|
+
switch (_response.error.statusCode) {
|
|
507
|
+
case 422:
|
|
508
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
509
|
+
unrecognizedObjectKeys: "passthrough",
|
|
510
|
+
allowUnrecognizedUnionMembers: true,
|
|
511
|
+
allowUnrecognizedEnumValues: true,
|
|
512
|
+
skipValidation: true,
|
|
513
|
+
breadcrumbsPrefix: ["response"],
|
|
514
|
+
}));
|
|
515
|
+
default:
|
|
516
|
+
throw new errors.LettaError({
|
|
517
|
+
statusCode: _response.error.statusCode,
|
|
518
|
+
body: _response.error.body,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
switch (_response.error.reason) {
|
|
523
|
+
case "non-json":
|
|
524
|
+
throw new errors.LettaError({
|
|
525
|
+
statusCode: _response.error.statusCode,
|
|
526
|
+
body: _response.error.rawBody,
|
|
527
|
+
});
|
|
528
|
+
case "timeout":
|
|
529
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/.");
|
|
530
|
+
case "unknown":
|
|
531
|
+
throw new errors.LettaError({
|
|
532
|
+
message: _response.error.errorMessage,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Create a new data folder.
|
|
539
|
+
*
|
|
540
|
+
* @param {Letta.FolderCreate} request
|
|
541
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
542
|
+
*
|
|
543
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* await client.folders.createFolder({
|
|
547
|
+
* name: "name"
|
|
548
|
+
* })
|
|
549
|
+
*/
|
|
550
|
+
createFolder(request, requestOptions) {
|
|
551
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
552
|
+
var _a, _b, _c;
|
|
553
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
554
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, "v1/folders/"),
|
|
555
|
+
method: "POST",
|
|
556
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
557
|
+
? yield core.Supplier.get(this._options.project)
|
|
558
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
559
|
+
contentType: "application/json",
|
|
560
|
+
requestType: "json",
|
|
561
|
+
body: serializers.FolderCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
562
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
563
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
564
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
565
|
+
});
|
|
566
|
+
if (_response.ok) {
|
|
567
|
+
return serializers.Folder.parseOrThrow(_response.body, {
|
|
568
|
+
unrecognizedObjectKeys: "passthrough",
|
|
569
|
+
allowUnrecognizedUnionMembers: true,
|
|
570
|
+
allowUnrecognizedEnumValues: true,
|
|
571
|
+
skipValidation: true,
|
|
572
|
+
breadcrumbsPrefix: ["response"],
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
if (_response.error.reason === "status-code") {
|
|
576
|
+
switch (_response.error.statusCode) {
|
|
577
|
+
case 422:
|
|
578
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
579
|
+
unrecognizedObjectKeys: "passthrough",
|
|
580
|
+
allowUnrecognizedUnionMembers: true,
|
|
581
|
+
allowUnrecognizedEnumValues: true,
|
|
582
|
+
skipValidation: true,
|
|
583
|
+
breadcrumbsPrefix: ["response"],
|
|
584
|
+
}));
|
|
585
|
+
default:
|
|
586
|
+
throw new errors.LettaError({
|
|
587
|
+
statusCode: _response.error.statusCode,
|
|
588
|
+
body: _response.error.body,
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
switch (_response.error.reason) {
|
|
593
|
+
case "non-json":
|
|
594
|
+
throw new errors.LettaError({
|
|
595
|
+
statusCode: _response.error.statusCode,
|
|
596
|
+
body: _response.error.rawBody,
|
|
597
|
+
});
|
|
598
|
+
case "timeout":
|
|
599
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling POST /v1/folders/.");
|
|
600
|
+
case "unknown":
|
|
601
|
+
throw new errors.LettaError({
|
|
602
|
+
message: _response.error.errorMessage,
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Upload a file to a data folder.
|
|
609
|
+
*
|
|
610
|
+
* @param {File | fs.ReadStream | Blob} file
|
|
611
|
+
* @param {string} folderId
|
|
612
|
+
* @param {Letta.BodyUploadFileToFolder} request
|
|
613
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
614
|
+
*
|
|
615
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* await client.folders.uploadFileToFolder(fs.createReadStream("/path/to/your/file"), "folder_id", {})
|
|
619
|
+
*/
|
|
620
|
+
uploadFileToFolder(file, folderId, request, requestOptions) {
|
|
621
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
622
|
+
var _a, _b, _c;
|
|
623
|
+
const _queryParams = {};
|
|
624
|
+
if (request.duplicateHandling != null) {
|
|
625
|
+
_queryParams["duplicate_handling"] = request.duplicateHandling;
|
|
626
|
+
}
|
|
627
|
+
const _request = yield core.newFormData();
|
|
628
|
+
yield _request.appendFile("file", file);
|
|
629
|
+
const _maybeEncodedRequest = yield _request.getRequest();
|
|
630
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
631
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}/upload`),
|
|
632
|
+
method: "POST",
|
|
633
|
+
headers: Object.assign(Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
634
|
+
? yield core.Supplier.get(this._options.project)
|
|
635
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
636
|
+
queryParameters: _queryParams,
|
|
637
|
+
requestType: "file",
|
|
638
|
+
duplex: _maybeEncodedRequest.duplex,
|
|
639
|
+
body: _maybeEncodedRequest.body,
|
|
640
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
641
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
642
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
643
|
+
});
|
|
644
|
+
if (_response.ok) {
|
|
645
|
+
return serializers.FileMetadata.parseOrThrow(_response.body, {
|
|
646
|
+
unrecognizedObjectKeys: "passthrough",
|
|
647
|
+
allowUnrecognizedUnionMembers: true,
|
|
648
|
+
allowUnrecognizedEnumValues: true,
|
|
649
|
+
skipValidation: true,
|
|
650
|
+
breadcrumbsPrefix: ["response"],
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
if (_response.error.reason === "status-code") {
|
|
654
|
+
switch (_response.error.statusCode) {
|
|
655
|
+
case 422:
|
|
656
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
657
|
+
unrecognizedObjectKeys: "passthrough",
|
|
658
|
+
allowUnrecognizedUnionMembers: true,
|
|
659
|
+
allowUnrecognizedEnumValues: true,
|
|
660
|
+
skipValidation: true,
|
|
661
|
+
breadcrumbsPrefix: ["response"],
|
|
662
|
+
}));
|
|
663
|
+
default:
|
|
664
|
+
throw new errors.LettaError({
|
|
665
|
+
statusCode: _response.error.statusCode,
|
|
666
|
+
body: _response.error.body,
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
switch (_response.error.reason) {
|
|
671
|
+
case "non-json":
|
|
672
|
+
throw new errors.LettaError({
|
|
673
|
+
statusCode: _response.error.statusCode,
|
|
674
|
+
body: _response.error.rawBody,
|
|
675
|
+
});
|
|
676
|
+
case "timeout":
|
|
677
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling POST /v1/folders/{folder_id}/upload.");
|
|
678
|
+
case "unknown":
|
|
679
|
+
throw new errors.LettaError({
|
|
680
|
+
message: _response.error.errorMessage,
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Get all agent IDs that have the specified folder attached.
|
|
687
|
+
*
|
|
688
|
+
* @param {string} folderId
|
|
689
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
690
|
+
*
|
|
691
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* await client.folders.getAgentsForFolder("folder_id")
|
|
695
|
+
*/
|
|
696
|
+
getAgentsForFolder(folderId, requestOptions) {
|
|
697
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
698
|
+
var _a, _b, _c;
|
|
699
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
700
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}/agents`),
|
|
701
|
+
method: "GET",
|
|
702
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
703
|
+
? yield core.Supplier.get(this._options.project)
|
|
704
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
705
|
+
contentType: "application/json",
|
|
706
|
+
requestType: "json",
|
|
707
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
708
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
709
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
710
|
+
});
|
|
711
|
+
if (_response.ok) {
|
|
712
|
+
return serializers.folders.getAgentsForFolder.Response.parseOrThrow(_response.body, {
|
|
713
|
+
unrecognizedObjectKeys: "passthrough",
|
|
714
|
+
allowUnrecognizedUnionMembers: true,
|
|
715
|
+
allowUnrecognizedEnumValues: true,
|
|
716
|
+
skipValidation: true,
|
|
717
|
+
breadcrumbsPrefix: ["response"],
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
if (_response.error.reason === "status-code") {
|
|
721
|
+
switch (_response.error.statusCode) {
|
|
722
|
+
case 422:
|
|
723
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
724
|
+
unrecognizedObjectKeys: "passthrough",
|
|
725
|
+
allowUnrecognizedUnionMembers: true,
|
|
726
|
+
allowUnrecognizedEnumValues: true,
|
|
727
|
+
skipValidation: true,
|
|
728
|
+
breadcrumbsPrefix: ["response"],
|
|
729
|
+
}));
|
|
730
|
+
default:
|
|
731
|
+
throw new errors.LettaError({
|
|
732
|
+
statusCode: _response.error.statusCode,
|
|
733
|
+
body: _response.error.body,
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
switch (_response.error.reason) {
|
|
738
|
+
case "non-json":
|
|
739
|
+
throw new errors.LettaError({
|
|
740
|
+
statusCode: _response.error.statusCode,
|
|
741
|
+
body: _response.error.rawBody,
|
|
742
|
+
});
|
|
743
|
+
case "timeout":
|
|
744
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/{folder_id}/agents.");
|
|
745
|
+
case "unknown":
|
|
746
|
+
throw new errors.LettaError({
|
|
747
|
+
message: _response.error.errorMessage,
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* List all passages associated with a data folder.
|
|
754
|
+
*
|
|
755
|
+
* @param {string} folderId
|
|
756
|
+
* @param {Letta.ListFolderPassagesRequest} request
|
|
757
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
758
|
+
*
|
|
759
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* await client.folders.listFolderPassages("folder_id")
|
|
763
|
+
*/
|
|
764
|
+
listFolderPassages(folderId_1) {
|
|
765
|
+
return __awaiter(this, arguments, void 0, function* (folderId, request = {}, requestOptions) {
|
|
766
|
+
var _a, _b, _c;
|
|
767
|
+
const { after, before, limit } = request;
|
|
768
|
+
const _queryParams = {};
|
|
769
|
+
if (after != null) {
|
|
770
|
+
_queryParams["after"] = after;
|
|
771
|
+
}
|
|
772
|
+
if (before != null) {
|
|
773
|
+
_queryParams["before"] = before;
|
|
774
|
+
}
|
|
775
|
+
if (limit != null) {
|
|
776
|
+
_queryParams["limit"] = limit.toString();
|
|
777
|
+
}
|
|
778
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
779
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}/passages`),
|
|
780
|
+
method: "GET",
|
|
781
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
782
|
+
? yield core.Supplier.get(this._options.project)
|
|
783
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
784
|
+
contentType: "application/json",
|
|
785
|
+
queryParameters: _queryParams,
|
|
786
|
+
requestType: "json",
|
|
787
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
788
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
789
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
790
|
+
});
|
|
791
|
+
if (_response.ok) {
|
|
792
|
+
return serializers.folders.listFolderPassages.Response.parseOrThrow(_response.body, {
|
|
793
|
+
unrecognizedObjectKeys: "passthrough",
|
|
794
|
+
allowUnrecognizedUnionMembers: true,
|
|
795
|
+
allowUnrecognizedEnumValues: true,
|
|
796
|
+
skipValidation: true,
|
|
797
|
+
breadcrumbsPrefix: ["response"],
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
if (_response.error.reason === "status-code") {
|
|
801
|
+
switch (_response.error.statusCode) {
|
|
802
|
+
case 422:
|
|
803
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
804
|
+
unrecognizedObjectKeys: "passthrough",
|
|
805
|
+
allowUnrecognizedUnionMembers: true,
|
|
806
|
+
allowUnrecognizedEnumValues: true,
|
|
807
|
+
skipValidation: true,
|
|
808
|
+
breadcrumbsPrefix: ["response"],
|
|
809
|
+
}));
|
|
810
|
+
default:
|
|
811
|
+
throw new errors.LettaError({
|
|
812
|
+
statusCode: _response.error.statusCode,
|
|
813
|
+
body: _response.error.body,
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
switch (_response.error.reason) {
|
|
818
|
+
case "non-json":
|
|
819
|
+
throw new errors.LettaError({
|
|
820
|
+
statusCode: _response.error.statusCode,
|
|
821
|
+
body: _response.error.rawBody,
|
|
822
|
+
});
|
|
823
|
+
case "timeout":
|
|
824
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/{folder_id}/passages.");
|
|
825
|
+
case "unknown":
|
|
826
|
+
throw new errors.LettaError({
|
|
827
|
+
message: _response.error.errorMessage,
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* List paginated files associated with a data folder.
|
|
834
|
+
*
|
|
835
|
+
* @param {string} folderId
|
|
836
|
+
* @param {Letta.ListFolderFilesRequest} request
|
|
837
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
838
|
+
*
|
|
839
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* await client.folders.listFolderFiles("folder_id")
|
|
843
|
+
*/
|
|
844
|
+
listFolderFiles(folderId_1) {
|
|
845
|
+
return __awaiter(this, arguments, void 0, function* (folderId, request = {}, requestOptions) {
|
|
846
|
+
var _a, _b, _c;
|
|
847
|
+
const { limit, after, includeContent } = request;
|
|
848
|
+
const _queryParams = {};
|
|
849
|
+
if (limit != null) {
|
|
850
|
+
_queryParams["limit"] = limit.toString();
|
|
851
|
+
}
|
|
852
|
+
if (after != null) {
|
|
853
|
+
_queryParams["after"] = after;
|
|
854
|
+
}
|
|
855
|
+
if (includeContent != null) {
|
|
856
|
+
_queryParams["include_content"] = includeContent.toString();
|
|
857
|
+
}
|
|
858
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
859
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}/files`),
|
|
860
|
+
method: "GET",
|
|
861
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
862
|
+
? yield core.Supplier.get(this._options.project)
|
|
863
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
864
|
+
contentType: "application/json",
|
|
865
|
+
queryParameters: _queryParams,
|
|
866
|
+
requestType: "json",
|
|
867
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
868
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
869
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
870
|
+
});
|
|
871
|
+
if (_response.ok) {
|
|
872
|
+
return serializers.folders.listFolderFiles.Response.parseOrThrow(_response.body, {
|
|
873
|
+
unrecognizedObjectKeys: "passthrough",
|
|
874
|
+
allowUnrecognizedUnionMembers: true,
|
|
875
|
+
allowUnrecognizedEnumValues: true,
|
|
876
|
+
skipValidation: true,
|
|
877
|
+
breadcrumbsPrefix: ["response"],
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
if (_response.error.reason === "status-code") {
|
|
881
|
+
switch (_response.error.statusCode) {
|
|
882
|
+
case 422:
|
|
883
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
884
|
+
unrecognizedObjectKeys: "passthrough",
|
|
885
|
+
allowUnrecognizedUnionMembers: true,
|
|
886
|
+
allowUnrecognizedEnumValues: true,
|
|
887
|
+
skipValidation: true,
|
|
888
|
+
breadcrumbsPrefix: ["response"],
|
|
889
|
+
}));
|
|
890
|
+
default:
|
|
891
|
+
throw new errors.LettaError({
|
|
892
|
+
statusCode: _response.error.statusCode,
|
|
893
|
+
body: _response.error.body,
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
switch (_response.error.reason) {
|
|
898
|
+
case "non-json":
|
|
899
|
+
throw new errors.LettaError({
|
|
900
|
+
statusCode: _response.error.statusCode,
|
|
901
|
+
body: _response.error.rawBody,
|
|
902
|
+
});
|
|
903
|
+
case "timeout":
|
|
904
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/folders/{folder_id}/files.");
|
|
905
|
+
case "unknown":
|
|
906
|
+
throw new errors.LettaError({
|
|
907
|
+
message: _response.error.errorMessage,
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Delete a file from a folder.
|
|
914
|
+
*
|
|
915
|
+
* @param {string} folderId
|
|
916
|
+
* @param {string} fileId
|
|
917
|
+
* @param {Folders.RequestOptions} requestOptions - Request-specific configuration.
|
|
918
|
+
*
|
|
919
|
+
* @throws {@link Letta.UnprocessableEntityError}
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* await client.folders.deleteFileFromFolder("folder_id", "file_id")
|
|
923
|
+
*/
|
|
924
|
+
deleteFileFromFolder(folderId, fileId, requestOptions) {
|
|
925
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
926
|
+
var _a, _b, _c;
|
|
927
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
928
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.LettaEnvironment.LettaCloud, `v1/folders/${encodeURIComponent(folderId)}/${encodeURIComponent(fileId)}`),
|
|
929
|
+
method: "DELETE",
|
|
930
|
+
headers: Object.assign(Object.assign({ "X-Project": (yield core.Supplier.get(this._options.project)) != null
|
|
931
|
+
? yield core.Supplier.get(this._options.project)
|
|
932
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.161", "User-Agent": "@letta-ai/letta-client/0.1.161", "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),
|
|
933
|
+
contentType: "application/json",
|
|
934
|
+
requestType: "json",
|
|
935
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
936
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
937
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
938
|
+
});
|
|
939
|
+
if (_response.ok) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
if (_response.error.reason === "status-code") {
|
|
943
|
+
switch (_response.error.statusCode) {
|
|
944
|
+
case 422:
|
|
945
|
+
throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
946
|
+
unrecognizedObjectKeys: "passthrough",
|
|
947
|
+
allowUnrecognizedUnionMembers: true,
|
|
948
|
+
allowUnrecognizedEnumValues: true,
|
|
949
|
+
skipValidation: true,
|
|
950
|
+
breadcrumbsPrefix: ["response"],
|
|
951
|
+
}));
|
|
952
|
+
default:
|
|
953
|
+
throw new errors.LettaError({
|
|
954
|
+
statusCode: _response.error.statusCode,
|
|
955
|
+
body: _response.error.body,
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
switch (_response.error.reason) {
|
|
960
|
+
case "non-json":
|
|
961
|
+
throw new errors.LettaError({
|
|
962
|
+
statusCode: _response.error.statusCode,
|
|
963
|
+
body: _response.error.rawBody,
|
|
964
|
+
});
|
|
965
|
+
case "timeout":
|
|
966
|
+
throw new errors.LettaTimeoutError("Timeout exceeded when calling DELETE /v1/folders/{folder_id}/{file_id}.");
|
|
967
|
+
case "unknown":
|
|
968
|
+
throw new errors.LettaError({
|
|
969
|
+
message: _response.error.errorMessage,
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
_getCustomAuthorizationHeaders() {
|
|
975
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
976
|
+
const tokenValue = yield core.Supplier.get(this._options.token);
|
|
977
|
+
return { Authorization: `Bearer ${tokenValue}` };
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
exports.Folders = Folders;
|