@nebula-ai/sdk 1.1.29 → 1.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -179,7 +179,7 @@ var _Nebula = class _Nebula {
179
179
  return await this._processContentParts(normalized);
180
180
  }
181
181
  /** Make an HTTP request to the Nebula API */
182
- async _makeRequest(method, endpoint, jsonData, params) {
182
+ async _makeRequest(method, endpoint, jsonData, params, extraHeaders) {
183
183
  const url = new URL(endpoint, this.baseUrl);
184
184
  if (params) {
185
185
  Object.entries(params).forEach(([key, value]) => {
@@ -194,7 +194,7 @@ var _Nebula = class _Nebula {
194
194
  }
195
195
  });
196
196
  }
197
- const headers = this._buildAuthHeaders(true);
197
+ const headers = { ...this._buildAuthHeaders(true), ...extraHeaders };
198
198
  const controller = new AbortController();
199
199
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
200
200
  try {
@@ -574,30 +574,30 @@ var _Nebula = class _Nebula {
574
574
  throw new NebulaClientException(`Unknown error: ${String(error)}`);
575
575
  }
576
576
  }
577
- /** Delete a specific chunk or message within a memory */
578
- async deleteChunk(chunkId) {
577
+ /** Delete a specific source within a memory */
578
+ async deleteSource(sourceId) {
579
579
  try {
580
- await this._makeRequest("DELETE", `/v1/chunks/${chunkId}`);
580
+ await this._makeRequest("DELETE", `/v1/sources/${sourceId}`);
581
581
  return true;
582
582
  } catch (error) {
583
583
  if (error instanceof NebulaException && error.statusCode === 404) {
584
- throw new NebulaNotFoundException(chunkId, "Chunk");
584
+ throw new NebulaNotFoundException(sourceId, "Source");
585
585
  }
586
586
  throw error;
587
587
  }
588
588
  }
589
- /** Update a specific chunk or message within a memory */
590
- async updateChunk(chunkId, content, metadata) {
589
+ /** Update a specific source within a memory */
590
+ async updateSource(sourceId, content, metadata) {
591
591
  const payload = { content };
592
592
  if (metadata !== void 0) {
593
593
  payload.metadata = metadata;
594
594
  }
595
595
  try {
596
- await this._makeRequest("PATCH", `/v1/chunks/${chunkId}`, payload);
596
+ await this._makeRequest("PATCH", `/v1/sources/${sourceId}`, payload);
597
597
  return true;
598
598
  } catch (error) {
599
599
  if (error instanceof NebulaException && error.statusCode === 404) {
600
- throw new NebulaNotFoundException(chunkId, "Chunk");
600
+ throw new NebulaNotFoundException(sourceId, "Source");
601
601
  }
602
602
  throw error;
603
603
  }
@@ -606,8 +606,8 @@ var _Nebula = class _Nebula {
606
606
  * Update memory-level properties including name, metadata, and collection associations.
607
607
  *
608
608
  * This method allows updating properties of an entire memory (document or conversation)
609
- * without modifying its content. For updating individual chunks or messages within a memory,
610
- * use updateChunk(). For updating content, use storeMemory() to append.
609
+ * without modifying its content. For updating individual sources within a memory,
610
+ * use updateSource(). For updating content, use storeMemory() to append.
611
611
  *
612
612
  * @param options - Update configuration
613
613
  * @param options.memoryId - The ID of the memory to update
@@ -826,8 +826,8 @@ var _Nebula = class _Nebula {
826
826
  data.effort = options.effort;
827
827
  }
828
828
  if (options.collection_ids) {
829
- const collectionIds = Array.isArray(options.collection_ids) ? options.collection_ids : [options.collection_ids];
830
- const validCollectionIds = collectionIds.filter((id) => id && id.trim() !== "");
829
+ const collectionIds2 = Array.isArray(options.collection_ids) ? options.collection_ids : [options.collection_ids];
830
+ const validCollectionIds = collectionIds2.filter((id) => id && id.trim() !== "");
831
831
  if (validCollectionIds.length) {
832
832
  data.collection_ids = validCollectionIds;
833
833
  }
@@ -838,14 +838,16 @@ var _Nebula = class _Nebula {
838
838
  if (options.searchSettings) {
839
839
  data.search_settings = options.searchSettings;
840
840
  }
841
- const response = await this._makeRequest("POST", "/v1/memories/search", data);
841
+ const collectionIds = data.collection_ids;
842
+ const extraHeaders = collectionIds && collectionIds.length === 1 ? { "X-Nebula-Collection-Id": collectionIds[0] } : void 0;
843
+ const response = await this._makeRequest("POST", "/v1/memories/search", data, void 0, extraHeaders);
842
844
  const memoryResponseData = response.results;
843
845
  const memoryResponse = {
844
846
  query: memoryResponseData.query || options.query,
845
847
  entities: memoryResponseData.entities || [],
846
- knowledge: memoryResponseData.knowledge ?? memoryResponseData.facts ?? [],
848
+ knowledge: memoryResponseData.knowledge ?? [],
847
849
  episodes: memoryResponseData.episodes || [],
848
- utterances: memoryResponseData.utterances || [],
850
+ sources: memoryResponseData.sources || [],
849
851
  total_traversal_time_ms: memoryResponseData.total_traversal_time_ms,
850
852
  token_count: memoryResponseData.token_count
851
853
  };