@tbrandenburg/node-red-agents 0.1.3 → 0.1.5
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/nodes/agent/agent.js +401 -368
- package/nodes/agent/lib/agents/base.js +31 -31
- package/nodes/agent/lib/agents/opencode.js +127 -120
- package/nodes/agent/lib/agents/pi.js +195 -175
- package/nodes/agent/lib/execution/lifecycle.js +41 -41
- package/nodes/agent/lib/execution/scheduler.js +74 -73
- package/nodes/agent/lib/execution/status.js +10 -10
- package/nodes/agent/lib/mcp/normalize.js +16 -16
- package/nodes/agent/lib/runtimes/base.js +10 -10
- package/nodes/agent/lib/runtimes/direct.js +19 -19
- package/nodes/agent/lib/runtimes/process-exec.js +71 -71
- package/nodes/agent/lib/runtimes/srt.js +40 -40
- package/nodes/agent-server/agent-server.js +495 -458
- package/nodes/agent-server/lib/daemon.js +99 -84
- package/nodes/agent-server/lib/http.js +45 -43
- package/nodes/agent-server/lib/model.js +10 -8
- package/nodes/agent-server/lib/port.js +14 -14
- package/nodes/agent-server/lib/registry.js +54 -54
- package/nodes/agent-server/lib/status.js +6 -6
- package/nodes/gh/README.md +11 -11
- package/nodes/gh/examples/list-pull-requests.json +46 -46
- package/nodes/gh/examples/run-workflow.json +40 -40
- package/nodes/gh/gh.js +220 -211
- package/nodes/gh/lib/parse-args.js +43 -43
- package/package.json +1 -1
- package/shared/srt-settings.js +32 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
// Splits a string of gh CLI arguments into an argv array without any shell
|
|
4
4
|
// evaluation. Single- and double-quoted spans are kept as one argument
|
|
@@ -11,57 +11,57 @@
|
|
|
11
11
|
// 'list --label "needs review"' -> ['list', '--label', 'needs review']
|
|
12
12
|
// 'pr list && rm -rf /' -> ['pr', 'list', '&&', 'rm', '-rf', '/']
|
|
13
13
|
function parseArgs(str) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const args = [];
|
|
20
|
-
let current = '';
|
|
21
|
-
let inArg = false;
|
|
22
|
-
let quote = null; // '"' or "'" while inside a quoted span
|
|
23
|
-
|
|
24
|
-
for (let i = 0; i < str.length; i += 1) {
|
|
25
|
-
const ch = str[i];
|
|
14
|
+
if (str === undefined || str === null) return [];
|
|
15
|
+
if (typeof str !== "string") {
|
|
16
|
+
throw new Error("parseArgs: expected a string, got " + typeof str);
|
|
17
|
+
}
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
current += ch;
|
|
32
|
-
}
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
19
|
+
const args = [];
|
|
20
|
+
let current = "";
|
|
21
|
+
let inArg = false;
|
|
22
|
+
let quote = null; // '"' or "'" while inside a quoted span
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
inArg = true;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r') {
|
|
43
|
-
if (inArg) {
|
|
44
|
-
args.push(current);
|
|
45
|
-
current = '';
|
|
46
|
-
inArg = false;
|
|
47
|
-
}
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
24
|
+
for (let i = 0; i < str.length; i += 1) {
|
|
25
|
+
const ch = str[i];
|
|
50
26
|
|
|
27
|
+
if (quote) {
|
|
28
|
+
if (ch === quote) {
|
|
29
|
+
quote = null;
|
|
30
|
+
} else {
|
|
51
31
|
current += ch;
|
|
52
|
-
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
53
34
|
}
|
|
54
35
|
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
if (ch === '"' || ch === "'") {
|
|
37
|
+
quote = ch;
|
|
38
|
+
inArg = true;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
|
|
43
|
+
if (inArg) {
|
|
61
44
|
args.push(current);
|
|
45
|
+
current = "";
|
|
46
|
+
inArg = false;
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
62
49
|
}
|
|
63
50
|
|
|
64
|
-
|
|
51
|
+
current += ch;
|
|
52
|
+
inArg = true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (quote) {
|
|
56
|
+
// Unterminated quote: fail safe by treating the rest of the
|
|
57
|
+
// string as literal content rather than throwing, since this is
|
|
58
|
+
// config text a user can fix, not something to crash a flow over.
|
|
59
|
+
args.push(current);
|
|
60
|
+
} else if (inArg) {
|
|
61
|
+
args.push(current);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return args;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
module.exports = { parseArgs };
|
package/package.json
CHANGED
package/shared/srt-settings.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const fs = require(
|
|
4
|
-
const os = require(
|
|
5
|
-
const path = require(
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const path = require("path");
|
|
6
6
|
|
|
7
7
|
// Translates the simple "Inline" SRT settings UI (two string lists + one
|
|
8
8
|
// checkbox), used by both the `agent` and `agent-server` nodes, into the
|
|
@@ -25,18 +25,18 @@ const path = require('path');
|
|
|
25
25
|
// "<field>: Required" for each one missing. This function always includes
|
|
26
26
|
// all four.
|
|
27
27
|
function buildSettingsJson({ allowedDomains, allowedWriteDirs, strictAllowlist } = {}) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
return {
|
|
29
|
+
network: {
|
|
30
|
+
allowedDomains: Array.isArray(allowedDomains) ? allowedDomains : [],
|
|
31
|
+
deniedDomains: [],
|
|
32
|
+
strictAllowlist: strictAllowlist !== false,
|
|
33
|
+
},
|
|
34
|
+
filesystem: {
|
|
35
|
+
allowWrite: Array.isArray(allowedWriteDirs) ? allowedWriteDirs : [],
|
|
36
|
+
denyRead: [],
|
|
37
|
+
denyWrite: [],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// config: { allowedDomains, allowedWriteDirs, strictAllowlist, advancedJson }
|
|
@@ -45,14 +45,17 @@ function buildSettingsJson({ allowedDomains, allowedWriteDirs, strictAllowlist }
|
|
|
45
45
|
// writeInlineSettingsFile so tests can check the generated content without
|
|
46
46
|
// needing a real filesystem.
|
|
47
47
|
function resolveSettingsJsonString(config = {}) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const raw =
|
|
49
|
+
config.advancedJson && config.advancedJson.trim()
|
|
50
|
+
? config.advancedJson
|
|
51
|
+
: JSON.stringify(buildSettingsJson(config));
|
|
52
|
+
// Throws a clear SyntaxError if the (usually hand-edited advanced) JSON
|
|
53
|
+
// is invalid -- deliberately no deeper validation than "is this valid
|
|
54
|
+
// JSON"; srt's own runtime error for a structurally-wrong-but-valid-JSON
|
|
55
|
+
// settings file is already clear and surfaces through the normal
|
|
56
|
+
// execution/spawn-failure path.
|
|
57
|
+
JSON.parse(raw);
|
|
58
|
+
return raw;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
// nodeId is used only to make the temp filename recognizable/stable per
|
|
@@ -61,11 +64,11 @@ function resolveSettingsJsonString(config = {}) {
|
|
|
61
64
|
// filePrefix distinguishes callers (e.g. 'agent' vs 'agent-server') so two
|
|
62
65
|
// different node types configuring the same nodeId-shaped id can never
|
|
63
66
|
// collide on the same temp file.
|
|
64
|
-
function writeInlineSettingsFile(nodeId, config, filePrefix =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
function writeInlineSettingsFile(nodeId, config, filePrefix = "srt-settings") {
|
|
68
|
+
const json = resolveSettingsJsonString(config);
|
|
69
|
+
const filePath = path.join(os.tmpdir(), `${filePrefix}-${nodeId}-${process.pid}.json`);
|
|
70
|
+
fs.writeFileSync(filePath, json);
|
|
71
|
+
return filePath;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
module.exports = { buildSettingsJson, resolveSettingsJsonString, writeInlineSettingsFile };
|