runbios-sdk 0.2.3 → 0.2.4-dev.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -220,10 +220,18 @@ export declare class HttpClient {
220
220
  private readonly accessToken;
221
221
  private readonly orgId;
222
222
  private readonly workspaceIdValue;
223
+ private resolvedWorkspaceIdValue;
223
224
  private readonly timeout;
224
225
  constructor(config: BiOSConfig);
225
226
  /** Workspace configured on the client, used by multipart/control-plane helpers. */
226
227
  get workspaceId(): string | undefined;
228
+ /** Resolve and cache the workspace bound to an API key.
229
+ *
230
+ * Multipart dataset endpoints require workspace_id in their body. API keys
231
+ * already have one authoritative workspace binding, so callers must not have
232
+ * to duplicate or choose it merely because this request is multipart.
233
+ */
234
+ resolveWorkspaceId(): Promise<string>;
227
235
  private buildHeaders;
228
236
  /**
229
237
  * Send a JSON request and parse the response.
package/dist/client.js CHANGED
@@ -335,11 +335,12 @@ export class HttpClient {
335
335
  accessToken;
336
336
  orgId;
337
337
  workspaceIdValue;
338
+ resolvedWorkspaceIdValue;
338
339
  timeout;
339
340
  constructor(config) {
340
341
  // Default host stays api.runbios.ai for now; cutover to api.runbios.ai is
341
342
  // planned once its DNS exists.
342
- this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api.runbios.ai').replace(/\/+$/, '');
343
+ this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api-dev.runbios.ai').replace(/\/+$/, '');
343
344
  this.apiKey = config.apiKey ?? envApiKey();
344
345
  this.accessToken = config.accessToken;
345
346
  this.orgId = config.orgId;
@@ -351,7 +352,24 @@ export class HttpClient {
351
352
  }
352
353
  /** Workspace configured on the client, used by multipart/control-plane helpers. */
353
354
  get workspaceId() {
354
- return this.workspaceIdValue;
355
+ return this.workspaceIdValue ?? this.resolvedWorkspaceIdValue;
356
+ }
357
+ /** Resolve and cache the workspace bound to an API key.
358
+ *
359
+ * Multipart dataset endpoints require workspace_id in their body. API keys
360
+ * already have one authoritative workspace binding, so callers must not have
361
+ * to duplicate or choose it merely because this request is multipart.
362
+ */
363
+ async resolveWorkspaceId() {
364
+ if (this.workspaceId)
365
+ return this.workspaceId;
366
+ const data = await this.fetchGet('/api/api-keys/introspect');
367
+ const id = data.workspace?.id;
368
+ if (typeof id !== 'string' || !id.trim()) {
369
+ throw new Error('RunBiOS: the API key is not bound to a workspace; dataset operations require a workspace-bound key');
370
+ }
371
+ this.resolvedWorkspaceIdValue = id.trim();
372
+ return this.resolvedWorkspaceIdValue;
355
373
  }
356
374
  // --------------------------------------------------------------------------
357
375
  // Internal helpers
@@ -369,8 +387,8 @@ export class HttpClient {
369
387
  }
370
388
  if (this.orgId)
371
389
  h['X-Org-ID'] = this.orgId;
372
- if (this.workspaceIdValue)
373
- h['X-Workspace-ID'] = this.workspaceIdValue;
390
+ if (this.workspaceId)
391
+ h['X-Workspace-ID'] = this.workspaceId;
374
392
  return h;
375
393
  }
376
394
  // --------------------------------------------------------------------------
package/dist/index.d.ts CHANGED
@@ -36,7 +36,7 @@ import { Loop } from './resources/loop.js';
36
36
  * SDK version. Sent as part of the User-Agent header.
37
37
  * Must match package.json "version" -- enforced by a contract test.
38
38
  */
