vyoma 0.1.0 → 1.0.1
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/index.d.mts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.js +49 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,19 @@ interface SandboxCreateRequest {
|
|
|
12
12
|
interface SandboxStopRequest {
|
|
13
13
|
sandboxId: ID;
|
|
14
14
|
}
|
|
15
|
+
interface SandboxStatusRequest {
|
|
16
|
+
sandboxId: ID;
|
|
17
|
+
}
|
|
18
|
+
interface SandboxWriteRequest {
|
|
19
|
+
sandboxId: ID;
|
|
20
|
+
path: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
interface SandboxExecRequest {
|
|
24
|
+
sandboxId: ID;
|
|
25
|
+
command: string;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
}
|
|
15
28
|
type SandboxStatus = "starting" | "running" | "stopped" | "error";
|
|
16
29
|
interface Sandbox {
|
|
17
30
|
id: ID;
|
|
@@ -24,17 +37,31 @@ interface Sandbox {
|
|
|
24
37
|
interface SandboxCreateResponse {
|
|
25
38
|
sandbox: Sandbox;
|
|
26
39
|
}
|
|
40
|
+
interface SandboxStopResponse {
|
|
41
|
+
sandboxId: ID;
|
|
42
|
+
status: "stopped";
|
|
43
|
+
}
|
|
27
44
|
interface SandboxStatusResponse {
|
|
28
45
|
sandboxId: ID;
|
|
29
46
|
status: SandboxStatus;
|
|
30
47
|
}
|
|
48
|
+
interface SandboxWriteResponse {
|
|
49
|
+
success: true;
|
|
50
|
+
}
|
|
51
|
+
interface SandboxExecResponse {
|
|
52
|
+
stdout: string;
|
|
53
|
+
stderr: string;
|
|
54
|
+
exitCode: number;
|
|
55
|
+
}
|
|
31
56
|
|
|
32
57
|
declare class SandboxResource {
|
|
33
58
|
private client;
|
|
34
59
|
constructor(client: VyomaClient);
|
|
35
60
|
create(data: SandboxCreateRequest): Promise<SandboxCreateResponse>;
|
|
36
|
-
stop(sandboxId: string): Promise<
|
|
61
|
+
stop(sandboxId: string): Promise<SandboxStopResponse>;
|
|
37
62
|
status(sandboxId: string): Promise<SandboxStatusResponse>;
|
|
63
|
+
write(sandboxId: string, path: string, content: string): Promise<SandboxWriteResponse>;
|
|
64
|
+
exec(sandboxId: string, command: string, cwd?: string): Promise<SandboxExecResponse>;
|
|
38
65
|
}
|
|
39
66
|
|
|
40
67
|
interface VyomaClientOptions {
|
|
@@ -49,4 +76,4 @@ declare class VyomaClient {
|
|
|
49
76
|
sandbox: SandboxResource;
|
|
50
77
|
}
|
|
51
78
|
|
|
52
|
-
export { type ApiError, type ID, type ISODate, type Sandbox, type SandboxCreateRequest, type SandboxCreateResponse, type SandboxStatus, type SandboxStatusResponse, type SandboxStopRequest, VyomaClient };
|
|
79
|
+
export { type ApiError, type ID, type ISODate, type Sandbox, type SandboxCreateRequest, type SandboxCreateResponse, type SandboxExecRequest, type SandboxExecResponse, type SandboxStatus, type SandboxStatusRequest, type SandboxStatusResponse, type SandboxStopRequest, type SandboxStopResponse, type SandboxWriteRequest, type SandboxWriteResponse, VyomaClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,19 @@ interface SandboxCreateRequest {
|
|
|
12
12
|
interface SandboxStopRequest {
|
|
13
13
|
sandboxId: ID;
|
|
14
14
|
}
|
|
15
|
+
interface SandboxStatusRequest {
|
|
16
|
+
sandboxId: ID;
|
|
17
|
+
}
|
|
18
|
+
interface SandboxWriteRequest {
|
|
19
|
+
sandboxId: ID;
|
|
20
|
+
path: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
interface SandboxExecRequest {
|
|
24
|
+
sandboxId: ID;
|
|
25
|
+
command: string;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
}
|
|
15
28
|
type SandboxStatus = "starting" | "running" | "stopped" | "error";
|
|
16
29
|
interface Sandbox {
|
|
17
30
|
id: ID;
|
|
@@ -24,17 +37,31 @@ interface Sandbox {
|
|
|
24
37
|
interface SandboxCreateResponse {
|
|
25
38
|
sandbox: Sandbox;
|
|
26
39
|
}
|
|
40
|
+
interface SandboxStopResponse {
|
|
41
|
+
sandboxId: ID;
|
|
42
|
+
status: "stopped";
|
|
43
|
+
}
|
|
27
44
|
interface SandboxStatusResponse {
|
|
28
45
|
sandboxId: ID;
|
|
29
46
|
status: SandboxStatus;
|
|
30
47
|
}
|
|
48
|
+
interface SandboxWriteResponse {
|
|
49
|
+
success: true;
|
|
50
|
+
}
|
|
51
|
+
interface SandboxExecResponse {
|
|
52
|
+
stdout: string;
|
|
53
|
+
stderr: string;
|
|
54
|
+
exitCode: number;
|
|
55
|
+
}
|
|
31
56
|
|
|
32
57
|
declare class SandboxResource {
|
|
33
58
|
private client;
|
|
34
59
|
constructor(client: VyomaClient);
|
|
35
60
|
create(data: SandboxCreateRequest): Promise<SandboxCreateResponse>;
|
|
36
|
-
stop(sandboxId: string): Promise<
|
|
61
|
+
stop(sandboxId: string): Promise<SandboxStopResponse>;
|
|
37
62
|
status(sandboxId: string): Promise<SandboxStatusResponse>;
|
|
63
|
+
write(sandboxId: string, path: string, content: string): Promise<SandboxWriteResponse>;
|
|
64
|
+
exec(sandboxId: string, command: string, cwd?: string): Promise<SandboxExecResponse>;
|
|
38
65
|
}
|
|
39
66
|
|
|
40
67
|
interface VyomaClientOptions {
|
|
@@ -49,4 +76,4 @@ declare class VyomaClient {
|
|
|
49
76
|
sandbox: SandboxResource;
|
|
50
77
|
}
|
|
51
78
|
|
|
52
|
-
export { type ApiError, type ID, type ISODate, type Sandbox, type SandboxCreateRequest, type SandboxCreateResponse, type SandboxStatus, type SandboxStatusResponse, type SandboxStopRequest, VyomaClient };
|
|
79
|
+
export { type ApiError, type ID, type ISODate, type Sandbox, type SandboxCreateRequest, type SandboxCreateResponse, type SandboxExecRequest, type SandboxExecResponse, type SandboxStatus, type SandboxStatusRequest, type SandboxStatusResponse, type SandboxStopRequest, type SandboxStopResponse, type SandboxWriteRequest, type SandboxWriteResponse, VyomaClient };
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var SandboxResource = class {
|
|
|
31
31
|
}
|
|
32
32
|
create(data) {
|
|
33
33
|
return this.client.request(
|
|
34
|
-
"/sandbox/create",
|
|
34
|
+
"/api/sandbox/create",
|
|
35
35
|
{
|
|
36
36
|
method: "POST",
|
|
37
37
|
body: JSON.stringify(data)
|
|
@@ -40,7 +40,7 @@ var SandboxResource = class {
|
|
|
40
40
|
}
|
|
41
41
|
stop(sandboxId) {
|
|
42
42
|
return this.client.request(
|
|
43
|
-
"/sandbox/stop",
|
|
43
|
+
"/api/sandbox/stop",
|
|
44
44
|
{
|
|
45
45
|
method: "POST",
|
|
46
46
|
body: JSON.stringify({ sandboxId })
|
|
@@ -49,9 +49,48 @@ var SandboxResource = class {
|
|
|
49
49
|
}
|
|
50
50
|
status(sandboxId) {
|
|
51
51
|
return this.client.request(
|
|
52
|
-
`/sandbox/status?sandboxId=${sandboxId}
|
|
52
|
+
`/api/sandbox/status?sandboxId=${sandboxId}`,
|
|
53
|
+
{
|
|
54
|
+
method: "GET"
|
|
55
|
+
}
|
|
53
56
|
);
|
|
54
57
|
}
|
|
58
|
+
write(sandboxId, path, content) {
|
|
59
|
+
return this.client.request(
|
|
60
|
+
"/api/sandbox/write",
|
|
61
|
+
{
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
sandboxId,
|
|
65
|
+
path,
|
|
66
|
+
content
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
exec(sandboxId, command, cwd) {
|
|
72
|
+
return this.client.request(
|
|
73
|
+
"/api/sandbox/exec",
|
|
74
|
+
{
|
|
75
|
+
method: "POST",
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
sandboxId,
|
|
78
|
+
command,
|
|
79
|
+
cwd
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/core/error.ts
|
|
87
|
+
var VyomaError = class extends Error {
|
|
88
|
+
constructor(message, status, code) {
|
|
89
|
+
super(message);
|
|
90
|
+
this.name = "VyomaError";
|
|
91
|
+
this.status = status;
|
|
92
|
+
this.code = code;
|
|
93
|
+
}
|
|
55
94
|
};
|
|
56
95
|
|
|
57
96
|
// src/core/client.ts
|
|
@@ -62,7 +101,7 @@ var VyomaClient = class {
|
|
|
62
101
|
throw new Error("Vyoma API key is required");
|
|
63
102
|
}
|
|
64
103
|
this.apiKey = options.apiKey;
|
|
65
|
-
this.baseUrl = options.baseUrl ?? "
|
|
104
|
+
this.baseUrl = options.baseUrl ?? "http://sandboxd.nakul.space";
|
|
66
105
|
}
|
|
67
106
|
async request(path, options = {}) {
|
|
68
107
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
@@ -74,8 +113,12 @@ var VyomaClient = class {
|
|
|
74
113
|
}
|
|
75
114
|
});
|
|
76
115
|
if (!res.ok) {
|
|
77
|
-
const
|
|
78
|
-
throw new
|
|
116
|
+
const data = await res.json().catch(() => null);
|
|
117
|
+
throw new VyomaError(
|
|
118
|
+
data?.error ?? "Vyoma API error",
|
|
119
|
+
res.status,
|
|
120
|
+
data?.code
|
|
121
|
+
);
|
|
79
122
|
}
|
|
80
123
|
return res.json();
|
|
81
124
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/resources/sandbox.ts","../src/core/client.ts"],"sourcesContent":["export { VyomaClient } from \"./core/client\";\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/resources/sandbox.ts","../src/core/error.ts","../src/core/client.ts"],"sourcesContent":["export { VyomaClient } from \"./core/client\";\nexport * from \"./types\";\n","import { VyomaClient } from \"../core/client\";\nimport {\n SandboxCreateRequest,\n SandboxCreateResponse,\n SandboxStatusResponse,\n SandboxStopResponse,\n SandboxWriteResponse,\n SandboxExecResponse,\n} from \"../types/sandbox\";\n\nexport class SandboxResource {\n constructor(private client: VyomaClient) {}\n\n create(data: SandboxCreateRequest) {\n return this.client.request<SandboxCreateResponse>(\n \"/api/sandbox/create\",\n {\n method: \"POST\",\n body: JSON.stringify(data),\n }\n );\n }\n\n stop(sandboxId: string) {\n return this.client.request<SandboxStopResponse>(\n \"/api/sandbox/stop\",\n {\n method: \"POST\",\n body: JSON.stringify({ sandboxId }),\n }\n );\n }\n\n status(sandboxId: string) {\n return this.client.request<SandboxStatusResponse>(\n `/api/sandbox/status?sandboxId=${sandboxId}`,\n {\n method: \"GET\",\n }\n );\n }\n\n write(\n sandboxId: string,\n path: string,\n content: string\n ) {\n return this.client.request<SandboxWriteResponse>(\n \"/api/sandbox/write\",\n {\n method: \"POST\",\n body: JSON.stringify({\n sandboxId,\n path,\n content,\n }),\n }\n );\n }\n\n exec(\n sandboxId: string,\n command: string,\n cwd?: string\n ) {\n return this.client.request<SandboxExecResponse>(\n \"/api/sandbox/exec\",\n {\n method: \"POST\",\n body: JSON.stringify({\n sandboxId,\n command,\n cwd,\n }),\n }\n );\n }\n}\n","export class VyomaError extends Error {\n status: number;\n code?: string;\n\n constructor(message: string, status: number, code?: string) {\n super(message);\n this.name = \"VyomaError\";\n this.status = status;\n this.code = code;\n }\n}\n","import { SandboxResource } from \"../resources/sandbox\";\nimport { VyomaError } from \"./error\";\n\nexport interface VyomaClientOptions {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport class VyomaClient {\n private apiKey: string;\n private baseUrl: string;\n\n constructor(options: VyomaClientOptions) {\n if (!options.apiKey) {\n throw new Error(\"Vyoma API key is required\");\n }\n\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl ?? \"http://sandboxd.nakul.space\";\n }\n\n async request<T>(path: string, options: RequestInit = {}): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n ...(options.headers || {}),\n },\n });\n\n if (!res.ok) {\n const data = await res.json().catch(() => null);\n throw new VyomaError(\n data?.error ?? \"Vyoma API error\",\n res.status,\n data?.code\n );\n }\n\n return res.json() as Promise<T>;\n }\n sandbox = new SandboxResource(this);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,QAAqB;AAArB;AAAA,EAAsB;AAAA,EAE1C,OAAO,MAA4B;AACjC,WAAO,KAAK,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU,IAAI;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,KAAK,WAAmB;AACtB,WAAO,KAAK,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU,EAAE,UAAU,CAAC;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAO,WAAmB;AACxB,WAAO,KAAK,OAAO;AAAA,MACjB,iCAAiC,SAAS;AAAA,MAC1C;AAAA,QACE,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MACE,WACA,MACA,SACA;AACA,WAAO,KAAK,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU;AAAA,UACnB;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA,EAEA,KACE,WACA,SACA,KACA;AACA,WAAO,KAAK,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU;AAAA,UACnB;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;;;AC7EO,IAAM,aAAN,cAAyB,MAAM;AAAA,EAIpC,YAAY,SAAiB,QAAgB,MAAe;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;;;ACFO,IAAM,cAAN,MAAkB;AAAA,EAIvB,YAAY,SAA6B;AA8BzC,mBAAU,IAAI,gBAAgB,IAAI;AA7BhC,QAAI,CAAC,QAAQ,QAAQ;AACnB,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAEA,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA,EAEA,MAAM,QAAW,MAAc,UAAuB,CAAC,GAAe;AACpE,UAAM,MAAM,MAAM,MAAM,GAAG,KAAK,OAAO,GAAG,IAAI,IAAI;AAAA,MAChD,GAAG;AAAA,MACH,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,GAAI,QAAQ,WAAW,CAAC;AAAA,MAC1B;AAAA,IACF,CAAC;AAED,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI;AAC9C,YAAM,IAAI;AAAA,QACR,MAAM,SAAS;AAAA,QACf,IAAI;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAEF;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var SandboxResource = class {
|
|
|
5
5
|
}
|
|
6
6
|
create(data) {
|
|
7
7
|
return this.client.request(
|
|
8
|
-
"/sandbox/create",
|
|
8
|
+
"/api/sandbox/create",
|
|
9
9
|
{
|
|
10
10
|
method: "POST",
|
|
11
11
|
body: JSON.stringify(data)
|
|
@@ -14,7 +14,7 @@ var SandboxResource = class {
|
|
|
14
14
|
}
|
|
15
15
|
stop(sandboxId) {
|
|
16
16
|
return this.client.request(
|
|
17
|
-
"/sandbox/stop",
|
|
17
|
+
"/api/sandbox/stop",
|
|
18
18
|
{
|
|
19
19
|
method: "POST",
|
|
20
20
|
body: JSON.stringify({ sandboxId })
|
|
@@ -23,9 +23,48 @@ var SandboxResource = class {
|
|
|
23
23
|
}
|
|
24
24
|
status(sandboxId) {
|
|
25
25
|
return this.client.request(
|
|
26
|
-
`/sandbox/status?sandboxId=${sandboxId}
|
|
26
|
+
`/api/sandbox/status?sandboxId=${sandboxId}`,
|
|
27
|
+
{
|
|
28
|
+
method: "GET"
|
|
29
|
+
}
|
|
27
30
|
);
|
|
28
31
|
}
|
|
32
|
+
write(sandboxId, path, content) {
|
|
33
|
+
return this.client.request(
|
|
34
|
+
"/api/sandbox/write",
|
|
35
|
+
{
|
|
36
|
+
method: "POST",
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
sandboxId,
|
|
39
|
+
path,
|
|
40
|
+
content
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
exec(sandboxId, command, cwd) {
|
|
46
|
+
return this.client.request(
|
|
47
|
+
"/api/sandbox/exec",
|
|
48
|
+
{
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: JSON.stringify({
|
|
51
|
+
sandboxId,
|
|
52
|
+
command,
|
|
53
|
+
cwd
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/core/error.ts
|
|
61
|
+
var VyomaError = class extends Error {
|
|
62
|
+
constructor(message, status, code) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.name = "VyomaError";
|
|
65
|
+
this.status = status;
|
|
66
|
+
this.code = code;
|
|
67
|
+
}
|
|
29
68
|
};
|
|
30
69
|
|
|
31
70
|
// src/core/client.ts
|
|
@@ -36,7 +75,7 @@ var VyomaClient = class {
|
|
|
36
75
|
throw new Error("Vyoma API key is required");
|
|
37
76
|
}
|
|
38
77
|
this.apiKey = options.apiKey;
|
|
39
|
-
this.baseUrl = options.baseUrl ?? "
|
|
78
|
+
this.baseUrl = options.baseUrl ?? "http://sandboxd.nakul.space";
|
|
40
79
|
}
|
|
41
80
|
async request(path, options = {}) {
|
|
42
81
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
@@ -48,8 +87,12 @@ var VyomaClient = class {
|
|
|
48
87
|
}
|
|
49
88
|
});
|
|
50
89
|
if (!res.ok) {
|
|
51
|
-
const
|
|
52
|
-
throw new
|
|
90
|
+
const data = await res.json().catch(() => null);
|
|
91
|
+
throw new VyomaError(
|
|
92
|
+
data?.error ?? "Vyoma API error",
|
|
93
|
+
res.status,
|
|
94
|
+
data?.code
|
|
95
|
+
);
|
|
53
96
|
}
|
|
54
97
|
return res.json();
|
|
55
98
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resources/sandbox.ts","../src/core/client.ts"],"sourcesContent":["import { VyomaClient } from \"../core/client\";\
|
|
1
|
+
{"version":3,"sources":["../src/resources/sandbox.ts","../src/core/error.ts","../src/core/client.ts"],"sourcesContent":["import { VyomaClient } from \"../core/client\";\nimport {\n SandboxCreateRequest,\n SandboxCreateResponse,\n SandboxStatusResponse,\n SandboxStopResponse,\n SandboxWriteResponse,\n SandboxExecResponse,\n} from \"../types/sandbox\";\n\nexport class SandboxResource {\n constructor(private client: VyomaClient) {}\n\n create(data: SandboxCreateRequest) {\n return this.client.request<SandboxCreateResponse>(\n \"/api/sandbox/create\",\n {\n method: \"POST\",\n body: JSON.stringify(data),\n }\n );\n }\n\n stop(sandboxId: string) {\n return this.client.request<SandboxStopResponse>(\n \"/api/sandbox/stop\",\n {\n method: \"POST\",\n body: JSON.stringify({ sandboxId }),\n }\n );\n }\n\n status(sandboxId: string) {\n return this.client.request<SandboxStatusResponse>(\n `/api/sandbox/status?sandboxId=${sandboxId}`,\n {\n method: \"GET\",\n }\n );\n }\n\n write(\n sandboxId: string,\n path: string,\n content: string\n ) {\n return this.client.request<SandboxWriteResponse>(\n \"/api/sandbox/write\",\n {\n method: \"POST\",\n body: JSON.stringify({\n sandboxId,\n path,\n content,\n }),\n }\n );\n }\n\n exec(\n sandboxId: string,\n command: string,\n cwd?: string\n ) {\n return this.client.request<SandboxExecResponse>(\n \"/api/sandbox/exec\",\n {\n method: \"POST\",\n body: JSON.stringify({\n sandboxId,\n command,\n cwd,\n }),\n }\n );\n }\n}\n","export class VyomaError extends Error {\n status: number;\n code?: string;\n\n constructor(message: string, status: number, code?: string) {\n super(message);\n this.name = \"VyomaError\";\n this.status = status;\n this.code = code;\n }\n}\n","import { SandboxResource } from \"../resources/sandbox\";\nimport { VyomaError } from \"./error\";\n\nexport interface VyomaClientOptions {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport class VyomaClient {\n private apiKey: string;\n private baseUrl: string;\n\n constructor(options: VyomaClientOptions) {\n if (!options.apiKey) {\n throw new Error(\"Vyoma API key is required\");\n }\n\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl ?? \"http://sandboxd.nakul.space\";\n }\n\n async request<T>(path: string, options: RequestInit = {}): Promise<T> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n ...(options.headers || {}),\n },\n });\n\n if (!res.ok) {\n const data = await res.json().catch(() => null);\n throw new VyomaError(\n data?.error ?? \"Vyoma API error\",\n res.status,\n data?.code\n );\n }\n\n return res.json() as Promise<T>;\n }\n sandbox = new SandboxResource(this);\n}\n"],"mappings":";AAUO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,QAAqB;AAArB;AAAA,EAAsB;AAAA,EAE1C,OAAO,MAA4B;AACjC,WAAO,KAAK,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA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