@nebula-ai/sdk 1.6.0-rc.0 → 1.6.2

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.js CHANGED
@@ -122,7 +122,6 @@ const DEFAULT_TIMEOUT_MS = 6e4;
122
122
  var NebulaCore = class {
123
123
  baseUrl;
124
124
  apiKey;
125
- bearerToken;
126
125
  defaultHeaders;
127
126
  fetchImpl;
128
127
  fetchOptions;
@@ -132,7 +131,6 @@ var NebulaCore = class {
132
131
  constructor(options = {}) {
133
132
  this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
134
133
  this.apiKey = options.apiKey;
135
- this.bearerToken = options.bearerToken;
136
134
  this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);
137
135
  this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
138
136
  this.fetchOptions = options.fetchOptions ?? {};
@@ -159,8 +157,7 @@ var NebulaCore = class {
159
157
  headers.set("User-Agent", this.userAgent);
160
158
  headers.set("Accept", "application/json");
161
159
  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}`);
160
+ if (this.apiKey) headers.set("Authorization", `Bearer ${this.apiKey}`);
164
161
  if (perRequest) for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);
165
162
  return headers;
166
163
  }
@@ -281,9 +278,8 @@ var ClientResource = class {
281
278
  this.core = core;
282
279
  }
283
280
  /**
284
- *
285
281
  * Health probe
286
- *
282
+ *
287
283
  * 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
284
  * @operationId client.health
289
285
  * @endpoint GET /v1/health
@@ -307,12 +303,11 @@ var CollectionsResource = class {
307
303
  this.core = core;
308
304
  }
309
305
  /**
310
- *
311
306
  * Create a new collection
312
- *
307
+ *
313
308
  * Create a new collection and automatically add the creating user
314
309
  * to it.
315
- *
310
+ *
316
311
  * This endpoint allows authenticated users to create a new collection
317
312
  * with a specified name and optional description. The user creating
318
313
  * the collection is automatically added as a member.
@@ -331,11 +326,10 @@ var CollectionsResource = class {
331
326
  })).results;
332
327
  }
333
328
  /**
334
- *
335
329
  * Delete collection
336
- *
330
+ *
337
331
  * Delete an existing collection.
338
- *
332
+ *
339
333
  * This endpoint allows deletion of a collection identified by its
340
334
  * UUID. The user must have appropriate permissions to delete the
341
335
  * collection. Deleting a collection removes all associations but does
@@ -354,16 +348,15 @@ var CollectionsResource = class {
354
348
  })).results;
355
349
  }
356
350
  /**
357
- *
358
351
  * List collections
359
- *
352
+ *
360
353
  * Returns a cursor-paginated list of collections the authenticated
361
354
  * user has access to.
362
- *
355
+ *
363
356
  * Results can be filtered by providing specific collection IDs.
364
357
  * Regular users will only see collections they own or have access to.
365
358
  * Superusers can see all collections.
366
- *
359
+ *
367
360
  * The collections are returned in order of last modification, with
368
361
  * most recent first.
369
362
  * @operationId collections.list
@@ -387,11 +380,10 @@ var CollectionsResource = class {
387
380
  });
388
381
  }
389
382
  /**
390
- *
391
383
  * Get collection details
392
- *
384
+ *
393
385
  * Get details of a specific collection.
394
- *
386
+ *
395
387
  * This endpoint retrieves detailed information about a single
396
388
  * collection identified by its UUID. The user must have access to the
397
389
  * collection to view its details.
@@ -409,11 +401,10 @@ var CollectionsResource = class {
409
401
  })).results;
410
402
  }
411
403
  /**
412
- *
413
404
  * Get a collection by name
414
- *
405
+ *
415
406
  * Retrieve a collection by its (owner_id, name) combination.
416
- *
407
+ *
417
408
  * The authenticated user can only fetch collections they own, or, if
418
409
  * superuser, from anyone.
419
410
  * @operationId collections.retrieveByName
@@ -430,11 +421,10 @@ var CollectionsResource = class {
430
421
  })).results;
431
422
  }
432
423
  /**
433
- *
434
424
  * Update collection
435
- *
425
+ *
436
426
  * Update an existing collection's configuration.
437
- *
427
+ *
438
428
  * This endpoint allows updating the name, description, and access settings of an
439
429
  * existing collection. The user must have appropriate permissions to
440
430
  * modify the collection.
@@ -461,9 +451,8 @@ var ConnectorsResource = class {
461
451
  this.core = core;
462
452
  }
463
453
  /**
464
- *
465
454
  * Start OAuth connection flow
466
- *
455
+ *
467
456
  * 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
457
  * @operationId connectors.connect
469
458
  * @endpoint POST /v1/connectors/{provider}/connect
@@ -480,9 +469,8 @@ var ConnectorsResource = class {
480
469
  })).results;
481
470
  }
482
471
  /**
483
- *
484
472
  * Disconnect an external data source
485
- *
473
+ *
486
474
  * 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
475
  * @operationId connectors.disconnect
488
476
  * @endpoint DELETE /v1/connectors/{connection_id}
@@ -498,9 +486,8 @@ var ConnectorsResource = class {
498
486
  })).results;
499
487
  }
500
488
  /**
501
- *
502
489
  * List active connections for a collection
503
- *
490
+ *
504
491
  * 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
492
  * @operationId connectors.list
506
493
  * @endpoint GET /v1/connectors
@@ -516,9 +503,8 @@ var ConnectorsResource = class {
516
503
  })).results;
517
504
  }
518
505
  /**
519
- *
520
506
  * List available connector providers
521
- *
507
+ *
522
508
  * 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
509
  * @operationId connectors.listProviders
524
510
  * @endpoint GET /v1/connectors/providers
@@ -534,9 +520,8 @@ var ConnectorsResource = class {
534
520
  })).results;
535
521
  }
536
522
  /**
537
- *
538
523
  * Get a single connection by ID
539
- *
524
+ *
540
525
  * 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
526
  * @operationId connectors.retrieve
542
527
  * @endpoint GET /v1/connectors/{connection_id}
@@ -552,9 +537,8 @@ var ConnectorsResource = class {
552
537
  })).results;
553
538
  }
554
539
  /**
555
- *
556
540
  * Manually trigger a sync
557
- *
541
+ *
558
542
  * 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
543
  * @operationId connectors.sync
560
544
  * @endpoint POST /v1/connectors/{connection_id}/sync
@@ -578,15 +562,14 @@ var MemoriesResource = class {
578
562
  this.core = core;
579
563
  }
580
564
  /**
581
- *
582
565
  * Append content to an engram
583
- *
566
+ *
584
567
  * Append content to an existing engram.
585
- *
568
+ *
586
569
  * **For conversation engrams:**
587
570
  * - Provide `messages` array with content, role, and optional metadata
588
571
  * - Works like `/conversations/{id}/messages` endpoint
589
- *
572
+ *
590
573
  * **For document engrams:**
591
574
  * - Provide either `raw_text` or `chunks` to append additional content
592
575
  * - Content will be processed and added to the engram
@@ -605,11 +588,10 @@ var MemoriesResource = class {
605
588
  })).results;
606
589
  }
607
590
  /**
608
- *
609
591
  * Create a new memory (conversation or document)
610
- *
592
+ *
611
593
  * Create a new memory (conversation or document) using clean JSON body.
612
- *
594
+ *
613
595
  * - Use `collection_id` (UUID)
614
596
  * - `kind` is optional and inferred from payload shape:
615
597
  * - If `messages` present -> conversation
@@ -632,19 +614,18 @@ var MemoriesResource = class {
632
614
  })).results;
633
615
  }
634
616
  /**
635
- *
636
617
  * Get presigned URL for large file upload
637
- *
618
+ *
638
619
  * Get a presigned URL for uploading large files directly to S3.
639
- *
620
+ *
640
621
  * Use this for files larger than 5MB that cannot be sent inline as base64.
641
622
  * After uploading, reference the file in memory creation using S3FileReference.
642
- *
623
+ *
643
624
  * Args:
644
625
  * filename: Original filename (e.g., "image.jpg")
645
626
  * content_type: MIME type (e.g., "image/jpeg", "application/pdf")
646
627
  * file_size: Expected file size in bytes (max 100MB)
647
- *
628
+ *
648
629
  * Returns:
649
630
  * dict with:
650
631
  * - upload_url: Presigned URL for PUT request (expires in 1 hour)
@@ -671,13 +652,12 @@ var MemoriesResource = class {
671
652
  })).results;
672
653
  }
673
654
  /**
674
- *
675
655
  * Delete an engram
676
- *
656
+ *
677
657
  * Delete a specific engram with graph awareness. All chunks corresponding to the
678
658
  * engram are deleted, and graph components (entities/relationships) are updated
679
659
  * or deleted based on remaining chunk references from other engrams.
680
- *
660
+ *
681
661
  * This method now properly handles graph components and maintains graph integrity
682
662
  * for search operations.
683
663
  * @operationId memories.delete
@@ -694,17 +674,16 @@ var MemoriesResource = class {
694
674
  })).results;
695
675
  }
696
676
  /**
697
- *
698
677
  * Delete one or more engrams
699
- *
678
+ *
700
679
  * Delete one or more engrams.
701
- *
680
+ *
702
681
  * This endpoint efficiently handles both single and batch deletions.
703
682
  * When multiple IDs are provided, it uses optimized batch operations.
704
- *
683
+ *
705
684
  * Args:
706
685
  * ids: Either a single UUID or a list of UUIDs to delete
707
- *
686
+ *
708
687
  * Returns:
709
688
  * For single deletion: boolean success response
710
689
  * For batch deletion: detailed results with successful and failed deletions
@@ -723,9 +702,8 @@ var MemoriesResource = class {
723
702
  });
724
703
  }
725
704
  /**
726
- *
727
705
  * Delete a previously uploaded S3 file
728
- *
706
+ *
729
707
  * Delete a file from S3 that was uploaded via a presigned URL.
730
708
  * Verifies the caller owns the file via S3 object metadata.
731
709
  * @operationId memories.deleteUpload
@@ -742,16 +720,15 @@ var MemoriesResource = class {
742
720
  })).results;
743
721
  }
744
722
  /**
745
- *
746
723
  * List engrams
747
- *
724
+ *
748
725
  * Returns a cursor-paginated list of engrams the authenticated user
749
726
  * has access to.
750
- *
727
+ *
751
728
  * Results can be filtered by providing specific engram IDs or collection IDs.
752
729
  * Regular users will only see engrams they own or have access to through
753
730
  * collections. Superusers can see all engrams.
754
- *
731
+ *
755
732
  * The engrams are returned in order of creation time, most recent
756
733
  * first. The response includes the engram's text field if available.
757
734
  * @operationId memories.list
@@ -777,11 +754,10 @@ var MemoriesResource = class {
777
754
  });
778
755
  }
779
756
  /**
780
- *
781
757
  * Recall workflow patterns by intent
782
- *
758
+ *
783
759
  * Workflow-pattern recall over 5 intents.
784
- *
760
+ *
785
761
  * * ``cursor`` -- match the caller's anchor against pattern
786
762
  * canonical states, return ranked patterns + position.
787
763
  * * ``predict`` -- like cursor but include the predicted next
@@ -805,15 +781,14 @@ var MemoriesResource = class {
805
781
  })).results;
806
782
  }
807
783
  /**
808
- *
809
784
  * Retrieve an engram
810
- *
785
+ *
811
786
  * Retrieves detailed information about a specific engram by its
812
787
  * ID.
813
- *
788
+ *
814
789
  * This endpoint returns the engram's metadata, status, and system information. It does not
815
790
  * return the engram's content - use the `/engrams/{id}/download` endpoint for that.
816
- *
791
+ *
817
792
  * Users can only retrieve engrams they own or have access to through collections.
818
793
  * Superusers can retrieve any engram.
819
794
  * @operationId memories.retrieve
@@ -830,14 +805,13 @@ var MemoriesResource = class {
830
805
  })).results;
831
806
  }
832
807
  /**
833
- *
834
808
  * Search memories
835
- *
809
+ *
836
810
  * Perform a search query across your memories.
837
- *
811
+ *
838
812
  * **Standard mode** (collection_ids or readable-scope search): returns hierarchical MemoryRecall
839
813
  * with semantics, episodes, procedures, and sources.
840
- *
814
+ *
841
815
  * **Snapshot mode** (snapshot field): returns graph-search results with
842
816
  * {entities, relationships} from stateless in-memory traversal.
843
817
  * @operationId memories.search
@@ -855,20 +829,19 @@ var MemoriesResource = class {
855
829
  })).results;
856
830
  }
857
831
  /**
858
- *
859
832
  * Update a memory
860
- *
833
+ *
861
834
  * Update memory-level properties including name, metadata, and collection associations.
862
- *
835
+ *
863
836
  * This endpoint allows updating properties of an entire memory (document or conversation)
864
837
  * without modifying its content:
865
838
  * - **name**: Updates the authoritative engram title
866
839
  * - **metadata**: Can replace or merge with existing metadata
867
840
  * - **collection_ids**: Updates authoritative engram collection associations
868
- *
841
+ *
869
842
  * Users can only update memories they own or have access to through collections.
870
843
  * At least one collection association must be maintained.
871
- *
844
+ *
872
845
  * If collection_id is provided and the engram is shared across collections, a copy-on-write
873
846
  * will be performed to create a collection-specific copy before modification.
874
847
  * @operationId memories.update
@@ -894,9 +867,8 @@ var SnapshotsResource = class {
894
867
  this.core = core;
895
868
  }
896
869
  /**
897
- *
898
870
  * Export a collection snapshot
899
- *
871
+ *
900
872
  * Export a collection's full graph state as a
901
873
  * portable SnapshotEnvelope.
902
874
  * @operationId snapshots.export
@@ -914,9 +886,8 @@ var SnapshotsResource = class {
914
886
  })).results;
915
887
  }
916
888
  /**
917
- *
918
889
  * Import a snapshot into an ephemeral collection
919
- *
890
+ *
920
891
  * Import a SnapshotEnvelope into an ephemeral
921
892
  * collection. Returns the ephemeral collection UUID.
922
893
  * @operationId snapshots.import
@@ -935,6 +906,89 @@ var SnapshotsResource = class {
935
906
  }
936
907
  };
937
908
  //#endregion
909
+ //#region src/resources/workspaces.ts
910
+ var WorkspacesResource = class {
911
+ core;
912
+ constructor(core) {
913
+ this.core = core;
914
+ }
915
+ /**
916
+ * Create workspace storage target
917
+ *
918
+ * Register a customer S3 bucket for hosted BYOC storage.
919
+ * @operationId workspaces.createStorageTarget
920
+ * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets
921
+ */
922
+ async createStorageTarget(params, options) {
923
+ return (await this.core.request({
924
+ method: "POST",
925
+ path: "/v1/workspaces/{workspace_id}/storage-targets",
926
+ pathParams: { workspace_id: params.workspaceId },
927
+ query: void 0,
928
+ body: params.body,
929
+ idempotent: false,
930
+ signal: options?.signal
931
+ })).results;
932
+ }
933
+ /**
934
+ * Disable workspace storage target
935
+ *
936
+ * Disable a customer storage target for future collection binds.
937
+ * @operationId workspaces.disableStorageTarget
938
+ * @endpoint DELETE /v1/workspaces/{workspace_id}/storage-targets/{target_id}
939
+ */
940
+ async disableStorageTarget(params, options) {
941
+ return (await this.core.request({
942
+ method: "DELETE",
943
+ path: "/v1/workspaces/{workspace_id}/storage-targets/{target_id}",
944
+ pathParams: {
945
+ workspace_id: params.workspaceId,
946
+ target_id: params.targetId
947
+ },
948
+ query: void 0,
949
+ idempotent: false,
950
+ signal: options?.signal
951
+ })).results;
952
+ }
953
+ /**
954
+ * List workspace storage targets
955
+ *
956
+ * List customer-owned object storage targets for a workspace.
957
+ * @operationId workspaces.listStorageTargets
958
+ * @endpoint GET /v1/workspaces/{workspace_id}/storage-targets
959
+ */
960
+ async listStorageTargets(workspaceId, options) {
961
+ return (await this.core.request({
962
+ method: "GET",
963
+ path: "/v1/workspaces/{workspace_id}/storage-targets",
964
+ pathParams: { workspace_id: workspaceId },
965
+ query: void 0,
966
+ idempotent: true,
967
+ signal: options?.signal
968
+ })).results;
969
+ }
970
+ /**
971
+ * Validate workspace storage target
972
+ *
973
+ * Probe a customer storage target and mark it active on success.
974
+ * @operationId workspaces.validateStorageTarget
975
+ * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate
976
+ */
977
+ async validateStorageTarget(params, options) {
978
+ return (await this.core.request({
979
+ method: "POST",
980
+ path: "/v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate",
981
+ pathParams: {
982
+ workspace_id: params.workspaceId,
983
+ target_id: params.targetId
984
+ },
985
+ query: void 0,
986
+ idempotent: false,
987
+ signal: options?.signal
988
+ })).results;
989
+ }
990
+ };
991
+ //#endregion
938
992
  //#region src/client.ts
939
993
  var NebulaClient = class {
940
994
  core;
@@ -943,6 +997,7 @@ var NebulaClient = class {
943
997
  connectors;
944
998
  memories;
945
999
  snapshots;
1000
+ workspaces;
946
1001
  constructor(options = {}) {
947
1002
  this.core = new NebulaCore(options);
948
1003
  this.client = new ClientResource(this.core);
@@ -950,13 +1005,14 @@ var NebulaClient = class {
950
1005
  this.connectors = new ConnectorsResource(this.core);
951
1006
  this.memories = new MemoriesResource(this.core);
952
1007
  this.snapshots = new SnapshotsResource(this.core);
1008
+ this.workspaces = new WorkspacesResource(this.core);
953
1009
  }
954
1010
  };
955
1011
  //#endregion
956
1012
  //#region src/lib/dx.ts
957
1013
  var Nebula = class extends NebulaClient {
958
1014
  constructor(options = {}) {
959
- super(normalizeAuthOptions(normalizeClientOptions(options)));
1015
+ super(normalizeClientOptions(options));
960
1016
  }
961
1017
  /**
962
1018
  * Polymorphic memory creator: dispatches to memories.create or memories.append
@@ -1040,21 +1096,12 @@ var Nebula = class extends NebulaClient {
1040
1096
  }, options);
1041
1097
  }
1042
1098
  };
1043
- function normalizeAuthOptions(options) {
1044
- if (options.apiKey != null && options.bearerToken == null && !looksLikeNebulaAPIKey(options.apiKey)) return {
1045
- ...options,
1046
- apiKey: void 0,
1047
- bearerToken: options.apiKey
1048
- };
1049
- return options;
1050
- }
1051
1099
  function normalizeClientOptions(options) {
1052
- const { apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, timeout: timeoutAlias, bearerToken, ...rest } = options;
1100
+ const { apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, timeout: timeoutAlias, ...rest } = options;
1053
1101
  const restClientOptions = rest;
1054
1102
  return {
1055
1103
  ...restClientOptions,
1056
1104
  apiKey: apiKey ?? void 0,
1057
- bearerToken: bearerToken ?? void 0,
1058
1105
  baseUrl: firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? void 0,
1059
1106
  timeoutMs: firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? void 0
1060
1107
  };
@@ -1062,12 +1109,6 @@ function normalizeClientOptions(options) {
1062
1109
  function firstDefined(...values) {
1063
1110
  return values.find((value) => value !== void 0);
1064
1111
  }
1065
- function looksLikeNebulaAPIKey(token) {
1066
- const parts = token.split(".");
1067
- if (parts.length !== 2) return false;
1068
- const [publicPart, rawPart] = parts;
1069
- return Boolean(rawPart) && (publicPart.startsWith("key_") || publicPart.startsWith("neb_"));
1070
- }
1071
1112
  function toMemoryCreateParams(memory) {
1072
1113
  const collectionID = memory.collection_id ?? memory.collectionId ?? void 0;
1073
1114
  const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;