39
- export declare const VERSION = "0.2.3";
39
+ export declare const VERSION = "0.2.4-dev.182";
40
40
  export declare class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  readonly models: Models;
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import { Loop } from './resources/loop.js';
36
36
  * SDK version. Sent as part of the User-Agent header.
37
37
  * Must match package.json "version" -- enforced by a contract test.
38
38
  */
39
- export const VERSION = '0.2.3';
39
+ export const VERSION = '0.2.4-dev.182';
40
40
  export class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  models;
@@ -123,10 +123,7 @@ export class Datasets {
123
123
  formData.append('name', params.name);
124
124
  if (params.description)
125
125
  formData.append('description', params.description);
126
- const workspaceId = params.workspaceId || this._http.workspaceId;
127
- if (!workspaceId) {
128
- throw new Error('RunBiOS: workspaceId is required for dataset uploads');
129
- }
126
+ const workspaceId = params.workspaceId || this._http.workspaceId || await this._http.resolveWorkspaceId();
130
127
  formData.append('workspace_id', workspaceId);
131
128
  if (params.format)
132
129
  formData.append('format', params.format);
@@ -229,10 +226,9 @@ export class Datasets {
229
226
  const repoId = String(raw.repoId || raw.hf_dataset_id || raw.repo_id || '');
230
227
  if (!repoId)
231
228
  throw new Error('RunBiOS: repoId is required');
232
- const workspaceId = String(raw.workspaceId || raw.workspace_id || '') || this._http.workspaceId;
233
- if (!workspaceId) {
234
- throw new Error('RunBiOS: workspaceId is required to register a HuggingFace dataset');
235
- }
229
+ const workspaceId = String(raw.workspaceId || raw.workspace_id || '')
230
+ || this._http.workspaceId
231
+ || await this._http.resolveWorkspaceId();
236
232
  const result = await this._http.fetchPost('/api/datasets/register-hf', {
237
233
  hf_dataset_id: repoId,
238
234
  name: raw.name || repoId.split('/').pop() || repoId,
@@ -326,7 +326,7 @@ export class Inference {
326
326
  this.key = config.inferenceKey || envInferenceKey() || envApiKey();
327
327
  // Same default host as HttpClient (api.runbios.ai); api.runbios.ai cutover
328
328
  // is planned once its DNS exists — update both call sites together.
329
- this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api.runbios.ai').replace(/\/+$/, '');
329
+ this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api-dev.runbios.ai').replace(/\/+$/, '');
330
330
  this.timeout = config.timeout ?? 900_000;
331
331
  this._http = http;
332
332
  }
package/dist/types.d.ts CHANGED
@@ -8,13 +8,13 @@ export interface BiOSConfig {
8
8
  orgId?: string;
9
9
  /** Workspace ID. Optional when using API keys (resolved from the key). Can override for multi-workspace keys. */
10
10
  workspaceId?: string;
11
- /** Base URL for the API. Falls back to the RUNBIOS_BASE_URL environment variable (legacy: BIOS_BASE_URL), then the canonical https://api.runbios.ai hostname. */
11
+ /** Base URL for the API. Falls back to the RUNBIOS_BASE_URL environment variable (legacy: BIOS_BASE_URL), then the canonical https://api-dev.runbios.ai hostname. */
12
12
  baseUrl?: string;
13
13
  /** Request timeout in milliseconds. Defaults to 30000. */
14
14
  timeout?: number;
15
15
  /** Default per-deployment inference key. Can be overridden per inference call. */
16
16
  inferenceKey?: string;
17
- /** Inference base URL. Defaults to baseUrl, then https://api.runbios.ai. */
17
+ /** Inference base URL. Defaults to baseUrl, then https://api-dev.runbios.ai. */
18
18
  inferenceBaseUrl?: string;
19
19
  /** End-to-end inference timeout in milliseconds. Defaults to 15 minutes. */
20
20
  inferenceTimeout?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runbios-sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.4-dev.182",
4
4
  "description": "Official TypeScript SDK for the Run BiOS training and deployment platform API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",