@capsule-run/sdk 0.6.0 → 0.6.2
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/run.d.ts.map +1 -1
- package/dist/run.js +17 -1
- package/dist/run.js.map +1 -1
- package/package.json +2 -1
- package/src/run.ts +20 -1
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;IAClD,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACtD,SAAS,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;IAClD,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACtD,SAAS,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAYD;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA0CjE"}
|
package/dist/run.js
CHANGED
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
import { execFile } from 'child_process';
|
|
8
8
|
import { resolve } from 'path';
|
|
9
9
|
import { existsSync } from 'fs';
|
|
10
|
+
/**
|
|
11
|
+
* Get the appropriate capsule command for the current platform
|
|
12
|
+
*/
|
|
13
|
+
function getCapsuleCommand(capsulePath) {
|
|
14
|
+
if (process.platform === 'win32' && !capsulePath.endsWith('.cmd')) {
|
|
15
|
+
return `${capsulePath}.cmd`;
|
|
16
|
+
}
|
|
17
|
+
return capsulePath;
|
|
18
|
+
}
|
|
10
19
|
/**
|
|
11
20
|
* Run a Capsule task from a third-party application
|
|
12
21
|
*
|
|
@@ -15,13 +24,20 @@ import { existsSync } from 'fs';
|
|
|
15
24
|
*/
|
|
16
25
|
export function run(options) {
|
|
17
26
|
const { file, args = [], cwd, capsulePath = 'capsule' } = options;
|
|
27
|
+
const command = getCapsuleCommand(capsulePath);
|
|
18
28
|
const resolvedFile = resolve(cwd || process.cwd(), file);
|
|
19
29
|
if (!existsSync(resolvedFile)) {
|
|
20
30
|
return Promise.reject(new Error(`File not found: ${resolvedFile}`));
|
|
21
31
|
}
|
|
22
32
|
return new Promise((resolve, reject) => {
|
|
23
33
|
const cmdArgs = ['run', resolvedFile, '--json', ...args];
|
|
24
|
-
|
|
34
|
+
let executable = command;
|
|
35
|
+
let executionArgs = cmdArgs;
|
|
36
|
+
if (process.platform === 'win32') {
|
|
37
|
+
executable = process.env.comspec || 'cmd.exe';
|
|
38
|
+
executionArgs = ['/d', '/s', '/c', command, ...cmdArgs];
|
|
39
|
+
}
|
|
40
|
+
execFile(executable, executionArgs, { cwd, encoding: 'utf-8' }, (error, stdout, stderr) => {
|
|
25
41
|
if (error && !stdout) {
|
|
26
42
|
if (error.code === 'ENOENT') {
|
|
27
43
|
reject(new Error(`Capsule CLI not found. Use 'npm install -g @capsule-run/cli' to install it.`));
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAqBhC;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,OAAsB;IACxC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAqBhC;;GAEG;AACH,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClE,OAAO,GAAG,WAAW,MAAM,CA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AC;oBACvD,MAAM,CAAC,IAAI,KAAK,CACd,6EAA6E,CAC9E,CAAC,CAAC;oBACH,OAAO;gBACT,CAAC;gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC3C,OAAO;YACT,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,CAAC,IAAI,KAAK,CAAC,mCAAmC,MAAM,EAAE,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capsule-run/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Capsule JavaScript SDK - run AI agent tasks in secure WASM sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/events": "^3.0.3",
|
|
55
|
+
"@types/node": "^25.2.3",
|
|
55
56
|
"@types/path-browserify": "^1.0.3",
|
|
56
57
|
"@types/readable-stream": "^4.0.18"
|
|
57
58
|
},
|
package/src/run.ts
CHANGED
|
@@ -28,6 +28,16 @@ export interface RunnerResult {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Get the appropriate capsule command for the current platform
|
|
33
|
+
*/
|
|
34
|
+
function getCapsuleCommand(capsulePath: string): string {
|
|
35
|
+
if (process.platform === 'win32' && !capsulePath.endsWith('.cmd')) {
|
|
36
|
+
return `${capsulePath}.cmd`;
|
|
37
|
+
}
|
|
38
|
+
return capsulePath;
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
/**
|
|
32
42
|
* Run a Capsule task from a third-party application
|
|
33
43
|
*
|
|
@@ -36,6 +46,7 @@ export interface RunnerResult {
|
|
|
36
46
|
*/
|
|
37
47
|
export function run(options: RunnerOptions): Promise<RunnerResult> {
|
|
38
48
|
const { file, args = [], cwd, capsulePath = 'capsule' } = options;
|
|
49
|
+
const command = getCapsuleCommand(capsulePath);
|
|
39
50
|
|
|
40
51
|
const resolvedFile = resolve(cwd || process.cwd(), file);
|
|
41
52
|
|
|
@@ -46,7 +57,15 @@ export function run(options: RunnerOptions): Promise<RunnerResult> {
|
|
|
46
57
|
return new Promise((resolve, reject) => {
|
|
47
58
|
const cmdArgs = ['run', resolvedFile, '--json', ...args];
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
let executable = command;
|
|
61
|
+
let executionArgs = cmdArgs;
|
|
62
|
+
|
|
63
|
+
if (process.platform === 'win32') {
|
|
64
|
+
executable = process.env.comspec || 'cmd.exe';
|
|
65
|
+
executionArgs = ['/d', '/s', '/c', command, ...cmdArgs];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
execFile(executable, executionArgs, { cwd, encoding: 'utf-8' }, (error, stdout, stderr) => {
|
|
50
69
|
if (error && !stdout) {
|
|
51
70
|
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
52
71
|
reject(new Error(
|