@nebula-ai/sdk 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/LICENSE +18 -4
  2. package/README.md +42 -346
  3. package/dist/index.cjs +1268 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +2824 -0
  6. package/dist/index.d.ts +2824 -0
  7. package/dist/index.js +1244 -0
  8. package/dist/index.js.map +1 -0
  9. package/package.json +40 -141
  10. package/CHANGELOG.md +0 -35
  11. package/api-promise.d.mts +0 -2
  12. package/api-promise.d.mts.map +0 -1
  13. package/api-promise.d.ts +0 -2
  14. package/api-promise.d.ts.map +0 -1
  15. package/api-promise.js +0 -6
  16. package/api-promise.js.map +0 -1
  17. package/api-promise.mjs +0 -2
  18. package/api-promise.mjs.map +0 -1
  19. package/client.d.mts +0 -205
  20. package/client.d.mts.map +0 -1
  21. package/client.d.ts +0 -205
  22. package/client.d.ts.map +0 -1
  23. package/client.js +0 -505
  24. package/client.js.map +0 -1
  25. package/client.mjs +0 -501
  26. package/client.mjs.map +0 -1
  27. package/core/api-promise.d.mts +0 -46
  28. package/core/api-promise.d.mts.map +0 -1
  29. package/core/api-promise.d.ts +0 -46
  30. package/core/api-promise.d.ts.map +0 -1
  31. package/core/api-promise.js +0 -74
  32. package/core/api-promise.js.map +0 -1
  33. package/core/api-promise.mjs +0 -70
  34. package/core/api-promise.mjs.map +0 -1
  35. package/core/error.d.mts +0 -46
  36. package/core/error.d.mts.map +0 -1
  37. package/core/error.d.ts +0 -46
  38. package/core/error.d.ts.map +0 -1
  39. package/core/error.js +0 -113
  40. package/core/error.js.map +0 -1
  41. package/core/error.mjs +0 -97
  42. package/core/error.mjs.map +0 -1
  43. package/core/resource.d.mts +0 -6
  44. package/core/resource.d.mts.map +0 -1
  45. package/core/resource.d.ts +0 -6
  46. package/core/resource.d.ts.map +0 -1
  47. package/core/resource.js +0 -11
  48. package/core/resource.js.map +0 -1
  49. package/core/resource.mjs +0 -7
  50. package/core/resource.mjs.map +0 -1
  51. package/core/uploads.d.mts +0 -3
  52. package/core/uploads.d.mts.map +0 -1
  53. package/core/uploads.d.ts +0 -3
  54. package/core/uploads.d.ts.map +0 -1
  55. package/core/uploads.js +0 -6
  56. package/core/uploads.js.map +0 -1
  57. package/core/uploads.mjs +0 -2
  58. package/core/uploads.mjs.map +0 -1
  59. package/error.d.mts +0 -2
  60. package/error.d.mts.map +0 -1
  61. package/error.d.ts +0 -2
  62. package/error.d.ts.map +0 -1
  63. package/error.js +0 -6
  64. package/error.js.map +0 -1
  65. package/error.mjs +0 -2
  66. package/error.mjs.map +0 -1
  67. package/index.d.mts +0 -13
  68. package/index.d.mts.map +0 -1
  69. package/index.d.ts +0 -13
  70. package/index.d.ts.map +0 -1
  71. package/index.js +0 -43
  72. package/index.js.map +0 -1
  73. package/index.mjs +0 -13
  74. package/index.mjs.map +0 -1
  75. package/internal/builtin-types.d.mts +0 -73
  76. package/internal/builtin-types.d.mts.map +0 -1
  77. package/internal/builtin-types.d.ts +0 -73
  78. package/internal/builtin-types.d.ts.map +0 -1
  79. package/internal/builtin-types.js +0 -4
  80. package/internal/builtin-types.js.map +0 -1
  81. package/internal/builtin-types.mjs +0 -3
  82. package/internal/builtin-types.mjs.map +0 -1
  83. package/internal/detect-platform.d.mts +0 -15
  84. package/internal/detect-platform.d.mts.map +0 -1
  85. package/internal/detect-platform.d.ts +0 -15
  86. package/internal/detect-platform.d.ts.map +0 -1
  87. package/internal/detect-platform.js +0 -162
  88. package/internal/detect-platform.js.map +0 -1
  89. package/internal/detect-platform.mjs +0 -157
  90. package/internal/detect-platform.mjs.map +0 -1
  91. package/internal/errors.d.mts +0 -3
  92. package/internal/errors.d.mts.map +0 -1
  93. package/internal/errors.d.ts +0 -3
  94. package/internal/errors.d.ts.map +0 -1
  95. package/internal/errors.js +0 -41
  96. package/internal/errors.js.map +0 -1
  97. package/internal/errors.mjs +0 -36
  98. package/internal/errors.mjs.map +0 -1
  99. package/internal/headers.d.mts +0 -20
  100. package/internal/headers.d.mts.map +0 -1
  101. package/internal/headers.d.ts +0 -20
  102. package/internal/headers.d.ts.map +0 -1
  103. package/internal/headers.js +0 -79
  104. package/internal/headers.js.map +0 -1
  105. package/internal/headers.mjs +0 -74
  106. package/internal/headers.mjs.map +0 -1
  107. package/internal/parse.d.mts +0 -12
  108. package/internal/parse.d.mts.map +0 -1
  109. package/internal/parse.d.ts +0 -12
  110. package/internal/parse.d.ts.map +0 -1
  111. package/internal/parse.js +0 -40
  112. package/internal/parse.js.map +0 -1
  113. package/internal/parse.mjs +0 -37
  114. package/internal/parse.mjs.map +0 -1
  115. package/internal/qs/formats.d.mts +0 -7
  116. package/internal/qs/formats.d.mts.map +0 -1
  117. package/internal/qs/formats.d.ts +0 -7
  118. package/internal/qs/formats.d.ts.map +0 -1
  119. package/internal/qs/formats.js +0 -13
  120. package/internal/qs/formats.js.map +0 -1
  121. package/internal/qs/formats.mjs +0 -9
  122. package/internal/qs/formats.mjs.map +0 -1
  123. package/internal/qs/index.d.mts +0 -10
  124. package/internal/qs/index.d.mts.map +0 -1
  125. package/internal/qs/index.d.ts +0 -10
  126. package/internal/qs/index.d.ts.map +0 -1
  127. package/internal/qs/index.js +0 -14
  128. package/internal/qs/index.js.map +0 -1
  129. package/internal/qs/index.mjs +0 -10
  130. package/internal/qs/index.mjs.map +0 -1
  131. package/internal/qs/stringify.d.mts +0 -3
  132. package/internal/qs/stringify.d.mts.map +0 -1
  133. package/internal/qs/stringify.d.ts +0 -3
  134. package/internal/qs/stringify.d.ts.map +0 -1
  135. package/internal/qs/stringify.js +0 -277
  136. package/internal/qs/stringify.js.map +0 -1
  137. package/internal/qs/stringify.mjs +0 -274
  138. package/internal/qs/stringify.mjs.map +0 -1
  139. package/internal/qs/types.d.mts +0 -57
  140. package/internal/qs/types.d.mts.map +0 -1
  141. package/internal/qs/types.d.ts +0 -57
  142. package/internal/qs/types.d.ts.map +0 -1
  143. package/internal/qs/types.js +0 -3
  144. package/internal/qs/types.js.map +0 -1
  145. package/internal/qs/types.mjs +0 -2
  146. package/internal/qs/types.mjs.map +0 -1
  147. package/internal/qs/utils.d.mts +0 -15
  148. package/internal/qs/utils.d.mts.map +0 -1
  149. package/internal/qs/utils.d.ts +0 -15
  150. package/internal/qs/utils.d.ts.map +0 -1
  151. package/internal/qs/utils.js +0 -230
  152. package/internal/qs/utils.js.map +0 -1
  153. package/internal/qs/utils.mjs +0 -217
  154. package/internal/qs/utils.mjs.map +0 -1
  155. package/internal/request-options.d.mts +0 -79
  156. package/internal/request-options.d.mts.map +0 -1
  157. package/internal/request-options.d.ts +0 -79
  158. package/internal/request-options.d.ts.map +0 -1
  159. package/internal/request-options.js +0 -14
  160. package/internal/request-options.js.map +0 -1
  161. package/internal/request-options.mjs +0 -10
  162. package/internal/request-options.mjs.map +0 -1
  163. package/internal/shim-types.d.mts +0 -17
  164. package/internal/shim-types.d.mts.map +0 -1
  165. package/internal/shim-types.d.ts +0 -17
  166. package/internal/shim-types.d.ts.map +0 -1
  167. package/internal/shim-types.js +0 -4
  168. package/internal/shim-types.js.map +0 -1
  169. package/internal/shim-types.mjs +0 -3
  170. package/internal/shim-types.mjs.map +0 -1
  171. package/internal/shims.d.mts +0 -20
  172. package/internal/shims.d.mts.map +0 -1
  173. package/internal/shims.d.ts +0 -20
  174. package/internal/shims.d.ts.map +0 -1
  175. package/internal/shims.js +0 -92
  176. package/internal/shims.js.map +0 -1
  177. package/internal/shims.mjs +0 -85
  178. package/internal/shims.mjs.map +0 -1
  179. package/internal/to-file.d.mts +0 -45
  180. package/internal/to-file.d.mts.map +0 -1
  181. package/internal/to-file.d.ts +0 -45
  182. package/internal/to-file.d.ts.map +0 -1
  183. package/internal/to-file.js +0 -91
  184. package/internal/to-file.js.map +0 -1
  185. package/internal/to-file.mjs +0 -88
  186. package/internal/to-file.mjs.map +0 -1
  187. package/internal/tslib.js +0 -81
  188. package/internal/tslib.mjs +0 -17
  189. package/internal/types.d.mts +0 -69
  190. package/internal/types.d.mts.map +0 -1
  191. package/internal/types.d.ts +0 -69
  192. package/internal/types.d.ts.map +0 -1
  193. package/internal/types.js +0 -4
  194. package/internal/types.js.map +0 -1
  195. package/internal/types.mjs +0 -3
  196. package/internal/types.mjs.map +0 -1
  197. package/internal/uploads.d.mts +0 -42
  198. package/internal/uploads.d.mts.map +0 -1
  199. package/internal/uploads.d.ts +0 -42
  200. package/internal/uploads.d.ts.map +0 -1
  201. package/internal/uploads.js +0 -141
  202. package/internal/uploads.js.map +0 -1
  203. package/internal/uploads.mjs +0 -131
  204. package/internal/uploads.mjs.map +0 -1
  205. package/internal/utils/base64.d.mts +0 -3
  206. package/internal/utils/base64.d.mts.map +0 -1
  207. package/internal/utils/base64.d.ts +0 -3
  208. package/internal/utils/base64.d.ts.map +0 -1
  209. package/internal/utils/base64.js +0 -38
  210. package/internal/utils/base64.js.map +0 -1
  211. package/internal/utils/base64.mjs +0 -33
  212. package/internal/utils/base64.mjs.map +0 -1
  213. package/internal/utils/bytes.d.mts +0 -4
  214. package/internal/utils/bytes.d.mts.map +0 -1
  215. package/internal/utils/bytes.d.ts +0 -4
  216. package/internal/utils/bytes.d.ts.map +0 -1
  217. package/internal/utils/bytes.js +0 -31
  218. package/internal/utils/bytes.js.map +0 -1
  219. package/internal/utils/bytes.mjs +0 -26
  220. package/internal/utils/bytes.mjs.map +0 -1
  221. package/internal/utils/env.d.mts +0 -9
  222. package/internal/utils/env.d.mts.map +0 -1
  223. package/internal/utils/env.d.ts +0 -9
  224. package/internal/utils/env.d.ts.map +0 -1
  225. package/internal/utils/env.js +0 -22
  226. package/internal/utils/env.js.map +0 -1
  227. package/internal/utils/env.mjs +0 -18
  228. package/internal/utils/env.mjs.map +0 -1
  229. package/internal/utils/log.d.mts +0 -37
  230. package/internal/utils/log.d.mts.map +0 -1
  231. package/internal/utils/log.d.ts +0 -37
  232. package/internal/utils/log.d.ts.map +0 -1
  233. package/internal/utils/log.js +0 -86
  234. package/internal/utils/log.js.map +0 -1
  235. package/internal/utils/log.mjs +0 -80
  236. package/internal/utils/log.mjs.map +0 -1
  237. package/internal/utils/path.d.mts +0 -15
  238. package/internal/utils/path.d.mts.map +0 -1
  239. package/internal/utils/path.d.ts +0 -15
  240. package/internal/utils/path.d.ts.map +0 -1
  241. package/internal/utils/path.js +0 -79
  242. package/internal/utils/path.js.map +0 -1
  243. package/internal/utils/path.mjs +0 -74
  244. package/internal/utils/path.mjs.map +0 -1
  245. package/internal/utils/query.d.mts +0 -2
  246. package/internal/utils/query.d.mts.map +0 -1
  247. package/internal/utils/query.d.ts +0 -2
  248. package/internal/utils/query.d.ts.map +0 -1
  249. package/internal/utils/query.js +0 -10
  250. package/internal/utils/query.js.map +0 -1
  251. package/internal/utils/query.mjs +0 -6
  252. package/internal/utils/query.mjs.map +0 -1
  253. package/internal/utils/sleep.d.mts +0 -2
  254. package/internal/utils/sleep.d.mts.map +0 -1
  255. package/internal/utils/sleep.d.ts +0 -2
  256. package/internal/utils/sleep.d.ts.map +0 -1
  257. package/internal/utils/sleep.js +0 -7
  258. package/internal/utils/sleep.js.map +0 -1
  259. package/internal/utils/sleep.mjs +0 -3
  260. package/internal/utils/sleep.mjs.map +0 -1
  261. package/internal/utils/uuid.d.mts +0 -5
  262. package/internal/utils/uuid.d.mts.map +0 -1
  263. package/internal/utils/uuid.d.ts +0 -5
  264. package/internal/utils/uuid.d.ts.map +0 -1
  265. package/internal/utils/uuid.js +0 -19
  266. package/internal/utils/uuid.js.map +0 -1
  267. package/internal/utils/uuid.mjs +0 -15
  268. package/internal/utils/uuid.mjs.map +0 -1
  269. package/internal/utils/values.d.mts +0 -18
  270. package/internal/utils/values.d.mts.map +0 -1
  271. package/internal/utils/values.d.ts +0 -18
  272. package/internal/utils/values.d.ts.map +0 -1
  273. package/internal/utils/values.js +0 -112
  274. package/internal/utils/values.js.map +0 -1
  275. package/internal/utils/values.mjs +0 -94
  276. package/internal/utils/values.mjs.map +0 -1
  277. package/internal/utils.d.mts +0 -8
  278. package/internal/utils.d.mts.map +0 -1
  279. package/internal/utils.d.ts +0 -8
  280. package/internal/utils.d.ts.map +0 -1
  281. package/internal/utils.js +0 -12
  282. package/internal/utils.js.map +0 -1
  283. package/internal/utils.mjs +0 -9
  284. package/internal/utils.mjs.map +0 -1
  285. package/lib/dx.d.mts +0 -96
  286. package/lib/dx.d.mts.map +0 -1
  287. package/lib/dx.d.ts +0 -96
  288. package/lib/dx.d.ts.map +0 -1
  289. package/lib/dx.js +0 -239
  290. package/lib/dx.js.map +0 -1
  291. package/lib/dx.mjs +0 -235
  292. package/lib/dx.mjs.map +0 -1
  293. package/resource.d.mts +0 -2
  294. package/resource.d.mts.map +0 -1
  295. package/resource.d.ts +0 -2
  296. package/resource.d.ts.map +0 -1
  297. package/resource.js +0 -6
  298. package/resource.js.map +0 -1
  299. package/resource.mjs +0 -2
  300. package/resource.mjs.map +0 -1
  301. package/resources/collections.d.mts +0 -289
  302. package/resources/collections.d.mts.map +0 -1
  303. package/resources/collections.d.ts +0 -289
  304. package/resources/collections.d.ts.map +0 -1
  305. package/resources/collections.js +0 -72
  306. package/resources/collections.js.map +0 -1
  307. package/resources/collections.mjs +0 -68
  308. package/resources/collections.mjs.map +0 -1
  309. package/resources/connectors.d.mts +0 -148
  310. package/resources/connectors.d.mts.map +0 -1
  311. package/resources/connectors.d.ts +0 -148
  312. package/resources/connectors.d.ts.map +0 -1
  313. package/resources/connectors.js +0 -50
  314. package/resources/connectors.js.map +0 -1
  315. package/resources/connectors.mjs +0 -46
  316. package/resources/connectors.mjs.map +0 -1
  317. package/resources/index.d.mts +0 -6
  318. package/resources/index.d.mts.map +0 -1
  319. package/resources/index.d.ts +0 -6
  320. package/resources/index.d.ts.map +0 -1
  321. package/resources/index.js +0 -13
  322. package/resources/index.js.map +0 -1
  323. package/resources/index.mjs +0 -6
  324. package/resources/index.mjs.map +0 -1
  325. package/resources/memories.d.mts +0 -1737
  326. package/resources/memories.d.mts.map +0 -1
  327. package/resources/memories.d.ts +0 -1737
  328. package/resources/memories.d.ts.map +0 -1
  329. package/resources/memories.js +0 -157
  330. package/resources/memories.js.map +0 -1
  331. package/resources/memories.mjs +0 -153
  332. package/resources/memories.mjs.map +0 -1
  333. package/resources/snapshots.d.mts +0 -281
  334. package/resources/snapshots.d.mts.map +0 -1
  335. package/resources/snapshots.d.ts +0 -281
  336. package/resources/snapshots.d.ts.map +0 -1
  337. package/resources/snapshots.js +0 -22
  338. package/resources/snapshots.js.map +0 -1
  339. package/resources/snapshots.mjs +0 -18
  340. package/resources/snapshots.mjs.map +0 -1
  341. package/resources/top-level.d.mts +0 -14
  342. package/resources/top-level.d.mts.map +0 -1
  343. package/resources/top-level.d.ts +0 -14
  344. package/resources/top-level.d.ts.map +0 -1
  345. package/resources/top-level.js +0 -4
  346. package/resources/top-level.js.map +0 -1
  347. package/resources/top-level.mjs +0 -3
  348. package/resources/top-level.mjs.map +0 -1
  349. package/resources.d.mts +0 -2
  350. package/resources.d.mts.map +0 -1
  351. package/resources.d.ts +0 -2
  352. package/resources.d.ts.map +0 -1
  353. package/resources.js +0 -5
  354. package/resources.js.map +0 -1
  355. package/resources.mjs +0 -2
  356. package/resources.mjs.map +0 -1
  357. package/src/api-promise.ts +0 -2
  358. package/src/client.ts +0 -892
  359. package/src/core/README.md +0 -3
  360. package/src/core/api-promise.ts +0 -92
  361. package/src/core/error.ts +0 -130
  362. package/src/core/resource.ts +0 -11
  363. package/src/core/uploads.ts +0 -2
  364. package/src/error.ts +0 -2
  365. package/src/index.ts +0 -36
  366. package/src/internal/README.md +0 -3
  367. package/src/internal/builtin-types.ts +0 -93
  368. package/src/internal/detect-platform.ts +0 -196
  369. package/src/internal/errors.ts +0 -33
  370. package/src/internal/headers.ts +0 -97
  371. package/src/internal/parse.ts +0 -56
  372. package/src/internal/qs/LICENSE.md +0 -13
  373. package/src/internal/qs/README.md +0 -3
  374. package/src/internal/qs/formats.ts +0 -10
  375. package/src/internal/qs/index.ts +0 -13
  376. package/src/internal/qs/stringify.ts +0 -385
  377. package/src/internal/qs/types.ts +0 -71
  378. package/src/internal/qs/utils.ts +0 -265
  379. package/src/internal/request-options.ts +0 -93
  380. package/src/internal/shim-types.ts +0 -26
  381. package/src/internal/shims.ts +0 -107
  382. package/src/internal/to-file.ts +0 -154
  383. package/src/internal/types.ts +0 -95
  384. package/src/internal/uploads.ts +0 -187
  385. package/src/internal/utils/base64.ts +0 -40
  386. package/src/internal/utils/bytes.ts +0 -32
  387. package/src/internal/utils/env.ts +0 -18
  388. package/src/internal/utils/log.ts +0 -127
  389. package/src/internal/utils/path.ts +0 -88
  390. package/src/internal/utils/query.ts +0 -7
  391. package/src/internal/utils/sleep.ts +0 -3
  392. package/src/internal/utils/uuid.ts +0 -17
  393. package/src/internal/utils/values.ts +0 -105
  394. package/src/internal/utils.ts +0 -9
  395. package/src/lib/.keep +0 -4
  396. package/src/lib/dx.ts +0 -459
  397. package/src/resource.ts +0 -2
  398. package/src/resources/collections.ts +0 -474
  399. package/src/resources/connectors.ts +0 -236
  400. package/src/resources/index.ts +0 -56
  401. package/src/resources/memories.ts +0 -2409
  402. package/src/resources/snapshots.ts +0 -387
  403. package/src/resources/top-level.ts +0 -19
  404. package/src/resources.ts +0 -1
  405. package/src/tsconfig.json +0 -11
  406. package/src/uploads.ts +0 -2
  407. package/src/version.ts +0 -1
  408. package/uploads.d.mts +0 -2
  409. package/uploads.d.mts.map +0 -1
  410. package/uploads.d.ts +0 -2
  411. package/uploads.d.ts.map +0 -1
  412. package/uploads.js +0 -6
  413. package/uploads.js.map +0 -1
  414. package/uploads.mjs +0 -2
  415. package/uploads.mjs.map +0 -1
  416. package/version.d.mts +0 -2
  417. package/version.d.mts.map +0 -1
  418. package/version.d.ts +0 -2
  419. package/version.d.ts.map +0 -1
  420. package/version.js +0 -5
  421. package/version.js.map +0 -1
  422. package/version.mjs +0 -2
  423. package/version.mjs.map +0 -1
