runbios-sdk 0.2.3-dev.179 → 0.2.3-dev.180

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,6 +335,7 @@ 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
@@ -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-dev.179";
39
+ export declare const VERSION = "0.2.3-dev.180";
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-dev.179';
39
+ export const VERSION = '0.2.3-dev.180';
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runbios-sdk",
3
- "version": "0.2.3-dev.179",
3
+ "version": "0.2.3-dev.180",
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",