n8n-nodes-daytona-tool 0.1.6 → 0.1.8
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/README.md +1 -0
- package/dist/index.js +2 -0
- package/dist/lib/daytonaClient.d.ts +1 -0
- package/dist/lib/daytonaClient.js +17 -8
- package/dist/nodes/Daytona/ExecuteCommand.node.d.ts +5 -0
- package/dist/nodes/Daytona/ExecuteCommand.node.js +157 -0
- package/dist/nodes/nodes/Daytona/ExecuteCommand.node.json +20 -0
- package/package.json +3 -2
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const RunCode_node_1 = require("./nodes/Daytona/RunCode.node");
|
|
|
8
8
|
const StartSandbox_node_1 = require("./nodes/Daytona/StartSandbox.node");
|
|
9
9
|
const StopSandbox_node_1 = require("./nodes/Daytona/StopSandbox.node");
|
|
10
10
|
const UploadFile_node_1 = require("./nodes/Daytona/UploadFile.node");
|
|
11
|
+
const ExecuteCommand_node_1 = require("./nodes/Daytona/ExecuteCommand.node");
|
|
11
12
|
exports.credentials = [new DaytonaApi_credentials_1.DaytonaApi()];
|
|
12
13
|
exports.nodes = [
|
|
13
14
|
new CreateSandbox_node_1.CreateSandbox(),
|
|
@@ -16,4 +17,5 @@ exports.nodes = [
|
|
|
16
17
|
new StartSandbox_node_1.StartSandbox(),
|
|
17
18
|
new StopSandbox_node_1.StopSandbox(),
|
|
18
19
|
new UploadFile_node_1.UploadFile(),
|
|
20
|
+
new ExecuteCommand_node_1.ExecuteCommand(),
|
|
19
21
|
];
|
|
@@ -18,6 +18,7 @@ export declare const runNodeCode: (sandbox: any, code: string, timeoutMs?: numbe
|
|
|
18
18
|
export declare const disposeSandbox: (sandbox: any) => Promise<any>;
|
|
19
19
|
export declare const startSandbox: (sandbox: any) => Promise<any>;
|
|
20
20
|
export declare const stopSandbox: (sandbox: any) => Promise<any>;
|
|
21
|
+
export declare const executeSandboxCommand: (sandbox: any, command: string, cwd?: string, env?: Record<string, string>, timeoutSeconds?: number) => Promise<any>;
|
|
21
22
|
export declare const createSandboxFile: (content: string, name: string, contentType?: string) => Readable;
|
|
22
23
|
export declare const uploadSandboxFile: (sandbox: any, remotePath: string, file: any) => Promise<any>;
|
|
23
24
|
export declare const uploadSandboxFileFromContent: (sandbox: any, remotePath: string, content: string, fileName: string) => Promise<any>;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uploadSandboxFileFromContent = exports.uploadSandboxFile = exports.createSandboxFile = exports.stopSandbox = exports.startSandbox = exports.disposeSandbox = exports.runNodeCode = exports.getSandboxByName = exports.getSandbox = exports.createSandbox = exports.createDaytonaClient = void 0;
|
|
6
|
+
exports.uploadSandboxFileFromContent = exports.uploadSandboxFile = exports.createSandboxFile = exports.executeSandboxCommand = exports.stopSandbox = exports.startSandbox = exports.disposeSandbox = exports.runNodeCode = exports.getSandboxByName = exports.getSandbox = exports.createSandbox = exports.createDaytonaClient = void 0;
|
|
7
7
|
const sdk_1 = require("@daytonaio/sdk");
|
|
8
8
|
const node_stream_1 = require("node:stream");
|
|
9
9
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
@@ -66,15 +66,14 @@ const getSandboxByName = async (client, name) => {
|
|
|
66
66
|
};
|
|
67
67
|
exports.getSandboxByName = getSandboxByName;
|
|
68
68
|
const runNodeCode = async (sandbox, code, timeoutMs) => {
|
|
69
|
-
var _a
|
|
69
|
+
var _a;
|
|
70
70
|
const processApi = (_a = sandbox === null || sandbox === void 0 ? void 0 : sandbox.process) !== null && _a !== void 0 ? _a : sandbox;
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
73
|
-
throw new Error('Daytona SDK:
|
|
71
|
+
const codeRunFn = processApi === null || processApi === void 0 ? void 0 : processApi.codeRun;
|
|
72
|
+
if (!codeRunFn) {
|
|
73
|
+
throw new Error('Daytona SDK: codeRun method not found.');
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
return executeFn.call(processApi, command, options);
|
|
75
|
+
const timeoutSeconds = timeoutMs ? Math.ceil(timeoutMs / 1000) : undefined;
|
|
76
|
+
return codeRunFn.call(processApi, code, undefined, timeoutSeconds);
|
|
78
77
|
};
|
|
79
78
|
exports.runNodeCode = runNodeCode;
|
|
80
79
|
const disposeSandbox = async (sandbox) => {
|
|
@@ -101,6 +100,16 @@ const stopSandbox = async (sandbox) => {
|
|
|
101
100
|
return stopFn.call(sandbox);
|
|
102
101
|
};
|
|
103
102
|
exports.stopSandbox = stopSandbox;
|
|
103
|
+
const executeSandboxCommand = async (sandbox, command, cwd, env, timeoutSeconds) => {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
const processApi = (_a = sandbox === null || sandbox === void 0 ? void 0 : sandbox.process) !== null && _a !== void 0 ? _a : sandbox;
|
|
106
|
+
const executeFn = (_b = processApi === null || processApi === void 0 ? void 0 : processApi.executeCommand) !== null && _b !== void 0 ? _b : processApi === null || processApi === void 0 ? void 0 : processApi.runCommand;
|
|
107
|
+
if (!executeFn) {
|
|
108
|
+
throw new Error('Daytona SDK: execute command method not found.');
|
|
109
|
+
}
|
|
110
|
+
return executeFn.call(processApi, command, cwd, env, timeoutSeconds);
|
|
111
|
+
};
|
|
112
|
+
exports.executeSandboxCommand = executeSandboxCommand;
|
|
104
113
|
const createSandboxFile = (content, name, contentType) => {
|
|
105
114
|
const buffer = Buffer.from(content, 'utf8');
|
|
106
115
|
const stream = node_stream_1.Readable.from(buffer);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class ExecuteCommand implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecuteCommand = void 0;
|
|
4
|
+
const daytonaClient_1 = require("../../lib/daytonaClient");
|
|
5
|
+
class ExecuteCommand {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Daytona Execute Command',
|
|
9
|
+
name: 'daytonaExecuteCommand',
|
|
10
|
+
group: ['transform'],
|
|
11
|
+
version: 1,
|
|
12
|
+
description: 'Execute a shell command in a Daytona sandbox.',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: 'Daytona Execute Command',
|
|
15
|
+
},
|
|
16
|
+
inputs: ['main'],
|
|
17
|
+
outputs: ['main'],
|
|
18
|
+
usableAsTool: true,
|
|
19
|
+
credentials: [
|
|
20
|
+
{
|
|
21
|
+
name: 'daytonaApi',
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
properties: [
|
|
26
|
+
{
|
|
27
|
+
displayName: 'Identifier',
|
|
28
|
+
name: 'identifier',
|
|
29
|
+
type: 'string',
|
|
30
|
+
default: '',
|
|
31
|
+
required: true,
|
|
32
|
+
description: 'Sandbox ID or name.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
displayName: 'Identifier Type',
|
|
36
|
+
name: 'identifierType',
|
|
37
|
+
type: 'options',
|
|
38
|
+
default: 'id',
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
name: 'ID',
|
|
42
|
+
value: 'id',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Name',
|
|
46
|
+
value: 'name',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Command',
|
|
52
|
+
name: 'command',
|
|
53
|
+
type: 'string',
|
|
54
|
+
typeOptions: {
|
|
55
|
+
rows: 4,
|
|
56
|
+
},
|
|
57
|
+
default: '',
|
|
58
|
+
required: true,
|
|
59
|
+
description: 'Shell command to execute.',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Working Directory',
|
|
63
|
+
name: 'cwd',
|
|
64
|
+
type: 'string',
|
|
65
|
+
default: '',
|
|
66
|
+
description: 'Optional working directory (for example: workspace).',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: 'Env Vars',
|
|
70
|
+
name: 'envVars',
|
|
71
|
+
type: 'fixedCollection',
|
|
72
|
+
typeOptions: {
|
|
73
|
+
multipleValues: true,
|
|
74
|
+
},
|
|
75
|
+
default: {},
|
|
76
|
+
description: 'Environment variables for the command.',
|
|
77
|
+
options: [
|
|
78
|
+
{
|
|
79
|
+
name: 'entries',
|
|
80
|
+
displayName: 'Entry',
|
|
81
|
+
values: [
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Key',
|
|
84
|
+
name: 'key',
|
|
85
|
+
type: 'string',
|
|
86
|
+
default: '',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Value',
|
|
90
|
+
name: 'value',
|
|
91
|
+
type: 'string',
|
|
92
|
+
default: '',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
displayName: 'Timeout (seconds)',
|
|
100
|
+
name: 'timeoutSeconds',
|
|
101
|
+
type: 'number',
|
|
102
|
+
default: 0,
|
|
103
|
+
description: 'Maximum time in seconds to wait. 0 waits indefinitely.',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async execute() {
|
|
109
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
110
|
+
const items = this.getInputData();
|
|
111
|
+
const credentials = await this.getCredentials('daytonaApi');
|
|
112
|
+
const client = (0, daytonaClient_1.createDaytonaClient)({
|
|
113
|
+
baseUrl: credentials.baseUrl,
|
|
114
|
+
token: credentials.token,
|
|
115
|
+
});
|
|
116
|
+
const returnData = [];
|
|
117
|
+
for (let i = 0; i < items.length; i++) {
|
|
118
|
+
const identifier = this.getNodeParameter('identifier', i);
|
|
119
|
+
const identifierType = this.getNodeParameter('identifierType', i);
|
|
120
|
+
const command = this.getNodeParameter('command', i);
|
|
121
|
+
const cwd = this.getNodeParameter('cwd', i) || undefined;
|
|
122
|
+
const timeoutSeconds = this.getNodeParameter('timeoutSeconds', i);
|
|
123
|
+
const envVarsRaw = this.getNodeParameter('envVars', i);
|
|
124
|
+
const envVars = ((_a = envVarsRaw === null || envVarsRaw === void 0 ? void 0 : envVarsRaw.entries) === null || _a === void 0 ? void 0 : _a.length)
|
|
125
|
+
? envVarsRaw.entries.reduce((acc, entry) => {
|
|
126
|
+
var _a;
|
|
127
|
+
const key = ((entry === null || entry === void 0 ? void 0 : entry.key) || '').trim();
|
|
128
|
+
if (!key) {
|
|
129
|
+
return acc;
|
|
130
|
+
}
|
|
131
|
+
acc[key] = (_a = entry === null || entry === void 0 ? void 0 : entry.value) !== null && _a !== void 0 ? _a : '';
|
|
132
|
+
return acc;
|
|
133
|
+
}, {})
|
|
134
|
+
: undefined;
|
|
135
|
+
const sandbox = identifierType === 'name'
|
|
136
|
+
? await (0, daytonaClient_1.getSandboxByName)(client, identifier)
|
|
137
|
+
: await (0, daytonaClient_1.getSandbox)(client, identifier);
|
|
138
|
+
const result = await (0, daytonaClient_1.executeSandboxCommand)(sandbox, command, cwd, envVars, timeoutSeconds > 0 ? timeoutSeconds : undefined);
|
|
139
|
+
returnData.push({
|
|
140
|
+
json: {
|
|
141
|
+
identifier,
|
|
142
|
+
identifierType,
|
|
143
|
+
sandboxId: (_c = (_b = sandbox === null || sandbox === void 0 ? void 0 : sandbox.id) !== null && _b !== void 0 ? _b : sandbox === null || sandbox === void 0 ? void 0 : sandbox.sandboxId) !== null && _c !== void 0 ? _c : (_d = sandbox === null || sandbox === void 0 ? void 0 : sandbox.metadata) === null || _d === void 0 ? void 0 : _d.id,
|
|
144
|
+
name: (_e = sandbox === null || sandbox === void 0 ? void 0 : sandbox.name) !== null && _e !== void 0 ? _e : (_f = sandbox === null || sandbox === void 0 ? void 0 : sandbox.metadata) === null || _f === void 0 ? void 0 : _f.name,
|
|
145
|
+
command,
|
|
146
|
+
cwd,
|
|
147
|
+
exitCode: (_h = (_g = result === null || result === void 0 ? void 0 : result.exitCode) !== null && _g !== void 0 ? _g : result === null || result === void 0 ? void 0 : result.code) !== null && _h !== void 0 ? _h : result === null || result === void 0 ? void 0 : result.status,
|
|
148
|
+
stdout: (_k = (_j = result === null || result === void 0 ? void 0 : result.stdout) !== null && _j !== void 0 ? _j : result === null || result === void 0 ? void 0 : result.result) !== null && _k !== void 0 ? _k : result === null || result === void 0 ? void 0 : result.output,
|
|
149
|
+
stderr: (_l = result === null || result === void 0 ? void 0 : result.stderr) !== null && _l !== void 0 ? _l : result === null || result === void 0 ? void 0 : result.error,
|
|
150
|
+
raw: result !== null && result !== void 0 ? result : null,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return [returnData];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.ExecuteCommand = ExecuteCommand;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-daytona-tool.ExecuteCommand",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": [
|
|
6
|
+
"Development"
|
|
7
|
+
],
|
|
8
|
+
"resources": {
|
|
9
|
+
"credentialDocumentation": [
|
|
10
|
+
{
|
|
11
|
+
"url": "https://www.daytona.io/docs/en/typescript-sdk/process/"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"primaryDocumentation": [
|
|
15
|
+
{
|
|
16
|
+
"url": "https://www.daytona.io/docs/en/typescript-sdk/process/"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-daytona-tool",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "n8n community nodes for running code in Daytona sandboxes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"dist/nodes/Daytona/DisposeSandbox.node.js",
|
|
48
48
|
"dist/nodes/Daytona/StartSandbox.node.js",
|
|
49
49
|
"dist/nodes/Daytona/StopSandbox.node.js",
|
|
50
|
-
"dist/nodes/Daytona/UploadFile.node.js"
|
|
50
|
+
"dist/nodes/Daytona/UploadFile.node.js",
|
|
51
|
+
"dist/nodes/Daytona/ExecuteCommand.node.js"
|
|
51
52
|
]
|
|
52
53
|
}
|
|
53
54
|
}
|