@blaxel/core 0.2.31 → 0.2.32-dev.183

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.
@@ -1,5 +1,5 @@
1
1
  import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
2
- import type { ListAgentsData, CreateAgentData, DeleteAgentData, GetAgentData, UpdateAgentData, ListAgentRevisionsData, GetConfigurationData, ListCustomDomainsData, CreateCustomDomainData, DeleteCustomDomainData, GetCustomDomainData, UpdateCustomDomainData, VerifyCustomDomainData, ListFunctionsData, CreateFunctionData, DeleteFunctionData, GetFunctionData, UpdateFunctionData, ListFunctionRevisionsData, GetIntegrationData, ListIntegrationConnectionsData, CreateIntegrationConnectionData, DeleteIntegrationConnectionData, GetIntegrationConnectionData, UpdateIntegrationConnectionData, GetIntegrationConnectionModelEndpointConfigurationsData, ListIntegrationConnectionModelsData, GetIntegrationConnectionModelData, ListJobsData, CreateJobData, DeleteJobData, GetJobData, UpdateJobData, ListJobRevisionsData, ListLocationsData, ListMcpHubDefinitionsData, ListModelsData, CreateModelData, DeleteModelData, GetModelData, UpdateModelData, ListModelRevisionsData, ListPoliciesData, CreatePolicyData, DeletePolicyData, GetPolicyData, UpdatePolicyData, ListPrivateClustersData, CreatePrivateClusterData, DeletePrivateClusterData, GetPrivateClusterData, UpdatePrivateClusterData, GetPrivateClusterHealthData, UpdatePrivateClusterHealthData, ListAllPendingInvitationsData, ListPublicIpsData, ListSandboxHubDefinitionsData, ListSandboxesData, CreateSandboxData, DeleteSandboxData, GetSandboxData, UpdateSandboxData, ListSandboxPreviewsData, CreateSandboxPreviewData, DeleteSandboxPreviewData, GetSandboxPreviewData, UpdateSandboxPreviewData, ListSandboxPreviewTokensData, CreateSandboxPreviewTokenData, DeleteSandboxPreviewTokenData, StartSandboxData, StopSandboxData, GetWorkspaceServiceAccountsData, CreateWorkspaceServiceAccountData, DeleteWorkspaceServiceAccountData, UpdateWorkspaceServiceAccountData, ListApiKeysForServiceAccountData, CreateApiKeyForServiceAccountData, DeleteApiKeyForServiceAccountData, ListTemplatesData, GetTemplateData, ListWorkspaceUsersData, InviteWorkspaceUserData, RemoveWorkspaceUserData, UpdateWorkspaceUserRoleData, ListWorkspacesData, CreateWorspaceData, DeleteWorkspaceData, GetWorkspaceData, UpdateWorkspaceData, DeclineWorkspaceInvitationData, AcceptWorkspaceInvitationData, LeaveWorkspaceData, CheckWorkspaceAvailabilityData } from './types.gen.js';
2
+ import type { ListAgentsData, CreateAgentData, DeleteAgentData, GetAgentData, UpdateAgentData, ListAgentRevisionsData, GetConfigurationData, ListCustomDomainsData, CreateCustomDomainData, DeleteCustomDomainData, GetCustomDomainData, UpdateCustomDomainData, VerifyCustomDomainData, ListFunctionsData, CreateFunctionData, DeleteFunctionData, GetFunctionData, UpdateFunctionData, ListFunctionRevisionsData, GetIntegrationData, ListIntegrationConnectionsData, CreateIntegrationConnectionData, DeleteIntegrationConnectionData, GetIntegrationConnectionData, UpdateIntegrationConnectionData, GetIntegrationConnectionModelEndpointConfigurationsData, ListIntegrationConnectionModelsData, GetIntegrationConnectionModelData, ListJobsData, CreateJobData, DeleteJobData, GetJobData, UpdateJobData, ListJobRevisionsData, ListLocationsData, ListMcpHubDefinitionsData, ListModelsData, CreateModelData, DeleteModelData, GetModelData, UpdateModelData, ListModelRevisionsData, ListPoliciesData, CreatePolicyData, DeletePolicyData, GetPolicyData, UpdatePolicyData, ListPrivateClustersData, CreatePrivateClusterData, DeletePrivateClusterData, GetPrivateClusterData, UpdatePrivateClusterData, GetPrivateClusterHealthData, UpdatePrivateClusterHealthData, ListAllPendingInvitationsData, ListPublicIpsData, ListSandboxHubDefinitionsData, ListSandboxesData, CreateSandboxData, DeleteSandboxData, GetSandboxData, UpdateSandboxData, ListSandboxPreviewsData, CreateSandboxPreviewData, DeleteSandboxPreviewData, GetSandboxPreviewData, UpdateSandboxPreviewData, ListSandboxPreviewTokensData, CreateSandboxPreviewTokenData, DeleteSandboxPreviewTokenData, StartSandboxData, StopSandboxData, GetWorkspaceServiceAccountsData, CreateWorkspaceServiceAccountData, DeleteWorkspaceServiceAccountData, UpdateWorkspaceServiceAccountData, ListApiKeysForServiceAccountData, CreateApiKeyForServiceAccountData, DeleteApiKeyForServiceAccountData, ListTemplatesData, GetTemplateData, ListWorkspaceUsersData, InviteWorkspaceUserData, RemoveWorkspaceUserData, UpdateWorkspaceUserRoleData, ListVolumesData, CreateVolumeData, DeleteVolumeData, GetVolumeData, UpdateVolumeData, ListWorkspacesData, CreateWorspaceData, DeleteWorkspaceData, GetWorkspaceData, UpdateWorkspaceData, DeclineWorkspaceInvitationData, AcceptWorkspaceInvitationData, LeaveWorkspaceData, CheckWorkspaceAvailabilityData } from './types.gen.js';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -432,6 +432,31 @@ export declare const removeWorkspaceUser: <ThrowOnError extends boolean = false>
432
432
  * Updates the role of a user in the workspace.
