@nebula-ai/sdk 1.6.1 → 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/README.md CHANGED
@@ -28,7 +28,6 @@ import { Nebula } from "@nebula-ai/sdk";
28
28
 
29
29
  const client = new Nebula({
30
30
  apiKey: process.env.NEBULA_API_KEY,
31
- // or: bearerToken: process.env.NEBULA_BEARER_TOKEN,
32
31
  });
33
32
 
34
33
  const result = await client.memories.create({
@@ -47,16 +46,11 @@ a `memory_id` is present); prefer the resource methods for everything else.
47
46
 
48
47
  ## Auth
49
48
 
50
- Pass either `apiKey` (for Nebula API keys) or `bearerToken` (for JWTs)
51
- when constructing the client. If you pass an opaque-looking token via
52
- `apiKey` (one that isn't prefixed with `key_` or `neb_`), the DX layer
53
- automatically routes it through the `Authorization: Bearer` header
54
- instead — handy when your app exchanges a workspace token for the SDK
55
- and doesn't want to think about which header to use.
49
+ Pass your Nebula API key as `apiKey` when constructing the client. It is sent
50
+ via the `Authorization: Bearer` header.
56
51
 
57
52
  ```ts
58
53
  new Nebula({ apiKey: process.env.NEBULA_API_KEY });
59
- new Nebula({ bearerToken: process.env.NEBULA_BEARER_TOKEN });
60
54
  ```
61
55
 
62
56
  ## Errors
package/dist/index.cjs CHANGED
@@ -126,7 +126,6 @@ const DEFAULT_TIMEOUT_MS = 6e4;
126
126
  var NebulaCore = class {
127
127
  baseUrl;
128
128
  apiKey;
129
- bearerToken;
130
129
  defaultHeaders;
131
130
  fetchImpl;
132
131
  fetchOptions;
@@ -136,7 +135,6 @@ var NebulaCore = class {
136
135
  constructor(options = {}) {
137
136
  this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
138
137
  this.apiKey = options.apiKey;
139
- this.bearerToken = options.bearerToken;
140
138
  this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);
141
139
  this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
142
140
  this.fetchOptions = options.fetchOptions ?? {};
@@ -163,8 +161,7 @@ var NebulaCore = class {
163
161
  headers.set("User-Agent", this.userAgent);
164
162
  headers.set("Accept", "application/json");
165
163
  if (hasBody) headers.set("Content-Type", "application/json");
166
- if (this.apiKey) headers.set("X-API-Key", this.apiKey);
167
- if (this.bearerToken) headers.set("Authorization", `Bearer ${this.bearerToken}`);
164
+ if (this.apiKey) headers.set("Authorization", `Bearer ${this.apiKey}`);
168
165
  if (perRequest) for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);
169
166
  return headers;
170
167
  }
@@ -1019,7 +1016,7 @@ var NebulaClient = class {
1019
1016
  //#region src/lib/dx.ts
1020
1017
  var Nebula = class extends NebulaClient {
1021
1018
  constructor(options = {}) {
1022
- super(normalizeAuthOptions(normalizeClientOptions(options)));
1019
+ super(normalizeClientOptions(options));
1023
1020
  }
1024
1021
  /**
1025
1022
  * Polymorphic memory creator: dispatches to memories.create or memories.append
@@ -1103,21 +1100,12 @@ var Nebula = class extends NebulaClient {
1103
1100
  }, options);
1104
1101
  }
1105
1102
  };
1106
- function normalizeAuthOptions(options) {
1107
- if (options.apiKey != null && options.bearerToken == null && !looksLikeNebulaAPIKey(options.apiKey)) return {
1108
- ...options,
1109
- apiKey: void 0,
1110
- bearerToken: options.apiKey
1111
- };
1112
- return options;
1113
- }
1114
1103
  function normalizeClientOptions(options) {
1115
- const { apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, timeout: timeoutAlias, bearerToken, ...rest } = options;
1104
+ const { apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, timeout: timeoutAlias, ...rest } = options;
1116
1105
  const restClientOptions = rest;
1117
1106
  return {
1118
1107
  ...restClientOptions,
1119
1108
  apiKey: apiKey ?? void 0,
1120
- bearerToken: bearerToken ?? void 0,
1121
1109
  baseUrl: firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? void 0,
1122
1110
  timeoutMs: firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? void 0
1123
1111
  };
@@ -1125,12 +1113,6 @@ function normalizeClientOptions(options) {
1125
1113
  function firstDefined(...values) {
1126
1114
  return values.find((value) => value !== void 0);
1127
1115
  }
1128
- function looksLikeNebulaAPIKey(token) {
1129
- const parts = token.split(".");
1130
- if (parts.length !== 2) return false;
1131
- const [publicPart, rawPart] = parts;
1132
- return Boolean(rawPart) && (publicPart.startsWith("key_") || publicPart.startsWith("neb_"));
1133
- }
1134
1116
  function toMemoryCreateParams(memory) {
1135
1117
  const collectionID = memory.collection_id ?? memory.collectionId ?? void 0;
1136
1118
  const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/runtime/errors.ts","../src/runtime/retry.ts","../src/runtime/client.ts","../src/resources/client.ts","../src/resources/collections.ts","../src/resources/connectors.ts","../src/resources/memories.ts","../src/resources/snapshots.ts","../src/resources/workspaces.ts","../src/client.ts","../src/lib/dx.ts"],"sourcesContent":["export class NebulaError extends Error {\n override readonly name: string = \"NebulaError\";\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n }\n}\n\nexport class NebulaConnectionError extends NebulaError {\n override readonly name = \"NebulaConnectionError\";\n}\n\nexport class NebulaTimeoutError extends NebulaError {\n override readonly name = \"NebulaTimeoutError\";\n}\n\n// Canonical Error envelope returned by every Nebula 4xx/5xx. The runtime\n// pulls these fields out of the response body and surfaces them as typed\n// accessors on NebulaAPIError so callers can branch on err.code without\n// digging into err.body.\n//\n// The optional fields are typed as `T | null` because the wire schema is\n// `anyOf [T, null]` — the server emits the keys with explicit `null` rather\n// than omitting them. The NebulaAPIError constructor coerces `null` to\n// `undefined` so the public accessor surface stays `T | undefined`.\nexport interface ErrorEnvelope {\n readonly type: string;\n readonly message: string;\n readonly code?: string | null;\n readonly request_id?: string | null;\n // `details` is intentionally `unknown`: the server emits arbitrary\n // JSON here. For validation errors it's an array of {loc, msg, type}\n // entries; for other classes it can be an object or null. Callers\n // should narrow at the read site (e.g. `Array.isArray(err.details)`).\n readonly details?: unknown;\n}\n\nexport interface APIErrorPayload {\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n}\n\nfunction isEnvelope(body: unknown): body is ErrorEnvelope {\n return (\n typeof body === \"object\" &&\n body !== null &&\n typeof (body as { type?: unknown }).type === \"string\" &&\n typeof (body as { message?: unknown }).message === \"string\"\n );\n}\n\nexport class NebulaAPIError extends NebulaError {\n override readonly name: string = \"NebulaAPIError\";\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n // Canonical envelope fields. `type` is always present when the server\n // returned the documented envelope; the rest are present when the server\n // populated them. All four are undefined when the response body wasn't\n // an envelope (e.g. an HTML error page from a misconfigured proxy).\n readonly type?: string;\n readonly code?: string;\n readonly details?: unknown;\n\n constructor(payload: APIErrorPayload, message?: string) {\n const envelope = isEnvelope(payload.body) ? payload.body : undefined;\n super(\n message ??\n envelope?.message ??\n `Nebula API error (status ${payload.status})`\n );\n this.status = payload.status;\n // Coerce `null` (wire-level) to `undefined` (idiomatic JS absence) so\n // every accessor's runtime value matches its declared T | undefined.\n const envCode =\n typeof envelope?.code === \"string\" ? envelope.code : undefined;\n const envRid =\n typeof envelope?.request_id === \"string\"\n ? envelope.request_id\n : undefined;\n // Prefer the envelope's request_id (server-stamped) over the header\n // we captured at the transport — they should match, but if they\n // diverge the envelope is authoritative.\n this.requestId = envRid ?? payload.requestId;\n this.body = payload.body;\n this.type = envelope?.type;\n this.code = envCode;\n this.details = envelope?.details ?? undefined;\n }\n}\n\nexport class NebulaBadRequestError extends NebulaAPIError {\n override readonly name = \"NebulaBadRequestError\";\n}\nexport class NebulaUnauthorizedError extends NebulaAPIError {\n override readonly name = \"NebulaUnauthorizedError\";\n}\nexport class NebulaForbiddenError extends NebulaAPIError {\n override readonly name = \"NebulaForbiddenError\";\n}\nexport class NebulaNotFoundError extends NebulaAPIError {\n override readonly name = \"NebulaNotFoundError\";\n}\nexport class NebulaConflictError extends NebulaAPIError {\n override readonly name = \"NebulaConflictError\";\n}\nexport class NebulaValidationError extends NebulaAPIError {\n override readonly name = \"NebulaValidationError\";\n}\nexport class NebulaRateLimitError extends NebulaAPIError {\n override readonly name = \"NebulaRateLimitError\";\n readonly retryAfter?: number;\n constructor(payload: APIErrorPayload, retryAfter?: number) {\n super(payload);\n this.retryAfter = retryAfter;\n }\n}\nexport class NebulaServerError extends NebulaAPIError {\n override readonly name = \"NebulaServerError\";\n}\n\ntype APIErrorCtor = new (payload: APIErrorPayload) => NebulaAPIError;\n\nconst STATUS_TO_CLASS: Record<number, APIErrorCtor> = {\n 400: NebulaBadRequestError,\n 401: NebulaUnauthorizedError,\n 403: NebulaForbiddenError,\n 404: NebulaNotFoundError,\n 409: NebulaConflictError,\n 422: NebulaValidationError,\n};\n\nexport function errorFromResponse(payload: APIErrorPayload, retryAfter?: number): NebulaAPIError {\n if (payload.status === 429) return new NebulaRateLimitError(payload, retryAfter);\n const cls = STATUS_TO_CLASS[payload.status];\n if (cls) return new cls(payload);\n if (payload.status >= 500) return new NebulaServerError(payload);\n return new NebulaAPIError(payload);\n}\n","export interface RetryPolicy {\n readonly maxRetries: number;\n readonly baseMs: number;\n readonly maxMs: number;\n}\n\nexport const DEFAULT_RETRY: RetryPolicy = {\n maxRetries: 2,\n baseMs: 250,\n maxMs: 8000,\n};\n\nconst RETRYABLE_STATUSES: ReadonlySet<number> = new Set([408, 429, 502, 503, 504]);\n\nexport function isRetryableStatus(status: number): boolean {\n return RETRYABLE_STATUSES.has(status);\n}\n\nexport function backoffMs(attempt: number, policy: RetryPolicy, retryAfterSec?: number): number {\n if (retryAfterSec != null && Number.isFinite(retryAfterSec)) {\n return Math.min(retryAfterSec * 1000, policy.maxMs);\n }\n const exp = Math.min(policy.baseMs * 2 ** attempt, policy.maxMs);\n return Math.floor(Math.random() * exp);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (ms <= 0) return Promise.resolve();\n return new Promise((resolveSleep, reject) => {\n const handle = setTimeout(resolveSleep, ms);\n if (signal) {\n const onAbort = () => {\n clearTimeout(handle);\n reject(signal.reason ?? new Error(\"aborted\"));\n };\n if (signal.aborted) onAbort();\n else signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n}\n","import {\n errorFromResponse,\n NebulaAPIError,\n NebulaConnectionError,\n NebulaTimeoutError,\n} from \"./errors.ts\";\nimport { backoffMs, DEFAULT_RETRY, isRetryableStatus, sleep, type RetryPolicy } from \"./retry.ts\";\n\nexport interface ClientOptions {\n baseUrl?: string;\n apiKey?: string;\n bearerToken?: string;\n defaultHeaders?: Record<string, string>;\n fetchImpl?: typeof fetch;\n // Caller-supplied RequestInit fields applied to every outbound fetch.\n // Lets browser callers pass `credentials: \"include\"` for cookie auth,\n // or `mode`/`cache`/`referrer` for cross-origin tuning. Method, headers,\n // body, and signal are owned by the runtime and cannot be overridden\n // here (they're set per-request).\n fetchOptions?: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n timeoutMs?: number;\n retry?: Partial<RetryPolicy>;\n userAgent?: string;\n}\n\nexport interface RequestArgs {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n pathParams?: Record<string, string | number>;\n query?: Record<string, unknown>;\n body?: unknown;\n headers?: Record<string, string>;\n idempotent?: boolean;\n signal?: AbortSignal;\n}\n\n/** Per-call options every generated resource method accepts. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n}\n\nconst DEFAULT_BASE_URL = \"https://api.zeroset.com\";\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\nexport class NebulaCore {\n readonly baseUrl: string;\n readonly apiKey?: string;\n readonly bearerToken?: string;\n readonly defaultHeaders: Record<string, string>;\n readonly fetchImpl: typeof fetch;\n readonly fetchOptions: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n readonly timeoutMs: number;\n readonly retry: RetryPolicy;\n readonly userAgent: string;\n\n constructor(options: ClientOptions = {}) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n this.bearerToken = options.bearerToken;\n // Filter null/undefined values. Callers (often using `as any` to\n // bypass the `Record<string, string>` type) pass nulls to suppress\n // a header — but `new Headers({k: null})` coerces null to the\n // literal string \"null\", which a backend that checks \"is this\n // header present\" treats as an explicit credential. Strip nulls\n // here so the Headers constructor sees only real string values.\n this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);\n this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);\n this.fetchOptions = options.fetchOptions ?? {};\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.retry = { ...DEFAULT_RETRY, ...(options.retry ?? {}) };\n this.userAgent = options.userAgent ?? \"nebula-sdk-js/0.0.1\";\n }\n\n buildUrl(path: string, pathParams?: Record<string, string | number>, query?: Record<string, unknown>): string {\n let resolved = path;\n if (pathParams) {\n for (const [k, v] of Object.entries(pathParams)) {\n resolved = resolved.replace(`{${k}}`, encodeURIComponent(String(v)));\n }\n }\n const url = new URL(this.baseUrl + resolved);\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v)) for (const item of v) url.searchParams.append(k, String(item));\n else url.searchParams.set(k, String(v));\n }\n }\n return url.toString();\n }\n\n private buildHeaders(perRequest?: Record<string, string>, hasBody = false): Headers {\n const headers = new Headers(this.defaultHeaders);\n headers.set(\"User-Agent\", this.userAgent);\n headers.set(\"Accept\", \"application/json\");\n if (hasBody) headers.set(\"Content-Type\", \"application/json\");\n if (this.apiKey) headers.set(\"X-API-Key\", this.apiKey);\n if (this.bearerToken) headers.set(\"Authorization\", `Bearer ${this.bearerToken}`);\n if (perRequest) {\n for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);\n }\n return headers;\n }\n\n async request<T>(args: RequestArgs): Promise<T> {\n const url = this.buildUrl(args.path, args.pathParams, args.query);\n const hasBody = args.body !== undefined && args.body !== null;\n const headers = this.buildHeaders(args.headers, hasBody);\n // Spread caller-supplied fetch options first so the runtime-owned\n // method/headers/body always win on key collision. The TS type for\n // `fetchOptions` already excludes those keys, so this is belt-and-\n // suspenders.\n const init: RequestInit = {\n ...this.fetchOptions,\n method: args.method,\n headers,\n body: hasBody ? JSON.stringify(args.body) : undefined,\n };\n\n const maxAttempts = (args.idempotent ?? false) ? this.retry.maxRetries + 1 : 1;\n let lastError: unknown;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n const controller = new AbortController();\n const timeoutHandle = setTimeout(() => controller.abort(new Error(\"timeout\")), this.timeoutMs);\n const { signal: composedSignal, dispose: disposeAbort } = composeAbort(\n controller.signal,\n args.signal\n );\n try {\n const response = await this.fetchImpl(url, { ...init, signal: composedSignal });\n\n if (response.ok) {\n if (response.status === 204) return undefined as T;\n return (await response.json()) as T;\n }\n\n const text = await safeReadText(response);\n const parsed = safeParseJSON(text);\n const retryAfter = parseRetryAfter(response.headers.get(\"Retry-After\"));\n const err = errorFromResponse(\n {\n status: response.status,\n requestId: response.headers.get(\"X-Request-Id\") ?? undefined,\n body: parsed ?? text,\n },\n retryAfter\n );\n\n if (isRetryableStatus(response.status) && attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry, retryAfter), args.signal);\n lastError = err;\n continue;\n }\n throw err;\n } catch (rawError) {\n if (rawError instanceof Error && rawError.name === \"AbortError\") {\n if (args.signal?.aborted) throw rawError;\n throw new NebulaTimeoutError(`Request timed out after ${this.timeoutMs}ms`, { cause: rawError });\n }\n if (rawError instanceof NebulaAPIError || rawError instanceof NebulaConnectionError) {\n throw rawError;\n }\n if (attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry), args.signal);\n lastError = rawError;\n continue;\n }\n if (rawError instanceof Error) {\n throw new NebulaConnectionError(rawError.message, { cause: rawError });\n }\n throw rawError;\n } finally {\n clearTimeout(timeoutHandle);\n disposeAbort();\n }\n }\n throw lastError ?? new NebulaConnectionError(\"retry budget exhausted\");\n }\n}\n\nfunction composeAbort(\n timeoutSignal: AbortSignal,\n userSignal?: AbortSignal\n): { signal: AbortSignal; dispose: () => void } {\n if (!userSignal) return { signal: timeoutSignal, dispose: () => {} };\n const controller = new AbortController();\n // Hold one listener per source so dispose can detach exactly what we added.\n // Caller's signal can outlive the request (e.g. a long-lived request-scope\n // controller reused across many SDK calls); without dispose, each call's\n // closures would stay pinned on it until that signal eventually aborts.\n const onTimeoutAbort = () =>\n controller.abort(timeoutSignal.reason ?? new Error(\"aborted\"));\n const onUserAbort = () =>\n controller.abort(userSignal.reason ?? new Error(\"aborted\"));\n if (timeoutSignal.aborted) controller.abort(timeoutSignal.reason);\n if (userSignal.aborted) controller.abort(userSignal.reason);\n timeoutSignal.addEventListener(\"abort\", onTimeoutAbort, { once: true });\n userSignal.addEventListener(\"abort\", onUserAbort, { once: true });\n const dispose = () => {\n timeoutSignal.removeEventListener(\"abort\", onTimeoutAbort);\n userSignal.removeEventListener(\"abort\", onUserAbort);\n };\n return { signal: controller.signal, dispose };\n}\n\nasync function safeReadText(response: Response): Promise<string> {\n try {\n return await response.text();\n } catch {\n return \"\";\n }\n}\n\nfunction safeParseJSON(text: string): unknown {\n if (!text) return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction filterNullishHeaders(\n headers: Record<string, string> | undefined\n): Record<string, string> {\n if (!headers) return {};\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(headers)) {\n // Accept anything that survives the truthy guard; the type is\n // `Record<string, string>` but callers occasionally cast with\n // `as any` to slip nulls through.\n if (v !== null && v !== undefined) out[k] = v;\n }\n return out;\n}\n\nfunction parseRetryAfter(header: string | null): number | undefined {\n if (!header) return undefined;\n const asNumber = Number.parseFloat(header);\n if (Number.isFinite(asNumber)) return asNumber;\n const asDate = Date.parse(header);\n if (Number.isFinite(asDate)) return Math.max(0, (asDate - Date.now()) / 1000);\n return undefined;\n}\n","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ClientResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Health probe\n *\n * 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.\n * @operationId client.health\n * @endpoint GET /v1/health\n */\n async health(options?: RequestOptions): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"GET\",\n path: \"/v1/health\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class CollectionsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create a new collection\n *\n * Create a new collection and automatically add the creating user\n * to it.\n *\n * This endpoint allows authenticated users to create a new collection\n * with a specified name and optional description. The user creating\n * the collection is automatically added as a member.\n * @operationId collections.create\n * @endpoint POST /v1/collections\n */\n async create(\n body: components[\"schemas\"][\"CreateCollectionRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Delete collection\n *\n * Delete an existing collection.\n *\n * This endpoint allows deletion of a collection identified by its\n * UUID. The user must have appropriate permissions to delete the\n * collection. Deleting a collection removes all associations but does\n * not delete the engrams within it.\n * @operationId collections.delete\n * @endpoint DELETE /v1/collections/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * List collections\n *\n * Returns a cursor-paginated list of collections the authenticated\n * user has access to.\n *\n * Results can be filtered by providing specific collection IDs.\n * Regular users will only see collections they own or have access to.\n * Superusers can see all collections.\n *\n * The collections are returned in order of last modification, with\n * most recent first.\n * @operationId collections.list\n * @endpoint GET /v1/collections\n */\n async list(\n params: {\n /** A list of collection IDs to retrieve. If not provided, all collections will be returned. */\n ids?: Array<string>;\n /** Filter collections by name (case-insensitive exact match). */\n name?: string | null;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** If true, only returns collections owned by the user, not all accessible collections. */\n ownerOnly?: boolean;\n /** Filter by workspace ID. Pass a UUID to scope to a workspace, or omit for all. */\n workspaceId?: string | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedCollectionResponse\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections\",\n pathParams: {},\n query: { ids: params.ids, name: params.name, cursor: params.cursor, limit: params.limit, owner_only: params.ownerOnly, workspace_id: params.workspaceId },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Get collection details\n *\n * Get details of a specific collection.\n *\n * This endpoint retrieves detailed information about a single\n * collection identified by its UUID. The user must have access to the\n * collection to view its details.\n * @operationId collections.retrieve\n * @endpoint GET /v1/collections/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Get a collection by name\n *\n * Retrieve a collection by its (owner_id, name) combination.\n *\n * The authenticated user can only fetch collections they own, or, if\n * superuser, from anyone.\n * @operationId collections.retrieveByName\n * @endpoint GET /v1/collections/name/{collection_name}\n */\n async retrieveByName(\n params: {\n /** The name of the collection */\n collectionName: string;\n /** (Superuser only) Specify the owner_id to retrieve a collection by name */\n ownerId?: string | null;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/name/{collection_name}\",\n pathParams: { collection_name: params.collectionName },\n query: { owner_id: params.ownerId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Update collection\n *\n * Update an existing collection's configuration.\n *\n * This endpoint allows updating the name, description, and access settings of an\n * existing collection. The user must have appropriate permissions to\n * modify the collection.\n * @operationId collections.update\n * @endpoint POST /v1/collections/{id}\n */\n async update(\n params: {\n /** The unique identifier of the collection to update */\n id: string;\n body: components[\"schemas\"][\"UpdateCollectionRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ConnectorsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Start OAuth connection flow\n *\n * 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.\n * @operationId connectors.connect\n * @endpoint POST /v1/connectors/{provider}/connect\n */\n async connect(\n params: {\n provider: string;\n body: components[\"schemas\"][\"ConnectRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{provider}/connect\",\n pathParams: { provider: params.provider },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectResponse\"] };\n return response.results;\n }\n\n /**\n * Disconnect an external data source\n *\n * 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.\n * @operationId connectors.disconnect\n * @endpoint DELETE /v1/connectors/{connection_id}\n */\n async disconnect(\n params: {\n connectionId: string;\n deleteMemories?: boolean;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorDisconnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorDisconnectResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: params.connectionId },\n query: { delete_memories: params.deleteMemories },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorDisconnectResponse\"] };\n return response.results;\n }\n\n /**\n * List active connections for a collection\n *\n * 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.\n * @operationId connectors.list\n * @endpoint GET /v1/connectors\n */\n async list(\n params: {\n collectionId: string;\n},\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors\",\n pathParams: {},\n query: { collection_id: params.collectionId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]> };\n return response.results;\n }\n\n /**\n * List available connector providers\n *\n * 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.\n * @operationId connectors.listProviders\n * @endpoint GET /v1/connectors/providers\n */\n async listProviders(options?: RequestOptions): Promise<Array<string>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStr\"]>({\n method: \"GET\",\n path: \"/v1/connectors/providers\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<string> };\n return response.results;\n }\n\n /**\n * Get a single connection by ID\n *\n * 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.\n * @operationId connectors.retrieve\n * @endpoint GET /v1/connectors/{connection_id}\n */\n async retrieve(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectionResponse\"] };\n return response.results;\n }\n\n /**\n * Manually trigger a sync\n *\n * 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.\n * @operationId connectors.sync\n * @endpoint POST /v1/connectors/{connection_id}/sync\n */\n async sync(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorSyncResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorSyncResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{connection_id}/sync\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorSyncResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class MemoriesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Append content to an engram\n *\n * Append content to an existing engram.\n *\n * **For conversation engrams:**\n * - Provide `messages` array with content, role, and optional metadata\n * - Works like `/conversations/{id}/messages` endpoint\n *\n * **For document engrams:**\n * - Provide either `raw_text` or `chunks` to append additional content\n * - Content will be processed and added to the engram\n * @operationId memories.append\n * @endpoint POST /v1/memories/{id}/append\n */\n async append(\n params: {\n /** The unique identifier of the engram */\n id: string;\n body: components[\"schemas\"][\"AppendMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/{id}/append\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"] };\n return response.results;\n }\n\n /**\n * Create a new memory (conversation or document)\n *\n * Create a new memory (conversation or document) using clean JSON body.\n *\n * - Use `collection_id` (UUID)\n * - `kind` is optional and inferred from payload shape:\n * - If `messages` present -> conversation\n * - Otherwise -> document\n * - For conversations: provide `messages` array\n * - For documents: provide `raw_text` or `chunks`\n * - Use `snapshot` for device-memory mode (mutually exclusive with collection_id)\n * @operationId memories.create\n * @endpoint POST /v1/memories\n */\n async create(\n body: components[\"schemas\"][\"CreateMemoryRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"MemoryCreateResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"] };\n return response.results;\n }\n\n /**\n * Get presigned URL for large file upload\n *\n * Get a presigned URL for uploading large files directly to S3.\n *\n * Use this for files larger than 5MB that cannot be sent inline as base64.\n * After uploading, reference the file in memory creation using S3FileReference.\n *\n * Args:\n * filename: Original filename (e.g., \"image.jpg\")\n * content_type: MIME type (e.g., \"image/jpeg\", \"application/pdf\")\n * file_size: Expected file size in bytes (max 100MB)\n *\n * Returns:\n * dict with:\n * - upload_url: Presigned URL for PUT request (expires in 1 hour)\n * - upload_headers: Headers that must be sent with the presigned PUT request\n * - s3_key: The S3 key to reference in memory creation\n * - bucket: S3 bucket name\n * - expires_in: Seconds until URL expires\n * - max_size: Maximum allowed file size\n * @operationId memories.createUpload\n * @endpoint POST /v1/memories/upload\n */\n async createUpload(\n params: {\n /** Original filename (e.g., 'image.jpg') */\n filename: string;\n /** MIME type (e.g., 'image/jpeg', 'application/pdf') */\n contentType: string;\n /** Expected file size in bytes (max 100MB) */\n fileSize: number;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PresignedUploadResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedPresignedUploadResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { filename: params.filename, content_type: params.contentType, file_size: params.fileSize },\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"PresignedUploadResponse\"] };\n return response.results;\n }\n\n /**\n * Delete an engram\n *\n * Delete a specific engram with graph awareness. All chunks corresponding to the\n * engram are deleted, and graph components (entities/relationships) are updated\n * or deleted based on remaining chunk references from other engrams.\n *\n * This method now properly handles graph components and maintains graph integrity\n * for search operations.\n * @operationId memories.delete\n * @endpoint DELETE /v1/memories/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * Delete one or more engrams\n *\n * Delete one or more engrams.\n *\n * This endpoint efficiently handles both single and batch deletions.\n * When multiple IDs are provided, it uses optimized batch operations.\n *\n * Args:\n * ids: Either a single UUID or a list of UUIDs to delete\n *\n * Returns:\n * For single deletion: boolean success response\n * For batch deletion: detailed results with successful and failed deletions\n * @operationId memories.deleteMany\n * @endpoint POST /v1/memories/delete\n */\n async deleteMany(\n body: components[\"schemas\"][\"DeleteMemoriesRequest\"],\n options?: RequestOptions,\n ): Promise<unknown> {\n return this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/delete\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n });\n }\n\n /**\n * Delete a previously uploaded S3 file\n *\n * Delete a file from S3 that was uploaded via a presigned URL.\n * Verifies the caller owns the file via S3 object metadata.\n * @operationId memories.deleteUpload\n * @endpoint DELETE /v1/memories/upload\n */\n async deleteUpload(\n params: {\n /** S3 key of the file to delete (returned by POST /memories/upload) */\n s3Key: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { s3_key: params.s3Key },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n /**\n * List engrams\n *\n * Returns a cursor-paginated list of engrams the authenticated user\n * has access to.\n *\n * Results can be filtered by providing specific engram IDs or collection IDs.\n * Regular users will only see engrams they own or have access to through\n * collections. Superusers can see all engrams.\n *\n * The engrams are returned in order of creation time, most recent\n * first. The response includes the engram's text field if available.\n * @operationId memories.list\n * @endpoint GET /v1/memories\n */\n async list(\n params: {\n /** A list of engram IDs to retrieve. If not provided, all engrams will be returned. */\n ids?: Array<string>;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** Maximum chunks to inline per engram. Defaults to all chunks for backwards compatibility; pass 0 to skip chunk hydration. */\n chunksLimit?: number | null;\n /** If true, only returns engrams owned by the user, not all accessible engrams. */\n ownerOnly?: boolean;\n /** Optional list of collection IDs to filter engrams by. If provided, exactly one collection ID must be specified. */\n collectionIds?: Array<string> | null;\n /** JSON string for metadata filtering. Example: '{\"metadata.source\": {\"$eq\": \"playground\"}}' */\n metadataFilters?: string | null;\n /** Read-your-writes assertion: the WAL-tail overlay path waits for at least this seq to be applied before serving (or returns 503 Unavailable on timeout). REQUIRES exactly one collection_ids entry — without a collection scope the request returns 422 (the per-WAL-shard scalar applied_wal_seq is meaningless across collections). When the served shard has not been migrated to wal_compaction_enabled, the field is accepted but the served path is the legacy overlay (the assertion has no effect — the response's applied_wal_seq will be 0). Pass back the value the matching upload response surfaced. */\n minAppliedWalSeq?: number | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedListedEngram\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedListedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories\",\n pathParams: {},\n query: { ids: params.ids, cursor: params.cursor, limit: params.limit, chunks_limit: params.chunksLimit, owner_only: params.ownerOnly, collection_ids: params.collectionIds, metadata_filters: params.metadataFilters, min_applied_wal_seq: params.minAppliedWalSeq },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Recall workflow patterns by intent\n *\n * Workflow-pattern recall over 5 intents.\n *\n * * ``cursor`` -- match the caller's anchor against pattern\n * canonical states, return ranked patterns + position.\n * * ``predict`` -- like cursor but include the predicted next\n * trace from each pattern's canonical instance.\n * * ``resume`` -- like cursor, biased toward longer patterns.\n * * ``evidence`` -- expand a specific pattern via\n * ``hydrate_pattern``.\n * * ``bootstrap`` -- top-K patterns by confidence with no anchor.\n * @operationId memories.recallWorkflow\n * @endpoint POST /v1/memories/workflow/recall\n */\n async recallWorkflow(\n body: components[\"schemas\"][\"CursorRecallRequest\"] | components[\"schemas\"][\"PredictRecallRequest\"] | components[\"schemas\"][\"ResumeRecallRequest\"] | components[\"schemas\"][\"EvidenceRecallRequest\"] | components[\"schemas\"][\"BootstrapRecallRequest\"],\n options?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n const response = (await this.core.request<components[\"schemas\"][\"WorkflowRecallResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/workflow/recall\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: Record<string, unknown> };\n return response.results;\n }\n\n /**\n * Retrieve an engram\n *\n * Retrieves detailed information about a specific engram by its\n * ID.\n *\n * This endpoint returns the engram's metadata, status, and system information. It does not\n * return the engram's content - use the `/engrams/{id}/download` endpoint for that.\n *\n * Users can only retrieve engrams they own or have access to through collections.\n * Superusers can retrieve any engram.\n * @operationId memories.retrieve\n * @endpoint GET /v1/memories/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n /**\n * Search memories\n *\n * Perform a search query across your memories.\n *\n * **Standard mode** (collection_ids or readable-scope search): returns hierarchical MemoryRecall\n * with semantics, episodes, procedures, and sources.\n *\n * **Snapshot mode** (snapshot field): returns graph-search results with\n * {entities, relationships} from stateless in-memory traversal.\n * @operationId memories.search\n * @endpoint POST /v1/memories/search\n */\n async search(\n body: components[\"schemas\"][\"MemorySearchRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/search\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"] };\n return response.results;\n }\n\n /**\n * Update a memory\n *\n * Update memory-level properties including name, metadata, and collection associations.\n *\n * This endpoint allows updating properties of an entire memory (document or conversation)\n * without modifying its content:\n * - **name**: Updates the authoritative engram title\n * - **metadata**: Can replace or merge with existing metadata\n * - **collection_ids**: Updates authoritative engram collection associations\n *\n * Users can only update memories they own or have access to through collections.\n * At least one collection association must be maintained.\n *\n * If collection_id is provided and the engram is shared across collections, a copy-on-write\n * will be performed to create a collection-specific copy before modification.\n * @operationId memories.update\n * @endpoint PATCH /v1/memories/{id}\n */\n async update(\n params: {\n /** The unique identifier of the memory */\n id: string;\n /** Collection context for copy-on-write. If provided and engram is shared, creates a copy before modification. */\n collectionId?: string | null;\n body: components[\"schemas\"][\"UpdateMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"PATCH\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: params.id },\n query: { collection_id: params.collectionId },\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class SnapshotsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Export a collection snapshot\n *\n * Export a collection's full graph state as a\n * portable SnapshotEnvelope.\n * @operationId snapshots.export\n * @endpoint POST /v1/device-memory/snapshot/export\n */\n async export(\n body: components[\"schemas\"][\"SnapshotExportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotEnvelopeOrSnapshotObjectReference\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/export\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"] };\n return response.results;\n }\n\n /**\n * Import a snapshot into an ephemeral collection\n *\n * Import a SnapshotEnvelope into an ephemeral\n * collection. Returns the ephemeral collection UUID.\n * @operationId snapshots.import\n * @endpoint POST /v1/device-memory/snapshot/import\n */\n async import(\n body: components[\"schemas\"][\"SnapshotImportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotImportResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotImportResult\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/import\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotImportResult\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class WorkspacesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create workspace storage target\n *\n * Register a customer S3 bucket for hosted BYOC storage.\n * @operationId workspaces.createStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets\n */\n async createStorageTarget(\n params: {\n workspaceId: string;\n body: components[\"schemas\"][\"StorageTargetCreateRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: params.workspaceId },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * Disable workspace storage target\n *\n * Disable a customer storage target for future collection binds.\n * @operationId workspaces.disableStorageTarget\n * @endpoint DELETE /v1/workspaces/{workspace_id}/storage-targets/{target_id}\n */\n async disableStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * List workspace storage targets\n *\n * List customer-owned object storage targets for a workspace.\n * @operationId workspaces.listStorageTargets\n * @endpoint GET /v1/workspaces/{workspace_id}/storage-targets\n */\n async listStorageTargets(\n workspaceId: string,\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"StorageTargetResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStorageTargetResponse\"]>({\n method: \"GET\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: workspaceId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"StorageTargetResponse\"]> };\n return response.results;\n }\n\n /**\n * Validate workspace storage target\n *\n * Probe a customer storage target and mark it active on success.\n * @operationId workspaces.validateStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\n */\n async validateStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport { NebulaCore, type ClientOptions } from \"./runtime/client.ts\";\nimport { ClientResource } from \"./resources/client.ts\";\nimport { CollectionsResource } from \"./resources/collections.ts\";\nimport { ConnectorsResource } from \"./resources/connectors.ts\";\nimport { MemoriesResource } from \"./resources/memories.ts\";\nimport { SnapshotsResource } from \"./resources/snapshots.ts\";\nimport { WorkspacesResource } from \"./resources/workspaces.ts\";\n\nexport class NebulaClient {\n protected readonly core: NebulaCore;\n readonly client: ClientResource;\n readonly collections: CollectionsResource;\n readonly connectors: ConnectorsResource;\n readonly memories: MemoriesResource;\n readonly snapshots: SnapshotsResource;\n readonly workspaces: WorkspacesResource;\n\n constructor(options: ClientOptions = {}) {\n this.core = new NebulaCore(options);\n this.client = new ClientResource(this.core);\n this.collections = new CollectionsResource(this.core);\n this.connectors = new ConnectorsResource(this.core);\n this.memories = new MemoriesResource(this.core);\n this.snapshots = new SnapshotsResource(this.core);\n this.workspaces = new WorkspacesResource(this.core);\n }\n}","// Handwritten Nebula DX layer.\n//\n// Carries only the methods that need real dispatch logic: storeMemory's\n// create-vs-append branch, bulk storeMemories with a concurrency cap,\n// positional connector helpers (connectProvider/listConnections/\n// disconnectConnection), and auth normalization.\n//\n// For everything else, use the resource methods directly. Resource\n// methods now return unwrapped values natively (the generator peels\n// the `{results: X}` wire envelope), so there's no separate auto-\n// generated unwrap layer to extend.\n//\n// Source of truth: nebula-sdks/custom/typescript/dx.ts\n// The generator copies this file into sdks/typescript/src/lib/dx.ts on every\n// `bun run generate`. Edit the source, not the copy.\n\nimport { NebulaClient } from \"../client.ts\";\nimport {\n type ClientOptions,\n type components,\n} from \"../index.ts\";\n\ntype Schemas = components[\"schemas\"];\ntype SnapshotEnvelopeInput = Schemas[\"SnapshotEnvelope-Input\"];\ntype SnapshotEnvelopeOutput = Schemas[\"SnapshotEnvelope-Output\"];\n\nexport type CompatClientOptions = ClientOptions & {\n apiKey?: string | null;\n baseUrl?: string | null;\n // Stainless-shape capital-U alias. Some internal callers\n // (backend/local-websocket-server, backend/lambda/websocket-llm) still\n // pass `baseURL`; without this alias the value falls through unused\n // and the runtime defaults to api.zeroset.com.\n baseURL?: string | null;\n // Stainless-shape alias for `timeoutMs`. Same compat reason.\n timeout?: number | null;\n bearerToken?: string | null;\n};\n\nexport interface MemoryCommonInput {\n collection_id?: string | null;\n collectionId?: string | null;\n content?: string | string[] | unknown[] | null;\n raw_text?: string | null;\n chunks?: Array<string> | null;\n messages?: unknown[] | null;\n metadata?: { [key: string]: unknown } | null;\n ingestion_config?: unknown;\n ingestion_mode?: string | null;\n}\n\nexport interface MemoryCreateInput extends MemoryCommonInput {\n kind?: Schemas[\"EngramKind\"] | null;\n name?: string | null;\n speaker_id?: string | null;\n speaker_name?: string | null;\n content_parts?: unknown[] | null;\n contents?: string[] | null;\n snapshot?: SnapshotEnvelopeInput | null;\n memory_id?: undefined | null;\n}\n\nexport interface MemoryAppendInput extends Omit<MemoryCommonInput, \"ingestion_mode\" | \"messages\"> {\n memory_id: string;\n ingestion_mode?: string | null;\n messages?: unknown[] | null;\n}\n\nexport type MemoryInput = MemoryCreateInput | MemoryAppendInput;\n\ntype MemoryCreateBody = Schemas[\"CreateMemoryRequest\"];\ntype MemoryAppendBody = Schemas[\"AppendMemoryRequest\"];\n\nexport class Nebula extends NebulaClient {\n constructor(options: CompatClientOptions = {}) {\n super(normalizeAuthOptions(normalizeClientOptions(options)));\n }\n\n /**\n * Polymorphic memory creator: dispatches to memories.create or memories.append\n * based on whether `memory_id` is set on the input. Returns the new memory's\n * id (string), or — when `snapshot` is set — the updated snapshot envelope.\n */\n async storeMemory(\n memory: MemoryInput,\n options?: { signal?: AbortSignal }\n ): Promise<string | SnapshotEnvelopeOutput> {\n if (\"memory_id\" in memory && memory.memory_id != null) {\n const memoryID = memory.memory_id;\n await this.memories.append(\n { id: memoryID, body: toMemoryAppendParams(memory) },\n options\n );\n return memoryID;\n }\n // `memories.create` now returns the unwrapped inner type directly\n // (the generator peels the wire `{results: X}` envelope).\n const result = await this.memories.create(\n toMemoryCreateParams(memory as MemoryCreateInput),\n options\n );\n if (isSnapshotResult(result)) {\n return (result.snapshot ?? result) as SnapshotEnvelopeOutput;\n }\n return extractID(result);\n }\n\n /**\n * Bulk parallel version of storeMemory with a concurrency cap.\n *\n * Default 8 concurrent in-flight requests matches the Python DX's\n * `asyncio.Semaphore(max_concurrency)` pattern. Use `maxConcurrency: 1`\n * for strictly serial submission; higher values risk overwhelming the\n * server when memories[] is large.\n */\n async storeMemories(\n memories: MemoryInput[],\n options?: { signal?: AbortSignal; maxConcurrency?: number }\n ): Promise<(string | SnapshotEnvelopeOutput)[]> {\n const cap = Math.max(1, options?.maxConcurrency ?? 8);\n const signal = options?.signal;\n const results: (string | SnapshotEnvelopeOutput)[] = new Array(memories.length);\n let nextIndex = 0;\n const worker = async (): Promise<void> => {\n while (true) {\n const i = nextIndex++;\n if (i >= memories.length) return;\n results[i] = await this.storeMemory(memories[i], { signal });\n }\n };\n await Promise.all(\n Array.from({ length: Math.min(cap, memories.length) }, () => worker())\n );\n return results;\n }\n\n /**\n * List memories scoped to one or more collection ids (string | string[])\n * or a full MemoryListParams object.\n */\n async listMemories(\n query: string | string[] | Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const normalized: Record<string, unknown> =\n typeof query === \"string\" || Array.isArray(query)\n ? { collectionIds: arrayify(query) }\n : query;\n return this.memories.list(normalized as never, options);\n }\n\n /**\n * Positional `connectProvider(provider, collectionID, config?)` — wraps the\n * generated `connectors.connect({provider, body})` to build the body shape.\n */\n async connectProvider(\n provider: string,\n collectionID: string,\n config?: Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const body: Schemas[\"ConnectRequest\"] = {\n collection_id: collectionID,\n ...(config !== undefined ? { config } : {}),\n } as Schemas[\"ConnectRequest\"];\n return this.connectors.connect({ provider, body }, options);\n }\n\n /** Positional listConnections(collectionID) — wraps the query wrapper. */\n async listConnections(\n collectionID: string,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.list({ collectionId: collectionID } as never, options);\n }\n\n /** Positional disconnect(connectionID, deleteMemories?). */\n async disconnectConnection(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n /** Alias for disconnectConnection (same arg shape). */\n async disconnect(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n}\n\n// ---------- helpers ----------\n\nfunction normalizeAuthOptions(options: ClientOptions): ClientOptions {\n if (\n options.apiKey != null &&\n options.bearerToken == null &&\n !looksLikeNebulaAPIKey(options.apiKey)\n ) {\n return { ...options, apiKey: undefined, bearerToken: options.apiKey };\n }\n return options;\n}\n\nfunction normalizeClientOptions(options: CompatClientOptions): ClientOptions {\n const {\n apiKey,\n baseUrl: baseUrlAlias,\n baseURL: baseURLCapAlias,\n timeout: timeoutAlias,\n bearerToken,\n ...rest\n } = options;\n const restClientOptions: ClientOptions = rest;\n return {\n ...restClientOptions,\n apiKey: apiKey ?? undefined,\n bearerToken: bearerToken ?? undefined,\n baseUrl:\n firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? undefined,\n timeoutMs:\n firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? undefined,\n };\n}\n\nfunction firstDefined<T>(...values: (T | null | undefined)[]): T | null | undefined {\n return values.find((value) => value !== undefined);\n}\n\nexport function looksLikeNebulaAPIKey(token: string): boolean {\n const parts = token.split(\".\");\n if (parts.length !== 2) return false;\n const [publicPart, rawPart] = parts;\n return Boolean(rawPart) && (publicPart.startsWith(\"key_\") || publicPart.startsWith(\"neb_\"));\n}\n\nfunction toMemoryCreateParams(memory: MemoryCreateInput): MemoryCreateBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;\n const params: Record<string, unknown> = { ...rest };\n\n if (collectionID !== undefined) {\n params.collection_id = collectionID;\n }\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else {\n params.content_parts = content;\n }\n }\n if (params.messages != null && !params.kind) {\n params.kind = \"conversation\";\n }\n return params as MemoryCreateBody;\n}\n\nfunction toMemoryAppendParams(memory: MemoryAppendInput): MemoryAppendBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n if (!collectionID) {\n throw new Error(\"collection_id is required when appending to an existing memory\");\n }\n const params: Record<string, unknown> = { collection_id: collectionID };\n for (const key of [\"metadata\", \"ingestion_config\", \"ingestion_mode\", \"raw_text\", \"chunks\", \"messages\"] as const) {\n const value = memory[key as keyof MemoryAppendInput];\n if (value != null) params[key] = value;\n }\n const content = (memory as MemoryCommonInput).content;\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else if (Array.isArray(content) && content.every((item) => typeof item === \"string\")) {\n params.chunks = content;\n } else if (Array.isArray(content)) {\n params.messages = content;\n }\n }\n return params as MemoryAppendBody;\n}\n\nfunction extractID(value: unknown): string {\n if (typeof value === \"object\" && value !== null) {\n const record = value as Record<string, unknown>;\n const id =\n record[\"id\"] ?? record[\"memory_id\"] ?? record[\"engram_id\"] ?? record[\"ephemeral_collection_id\"];\n if (typeof id === \"string\") return id;\n }\n throw new Error(\"Nebula memory create response did not include an id\");\n}\n\nfunction isSnapshotResult(value: unknown): value is { snapshot?: SnapshotEnvelopeOutput } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"snapshot\" in (value as Record<string, unknown>)\n );\n}\n\nfunction arrayify(value: string | string[]): string[] {\n return Array.isArray(value) ? value : [value];\n}\n"],"mappings":";;;;;AAAA,IAAa,cAAb,cAAiC,MAAM;CACrC,OAAiC;CACjC,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;CACxB;AACF;AAEA,IAAa,wBAAb,cAA2C,YAAY;CACrD,OAAyB;AAC3B;AAEA,IAAa,qBAAb,cAAwC,YAAY;CAClD,OAAyB;AAC3B;AA6BA,SAAS,WAAW,MAAsC;CACxD,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA4B,SAAS,YAC7C,OAAQ,KAA+B,YAAY;AAEvD;AAEA,IAAa,iBAA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ACT;AAEA,SAAS,qBAAqB,QAA6C;CACzE,MAAM,eAAe,OAAO,iBAAiB,OAAO,gBAAgB,KAAA;CACpE,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,gEAAgE;CAElF,MAAM,SAAkC,EAAE,eAAe,aAAa;CACtE,KAAK,MAAM,OAAO;EAAC;EAAY;EAAoB;EAAkB;EAAY;EAAU;CAAU,GAAY;EAC/G,MAAM,QAAQ,OAAO;EACrB,IAAI,SAAS,MAAM,OAAO,OAAO;CACnC;CACA,MAAM,UAAW,OAA6B;CAC9C,IAAI,WAAW;MACT,OAAO,YAAY,UACrB,OAAO,WAAW;OACb,IAAI,MAAM,QAAQ,OAAO,KAAK,QAAQ,OAAO,SAAS,OAAO,SAAS,QAAQ,GACnF,OAAO,SAAS;OACX,IAAI,MAAM,QAAQ,OAAO,GAC9B,OAAO,WAAW;CAAA;CAGtB,OAAO;AACT;AAEA,SAAS,UAAU,OAAwB;CACzC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,SAAS;EACf,MAAM,KACJ,OAAO,SAAS,OAAO,gBAAgB,OAAO,gBAAgB,OAAO;EACvE,IAAI,OAAO,OAAO,UAAU,OAAO;CACrC;CACA,MAAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,iBAAiB,OAAgE;CACxF,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAe;AAEnB;AAEA,SAAS,SAAS,OAAoC;CACpD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/runtime/errors.ts","../src/runtime/retry.ts","../src/runtime/client.ts","../src/resources/client.ts","../src/resources/collections.ts","../src/resources/connectors.ts","../src/resources/memories.ts","../src/resources/snapshots.ts","../src/resources/workspaces.ts","../src/client.ts","../src/lib/dx.ts"],"sourcesContent":["export class NebulaError extends Error {\n override readonly name: string = \"NebulaError\";\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n }\n}\n\nexport class NebulaConnectionError extends NebulaError {\n override readonly name = \"NebulaConnectionError\";\n}\n\nexport class NebulaTimeoutError extends NebulaError {\n override readonly name = \"NebulaTimeoutError\";\n}\n\n// Canonical Error envelope returned by every Nebula 4xx/5xx. The runtime\n// pulls these fields out of the response body and surfaces them as typed\n// accessors on NebulaAPIError so callers can branch on err.code without\n// digging into err.body.\n//\n// The optional fields are typed as `T | null` because the wire schema is\n// `anyOf [T, null]` — the server emits the keys with explicit `null` rather\n// than omitting them. The NebulaAPIError constructor coerces `null` to\n// `undefined` so the public accessor surface stays `T | undefined`.\nexport interface ErrorEnvelope {\n readonly type: string;\n readonly message: string;\n readonly code?: string | null;\n readonly request_id?: string | null;\n // `details` is intentionally `unknown`: the server emits arbitrary\n // JSON here. For validation errors it's an array of {loc, msg, type}\n // entries; for other classes it can be an object or null. Callers\n // should narrow at the read site (e.g. `Array.isArray(err.details)`).\n readonly details?: unknown;\n}\n\nexport interface APIErrorPayload {\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n}\n\nfunction isEnvelope(body: unknown): body is ErrorEnvelope {\n return (\n typeof body === \"object\" &&\n body !== null &&\n typeof (body as { type?: unknown }).type === \"string\" &&\n typeof (body as { message?: unknown }).message === \"string\"\n );\n}\n\nexport class NebulaAPIError extends NebulaError {\n override readonly name: string = \"NebulaAPIError\";\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n // Canonical envelope fields. `type` is always present when the server\n // returned the documented envelope; the rest are present when the server\n // populated them. All four are undefined when the response body wasn't\n // an envelope (e.g. an HTML error page from a misconfigured proxy).\n readonly type?: string;\n readonly code?: string;\n readonly details?: unknown;\n\n constructor(payload: APIErrorPayload, message?: string) {\n const envelope = isEnvelope(payload.body) ? payload.body : undefined;\n super(\n message ??\n envelope?.message ??\n `Nebula API error (status ${payload.status})`\n );\n this.status = payload.status;\n // Coerce `null` (wire-level) to `undefined` (idiomatic JS absence) so\n // every accessor's runtime value matches its declared T | undefined.\n const envCode =\n typeof envelope?.code === \"string\" ? envelope.code : undefined;\n const envRid =\n typeof envelope?.request_id === \"string\"\n ? envelope.request_id\n : undefined;\n // Prefer the envelope's request_id (server-stamped) over the header\n // we captured at the transport — they should match, but if they\n // diverge the envelope is authoritative.\n this.requestId = envRid ?? payload.requestId;\n this.body = payload.body;\n this.type = envelope?.type;\n this.code = envCode;\n this.details = envelope?.details ?? undefined;\n }\n}\n\nexport class NebulaBadRequestError extends NebulaAPIError {\n override readonly name = \"NebulaBadRequestError\";\n}\nexport class NebulaUnauthorizedError extends NebulaAPIError {\n override readonly name = \"NebulaUnauthorizedError\";\n}\nexport class NebulaForbiddenError extends NebulaAPIError {\n override readonly name = \"NebulaForbiddenError\";\n}\nexport class NebulaNotFoundError extends NebulaAPIError {\n override readonly name = \"NebulaNotFoundError\";\n}\nexport class NebulaConflictError extends NebulaAPIError {\n override readonly name = \"NebulaConflictError\";\n}\nexport class NebulaValidationError extends NebulaAPIError {\n override readonly name = \"NebulaValidationError\";\n}\nexport class NebulaRateLimitError extends NebulaAPIError {\n override readonly name = \"NebulaRateLimitError\";\n readonly retryAfter?: number;\n constructor(payload: APIErrorPayload, retryAfter?: number) {\n super(payload);\n this.retryAfter = retryAfter;\n }\n}\nexport class NebulaServerError extends NebulaAPIError {\n override readonly name = \"NebulaServerError\";\n}\n\ntype APIErrorCtor = new (payload: APIErrorPayload) => NebulaAPIError;\n\nconst STATUS_TO_CLASS: Record<number, APIErrorCtor> = {\n 400: NebulaBadRequestError,\n 401: NebulaUnauthorizedError,\n 403: NebulaForbiddenError,\n 404: NebulaNotFoundError,\n 409: NebulaConflictError,\n 422: NebulaValidationError,\n};\n\nexport function errorFromResponse(payload: APIErrorPayload, retryAfter?: number): NebulaAPIError {\n if (payload.status === 429) return new NebulaRateLimitError(payload, retryAfter);\n const cls = STATUS_TO_CLASS[payload.status];\n if (cls) return new cls(payload);\n if (payload.status >= 500) return new NebulaServerError(payload);\n return new NebulaAPIError(payload);\n}\n","export interface RetryPolicy {\n readonly maxRetries: number;\n readonly baseMs: number;\n readonly maxMs: number;\n}\n\nexport const DEFAULT_RETRY: RetryPolicy = {\n maxRetries: 2,\n baseMs: 250,\n maxMs: 8000,\n};\n\nconst RETRYABLE_STATUSES: ReadonlySet<number> = new Set([408, 429, 502, 503, 504]);\n\nexport function isRetryableStatus(status: number): boolean {\n return RETRYABLE_STATUSES.has(status);\n}\n\nexport function backoffMs(attempt: number, policy: RetryPolicy, retryAfterSec?: number): number {\n if (retryAfterSec != null && Number.isFinite(retryAfterSec)) {\n return Math.min(retryAfterSec * 1000, policy.maxMs);\n }\n const exp = Math.min(policy.baseMs * 2 ** attempt, policy.maxMs);\n return Math.floor(Math.random() * exp);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (ms <= 0) return Promise.resolve();\n return new Promise((resolveSleep, reject) => {\n const handle = setTimeout(resolveSleep, ms);\n if (signal) {\n const onAbort = () => {\n clearTimeout(handle);\n reject(signal.reason ?? new Error(\"aborted\"));\n };\n if (signal.aborted) onAbort();\n else signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n}\n","import {\n errorFromResponse,\n NebulaAPIError,\n NebulaConnectionError,\n NebulaTimeoutError,\n} from \"./errors.ts\";\nimport { backoffMs, DEFAULT_RETRY, isRetryableStatus, sleep, type RetryPolicy } from \"./retry.ts\";\n\nexport interface ClientOptions {\n baseUrl?: string;\n apiKey?: string;\n defaultHeaders?: Record<string, string>;\n fetchImpl?: typeof fetch;\n // Caller-supplied RequestInit fields applied to every outbound fetch.\n // Lets browser callers pass `credentials: \"include\"` for cookie auth,\n // or `mode`/`cache`/`referrer` for cross-origin tuning. Method, headers,\n // body, and signal are owned by the runtime and cannot be overridden\n // here (they're set per-request).\n fetchOptions?: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n timeoutMs?: number;\n retry?: Partial<RetryPolicy>;\n userAgent?: string;\n}\n\nexport interface RequestArgs {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n pathParams?: Record<string, string | number>;\n query?: Record<string, unknown>;\n body?: unknown;\n headers?: Record<string, string>;\n idempotent?: boolean;\n signal?: AbortSignal;\n}\n\n/** Per-call options every generated resource method accepts. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n}\n\nconst DEFAULT_BASE_URL = \"https://api.zeroset.com\";\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\nexport class NebulaCore {\n readonly baseUrl: string;\n readonly apiKey?: string;\n readonly defaultHeaders: Record<string, string>;\n readonly fetchImpl: typeof fetch;\n readonly fetchOptions: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n readonly timeoutMs: number;\n readonly retry: RetryPolicy;\n readonly userAgent: string;\n\n constructor(options: ClientOptions = {}) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n // Filter null/undefined values. Callers (often using `as any` to\n // bypass the `Record<string, string>` type) pass nulls to suppress\n // a header — but `new Headers({k: null})` coerces null to the\n // literal string \"null\", which a backend that checks \"is this\n // header present\" treats as an explicit credential. Strip nulls\n // here so the Headers constructor sees only real string values.\n this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);\n this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);\n this.fetchOptions = options.fetchOptions ?? {};\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.retry = { ...DEFAULT_RETRY, ...(options.retry ?? {}) };\n this.userAgent = options.userAgent ?? \"nebula-sdk-js/0.0.1\";\n }\n\n buildUrl(path: string, pathParams?: Record<string, string | number>, query?: Record<string, unknown>): string {\n let resolved = path;\n if (pathParams) {\n for (const [k, v] of Object.entries(pathParams)) {\n resolved = resolved.replace(`{${k}}`, encodeURIComponent(String(v)));\n }\n }\n const url = new URL(this.baseUrl + resolved);\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v)) for (const item of v) url.searchParams.append(k, String(item));\n else url.searchParams.set(k, String(v));\n }\n }\n return url.toString();\n }\n\n private buildHeaders(perRequest?: Record<string, string>, hasBody = false): Headers {\n const headers = new Headers(this.defaultHeaders);\n headers.set(\"User-Agent\", this.userAgent);\n headers.set(\"Accept\", \"application/json\");\n if (hasBody) headers.set(\"Content-Type\", \"application/json\");\n // The API key authenticates via the Authorization header — the backend\n // resolves a Nebula API key (or, for internal callers, a JWT) from the\n // same bearer credential.\n if (this.apiKey) headers.set(\"Authorization\", `Bearer ${this.apiKey}`);\n if (perRequest) {\n for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);\n }\n return headers;\n }\n\n async request<T>(args: RequestArgs): Promise<T> {\n const url = this.buildUrl(args.path, args.pathParams, args.query);\n const hasBody = args.body !== undefined && args.body !== null;\n const headers = this.buildHeaders(args.headers, hasBody);\n // Spread caller-supplied fetch options first so the runtime-owned\n // method/headers/body always win on key collision. The TS type for\n // `fetchOptions` already excludes those keys, so this is belt-and-\n // suspenders.\n const init: RequestInit = {\n ...this.fetchOptions,\n method: args.method,\n headers,\n body: hasBody ? JSON.stringify(args.body) : undefined,\n };\n\n const maxAttempts = (args.idempotent ?? false) ? this.retry.maxRetries + 1 : 1;\n let lastError: unknown;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n const controller = new AbortController();\n const timeoutHandle = setTimeout(() => controller.abort(new Error(\"timeout\")), this.timeoutMs);\n const { signal: composedSignal, dispose: disposeAbort } = composeAbort(\n controller.signal,\n args.signal\n );\n try {\n const response = await this.fetchImpl(url, { ...init, signal: composedSignal });\n\n if (response.ok) {\n if (response.status === 204) return undefined as T;\n return (await response.json()) as T;\n }\n\n const text = await safeReadText(response);\n const parsed = safeParseJSON(text);\n const retryAfter = parseRetryAfter(response.headers.get(\"Retry-After\"));\n const err = errorFromResponse(\n {\n status: response.status,\n requestId: response.headers.get(\"X-Request-Id\") ?? undefined,\n body: parsed ?? text,\n },\n retryAfter\n );\n\n if (isRetryableStatus(response.status) && attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry, retryAfter), args.signal);\n lastError = err;\n continue;\n }\n throw err;\n } catch (rawError) {\n if (rawError instanceof Error && rawError.name === \"AbortError\") {\n if (args.signal?.aborted) throw rawError;\n throw new NebulaTimeoutError(`Request timed out after ${this.timeoutMs}ms`, { cause: rawError });\n }\n if (rawError instanceof NebulaAPIError || rawError instanceof NebulaConnectionError) {\n throw rawError;\n }\n if (attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry), args.signal);\n lastError = rawError;\n continue;\n }\n if (rawError instanceof Error) {\n throw new NebulaConnectionError(rawError.message, { cause: rawError });\n }\n throw rawError;\n } finally {\n clearTimeout(timeoutHandle);\n disposeAbort();\n }\n }\n throw lastError ?? new NebulaConnectionError(\"retry budget exhausted\");\n }\n}\n\nfunction composeAbort(\n timeoutSignal: AbortSignal,\n userSignal?: AbortSignal\n): { signal: AbortSignal; dispose: () => void } {\n if (!userSignal) return { signal: timeoutSignal, dispose: () => {} };\n const controller = new AbortController();\n // Hold one listener per source so dispose can detach exactly what we added.\n // Caller's signal can outlive the request (e.g. a long-lived request-scope\n // controller reused across many SDK calls); without dispose, each call's\n // closures would stay pinned on it until that signal eventually aborts.\n const onTimeoutAbort = () =>\n controller.abort(timeoutSignal.reason ?? new Error(\"aborted\"));\n const onUserAbort = () =>\n controller.abort(userSignal.reason ?? new Error(\"aborted\"));\n if (timeoutSignal.aborted) controller.abort(timeoutSignal.reason);\n if (userSignal.aborted) controller.abort(userSignal.reason);\n timeoutSignal.addEventListener(\"abort\", onTimeoutAbort, { once: true });\n userSignal.addEventListener(\"abort\", onUserAbort, { once: true });\n const dispose = () => {\n timeoutSignal.removeEventListener(\"abort\", onTimeoutAbort);\n userSignal.removeEventListener(\"abort\", onUserAbort);\n };\n return { signal: controller.signal, dispose };\n}\n\nasync function safeReadText(response: Response): Promise<string> {\n try {\n return await response.text();\n } catch {\n return \"\";\n }\n}\n\nfunction safeParseJSON(text: string): unknown {\n if (!text) return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction filterNullishHeaders(\n headers: Record<string, string> | undefined\n): Record<string, string> {\n if (!headers) return {};\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(headers)) {\n // Accept anything that survives the truthy guard; the type is\n // `Record<string, string>` but callers occasionally cast with\n // `as any` to slip nulls through.\n if (v !== null && v !== undefined) out[k] = v;\n }\n return out;\n}\n\nfunction parseRetryAfter(header: string | null): number | undefined {\n if (!header) return undefined;\n const asNumber = Number.parseFloat(header);\n if (Number.isFinite(asNumber)) return asNumber;\n const asDate = Date.parse(header);\n if (Number.isFinite(asDate)) return Math.max(0, (asDate - Date.now()) / 1000);\n return undefined;\n}\n","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ClientResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Health probe\n *\n * 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.\n * @operationId client.health\n * @endpoint GET /v1/health\n */\n async health(options?: RequestOptions): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"GET\",\n path: \"/v1/health\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class CollectionsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create a new collection\n *\n * Create a new collection and automatically add the creating user\n * to it.\n *\n * This endpoint allows authenticated users to create a new collection\n * with a specified name and optional description. The user creating\n * the collection is automatically added as a member.\n * @operationId collections.create\n * @endpoint POST /v1/collections\n */\n async create(\n body: components[\"schemas\"][\"CreateCollectionRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Delete collection\n *\n * Delete an existing collection.\n *\n * This endpoint allows deletion of a collection identified by its\n * UUID. The user must have appropriate permissions to delete the\n * collection. Deleting a collection removes all associations but does\n * not delete the engrams within it.\n * @operationId collections.delete\n * @endpoint DELETE /v1/collections/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * List collections\n *\n * Returns a cursor-paginated list of collections the authenticated\n * user has access to.\n *\n * Results can be filtered by providing specific collection IDs.\n * Regular users will only see collections they own or have access to.\n * Superusers can see all collections.\n *\n * The collections are returned in order of last modification, with\n * most recent first.\n * @operationId collections.list\n * @endpoint GET /v1/collections\n */\n async list(\n params: {\n /** A list of collection IDs to retrieve. If not provided, all collections will be returned. */\n ids?: Array<string>;\n /** Filter collections by name (case-insensitive exact match). */\n name?: string | null;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** If true, only returns collections owned by the user, not all accessible collections. */\n ownerOnly?: boolean;\n /** Filter by workspace ID. Pass a UUID to scope to a workspace, or omit for all. */\n workspaceId?: string | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedCollectionResponse\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections\",\n pathParams: {},\n query: { ids: params.ids, name: params.name, cursor: params.cursor, limit: params.limit, owner_only: params.ownerOnly, workspace_id: params.workspaceId },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Get collection details\n *\n * Get details of a specific collection.\n *\n * This endpoint retrieves detailed information about a single\n * collection identified by its UUID. The user must have access to the\n * collection to view its details.\n * @operationId collections.retrieve\n * @endpoint GET /v1/collections/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Get a collection by name\n *\n * Retrieve a collection by its (owner_id, name) combination.\n *\n * The authenticated user can only fetch collections they own, or, if\n * superuser, from anyone.\n * @operationId collections.retrieveByName\n * @endpoint GET /v1/collections/name/{collection_name}\n */\n async retrieveByName(\n params: {\n /** The name of the collection */\n collectionName: string;\n /** (Superuser only) Specify the owner_id to retrieve a collection by name */\n ownerId?: string | null;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/name/{collection_name}\",\n pathParams: { collection_name: params.collectionName },\n query: { owner_id: params.ownerId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Update collection\n *\n * Update an existing collection's configuration.\n *\n * This endpoint allows updating the name, description, and access settings of an\n * existing collection. The user must have appropriate permissions to\n * modify the collection.\n * @operationId collections.update\n * @endpoint POST /v1/collections/{id}\n */\n async update(\n params: {\n /** The unique identifier of the collection to update */\n id: string;\n body: components[\"schemas\"][\"UpdateCollectionRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ConnectorsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Start OAuth connection flow\n *\n * 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.\n * @operationId connectors.connect\n * @endpoint POST /v1/connectors/{provider}/connect\n */\n async connect(\n params: {\n provider: string;\n body: components[\"schemas\"][\"ConnectRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{provider}/connect\",\n pathParams: { provider: params.provider },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectResponse\"] };\n return response.results;\n }\n\n /**\n * Disconnect an external data source\n *\n * 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.\n * @operationId connectors.disconnect\n * @endpoint DELETE /v1/connectors/{connection_id}\n */\n async disconnect(\n params: {\n connectionId: string;\n deleteMemories?: boolean;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorDisconnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorDisconnectResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: params.connectionId },\n query: { delete_memories: params.deleteMemories },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorDisconnectResponse\"] };\n return response.results;\n }\n\n /**\n * List active connections for a collection\n *\n * 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.\n * @operationId connectors.list\n * @endpoint GET /v1/connectors\n */\n async list(\n params: {\n collectionId: string;\n},\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors\",\n pathParams: {},\n query: { collection_id: params.collectionId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]> };\n return response.results;\n }\n\n /**\n * List available connector providers\n *\n * 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.\n * @operationId connectors.listProviders\n * @endpoint GET /v1/connectors/providers\n */\n async listProviders(options?: RequestOptions): Promise<Array<string>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStr\"]>({\n method: \"GET\",\n path: \"/v1/connectors/providers\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<string> };\n return response.results;\n }\n\n /**\n * Get a single connection by ID\n *\n * 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.\n * @operationId connectors.retrieve\n * @endpoint GET /v1/connectors/{connection_id}\n */\n async retrieve(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectionResponse\"] };\n return response.results;\n }\n\n /**\n * Manually trigger a sync\n *\n * 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.\n * @operationId connectors.sync\n * @endpoint POST /v1/connectors/{connection_id}/sync\n */\n async sync(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorSyncResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorSyncResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{connection_id}/sync\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorSyncResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class MemoriesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Append content to an engram\n *\n * Append content to an existing engram.\n *\n * **For conversation engrams:**\n * - Provide `messages` array with content, role, and optional metadata\n * - Works like `/conversations/{id}/messages` endpoint\n *\n * **For document engrams:**\n * - Provide either `raw_text` or `chunks` to append additional content\n * - Content will be processed and added to the engram\n * @operationId memories.append\n * @endpoint POST /v1/memories/{id}/append\n */\n async append(\n params: {\n /** The unique identifier of the engram */\n id: string;\n body: components[\"schemas\"][\"AppendMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/{id}/append\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"] };\n return response.results;\n }\n\n /**\n * Create a new memory (conversation or document)\n *\n * Create a new memory (conversation or document) using clean JSON body.\n *\n * - Use `collection_id` (UUID)\n * - `kind` is optional and inferred from payload shape:\n * - If `messages` present -> conversation\n * - Otherwise -> document\n * - For conversations: provide `messages` array\n * - For documents: provide `raw_text` or `chunks`\n * - Use `snapshot` for device-memory mode (mutually exclusive with collection_id)\n * @operationId memories.create\n * @endpoint POST /v1/memories\n */\n async create(\n body: components[\"schemas\"][\"CreateMemoryRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"MemoryCreateResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"] };\n return response.results;\n }\n\n /**\n * Get presigned URL for large file upload\n *\n * Get a presigned URL for uploading large files directly to S3.\n *\n * Use this for files larger than 5MB that cannot be sent inline as base64.\n * After uploading, reference the file in memory creation using S3FileReference.\n *\n * Args:\n * filename: Original filename (e.g., \"image.jpg\")\n * content_type: MIME type (e.g., \"image/jpeg\", \"application/pdf\")\n * file_size: Expected file size in bytes (max 100MB)\n *\n * Returns:\n * dict with:\n * - upload_url: Presigned URL for PUT request (expires in 1 hour)\n * - upload_headers: Headers that must be sent with the presigned PUT request\n * - s3_key: The S3 key to reference in memory creation\n * - bucket: S3 bucket name\n * - expires_in: Seconds until URL expires\n * - max_size: Maximum allowed file size\n * @operationId memories.createUpload\n * @endpoint POST /v1/memories/upload\n */\n async createUpload(\n params: {\n /** Original filename (e.g., 'image.jpg') */\n filename: string;\n /** MIME type (e.g., 'image/jpeg', 'application/pdf') */\n contentType: string;\n /** Expected file size in bytes (max 100MB) */\n fileSize: number;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PresignedUploadResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedPresignedUploadResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { filename: params.filename, content_type: params.contentType, file_size: params.fileSize },\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"PresignedUploadResponse\"] };\n return response.results;\n }\n\n /**\n * Delete an engram\n *\n * Delete a specific engram with graph awareness. All chunks corresponding to the\n * engram are deleted, and graph components (entities/relationships) are updated\n * or deleted based on remaining chunk references from other engrams.\n *\n * This method now properly handles graph components and maintains graph integrity\n * for search operations.\n * @operationId memories.delete\n * @endpoint DELETE /v1/memories/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * Delete one or more engrams\n *\n * Delete one or more engrams.\n *\n * This endpoint efficiently handles both single and batch deletions.\n * When multiple IDs are provided, it uses optimized batch operations.\n *\n * Args:\n * ids: Either a single UUID or a list of UUIDs to delete\n *\n * Returns:\n * For single deletion: boolean success response\n * For batch deletion: detailed results with successful and failed deletions\n * @operationId memories.deleteMany\n * @endpoint POST /v1/memories/delete\n */\n async deleteMany(\n body: components[\"schemas\"][\"DeleteMemoriesRequest\"],\n options?: RequestOptions,\n ): Promise<unknown> {\n return this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/delete\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n });\n }\n\n /**\n * Delete a previously uploaded S3 file\n *\n * Delete a file from S3 that was uploaded via a presigned URL.\n * Verifies the caller owns the file via S3 object metadata.\n * @operationId memories.deleteUpload\n * @endpoint DELETE /v1/memories/upload\n */\n async deleteUpload(\n params: {\n /** S3 key of the file to delete (returned by POST /memories/upload) */\n s3Key: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { s3_key: params.s3Key },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n /**\n * List engrams\n *\n * Returns a cursor-paginated list of engrams the authenticated user\n * has access to.\n *\n * Results can be filtered by providing specific engram IDs or collection IDs.\n * Regular users will only see engrams they own or have access to through\n * collections. Superusers can see all engrams.\n *\n * The engrams are returned in order of creation time, most recent\n * first. The response includes the engram's text field if available.\n * @operationId memories.list\n * @endpoint GET /v1/memories\n */\n async list(\n params: {\n /** A list of engram IDs to retrieve. If not provided, all engrams will be returned. */\n ids?: Array<string>;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** Maximum chunks to inline per engram. Defaults to all chunks for backwards compatibility; pass 0 to skip chunk hydration. */\n chunksLimit?: number | null;\n /** If true, only returns engrams owned by the user, not all accessible engrams. */\n ownerOnly?: boolean;\n /** Optional list of collection IDs to filter engrams by. If provided, exactly one collection ID must be specified. */\n collectionIds?: Array<string> | null;\n /** JSON string for metadata filtering. Example: '{\"metadata.source\": {\"$eq\": \"playground\"}}' */\n metadataFilters?: string | null;\n /** Read-your-writes assertion: the WAL-tail overlay path waits for at least this seq to be applied before serving (or returns 503 Unavailable on timeout). REQUIRES exactly one collection_ids entry — without a collection scope the request returns 422 (the per-WAL-shard scalar applied_wal_seq is meaningless across collections). When the served shard has not been migrated to wal_compaction_enabled, the field is accepted but the served path is the legacy overlay (the assertion has no effect — the response's applied_wal_seq will be 0). Pass back the value the matching upload response surfaced. */\n minAppliedWalSeq?: number | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedListedEngram\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedListedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories\",\n pathParams: {},\n query: { ids: params.ids, cursor: params.cursor, limit: params.limit, chunks_limit: params.chunksLimit, owner_only: params.ownerOnly, collection_ids: params.collectionIds, metadata_filters: params.metadataFilters, min_applied_wal_seq: params.minAppliedWalSeq },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Recall workflow patterns by intent\n *\n * Workflow-pattern recall over 5 intents.\n *\n * * ``cursor`` -- match the caller's anchor against pattern\n * canonical states, return ranked patterns + position.\n * * ``predict`` -- like cursor but include the predicted next\n * trace from each pattern's canonical instance.\n * * ``resume`` -- like cursor, biased toward longer patterns.\n * * ``evidence`` -- expand a specific pattern via\n * ``hydrate_pattern``.\n * * ``bootstrap`` -- top-K patterns by confidence with no anchor.\n * @operationId memories.recallWorkflow\n * @endpoint POST /v1/memories/workflow/recall\n */\n async recallWorkflow(\n body: components[\"schemas\"][\"CursorRecallRequest\"] | components[\"schemas\"][\"PredictRecallRequest\"] | components[\"schemas\"][\"ResumeRecallRequest\"] | components[\"schemas\"][\"EvidenceRecallRequest\"] | components[\"schemas\"][\"BootstrapRecallRequest\"],\n options?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n const response = (await this.core.request<components[\"schemas\"][\"WorkflowRecallResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/workflow/recall\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: Record<string, unknown> };\n return response.results;\n }\n\n /**\n * Retrieve an engram\n *\n * Retrieves detailed information about a specific engram by its\n * ID.\n *\n * This endpoint returns the engram's metadata, status, and system information. It does not\n * return the engram's content - use the `/engrams/{id}/download` endpoint for that.\n *\n * Users can only retrieve engrams they own or have access to through collections.\n * Superusers can retrieve any engram.\n * @operationId memories.retrieve\n * @endpoint GET /v1/memories/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n /**\n * Search memories\n *\n * Perform a search query across your memories.\n *\n * **Standard mode** (collection_ids or readable-scope search): returns hierarchical MemoryRecall\n * with semantics, episodes, procedures, and sources.\n *\n * **Snapshot mode** (snapshot field): returns graph-search results with\n * {entities, relationships} from stateless in-memory traversal.\n * @operationId memories.search\n * @endpoint POST /v1/memories/search\n */\n async search(\n body: components[\"schemas\"][\"MemorySearchRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/search\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"] };\n return response.results;\n }\n\n /**\n * Update a memory\n *\n * Update memory-level properties including name, metadata, and collection associations.\n *\n * This endpoint allows updating properties of an entire memory (document or conversation)\n * without modifying its content:\n * - **name**: Updates the authoritative engram title\n * - **metadata**: Can replace or merge with existing metadata\n * - **collection_ids**: Updates authoritative engram collection associations\n *\n * Users can only update memories they own or have access to through collections.\n * At least one collection association must be maintained.\n *\n * If collection_id is provided and the engram is shared across collections, a copy-on-write\n * will be performed to create a collection-specific copy before modification.\n * @operationId memories.update\n * @endpoint PATCH /v1/memories/{id}\n */\n async update(\n params: {\n /** The unique identifier of the memory */\n id: string;\n /** Collection context for copy-on-write. If provided and engram is shared, creates a copy before modification. */\n collectionId?: string | null;\n body: components[\"schemas\"][\"UpdateMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"PATCH\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: params.id },\n query: { collection_id: params.collectionId },\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class SnapshotsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Export a collection snapshot\n *\n * Export a collection's full graph state as a\n * portable SnapshotEnvelope.\n * @operationId snapshots.export\n * @endpoint POST /v1/device-memory/snapshot/export\n */\n async export(\n body: components[\"schemas\"][\"SnapshotExportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotEnvelopeOrSnapshotObjectReference\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/export\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"] };\n return response.results;\n }\n\n /**\n * Import a snapshot into an ephemeral collection\n *\n * Import a SnapshotEnvelope into an ephemeral\n * collection. Returns the ephemeral collection UUID.\n * @operationId snapshots.import\n * @endpoint POST /v1/device-memory/snapshot/import\n */\n async import(\n body: components[\"schemas\"][\"SnapshotImportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotImportResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotImportResult\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/import\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotImportResult\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class WorkspacesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create workspace storage target\n *\n * Register a customer S3 bucket for hosted BYOC storage.\n * @operationId workspaces.createStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets\n */\n async createStorageTarget(\n params: {\n workspaceId: string;\n body: components[\"schemas\"][\"StorageTargetCreateRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: params.workspaceId },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * Disable workspace storage target\n *\n * Disable a customer storage target for future collection binds.\n * @operationId workspaces.disableStorageTarget\n * @endpoint DELETE /v1/workspaces/{workspace_id}/storage-targets/{target_id}\n */\n async disableStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * List workspace storage targets\n *\n * List customer-owned object storage targets for a workspace.\n * @operationId workspaces.listStorageTargets\n * @endpoint GET /v1/workspaces/{workspace_id}/storage-targets\n */\n async listStorageTargets(\n workspaceId: string,\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"StorageTargetResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStorageTargetResponse\"]>({\n method: \"GET\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: workspaceId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"StorageTargetResponse\"]> };\n return response.results;\n }\n\n /**\n * Validate workspace storage target\n *\n * Probe a customer storage target and mark it active on success.\n * @operationId workspaces.validateStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\n */\n async validateStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport { NebulaCore, type ClientOptions } from \"./runtime/client.ts\";\nimport { ClientResource } from \"./resources/client.ts\";\nimport { CollectionsResource } from \"./resources/collections.ts\";\nimport { ConnectorsResource } from \"./resources/connectors.ts\";\nimport { MemoriesResource } from \"./resources/memories.ts\";\nimport { SnapshotsResource } from \"./resources/snapshots.ts\";\nimport { WorkspacesResource } from \"./resources/workspaces.ts\";\n\nexport class NebulaClient {\n protected readonly core: NebulaCore;\n readonly client: ClientResource;\n readonly collections: CollectionsResource;\n readonly connectors: ConnectorsResource;\n readonly memories: MemoriesResource;\n readonly snapshots: SnapshotsResource;\n readonly workspaces: WorkspacesResource;\n\n constructor(options: ClientOptions = {}) {\n this.core = new NebulaCore(options);\n this.client = new ClientResource(this.core);\n this.collections = new CollectionsResource(this.core);\n this.connectors = new ConnectorsResource(this.core);\n this.memories = new MemoriesResource(this.core);\n this.snapshots = new SnapshotsResource(this.core);\n this.workspaces = new WorkspacesResource(this.core);\n }\n}","// Handwritten Nebula DX layer.\n//\n// Carries only the methods that need real dispatch logic: storeMemory's\n// create-vs-append branch, bulk storeMemories with a concurrency cap,\n// positional connector helpers (connectProvider/listConnections/\n// disconnectConnection), and auth normalization.\n//\n// For everything else, use the resource methods directly. Resource\n// methods now return unwrapped values natively (the generator peels\n// the `{results: X}` wire envelope), so there's no separate auto-\n// generated unwrap layer to extend.\n//\n// Source of truth: nebula-sdks/custom/typescript/dx.ts\n// The generator copies this file into sdks/typescript/src/lib/dx.ts on every\n// `pnpm --dir nebula-sdks/generator run generate`. Edit the source, not the copy.\n\nimport { NebulaClient } from \"../client.ts\";\nimport {\n type ClientOptions,\n type components,\n} from \"../index.ts\";\n\ntype Schemas = components[\"schemas\"];\ntype SnapshotEnvelopeInput = Schemas[\"SnapshotEnvelope-Input\"];\ntype SnapshotEnvelopeOutput = Schemas[\"SnapshotEnvelope-Output\"];\n\nexport type CompatClientOptions = ClientOptions & {\n apiKey?: string | null;\n baseUrl?: string | null;\n // Legacy capital-U alias. Some internal callers, including the\n // local playground WebSocket server, still pass `baseURL`; without this\n // alias the value falls through unused and the runtime defaults to\n // api.zeroset.com.\n baseURL?: string | null;\n // Legacy alias for `timeoutMs`. Same compat reason.\n timeout?: number | null;\n};\n\nexport interface MemoryCommonInput {\n collection_id?: string | null;\n collectionId?: string | null;\n content?: string | string[] | unknown[] | null;\n raw_text?: string | null;\n chunks?: Array<string> | null;\n messages?: unknown[] | null;\n metadata?: { [key: string]: unknown } | null;\n ingestion_config?: unknown;\n ingestion_mode?: string | null;\n}\n\nexport interface MemoryCreateInput extends MemoryCommonInput {\n kind?: Schemas[\"EngramKind\"] | null;\n name?: string | null;\n speaker_id?: string | null;\n speaker_name?: string | null;\n content_parts?: unknown[] | null;\n contents?: string[] | null;\n snapshot?: SnapshotEnvelopeInput | null;\n memory_id?: undefined | null;\n}\n\nexport interface MemoryAppendInput extends Omit<MemoryCommonInput, \"ingestion_mode\" | \"messages\"> {\n memory_id: string;\n ingestion_mode?: string | null;\n messages?: unknown[] | null;\n}\n\nexport type MemoryInput = MemoryCreateInput | MemoryAppendInput;\n\ntype MemoryCreateBody = Schemas[\"CreateMemoryRequest\"];\ntype MemoryAppendBody = Schemas[\"AppendMemoryRequest\"];\n\nexport class Nebula extends NebulaClient {\n constructor(options: CompatClientOptions = {}) {\n super(normalizeClientOptions(options));\n }\n\n /**\n * Polymorphic memory creator: dispatches to memories.create or memories.append\n * based on whether `memory_id` is set on the input. Returns the new memory's\n * id (string), or — when `snapshot` is set — the updated snapshot envelope.\n */\n async storeMemory(\n memory: MemoryInput,\n options?: { signal?: AbortSignal }\n ): Promise<string | SnapshotEnvelopeOutput> {\n if (\"memory_id\" in memory && memory.memory_id != null) {\n const memoryID = memory.memory_id;\n await this.memories.append(\n { id: memoryID, body: toMemoryAppendParams(memory) },\n options\n );\n return memoryID;\n }\n // `memories.create` now returns the unwrapped inner type directly\n // (the generator peels the wire `{results: X}` envelope).\n const result = await this.memories.create(\n toMemoryCreateParams(memory as MemoryCreateInput),\n options\n );\n if (isSnapshotResult(result)) {\n return (result.snapshot ?? result) as SnapshotEnvelopeOutput;\n }\n return extractID(result);\n }\n\n /**\n * Bulk parallel version of storeMemory with a concurrency cap.\n *\n * Default 8 concurrent in-flight requests matches the Python DX's\n * `asyncio.Semaphore(max_concurrency)` pattern. Use `maxConcurrency: 1`\n * for strictly serial submission; higher values risk overwhelming the\n * server when memories[] is large.\n */\n async storeMemories(\n memories: MemoryInput[],\n options?: { signal?: AbortSignal; maxConcurrency?: number }\n ): Promise<(string | SnapshotEnvelopeOutput)[]> {\n const cap = Math.max(1, options?.maxConcurrency ?? 8);\n const signal = options?.signal;\n const results: (string | SnapshotEnvelopeOutput)[] = new Array(memories.length);\n let nextIndex = 0;\n const worker = async (): Promise<void> => {\n while (true) {\n const i = nextIndex++;\n if (i >= memories.length) return;\n results[i] = await this.storeMemory(memories[i], { signal });\n }\n };\n await Promise.all(\n Array.from({ length: Math.min(cap, memories.length) }, () => worker())\n );\n return results;\n }\n\n /**\n * List memories scoped to one or more collection ids (string | string[])\n * or a full MemoryListParams object.\n */\n async listMemories(\n query: string | string[] | Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const normalized: Record<string, unknown> =\n typeof query === \"string\" || Array.isArray(query)\n ? { collectionIds: arrayify(query) }\n : query;\n return this.memories.list(normalized as never, options);\n }\n\n /**\n * Positional `connectProvider(provider, collectionID, config?)` — wraps the\n * generated `connectors.connect({provider, body})` to build the body shape.\n */\n async connectProvider(\n provider: string,\n collectionID: string,\n config?: Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const body: Schemas[\"ConnectRequest\"] = {\n collection_id: collectionID,\n ...(config !== undefined ? { config } : {}),\n } as Schemas[\"ConnectRequest\"];\n return this.connectors.connect({ provider, body }, options);\n }\n\n /** Positional listConnections(collectionID) — wraps the query wrapper. */\n async listConnections(\n collectionID: string,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.list({ collectionId: collectionID } as never, options);\n }\n\n /** Positional disconnect(connectionID, deleteMemories?). */\n async disconnectConnection(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n /** Alias for disconnectConnection (same arg shape). */\n async disconnect(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n}\n\n// ---------- helpers ----------\n\nfunction normalizeClientOptions(options: CompatClientOptions): ClientOptions {\n const {\n apiKey,\n baseUrl: baseUrlAlias,\n baseURL: baseURLCapAlias,\n timeout: timeoutAlias,\n ...rest\n } = options;\n const restClientOptions: ClientOptions = rest;\n return {\n ...restClientOptions,\n apiKey: apiKey ?? undefined,\n baseUrl:\n firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? undefined,\n timeoutMs:\n firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? undefined,\n };\n}\n\nfunction firstDefined<T>(...values: (T | null | undefined)[]): T | null | undefined {\n return values.find((value) => value !== undefined);\n}\n\nfunction toMemoryCreateParams(memory: MemoryCreateInput): MemoryCreateBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;\n const params: Record<string, unknown> = { ...rest };\n\n if (collectionID !== undefined) {\n params.collection_id = collectionID;\n }\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else {\n params.content_parts = content;\n }\n }\n if (params.messages != null && !params.kind) {\n params.kind = \"conversation\";\n }\n return params as MemoryCreateBody;\n}\n\nfunction toMemoryAppendParams(memory: MemoryAppendInput): MemoryAppendBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n if (!collectionID) {\n throw new Error(\"collection_id is required when appending to an existing memory\");\n }\n const params: Record<string, unknown> = { collection_id: collectionID };\n for (const key of [\"metadata\", \"ingestion_config\", \"ingestion_mode\", \"raw_text\", \"chunks\", \"messages\"] as const) {\n const value = memory[key as keyof MemoryAppendInput];\n if (value != null) params[key] = value;\n }\n const content = (memory as MemoryCommonInput).content;\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else if (Array.isArray(content) && content.every((item) => typeof item === \"string\")) {\n params.chunks = content;\n } else if (Array.isArray(content)) {\n params.messages = content;\n }\n }\n return params as MemoryAppendBody;\n}\n\nfunction extractID(value: unknown): string {\n if (typeof value === \"object\" && value !== null) {\n const record = value as Record<string, unknown>;\n const id =\n record[\"id\"] ?? record[\"memory_id\"] ?? record[\"engram_id\"] ?? record[\"ephemeral_collection_id\"];\n if (typeof id === \"string\") return id;\n }\n throw new Error(\"Nebula memory create response did not include an id\");\n}\n\nfunction isSnapshotResult(value: unknown): value is { snapshot?: SnapshotEnvelopeOutput } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"snapshot\" in (value as Record<string, unknown>)\n );\n}\n\nfunction arrayify(value: string | string[]): string[] {\n return Array.isArray(value) ? value : [value];\n}\n"],"mappings":";;;;;AAAA,IAAa,cAAb,cAAiC,MAAM;CACrC,OAAiC;CACjC,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;CACxB;AACF;AAEA,IAAa,wBAAb,cAA2C,YAAY;CACrD,OAAyB;AAC3B;AAEA,IAAa,qBAAb,cAAwC,YAAY;CAClD,OAAyB;AAC3B;AA6BA,SAAS,WA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/G,MAAM,QAAQ,OAAO;EACrB,IAAI,SAAS,MAAM,OAAO,OAAO;CACnC;CACA,MAAM,UAAW,OAA6B;CAC9C,IAAI,WAAW;MACT,OAAO,YAAY,UACrB,OAAO,WAAW;OACb,IAAI,MAAM,QAAQ,OAAO,KAAK,QAAQ,OAAO,SAAS,OAAO,SAAS,QAAQ,GACnF,OAAO,SAAS;OACX,IAAI,MAAM,QAAQ,OAAO,GAC9B,OAAO,WAAW;CAAA;CAGtB,OAAO;AACT;AAEA,SAAS,UAAU,OAAwB;CACzC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,SAAS;EACf,MAAM,KACJ,OAAO,SAAS,OAAO,gBAAgB,OAAO,gBAAgB,OAAO;EACvE,IAAI,OAAO,OAAO,UAAU,OAAO;CACrC;CACA,MAAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,iBAAiB,OAAgE;CACxF,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAe;AAEnB;AAEA,SAAS,SAAS,OAAoC;CACpD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C"}
package/dist/index.d.cts CHANGED
@@ -13,7 +13,6 @@ declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
13
13
  interface ClientOptions {
14
14
  baseUrl?: string;
15
15
  apiKey?: string;
16
- bearerToken?: string;
17
16
  defaultHeaders?: Record<string, string>;
18
17
  fetchImpl?: typeof fetch;
19
18
  fetchOptions?: Omit<RequestInit, "method" | "headers" | "body" | "signal">;
@@ -38,7 +37,6 @@ interface RequestOptions {
38
37
  declare class NebulaCore {
39
38
  readonly baseUrl: string;
40
39
  readonly apiKey?: string;
41
- readonly bearerToken?: string;
42
40
  readonly defaultHeaders: Record<string, string>;
43
41
  readonly fetchImpl: typeof fetch;
44
42
  readonly fetchOptions: Omit<RequestInit, "method" | "headers" | "body" | "signal">;
@@ -1376,7 +1374,10 @@ interface components {
1376
1374
  episodic?: components["schemas"]["ActivatedEpisode"][]; /** Inference Hints */
1377
1375
  inference_hints?: components["schemas"]["InferenceHint"][]; /** Procedural */
1378
1376
  procedural?: components["schemas"]["ActivatedProcedure"][]; /** Query */
1379
- query: string; /** Semantic */
1377
+ query: string; /** Search Timing Ms */
1378
+ search_timing_ms?: {
1379
+ [key: string]: number;
1380
+ } | null; /** Semantic */
1380
1381
  semantic?: components["schemas"]["ActivatedSemantic"][]; /** Sources */
1381
1382
  sources?: components["schemas"]["GroundedSource"][]; /** Total Traversal Time Ms */
1382
1383
  total_traversal_time_ms?: number | null; /** Workflows */
@@ -2628,7 +2629,6 @@ type CompatClientOptions = ClientOptions & {
2628
2629
  baseUrl?: string | null;
2629
2630
  baseURL?: string | null;
2630
2631
  timeout?: number | null;
2631
- bearerToken?: string | null;
2632
2632
  };
2633
2633
  interface MemoryCommonInput {
2634
2634
  collection_id?: string | null;
package/dist/index.d.ts CHANGED
@@ -13,7 +13,6 @@ declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
13
13
  interface ClientOptions {
14
14
  baseUrl?: string;
15
15
  apiKey?: string;
16
- bearerToken?: string;
17
16
  defaultHeaders?: Record<string, string>;
18
17
  fetchImpl?: typeof fetch;
19
18
  fetchOptions?: Omit<RequestInit, "method" | "headers" | "body" | "signal">;
@@ -38,7 +37,6 @@ interface RequestOptions {
38
37
  declare class NebulaCore {
39
38
  readonly baseUrl: string;
40
39
  readonly apiKey?: string;
41
- readonly bearerToken?: string;
42
40
  readonly defaultHeaders: Record<string, string>;
43
41
  readonly fetchImpl: typeof fetch;
44
42
  readonly fetchOptions: Omit<RequestInit, "method" | "headers" | "body" | "signal">;
@@ -1376,7 +1374,10 @@ interface components {
1376
1374
  episodic?: components["schemas"]["ActivatedEpisode"][]; /** Inference Hints */
1377
1375
  inference_hints?: components["schemas"]["InferenceHint"][]; /** Procedural */
1378
1376
  procedural?: components["schemas"]["ActivatedProcedure"][]; /** Query */
1379
- query: string; /** Semantic */
1377
+ query: string; /** Search Timing Ms */
1378
+ search_timing_ms?: {
1379
+ [key: string]: number;
1380
+ } | null; /** Semantic */
1380
1381
  semantic?: components["schemas"]["ActivatedSemantic"][]; /** Sources */
1381
1382
  sources?: components["schemas"]["GroundedSource"][]; /** Total Traversal Time Ms */
1382
1383
  total_traversal_time_ms?: number | null; /** Workflows */
@@ -2628,7 +2629,6 @@ type CompatClientOptions = ClientOptions & {
2628
2629
  baseUrl?: string | null;
2629
2630
  baseURL?: string | null;
2630
2631
  timeout?: number | null;
2631
- bearerToken?: string | null;
2632
2632
  };
2633
2633
  interface MemoryCommonInput {
2634
2634
  collection_id?: string | null;
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
  }
@@ -1015,7 +1012,7 @@ var NebulaClient = class {
1015
1012
  //#region src/lib/dx.ts
1016
1013
  var Nebula = class extends NebulaClient {
1017
1014
  constructor(options = {}) {
1018
- super(normalizeAuthOptions(normalizeClientOptions(options)));
1015
+ super(normalizeClientOptions(options));
1019
1016
  }
1020
1017
  /**
1021
1018
  * Polymorphic memory creator: dispatches to memories.create or memories.append
@@ -1099,21 +1096,12 @@ var Nebula = class extends NebulaClient {
1099
1096
  }, options);
1100
1097
  }
1101
1098
  };
1102
- function normalizeAuthOptions(options) {
1103
- if (options.apiKey != null && options.bearerToken == null && !looksLikeNebulaAPIKey(options.apiKey)) return {
1104
- ...options,
1105
- apiKey: void 0,
1106
- bearerToken: options.apiKey
1107
- };
1108
- return options;
1109
- }
1110
1099
  function normalizeClientOptions(options) {
1111
- const { apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, timeout: timeoutAlias, bearerToken, ...rest } = options;
1100
+ const { apiKey, baseUrl: baseUrlAlias, baseURL: baseURLCapAlias, timeout: timeoutAlias, ...rest } = options;
1112
1101
  const restClientOptions = rest;
1113
1102
  return {
1114
1103
  ...restClientOptions,
1115
1104
  apiKey: apiKey ?? void 0,
1116
- bearerToken: bearerToken ?? void 0,
1117
1105
  baseUrl: firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? void 0,
1118
1106
  timeoutMs: firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? void 0
1119
1107
  };
@@ -1121,12 +1109,6 @@ function normalizeClientOptions(options) {
1121
1109
  function firstDefined(...values) {
1122
1110
  return values.find((value) => value !== void 0);
1123
1111
  }
1124
- function looksLikeNebulaAPIKey(token) {
1125
- const parts = token.split(".");
1126
- if (parts.length !== 2) return false;
1127
- const [publicPart, rawPart] = parts;
1128
- return Boolean(rawPart) && (publicPart.startsWith("key_") || publicPart.startsWith("neb_"));
1129
- }
1130
1112
  function toMemoryCreateParams(memory) {
1131
1113
  const collectionID = memory.collection_id ?? memory.collectionId ?? void 0;
1132
1114
  const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/runtime/errors.ts","../src/runtime/retry.ts","../src/runtime/client.ts","../src/resources/client.ts","../src/resources/collections.ts","../src/resources/connectors.ts","../src/resources/memories.ts","../src/resources/snapshots.ts","../src/resources/workspaces.ts","../src/client.ts","../src/lib/dx.ts"],"sourcesContent":["export class NebulaError extends Error {\n override readonly name: string = \"NebulaError\";\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n }\n}\n\nexport class NebulaConnectionError extends NebulaError {\n override readonly name = \"NebulaConnectionError\";\n}\n\nexport class NebulaTimeoutError extends NebulaError {\n override readonly name = \"NebulaTimeoutError\";\n}\n\n// Canonical Error envelope returned by every Nebula 4xx/5xx. The runtime\n// pulls these fields out of the response body and surfaces them as typed\n// accessors on NebulaAPIError so callers can branch on err.code without\n// digging into err.body.\n//\n// The optional fields are typed as `T | null` because the wire schema is\n// `anyOf [T, null]` — the server emits the keys with explicit `null` rather\n// than omitting them. The NebulaAPIError constructor coerces `null` to\n// `undefined` so the public accessor surface stays `T | undefined`.\nexport interface ErrorEnvelope {\n readonly type: string;\n readonly message: string;\n readonly code?: string | null;\n readonly request_id?: string | null;\n // `details` is intentionally `unknown`: the server emits arbitrary\n // JSON here. For validation errors it's an array of {loc, msg, type}\n // entries; for other classes it can be an object or null. Callers\n // should narrow at the read site (e.g. `Array.isArray(err.details)`).\n readonly details?: unknown;\n}\n\nexport interface APIErrorPayload {\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n}\n\nfunction isEnvelope(body: unknown): body is ErrorEnvelope {\n return (\n typeof body === \"object\" &&\n body !== null &&\n typeof (body as { type?: unknown }).type === \"string\" &&\n typeof (body as { message?: unknown }).message === \"string\"\n );\n}\n\nexport class NebulaAPIError extends NebulaError {\n override readonly name: string = \"NebulaAPIError\";\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n // Canonical envelope fields. `type` is always present when the server\n // returned the documented envelope; the rest are present when the server\n // populated them. All four are undefined when the response body wasn't\n // an envelope (e.g. an HTML error page from a misconfigured proxy).\n readonly type?: string;\n readonly code?: string;\n readonly details?: unknown;\n\n constructor(payload: APIErrorPayload, message?: string) {\n const envelope = isEnvelope(payload.body) ? payload.body : undefined;\n super(\n message ??\n envelope?.message ??\n `Nebula API error (status ${payload.status})`\n );\n this.status = payload.status;\n // Coerce `null` (wire-level) to `undefined` (idiomatic JS absence) so\n // every accessor's runtime value matches its declared T | undefined.\n const envCode =\n typeof envelope?.code === \"string\" ? envelope.code : undefined;\n const envRid =\n typeof envelope?.request_id === \"string\"\n ? envelope.request_id\n : undefined;\n // Prefer the envelope's request_id (server-stamped) over the header\n // we captured at the transport — they should match, but if they\n // diverge the envelope is authoritative.\n this.requestId = envRid ?? payload.requestId;\n this.body = payload.body;\n this.type = envelope?.type;\n this.code = envCode;\n this.details = envelope?.details ?? undefined;\n }\n}\n\nexport class NebulaBadRequestError extends NebulaAPIError {\n override readonly name = \"NebulaBadRequestError\";\n}\nexport class NebulaUnauthorizedError extends NebulaAPIError {\n override readonly name = \"NebulaUnauthorizedError\";\n}\nexport class NebulaForbiddenError extends NebulaAPIError {\n override readonly name = \"NebulaForbiddenError\";\n}\nexport class NebulaNotFoundError extends NebulaAPIError {\n override readonly name = \"NebulaNotFoundError\";\n}\nexport class NebulaConflictError extends NebulaAPIError {\n override readonly name = \"NebulaConflictError\";\n}\nexport class NebulaValidationError extends NebulaAPIError {\n override readonly name = \"NebulaValidationError\";\n}\nexport class NebulaRateLimitError extends NebulaAPIError {\n override readonly name = \"NebulaRateLimitError\";\n readonly retryAfter?: number;\n constructor(payload: APIErrorPayload, retryAfter?: number) {\n super(payload);\n this.retryAfter = retryAfter;\n }\n}\nexport class NebulaServerError extends NebulaAPIError {\n override readonly name = \"NebulaServerError\";\n}\n\ntype APIErrorCtor = new (payload: APIErrorPayload) => NebulaAPIError;\n\nconst STATUS_TO_CLASS: Record<number, APIErrorCtor> = {\n 400: NebulaBadRequestError,\n 401: NebulaUnauthorizedError,\n 403: NebulaForbiddenError,\n 404: NebulaNotFoundError,\n 409: NebulaConflictError,\n 422: NebulaValidationError,\n};\n\nexport function errorFromResponse(payload: APIErrorPayload, retryAfter?: number): NebulaAPIError {\n if (payload.status === 429) return new NebulaRateLimitError(payload, retryAfter);\n const cls = STATUS_TO_CLASS[payload.status];\n if (cls) return new cls(payload);\n if (payload.status >= 500) return new NebulaServerError(payload);\n return new NebulaAPIError(payload);\n}\n","export interface RetryPolicy {\n readonly maxRetries: number;\n readonly baseMs: number;\n readonly maxMs: number;\n}\n\nexport const DEFAULT_RETRY: RetryPolicy = {\n maxRetries: 2,\n baseMs: 250,\n maxMs: 8000,\n};\n\nconst RETRYABLE_STATUSES: ReadonlySet<number> = new Set([408, 429, 502, 503, 504]);\n\nexport function isRetryableStatus(status: number): boolean {\n return RETRYABLE_STATUSES.has(status);\n}\n\nexport function backoffMs(attempt: number, policy: RetryPolicy, retryAfterSec?: number): number {\n if (retryAfterSec != null && Number.isFinite(retryAfterSec)) {\n return Math.min(retryAfterSec * 1000, policy.maxMs);\n }\n const exp = Math.min(policy.baseMs * 2 ** attempt, policy.maxMs);\n return Math.floor(Math.random() * exp);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (ms <= 0) return Promise.resolve();\n return new Promise((resolveSleep, reject) => {\n const handle = setTimeout(resolveSleep, ms);\n if (signal) {\n const onAbort = () => {\n clearTimeout(handle);\n reject(signal.reason ?? new Error(\"aborted\"));\n };\n if (signal.aborted) onAbort();\n else signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n}\n","import {\n errorFromResponse,\n NebulaAPIError,\n NebulaConnectionError,\n NebulaTimeoutError,\n} from \"./errors.ts\";\nimport { backoffMs, DEFAULT_RETRY, isRetryableStatus, sleep, type RetryPolicy } from \"./retry.ts\";\n\nexport interface ClientOptions {\n baseUrl?: string;\n apiKey?: string;\n bearerToken?: string;\n defaultHeaders?: Record<string, string>;\n fetchImpl?: typeof fetch;\n // Caller-supplied RequestInit fields applied to every outbound fetch.\n // Lets browser callers pass `credentials: \"include\"` for cookie auth,\n // or `mode`/`cache`/`referrer` for cross-origin tuning. Method, headers,\n // body, and signal are owned by the runtime and cannot be overridden\n // here (they're set per-request).\n fetchOptions?: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n timeoutMs?: number;\n retry?: Partial<RetryPolicy>;\n userAgent?: string;\n}\n\nexport interface RequestArgs {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n pathParams?: Record<string, string | number>;\n query?: Record<string, unknown>;\n body?: unknown;\n headers?: Record<string, string>;\n idempotent?: boolean;\n signal?: AbortSignal;\n}\n\n/** Per-call options every generated resource method accepts. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n}\n\nconst DEFAULT_BASE_URL = \"https://api.zeroset.com\";\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\nexport class NebulaCore {\n readonly baseUrl: string;\n readonly apiKey?: string;\n readonly bearerToken?: string;\n readonly defaultHeaders: Record<string, string>;\n readonly fetchImpl: typeof fetch;\n readonly fetchOptions: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n readonly timeoutMs: number;\n readonly retry: RetryPolicy;\n readonly userAgent: string;\n\n constructor(options: ClientOptions = {}) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n this.bearerToken = options.bearerToken;\n // Filter null/undefined values. Callers (often using `as any` to\n // bypass the `Record<string, string>` type) pass nulls to suppress\n // a header — but `new Headers({k: null})` coerces null to the\n // literal string \"null\", which a backend that checks \"is this\n // header present\" treats as an explicit credential. Strip nulls\n // here so the Headers constructor sees only real string values.\n this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);\n this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);\n this.fetchOptions = options.fetchOptions ?? {};\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.retry = { ...DEFAULT_RETRY, ...(options.retry ?? {}) };\n this.userAgent = options.userAgent ?? \"nebula-sdk-js/0.0.1\";\n }\n\n buildUrl(path: string, pathParams?: Record<string, string | number>, query?: Record<string, unknown>): string {\n let resolved = path;\n if (pathParams) {\n for (const [k, v] of Object.entries(pathParams)) {\n resolved = resolved.replace(`{${k}}`, encodeURIComponent(String(v)));\n }\n }\n const url = new URL(this.baseUrl + resolved);\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v)) for (const item of v) url.searchParams.append(k, String(item));\n else url.searchParams.set(k, String(v));\n }\n }\n return url.toString();\n }\n\n private buildHeaders(perRequest?: Record<string, string>, hasBody = false): Headers {\n const headers = new Headers(this.defaultHeaders);\n headers.set(\"User-Agent\", this.userAgent);\n headers.set(\"Accept\", \"application/json\");\n if (hasBody) headers.set(\"Content-Type\", \"application/json\");\n if (this.apiKey) headers.set(\"X-API-Key\", this.apiKey);\n if (this.bearerToken) headers.set(\"Authorization\", `Bearer ${this.bearerToken}`);\n if (perRequest) {\n for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);\n }\n return headers;\n }\n\n async request<T>(args: RequestArgs): Promise<T> {\n const url = this.buildUrl(args.path, args.pathParams, args.query);\n const hasBody = args.body !== undefined && args.body !== null;\n const headers = this.buildHeaders(args.headers, hasBody);\n // Spread caller-supplied fetch options first so the runtime-owned\n // method/headers/body always win on key collision. The TS type for\n // `fetchOptions` already excludes those keys, so this is belt-and-\n // suspenders.\n const init: RequestInit = {\n ...this.fetchOptions,\n method: args.method,\n headers,\n body: hasBody ? JSON.stringify(args.body) : undefined,\n };\n\n const maxAttempts = (args.idempotent ?? false) ? this.retry.maxRetries + 1 : 1;\n let lastError: unknown;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n const controller = new AbortController();\n const timeoutHandle = setTimeout(() => controller.abort(new Error(\"timeout\")), this.timeoutMs);\n const { signal: composedSignal, dispose: disposeAbort } = composeAbort(\n controller.signal,\n args.signal\n );\n try {\n const response = await this.fetchImpl(url, { ...init, signal: composedSignal });\n\n if (response.ok) {\n if (response.status === 204) return undefined as T;\n return (await response.json()) as T;\n }\n\n const text = await safeReadText(response);\n const parsed = safeParseJSON(text);\n const retryAfter = parseRetryAfter(response.headers.get(\"Retry-After\"));\n const err = errorFromResponse(\n {\n status: response.status,\n requestId: response.headers.get(\"X-Request-Id\") ?? undefined,\n body: parsed ?? text,\n },\n retryAfter\n );\n\n if (isRetryableStatus(response.status) && attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry, retryAfter), args.signal);\n lastError = err;\n continue;\n }\n throw err;\n } catch (rawError) {\n if (rawError instanceof Error && rawError.name === \"AbortError\") {\n if (args.signal?.aborted) throw rawError;\n throw new NebulaTimeoutError(`Request timed out after ${this.timeoutMs}ms`, { cause: rawError });\n }\n if (rawError instanceof NebulaAPIError || rawError instanceof NebulaConnectionError) {\n throw rawError;\n }\n if (attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry), args.signal);\n lastError = rawError;\n continue;\n }\n if (rawError instanceof Error) {\n throw new NebulaConnectionError(rawError.message, { cause: rawError });\n }\n throw rawError;\n } finally {\n clearTimeout(timeoutHandle);\n disposeAbort();\n }\n }\n throw lastError ?? new NebulaConnectionError(\"retry budget exhausted\");\n }\n}\n\nfunction composeAbort(\n timeoutSignal: AbortSignal,\n userSignal?: AbortSignal\n): { signal: AbortSignal; dispose: () => void } {\n if (!userSignal) return { signal: timeoutSignal, dispose: () => {} };\n const controller = new AbortController();\n // Hold one listener per source so dispose can detach exactly what we added.\n // Caller's signal can outlive the request (e.g. a long-lived request-scope\n // controller reused across many SDK calls); without dispose, each call's\n // closures would stay pinned on it until that signal eventually aborts.\n const onTimeoutAbort = () =>\n controller.abort(timeoutSignal.reason ?? new Error(\"aborted\"));\n const onUserAbort = () =>\n controller.abort(userSignal.reason ?? new Error(\"aborted\"));\n if (timeoutSignal.aborted) controller.abort(timeoutSignal.reason);\n if (userSignal.aborted) controller.abort(userSignal.reason);\n timeoutSignal.addEventListener(\"abort\", onTimeoutAbort, { once: true });\n userSignal.addEventListener(\"abort\", onUserAbort, { once: true });\n const dispose = () => {\n timeoutSignal.removeEventListener(\"abort\", onTimeoutAbort);\n userSignal.removeEventListener(\"abort\", onUserAbort);\n };\n return { signal: controller.signal, dispose };\n}\n\nasync function safeReadText(response: Response): Promise<string> {\n try {\n return await response.text();\n } catch {\n return \"\";\n }\n}\n\nfunction safeParseJSON(text: string): unknown {\n if (!text) return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction filterNullishHeaders(\n headers: Record<string, string> | undefined\n): Record<string, string> {\n if (!headers) return {};\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(headers)) {\n // Accept anything that survives the truthy guard; the type is\n // `Record<string, string>` but callers occasionally cast with\n // `as any` to slip nulls through.\n if (v !== null && v !== undefined) out[k] = v;\n }\n return out;\n}\n\nfunction parseRetryAfter(header: string | null): number | undefined {\n if (!header) return undefined;\n const asNumber = Number.parseFloat(header);\n if (Number.isFinite(asNumber)) return asNumber;\n const asDate = Date.parse(header);\n if (Number.isFinite(asDate)) return Math.max(0, (asDate - Date.now()) / 1000);\n return undefined;\n}\n","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ClientResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Health probe\n *\n * 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.\n * @operationId client.health\n * @endpoint GET /v1/health\n */\n async health(options?: RequestOptions): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"GET\",\n path: \"/v1/health\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class CollectionsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create a new collection\n *\n * Create a new collection and automatically add the creating user\n * to it.\n *\n * This endpoint allows authenticated users to create a new collection\n * with a specified name and optional description. The user creating\n * the collection is automatically added as a member.\n * @operationId collections.create\n * @endpoint POST /v1/collections\n */\n async create(\n body: components[\"schemas\"][\"CreateCollectionRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Delete collection\n *\n * Delete an existing collection.\n *\n * This endpoint allows deletion of a collection identified by its\n * UUID. The user must have appropriate permissions to delete the\n * collection. Deleting a collection removes all associations but does\n * not delete the engrams within it.\n * @operationId collections.delete\n * @endpoint DELETE /v1/collections/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * List collections\n *\n * Returns a cursor-paginated list of collections the authenticated\n * user has access to.\n *\n * Results can be filtered by providing specific collection IDs.\n * Regular users will only see collections they own or have access to.\n * Superusers can see all collections.\n *\n * The collections are returned in order of last modification, with\n * most recent first.\n * @operationId collections.list\n * @endpoint GET /v1/collections\n */\n async list(\n params: {\n /** A list of collection IDs to retrieve. If not provided, all collections will be returned. */\n ids?: Array<string>;\n /** Filter collections by name (case-insensitive exact match). */\n name?: string | null;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** If true, only returns collections owned by the user, not all accessible collections. */\n ownerOnly?: boolean;\n /** Filter by workspace ID. Pass a UUID to scope to a workspace, or omit for all. */\n workspaceId?: string | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedCollectionResponse\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections\",\n pathParams: {},\n query: { ids: params.ids, name: params.name, cursor: params.cursor, limit: params.limit, owner_only: params.ownerOnly, workspace_id: params.workspaceId },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Get collection details\n *\n * Get details of a specific collection.\n *\n * This endpoint retrieves detailed information about a single\n * collection identified by its UUID. The user must have access to the\n * collection to view its details.\n * @operationId collections.retrieve\n * @endpoint GET /v1/collections/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Get a collection by name\n *\n * Retrieve a collection by its (owner_id, name) combination.\n *\n * The authenticated user can only fetch collections they own, or, if\n * superuser, from anyone.\n * @operationId collections.retrieveByName\n * @endpoint GET /v1/collections/name/{collection_name}\n */\n async retrieveByName(\n params: {\n /** The name of the collection */\n collectionName: string;\n /** (Superuser only) Specify the owner_id to retrieve a collection by name */\n ownerId?: string | null;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/name/{collection_name}\",\n pathParams: { collection_name: params.collectionName },\n query: { owner_id: params.ownerId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Update collection\n *\n * Update an existing collection's configuration.\n *\n * This endpoint allows updating the name, description, and access settings of an\n * existing collection. The user must have appropriate permissions to\n * modify the collection.\n * @operationId collections.update\n * @endpoint POST /v1/collections/{id}\n */\n async update(\n params: {\n /** The unique identifier of the collection to update */\n id: string;\n body: components[\"schemas\"][\"UpdateCollectionRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ConnectorsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Start OAuth connection flow\n *\n * 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.\n * @operationId connectors.connect\n * @endpoint POST /v1/connectors/{provider}/connect\n */\n async connect(\n params: {\n provider: string;\n body: components[\"schemas\"][\"ConnectRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{provider}/connect\",\n pathParams: { provider: params.provider },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectResponse\"] };\n return response.results;\n }\n\n /**\n * Disconnect an external data source\n *\n * 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.\n * @operationId connectors.disconnect\n * @endpoint DELETE /v1/connectors/{connection_id}\n */\n async disconnect(\n params: {\n connectionId: string;\n deleteMemories?: boolean;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorDisconnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorDisconnectResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: params.connectionId },\n query: { delete_memories: params.deleteMemories },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorDisconnectResponse\"] };\n return response.results;\n }\n\n /**\n * List active connections for a collection\n *\n * 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.\n * @operationId connectors.list\n * @endpoint GET /v1/connectors\n */\n async list(\n params: {\n collectionId: string;\n},\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors\",\n pathParams: {},\n query: { collection_id: params.collectionId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]> };\n return response.results;\n }\n\n /**\n * List available connector providers\n *\n * 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.\n * @operationId connectors.listProviders\n * @endpoint GET /v1/connectors/providers\n */\n async listProviders(options?: RequestOptions): Promise<Array<string>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStr\"]>({\n method: \"GET\",\n path: \"/v1/connectors/providers\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<string> };\n return response.results;\n }\n\n /**\n * Get a single connection by ID\n *\n * 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.\n * @operationId connectors.retrieve\n * @endpoint GET /v1/connectors/{connection_id}\n */\n async retrieve(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectionResponse\"] };\n return response.results;\n }\n\n /**\n * Manually trigger a sync\n *\n * 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.\n * @operationId connectors.sync\n * @endpoint POST /v1/connectors/{connection_id}/sync\n */\n async sync(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorSyncResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorSyncResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{connection_id}/sync\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorSyncResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class MemoriesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Append content to an engram\n *\n * Append content to an existing engram.\n *\n * **For conversation engrams:**\n * - Provide `messages` array with content, role, and optional metadata\n * - Works like `/conversations/{id}/messages` endpoint\n *\n * **For document engrams:**\n * - Provide either `raw_text` or `chunks` to append additional content\n * - Content will be processed and added to the engram\n * @operationId memories.append\n * @endpoint POST /v1/memories/{id}/append\n */\n async append(\n params: {\n /** The unique identifier of the engram */\n id: string;\n body: components[\"schemas\"][\"AppendMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/{id}/append\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"] };\n return response.results;\n }\n\n /**\n * Create a new memory (conversation or document)\n *\n * Create a new memory (conversation or document) using clean JSON body.\n *\n * - Use `collection_id` (UUID)\n * - `kind` is optional and inferred from payload shape:\n * - If `messages` present -> conversation\n * - Otherwise -> document\n * - For conversations: provide `messages` array\n * - For documents: provide `raw_text` or `chunks`\n * - Use `snapshot` for device-memory mode (mutually exclusive with collection_id)\n * @operationId memories.create\n * @endpoint POST /v1/memories\n */\n async create(\n body: components[\"schemas\"][\"CreateMemoryRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"MemoryCreateResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"] };\n return response.results;\n }\n\n /**\n * Get presigned URL for large file upload\n *\n * Get a presigned URL for uploading large files directly to S3.\n *\n * Use this for files larger than 5MB that cannot be sent inline as base64.\n * After uploading, reference the file in memory creation using S3FileReference.\n *\n * Args:\n * filename: Original filename (e.g., \"image.jpg\")\n * content_type: MIME type (e.g., \"image/jpeg\", \"application/pdf\")\n * file_size: Expected file size in bytes (max 100MB)\n *\n * Returns:\n * dict with:\n * - upload_url: Presigned URL for PUT request (expires in 1 hour)\n * - upload_headers: Headers that must be sent with the presigned PUT request\n * - s3_key: The S3 key to reference in memory creation\n * - bucket: S3 bucket name\n * - expires_in: Seconds until URL expires\n * - max_size: Maximum allowed file size\n * @operationId memories.createUpload\n * @endpoint POST /v1/memories/upload\n */\n async createUpload(\n params: {\n /** Original filename (e.g., 'image.jpg') */\n filename: string;\n /** MIME type (e.g., 'image/jpeg', 'application/pdf') */\n contentType: string;\n /** Expected file size in bytes (max 100MB) */\n fileSize: number;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PresignedUploadResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedPresignedUploadResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { filename: params.filename, content_type: params.contentType, file_size: params.fileSize },\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"PresignedUploadResponse\"] };\n return response.results;\n }\n\n /**\n * Delete an engram\n *\n * Delete a specific engram with graph awareness. All chunks corresponding to the\n * engram are deleted, and graph components (entities/relationships) are updated\n * or deleted based on remaining chunk references from other engrams.\n *\n * This method now properly handles graph components and maintains graph integrity\n * for search operations.\n * @operationId memories.delete\n * @endpoint DELETE /v1/memories/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * Delete one or more engrams\n *\n * Delete one or more engrams.\n *\n * This endpoint efficiently handles both single and batch deletions.\n * When multiple IDs are provided, it uses optimized batch operations.\n *\n * Args:\n * ids: Either a single UUID or a list of UUIDs to delete\n *\n * Returns:\n * For single deletion: boolean success response\n * For batch deletion: detailed results with successful and failed deletions\n * @operationId memories.deleteMany\n * @endpoint POST /v1/memories/delete\n */\n async deleteMany(\n body: components[\"schemas\"][\"DeleteMemoriesRequest\"],\n options?: RequestOptions,\n ): Promise<unknown> {\n return this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/delete\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n });\n }\n\n /**\n * Delete a previously uploaded S3 file\n *\n * Delete a file from S3 that was uploaded via a presigned URL.\n * Verifies the caller owns the file via S3 object metadata.\n * @operationId memories.deleteUpload\n * @endpoint DELETE /v1/memories/upload\n */\n async deleteUpload(\n params: {\n /** S3 key of the file to delete (returned by POST /memories/upload) */\n s3Key: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { s3_key: params.s3Key },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n /**\n * List engrams\n *\n * Returns a cursor-paginated list of engrams the authenticated user\n * has access to.\n *\n * Results can be filtered by providing specific engram IDs or collection IDs.\n * Regular users will only see engrams they own or have access to through\n * collections. Superusers can see all engrams.\n *\n * The engrams are returned in order of creation time, most recent\n * first. The response includes the engram's text field if available.\n * @operationId memories.list\n * @endpoint GET /v1/memories\n */\n async list(\n params: {\n /** A list of engram IDs to retrieve. If not provided, all engrams will be returned. */\n ids?: Array<string>;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** Maximum chunks to inline per engram. Defaults to all chunks for backwards compatibility; pass 0 to skip chunk hydration. */\n chunksLimit?: number | null;\n /** If true, only returns engrams owned by the user, not all accessible engrams. */\n ownerOnly?: boolean;\n /** Optional list of collection IDs to filter engrams by. If provided, exactly one collection ID must be specified. */\n collectionIds?: Array<string> | null;\n /** JSON string for metadata filtering. Example: '{\"metadata.source\": {\"$eq\": \"playground\"}}' */\n metadataFilters?: string | null;\n /** Read-your-writes assertion: the WAL-tail overlay path waits for at least this seq to be applied before serving (or returns 503 Unavailable on timeout). REQUIRES exactly one collection_ids entry — without a collection scope the request returns 422 (the per-WAL-shard scalar applied_wal_seq is meaningless across collections). When the served shard has not been migrated to wal_compaction_enabled, the field is accepted but the served path is the legacy overlay (the assertion has no effect — the response's applied_wal_seq will be 0). Pass back the value the matching upload response surfaced. */\n minAppliedWalSeq?: number | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedListedEngram\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedListedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories\",\n pathParams: {},\n query: { ids: params.ids, cursor: params.cursor, limit: params.limit, chunks_limit: params.chunksLimit, owner_only: params.ownerOnly, collection_ids: params.collectionIds, metadata_filters: params.metadataFilters, min_applied_wal_seq: params.minAppliedWalSeq },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Recall workflow patterns by intent\n *\n * Workflow-pattern recall over 5 intents.\n *\n * * ``cursor`` -- match the caller's anchor against pattern\n * canonical states, return ranked patterns + position.\n * * ``predict`` -- like cursor but include the predicted next\n * trace from each pattern's canonical instance.\n * * ``resume`` -- like cursor, biased toward longer patterns.\n * * ``evidence`` -- expand a specific pattern via\n * ``hydrate_pattern``.\n * * ``bootstrap`` -- top-K patterns by confidence with no anchor.\n * @operationId memories.recallWorkflow\n * @endpoint POST /v1/memories/workflow/recall\n */\n async recallWorkflow(\n body: components[\"schemas\"][\"CursorRecallRequest\"] | components[\"schemas\"][\"PredictRecallRequest\"] | components[\"schemas\"][\"ResumeRecallRequest\"] | components[\"schemas\"][\"EvidenceRecallRequest\"] | components[\"schemas\"][\"BootstrapRecallRequest\"],\n options?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n const response = (await this.core.request<components[\"schemas\"][\"WorkflowRecallResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/workflow/recall\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: Record<string, unknown> };\n return response.results;\n }\n\n /**\n * Retrieve an engram\n *\n * Retrieves detailed information about a specific engram by its\n * ID.\n *\n * This endpoint returns the engram's metadata, status, and system information. It does not\n * return the engram's content - use the `/engrams/{id}/download` endpoint for that.\n *\n * Users can only retrieve engrams they own or have access to through collections.\n * Superusers can retrieve any engram.\n * @operationId memories.retrieve\n * @endpoint GET /v1/memories/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n /**\n * Search memories\n *\n * Perform a search query across your memories.\n *\n * **Standard mode** (collection_ids or readable-scope search): returns hierarchical MemoryRecall\n * with semantics, episodes, procedures, and sources.\n *\n * **Snapshot mode** (snapshot field): returns graph-search results with\n * {entities, relationships} from stateless in-memory traversal.\n * @operationId memories.search\n * @endpoint POST /v1/memories/search\n */\n async search(\n body: components[\"schemas\"][\"MemorySearchRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/search\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"] };\n return response.results;\n }\n\n /**\n * Update a memory\n *\n * Update memory-level properties including name, metadata, and collection associations.\n *\n * This endpoint allows updating properties of an entire memory (document or conversation)\n * without modifying its content:\n * - **name**: Updates the authoritative engram title\n * - **metadata**: Can replace or merge with existing metadata\n * - **collection_ids**: Updates authoritative engram collection associations\n *\n * Users can only update memories they own or have access to through collections.\n * At least one collection association must be maintained.\n *\n * If collection_id is provided and the engram is shared across collections, a copy-on-write\n * will be performed to create a collection-specific copy before modification.\n * @operationId memories.update\n * @endpoint PATCH /v1/memories/{id}\n */\n async update(\n params: {\n /** The unique identifier of the memory */\n id: string;\n /** Collection context for copy-on-write. If provided and engram is shared, creates a copy before modification. */\n collectionId?: string | null;\n body: components[\"schemas\"][\"UpdateMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"PATCH\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: params.id },\n query: { collection_id: params.collectionId },\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class SnapshotsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Export a collection snapshot\n *\n * Export a collection's full graph state as a\n * portable SnapshotEnvelope.\n * @operationId snapshots.export\n * @endpoint POST /v1/device-memory/snapshot/export\n */\n async export(\n body: components[\"schemas\"][\"SnapshotExportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotEnvelopeOrSnapshotObjectReference\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/export\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"] };\n return response.results;\n }\n\n /**\n * Import a snapshot into an ephemeral collection\n *\n * Import a SnapshotEnvelope into an ephemeral\n * collection. Returns the ephemeral collection UUID.\n * @operationId snapshots.import\n * @endpoint POST /v1/device-memory/snapshot/import\n */\n async import(\n body: components[\"schemas\"][\"SnapshotImportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotImportResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotImportResult\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/import\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotImportResult\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class WorkspacesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create workspace storage target\n *\n * Register a customer S3 bucket for hosted BYOC storage.\n * @operationId workspaces.createStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets\n */\n async createStorageTarget(\n params: {\n workspaceId: string;\n body: components[\"schemas\"][\"StorageTargetCreateRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: params.workspaceId },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * Disable workspace storage target\n *\n * Disable a customer storage target for future collection binds.\n * @operationId workspaces.disableStorageTarget\n * @endpoint DELETE /v1/workspaces/{workspace_id}/storage-targets/{target_id}\n */\n async disableStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * List workspace storage targets\n *\n * List customer-owned object storage targets for a workspace.\n * @operationId workspaces.listStorageTargets\n * @endpoint GET /v1/workspaces/{workspace_id}/storage-targets\n */\n async listStorageTargets(\n workspaceId: string,\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"StorageTargetResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStorageTargetResponse\"]>({\n method: \"GET\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: workspaceId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"StorageTargetResponse\"]> };\n return response.results;\n }\n\n /**\n * Validate workspace storage target\n *\n * Probe a customer storage target and mark it active on success.\n * @operationId workspaces.validateStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\n */\n async validateStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport { NebulaCore, type ClientOptions } from \"./runtime/client.ts\";\nimport { ClientResource } from \"./resources/client.ts\";\nimport { CollectionsResource } from \"./resources/collections.ts\";\nimport { ConnectorsResource } from \"./resources/connectors.ts\";\nimport { MemoriesResource } from \"./resources/memories.ts\";\nimport { SnapshotsResource } from \"./resources/snapshots.ts\";\nimport { WorkspacesResource } from \"./resources/workspaces.ts\";\n\nexport class NebulaClient {\n protected readonly core: NebulaCore;\n readonly client: ClientResource;\n readonly collections: CollectionsResource;\n readonly connectors: ConnectorsResource;\n readonly memories: MemoriesResource;\n readonly snapshots: SnapshotsResource;\n readonly workspaces: WorkspacesResource;\n\n constructor(options: ClientOptions = {}) {\n this.core = new NebulaCore(options);\n this.client = new ClientResource(this.core);\n this.collections = new CollectionsResource(this.core);\n this.connectors = new ConnectorsResource(this.core);\n this.memories = new MemoriesResource(this.core);\n this.snapshots = new SnapshotsResource(this.core);\n this.workspaces = new WorkspacesResource(this.core);\n }\n}","// Handwritten Nebula DX layer.\n//\n// Carries only the methods that need real dispatch logic: storeMemory's\n// create-vs-append branch, bulk storeMemories with a concurrency cap,\n// positional connector helpers (connectProvider/listConnections/\n// disconnectConnection), and auth normalization.\n//\n// For everything else, use the resource methods directly. Resource\n// methods now return unwrapped values natively (the generator peels\n// the `{results: X}` wire envelope), so there's no separate auto-\n// generated unwrap layer to extend.\n//\n// Source of truth: nebula-sdks/custom/typescript/dx.ts\n// The generator copies this file into sdks/typescript/src/lib/dx.ts on every\n// `bun run generate`. Edit the source, not the copy.\n\nimport { NebulaClient } from \"../client.ts\";\nimport {\n type ClientOptions,\n type components,\n} from \"../index.ts\";\n\ntype Schemas = components[\"schemas\"];\ntype SnapshotEnvelopeInput = Schemas[\"SnapshotEnvelope-Input\"];\ntype SnapshotEnvelopeOutput = Schemas[\"SnapshotEnvelope-Output\"];\n\nexport type CompatClientOptions = ClientOptions & {\n apiKey?: string | null;\n baseUrl?: string | null;\n // Stainless-shape capital-U alias. Some internal callers\n // (backend/local-websocket-server, backend/lambda/websocket-llm) still\n // pass `baseURL`; without this alias the value falls through unused\n // and the runtime defaults to api.zeroset.com.\n baseURL?: string | null;\n // Stainless-shape alias for `timeoutMs`. Same compat reason.\n timeout?: number | null;\n bearerToken?: string | null;\n};\n\nexport interface MemoryCommonInput {\n collection_id?: string | null;\n collectionId?: string | null;\n content?: string | string[] | unknown[] | null;\n raw_text?: string | null;\n chunks?: Array<string> | null;\n messages?: unknown[] | null;\n metadata?: { [key: string]: unknown } | null;\n ingestion_config?: unknown;\n ingestion_mode?: string | null;\n}\n\nexport interface MemoryCreateInput extends MemoryCommonInput {\n kind?: Schemas[\"EngramKind\"] | null;\n name?: string | null;\n speaker_id?: string | null;\n speaker_name?: string | null;\n content_parts?: unknown[] | null;\n contents?: string[] | null;\n snapshot?: SnapshotEnvelopeInput | null;\n memory_id?: undefined | null;\n}\n\nexport interface MemoryAppendInput extends Omit<MemoryCommonInput, \"ingestion_mode\" | \"messages\"> {\n memory_id: string;\n ingestion_mode?: string | null;\n messages?: unknown[] | null;\n}\n\nexport type MemoryInput = MemoryCreateInput | MemoryAppendInput;\n\ntype MemoryCreateBody = Schemas[\"CreateMemoryRequest\"];\ntype MemoryAppendBody = Schemas[\"AppendMemoryRequest\"];\n\nexport class Nebula extends NebulaClient {\n constructor(options: CompatClientOptions = {}) {\n super(normalizeAuthOptions(normalizeClientOptions(options)));\n }\n\n /**\n * Polymorphic memory creator: dispatches to memories.create or memories.append\n * based on whether `memory_id` is set on the input. Returns the new memory's\n * id (string), or — when `snapshot` is set — the updated snapshot envelope.\n */\n async storeMemory(\n memory: MemoryInput,\n options?: { signal?: AbortSignal }\n ): Promise<string | SnapshotEnvelopeOutput> {\n if (\"memory_id\" in memory && memory.memory_id != null) {\n const memoryID = memory.memory_id;\n await this.memories.append(\n { id: memoryID, body: toMemoryAppendParams(memory) },\n options\n );\n return memoryID;\n }\n // `memories.create` now returns the unwrapped inner type directly\n // (the generator peels the wire `{results: X}` envelope).\n const result = await this.memories.create(\n toMemoryCreateParams(memory as MemoryCreateInput),\n options\n );\n if (isSnapshotResult(result)) {\n return (result.snapshot ?? result) as SnapshotEnvelopeOutput;\n }\n return extractID(result);\n }\n\n /**\n * Bulk parallel version of storeMemory with a concurrency cap.\n *\n * Default 8 concurrent in-flight requests matches the Python DX's\n * `asyncio.Semaphore(max_concurrency)` pattern. Use `maxConcurrency: 1`\n * for strictly serial submission; higher values risk overwhelming the\n * server when memories[] is large.\n */\n async storeMemories(\n memories: MemoryInput[],\n options?: { signal?: AbortSignal; maxConcurrency?: number }\n ): Promise<(string | SnapshotEnvelopeOutput)[]> {\n const cap = Math.max(1, options?.maxConcurrency ?? 8);\n const signal = options?.signal;\n const results: (string | SnapshotEnvelopeOutput)[] = new Array(memories.length);\n let nextIndex = 0;\n const worker = async (): Promise<void> => {\n while (true) {\n const i = nextIndex++;\n if (i >= memories.length) return;\n results[i] = await this.storeMemory(memories[i], { signal });\n }\n };\n await Promise.all(\n Array.from({ length: Math.min(cap, memories.length) }, () => worker())\n );\n return results;\n }\n\n /**\n * List memories scoped to one or more collection ids (string | string[])\n * or a full MemoryListParams object.\n */\n async listMemories(\n query: string | string[] | Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const normalized: Record<string, unknown> =\n typeof query === \"string\" || Array.isArray(query)\n ? { collectionIds: arrayify(query) }\n : query;\n return this.memories.list(normalized as never, options);\n }\n\n /**\n * Positional `connectProvider(provider, collectionID, config?)` — wraps the\n * generated `connectors.connect({provider, body})` to build the body shape.\n */\n async connectProvider(\n provider: string,\n collectionID: string,\n config?: Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const body: Schemas[\"ConnectRequest\"] = {\n collection_id: collectionID,\n ...(config !== undefined ? { config } : {}),\n } as Schemas[\"ConnectRequest\"];\n return this.connectors.connect({ provider, body }, options);\n }\n\n /** Positional listConnections(collectionID) — wraps the query wrapper. */\n async listConnections(\n collectionID: string,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.list({ collectionId: collectionID } as never, options);\n }\n\n /** Positional disconnect(connectionID, deleteMemories?). */\n async disconnectConnection(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n /** Alias for disconnectConnection (same arg shape). */\n async disconnect(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n}\n\n// ---------- helpers ----------\n\nfunction normalizeAuthOptions(options: ClientOptions): ClientOptions {\n if (\n options.apiKey != null &&\n options.bearerToken == null &&\n !looksLikeNebulaAPIKey(options.apiKey)\n ) {\n return { ...options, apiKey: undefined, bearerToken: options.apiKey };\n }\n return options;\n}\n\nfunction normalizeClientOptions(options: CompatClientOptions): ClientOptions {\n const {\n apiKey,\n baseUrl: baseUrlAlias,\n baseURL: baseURLCapAlias,\n timeout: timeoutAlias,\n bearerToken,\n ...rest\n } = options;\n const restClientOptions: ClientOptions = rest;\n return {\n ...restClientOptions,\n apiKey: apiKey ?? undefined,\n bearerToken: bearerToken ?? undefined,\n baseUrl:\n firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? undefined,\n timeoutMs:\n firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? undefined,\n };\n}\n\nfunction firstDefined<T>(...values: (T | null | undefined)[]): T | null | undefined {\n return values.find((value) => value !== undefined);\n}\n\nexport function looksLikeNebulaAPIKey(token: string): boolean {\n const parts = token.split(\".\");\n if (parts.length !== 2) return false;\n const [publicPart, rawPart] = parts;\n return Boolean(rawPart) && (publicPart.startsWith(\"key_\") || publicPart.startsWith(\"neb_\"));\n}\n\nfunction toMemoryCreateParams(memory: MemoryCreateInput): MemoryCreateBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;\n const params: Record<string, unknown> = { ...rest };\n\n if (collectionID !== undefined) {\n params.collection_id = collectionID;\n }\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else {\n params.content_parts = content;\n }\n }\n if (params.messages != null && !params.kind) {\n params.kind = \"conversation\";\n }\n return params as MemoryCreateBody;\n}\n\nfunction toMemoryAppendParams(memory: MemoryAppendInput): MemoryAppendBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n if (!collectionID) {\n throw new Error(\"collection_id is required when appending to an existing memory\");\n }\n const params: Record<string, unknown> = { collection_id: collectionID };\n for (const key of [\"metadata\", \"ingestion_config\", \"ingestion_mode\", \"raw_text\", \"chunks\", \"messages\"] as const) {\n const value = memory[key as keyof MemoryAppendInput];\n if (value != null) params[key] = value;\n }\n const content = (memory as MemoryCommonInput).content;\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else if (Array.isArray(content) && content.every((item) => typeof item === \"string\")) {\n params.chunks = content;\n } else if (Array.isArray(content)) {\n params.messages = content;\n }\n }\n return params as MemoryAppendBody;\n}\n\nfunction extractID(value: unknown): string {\n if (typeof value === \"object\" && value !== null) {\n const record = value as Record<string, unknown>;\n const id =\n record[\"id\"] ?? record[\"memory_id\"] ?? record[\"engram_id\"] ?? record[\"ephemeral_collection_id\"];\n if (typeof id === \"string\") return id;\n }\n throw new Error(\"Nebula memory create response did not include an id\");\n}\n\nfunction isSnapshotResult(value: unknown): value is { snapshot?: SnapshotEnvelopeOutput } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"snapshot\" in (value as Record<string, unknown>)\n );\n}\n\nfunction arrayify(value: string | string[]): string[] {\n return Array.isArray(value) ? value : [value];\n}\n"],"mappings":";AAAA,IAAa,cAAb,cAAiC,MAAM;CACrC,OAAiC;CACjC,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;CACxB;AACF;AAEA,IAAa,wBAAb,cAA2C,YAAY;CACrD,OAAyB;AAC3B;AAEA,IAAa,qBAAb,cAAwC,YAAY;CAClD,OAAyB;AAC3B;AA6BA,SAAS,WAAW,MAAsC;CACxD,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA4B,SAAS,YAC7C,OAAQ,KAA+B,YAAY;AAEvD;AAEA,IAAa,iBAAb,cAAoC,YAAY;CAC9C,OAAiC;CACjC;CACA;CACA;CAKA;CACA;CACA;CAEA,YAAY,SAA0B,SAAkB;EACtD,MAAM,WAAW,WAAW,QAAQ,IAAI,IAAI,QAAQ,OAAO,KAAA;EAC3D,MACE,WACE,UAAU,WACV,4BAA4B,QAAQ,OAAO,EAC/C;EACA,KAAK,SAAS,QAAQ;EAGtB,MAAM,UACJ,OAAO,UAAU,SAAS,WAAW,SAAS,OAAO,KAAA;EACvD,MAAM,SACJ,OAAO,UAAU,eAAe,WAC5B,SAAS,aACT,KAAA;EAIN,KAAK,YAAY,UAAU,QAAQ;EACnC,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W;OACb,IAAI,MAAM,QAAQ,OAAO,KAAK,QAAQ,OAAO,SAAS,OAAO,SAAS,QAAQ,GACnF,OAAO,SAAS;OACX,IAAI,MAAM,QAAQ,OAAO,GAC9B,OAAO,WAAW;CAAA;CAGtB,OAAO;AACT;AAEA,SAAS,UAAU,OAAwB;CACzC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,SAAS;EACf,MAAM,KACJ,OAAO,SAAS,OAAO,gBAAgB,OAAO,gBAAgB,OAAO;EACvE,IAAI,OAAO,OAAO,UAAU,OAAO;CACrC;CACA,MAAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,iBAAiB,OAAgE;CACxF,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAe;AAEnB;AAEA,SAAS,SAAS,OAAoC;CACpD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/runtime/errors.ts","../src/runtime/retry.ts","../src/runtime/client.ts","../src/resources/client.ts","../src/resources/collections.ts","../src/resources/connectors.ts","../src/resources/memories.ts","../src/resources/snapshots.ts","../src/resources/workspaces.ts","../src/client.ts","../src/lib/dx.ts"],"sourcesContent":["export class NebulaError extends Error {\n override readonly name: string = \"NebulaError\";\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n }\n}\n\nexport class NebulaConnectionError extends NebulaError {\n override readonly name = \"NebulaConnectionError\";\n}\n\nexport class NebulaTimeoutError extends NebulaError {\n override readonly name = \"NebulaTimeoutError\";\n}\n\n// Canonical Error envelope returned by every Nebula 4xx/5xx. The runtime\n// pulls these fields out of the response body and surfaces them as typed\n// accessors on NebulaAPIError so callers can branch on err.code without\n// digging into err.body.\n//\n// The optional fields are typed as `T | null` because the wire schema is\n// `anyOf [T, null]` — the server emits the keys with explicit `null` rather\n// than omitting them. The NebulaAPIError constructor coerces `null` to\n// `undefined` so the public accessor surface stays `T | undefined`.\nexport interface ErrorEnvelope {\n readonly type: string;\n readonly message: string;\n readonly code?: string | null;\n readonly request_id?: string | null;\n // `details` is intentionally `unknown`: the server emits arbitrary\n // JSON here. For validation errors it's an array of {loc, msg, type}\n // entries; for other classes it can be an object or null. Callers\n // should narrow at the read site (e.g. `Array.isArray(err.details)`).\n readonly details?: unknown;\n}\n\nexport interface APIErrorPayload {\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n}\n\nfunction isEnvelope(body: unknown): body is ErrorEnvelope {\n return (\n typeof body === \"object\" &&\n body !== null &&\n typeof (body as { type?: unknown }).type === \"string\" &&\n typeof (body as { message?: unknown }).message === \"string\"\n );\n}\n\nexport class NebulaAPIError extends NebulaError {\n override readonly name: string = \"NebulaAPIError\";\n readonly status: number;\n readonly requestId?: string;\n readonly body: unknown;\n // Canonical envelope fields. `type` is always present when the server\n // returned the documented envelope; the rest are present when the server\n // populated them. All four are undefined when the response body wasn't\n // an envelope (e.g. an HTML error page from a misconfigured proxy).\n readonly type?: string;\n readonly code?: string;\n readonly details?: unknown;\n\n constructor(payload: APIErrorPayload, message?: string) {\n const envelope = isEnvelope(payload.body) ? payload.body : undefined;\n super(\n message ??\n envelope?.message ??\n `Nebula API error (status ${payload.status})`\n );\n this.status = payload.status;\n // Coerce `null` (wire-level) to `undefined` (idiomatic JS absence) so\n // every accessor's runtime value matches its declared T | undefined.\n const envCode =\n typeof envelope?.code === \"string\" ? envelope.code : undefined;\n const envRid =\n typeof envelope?.request_id === \"string\"\n ? envelope.request_id\n : undefined;\n // Prefer the envelope's request_id (server-stamped) over the header\n // we captured at the transport — they should match, but if they\n // diverge the envelope is authoritative.\n this.requestId = envRid ?? payload.requestId;\n this.body = payload.body;\n this.type = envelope?.type;\n this.code = envCode;\n this.details = envelope?.details ?? undefined;\n }\n}\n\nexport class NebulaBadRequestError extends NebulaAPIError {\n override readonly name = \"NebulaBadRequestError\";\n}\nexport class NebulaUnauthorizedError extends NebulaAPIError {\n override readonly name = \"NebulaUnauthorizedError\";\n}\nexport class NebulaForbiddenError extends NebulaAPIError {\n override readonly name = \"NebulaForbiddenError\";\n}\nexport class NebulaNotFoundError extends NebulaAPIError {\n override readonly name = \"NebulaNotFoundError\";\n}\nexport class NebulaConflictError extends NebulaAPIError {\n override readonly name = \"NebulaConflictError\";\n}\nexport class NebulaValidationError extends NebulaAPIError {\n override readonly name = \"NebulaValidationError\";\n}\nexport class NebulaRateLimitError extends NebulaAPIError {\n override readonly name = \"NebulaRateLimitError\";\n readonly retryAfter?: number;\n constructor(payload: APIErrorPayload, retryAfter?: number) {\n super(payload);\n this.retryAfter = retryAfter;\n }\n}\nexport class NebulaServerError extends NebulaAPIError {\n override readonly name = \"NebulaServerError\";\n}\n\ntype APIErrorCtor = new (payload: APIErrorPayload) => NebulaAPIError;\n\nconst STATUS_TO_CLASS: Record<number, APIErrorCtor> = {\n 400: NebulaBadRequestError,\n 401: NebulaUnauthorizedError,\n 403: NebulaForbiddenError,\n 404: NebulaNotFoundError,\n 409: NebulaConflictError,\n 422: NebulaValidationError,\n};\n\nexport function errorFromResponse(payload: APIErrorPayload, retryAfter?: number): NebulaAPIError {\n if (payload.status === 429) return new NebulaRateLimitError(payload, retryAfter);\n const cls = STATUS_TO_CLASS[payload.status];\n if (cls) return new cls(payload);\n if (payload.status >= 500) return new NebulaServerError(payload);\n return new NebulaAPIError(payload);\n}\n","export interface RetryPolicy {\n readonly maxRetries: number;\n readonly baseMs: number;\n readonly maxMs: number;\n}\n\nexport const DEFAULT_RETRY: RetryPolicy = {\n maxRetries: 2,\n baseMs: 250,\n maxMs: 8000,\n};\n\nconst RETRYABLE_STATUSES: ReadonlySet<number> = new Set([408, 429, 502, 503, 504]);\n\nexport function isRetryableStatus(status: number): boolean {\n return RETRYABLE_STATUSES.has(status);\n}\n\nexport function backoffMs(attempt: number, policy: RetryPolicy, retryAfterSec?: number): number {\n if (retryAfterSec != null && Number.isFinite(retryAfterSec)) {\n return Math.min(retryAfterSec * 1000, policy.maxMs);\n }\n const exp = Math.min(policy.baseMs * 2 ** attempt, policy.maxMs);\n return Math.floor(Math.random() * exp);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (ms <= 0) return Promise.resolve();\n return new Promise((resolveSleep, reject) => {\n const handle = setTimeout(resolveSleep, ms);\n if (signal) {\n const onAbort = () => {\n clearTimeout(handle);\n reject(signal.reason ?? new Error(\"aborted\"));\n };\n if (signal.aborted) onAbort();\n else signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n}\n","import {\n errorFromResponse,\n NebulaAPIError,\n NebulaConnectionError,\n NebulaTimeoutError,\n} from \"./errors.ts\";\nimport { backoffMs, DEFAULT_RETRY, isRetryableStatus, sleep, type RetryPolicy } from \"./retry.ts\";\n\nexport interface ClientOptions {\n baseUrl?: string;\n apiKey?: string;\n defaultHeaders?: Record<string, string>;\n fetchImpl?: typeof fetch;\n // Caller-supplied RequestInit fields applied to every outbound fetch.\n // Lets browser callers pass `credentials: \"include\"` for cookie auth,\n // or `mode`/`cache`/`referrer` for cross-origin tuning. Method, headers,\n // body, and signal are owned by the runtime and cannot be overridden\n // here (they're set per-request).\n fetchOptions?: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n timeoutMs?: number;\n retry?: Partial<RetryPolicy>;\n userAgent?: string;\n}\n\nexport interface RequestArgs {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n pathParams?: Record<string, string | number>;\n query?: Record<string, unknown>;\n body?: unknown;\n headers?: Record<string, string>;\n idempotent?: boolean;\n signal?: AbortSignal;\n}\n\n/** Per-call options every generated resource method accepts. */\nexport interface RequestOptions {\n signal?: AbortSignal;\n}\n\nconst DEFAULT_BASE_URL = \"https://api.zeroset.com\";\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\nexport class NebulaCore {\n readonly baseUrl: string;\n readonly apiKey?: string;\n readonly defaultHeaders: Record<string, string>;\n readonly fetchImpl: typeof fetch;\n readonly fetchOptions: Omit<RequestInit, \"method\" | \"headers\" | \"body\" | \"signal\">;\n readonly timeoutMs: number;\n readonly retry: RetryPolicy;\n readonly userAgent: string;\n\n constructor(options: ClientOptions = {}) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n // Filter null/undefined values. Callers (often using `as any` to\n // bypass the `Record<string, string>` type) pass nulls to suppress\n // a header — but `new Headers({k: null})` coerces null to the\n // literal string \"null\", which a backend that checks \"is this\n // header present\" treats as an explicit credential. Strip nulls\n // here so the Headers constructor sees only real string values.\n this.defaultHeaders = filterNullishHeaders(options.defaultHeaders);\n this.fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);\n this.fetchOptions = options.fetchOptions ?? {};\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.retry = { ...DEFAULT_RETRY, ...(options.retry ?? {}) };\n this.userAgent = options.userAgent ?? \"nebula-sdk-js/0.0.1\";\n }\n\n buildUrl(path: string, pathParams?: Record<string, string | number>, query?: Record<string, unknown>): string {\n let resolved = path;\n if (pathParams) {\n for (const [k, v] of Object.entries(pathParams)) {\n resolved = resolved.replace(`{${k}}`, encodeURIComponent(String(v)));\n }\n }\n const url = new URL(this.baseUrl + resolved);\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v)) for (const item of v) url.searchParams.append(k, String(item));\n else url.searchParams.set(k, String(v));\n }\n }\n return url.toString();\n }\n\n private buildHeaders(perRequest?: Record<string, string>, hasBody = false): Headers {\n const headers = new Headers(this.defaultHeaders);\n headers.set(\"User-Agent\", this.userAgent);\n headers.set(\"Accept\", \"application/json\");\n if (hasBody) headers.set(\"Content-Type\", \"application/json\");\n // The API key authenticates via the Authorization header — the backend\n // resolves a Nebula API key (or, for internal callers, a JWT) from the\n // same bearer credential.\n if (this.apiKey) headers.set(\"Authorization\", `Bearer ${this.apiKey}`);\n if (perRequest) {\n for (const [k, v] of Object.entries(perRequest)) headers.set(k, v);\n }\n return headers;\n }\n\n async request<T>(args: RequestArgs): Promise<T> {\n const url = this.buildUrl(args.path, args.pathParams, args.query);\n const hasBody = args.body !== undefined && args.body !== null;\n const headers = this.buildHeaders(args.headers, hasBody);\n // Spread caller-supplied fetch options first so the runtime-owned\n // method/headers/body always win on key collision. The TS type for\n // `fetchOptions` already excludes those keys, so this is belt-and-\n // suspenders.\n const init: RequestInit = {\n ...this.fetchOptions,\n method: args.method,\n headers,\n body: hasBody ? JSON.stringify(args.body) : undefined,\n };\n\n const maxAttempts = (args.idempotent ?? false) ? this.retry.maxRetries + 1 : 1;\n let lastError: unknown;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n const controller = new AbortController();\n const timeoutHandle = setTimeout(() => controller.abort(new Error(\"timeout\")), this.timeoutMs);\n const { signal: composedSignal, dispose: disposeAbort } = composeAbort(\n controller.signal,\n args.signal\n );\n try {\n const response = await this.fetchImpl(url, { ...init, signal: composedSignal });\n\n if (response.ok) {\n if (response.status === 204) return undefined as T;\n return (await response.json()) as T;\n }\n\n const text = await safeReadText(response);\n const parsed = safeParseJSON(text);\n const retryAfter = parseRetryAfter(response.headers.get(\"Retry-After\"));\n const err = errorFromResponse(\n {\n status: response.status,\n requestId: response.headers.get(\"X-Request-Id\") ?? undefined,\n body: parsed ?? text,\n },\n retryAfter\n );\n\n if (isRetryableStatus(response.status) && attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry, retryAfter), args.signal);\n lastError = err;\n continue;\n }\n throw err;\n } catch (rawError) {\n if (rawError instanceof Error && rawError.name === \"AbortError\") {\n if (args.signal?.aborted) throw rawError;\n throw new NebulaTimeoutError(`Request timed out after ${this.timeoutMs}ms`, { cause: rawError });\n }\n if (rawError instanceof NebulaAPIError || rawError instanceof NebulaConnectionError) {\n throw rawError;\n }\n if (attempt + 1 < maxAttempts) {\n await sleep(backoffMs(attempt, this.retry), args.signal);\n lastError = rawError;\n continue;\n }\n if (rawError instanceof Error) {\n throw new NebulaConnectionError(rawError.message, { cause: rawError });\n }\n throw rawError;\n } finally {\n clearTimeout(timeoutHandle);\n disposeAbort();\n }\n }\n throw lastError ?? new NebulaConnectionError(\"retry budget exhausted\");\n }\n}\n\nfunction composeAbort(\n timeoutSignal: AbortSignal,\n userSignal?: AbortSignal\n): { signal: AbortSignal; dispose: () => void } {\n if (!userSignal) return { signal: timeoutSignal, dispose: () => {} };\n const controller = new AbortController();\n // Hold one listener per source so dispose can detach exactly what we added.\n // Caller's signal can outlive the request (e.g. a long-lived request-scope\n // controller reused across many SDK calls); without dispose, each call's\n // closures would stay pinned on it until that signal eventually aborts.\n const onTimeoutAbort = () =>\n controller.abort(timeoutSignal.reason ?? new Error(\"aborted\"));\n const onUserAbort = () =>\n controller.abort(userSignal.reason ?? new Error(\"aborted\"));\n if (timeoutSignal.aborted) controller.abort(timeoutSignal.reason);\n if (userSignal.aborted) controller.abort(userSignal.reason);\n timeoutSignal.addEventListener(\"abort\", onTimeoutAbort, { once: true });\n userSignal.addEventListener(\"abort\", onUserAbort, { once: true });\n const dispose = () => {\n timeoutSignal.removeEventListener(\"abort\", onTimeoutAbort);\n userSignal.removeEventListener(\"abort\", onUserAbort);\n };\n return { signal: controller.signal, dispose };\n}\n\nasync function safeReadText(response: Response): Promise<string> {\n try {\n return await response.text();\n } catch {\n return \"\";\n }\n}\n\nfunction safeParseJSON(text: string): unknown {\n if (!text) return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction filterNullishHeaders(\n headers: Record<string, string> | undefined\n): Record<string, string> {\n if (!headers) return {};\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(headers)) {\n // Accept anything that survives the truthy guard; the type is\n // `Record<string, string>` but callers occasionally cast with\n // `as any` to slip nulls through.\n if (v !== null && v !== undefined) out[k] = v;\n }\n return out;\n}\n\nfunction parseRetryAfter(header: string | null): number | undefined {\n if (!header) return undefined;\n const asNumber = Number.parseFloat(header);\n if (Number.isFinite(asNumber)) return asNumber;\n const asDate = Date.parse(header);\n if (Number.isFinite(asDate)) return Math.max(0, (asDate - Date.now()) / 1000);\n return undefined;\n}\n","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ClientResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Health probe\n *\n * 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.\n * @operationId client.health\n * @endpoint GET /v1/health\n */\n async health(options?: RequestOptions): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"GET\",\n path: \"/v1/health\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class CollectionsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create a new collection\n *\n * Create a new collection and automatically add the creating user\n * to it.\n *\n * This endpoint allows authenticated users to create a new collection\n * with a specified name and optional description. The user creating\n * the collection is automatically added as a member.\n * @operationId collections.create\n * @endpoint POST /v1/collections\n */\n async create(\n body: components[\"schemas\"][\"CreateCollectionRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Delete collection\n *\n * Delete an existing collection.\n *\n * This endpoint allows deletion of a collection identified by its\n * UUID. The user must have appropriate permissions to delete the\n * collection. Deleting a collection removes all associations but does\n * not delete the engrams within it.\n * @operationId collections.delete\n * @endpoint DELETE /v1/collections/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * List collections\n *\n * Returns a cursor-paginated list of collections the authenticated\n * user has access to.\n *\n * Results can be filtered by providing specific collection IDs.\n * Regular users will only see collections they own or have access to.\n * Superusers can see all collections.\n *\n * The collections are returned in order of last modification, with\n * most recent first.\n * @operationId collections.list\n * @endpoint GET /v1/collections\n */\n async list(\n params: {\n /** A list of collection IDs to retrieve. If not provided, all collections will be returned. */\n ids?: Array<string>;\n /** Filter collections by name (case-insensitive exact match). */\n name?: string | null;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** If true, only returns collections owned by the user, not all accessible collections. */\n ownerOnly?: boolean;\n /** Filter by workspace ID. Pass a UUID to scope to a workspace, or omit for all. */\n workspaceId?: string | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedCollectionResponse\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections\",\n pathParams: {},\n query: { ids: params.ids, name: params.name, cursor: params.cursor, limit: params.limit, owner_only: params.ownerOnly, workspace_id: params.workspaceId },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Get collection details\n *\n * Get details of a specific collection.\n *\n * This endpoint retrieves detailed information about a single\n * collection identified by its UUID. The user must have access to the\n * collection to view its details.\n * @operationId collections.retrieve\n * @endpoint GET /v1/collections/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Get a collection by name\n *\n * Retrieve a collection by its (owner_id, name) combination.\n *\n * The authenticated user can only fetch collections they own, or, if\n * superuser, from anyone.\n * @operationId collections.retrieveByName\n * @endpoint GET /v1/collections/name/{collection_name}\n */\n async retrieveByName(\n params: {\n /** The name of the collection */\n collectionName: string;\n /** (Superuser only) Specify the owner_id to retrieve a collection by name */\n ownerId?: string | null;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/collections/name/{collection_name}\",\n pathParams: { collection_name: params.collectionName },\n query: { owner_id: params.ownerId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n /**\n * Update collection\n *\n * Update an existing collection's configuration.\n *\n * This endpoint allows updating the name, description, and access settings of an\n * existing collection. The user must have appropriate permissions to\n * modify the collection.\n * @operationId collections.update\n * @endpoint POST /v1/collections/{id}\n */\n async update(\n params: {\n /** The unique identifier of the collection to update */\n id: string;\n body: components[\"schemas\"][\"UpdateCollectionRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CollectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedCollectionResponse\"]>({\n method: \"POST\",\n path: \"/v1/collections/{id}\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CollectionResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class ConnectorsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Start OAuth connection flow\n *\n * 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.\n * @operationId connectors.connect\n * @endpoint POST /v1/connectors/{provider}/connect\n */\n async connect(\n params: {\n provider: string;\n body: components[\"schemas\"][\"ConnectRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{provider}/connect\",\n pathParams: { provider: params.provider },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectResponse\"] };\n return response.results;\n }\n\n /**\n * Disconnect an external data source\n *\n * 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.\n * @operationId connectors.disconnect\n * @endpoint DELETE /v1/connectors/{connection_id}\n */\n async disconnect(\n params: {\n connectionId: string;\n deleteMemories?: boolean;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorDisconnectResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorDisconnectResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: params.connectionId },\n query: { delete_memories: params.deleteMemories },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorDisconnectResponse\"] };\n return response.results;\n }\n\n /**\n * List active connections for a collection\n *\n * 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.\n * @operationId connectors.list\n * @endpoint GET /v1/connectors\n */\n async list(\n params: {\n collectionId: string;\n},\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors\",\n pathParams: {},\n query: { collection_id: params.collectionId },\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"ConnectorConnectionResponse\"]> };\n return response.results;\n }\n\n /**\n * List available connector providers\n *\n * 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.\n * @operationId connectors.listProviders\n * @endpoint GET /v1/connectors/providers\n */\n async listProviders(options?: RequestOptions): Promise<Array<string>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStr\"]>({\n method: \"GET\",\n path: \"/v1/connectors/providers\",\n pathParams: {},\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<string> };\n return response.results;\n }\n\n /**\n * Get a single connection by ID\n *\n * 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.\n * @operationId connectors.retrieve\n * @endpoint GET /v1/connectors/{connection_id}\n */\n async retrieve(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorConnectionResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorConnectionResponse\"]>({\n method: \"GET\",\n path: \"/v1/connectors/{connection_id}\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorConnectionResponse\"] };\n return response.results;\n }\n\n /**\n * Manually trigger a sync\n *\n * 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.\n * @operationId connectors.sync\n * @endpoint POST /v1/connectors/{connection_id}/sync\n */\n async sync(\n connectionId: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"ConnectorSyncResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedConnectorSyncResponse\"]>({\n method: \"POST\",\n path: \"/v1/connectors/{connection_id}/sync\",\n pathParams: { connection_id: connectionId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"ConnectorSyncResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class MemoriesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Append content to an engram\n *\n * Append content to an existing engram.\n *\n * **For conversation engrams:**\n * - Provide `messages` array with content, role, and optional metadata\n * - Works like `/conversations/{id}/messages` endpoint\n *\n * **For document engrams:**\n * - Provide either `raw_text` or `chunks` to append additional content\n * - Content will be processed and added to the engram\n * @operationId memories.append\n * @endpoint POST /v1/memories/{id}/append\n */\n async append(\n params: {\n /** The unique identifier of the engram */\n id: string;\n body: components[\"schemas\"][\"AppendMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/{id}/append\",\n pathParams: { id: params.id },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"AppendMemoryResponse\"] | components[\"schemas\"][\"IngestionResponse\"] };\n return response.results;\n }\n\n /**\n * Create a new memory (conversation or document)\n *\n * Create a new memory (conversation or document) using clean JSON body.\n *\n * - Use `collection_id` (UUID)\n * - `kind` is optional and inferred from payload shape:\n * - If `messages` present -> conversation\n * - Otherwise -> document\n * - For conversations: provide `messages` array\n * - For documents: provide `raw_text` or `chunks`\n * - Use `snapshot` for device-memory mode (mutually exclusive with collection_id)\n * @operationId memories.create\n * @endpoint POST /v1/memories\n */\n async create(\n body: components[\"schemas\"][\"CreateMemoryRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"MemoryCreateResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"MemoryCreateAcceptedResponse\"] | components[\"schemas\"][\"SnapshotMutationResult\"] };\n return response.results;\n }\n\n /**\n * Get presigned URL for large file upload\n *\n * Get a presigned URL for uploading large files directly to S3.\n *\n * Use this for files larger than 5MB that cannot be sent inline as base64.\n * After uploading, reference the file in memory creation using S3FileReference.\n *\n * Args:\n * filename: Original filename (e.g., \"image.jpg\")\n * content_type: MIME type (e.g., \"image/jpeg\", \"application/pdf\")\n * file_size: Expected file size in bytes (max 100MB)\n *\n * Returns:\n * dict with:\n * - upload_url: Presigned URL for PUT request (expires in 1 hour)\n * - upload_headers: Headers that must be sent with the presigned PUT request\n * - s3_key: The S3 key to reference in memory creation\n * - bucket: S3 bucket name\n * - expires_in: Seconds until URL expires\n * - max_size: Maximum allowed file size\n * @operationId memories.createUpload\n * @endpoint POST /v1/memories/upload\n */\n async createUpload(\n params: {\n /** Original filename (e.g., 'image.jpg') */\n filename: string;\n /** MIME type (e.g., 'image/jpeg', 'application/pdf') */\n contentType: string;\n /** Expected file size in bytes (max 100MB) */\n fileSize: number;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PresignedUploadResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedPresignedUploadResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { filename: params.filename, content_type: params.contentType, file_size: params.fileSize },\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"PresignedUploadResponse\"] };\n return response.results;\n }\n\n /**\n * Delete an engram\n *\n * Delete a specific engram with graph awareness. All chunks corresponding to the\n * engram are deleted, and graph components (entities/relationships) are updated\n * or deleted based on remaining chunk references from other engrams.\n *\n * This method now properly handles graph components and maintains graph integrity\n * for search operations.\n * @operationId memories.delete\n * @endpoint DELETE /v1/memories/{id}\n */\n async delete(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericBooleanResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericBooleanResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericBooleanResponse\"] };\n return response.results;\n }\n\n /**\n * Delete one or more engrams\n *\n * Delete one or more engrams.\n *\n * This endpoint efficiently handles both single and batch deletions.\n * When multiple IDs are provided, it uses optimized batch operations.\n *\n * Args:\n * ids: Either a single UUID or a list of UUIDs to delete\n *\n * Returns:\n * For single deletion: boolean success response\n * For batch deletion: detailed results with successful and failed deletions\n * @operationId memories.deleteMany\n * @endpoint POST /v1/memories/delete\n */\n async deleteMany(\n body: components[\"schemas\"][\"DeleteMemoriesRequest\"],\n options?: RequestOptions,\n ): Promise<unknown> {\n return this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/delete\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n });\n }\n\n /**\n * Delete a previously uploaded S3 file\n *\n * Delete a file from S3 that was uploaded via a presigned URL.\n * Verifies the caller owns the file via S3 object metadata.\n * @operationId memories.deleteUpload\n * @endpoint DELETE /v1/memories/upload\n */\n async deleteUpload(\n params: {\n /** S3 key of the file to delete (returned by POST /memories/upload) */\n s3Key: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"GenericMessageResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedGenericMessageResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/memories/upload\",\n pathParams: {},\n query: { s3_key: params.s3Key },\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"GenericMessageResponse\"] };\n return response.results;\n }\n\n /**\n * List engrams\n *\n * Returns a cursor-paginated list of engrams the authenticated user\n * has access to.\n *\n * Results can be filtered by providing specific engram IDs or collection IDs.\n * Regular users will only see engrams they own or have access to through\n * collections. Superusers can see all engrams.\n *\n * The engrams are returned in order of creation time, most recent\n * first. The response includes the engram's text field if available.\n * @operationId memories.list\n * @endpoint GET /v1/memories\n */\n async list(\n params: {\n /** A list of engram IDs to retrieve. If not provided, all engrams will be returned. */\n ids?: Array<string>;\n /** Opaque pagination cursor. Pass the ``next_cursor`` from a previous response to fetch the next page. */\n cursor?: string | null;\n /** Specifies a limit on the number of objects to return, ranging between 1 and 1000. Defaults to 100. */\n limit?: number;\n /** Maximum chunks to inline per engram. Defaults to all chunks for backwards compatibility; pass 0 to skip chunk hydration. */\n chunksLimit?: number | null;\n /** If true, only returns engrams owned by the user, not all accessible engrams. */\n ownerOnly?: boolean;\n /** Optional list of collection IDs to filter engrams by. If provided, exactly one collection ID must be specified. */\n collectionIds?: Array<string> | null;\n /** JSON string for metadata filtering. Example: '{\"metadata.source\": {\"$eq\": \"playground\"}}' */\n metadataFilters?: string | null;\n /** Read-your-writes assertion: the WAL-tail overlay path waits for at least this seq to be applied before serving (or returns 503 Unavailable on timeout). REQUIRES exactly one collection_ids entry — without a collection scope the request returns 422 (the per-WAL-shard scalar applied_wal_seq is meaningless across collections). When the served shard has not been migrated to wal_compaction_enabled, the field is accepted but the served path is the legacy overlay (the assertion has no effect — the response's applied_wal_seq will be 0). Pass back the value the matching upload response surfaced. */\n minAppliedWalSeq?: number | null;\n} = {},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"PaginatedListedEngram\"]> {\n return this.core.request<components[\"schemas\"][\"PaginatedListedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories\",\n pathParams: {},\n query: { ids: params.ids, cursor: params.cursor, limit: params.limit, chunks_limit: params.chunksLimit, owner_only: params.ownerOnly, collection_ids: params.collectionIds, metadata_filters: params.metadataFilters, min_applied_wal_seq: params.minAppliedWalSeq },\n idempotent: true,\n signal: options?.signal,\n });\n }\n\n /**\n * Recall workflow patterns by intent\n *\n * Workflow-pattern recall over 5 intents.\n *\n * * ``cursor`` -- match the caller's anchor against pattern\n * canonical states, return ranked patterns + position.\n * * ``predict`` -- like cursor but include the predicted next\n * trace from each pattern's canonical instance.\n * * ``resume`` -- like cursor, biased toward longer patterns.\n * * ``evidence`` -- expand a specific pattern via\n * ``hydrate_pattern``.\n * * ``bootstrap`` -- top-K patterns by confidence with no anchor.\n * @operationId memories.recallWorkflow\n * @endpoint POST /v1/memories/workflow/recall\n */\n async recallWorkflow(\n body: components[\"schemas\"][\"CursorRecallRequest\"] | components[\"schemas\"][\"PredictRecallRequest\"] | components[\"schemas\"][\"ResumeRecallRequest\"] | components[\"schemas\"][\"EvidenceRecallRequest\"] | components[\"schemas\"][\"BootstrapRecallRequest\"],\n options?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n const response = (await this.core.request<components[\"schemas\"][\"WorkflowRecallResponse\"]>({\n method: \"POST\",\n path: \"/v1/memories/workflow/recall\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: Record<string, unknown> };\n return response.results;\n }\n\n /**\n * Retrieve an engram\n *\n * Retrieves detailed information about a specific engram by its\n * ID.\n *\n * This endpoint returns the engram's metadata, status, and system information. It does not\n * return the engram's content - use the `/engrams/{id}/download` endpoint for that.\n *\n * Users can only retrieve engrams they own or have access to through collections.\n * Superusers can retrieve any engram.\n * @operationId memories.retrieve\n * @endpoint GET /v1/memories/{id}\n */\n async retrieve(\n id: string,\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"GET\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: id },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n /**\n * Search memories\n *\n * Perform a search query across your memories.\n *\n * **Standard mode** (collection_ids or readable-scope search): returns hierarchical MemoryRecall\n * with semantics, episodes, procedures, and sources.\n *\n * **Snapshot mode** (snapshot field): returns graph-search results with\n * {entities, relationships} from stateless in-memory traversal.\n * @operationId memories.search\n * @endpoint POST /v1/memories/search\n */\n async search(\n body: components[\"schemas\"][\"MemorySearchRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"]> {\n const response = (await this.core.request<unknown>({\n method: \"POST\",\n path: \"/v1/memories/search\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"CompactMemoryRecallResponse\"] | components[\"schemas\"][\"MemoryRecall\"] | components[\"schemas\"][\"SnapshotSearchResult\"] };\n return response.results;\n }\n\n /**\n * Update a memory\n *\n * Update memory-level properties including name, metadata, and collection associations.\n *\n * This endpoint allows updating properties of an entire memory (document or conversation)\n * without modifying its content:\n * - **name**: Updates the authoritative engram title\n * - **metadata**: Can replace or merge with existing metadata\n * - **collection_ids**: Updates authoritative engram collection associations\n *\n * Users can only update memories they own or have access to through collections.\n * At least one collection association must be maintained.\n *\n * If collection_id is provided and the engram is shared across collections, a copy-on-write\n * will be performed to create a collection-specific copy before modification.\n * @operationId memories.update\n * @endpoint PATCH /v1/memories/{id}\n */\n async update(\n params: {\n /** The unique identifier of the memory */\n id: string;\n /** Collection context for copy-on-write. If provided and engram is shared, creates a copy before modification. */\n collectionId?: string | null;\n body: components[\"schemas\"][\"UpdateMemoryRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"Engram\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedEngram\"]>({\n method: \"PATCH\",\n path: \"/v1/memories/{id}\",\n pathParams: { id: params.id },\n query: { collection_id: params.collectionId },\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"Engram\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class SnapshotsResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Export a collection snapshot\n *\n * Export a collection's full graph state as a\n * portable SnapshotEnvelope.\n * @operationId snapshots.export\n * @endpoint POST /v1/device-memory/snapshot/export\n */\n async export(\n body: components[\"schemas\"][\"SnapshotExportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotEnvelopeOrSnapshotObjectReference\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/export\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: true,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotEnvelope-Output\"] | components[\"schemas\"][\"SnapshotObjectReference\"] };\n return response.results;\n }\n\n /**\n * Import a snapshot into an ephemeral collection\n *\n * Import a SnapshotEnvelope into an ephemeral\n * collection. Returns the ephemeral collection UUID.\n * @operationId snapshots.import\n * @endpoint POST /v1/device-memory/snapshot/import\n */\n async import(\n body: components[\"schemas\"][\"SnapshotImportRequest\"],\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"SnapshotImportResult\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedSnapshotImportResult\"]>({\n method: \"POST\",\n path: \"/v1/device-memory/snapshot/import\",\n pathParams: {},\n query: undefined,\n body: body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"SnapshotImportResult\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport type { components } from \"../types.ts\";\nimport type { NebulaCore, RequestOptions } from \"../runtime/client.ts\";\n\nexport class WorkspacesResource {\n constructor(private readonly core: NebulaCore) {}\n\n /**\n * Create workspace storage target\n *\n * Register a customer S3 bucket for hosted BYOC storage.\n * @operationId workspaces.createStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets\n */\n async createStorageTarget(\n params: {\n workspaceId: string;\n body: components[\"schemas\"][\"StorageTargetCreateRequest\"];\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: params.workspaceId },\n query: undefined,\n body: params.body,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * Disable workspace storage target\n *\n * Disable a customer storage target for future collection binds.\n * @operationId workspaces.disableStorageTarget\n * @endpoint DELETE /v1/workspaces/{workspace_id}/storage-targets/{target_id}\n */\n async disableStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"DELETE\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n /**\n * List workspace storage targets\n *\n * List customer-owned object storage targets for a workspace.\n * @operationId workspaces.listStorageTargets\n * @endpoint GET /v1/workspaces/{workspace_id}/storage-targets\n */\n async listStorageTargets(\n workspaceId: string,\n options?: RequestOptions,\n ): Promise<Array<components[\"schemas\"][\"StorageTargetResponse\"]>> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedListOfStorageTargetResponse\"]>({\n method: \"GET\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets\",\n pathParams: { workspace_id: workspaceId },\n query: undefined,\n idempotent: true,\n signal: options?.signal,\n })) as { results: Array<components[\"schemas\"][\"StorageTargetResponse\"]> };\n return response.results;\n }\n\n /**\n * Validate workspace storage target\n *\n * Probe a customer storage target and mark it active on success.\n * @operationId workspaces.validateStorageTarget\n * @endpoint POST /v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\n */\n async validateStorageTarget(\n params: {\n workspaceId: string;\n targetId: string;\n},\n options?: RequestOptions,\n ): Promise<components[\"schemas\"][\"StorageTargetResponse\"]> {\n const response = (await this.core.request<components[\"schemas\"][\"WrappedStorageTargetResponse\"]>({\n method: \"POST\",\n path: \"/v1/workspaces/{workspace_id}/storage-targets/{target_id}/validate\",\n pathParams: { workspace_id: params.workspaceId, target_id: params.targetId },\n query: undefined,\n idempotent: false,\n signal: options?.signal,\n })) as { results: components[\"schemas\"][\"StorageTargetResponse\"] };\n return response.results;\n }\n\n}","// AUTOGENERATED by nebula-sdks/generator. Do not edit by hand.\n// Source: nebula-sdks/openapi/openapi.json\n\nimport { NebulaCore, type ClientOptions } from \"./runtime/client.ts\";\nimport { ClientResource } from \"./resources/client.ts\";\nimport { CollectionsResource } from \"./resources/collections.ts\";\nimport { ConnectorsResource } from \"./resources/connectors.ts\";\nimport { MemoriesResource } from \"./resources/memories.ts\";\nimport { SnapshotsResource } from \"./resources/snapshots.ts\";\nimport { WorkspacesResource } from \"./resources/workspaces.ts\";\n\nexport class NebulaClient {\n protected readonly core: NebulaCore;\n readonly client: ClientResource;\n readonly collections: CollectionsResource;\n readonly connectors: ConnectorsResource;\n readonly memories: MemoriesResource;\n readonly snapshots: SnapshotsResource;\n readonly workspaces: WorkspacesResource;\n\n constructor(options: ClientOptions = {}) {\n this.core = new NebulaCore(options);\n this.client = new ClientResource(this.core);\n this.collections = new CollectionsResource(this.core);\n this.connectors = new ConnectorsResource(this.core);\n this.memories = new MemoriesResource(this.core);\n this.snapshots = new SnapshotsResource(this.core);\n this.workspaces = new WorkspacesResource(this.core);\n }\n}","// Handwritten Nebula DX layer.\n//\n// Carries only the methods that need real dispatch logic: storeMemory's\n// create-vs-append branch, bulk storeMemories with a concurrency cap,\n// positional connector helpers (connectProvider/listConnections/\n// disconnectConnection), and auth normalization.\n//\n// For everything else, use the resource methods directly. Resource\n// methods now return unwrapped values natively (the generator peels\n// the `{results: X}` wire envelope), so there's no separate auto-\n// generated unwrap layer to extend.\n//\n// Source of truth: nebula-sdks/custom/typescript/dx.ts\n// The generator copies this file into sdks/typescript/src/lib/dx.ts on every\n// `pnpm --dir nebula-sdks/generator run generate`. Edit the source, not the copy.\n\nimport { NebulaClient } from \"../client.ts\";\nimport {\n type ClientOptions,\n type components,\n} from \"../index.ts\";\n\ntype Schemas = components[\"schemas\"];\ntype SnapshotEnvelopeInput = Schemas[\"SnapshotEnvelope-Input\"];\ntype SnapshotEnvelopeOutput = Schemas[\"SnapshotEnvelope-Output\"];\n\nexport type CompatClientOptions = ClientOptions & {\n apiKey?: string | null;\n baseUrl?: string | null;\n // Legacy capital-U alias. Some internal callers, including the\n // local playground WebSocket server, still pass `baseURL`; without this\n // alias the value falls through unused and the runtime defaults to\n // api.zeroset.com.\n baseURL?: string | null;\n // Legacy alias for `timeoutMs`. Same compat reason.\n timeout?: number | null;\n};\n\nexport interface MemoryCommonInput {\n collection_id?: string | null;\n collectionId?: string | null;\n content?: string | string[] | unknown[] | null;\n raw_text?: string | null;\n chunks?: Array<string> | null;\n messages?: unknown[] | null;\n metadata?: { [key: string]: unknown } | null;\n ingestion_config?: unknown;\n ingestion_mode?: string | null;\n}\n\nexport interface MemoryCreateInput extends MemoryCommonInput {\n kind?: Schemas[\"EngramKind\"] | null;\n name?: string | null;\n speaker_id?: string | null;\n speaker_name?: string | null;\n content_parts?: unknown[] | null;\n contents?: string[] | null;\n snapshot?: SnapshotEnvelopeInput | null;\n memory_id?: undefined | null;\n}\n\nexport interface MemoryAppendInput extends Omit<MemoryCommonInput, \"ingestion_mode\" | \"messages\"> {\n memory_id: string;\n ingestion_mode?: string | null;\n messages?: unknown[] | null;\n}\n\nexport type MemoryInput = MemoryCreateInput | MemoryAppendInput;\n\ntype MemoryCreateBody = Schemas[\"CreateMemoryRequest\"];\ntype MemoryAppendBody = Schemas[\"AppendMemoryRequest\"];\n\nexport class Nebula extends NebulaClient {\n constructor(options: CompatClientOptions = {}) {\n super(normalizeClientOptions(options));\n }\n\n /**\n * Polymorphic memory creator: dispatches to memories.create or memories.append\n * based on whether `memory_id` is set on the input. Returns the new memory's\n * id (string), or — when `snapshot` is set — the updated snapshot envelope.\n */\n async storeMemory(\n memory: MemoryInput,\n options?: { signal?: AbortSignal }\n ): Promise<string | SnapshotEnvelopeOutput> {\n if (\"memory_id\" in memory && memory.memory_id != null) {\n const memoryID = memory.memory_id;\n await this.memories.append(\n { id: memoryID, body: toMemoryAppendParams(memory) },\n options\n );\n return memoryID;\n }\n // `memories.create` now returns the unwrapped inner type directly\n // (the generator peels the wire `{results: X}` envelope).\n const result = await this.memories.create(\n toMemoryCreateParams(memory as MemoryCreateInput),\n options\n );\n if (isSnapshotResult(result)) {\n return (result.snapshot ?? result) as SnapshotEnvelopeOutput;\n }\n return extractID(result);\n }\n\n /**\n * Bulk parallel version of storeMemory with a concurrency cap.\n *\n * Default 8 concurrent in-flight requests matches the Python DX's\n * `asyncio.Semaphore(max_concurrency)` pattern. Use `maxConcurrency: 1`\n * for strictly serial submission; higher values risk overwhelming the\n * server when memories[] is large.\n */\n async storeMemories(\n memories: MemoryInput[],\n options?: { signal?: AbortSignal; maxConcurrency?: number }\n ): Promise<(string | SnapshotEnvelopeOutput)[]> {\n const cap = Math.max(1, options?.maxConcurrency ?? 8);\n const signal = options?.signal;\n const results: (string | SnapshotEnvelopeOutput)[] = new Array(memories.length);\n let nextIndex = 0;\n const worker = async (): Promise<void> => {\n while (true) {\n const i = nextIndex++;\n if (i >= memories.length) return;\n results[i] = await this.storeMemory(memories[i], { signal });\n }\n };\n await Promise.all(\n Array.from({ length: Math.min(cap, memories.length) }, () => worker())\n );\n return results;\n }\n\n /**\n * List memories scoped to one or more collection ids (string | string[])\n * or a full MemoryListParams object.\n */\n async listMemories(\n query: string | string[] | Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const normalized: Record<string, unknown> =\n typeof query === \"string\" || Array.isArray(query)\n ? { collectionIds: arrayify(query) }\n : query;\n return this.memories.list(normalized as never, options);\n }\n\n /**\n * Positional `connectProvider(provider, collectionID, config?)` — wraps the\n * generated `connectors.connect({provider, body})` to build the body shape.\n */\n async connectProvider(\n provider: string,\n collectionID: string,\n config?: Record<string, unknown>,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n const body: Schemas[\"ConnectRequest\"] = {\n collection_id: collectionID,\n ...(config !== undefined ? { config } : {}),\n } as Schemas[\"ConnectRequest\"];\n return this.connectors.connect({ provider, body }, options);\n }\n\n /** Positional listConnections(collectionID) — wraps the query wrapper. */\n async listConnections(\n collectionID: string,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.list({ collectionId: collectionID } as never, options);\n }\n\n /** Positional disconnect(connectionID, deleteMemories?). */\n async disconnectConnection(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n /** Alias for disconnectConnection (same arg shape). */\n async disconnect(\n connectionID: string,\n deleteMemories = false,\n options?: { signal?: AbortSignal }\n ): Promise<unknown> {\n return this.connectors.disconnect(\n { connectionId: connectionID, deleteMemories } as never,\n options\n );\n }\n\n}\n\n// ---------- helpers ----------\n\nfunction normalizeClientOptions(options: CompatClientOptions): ClientOptions {\n const {\n apiKey,\n baseUrl: baseUrlAlias,\n baseURL: baseURLCapAlias,\n timeout: timeoutAlias,\n ...rest\n } = options;\n const restClientOptions: ClientOptions = rest;\n return {\n ...restClientOptions,\n apiKey: apiKey ?? undefined,\n baseUrl:\n firstDefined(restClientOptions.baseUrl, baseUrlAlias, baseURLCapAlias) ?? undefined,\n timeoutMs:\n firstDefined(restClientOptions.timeoutMs, timeoutAlias) ?? undefined,\n };\n}\n\nfunction firstDefined<T>(...values: (T | null | undefined)[]): T | null | undefined {\n return values.find((value) => value !== undefined);\n}\n\nfunction toMemoryCreateParams(memory: MemoryCreateInput): MemoryCreateBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n const { collectionId: _ignore, content, memory_id: _ignoreMemoryID, ...rest } = memory;\n const params: Record<string, unknown> = { ...rest };\n\n if (collectionID !== undefined) {\n params.collection_id = collectionID;\n }\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else {\n params.content_parts = content;\n }\n }\n if (params.messages != null && !params.kind) {\n params.kind = \"conversation\";\n }\n return params as MemoryCreateBody;\n}\n\nfunction toMemoryAppendParams(memory: MemoryAppendInput): MemoryAppendBody {\n const collectionID = memory.collection_id ?? memory.collectionId ?? undefined;\n if (!collectionID) {\n throw new Error(\"collection_id is required when appending to an existing memory\");\n }\n const params: Record<string, unknown> = { collection_id: collectionID };\n for (const key of [\"metadata\", \"ingestion_config\", \"ingestion_mode\", \"raw_text\", \"chunks\", \"messages\"] as const) {\n const value = memory[key as keyof MemoryAppendInput];\n if (value != null) params[key] = value;\n }\n const content = (memory as MemoryCommonInput).content;\n if (content != null) {\n if (typeof content === \"string\") {\n params.raw_text = content;\n } else if (Array.isArray(content) && content.every((item) => typeof item === \"string\")) {\n params.chunks = content;\n } else if (Array.isArray(content)) {\n params.messages = content;\n }\n }\n return params as MemoryAppendBody;\n}\n\nfunction extractID(value: unknown): string {\n if (typeof value === \"object\" && value !== null) {\n const record = value as Record<string, unknown>;\n const id =\n record[\"id\"] ?? record[\"memory_id\"] ?? record[\"engram_id\"] ?? record[\"ephemeral_collection_id\"];\n if (typeof id === \"string\") return id;\n }\n throw new Error(\"Nebula memory create response did not include an id\");\n}\n\nfunction isSnapshotResult(value: unknown): value is { snapshot?: SnapshotEnvelopeOutput } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"snapshot\" in (value as Record<string, unknown>)\n );\n}\n\nfunction arrayify(value: string | string[]): string[] {\n return Array.isArray(value) ? value : [value];\n}\n"],"mappings":";AAAA,IAAa,cAAb,cAAiC,MAAM;CACrC,OAAiC;CACjC,YAAY,SAAiB,SAA+B;EAC1D,MAAM,SAAS,OAAO;CACxB;AACF;AAEA,IAAa,wBAAb,cAA2C,YAAY;CACrD,OAAyB;AAC3B;AAEA,IAAa,qBAAb,cAAwC,YAAY;CAClD,OAAyB;AAC3B;AA6BA,SAAS,WAAW,MAAsC;CACxD,OACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA4B,SAAS,YAC7C,OAAQ,KAA+B,YAAY;AAEvD;AAEA,IAAa,iBAAb,cAAoC,YAAY;CAC9C,OAAiC;CACjC;CACA;CACA;CAKA;CACA;CACA;CAEA,YAAY,SAA0B,SAAkB;EACtD,MAAM,WAAW,WAAW,QAAQ,IAAI,IAAI,QAAQ,OAAO,KAAA;EAC3D,MACE,WACE,UAAU,WACV,4BAA4B,QAAQ,OAAO,EAC/C;EACA,KAAK,SAAS,QAAQ;EAGtB,MAAM,UACJ,OAAO,UAAU,SAAS,WAAW,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ACf,MAAM,KACJ,OAAO,SAAS,OAAO,gBAAgB,OAAO,gBAAgB,OAAO;EACvE,IAAI,OAAO,OAAO,UAAU,OAAO;CACrC;CACA,MAAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,iBAAiB,OAAgE;CACxF,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAe;AAEnB;AAEA,SAAS,SAAS,OAAoC;CACpD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula-ai/sdk",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Official Nebula SDK for TypeScript (autogenerated).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/zeroset-inc/nebula-typescript",
@@ -42,8 +42,8 @@
42
42
  "build": "tsdown src/index.ts --format esm,cjs --dts --sourcemap --clean --out-dir dist --platform neutral --target es2022",
43
43
  "type-check": "tsc --noEmit",
44
44
  "test": "bun test",
45
- "prepare": "bun run build",
46
- "prepack": "bun run build"
45
+ "prepare": "tsdown src/index.ts --format esm,cjs --dts --sourcemap --clean --out-dir dist --platform neutral --target es2022",
46
+ "prepack": "tsdown src/index.ts --format esm,cjs --dts --sourcemap --clean --out-dir dist --platform neutral --target es2022"
47
47
  },
48
48
  "devDependencies": {
49
49
  "typescript": "^5.6.0",