@blaxel/core 0.2.33 → 0.2.34
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/sdk.gen.d.ts +55 -31
- package/dist/client/sdk.gen.js +216 -112
- package/dist/client/types.gen.d.ts +367 -213
- package/dist/common/settings.d.ts +2 -0
- package/dist/common/settings.js +74 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/client.d.ts +8 -1
- package/dist/mcp/client.js +35 -13
- package/dist/sandbox/action.js +4 -2
- package/dist/sandbox/client/types.gen.js +0 -1
- package/dist/sandbox/process/process.js +5 -5
- package/dist/sandbox/sandbox.d.ts +6 -3
- package/dist/sandbox/sandbox.js +50 -50
- package/dist/sandbox/session.js +4 -1
- package/dist/sandbox/types.d.ts +14 -1
- package/dist/sandbox/types.js +29 -0
- package/dist/tools/mcpTool.js +19 -4
- package/dist/volume/index.d.ts +23 -0
- package/dist/volume/index.js +113 -0
- package/package.json +6 -2
|
@@ -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.
|
|
3
|
+
"version": "0.2.34",
|
|
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": "7a2fa3abb20301bb12cc85be0622bc498ff3fedc",
|
|
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
|
}
|