@letta-ai/letta-client 0.1.38 → 0.1.39

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 (138) hide show
  1. package/api/resources/agents/client/Client.d.ts +6 -3
  2. package/api/resources/agents/client/Client.js +21 -16
  3. package/api/resources/agents/resources/blocks/client/Client.d.ts +97 -0
  4. package/api/resources/agents/resources/blocks/client/Client.js +400 -0
  5. package/api/resources/agents/resources/blocks/client/index.d.ts +1 -0
  6. package/api/resources/agents/resources/context/client/Client.js +1 -1
  7. package/api/resources/agents/resources/coreMemory/client/Client.d.ts +0 -65
  8. package/api/resources/agents/resources/coreMemory/client/Client.js +1 -332
  9. package/api/resources/agents/resources/index.d.ts +3 -2
  10. package/api/resources/agents/resources/index.js +4 -3
  11. package/api/resources/agents/resources/memoryVariables/client/Client.js +1 -1
  12. package/api/resources/agents/resources/messages/client/Client.js +5 -5
  13. package/api/resources/agents/resources/{archivalMemory → passages}/client/Client.d.ts +14 -14
  14. package/{dist/api/resources/agents/resources/archivalMemory → api/resources/agents/resources/passages}/client/Client.js +15 -15
  15. package/api/resources/agents/resources/{archivalMemory/client/requests/ArchivalMemoryListRequest.d.ts → passages/client/requests/PassagesListRequest.d.ts} +1 -1
  16. package/api/resources/agents/resources/passages/client/requests/index.d.ts +2 -0
  17. package/api/resources/agents/resources/sources/client/Client.js +3 -3
  18. package/api/resources/agents/resources/templates/client/Client.js +3 -3
  19. package/api/resources/agents/resources/tools/client/Client.js +3 -3
  20. package/api/resources/blocks/client/Client.js +6 -6
  21. package/api/resources/health/client/Client.js +1 -1
  22. package/api/resources/identities/client/Client.js +6 -6
  23. package/api/resources/jobs/client/Client.js +4 -4
  24. package/api/resources/models/client/Client.js +2 -2
  25. package/api/resources/providers/client/Client.js +4 -4
  26. package/api/resources/runs/client/Client.js +6 -6
  27. package/api/resources/sources/client/Client.js +6 -6
  28. package/api/resources/sources/resources/files/client/Client.js +3 -3
  29. package/api/resources/sources/resources/passages/client/Client.js +1 -1
  30. package/api/resources/steps/client/Client.js +2 -2
  31. package/api/resources/tag/client/Client.js +1 -1
  32. package/api/resources/templates/client/Client.js +1 -1
  33. package/api/resources/tools/client/Client.js +11 -11
  34. package/dist/api/resources/agents/client/Client.d.ts +6 -3
  35. package/dist/api/resources/agents/client/Client.js +21 -16
  36. package/dist/api/resources/agents/resources/blocks/client/Client.d.ts +97 -0
  37. package/dist/api/resources/agents/resources/blocks/client/Client.js +400 -0
  38. package/dist/api/resources/agents/resources/blocks/client/index.d.ts +1 -0
  39. package/dist/api/resources/agents/resources/blocks/client/index.js +2 -0
  40. package/dist/api/resources/agents/resources/context/client/Client.js +1 -1
  41. package/dist/api/resources/agents/resources/coreMemory/client/Client.d.ts +0 -65
  42. package/dist/api/resources/agents/resources/coreMemory/client/Client.js +1 -332
  43. package/dist/api/resources/agents/resources/index.d.ts +3 -2
  44. package/dist/api/resources/agents/resources/index.js +4 -3
  45. package/dist/api/resources/agents/resources/memoryVariables/client/Client.js +1 -1
  46. package/dist/api/resources/agents/resources/messages/client/Client.js +5 -5
  47. package/dist/api/resources/agents/resources/{archivalMemory → passages}/client/Client.d.ts +14 -14
  48. package/{api/resources/agents/resources/archivalMemory → dist/api/resources/agents/resources/passages}/client/Client.js +15 -15
  49. package/dist/api/resources/agents/resources/{archivalMemory/client/requests/ArchivalMemoryListRequest.d.ts → passages/client/requests/PassagesListRequest.d.ts} +1 -1
  50. package/dist/api/resources/agents/resources/passages/client/requests/index.d.ts +2 -0
  51. package/dist/api/resources/agents/resources/passages/client/requests/index.js +2 -0
  52. package/dist/api/resources/agents/resources/sources/client/Client.js +3 -3
  53. package/dist/api/resources/agents/resources/templates/client/Client.js +3 -3
  54. package/dist/api/resources/agents/resources/tools/client/Client.js +3 -3
  55. package/dist/api/resources/blocks/client/Client.js +6 -6
  56. package/dist/api/resources/health/client/Client.js +1 -1
  57. package/dist/api/resources/identities/client/Client.js +6 -6
  58. package/dist/api/resources/jobs/client/Client.js +4 -4
  59. package/dist/api/resources/models/client/Client.js +2 -2
  60. package/dist/api/resources/providers/client/Client.js +4 -4
  61. package/dist/api/resources/runs/client/Client.js +6 -6
  62. package/dist/api/resources/sources/client/Client.js +6 -6
  63. package/dist/api/resources/sources/resources/files/client/Client.js +3 -3
  64. package/dist/api/resources/sources/resources/passages/client/Client.js +1 -1
  65. package/dist/api/resources/steps/client/Client.js +2 -2
  66. package/dist/api/resources/tag/client/Client.js +1 -1
  67. package/dist/api/resources/templates/client/Client.js +1 -1
  68. package/dist/api/resources/tools/client/Client.js +11 -11
  69. package/dist/serialization/resources/agents/resources/blocks/client/index.d.ts +1 -0
  70. package/dist/serialization/resources/agents/resources/{coreMemory → blocks}/client/index.js +2 -2
  71. package/dist/serialization/resources/agents/resources/{coreMemory/client/listBlocks.d.ts → blocks/client/list.d.ts} +1 -1
  72. package/dist/serialization/resources/agents/resources/index.d.ts +3 -3
  73. package/dist/serialization/resources/agents/resources/index.js +4 -4
  74. package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/create.d.ts +1 -1
  75. package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/list.d.ts +1 -1
  76. package/dist/version.d.ts +1 -1
  77. package/dist/version.js +1 -1
  78. package/package.json +1 -1
  79. package/reference.md +28 -26
  80. package/serialization/resources/agents/resources/blocks/client/index.d.ts +1 -0
  81. package/serialization/resources/agents/resources/{coreMemory → blocks}/client/index.js +2 -2
  82. package/serialization/resources/agents/resources/{coreMemory/client/listBlocks.d.ts → blocks/client/list.d.ts} +1 -1
  83. package/serialization/resources/agents/resources/blocks/index.d.ts +1 -0
  84. package/serialization/resources/agents/resources/blocks/index.js +17 -0
  85. package/serialization/resources/agents/resources/index.d.ts +3 -3
  86. package/serialization/resources/agents/resources/index.js +4 -4
  87. package/serialization/resources/agents/resources/{archivalMemory → passages}/client/create.d.ts +1 -1
  88. package/serialization/resources/agents/resources/{archivalMemory → passages}/client/list.d.ts +1 -1
  89. package/serialization/resources/agents/resources/passages/index.d.ts +1 -0
  90. package/serialization/resources/agents/resources/passages/index.js +17 -0
  91. package/version.d.ts +1 -1
  92. package/version.js +1 -1
  93. package/api/resources/agents/resources/archivalMemory/client/requests/index.d.ts +0 -2
  94. package/dist/api/resources/agents/resources/archivalMemory/client/requests/index.d.ts +0 -2
  95. package/dist/serialization/resources/agents/resources/coreMemory/client/index.d.ts +0 -1
  96. package/serialization/resources/agents/resources/coreMemory/client/index.d.ts +0 -1
  97. /package/api/resources/agents/resources/{archivalMemory/client/requests → blocks/client}/index.js +0 -0
  98. /package/api/resources/agents/resources/{archivalMemory → blocks}/index.d.ts +0 -0
  99. /package/api/resources/agents/resources/{archivalMemory → blocks}/index.js +0 -0
  100. /package/api/resources/agents/resources/{archivalMemory → passages}/client/index.d.ts +0 -0
  101. /package/api/resources/agents/resources/{archivalMemory → passages}/client/index.js +0 -0
  102. /package/api/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.d.ts +0 -0
  103. /package/api/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.js +0 -0
  104. /package/api/resources/agents/resources/{archivalMemory/client/requests/ArchivalMemoryListRequest.js → passages/client/requests/PassagesListRequest.js} +0 -0
  105. /package/{dist/api/resources/agents/resources/archivalMemory → api/resources/agents/resources/passages}/client/requests/index.js +0 -0
  106. /package/{dist/api/resources/agents/resources/archivalMemory → api/resources/agents/resources/passages}/index.d.ts +0 -0
  107. /package/{dist/api/resources/agents/resources/archivalMemory → api/resources/agents/resources/passages}/index.js +0 -0
  108. /package/dist/{serialization/resources/agents/resources/archivalMemory → api/resources/agents/resources/blocks}/index.d.ts +0 -0
  109. /package/dist/{serialization/resources/agents/resources/archivalMemory → api/resources/agents/resources/blocks}/index.js +0 -0
  110. /package/dist/api/resources/agents/resources/{archivalMemory → passages}/client/index.d.ts +0 -0
  111. /package/dist/api/resources/agents/resources/{archivalMemory → passages}/client/index.js +0 -0
  112. /package/dist/api/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.d.ts +0 -0
  113. /package/dist/api/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.js +0 -0
  114. /package/dist/api/resources/agents/resources/{archivalMemory/client/requests/ArchivalMemoryListRequest.js → passages/client/requests/PassagesListRequest.js} +0 -0
  115. /package/dist/{serialization/resources/agents/resources/coreMemory → api/resources/agents/resources/passages}/index.d.ts +0 -0
  116. /package/dist/{serialization/resources/agents/resources/coreMemory → api/resources/agents/resources/passages}/index.js +0 -0
  117. /package/dist/serialization/resources/agents/resources/{coreMemory/client/listBlocks.js → blocks/client/list.js} +0 -0
  118. /package/{serialization/resources/agents/resources/archivalMemory → dist/serialization/resources/agents/resources/blocks}/index.d.ts +0 -0
  119. /package/{serialization/resources/agents/resources/archivalMemory → dist/serialization/resources/agents/resources/blocks}/index.js +0 -0
  120. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/create.js +0 -0
  121. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/index.d.ts +0 -0
  122. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/index.js +0 -0
  123. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/list.js +0 -0
  124. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.d.ts +0 -0
  125. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.js +0 -0
  126. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/index.d.ts +0 -0
  127. /package/dist/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/index.js +0 -0
  128. /package/{serialization/resources/agents/resources/coreMemory → dist/serialization/resources/agents/resources/passages}/index.d.ts +0 -0
  129. /package/{serialization/resources/agents/resources/coreMemory → dist/serialization/resources/agents/resources/passages}/index.js +0 -0
  130. /package/serialization/resources/agents/resources/{coreMemory/client/listBlocks.js → blocks/client/list.js} +0 -0
  131. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/create.js +0 -0
  132. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/index.d.ts +0 -0
  133. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/index.js +0 -0
  134. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/list.js +0 -0
  135. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.d.ts +0 -0
  136. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/CreateArchivalMemory.js +0 -0
  137. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/index.d.ts +0 -0
  138. /package/serialization/resources/agents/resources/{archivalMemory → passages}/client/requests/index.js +0 -0