433
433
  */
434
434
  export declare const updateWorkspaceUserRole: <ThrowOnError extends boolean = false>(options: Options<UpdateWorkspaceUserRoleData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").WorkspaceUser, unknown, ThrowOnError>;
435
+ /**
436
+ * List volumes
437
+ * Returns a list of all volumes in the workspace.
438
+ */
439
+ export declare const listVolumes: <ThrowOnError extends boolean = false>(options?: Options<ListVolumesData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Volume[], unknown, ThrowOnError>;
440
+ /**
441
+ * Create volume
442
+ * Creates a volume.
443
+ */
444
+ export declare const createVolume: <ThrowOnError extends boolean = false>(options: Options<CreateVolumeData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Volume, unknown, ThrowOnError>;
445
+ /**
446
+ * Delete volume
447
+ * Deletes a volume by name.
448
+ */
449
+ export declare const deleteVolume: <ThrowOnError extends boolean = false>(options: Options<DeleteVolumeData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Volume, unknown, ThrowOnError>;
450
+ /**
451
+ * Get volume
452
+ * Returns a volume by name.
453
+ */
454
+ export declare const getVolume: <ThrowOnError extends boolean = false>(options: Options<GetVolumeData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Volume, unknown, ThrowOnError>;
455
+ /**
456
+ * Update volume (Not Implemented)
457
+ * Update a volume by name.
458
+ */
459
+ export declare const updateVolume: <ThrowOnError extends boolean = false>(options: Options<UpdateVolumeData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Volume, unknown, ThrowOnError>;
435
460
  /**
436
461
  * List workspaces
437
462
  * Returns a list of all workspaces.
@@ -2,7 +2,7 @@
2
2
  // This file is auto-generated by @hey-api/openapi-ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.deletePrivateCluster = exports.createPrivateCluster = exports.listPrivateClusters = exports.updatePolicy = exports.getPolicy = exports.deletePolicy = exports.createPolicy = exports.listPolicies = exports.listModelRevisions = exports.updateModel = exports.getModel = exports.deleteModel = exports.createModel = exports.listModels = exports.listMcpHubDefinitions = exports.listLocations = exports.listJobRevisions = exports.updateJob = exports.getJob = exports.deleteJob = exports.createJob = exports.listJobs = exports.getIntegrationConnectionModel = exports.listIntegrationConnectionModels = exports.getIntegrationConnectionModelEndpointConfigurations = exports.updateIntegrationConnection = exports.getIntegrationConnection = exports.deleteIntegrationConnection = exports.createIntegrationConnection = exports.listIntegrationConnections = exports.getIntegration = exports.listFunctionRevisions = exports.updateFunction = exports.getFunction = exports.deleteFunction = exports.createFunction = exports.listFunctions = exports.verifyCustomDomain = exports.updateCustomDomain = exports.getCustomDomain = exports.deleteCustomDomain = exports.createCustomDomain = exports.listCustomDomains = exports.getConfiguration = exports.listAgentRevisions = exports.updateAgent = exports.getAgent = exports.deleteAgent = exports.createAgent = exports.listAgents = void 0;
5
- exports.checkWorkspaceAvailability = exports.leaveWorkspace = exports.acceptWorkspaceInvitation = exports.declineWorkspaceInvitation = exports.updateWorkspace = exports.getWorkspace = exports.deleteWorkspace = exports.createWorspace = exports.listWorkspaces = exports.updateWorkspaceUserRole = exports.removeWorkspaceUser = exports.inviteWorkspaceUser = exports.listWorkspaceUsers = exports.getTemplate = exports.listTemplates = exports.deleteApiKeyForServiceAccount = exports.createApiKeyForServiceAccount = exports.listApiKeysForServiceAccount = exports.updateWorkspaceServiceAccount = exports.deleteWorkspaceServiceAccount = exports.createWorkspaceServiceAccount = exports.getWorkspaceServiceAccounts = exports.stopSandbox = exports.startSandbox = exports.deleteSandboxPreviewToken = exports.createSandboxPreviewToken = exports.listSandboxPreviewTokens = exports.updateSandboxPreview = exports.getSandboxPreview = exports.deleteSandboxPreview = exports.createSandboxPreview = exports.listSandboxPreviews = exports.updateSandbox = exports.getSandbox = exports.deleteSandbox = exports.createSandbox = exports.listSandboxes = exports.listSandboxHubDefinitions = exports.listPublicIps = exports.listAllPendingInvitations = exports.updatePrivateClusterHealth = exports.getPrivateClusterHealth = exports.updatePrivateCluster = exports.getPrivateCluster = void 0;
5
+ exports.checkWorkspaceAvailability = exports.leaveWorkspace = exports.acceptWorkspaceInvitation = exports.declineWorkspaceInvitation = exports.updateWorkspace = exports.getWorkspace = exports.deleteWorkspace = exports.createWorspace = exports.listWorkspaces = exports.updateVolume = exports.getVolume = exports.deleteVolume = exports.createVolume = exports.listVolumes = exports.updateWorkspaceUserRole = exports.removeWorkspaceUser = exports.inviteWorkspaceUser = exports.listWorkspaceUsers = exports.getTemplate = exports.listTemplates = exports.deleteApiKeyForServiceAccount = exports.createApiKeyForServiceAccount = exports.listApiKeysForServiceAccount = exports.updateWorkspaceServiceAccount = exports.deleteWorkspaceServiceAccount = exports.createWorkspaceServiceAccount = exports.getWorkspaceServiceAccounts = exports.stopSandbox = exports.startSandbox = exports.deleteSandboxPreviewToken = exports.createSandboxPreviewToken = exports.listSandboxPreviewTokens = exports.updateSandboxPreview = exports.getSandboxPreview = exports.deleteSandboxPreview = exports.createSandboxPreview = exports.listSandboxPreviews = exports.updateSandbox = exports.getSandbox = exports.deleteSandbox = exports.createSandbox = exports.listSandboxes = exports.listSandboxHubDefinitions = exports.listPublicIps = exports.listAllPendingInvitations = exports.updatePrivateClusterHealth = exports.getPrivateClusterHealth = exports.updatePrivateCluster = exports.getPrivateCluster = void 0;
6
6
  const client_gen_1 = require("./client.gen");
7
7
  /**
8
8
  * List all agents
@@ -1512,6 +1512,99 @@ const updateWorkspaceUserRole = (options) => {
1512
1512
  });
1513
1513
  };
1514
1514
  exports.updateWorkspaceUserRole = updateWorkspaceUserRole;
1515
+ /**
1516
+ * List volumes
1517
+ * Returns a list of all volumes in the workspace.
1518
+ */
1519
+ const listVolumes = (options) => {
1520
+ return (options?.client ?? client_gen_1.client).get({
1521
+ security: [
1522
+ {
1523
+ scheme: 'bearer',
1524
+ type: 'http'
1525
+ }
1526
+ ],
1527
+ url: '/volumes',
1528
+ ...options
1529
+ });
1530
+ };
1531
+ exports.listVolumes = listVolumes;
1532
+ /**
1533
+ * Create volume
1534
+ * Creates a volume.
1535
+ */
1536
+ const createVolume = (options) => {
1537
+ return (options.client ?? client_gen_1.client).post({
1538
+ security: [
1539
+ {
1540
+ scheme: 'bearer',
1541
+ type: 'http'
1542
+ }
1543
+ ],
1544
+ url: '/volumes',
1545
+ ...options,
1546
+ headers: {
1547
+ 'Content-Type': 'application/json',
1548
+ ...options?.headers
1549
+ }
1550
+ });
1551
+ };
1552
+ exports.createVolume = createVolume;
1553
+ /**
1554
+ * Delete volume
1555
+ * Deletes a volume by name.
1556
+ */
1557
+ const deleteVolume = (options) => {
1558
+ return (options.client ?? client_gen_1.client).delete({
1559
+ security: [
1560
+ {
1561
+ scheme: 'bearer',
1562
+ type: 'http'
1563
+ }
1564
+ ],
1565
+ url: '/volumes/{volumeName}',
1566
+ ...options
1567
+ });
1568
+ };
1569
+ exports.deleteVolume = deleteVolume;
1570
+ /**
1571
+ * Get volume
1572
+ * Returns a volume by name.
1573
+ */
1574
+ const getVolume = (options) => {
1575
+ return (options.client ?? client_gen_1.client).get({
1576
+ security: [
1577
+ {
1578
+ scheme: 'bearer',
1579
+ type: 'http'
1580
+ }
1581
+ ],
1582
+ url: '/volumes/{volumeName}',
1583
+ ...options
1584
+ });
1585
+ };
1586
+ exports.getVolume = getVolume;
1587
+ /**
1588
+ * Update volume (Not Implemented)
1589
+ * Update a volume by name.
1590
+ */
1591
+ const updateVolume = (options) => {
1592
+ return (options.client ?? client_gen_1.client).put({
1593
+ security: [
1594
+ {
1595
+ scheme: 'bearer',
1596
+ type: 'http'
1597
+ }
1598
+ ],
1599
+ url: '/volumes/{volumeName}',
1600
+ ...options,
1601
+ headers: {
1602
+ 'Content-Type': 'application/json',
1603
+ ...options?.headers
1604
+ }
1605
+ });
1606
+ };
1607
+ exports.updateVolume = updateVolume;
1515
1608
  /**
1516
1609
  * List workspaces
1517
1610
  * Returns a list of all workspaces.
@@ -2029,6 +2029,10 @@ export type Sandbox = {
2029
2029
  * Sandbox status
2030
2030
  */
2031
2031
  status?: string;
2032
+ /**
2033
+ * TTL timestamp for automatic deletion (optional, nil means no auto-deletion)
2034
+ */
2035
+ ttl?: number;
2032
2036
  };
2033
2037
  /**
2034
2038
  * Sandbox definition for admin store operations
@@ -2083,7 +2087,9 @@ export type SandboxDefinition = {
2083
2087
  /**
2084
2088
  * Sandbox specification
2085
2089
  */
2086
- export type SandboxSpec = CoreSpec & unknown;
2090
+ export type SandboxSpec = CoreSpec & {
2091
+ volumes?: VolumeAttachments;
2092
+ };
2087
2093
  /**
2088
2094
  * Name of a Sandbox definition
2089
2095
  */
@@ -2464,6 +2470,63 @@ export type TriggerConfigurationTask = {
2464
2470
  * Triggers to use your agent
2465
2471
  */
2466
2472
  export type Triggers = Array<Trigger>;
2473
+ /**
2474
+ * Volume resource for persistent storage
2475
+ */
2476
+ export type Volume = {
2477
+ events?: CoreEvents;
2478
+ metadata?: Metadata;
2479
+ spec?: VolumeSpec;
2480
+ state?: VolumeState;
2481
+ /**
2482
+ * Volume status computed from events
2483
+ */
2484
+ status?: string;
2485
+ /**
2486
+ * Timestamp when the volume was marked for termination
2487
+ */
2488
+ terminatedAt?: string;
2489
+ };
2490
+ /**
2491
+ * Volume attachment configuration for sandbox
2492
+ */
2493
+ export type VolumeAttachment = {
2494
+ /**
2495
+ * Mount path in the container
2496
+ */
2497
+ mountPath?: string;
2498
+ /**
2499
+ * Name of the volume to attach
2500
+ */
2501
+ name?: string;
2502
+ /**
2503
+ * Whether the volume is mounted as read-only
2504
+ */
2505
+ readOnly?: boolean;
2506
+ };
2507
+ export type VolumeAttachments = Array<VolumeAttachment>;
2508
+ /**
2509
+ * Volume specification - immutable configuration
2510
+ */
2511
+ export type VolumeSpec = {
2512
+ /**
2513
+ * AWS region where the volume should be created (e.g. us-west-2, eu-west-1)
2514
+ */
2515
+ region?: string;
2516
+ /**
2517
+ * Size of the volume in MB
2518
+ */
2519
+ size?: number;
2520
+ };
2521
+ /**
2522
+ * Volume state - mutable runtime state
2523
+ */
2524
+ export type VolumeState = {
2525
+ /**
2526
+ * Resource this volume is attached to (e.g. "sandbox:my-sandbox", "model:my-model")
2527
+ */
2528
+ attachedTo?: string;
2529
+ };
2467
2530
  /**
2468
2531
  * WebSocket connection details
2469
2532
  */
@@ -4238,6 +4301,92 @@ export type UpdateWorkspaceUserRoleResponses = {
4238
4301
  200: WorkspaceUser;
4239
4302
  };
4240
4303
  export type UpdateWorkspaceUserRoleResponse = UpdateWorkspaceUserRoleResponses[keyof UpdateWorkspaceUserRoleResponses];
4304
+ export type ListVolumesData = {
4305
+ body?: never;
4306
+ path?: never;
4307
+ query?: never;
4308
+ url: '/volumes';
4309
+ };
4310
+ export type ListVolumesResponses = {
4311
+ /**
4312
+ * successful operation
4313
+ */
4314
+ 200: Array<Volume>;
4315
+ };
4316
+ export type ListVolumesResponse = ListVolumesResponses[keyof ListVolumesResponses];
4317
+ export type CreateVolumeData = {
4318
+ body: Volume;
4319
+ path?: never;
4320
+ query?: never;
4321
+ url: '/volumes';
4322
+ };
4323
+ export type CreateVolumeResponses = {
4324
+ /**
4325
+ * successful operation
4326
+ */
4327
+ 200: Volume;
4328
+ };
4329
+ export type CreateVolumeResponse = CreateVolumeResponses[keyof CreateVolumeResponses];
4330
+ export type DeleteVolumeData = {
4331
+ body?: never;
4332
+ path: {
4333
+ /**
4334
+ * Name of the volume
4335
+ */
4336
+ volumeName: string;
4337
+ };
4338
+ query?: never;
4339
+ url: '/volumes/{volumeName}';
4340
+ };
4341
+ export type DeleteVolumeResponses = {
4342
+ /**
4343
+ * successful operation
4344
+ */
4345
+ 200: Volume;
4346
+ };
4347
+ export type DeleteVolumeResponse = DeleteVolumeResponses[keyof DeleteVolumeResponses];
4348
+ export type GetVolumeData = {
4349
+ body?: never;
4350
+ path: {
4351
+ /**
4352
+ * Name of the volume
4353
+ */
4354
+ volumeName: string;
4355
+ };
4356
+ query?: never;
4357
+ url: '/volumes/{volumeName}';
4358
+ };
4359
+ export type GetVolumeResponses = {
4360
+ /**
4361
+ * successful operation
4362
+ */
4363
+ 200: Volume;
4364
+ };
4365
+ export type GetVolumeResponse = GetVolumeResponses[keyof GetVolumeResponses];
4366
+ export type UpdateVolumeData = {
4367
+ body: Volume;
4368
+ path: {
4369
+ /**
4370
+ * Name of the volume
4371
+ */
4372
+ volumeName: string;
4373
+ };
4374
+ query?: never;
4375
+ url: '/volumes/{volumeName}';
4376
+ };
4377
+ export type UpdateVolumeErrors = {
4378
+ /**
4379
+ * Method not allowed - volume updates are not supported
4380
+ */
4381
+ 405: unknown;
4382
+ };
4383
+ export type UpdateVolumeResponses = {
4384
+ /**
4385
+ * successful operation
4386
+ */
4387
+ 200: Volume;
4388
+ };
4389
+ export type UpdateVolumeResponse = UpdateVolumeResponses[keyof UpdateVolumeResponses];
4241
4390
  export type ListWorkspacesData = {
4242
4391
  body?: never;
4243
4392
  path?: never;
@@ -7,6 +7,7 @@ export type Config = {
7
7
  declare class Settings {
8
8
  credentials: Credentials;
9
9
  config: Config;
10
+ private _version;
10
11
  constructor();
11
12
  setConfig(config: Config): void;
12
13
  get env(): string;
@@ -15,6 +16,7 @@ declare class Settings {
15
16
  get workspace(): string;
16
17
  get authorization(): string;
17
18
  get token(): string;
19
+ get version(): string;
18
20
  get headers(): Record<string, string>;
19
21
  get name(): string;
20
22
  get type(): string;
@@ -3,9 +3,74 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.settings = void 0;
4
4
  const index_js_1 = require("../authentication/index.js");
5
5
  const env_js_1 = require("../common/env.js");
6
+ // Function to get package version
7
+ function getPackageVersion() {
8
+ try {
9
+ // Try to require package.json (Node.js only, gracefully fails in browser)
10
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
11
+ const packageJson = {"version":"0.2.32-dev.183","commit":"fbb89b46492b217f58d6115db98bd5e19cdc06f9"};
12
+ return packageJson.version || "unknown";
13
+ }
14
+ catch {
15
+ // Fallback for browser environments or if require fails
16
+ return "unknown";
17
+ }
18
+ }
19
+ // Function to get OS and architecture
20
+ function getOsArch() {
21
+ try {
22
+ // Node.js environment
23
+ if (typeof process !== 'undefined' && process.platform && process.arch) {
24
+ const platform = process.platform === 'win32' ? 'windows' :
25
+ process.platform === 'darwin' ? 'darwin' :
26
+ process.platform === 'linux' ? 'linux' : process.platform;
27
+ return `${platform}/${process.arch}`;
28
+ }
29
+ }
30
+ catch {
31
+ // Fall through to browser detection
32
+ }
33
+ // Browser environment - use fixed detection
34
+ try {
35
+ // @ts-ignore - navigator is available in browser environments
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
37
+ if (typeof navigator !== 'undefined' && navigator?.platform) {
38
+ // @ts-ignore - navigator.platform is available in browser environments
39
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
40
+ const navPlatform = navigator.platform.toLowerCase();
41
+ const platform = navPlatform.includes('win') ? 'windows' :
42
+ navPlatform.includes('mac') ? 'darwin' :
43
+ navPlatform.includes('linux') ? 'linux' : 'browser';
44
+ const arch = navPlatform.includes('64') ? 'amd64' : 'unknown';
45
+ return `${platform}/${arch}`;
46
+ }
47
+ }
48
+ catch {
49
+ // Ignore errors
50
+ }
51
+ return "browser/unknown";
52
+ }
53
+ // Function to get commit hash
54
+ function getCommitHash() {
55
+ try {
56
+ // Try to require package.json and look for commit field (set during build)
57
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
58
+ const packageJson = {"version":"0.2.32-dev.183","commit":"fbb89b46492b217f58d6115db98bd5e19cdc06f9"};
59
+ // Check for commit in various possible locations
60
+ const commit = packageJson.commit || packageJson.buildInfo?.commit;
61
+ if (commit) {
62
+ return commit.length > 7 ? commit.substring(0, 7) : commit;
63
+ }
64
+ }
65
+ catch {
66
+ // Fallback for browser environments or if require fails
67
+ }
68
+ return "unknown";
69
+ }
6
70
  class Settings {
7
71
  credentials;
8
72
  config;
73
+ _version = null;
9
74
  constructor() {
10
75
  this.credentials = (0, index_js_1.authentication)();
11
76
  this.config = {
@@ -59,10 +124,19 @@ class Settings {
59
124
  }
60
125
  return this.credentials.token;
61
126
  }
127
+ get version() {
128
+ if (this._version === null) {
129
+ this._version = getPackageVersion();
130
+ }
131
+ return this._version;
132
+ }
62
133
  get headers() {
134
+ const osArch = getOsArch();
135
+ const commitHash = getCommitHash();
63
136
  return {
64
137
  "x-blaxel-authorization": this.authorization,
65
138
  "x-blaxel-workspace": this.workspace || "",
139
+ "User-Agent": `blaxel/sdk/typescript/${this.version} (${osArch}) blaxel/${commitHash}`,
66
140
  };
67
141
  }
68
142
  get name() {
package/dist/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export * from "./sandbox/index.js";
14
14
  export * from "./telemetry/telemetry.js";
15
15
  export * from "./tools/index.js";
16
16
  export * from "./tools/types.js";
17
+ export * from "./volume/index.js";
package/dist/index.js CHANGED
@@ -30,3 +30,4 @@ __exportStar(require("./sandbox/index.js"), exports);
30
30
  __exportStar(require("./telemetry/telemetry.js"), exports);
31
31
  __exportStar(require("./tools/index.js"), exports);
32
32
  __exportStar(require("./tools/types.js"), exports);
33
+ __exportStar(require("./volume/index.js"), exports);
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
- /* eslint-disable */
3
2
  // This file is auto-generated by @hey-api/openapi-ts
4
3
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -58,7 +58,7 @@ class SandboxProcess extends action_js_1.SandboxAction {
58
58
  startStream();
59
59
  // Return control functions
60
60
  return {
61
- close: async () => {
61
+ close: () => {
62
62
  isRunning = false;
63
63
  // Clear reconnect timer
64
64
  if (reconnectTimer) {
@@ -16,7 +16,7 @@ export declare class SandboxInstance {
16
16
  get metadata(): import("../client/types.gen.js").Metadata | undefined;
17
17
  get status(): string | undefined;
18
18
  get events(): import("../client/types.gen.js").CoreEvents | undefined;
19
- get spec(): import("../client/types.gen.js").CoreSpec | undefined;
19
+ get spec(): import("../client/types.gen.js").SandboxSpec | undefined;
20
20
  wait({ maxWait, interval }?: {
21
21
  maxWait?: number;
22
22
  interval?: number;
@@ -48,8 +48,8 @@ class SandboxInstance {
48
48
  const defaultName = `sandbox-${(0, uuid_1.v4)().replace(/-/g, '').substring(0, 8)}`;
49
49
  const defaultImage = `blaxel/${env}-base:latest`;
50
50
  const defaultMemory = 4096;
51
- // Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports/envs keys
52
- if (!sandbox || 'name' in sandbox || 'image' in sandbox || 'memory' in sandbox || 'ports' in sandbox || 'envs' in sandbox) {
51
+ // Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports/envs/volumes keys
52
+ if (!sandbox || 'name' in sandbox || 'image' in sandbox || 'memory' in sandbox || 'ports' in sandbox || 'envs' in sandbox || 'volumes' in sandbox) {
53
53
  if (!sandbox)
54
54
  sandbox = {};
55
55
  if (!sandbox.name)
@@ -60,6 +60,7 @@ class SandboxInstance {
60
60
  sandbox.memory = defaultMemory;
61
61
  const ports = (0, types_js_1.normalizePorts)(sandbox.ports);
62
62
  const envs = (0, types_js_1.normalizeEnvs)(sandbox.envs);
63
+ const volumes = (0, types_js_1.normalizeVolumes)(sandbox.volumes);
63
64
  const ttl = sandbox.ttl;
64
65
  const expires = sandbox.expires;
65
66
  sandbox = {
@@ -71,7 +72,8 @@ class SandboxInstance {
71
72
  ports: ports,
72
73
  envs: envs,
73
74
  generation: "mk3",
74
- }
75
+ },
76
+ volumes: volumes
75
77
  }
76
78
  };
77
79
  if (ttl) {
@@ -1,4 +1,4 @@
1
- import { Port, Sandbox } from "../client/types.gen";
1
+ import { Port, Sandbox, VolumeAttachment } from "../client/types.gen";
2
2
  import { PostProcessResponse, ProcessRequest } from "./client";
3
3
  export interface SessionCreateOptions {
4
4
  expiresAt?: Date;
@@ -15,6 +15,11 @@ export interface EnvVar {
15
15
  name: string;
16
16
  value: string;
17
17
  }
18
+ export interface VolumeBinding {
19
+ name: string;
20
+ mountPath: string;
21
+ readOnly?: boolean;
22
+ }
18
23
  export type SandboxConfiguration = {
19
24
  forceUrl?: string;
20
25
  headers?: Record<string, string>;
@@ -30,11 +35,13 @@ export type SandboxCreateConfiguration = {
30
35
  memory?: number;
31
36
  ports?: (Port | Record<string, any>)[];
32
37
  envs?: EnvVar[];
38
+ volumes?: (VolumeBinding | VolumeAttachment)[];
33
39
  ttl?: string;
34
40
  expires?: Date;
35
41
  };
36
42
  export declare function normalizePorts(ports?: (Port | Record<string, any>)[]): Port[] | undefined;
37
43
  export declare function normalizeEnvs(envs?: EnvVar[]): EnvVar[] | undefined;
44
+ export declare function normalizeVolumes(volumes?: (VolumeBinding | VolumeAttachment)[]): VolumeAttachment[] | undefined;
38
45
  export type ProcessRequestWithLog = ProcessRequest & {
39
46
  onLog?: (log: string) => void;
40
47
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizePorts = normalizePorts;
4
4
  exports.normalizeEnvs = normalizeEnvs;
5
+ exports.normalizeVolumes = normalizeVolumes;
5
6
  function normalizePorts(ports) {
6
7
  if (!ports || ports.length === 0) {
7
8
  return undefined;
@@ -50,3 +51,31 @@ function normalizeEnvs(envs) {
50
51
  }
51
52
  return envObjects;
52
53
  }
54
+ function normalizeVolumes(volumes) {
55
+ if (!volumes || volumes.length === 0) {
56
+ return undefined;
57
+ }
58
+ const volumeObjects = [];
59
+ for (const volume of volumes) {
60
+ if (typeof volume === 'object' && volume !== null) {
61
+ // Validate that the object has the required keys
62
+ if (!('name' in volume) || !('mountPath' in volume)) {
63
+ throw new Error(`Volume binding object must have 'name' and 'mountPath' keys: ${JSON.stringify(volume)}`);
64
+ }
65
+ if (typeof volume.name !== 'string' || typeof volume.mountPath !== 'string') {
66
+ throw new Error(`Volume binding 'name' and 'mountPath' must be strings: ${JSON.stringify(volume)}`);
67
+ }
68
+ // Convert VolumeBinding to VolumeAttachment format
69
+ const volumeAttachment = {
70
+ name: volume.name,
71
+ mountPath: volume.mountPath,
72
+ readOnly: 'readOnly' in volume ? volume.readOnly : false
73
+ };
74
+ volumeObjects.push(volumeAttachment);
75
+ }
76
+ else {
77
+ throw new Error(`Invalid volume type: ${typeof volume}. Expected object with 'name' and 'mountPath' keys.`);
78
+ }
79
+ }
80
+ return volumeObjects;
81
+ }
@@ -0,0 +1,23 @@
1
+ import { Volume } from "../client/index.js";
2
+ export interface VolumeCreateConfiguration {
3
+ name?: string;
4
+ displayName?: string;
5
+ size?: number;
6
+ region?: string;
7
+ }
8
+ export declare class VolumeInstance {
9
+ private volume;
10
+ constructor(volume: Volume);
11
+ get metadata(): import("../client/types.gen.js").Metadata | undefined;
12
+ get spec(): import("../client/types.gen.js").VolumeSpec | undefined;
13
+ get status(): string | undefined;
14
+ get name(): string | undefined;
15
+ get displayName(): string | undefined;
16
+ get size(): number | undefined;
17
+ get region(): string | undefined;
18
+ static create(config: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
19
+ static get(volumeName: string): Promise<VolumeInstance>;
20
+ static list(): Promise<VolumeInstance[]>;
21
+ static delete(volumeName: string): Promise<Volume>;
22
+ static createIfNotExists(config: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
23
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VolumeInstance = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const index_js_1 = require("../client/index.js");
6
+ class VolumeInstance {
7
+ volume;
8
+ constructor(volume) {
9
+ this.volume = volume;
10
+ }
11
+ get metadata() {
12
+ return this.volume.metadata;
13
+ }
14
+ get spec() {
15
+ return this.volume.spec;
16
+ }
17
+ get status() {
18
+ return this.volume.status;
19
+ }
20
+ get name() {
21
+ return this.volume.metadata?.name;
22
+ }
23
+ get displayName() {
24
+ return this.volume.metadata?.displayName;
25
+ }
26
+ get size() {
27
+ return this.volume.spec?.size;
28
+ }
29
+ get region() {
30
+ return this.volume.spec?.region;
31
+ }
32
+ static async create(config) {
33
+ const defaultName = `volume-${(0, uuid_1.v4)().replace(/-/g, '').substring(0, 8)}`;
34
+ const defaultSize = 1024; // 1GB in MB
35
+ let volume;
36
+ // Handle VolumeCreateConfiguration or simple config object
37
+ if ('spec' in config && 'metadata' in config) {
38
+ // It's already a Volume object
39
+ volume = config;
40
+ }
41
+ else {
42
+ // It's a VolumeCreateConfiguration
43
+ const volumeConfig = config;
44
+ volume = {
45
+ metadata: {
46
+ name: volumeConfig.name || defaultName,
47
+ displayName: volumeConfig.displayName || volumeConfig.name || defaultName
48
+ },
49
+ spec: {
50
+ size: volumeConfig.size || defaultSize,
51
+ region: volumeConfig.region
52
+ }
53
+ };
54
+ }
55
+ // Ensure required fields have defaults
56
+ if (!volume.metadata) {
57
+ volume.metadata = { name: defaultName };
58
+ }
59
+ if (!volume.metadata.name) {
60
+ volume.metadata.name = defaultName;
61
+ }
62
+ if (!volume.spec) {
63
+ volume.spec = { size: defaultSize };
64
+ }
65
+ if (!volume.spec.size) {
66
+ volume.spec.size = defaultSize;
67
+ }
68
+ const { data } = await (0, index_js_1.createVolume)({
69
+ body: volume,
70
+ throwOnError: true,
71
+ });
72
+ return new VolumeInstance(data);
73
+ }
74
+ static async get(volumeName) {
75
+ const { data } = await (0, index_js_1.getVolume)({
76
+ path: {
77
+ volumeName,
78
+ },
79
+ throwOnError: true,
80
+ });
81
+ return new VolumeInstance(data);
82
+ }
83
+ static async list() {
84
+ const { data } = await (0, index_js_1.listVolumes)({ throwOnError: true });
85
+ return data.map((volume) => new VolumeInstance(volume));
86
+ }
87
+ static async delete(volumeName) {
88
+ const { data } = await (0, index_js_1.deleteVolume)({
89
+ path: {
90
+ volumeName,
91
+ },
92
+ throwOnError: true,
93
+ });
94
+ return data;
95
+ }
96
+ static async createIfNotExists(config) {
97
+ try {
98
+ return await VolumeInstance.create(config);
99
+ }
100
+ catch (e) {
101
+ if (typeof e === "object" && e !== null && "code" in e && (e.code === 409 || e.code === 'VOLUME_ALREADY_EXISTS')) {
102
+ const name = 'name' in config ? config.name : config.metadata?.name;
103
+ if (!name) {
104
+ throw new Error("Volume name is required");
105
+ }
106
+ const volumeInstance = await VolumeInstance.get(name);
107
+ return volumeInstance;
108
+ }
109
+ throw e;
110
+ }
111
+ }
112
+ }
113
+ exports.VolumeInstance = VolumeInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.31",
3
+ "version": "0.2.32-dev.183",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",
@@ -76,10 +76,14 @@
76
76
  "vite": "^5.2.0",
77
77
  "vitest": "^1.5.0"
78
78
  },
79
+ "commit": "fbb89b46492b217f58d6115db98bd5e19cdc06f9",
79
80
  "scripts": {
80
81
  "lint": "eslint src/",
81
82
  "dev": "tsc --watch",
82
- "build": "tsc",
83
+ "build": "npm run build:inject-commit && tsc && npm run build:replace-imports",
84
+ "build:clean": "tsc",
85
+ "build:inject-commit": "node -e \"const fs=require('fs'),pkg=require('./package.json'),{execSync}=require('child_process');try{const commit=execSync('git rev-parse HEAD',{encoding:'utf8'}).trim();pkg.commit=commit;fs.writeFileSync('./package.json',JSON.stringify(pkg,null,'\\t')+'\\n');console.log('✅ Injected commit:',commit.substring(0,7))}catch(e){console.log('⚠️ Could not inject commit:',e.message)}\"",
86
+ "build:replace-imports": "node -e \"const fs=require('fs'),path=require('path'),pkg=require('./package.json');const settingsPath=path.join('dist','common','settings.js');if(fs.existsSync(settingsPath)){let content=fs.readFileSync(settingsPath,'utf8');content=content.replace(/require\\(\\\".*?\\/package\\.json\\\"\\)/g,JSON.stringify({version:pkg.version,commit:pkg.commit||'unknown'}));fs.writeFileSync(settingsPath,content);console.log('✅ Replaced package.json imports in compiled JS with version:',pkg.version,'commit:',(pkg.commit||'unknown').substring(0,7));}else{console.log('⚠️ Could not find',settingsPath,'to replace imports');}\"",
83
87
  "test": "vitest --run",
84
88
  "test:watch": "vitest --watch"
85
89
  }