package/dist/index.js ADDED
@@ -0,0 +1,1244 @@
1
+ //#region src/runtime/errors.ts
2
+ var NebulaError = class extends Error {
3
+ name = "NebulaError";
4
+ constructor(message, options) {
5
+ super(message, options);
6
+ }
7
+ };
8
+ var NebulaConnectionError = class extends NebulaError {
9
+ name = "NebulaConnectionError";
10
+ };
11
+ var NebulaTimeoutError = class extends NebulaError {
12
+ name = "NebulaTimeoutError";
13
+ };
14
+ function isEnvelope(body) {
15
+ return typeof body === "object" && body !== null && typeof body.type === "string" && typeof body.message === "string";
16
+ }
17
+ var NebulaAPIError = class extends NebulaError {
18
+ name = "NebulaAPIError";
19
+ status;
20
+ requestId;
21
+ body;
22
+ type;
23
+ code;
24
+ details;
25
+ constructor(payload, message) {
26
+ const envelope = isEnvelope(payload.body) ? payload.body : void 0;
27
+ super(message ?? envelope?.message ?? `Nebula API error (status ${payload.status})`);
28
+ this.status = payload.status;
29
+ const envCode = typeof envelope?.code === "string" ? envelope.code : void 0;
30
+ const envRid = typeof envelope?.request_id === "string" ? envelope.request_id : void 0;
31
+ this.requestId = envRid ?? payload.requestId;
32
+ this.body = payload.body;
33
+ this.type = envelope?.type;
34
+ this.code = envCode;
35
+ this.details = envelope?.details ?? void 0;
36
+ }
37
+ };
38
+ var NebulaBadRequestError = class extends NebulaAPIError {
39
+ name = "NebulaBadRequestError";
40
+ };
41
+ var NebulaUnauthorizedError = class extends NebulaAPIError {
42
+ name = "NebulaUnauthorizedError";
43
+ };
44
+ var NebulaForbiddenError = class extends NebulaAPIError {
45
+ name = "NebulaForbiddenError";
46
+ };
47
+ var NebulaNotFoundError = class extends NebulaAPIError {
48
+ name = "NebulaNotFoundError";
49
+ };
50
+ var NebulaConflictError = class extends NebulaAPIError {
51
+ name = "NebulaConflictError";
52
+ };
53
+ var NebulaValidationError = class extends NebulaAPIError {
54
+ name = "NebulaValidationError";
55
+ };
56
+ var NebulaRateLimitError = class extends NebulaAPIError {
57
+ name = "NebulaRateLimitError";
58
+ retryAfter;
59
+ constructor(payload, retryAfter) {
60
+ super(payload);
61
+ this.retryAfter = retryAfter;
62
+ }
63
+ };
64
+ var NebulaServerError = class extends NebulaAPIError {
65
+ name = "NebulaServerError";
66
+ };
67
+ const STATUS_TO_CLASS = {
68
+ 400: NebulaBadRequestError,
69
+ 401: NebulaUnauthorizedError,
70
+ 403: NebulaForbiddenError,
71
+ 404: NebulaNotFoundError,
72
+ 409: NebulaConflictError,
73
+ 422: NebulaValidationError
74
+ };
75
+ function errorFromResponse(payload, retryAfter) {
76
+ if (payload.status === 429) return new NebulaRateLimitError(payload, retryAfter);
77
+ const cls = STATUS_TO_CLASS[payload.status];
78
+ if (cls) return new cls(payload);
79
+ if (payload.status >= 500) return new NebulaServerError(payload);
80
+ return new NebulaAPIError(payload);
81
+ }
82
+ //#endregion
83
+ //#region src/runtime/retry.ts
84
+ const DEFAULT_RETRY = {
85
+ maxRetries: 2,
86
+ baseMs: 250,
87
+ maxMs: 8e3
88
+ };
89
+ const RETRYABLE_STATUSES = new Set([
90
+ 408,
91
+ 429,
92
+ 502,
93
+ 503,
94
+ 504
95
+ ]);
96
+ function isRetryableStatus(status) {
97
+ return RETRYABLE_STATUSES.has(status);
98
+ }
99
+ function backoffMs(attempt, policy, retryAfterSec) {
100
+ if (retryAfterSec != null && Number.isFinite(retryAfterSec)) return Math.min(retryAfterSec * 1e3, policy.maxMs);
101
+ const exp = Math.min(policy.baseMs * 2 ** attempt, policy.maxMs);
102
+ return Math.floor(Math.random() * exp);
103
+ }
104
+ function sleep(ms, signal) {
105
+ if (ms <= 0) return Promise.resolve();
106
+ return new Promise((resolveSleep, reject) => {
107
+ const handle = setTimeout(resolveSleep, ms);
108
+ if (signal) {
109
+ const onAbort = () => {
110
+ clearTimeout(handle);
111
+ reject(signal.reason ?? /* @__PURE__ */ new Error("aborted"));
112
+ };
113
+ if (signal.aborted) onAbort();
114
+ else signal.addEventListener("abort", onAbort, { once: true });
115
+ }
116
+ });
117
+ }
118
+ //#endregion
119
+ //#region src/runtime/client.ts
120
+ const DEFAULT_BASE_URL = "https://api.zeroset.com";
121
+ const DEFAULT_TIMEOUT_MS = 6e4;
122
+ var NebulaCore = class {
123
+ baseUrl;
124
+ apiKey;
125
+ bearerToken;
126
+ defaultHeaders;
127
+ fetchImpl;
128
+ fetchOptions;
129
+ timeoutMs;
130
+ retry;
131
+ userAgent;
132
+ constructor(options = {}) {
133
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
134
+ this.apiKey = options.apiKey;
135
+ this.bearerToken = options.bearerToken;
136
+ this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);
137
+ this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
138
+ this.fetchOptions = options.fetchOptions ?? {};
139
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
140
+ this.retry = {
141
+ ...DEFAULT_RETRY,
142
+ ...options.retry ?? {}
143
+ };
144
+ this.userAgent = options.userAgent ?? "nebula-sdk-js/0.0.1";
145
+ }
146
+ buildUrl(path, pathParams, query) {
147
+ let resolved = path;
148
+ if (pathParams) for (const [k, v] of Object.entries(pathParams)) resolved = resolved.replace(`{${k}}`, encodeURIComponent(String(v)));
149
+ const url = new URL(this.baseUrl + resolved);
150
+ if (query) for (const [k, v] of Object.entries(query)) {
151
+ if (v === void 0 || v === null) continue;
152
+ if (Array.isArray(v)) for (const item of v) url.searchParams.append(k, String(item));
153
+ else url.searchParams.set(k, String(v));
154
+ }
155
+ return url.toString();
156
+ }
157
+ buildHeaders(perRequest, hasBody = false) {
158
+ const headers = new Headers(this.defaultHeaders);
159
+ headers.set("User-Agent", this.userAgent);
160
+ headers.set("Accept", "application/json");
161
+ if (hasBody) headers.set("Content-Type", "application/json");
162
+ if (this.apiKey) headers.set("X-API-Key", this.apiKey);
163
+ if (this.bearerToken) headers.set("Authorization", `Bearer ${this.bearerToken}`);
164
+ if (perRequest) for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);
165
+ return headers;
166
+ }
167
+ async request(args) {
168
+ const url = this.buildUrl(args.path, args.pathParams, args.query);
169
+ const hasBody = args.body !== void 0 && args.body !== null;
170
+ const headers = this.buildHeaders(args.headers, hasBody);
171
+ const init = {
172
+ ...this.fetchOptions,
173
+ method: args.method,
174
+ headers,
175
+ body: hasBody ? JSON.stringify(args.body) : void 0
176
+ };
177
+ const maxAttempts = args.idempotent ?? false ? this.retry.maxRetries + 1 : 1;
178
+ let lastError;
179
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
180
+ const controller = new AbortController();
181
+ const timeoutHandle = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("timeout")), this.timeoutMs);
182
+ const { signal: composedSignal, dispose: disposeAbort } = composeAbort(controller.signal, args.signal);
183
+ try {
184
+ const response = await this.fetchImpl(url, {
185
+ ...init,
186
+ signal: composedSignal
187
+ });
188
+ if (response.ok) {
189
+ if (response.status === 204) return void 0;
190
+ return await response.json();
191
+ }
192
+ const text = await safeReadText(response);
193
+ const parsed = safeParseJSON(text);
194
+ const retryAfter = parseRetryAfter(response.headers.get("Retry-After"));
195
+ const err = errorFromResponse({
196
+ status: response.status,
197
+ requestId: response.headers.get("X-Request-Id") ?? void 0,
198
+ body: parsed ?? text
199
+ }, retryAfter);
200
+ if (isRetryableStatus(response.status) && attempt + 1 < maxAttempts) {
201
+ await sleep(backoffMs(attempt, this.retry, retryAfter), args.signal);
202
+ lastError = err;
203
+ continue;
204
+ }
205
+ throw err;
206
+ } catch (rawError) {
207
+ if (rawError instanceof Error && rawError.name === "AbortError") {
208
+ if (args.signal?.aborted) throw rawError;
209
+ throw new NebulaTimeoutError(`Request timed out after ${this.timeoutMs}ms`, { cause: rawError });
210
+ }
211
+ if (rawError instanceof NebulaAPIError || rawError instanceof NebulaConnectionError) throw rawError;
212
+ if (attempt + 1 < maxAttempts) {
213
+ await sleep(backoffMs(attempt, this.retry), args.signal);
214
+ lastError = rawError;
215
+ continue;
216
+ }
217
+ if (rawError instanceof Error) throw new NebulaConnectionError(rawError.message, { cause: rawError });
218
+ throw rawError;
219
+ } finally {
220
+ clearTimeout(timeoutHandle);
221
+ disposeAbort();
222
+ }
223
+ }
224
+ throw lastError ?? new NebulaConnectionError("retry budget exhausted");
225
+ }
226
+ };
227
+ function composeAbort(timeoutSignal, userSignal) {
228
+ if (!userSignal) return {
229
+ signal: timeoutSignal,
230
+ dispose: () => {}
231
+ };
232
+ const controller = new AbortController();
233
+ const onTimeoutAbort = () => controller.abort(timeoutSignal.reason ?? /* @__PURE__ */ new Error("aborted"));
234
+ const onUserAbort = () => controller.abort(userSignal.reason ?? /* @__PURE__ */ new Error("aborted"));
235
+ if (timeoutSignal.aborted) controller.abort(timeoutSignal.reason);
236
+ if (userSignal.aborted) controller.abort(userSignal.reason);
237
+ timeoutSignal.addEventListener("abort", onTimeoutAbort, { once: true });
238
+ userSignal.addEventListener("abort", onUserAbort, { once: true });
239
+ const dispose = () => {
240
+ timeoutSignal.removeEventListener("abort", onTimeoutAbort);
241
+ userSignal.removeEventListener("abort", onUserAbort);
242
+ };
243
+ return {
244
+ signal: controller.signal,
245
+ dispose
246
+ };
247
+ }
248
+ async function safeReadText(response) {
249
+ try {
250
+ return await response.text();
251
+ } catch {
252
+ return "";
253
+ }
254
+ }
255
+ function safeParseJSON(text) {
256
+ if (!text) return void 0;
257
+ try {
258
+ return JSON.parse(text);
259
+ } catch {
260
+ return;
261
+ }
262
+ }
263
+ function filterNullishHeaders(headers) {
264
+ if (!headers) return {};
265
+ const out = {};
266
+ for (const [k, v] of Object.entries(headers)) if (v !== null && v !== void 0) out[k] = v;
267
+ return out;
268
+ }
269
+ function parseRetryAfter(header) {
270
+ if (!header) return void 0;
271
+ const asNumber = Number.parseFloat(header);
272
+ if (Number.isFinite(asNumber)) return asNumber;
273
+ const asDate = Date.parse(header);
274
+ if (Number.isFinite(asDate)) return Math.max(0, (asDate - Date.now()) / 1e3);
275
+ }
276
+ //#endregion
277
+ //#region src/resources/client.ts
278
+ var ClientResource = class {
279
+ core;
280
+ constructor(core) {
281
+ this.core = core;
282
+ }
283
+ /**
284
+ *
285
+ * Health probe
286
+ *
287
+ * Lightweight liveness probe. Returns a 200 with a fixed message when the API process is up. Does not verify downstream dependencies (database, storage, workers) — use the internal status endpoints for those.
288
+ * @operationId client.health
289
+ * @endpoint GET /v1/health
290
+ */
291
+ async health(options) {
292
+ return this.core.request({
293
+ method: "GET",
294
+ path: "/v1/health",
295
+ pathParams: {},
296
+ query: void 0,
297
+ idempotent: true,
298
+ signal: options?.signal
299
+ });
300
+ }
301
+ };
302
+ //#endregion
303
+ //#region src/resources/collections.ts
304
+ var CollectionsResource = class {
305
+ core;
306
+ constructor(core) {
307
+ this.core = core;
308
+ }
309
+ /**
310
+ *
311
+ * Create a new collection
312
+ *
313
+ * Create a new collection and automatically add the creating user
314
+ * to it.
315
+ *
316
+ * This endpoint allows authenticated users to create a new collection
317
+ * with a specified name and optional description. The user creating
318
+ * the collection is automatically added as a member.
319
+ * @operationId collections.create
320
+ * @endpoint POST /v1/collections
321
+ */
322
+ async create(params, options) {
323
+ return this.core.request({
324
+ method: "POST",
325
+ path: "/v1/collections",
326
+ pathParams: {},
327
+ query: void 0,
328
+ body: params.body,
329
+ idempotent: false,
330
+ signal: options?.signal
331
+ });
332
+ }
333
+ /**
334
+ *
335
+ * Delete collection
336
+ *
337
+ * Delete an existing collection.
338
+ *
339
+ * This endpoint allows deletion of a collection identified by its
340
+ * UUID. The user must have appropriate permissions to delete the
341
+ * collection. Deleting a collection removes all associations but does
342
+ * not delete the engrams within it.
343
+ * @operationId collections.delete
344
+ * @endpoint DELETE /v1/collections/{id}
345
+ */
346
+ async delete(id, options) {
347
+ return this.core.request({
348
+ method: "DELETE",
349
+ path: "/v1/collections/{id}",
350
+ pathParams: { id },
351
+ query: void 0,
352
+ idempotent: true,
353
+ signal: options?.signal
354
+ });
355
+ }
356
+ /**
357
+ *
358
+ * List collections
359
+ *
360
+ * Returns a cursor-paginated list of collections the authenticated
361
+ * user has access to.
362
+ *
363
+ * Results can be filtered by providing specific collection IDs.
364
+ * Regular users will only see collections they own or have access to.
365
+ * Superusers can see all collections.
366
+ *
367
+ * The collections are returned in order of last modification, with
368
+ * most recent first.
369
+ * @operationId collections.list
370
+ * @endpoint GET /v1/collections
371
+ */
372
+ async list(params = {}, options) {
373
+ return this.core.request({
374
+ method: "GET",
375
+ path: "/v1/collections",
376
+ pathParams: {},
377
+ query: {
378
+ ids: params.ids,
379
+ name: params.name,
380
+ cursor: params.cursor,
381
+ limit: params.limit,
382
+ owner_only: params.ownerOnly,
383
+ workspace_id: params.workspaceId
384
+ },
385
+ idempotent: true,
386
+ signal: options?.signal
387
+ });
388
+ }
389
+ /**
390
+ *
391
+ * Get collection details
392
+ *
393
+ * Get details of a specific collection.
394
+ *
395
+ * This endpoint retrieves detailed information about a single
396
+ * collection identified by its UUID. The user must have access to the
397
+ * collection to view its details.
398
+ * @operationId collections.retrieve
399
+ * @endpoint GET /v1/collections/{id}
400
+ */
401
+ async retrieve(id, options) {
402
+ return this.core.request({
403
+ method: "GET",
404
+ path: "/v1/collections/{id}",
405
+ pathParams: { id },
406
+ query: void 0,
407
+ idempotent: true,
408
+ signal: options?.signal
409
+ });
410
+ }
411
+ /**
412
+ *
413
+ * Get a collection by name
414
+ *
415
+ * Retrieve a collection by its (owner_id, name) combination.
416
+ *
417
+ * The authenticated user can only fetch collections they own, or, if
418
+ * superuser, from anyone.
419
+ * @operationId collections.retrieveByName
420
+ * @endpoint GET /v1/collections/name/{collection_name}
421
+ */
422
+ async retrieveByName(params, options) {
423
+ return this.core.request({
424
+ method: "GET",
425
+ path: "/v1/collections/name/{collection_name}",
426
+ pathParams: { collection_name: params.collectionName },
427
+ query: { owner_id: params.ownerId },
428
+ idempotent: true,
429
+ signal: options?.signal
430
+ });
431
+ }
432
+ /**
433
+ *
434
+ * Update collection
435
+ *
436
+ * Update an existing collection's configuration.
437
+ *
438
+ * This endpoint allows updating the name, description, and access settings of an
439
+ * existing collection. The user must have appropriate permissions to
440
+ * modify the collection.
441
+ * @operationId collections.update
442
+ * @endpoint POST /v1/collections/{id}
443
+ */
444
+ async update(params, options) {
445
+ return this.core.request({
446
+ method: "POST",
447
+ path: "/v1/collections/{id}",
448
+ pathParams: { id: params.id },
449
+ query: void 0,
450
+ body: params.body,
451
+ idempotent: false,
452
+ signal: options?.signal
453
+ });
454
+ }
455
+ };
456
+ //#endregion
457
+ //#region src/resources/connectors.ts
458
+ var ConnectorsResource = class {
459
+ core;
460
+ constructor(core) {
461
+ this.core = core;
462
+ }
463
+ /**
464
+ *
465
+ * Start OAuth connection flow
466
+ *
467
+ * Start the OAuth connection flow for the given external provider. Returns the authorization URL the user should visit to grant Nebula access. After consent the provider redirects back to Nebula and the connection becomes active.
468
+ * @operationId connectors.connect
469
+ * @endpoint POST /v1/connectors/{provider}/connect
470
+ */
471
+ async connect(params, options) {
472
+ return this.core.request({
473
+ method: "POST",
474
+ path: "/v1/connectors/{provider}/connect",
475
+ pathParams: { provider: params.provider },
476
+ query: void 0,
477
+ body: params.body,
478
+ idempotent: false,
479
+ signal: options?.signal
480
+ });
481
+ }
482
+ /**
483
+ *
484
+ * Disconnect an external data source
485
+ *
486
+ * Disconnect the named connection, revoking the stored OAuth credentials and stopping future syncs. Optionally pass `delete_memories=true` to also remove every memory this connection had ingested.
487
+ * @operationId connectors.disconnect
488
+ * @endpoint DELETE /v1/connectors/{connection_id}
489
+ */
490
+ async disconnect(params, options) {
491
+ return this.core.request({
492
+ method: "DELETE",
493
+ path: "/v1/connectors/{connection_id}",
494
+ pathParams: { connection_id: params.connectionId },
495
+ query: { delete_memories: params.deleteMemories },
496
+ idempotent: true,
497
+ signal: options?.signal
498
+ });
499
+ }
500
+ /**
501
+ *
502
+ * List active connections for a collection
503
+ *
504
+ * Return every connector connection associated with the given collection, with encrypted credentials redacted. Useful for showing the user which third-party data sources are wired up to a collection.
505
+ * @operationId connectors.list
506
+ * @endpoint GET /v1/connectors
507
+ */
508
+ async list(params, options) {
509
+ return this.core.request({
510
+ method: "GET",
511
+ path: "/v1/connectors",
512
+ pathParams: {},
513
+ query: { collection_id: params.collectionId },
514
+ idempotent: true,
515
+ signal: options?.signal
516
+ });
517
+ }
518
+ /**
519
+ *
520
+ * List available connector providers
521
+ *
522
+ * Return the set of connector provider identifiers (e.g. `google_drive`, `slack`) that this Nebula instance is configured to expose. Pass one of these to `POST /connectors/{provider}/connect` to start an OAuth flow.
523
+ * @operationId connectors.listProviders
524
+ * @endpoint GET /v1/connectors/providers
525
+ */
526
+ async listProviders(options) {
527
+ return this.core.request({
528
+ method: "GET",
529
+ path: "/v1/connectors/providers",
530
+ pathParams: {},
531
+ query: void 0,
532
+ idempotent: true,
533
+ signal: options?.signal
534
+ });
535
+ }
536
+ /**
537
+ *
538
+ * Get a single connection by ID
539
+ *
540
+ * Fetch a single connector connection by its UUID. Returns the connection metadata plus whether the underlying subscription is active. Encrypted credentials are never returned to clients.
541
+ * @operationId connectors.retrieve
542
+ * @endpoint GET /v1/connectors/{connection_id}
543
+ */
544
+ async retrieve(connectionId, options) {
545
+ return this.core.request({
546
+ method: "GET",
547
+ path: "/v1/connectors/{connection_id}",
548
+ pathParams: { connection_id: connectionId },
549
+ query: void 0,
550
+ idempotent: true,
551
+ signal: options?.signal
552
+ });
553
+ }
554
+ /**
555
+ *
556
+ * Manually trigger a sync
557
+ *
558
+ * Schedule an immediate sync for an active connection, bypassing the normal cadence. Returns 409 if a sync is already in progress and 400 if the connection isn't in the `active` state.
559
+ * @operationId connectors.sync
560
+ * @endpoint POST /v1/connectors/{connection_id}/sync
561
+ */
562
+ async sync(connectionId, options) {
563
+ return this.core.request({
564
+ method: "POST",
565
+ path: "/v1/connectors/{connection_id}/sync",
566
+ pathParams: { connection_id: connectionId },
567
+ query: void 0,
568
+ idempotent: true,
569
+ signal: options?.signal
570
+ });
571
+ }
572
+ };
573
+ //#endregion
574
+ //#region src/resources/memories.ts
575
+ var MemoriesResource = class {
576
+ core;
577
+ constructor(core) {
578
+ this.core = core;
579
+ }
580
+ /**
581
+ *
582
+ * Append content to an engram
583
+ *
584
+ * Append content to an existing engram.
585
+ *
586
+ * **For conversation engrams:**
587
+ * - Provide `messages` array with content, role, and optional metadata
588
+ * - Works like `/conversations/{id}/messages` endpoint
589
+ *
590
+ * **For document engrams:**
591
+ * - Provide either `raw_text` or `chunks` to append additional content
592
+ * - Content will be processed and added to the engram
593
+ * @operationId memories.append
594
+ * @endpoint POST /v1/memories/{id}/append
595
+ */
596
+ async append(params, options) {
597
+ return this.core.request({
598
+ method: "POST",
599
+ path: "/v1/memories/{id}/append",
600
+ pathParams: { id: params.id },
601
+ query: void 0,
602
+ body: params.body,
603
+ idempotent: false,
604
+ signal: options?.signal
605
+ });
606
+ }
607
+ /**
608
+ *
609
+ * Create a new memory (conversation or document)
610
+ *
611
+ * Create a new memory (conversation or document) using clean JSON body.
612
+ *
613
+ * - Use `collection_id` (UUID)
614
+ * - `kind` is optional and inferred from payload shape:
615
+ * - If `messages` present -> conversation
616
+ * - Otherwise -> document
617
+ * - For conversations: provide `messages` array
618
+ * - For documents: provide `raw_text` or `chunks`
619
+ * - Use `snapshot` for device-memory mode (mutually exclusive with collection_id)
620
+ * @operationId memories.create
621
+ * @endpoint POST /v1/memories
622
+ */
623
+ async create(params, options) {
624
+ return this.core.request({
625
+ method: "POST",
626
+ path: "/v1/memories",
627
+ pathParams: {},
628
+ query: void 0,
629
+ body: params.body,
630
+ idempotent: false,
631
+ signal: options?.signal
632
+ });
633
+ }
634
+ /**
635
+ *
636
+ * Get presigned URL for large file upload
637
+ *
638
+ * Get a presigned URL for uploading large files directly to S3.
639
+ *
640
+ * Use this for files larger than 5MB that cannot be sent inline as base64.
641
+ * After uploading, reference the file in memory creation using S3FileReference.
642
+ *
643
+ * Args:
644
+ * filename: Original filename (e.g., "image.jpg")
645
+ * content_type: MIME type (e.g., "image/jpeg", "application/pdf")
646
+ * file_size: Expected file size in bytes (max 100MB)
647
+ *
648
+ * Returns:
649
+ * dict with:
650
+ * - upload_url: Presigned URL for PUT request (expires in 1 hour)
651
+ * - upload_headers: Headers that must be sent with the presigned PUT request
652
+ * - s3_key: The S3 key to reference in memory creation
653
+ * - bucket: S3 bucket name
654
+ * - expires_in: Seconds until URL expires
655
+ * - max_size: Maximum allowed file size
656
+ * @operationId memories.createUpload
657
+ * @endpoint POST /v1/memories/upload
658
+ */
659
+ async createUpload(params, options) {
660
+ return this.core.request({
661
+ method: "POST",
662
+ path: "/v1/memories/upload",
663
+ pathParams: {},
664
+ query: {
665
+ filename: params.filename,
666
+ content_type: params.contentType,
667
+ file_size: params.fileSize
668
+ },
669
+ idempotent: false,
670
+ signal: options?.signal
671
+ });
672
+ }
673
+ /**
674
+ *
675
+ * Delete an engram
676
+ *
677
+ * Delete a specific engram with graph awareness. All chunks corresponding to the
678
+ * engram are deleted, and graph components (entities/relationships) are updated
679
+ * or deleted based on remaining chunk references from other engrams.
680
+ *
681
+ * This method now properly handles graph components and maintains graph integrity
682
+ * for search operations.
683
+ * @operationId memories.delete
684
+ * @endpoint DELETE /v1/memories/{id}
685
+ */
686
+ async delete(id, options) {
687
+ return this.core.request({
688
+ method: "DELETE",
689
+ path: "/v1/memories/{id}",
690
+ pathParams: { id },
691
+ query: void 0,
692
+ idempotent: false,
693
+ signal: options?.signal
694
+ });
695
+ }
696
+ /**
697
+ *
698
+ * Delete one or more engrams
699
+ *
700
+ * Delete one or more engrams.
701
+ *
702
+ * This endpoint efficiently handles both single and batch deletions.
703
+ * When multiple IDs are provided, it uses optimized batch operations.
704
+ *
705
+ * Args:
706
+ * ids: Either a single UUID or a list of UUIDs to delete
707
+ *
708
+ * Returns:
709
+ * For single deletion: boolean success response
710
+ * For batch deletion: detailed results with successful and failed deletions
711
+ * @operationId memories.deleteMany
712
+ * @endpoint POST /v1/memories/delete
713
+ */
714
+ async deleteMany(params, options) {
715
+ return this.core.request({
716
+ method: "POST",
717
+ path: "/v1/memories/delete",
718
+ pathParams: {},
719
+ query: void 0,
720
+ body: params.body,
721
+ idempotent: false,
722
+ signal: options?.signal
723
+ });
724
+ }
725
+ /**
726
+ *
727
+ * Delete a previously uploaded S3 file
728
+ *
729
+ * Delete a file from S3 that was uploaded via a presigned URL.
730
+ * Verifies the caller owns the file via S3 object metadata.
731
+ * @operationId memories.deleteUpload
732
+ * @endpoint DELETE /v1/memories/upload
733
+ */
734
+ async deleteUpload(params, options) {
735
+ return this.core.request({
736
+ method: "DELETE",
737
+ path: "/v1/memories/upload",
738
+ pathParams: {},
739
+ query: { s3_key: params.s3Key },
740
+ idempotent: true,
741
+ signal: options?.signal
742
+ });
743
+ }
744
+ /**
745
+ *
746
+ * List engrams
747
+ *
748
+ * Returns a cursor-paginated list of engrams the authenticated user
749
+ * has access to.
750
+ *
751
+ * Results can be filtered by providing specific engram IDs or collection IDs.
752
+ * Regular users will only see engrams they own or have access to through
753
+ * collections. Superusers can see all engrams.
754
+ *
755
+ * The engrams are returned in order of creation time, most recent
756
+ * first. The response includes the engram's text field if available.
757
+ * @operationId memories.list
758
+ * @endpoint GET /v1/memories
759
+ */
760
+ async list(params = {}, options) {
761
+ return this.core.request({
762
+ method: "GET",
763
+ path: "/v1/memories",
764
+ pathParams: {},
765
+ query: {
766
+ ids: params.ids,
767
+ cursor: params.cursor,
768
+ limit: params.limit,
769
+ chunks_limit: params.chunksLimit,
770
+ owner_only: params.ownerOnly,
771
+ collection_ids: params.collectionIds,
772
+ metadata_filters: params.metadataFilters,
773
+ min_applied_wal_seq: params.minAppliedWalSeq
774
+ },
775
+ idempotent: true,
776
+ signal: options?.signal
777
+ });
778
+ }
779
+ /**
780
+ *
781
+ * Recall workflow patterns by intent
782
+ *
783
+ * Workflow-pattern recall over 5 intents.
784
+ *
785
+ * * ``cursor`` -- match the caller's anchor against pattern
786
+ * canonical states, return ranked patterns + position.
787
+ * * ``predict`` -- like cursor but include the predicted next
788
+ * trace from each pattern's canonical instance.
789
+ * * ``resume`` -- like cursor, biased toward longer patterns.
790
+ * * ``evidence`` -- expand a specific pattern via
791
+ * ``hydrate_pattern``.
792
+ * * ``bootstrap`` -- top-K patterns by confidence with no anchor.
793
+ * @operationId memories.recallWorkflow
794
+ * @endpoint POST /v1/memories/workflow/recall
795
+ */
796
+ async recallWorkflow(params, options) {
797
+ return this.core.request({
798
+ method: "POST",
799
+ path: "/v1/memories/workflow/recall",
800
+ pathParams: {},
801
+ query: void 0,
802
+ body: params.body,
803
+ idempotent: false,
804
+ signal: options?.signal
805
+ });
806
+ }
807
+ /**
808
+ *
809
+ * Retrieve an engram
810
+ *
811
+ * Retrieves detailed information about a specific engram by its
812
+ * ID.
813
+ *
814
+ * This endpoint returns the engram's metadata, status, and system information. It does not
815
+ * return the engram's content - use the `/engrams/{id}/download` endpoint for that.
816
+ *
817
+ * Users can only retrieve engrams they own or have access to through collections.
818
+ * Superusers can retrieve any engram.
819
+ * @operationId memories.retrieve
820
+ * @endpoint GET /v1/memories/{id}
821
+ */
822
+ async retrieve(id, options) {
823
+ return this.core.request({
824
+ method: "GET",
825
+ path: "/v1/memories/{id}",
826
+ pathParams: { id },
827
+ query: void 0,
828
+ idempotent: true,
829
+ signal: options?.signal
830
+ });
831
+ }
832
+ /**
833
+ *
834
+ * Search memories
835
+ *
836
+ * Perform a search query across your memories.
837
+ *
838
+ * **Standard mode** (collection_ids or readable-scope search): returns hierarchical MemoryRecall
839
+ * with semantics, episodes, procedures, and sources.
840
+ *
841
+ * **Snapshot mode** (snapshot field): returns graph-search results with
842
+ * {entities, relationships} from stateless in-memory traversal.
843
+ * @operationId memories.search
844
+ * @endpoint POST /v1/memories/search
845
+ */
846
+ async search(params, options) {
847
+ return this.core.request({
848
+ method: "POST",
849
+ path: "/v1/memories/search",
850
+ pathParams: {},
851
+ query: void 0,
852
+ body: params.body,
853
+ idempotent: false,
854
+ signal: options?.signal
855
+ });
856
+ }
857
+ /**
858
+ *
859
+ * Update a memory
860
+ *
861
+ * Update memory-level properties including name, metadata, and collection associations.
862
+ *
863
+ * This endpoint allows updating properties of an entire memory (document or conversation)
864
+ * without modifying its content:
865
+ * - **name**: Updates the authoritative engram title
866
+ * - **metadata**: Can replace or merge with existing metadata
867
+ * - **collection_ids**: Updates authoritative engram collection associations
868
+ *
869
+ * Users can only update memories they own or have access to through collections.
870
+ * At least one collection association must be maintained.
871
+ *
872
+ * If collection_id is provided and the engram is shared across collections, a copy-on-write
873
+ * will be performed to create a collection-specific copy before modification.
874
+ * @operationId memories.update
875
+ * @endpoint PATCH /v1/memories/{id}
876
+ */
877
+ async update(params, options) {
878
+ return this.core.request({
879
+ method: "PATCH",
880
+ path: "/v1/memories/{id}",
881
+ pathParams: { id: params.id },
882
+ query: { collection_id: params.collectionId },
883
+ body: params.body,
884
+ idempotent: false,
885
+ signal: options?.signal
886
+ });
887
+ }
888
+ };
889
+ //#endregion
890
+ //#region src/resources/snapshots.ts
891
+ var SnapshotsResource = class {
892
+ core;
893
+ constructor(core) {
894
+ this.core = core;
895
+ }
896
+ /**
897
+ *
898
+ * Export a collection snapshot
899
+ *
900
+ * Export a collection's full graph state as a
901
+ * portable SnapshotEnvelope.
902
+ * @operationId snapshots.export
903
+ * @endpoint POST /v1/device-memory/snapshot/export
904
+ */
905
+ async export(params, options) {
906
+ return this.core.request({
907
+ method: "POST",
908
+ path: "/v1/device-memory/snapshot/export",
909
+ pathParams: {},
910
+ query: void 0,
911
+ body: params.body,
912
+ idempotent: true,
913
+ signal: options?.signal
914
+ });
915
+ }
916
+ /**
917
+ *
918
+ * Import a snapshot into an ephemeral collection
919
+ *
920
+ * Import a SnapshotEnvelope into an ephemeral
921
+ * collection. Returns the ephemeral collection UUID.
922
+ * @operationId snapshots.import
923
+ * @endpoint POST /v1/device-memory/snapshot/import
924
+ */
925
+ async import(params, options) {
926
+ return this.core.request({
927
+ method: "POST",
928
+ path: "/v1/device-memory/snapshot/import",
929
+ pathParams: {},
930
+ query: void 0,
931
+ body: params.body,
932
+ idempotent: false,
933
+ signal: options?.signal
934
+ });
935
+ }
936
+ };
937
+ //#endregion
938
+ //#region src/client.ts
939
+ var NebulaClient = class {
940
+ core;
941
+ client;
942
+ collections;
943
+ connectors;
944
+ memories;
945
+ snapshots;
946
+ constructor(options = {}) {
947
+ this.core = new NebulaCore(options);
948
+ this.client = new ClientResource(this.core);
949
+ this.collections = new CollectionsResource(this.core);
950
+ this.connectors = new ConnectorsResource(this.core);
951
+ this.memories = new MemoriesResource(this.core);
952
+ this.snapshots = new SnapshotsResource(this.core);
953
+ }
954
+ };
955
+ //#endregion
956
+ //#region src/lib/_dx_generated.ts
957
+ /** Strip a `results` envelope at runtime; matches `Unwrapped<>`. */
958
+ function unwrap$1(p) {
959
+ return p.then((r) => {
960
+ if (r !== null && typeof r === "object" && "results" in r) return r.results;
961
+ return r;
962
+ });
963
+ }
964
+ /**
965
+ * Generated DX layer: simple unwrap/passthrough convenience methods.
966
+ * Signatures are derived from the underlying resource methods so
967
+ * callers see the same arg names + types in IDE hover.
968
+ */
969
+ var NebulaDX = class extends NebulaClient {
970
+ /** Retrieve a single memory by id and return just the data. (generated from dx-extensions.yaml). */
971
+ async getMemory(...args) {
972
+ return unwrap$1(this.memories.retrieve(...args));
973
+ }
974
+ /** Update a memory by id; returns the updated record. (generated from dx-extensions.yaml). */
975
+ async updateMemory(...args) {
976
+ return unwrap$1(this.memories.update(...args));
977
+ }
978
+ /** Liveness probe with the wire envelope unwrapped. (generated from dx-extensions.yaml). */
979
+ async healthCheck(...args) {
980
+ return unwrap$1(this.client.health(...args));
981
+ }
982
+ /** unwrap → collections.create (generated from dx-extensions.yaml). */
983
+ async createCollection(...args) {
984
+ return unwrap$1(this.collections.create(...args));
985
+ }
986
+ /** unwrap → collections.retrieve (generated from dx-extensions.yaml). */
987
+ async getCollection(...args) {
988
+ return unwrap$1(this.collections.retrieve(...args));
989
+ }
990
+ /** unwrap → collections.retrieveByName (generated from dx-extensions.yaml). */
991
+ async getCollectionByName(...args) {
992
+ return unwrap$1(this.collections.retrieveByName(...args));
993
+ }
994
+ /** unwrap → collections.list (generated from dx-extensions.yaml). */
995
+ async listCollections(...args) {
996
+ return unwrap$1(this.collections.list(...args));
997
+ }
998
+ /** unwrap → collections.update (generated from dx-extensions.yaml). */
999
+ async updateCollection(...args) {
1000
+ return unwrap$1(this.collections.update(...args));
1001
+ }
1002
+ /** unwrap → connectors.listProviders (generated from dx-extensions.yaml). */
1003
+ async listProviders(...args) {
1004
+ return unwrap$1(this.connectors.listProviders(...args));
1005
+ }
1006
+ /** unwrap → connectors.retrieve (generated from dx-extensions.yaml). */
1007
+ async getConnection(...args) {
1008
+ return unwrap$1(this.connectors.retrieve(...args));
1009
+ }
1010
+ /** unwrap → connectors.sync (generated from dx-extensions.yaml). */
1011
+ async triggerSync(...args) {
1012
+ return unwrap$1(this.connectors.sync(...args));
1013
+ }
1014
+ /** unwrap → memories.createUpload (generated from dx-extensions.yaml). */
1015
+ async getUploadUrl(...args) {
1016
+ return unwrap$1(this.memories.createUpload(...args));
1017
+ }
1018
+ /** unwrap → snapshots.export (generated from dx-extensions.yaml). */
1019
+ async exportSnapshot(...args) {
1020
+ return unwrap$1(this.snapshots.export(...args));
1021
+ }
1022
+ /** unwrap → snapshots.import (generated from dx-extensions.yaml). */
1023
+ async importSnapshot(...args) {
1024
+ return unwrap$1(this.snapshots.import(...args));
1025
+ }
1026
+ };
1027
+ //#endregion
1028
+ //#region src/lib/dx.ts
1029
+ var Nebula = class extends NebulaDX {
1030
+ constructor(options = {}) {
1031
+ super(normalizeAuthOptions(normalizeClientOptions(options)));
1032
+ }
1033
+ /**
1034
+ * Polymorphic memory creator: dispatches to memories.create or memories.append
1035
+ * based on whether `memory_id` is set on the input. Returns the new memory's
1036
+ * id (string), or — when `snapshot` is set — the updated snapshot envelope.
1037
+ */
1038
+ async storeMemory(memory, options) {
1039
+ if ("memory_id" in memory && memory.memory_id != null) {
1040
+ const memoryID = memory.memory_id;
1041
+ await this.memories.append({
1042
+ id: memoryID,
1043
+ body: toMemoryAppendParams(memory)
1044
+ }, options);
1045
+ return memoryID;
1046
+ }
1047
+ const result = unwrapResults(await this.memories.create({ body: toMemoryCreateParams(memory) }, options));
1048
+ if (isSnapshotResult(result)) return result.snapshot ?? result;
1049
+ return extractID(result);
1050
+ }
1051
+ /**
1052
+ * Bulk parallel version of storeMemory with a concurrency cap.
1053
+ *
1054
+ * Default 8 concurrent in-flight requests matches the Python DX's
1055
+ * `asyncio.Semaphore(max_concurrency)` pattern. Use `maxConcurrency: 1`
1056
+ * for strictly serial submission; higher values risk overwhelming the
1057
+ * server when memories[] is large.
1058
+ */
1059
+ async storeMemories(memories, options) {
1060
+ const cap = Math.max(1, options?.maxConcurrency ?? 8);
1061
+ const signal = options?.signal;
1062
+ const results = new Array(memories.length);
1063
+ let nextIndex = 0;
1064
+ const worker = async () => {
1065
+ while (true) {
1066
+ const i = nextIndex++;
1067
+ if (i >= memories.length) return;
1068
+ results[i] = await this.storeMemory(memories[i], { signal });
1069
+ }
1070
+ };
1071
+ await Promise.all(Array.from({ length: Math.min(cap, memories.length) }, () => worker()));
1072
+ return results;
1073
+ }
1074
+ /**
1075
+ * List memories scoped to one or more collection ids (string | string[])
1076
+ * or a full MemoryListParams object.
1077
+ */
1078
+ async listMemories(query, options) {
1079
+ const normalized = typeof query === "string" || Array.isArray(query) ? { collectionIds: arrayify(query) } : query;
1080
+ return unwrap(this.memories.list(normalized, options));
1081
+ }
1082
+ /**
1083
+ * Memory search shortcut: unwraps `results`. (Affinity-header injection
1084
+ * is a planned enhancement; currently delegates straight to the resource.)
1085
+ */
1086
+ async search(body, options) {
1087
+ return unwrap(this.memories.search({ body }, options));
1088
+ }
1089
+ /**
1090
+ * deleteCollection coerces the wire {success: bool} envelope into a Python-
1091
+ * style boolean return.
1092
+ */
1093
+ async deleteCollection(id, options) {
1094
+ const result = unwrapResults(await this.collections.delete(id, options));
1095
+ return Boolean(result.success);
1096
+ }
1097
+ createCluster = this.createCollection;
1098
+ getCluster = this.getCollection;
1099
+ getClusterByName = this.getCollectionByName;
1100
+ listClusters = this.listCollections;
1101
+ updateCluster = this.updateCollection;
1102
+ deleteCluster = this.deleteCollection;
1103
+ /**
1104
+ * Positional `connectProvider(provider, collectionID, config?)` — wraps the
1105
+ * generated `connectors.connect({provider, body})` to build the body shape.
1106
+ */
1107
+ async connectProvider(provider, collectionID, config, options) {
1108
+ const body = {
1109
+ collection_id: collectionID,
1110
+ ...config !== void 0 ? { config } : {}
1111
+ };
1112
+ return unwrap(this.connectors.connect({
1113
+ provider,
1114
+ body
1115
+ }, options));
1116
+ }
1117
+ /** Positional listConnections(collectionID) — wraps the query wrapper. */
1118
+ async listConnections(collectionID, options) {
1119
+ return unwrap(this.connectors.list({ collectionId: collectionID }, options));
1120
+ }
1121
+ /** Positional disconnect(connectionID, deleteMemories?). */
1122
+ async disconnectConnection(connectionID, deleteMemories = false, options) {
1123
+ return unwrap(this.connectors.disconnect({
1124
+ connectionId: connectionID,
1125
+ deleteMemories
1126
+ }, options));
1127
+ }
1128
+ /** Alias for disconnectConnection (same arg shape). */
1129
+ async disconnect(connectionID, deleteMemories = false, options) {
1130
+ return unwrap(this.connectors.disconnect({
1131
+ connectionId: connectionID,
1132
+ deleteMemories
1133
+ }, options));
1134
+ }
1135
+ /** Single-id delete; coerces 204 to boolean true. */
1136
+ async deleteMemory(memoryID, options) {
1137
+ await this.memories.delete(memoryID, options);
1138
+ return true;
1139
+ }
1140
+ /** Bulk delete by ids. */
1141
+ async deleteMemories(memoryIDs, options) {
1142
+ return this.memories.deleteMany({ body: memoryIDs }, options);
1143
+ }
1144
+ /**
1145
+ * Polymorphic delete: dispatches based on argument type.
1146
+ * - `delete("/some/path")` -> raw HTTP DELETE (escape hatch; not implemented)
1147
+ * - `delete("memory-id")` -> deleteMemory
1148
+ * - `delete(["id1", "id2"])` -> deleteMemories (bulk)
1149
+ */
1150
+ async delete(pathOrMemoryIDs, options) {
1151
+ if (Array.isArray(pathOrMemoryIDs)) return this.deleteMemories(pathOrMemoryIDs, options);
1152
+ if (isRequestPath(pathOrMemoryIDs)) throw new Error(`delete("${pathOrMemoryIDs}") raw-path escape hatch is not implemented in this SDK yet`);
1153
+ return this.deleteMemory(pathOrMemoryIDs, options);
1154
+ }
1155
+ };
1156
+ function normalizeAuthOptions(options) {
1157
+ if (options.apiKey != null && options.bearerToken == null && !looksLikeNebulaAPIKey(options.apiKey)) return {
1158
+ ...options,
1159
+ apiKey: void 0,
1160
+ bearerToken: options.apiKey
1161
+ };
1162
+ return options;
1163
+ }
1164
+ function normalizeClientOptions(options) {
1165
+ const { api_key: apiKeyAlias, apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, base_url: baseUrlSnakeAlias, timeout: timeoutAlias, bearerToken, bearer_token: bearerTokenAlias, accessToken, access_token: accessTokenAlias, ...rest } = options;
1166
+ const restClientOptions = rest;
1167
+ return {
1168
+ ...restClientOptions,
1169
+ apiKey: firstDefined(apiKey, apiKeyAlias) ?? void 0,
1170
+ bearerToken: firstDefined(bearerToken, bearerTokenAlias, accessToken, accessTokenAlias) ?? void 0,
1171
+ baseUrl: firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias, baseUrlSnakeAlias) ?? void 0,
1172
+ timeoutMs: firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? void 0
1173
+ };
1174
+ }
1175
+ function firstDefined(...values) {
1176
+ return values.find((value) => value !== void 0);
1177
+ }
1178
+ function looksLikeNebulaAPIKey(token) {
1179
+ const parts = token.split(".");
1180
+ if (parts.length !== 2) return false;
1181
+ const [publicPart, rawPart] = parts;
1182
+ return Boolean(rawPart) && (publicPart.startsWith("key_") || publicPart.startsWith("neb_"));
1183
+ }
1184
+ function toMemoryCreateParams(memory) {
1185
+ const collectionID = memory.collection_id ?? memory.collectionId ?? void 0;
1186
+ const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;
1187
+ const params = { ...rest };
1188
+ if (collectionID !== void 0) params.collection_id = collectionID;
1189
+ if (content != null) if (typeof content === "string") params.raw_text = content;
1190
+ else params.content_parts = content;
1191
+ if (params.messages != null && !params.engram_type) params.engram_type = "conversation";
1192
+ return params;
1193
+ }
1194
+ function toMemoryAppendParams(memory) {
1195
+ const collectionID = memory.collection_id ?? memory.collectionId ?? void 0;
1196
+ if (!collectionID) throw new Error("collection_id is required when appending to an existing memory");
1197
+ const params = { collection_id: collectionID };
1198
+ for (const key of [
1199
+ "metadata",
1200
+ "ingestion_config",
1201
+ "ingestion_mode",
1202
+ "raw_text",
1203
+ "chunks",
1204
+ "messages"
1205
+ ]) {
1206
+ const value = memory[key];
1207
+ if (value != null) params[key] = value;
1208
+ }
1209
+ const content = memory.content;
1210
+ if (content != null) {
1211
+ if (typeof content === "string") params.raw_text = content;
1212
+ else if (Array.isArray(content) && content.every((item) => typeof item === "string")) params.chunks = content;
1213
+ else if (Array.isArray(content)) params.messages = content;
1214
+ }
1215
+ return params;
1216
+ }
1217
+ function unwrap(promise) {
1218
+ return Promise.resolve(promise).then((response) => unwrapResults(response));
1219
+ }
1220
+ function unwrapResults(response) {
1221
+ if (response !== null && typeof response === "object" && "results" in response) return response.results;
1222
+ return response;
1223
+ }
1224
+ function extractID(value) {
1225
+ if (typeof value === "object" && value !== null) {
1226
+ const record = value;
1227
+ const id = record["id"] ?? record["memory_id"] ?? record["engram_id"] ?? record["ephemeral_collection_id"];
1228
+ if (typeof id === "string") return id;
1229
+ }
1230
+ throw new Error("Nebula memory create response did not include an id");
1231
+ }
1232
+ function isSnapshotResult(value) {
1233
+ return typeof value === "object" && value !== null && "snapshot" in value;
1234
+ }
1235
+ function arrayify(value) {
1236
+ return Array.isArray(value) ? value : [value];
1237
+ }
1238
+ function isRequestPath(value) {
1239
+ return value.startsWith("/") || /^https?:\/\//i.test(value);
1240
+ }
1241
+ //#endregion
1242
+ export { DEFAULT_RETRY, Nebula, Nebula as default, NebulaAPIError, NebulaBadRequestError, NebulaClient, NebulaConflictError, NebulaConnectionError, NebulaCore, NebulaError, NebulaForbiddenError, NebulaNotFoundError, NebulaRateLimitError, NebulaServerError, NebulaTimeoutError, NebulaUnauthorizedError, NebulaValidationError, backoffMs, errorFromResponse, isRetryableStatus, sleep };
1243
+
1244
+ //# sourceMappingURL=index.js.map