@@ -8,7 +8,8 @@ import { Context } from "../resources/context/client/Client";
8
8
  import { Tools } from "../resources/tools/client/Client";
9
9
  import { Sources } from "../resources/sources/client/Client";
10
10
  import { CoreMemory } from "../resources/coreMemory/client/Client";
11
- import { ArchivalMemory } from "../resources/archivalMemory/client/Client";
11
+ import { Blocks } from "../resources/blocks/client/Client";
12
+ import { Passages } from "../resources/passages/client/Client";
12
13
  import { Messages } from "../resources/messages/client/Client";
13
14
  import { Templates } from "../resources/templates/client/Client";
14
15
  import { MemoryVariables } from "../resources/memoryVariables/client/Client";
@@ -37,7 +38,8 @@ export declare class Agents {
37
38
  protected _tools: Tools | undefined;
38
39
  protected _sources: Sources | undefined;
39
40
  protected _coreMemory: CoreMemory | undefined;
40
- protected _archivalMemory: ArchivalMemory | undefined;
41
+ protected _blocks: Blocks | undefined;
42
+ protected _passages: Passages | undefined;
41
43
  protected _messages: Messages | undefined;
42
44
  protected _templates: Templates | undefined;
43
45
  protected _memoryVariables: MemoryVariables | undefined;
@@ -46,7 +48,8 @@ export declare class Agents {
46
48
  get tools(): Tools;
47
49
  get sources(): Sources;
48
50
  get coreMemory(): CoreMemory;
49
- get archivalMemory(): ArchivalMemory;
51
+ get blocks(): Blocks;
52
+ get passages(): Passages;
50
53
  get messages(): Messages;
51
54
  get templates(): Templates;
52
55
  get memoryVariables(): MemoryVariables;
@@ -70,10 +70,11 @@ const Client_1 = require("../resources/context/client/Client");
70
70
  const Client_2 = require("../resources/tools/client/Client");
71
71
  const Client_3 = require("../resources/sources/client/Client");
72
72
  const Client_4 = require("../resources/coreMemory/client/Client");
73
- const Client_5 = require("../resources/archivalMemory/client/Client");
74
- const Client_6 = require("../resources/messages/client/Client");
75
- const Client_7 = require("../resources/templates/client/Client");
76
- const Client_8 = require("../resources/memoryVariables/client/Client");
73
+ const Client_5 = require("../resources/blocks/client/Client");
74
+ const Client_6 = require("../resources/passages/client/Client");
75
+ const Client_7 = require("../resources/messages/client/Client");
76
+ const Client_8 = require("../resources/templates/client/Client");
77
+ const Client_9 = require("../resources/memoryVariables/client/Client");
77
78
  class Agents {
78
79
  constructor(_options = {}) {
79
80
  this._options = _options;
@@ -94,21 +95,25 @@ class Agents {
94
95
  var _a;
95
96
  return ((_a = this._coreMemory) !== null && _a !== void 0 ? _a : (this._coreMemory = new Client_4.CoreMemory(this._options)));
96
97
  }
97
- get archivalMemory() {
98
+ get blocks() {
98
99
  var _a;
99
- return ((_a = this._archivalMemory) !== null && _a !== void 0 ? _a : (this._archivalMemory = new Client_5.ArchivalMemory(this._options)));
100
+ return ((_a = this._blocks) !== null && _a !== void 0 ? _a : (this._blocks = new Client_5.Blocks(this._options)));
101
+ }
102
+ get passages() {
103
+ var _a;
104
+ return ((_a = this._passages) !== null && _a !== void 0 ? _a : (this._passages = new Client_6.Passages(this._options)));
100
105
  }
101
106
  get messages() {
102
107
  var _a;
103
- return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_6.Messages(this._options)));
108
+ return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_7.Messages(this._options)));
104
109
  }
105
110
  get templates() {
106
111
  var _a;
107
- return ((_a = this._templates) !== null && _a !== void 0 ? _a : (this._templates = new Client_7.Templates(this._options)));
112
+ return ((_a = this._templates) !== null && _a !== void 0 ? _a : (this._templates = new Client_8.Templates(this._options)));
108
113
  }
109
114
  get memoryVariables() {
110
115
  var _a;
111
- return ((_a = this._memoryVariables) !== null && _a !== void 0 ? _a : (this._memoryVariables = new Client_8.MemoryVariables(this._options)));
116
+ return ((_a = this._memoryVariables) !== null && _a !== void 0 ? _a : (this._memoryVariables = new Client_9.MemoryVariables(this._options)));
112
117
  }
113
118
  /**
114
119
  * List all agents associated with a given user.
@@ -173,7 +178,7 @@ class Agents {
173
178
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
174
179
  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/agents/"),
175
180
  method: "GET",
176
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "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),
181
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
177
182
  contentType: "application/json",
178
183
  queryParameters: _queryParams,
179
184
  requestType: "json",
@@ -240,7 +245,7 @@ class Agents {
240
245
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
241
246
  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/agents/"),
242
247
  method: "POST",
243
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "X-Project": project != null ? project : undefined }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
248
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "X-Project": project != null ? project : undefined }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
244
249
  contentType: "application/json",
245
250
  requestType: "json",
246
251
  body: serializers.CreateAgentRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
@@ -306,7 +311,7 @@ class Agents {
306
311
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
307
312
  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/agents/${encodeURIComponent(agentId)}`),
308
313
  method: "GET",
309
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "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),
314
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
310
315
  contentType: "application/json",
311
316
  requestType: "json",
312
317
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -371,7 +376,7 @@ class Agents {
371
376
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
372
377
  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/agents/${encodeURIComponent(agentId)}`),
373
378
  method: "DELETE",
374
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "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),
379
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
375
380
  contentType: "application/json",
376
381
  requestType: "json",
377
382
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -431,7 +436,7 @@ class Agents {
431
436
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
432
437
  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/agents/${encodeURIComponent(agentId)}`),
433
438
  method: "PATCH",
434
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "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),
439
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
435
440
  contentType: "application/json",
436
441
  requestType: "json",
437
442
  body: serializers.UpdateAgent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -503,7 +508,7 @@ class Agents {
503
508
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
504
509
  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/agents/${encodeURIComponent(agentId)}/reset-messages`),
505
510
  method: "PATCH",
506
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "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),
511
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
507
512
  contentType: "application/json",
508
513
  queryParameters: _queryParams,
509
514
  requestType: "json",
@@ -569,7 +574,7 @@ class Agents {
569
574
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
570
575
  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/agents/search"),
571
576
  method: "POST",
572
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.38", "User-Agent": "@letta-ai/letta-client/0.1.38", "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),
577
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
573
578
  contentType: "application/json",
574
579
  requestType: "json",
575
580
  body: serializers.AgentsSearchRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -0,0 +1,97 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../../../environments";
5
+ import * as core from "../../../../../../core";
6
+ import * as Letta from "../../../../../index";
7
+ export declare namespace Blocks {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.LettaEnvironment | string>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ token?: core.Supplier<string | undefined>;
13
+ fetcher?: core.FetchFunction;
14
+ }
15
+ interface RequestOptions {
16
+ /** The maximum time to wait for a response in seconds. */
17
+ timeoutInSeconds?: number;
18
+ /** The number of times to retry the request. Defaults to 2. */
19
+ maxRetries?: number;
20
+ /** A hook to abort the request. */
21
+ abortSignal?: AbortSignal;
22
+ /** Additional headers to include in the request. */
23
+ headers?: Record<string, string>;
24
+ }
25
+ }
26
+ export declare class Blocks {
27
+ protected readonly _options: Blocks.Options;
28
+ constructor(_options?: Blocks.Options);
29
+ /**
30
+ * Retrieve a memory block from an agent.
31
+ *
32
+ * @param {string} agentId
33
+ * @param {string} blockLabel
34
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
35
+ *
36
+ * @throws {@link Letta.UnprocessableEntityError}
37
+ *
38
+ * @example
39
+ * await client.agents.blocks.retrieve("agent_id", "block_label")
40
+ */
41
+ retrieve(agentId: string, blockLabel: string, requestOptions?: Blocks.RequestOptions): Promise<Letta.Block>;
42
+ /**
43
+ * Updates a memory block of an agent.
44
+ *
45
+ * @param {string} agentId
46
+ * @param {string} blockLabel
47
+ * @param {Letta.BlockUpdate} request
48
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
49
+ *
50
+ * @throws {@link Letta.UnprocessableEntityError}
51
+ *
52
+ * @example
53
+ * await client.agents.blocks.modify("agent_id", "block_label", {})
54
+ */
55
+ modify(agentId: string, blockLabel: string, request: Letta.BlockUpdate, requestOptions?: Blocks.RequestOptions): Promise<Letta.Block>;
56
+ /**
57
+ * Retrieve the memory blocks of a specific agent.
58
+ *
59
+ * @param {string} agentId
60
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
61
+ *
62
+ * @throws {@link Letta.UnprocessableEntityError}
63
+ *
64
+ * @example
65
+ * await client.agents.blocks.list("agent_id")
66
+ */
67
+ list(agentId: string, requestOptions?: Blocks.RequestOptions): Promise<Letta.Block[]>;
68
+ /**
69
+ * Attach a block to an agent.
70
+ *
71
+ * @param {string} agentId
72
+ * @param {string} blockId
73
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
74
+ *
75
+ * @throws {@link Letta.UnprocessableEntityError}
76
+ *
77
+ * @example
78
+ * await client.agents.blocks.attach("agent_id", "block_id")
79
+ */
80
+ attach(agentId: string, blockId: string, requestOptions?: Blocks.RequestOptions): Promise<Letta.AgentState>;
81
+ /**
82
+ * Detach a block from an agent.
83
+ *
84
+ * @param {string} agentId
85
+ * @param {string} blockId
86
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
87
+ *
88
+ * @throws {@link Letta.UnprocessableEntityError}
89
+ *
90
+ * @example
91
+ * await client.agents.blocks.detach("agent_id", "block_id")
92
+ */
93
+ detach(agentId: string, blockId: string, requestOptions?: Blocks.RequestOptions): Promise<Letta.AgentState>;
94
+ protected _getCustomAuthorizationHeaders(): Promise<{
95
+ Authorization: string;
96
+ }>;
97
+ }
@@ -0,0 +1,400 @@
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.Blocks = 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 Blocks {
59
+ constructor(_options = {}) {
60
+ this._options = _options;
61
+ }
62
+ /**
63
+ * Retrieve a memory block from an agent.
64
+ *
65
+ * @param {string} agentId
66
+ * @param {string} blockLabel
67
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
68
+ *
69
+ * @throws {@link Letta.UnprocessableEntityError}
70
+ *
71
+ * @example
72
+ * await client.agents.blocks.retrieve("agent_id", "block_label")
73
+ */
74
+ retrieve(agentId, blockLabel, requestOptions) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ var _a, _b, _c;
77
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
78
+ 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/agents/${encodeURIComponent(agentId)}/core-memory/blocks/${encodeURIComponent(blockLabel)}`),
79
+ method: "GET",
80
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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.Block.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/agents/{agent_id}/core-memory/blocks/{block_label}.");
121
+ case "unknown":
122
+ throw new errors.LettaError({
123
+ message: _response.error.errorMessage,
124
+ });
125
+ }
126
+ });
127
+ }
128
+ /**
129
+ * Updates a memory block of an agent.
130
+ *
131
+ * @param {string} agentId
132
+ * @param {string} blockLabel
133
+ * @param {Letta.BlockUpdate} request
134
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
135
+ *
136
+ * @throws {@link Letta.UnprocessableEntityError}
137
+ *
138
+ * @example
139
+ * await client.agents.blocks.modify("agent_id", "block_label", {})
140
+ */
141
+ modify(agentId, blockLabel, request, requestOptions) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ var _a, _b, _c;
144
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
145
+ 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/agents/${encodeURIComponent(agentId)}/core-memory/blocks/${encodeURIComponent(blockLabel)}`),
146
+ method: "PATCH",
147
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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
+ body: serializers.BlockUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
151
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
152
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
153
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
154
+ });
155
+ if (_response.ok) {
156
+ return serializers.Block.parseOrThrow(_response.body, {
157
+ unrecognizedObjectKeys: "passthrough",
158
+ allowUnrecognizedUnionMembers: true,
159
+ allowUnrecognizedEnumValues: true,
160
+ skipValidation: true,
161
+ breadcrumbsPrefix: ["response"],
162
+ });
163
+ }
164
+ if (_response.error.reason === "status-code") {
165
+ switch (_response.error.statusCode) {
166
+ case 422:
167
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
168
+ unrecognizedObjectKeys: "passthrough",
169
+ allowUnrecognizedUnionMembers: true,
170
+ allowUnrecognizedEnumValues: true,
171
+ skipValidation: true,
172
+ breadcrumbsPrefix: ["response"],
173
+ }));
174
+ default:
175
+ throw new errors.LettaError({
176
+ statusCode: _response.error.statusCode,
177
+ body: _response.error.body,
178
+ });
179
+ }
180
+ }
181
+ switch (_response.error.reason) {
182
+ case "non-json":
183
+ throw new errors.LettaError({
184
+ statusCode: _response.error.statusCode,
185
+ body: _response.error.rawBody,
186
+ });
187
+ case "timeout":
188
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling PATCH /v1/agents/{agent_id}/core-memory/blocks/{block_label}.");
189
+ case "unknown":
190
+ throw new errors.LettaError({
191
+ message: _response.error.errorMessage,
192
+ });
193
+ }
194
+ });
195
+ }
196
+ /**
197
+ * Retrieve the memory blocks of a specific agent.
198
+ *
199
+ * @param {string} agentId
200
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
201
+ *
202
+ * @throws {@link Letta.UnprocessableEntityError}
203
+ *
204
+ * @example
205
+ * await client.agents.blocks.list("agent_id")
206
+ */
207
+ list(agentId, requestOptions) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ var _a, _b, _c;
210
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
211
+ 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/agents/${encodeURIComponent(agentId)}/core-memory/blocks`),
212
+ method: "GET",
213
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
214
+ contentType: "application/json",
215
+ requestType: "json",
216
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
217
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
218
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
219
+ });
220
+ if (_response.ok) {
221
+ return serializers.agents.blocks.list.Response.parseOrThrow(_response.body, {
222
+ unrecognizedObjectKeys: "passthrough",
223
+ allowUnrecognizedUnionMembers: true,
224
+ allowUnrecognizedEnumValues: true,
225
+ skipValidation: true,
226
+ breadcrumbsPrefix: ["response"],
227
+ });
228
+ }
229
+ if (_response.error.reason === "status-code") {
230
+ switch (_response.error.statusCode) {
231
+ case 422:
232
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
233
+ unrecognizedObjectKeys: "passthrough",
234
+ allowUnrecognizedUnionMembers: true,
235
+ allowUnrecognizedEnumValues: true,
236
+ skipValidation: true,
237
+ breadcrumbsPrefix: ["response"],
238
+ }));
239
+ default:
240
+ throw new errors.LettaError({
241
+ statusCode: _response.error.statusCode,
242
+ body: _response.error.body,
243
+ });
244
+ }
245
+ }
246
+ switch (_response.error.reason) {
247
+ case "non-json":
248
+ throw new errors.LettaError({
249
+ statusCode: _response.error.statusCode,
250
+ body: _response.error.rawBody,
251
+ });
252
+ case "timeout":
253
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling GET /v1/agents/{agent_id}/core-memory/blocks.");
254
+ case "unknown":
255
+ throw new errors.LettaError({
256
+ message: _response.error.errorMessage,
257
+ });
258
+ }
259
+ });
260
+ }
261
+ /**
262
+ * Attach a block to an agent.
263
+ *
264
+ * @param {string} agentId
265
+ * @param {string} blockId
266
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
267
+ *
268
+ * @throws {@link Letta.UnprocessableEntityError}
269
+ *
270
+ * @example
271
+ * await client.agents.blocks.attach("agent_id", "block_id")
272
+ */
273
+ attach(agentId, blockId, requestOptions) {
274
+ return __awaiter(this, void 0, void 0, function* () {
275
+ var _a, _b, _c;
276
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
277
+ 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/agents/${encodeURIComponent(agentId)}/core-memory/blocks/attach/${encodeURIComponent(blockId)}`),
278
+ method: "PATCH",
279
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
280
+ contentType: "application/json",
281
+ requestType: "json",
282
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
283
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
284
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
285
+ });
286
+ if (_response.ok) {
287
+ return serializers.AgentState.parseOrThrow(_response.body, {
288
+ unrecognizedObjectKeys: "passthrough",
289
+ allowUnrecognizedUnionMembers: true,
290
+ allowUnrecognizedEnumValues: true,
291
+ skipValidation: true,
292
+ breadcrumbsPrefix: ["response"],
293
+ });
294
+ }
295
+ if (_response.error.reason === "status-code") {
296
+ switch (_response.error.statusCode) {
297
+ case 422:
298
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
299
+ unrecognizedObjectKeys: "passthrough",
300
+ allowUnrecognizedUnionMembers: true,
301
+ allowUnrecognizedEnumValues: true,
302
+ skipValidation: true,
303
+ breadcrumbsPrefix: ["response"],
304
+ }));
305
+ default:
306
+ throw new errors.LettaError({
307
+ statusCode: _response.error.statusCode,
308
+ body: _response.error.body,
309
+ });
310
+ }
311
+ }
312
+ switch (_response.error.reason) {
313
+ case "non-json":
314
+ throw new errors.LettaError({
315
+ statusCode: _response.error.statusCode,
316
+ body: _response.error.rawBody,
317
+ });
318
+ case "timeout":
319
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling PATCH /v1/agents/{agent_id}/core-memory/blocks/attach/{block_id}.");
320
+ case "unknown":
321
+ throw new errors.LettaError({
322
+ message: _response.error.errorMessage,
323
+ });
324
+ }
325
+ });
326
+ }
327
+ /**
328
+ * Detach a block from an agent.
329
+ *
330
+ * @param {string} agentId
331
+ * @param {string} blockId
332
+ * @param {Blocks.RequestOptions} requestOptions - Request-specific configuration.
333
+ *
334
+ * @throws {@link Letta.UnprocessableEntityError}
335
+ *
336
+ * @example
337
+ * await client.agents.blocks.detach("agent_id", "block_id")
338
+ */
339
+ detach(agentId, blockId, requestOptions) {
340
+ return __awaiter(this, void 0, void 0, function* () {
341
+ var _a, _b, _c;
342
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
343
+ 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/agents/${encodeURIComponent(agentId)}/core-memory/blocks/detach/${encodeURIComponent(blockId)}`),
344
+ method: "PATCH",
345
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@letta-ai/letta-client", "X-Fern-SDK-Version": "0.1.39", "User-Agent": "@letta-ai/letta-client/0.1.39", "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),
346
+ contentType: "application/json",
347
+ requestType: "json",
348
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
349
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
350
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
351
+ });
352
+ if (_response.ok) {
353
+ return serializers.AgentState.parseOrThrow(_response.body, {
354
+ unrecognizedObjectKeys: "passthrough",
355
+ allowUnrecognizedUnionMembers: true,
356
+ allowUnrecognizedEnumValues: true,
357
+ skipValidation: true,
358
+ breadcrumbsPrefix: ["response"],
359
+ });
360
+ }
361
+ if (_response.error.reason === "status-code") {
362
+ switch (_response.error.statusCode) {
363
+ case 422:
364
+ throw new Letta.UnprocessableEntityError(serializers.HttpValidationError.parseOrThrow(_response.error.body, {
365
+ unrecognizedObjectKeys: "passthrough",
366
+ allowUnrecognizedUnionMembers: true,
367
+ allowUnrecognizedEnumValues: true,
368
+ skipValidation: true,
369
+ breadcrumbsPrefix: ["response"],
370
+ }));
371
+ default:
372
+ throw new errors.LettaError({
373
+ statusCode: _response.error.statusCode,
374
+ body: _response.error.body,
375
+ });
376
+ }
377
+ }
378
+ switch (_response.error.reason) {
379
+ case "non-json":
380
+ throw new errors.LettaError({
381
+ statusCode: _response.error.statusCode,
382
+ body: _response.error.rawBody,
383
+ });
384
+ case "timeout":
385
+ throw new errors.LettaTimeoutError("Timeout exceeded when calling PATCH /v1/agents/{agent_id}/core-memory/blocks/detach/{block_id}.");
386
+ case "unknown":
387
+ throw new errors.LettaError({
388
+ message: _response.error.errorMessage,
389
+ });
390
+ }
391
+ });
392
+ }
393
+ _getCustomAuthorizationHeaders() {
394
+ return __awaiter(this, void 0, void 0, function* () {
395
+ const tokenValue = yield core.Supplier.get(this._options.token);
396
+ return { Authorization: `Bearer ${tokenValue}` };
397
+ });
398
+ }
399
+ }
400
+ exports.Blocks = Blocks;