@lazyingart/agintiflow 0.1.0
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/AGENTS.md +41 -0
- package/LICENSE +201 -0
- package/README.md +294 -0
- package/bin/aginti-cli.js +7 -0
- package/docker/sandbox.Dockerfile +22 -0
- package/docs/npm-publishing.md +45 -0
- package/i18n/README.ar.md +51 -0
- package/i18n/README.de.md +51 -0
- package/i18n/README.es.md +51 -0
- package/i18n/README.fr.md +51 -0
- package/i18n/README.ja.md +51 -0
- package/i18n/README.ko.md +51 -0
- package/i18n/README.ru.md +51 -0
- package/i18n/README.vi.md +51 -0
- package/i18n/README.zh-Hans.md +51 -0
- package/i18n/README.zh-Hant.md +171 -0
- package/logos/banner-opaque.png +0 -0
- package/logos/logo.png +0 -0
- package/package.json +62 -0
- package/public/app.js +1060 -0
- package/public/index.html +198 -0
- package/public/styles.css +305 -0
- package/run.js +6 -0
- package/scripts/install-docker-ubuntu.sh +140 -0
- package/src/agent-runner.js +686 -0
- package/src/cli.js +181 -0
- package/src/command-policy.js +185 -0
- package/src/config.js +89 -0
- package/src/docker-sandbox.js +309 -0
- package/src/guardrails.js +122 -0
- package/src/model-client.js +212 -0
- package/src/model-routing.js +135 -0
- package/src/redaction.js +29 -0
- package/src/session-store.js +73 -0
- package/src/snapshot.js +55 -0
- package/src/tool-wrappers.js +193 -0
- package/src/web-db.js +158 -0
- package/web.js +530 -0
package/src/cli.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { runAgent } from "./agent-runner.js";
|
|
2
|
+
import { loadConfig } from "./config.js";
|
|
3
|
+
import { listAgentWrappers } from "./tool-wrappers.js";
|
|
4
|
+
import { getModelPresets } from "./model-routing.js";
|
|
5
|
+
import { getDockerSandboxStatus, runDockerPreflight } from "./docker-sandbox.js";
|
|
6
|
+
|
|
7
|
+
function readOption(argv, index) {
|
|
8
|
+
const value = argv[index + 1];
|
|
9
|
+
if (!value || value.startsWith("--")) return "";
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function parseArgs(argv) {
|
|
14
|
+
const result = {
|
|
15
|
+
goal: "",
|
|
16
|
+
startUrl: "",
|
|
17
|
+
resume: "",
|
|
18
|
+
sessionId: "",
|
|
19
|
+
provider: "",
|
|
20
|
+
model: "",
|
|
21
|
+
routingMode: "",
|
|
22
|
+
commandCwd: "",
|
|
23
|
+
sandboxMode: "",
|
|
24
|
+
packageInstallPolicy: "",
|
|
25
|
+
allowShellTool: undefined,
|
|
26
|
+
allowWrapperTools: undefined,
|
|
27
|
+
useDockerSandbox: undefined,
|
|
28
|
+
headless: undefined,
|
|
29
|
+
maxSteps: undefined,
|
|
30
|
+
listRoutes: false,
|
|
31
|
+
listWrappers: false,
|
|
32
|
+
sandboxStatus: false,
|
|
33
|
+
sandboxPreflight: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const parts = [];
|
|
37
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
38
|
+
const arg = argv[i];
|
|
39
|
+
if (arg === "--start-url") {
|
|
40
|
+
result.startUrl = readOption(argv, i);
|
|
41
|
+
i += 1;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (arg === "--resume") {
|
|
45
|
+
result.resume = readOption(argv, i);
|
|
46
|
+
i += 1;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (arg === "--session-id") {
|
|
50
|
+
result.sessionId = readOption(argv, i);
|
|
51
|
+
i += 1;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (arg === "--provider") {
|
|
55
|
+
result.provider = readOption(argv, i);
|
|
56
|
+
i += 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (arg === "--model") {
|
|
60
|
+
result.model = readOption(argv, i);
|
|
61
|
+
i += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (arg === "--routing") {
|
|
65
|
+
result.routingMode = readOption(argv, i);
|
|
66
|
+
i += 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (arg === "--cwd") {
|
|
70
|
+
result.commandCwd = readOption(argv, i);
|
|
71
|
+
i += 1;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (arg === "--sandbox-mode") {
|
|
75
|
+
result.sandboxMode = readOption(argv, i);
|
|
76
|
+
i += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (arg === "--package-install-policy") {
|
|
80
|
+
result.packageInstallPolicy = readOption(argv, i);
|
|
81
|
+
i += 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (arg === "--approve-package-installs") {
|
|
85
|
+
result.packageInstallPolicy = "allow";
|
|
86
|
+
result.sandboxMode = result.sandboxMode || "docker-workspace";
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (arg === "--max-steps") {
|
|
90
|
+
result.maxSteps = Number(readOption(argv, i));
|
|
91
|
+
i += 1;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (arg === "--allow-shell") {
|
|
95
|
+
result.allowShellTool = true;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (arg === "--allow-wrappers") {
|
|
99
|
+
result.allowWrapperTools = true;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (arg === "--docker-sandbox") {
|
|
103
|
+
result.useDockerSandbox = true;
|
|
104
|
+
result.sandboxMode = result.sandboxMode || "docker-readonly";
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (arg === "--headless") {
|
|
108
|
+
result.headless = true;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (arg === "--list-routes") {
|
|
112
|
+
result.listRoutes = true;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (arg === "--list-wrappers") {
|
|
116
|
+
result.listWrappers = true;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (arg === "--sandbox-status") {
|
|
120
|
+
result.sandboxStatus = true;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (arg === "--sandbox-preflight") {
|
|
124
|
+
result.sandboxPreflight = true;
|
|
125
|
+
result.useDockerSandbox = true;
|
|
126
|
+
result.sandboxMode = result.sandboxMode || "docker-readonly";
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
parts.push(arg);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
result.goal = parts.join(" ").trim();
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function printRoutes() {
|
|
137
|
+
const presets = getModelPresets();
|
|
138
|
+
for (const preset of Object.values(presets)) {
|
|
139
|
+
const reasoning = preset.reasoning ? ` reasoning=${preset.reasoning}` : "";
|
|
140
|
+
console.log(`${preset.id}: provider=${preset.provider} model=${preset.model}${reasoning} - ${preset.description}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function printWrappers() {
|
|
145
|
+
for (const wrapper of listAgentWrappers()) {
|
|
146
|
+
console.log(`${wrapper.name}: ${wrapper.available ? "available" : "missing"} - ${wrapper.role}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
151
|
+
const args = parseArgs(argv);
|
|
152
|
+
|
|
153
|
+
if (args.listRoutes) {
|
|
154
|
+
printRoutes();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (args.listWrappers) {
|
|
159
|
+
printWrappers();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (args.sandboxStatus || args.sandboxPreflight) {
|
|
164
|
+
const config = loadConfig({ ...args, goal: args.goal || "sandbox preflight" });
|
|
165
|
+
const result = args.sandboxPreflight
|
|
166
|
+
? await runDockerPreflight(config, { buildImage: true })
|
|
167
|
+
: { ok: true, status: await getDockerSandboxStatus(config) };
|
|
168
|
+
console.log(JSON.stringify(result, null, 2));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!args.goal && !args.resume) {
|
|
173
|
+
console.error(
|
|
174
|
+
'Usage: aginti-cli [--routing smart|fast|complex|manual] [--sandbox-mode host|docker-readonly|docker-workspace] [--package-install-policy block|prompt|allow] [--allow-shell] [--allow-wrappers] [--sandbox-status|--sandbox-preflight] "your task"'
|
|
175
|
+
);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const config = loadConfig(args);
|
|
180
|
+
await runAgent(config);
|
|
181
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export const SANDBOX_MODES = ["host", "docker-readonly", "docker-workspace"];
|
|
2
|
+
export const PACKAGE_INSTALL_POLICIES = ["block", "prompt", "allow"];
|
|
3
|
+
|
|
4
|
+
const READ_ONLY_PATTERNS = [
|
|
5
|
+
/^pwd$/,
|
|
6
|
+
/^date$/,
|
|
7
|
+
/^whoami$/,
|
|
8
|
+
/^uname(?:\s+-a)?$/,
|
|
9
|
+
/^ls(?:\s+[-\w./~*]+)*$/,
|
|
10
|
+
/^find(?:\s+[./~\w-]+)*(?:\s+-maxdepth\s+\d+)?(?:\s+-type\s+[fd])?$/,
|
|
11
|
+
/^rg(?:\s+.+)?$/,
|
|
12
|
+
/^cat(?:\s+[-\w./~*]+)+$/,
|
|
13
|
+
/^head(?:\s+.+)?$/,
|
|
14
|
+
/^tail(?:\s+.+)?$/,
|
|
15
|
+
/^wc(?:\s+.+)?$/,
|
|
16
|
+
/^sed\s+-n\s+['"0-9,:p\s-]+\s+[-\w./~*]+$/,
|
|
17
|
+
/^git\s+(status|branch|log|show|diff(?:\s+--stat)?|remote\s+-v)(?:\s+.+)?$/,
|
|
18
|
+
/^node\s+-v$/,
|
|
19
|
+
/^npm\s+-v$/,
|
|
20
|
+
/^python(?:3)?\s+--version$/,
|
|
21
|
+
/^pip(?:3)?\s+--version$/,
|
|
22
|
+
/^conda\s+--version$/,
|
|
23
|
+
/^echo(?:\s+.+)?$/,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const TEST_PATTERNS = [
|
|
27
|
+
/^npm\s+(run\s+)?(check|test|build|lint)(?:\s+--\s+[-\w./:=]+)*$/,
|
|
28
|
+
/^npm\s+test$/,
|
|
29
|
+
/^node\s+--check\s+[-\w./]+$/,
|
|
30
|
+
/^python(?:3)?\s+-m\s+pytest(?:\s+[-\w./:=]+)*$/,
|
|
31
|
+
/^pytest(?:\s+[-\w./:=]+)*$/,
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const PACKAGE_INSTALL_PATTERNS = [
|
|
35
|
+
/^npm\s+ci$/,
|
|
36
|
+
/^npm\s+install$/,
|
|
37
|
+
/^pnpm\s+install$/,
|
|
38
|
+
/^yarn\s+install$/,
|
|
39
|
+
/^python(?:3)?\s+-m\s+pip\s+install\s+-r\s+[-\w./]+$/,
|
|
40
|
+
/^pip(?:3)?\s+install\s+-r\s+[-\w./]+$/,
|
|
41
|
+
/^conda\s+env\s+(create|update)\s+-f\s+[-\w./]+$/,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const ENV_SETUP_PATTERNS = [
|
|
45
|
+
/^python(?:3)?\s+-m\s+venv\s+\.venv$/,
|
|
46
|
+
/^python(?:3)?\s+-m\s+venv\s+venv$/,
|
|
47
|
+
/^npm\s+init\s+-y$/,
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const BLOCKED_SHELL_TOKENS = ["&&", "||", ";", "|", ">", "<", "$(", "`"];
|
|
51
|
+
const BLOCKED_WRITE_TOKENS = [
|
|
52
|
+
"sudo ",
|
|
53
|
+
" rm",
|
|
54
|
+
" mv",
|
|
55
|
+
" cp",
|
|
56
|
+
" chmod",
|
|
57
|
+
" chown",
|
|
58
|
+
" mkdir",
|
|
59
|
+
" rmdir",
|
|
60
|
+
" touch",
|
|
61
|
+
" tee",
|
|
62
|
+
"-delete",
|
|
63
|
+
"git add",
|
|
64
|
+
"git commit",
|
|
65
|
+
"git push",
|
|
66
|
+
"git pull",
|
|
67
|
+
"git checkout",
|
|
68
|
+
"git switch",
|
|
69
|
+
"git reset",
|
|
70
|
+
"git clean",
|
|
71
|
+
"curl ",
|
|
72
|
+
"wget ",
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const ALWAYS_BLOCKED_PATTERNS = [
|
|
76
|
+
/^npm\s+publish\b/i,
|
|
77
|
+
/^npm\s+token\b/i,
|
|
78
|
+
/^npm\s+(login|adduser)\b/i,
|
|
79
|
+
/^npm\s+config\s+set\s+.*(?:_authToken|token)\b/i,
|
|
80
|
+
/NPM_TOKEN\s*=/i,
|
|
81
|
+
/_authToken\s*=/i,
|
|
82
|
+
/OPENAI_API_KEY\s*=/i,
|
|
83
|
+
/DEEPSEEK_API_KEY\s*=/i,
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
function normalizePolicy(value, allowed, fallback) {
|
|
87
|
+
return allowed.includes(value) ? value : fallback;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function normalizeSandboxMode(value) {
|
|
91
|
+
return normalizePolicy(value, SANDBOX_MODES, "host");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function normalizePackageInstallPolicy(value) {
|
|
95
|
+
return normalizePolicy(value, PACKAGE_INSTALL_POLICIES, "prompt");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function matchAny(patterns, command) {
|
|
99
|
+
return patterns.some((pattern) => pattern.test(command));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function classifyCommand(command) {
|
|
103
|
+
const normalized = String(command || "").trim();
|
|
104
|
+
if (!normalized) return { category: "blocked", reason: "Command is empty." };
|
|
105
|
+
|
|
106
|
+
if (ALWAYS_BLOCKED_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
|
107
|
+
return { category: "blocked", reason: "Command is blocked because it may expose secrets or publish packages." };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const lowered = ` ${normalized.toLowerCase()} `;
|
|
111
|
+
if (BLOCKED_SHELL_TOKENS.some((part) => normalized.includes(part))) {
|
|
112
|
+
return { category: "blocked", reason: `Command contains blocked shell syntax: ${normalized}` };
|
|
113
|
+
}
|
|
114
|
+
if (BLOCKED_WRITE_TOKENS.some((part) => lowered.includes(part))) {
|
|
115
|
+
return { category: "blocked", reason: `Command contains a write-capable or network token: ${normalized}` };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (matchAny(READ_ONLY_PATTERNS, normalized)) {
|
|
119
|
+
return { category: "read-only", needsNetwork: false, writesWorkspace: false };
|
|
120
|
+
}
|
|
121
|
+
if (matchAny(TEST_PATTERNS, normalized)) {
|
|
122
|
+
return { category: "test", needsNetwork: false, writesWorkspace: false };
|
|
123
|
+
}
|
|
124
|
+
if (matchAny(PACKAGE_INSTALL_PATTERNS, normalized)) {
|
|
125
|
+
return { category: "package-install", needsNetwork: true, writesWorkspace: true };
|
|
126
|
+
}
|
|
127
|
+
if (matchAny(ENV_SETUP_PATTERNS, normalized)) {
|
|
128
|
+
return { category: "env-setup", needsNetwork: false, writesWorkspace: true };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { category: "blocked", reason: `Command is outside the execution allowlist: ${normalized}` };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function evaluateCommandPolicy(command, config) {
|
|
135
|
+
const classification = classifyCommand(command);
|
|
136
|
+
const sandboxMode = normalizeSandboxMode(config.sandboxMode);
|
|
137
|
+
const packageInstallPolicy = normalizePackageInstallPolicy(config.packageInstallPolicy);
|
|
138
|
+
|
|
139
|
+
if (classification.category === "blocked") {
|
|
140
|
+
return { allowed: false, ...classification, sandboxMode, packageInstallPolicy };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!config.allowShellTool) {
|
|
144
|
+
return {
|
|
145
|
+
allowed: false,
|
|
146
|
+
category: classification.category,
|
|
147
|
+
reason: "Shell tool is disabled for this run.",
|
|
148
|
+
sandboxMode,
|
|
149
|
+
packageInstallPolicy,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (classification.category === "package-install" || classification.category === "env-setup") {
|
|
154
|
+
if (packageInstallPolicy !== "allow") {
|
|
155
|
+
return {
|
|
156
|
+
allowed: false,
|
|
157
|
+
category: classification.category,
|
|
158
|
+
needsApproval: true,
|
|
159
|
+
reason:
|
|
160
|
+
packageInstallPolicy === "prompt"
|
|
161
|
+
? "Environment setup or package install requires explicit approval in the UI."
|
|
162
|
+
: "Environment setup and package installs are blocked by policy.",
|
|
163
|
+
sandboxMode,
|
|
164
|
+
packageInstallPolicy,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (sandboxMode !== "docker-workspace") {
|
|
169
|
+
return {
|
|
170
|
+
allowed: false,
|
|
171
|
+
category: classification.category,
|
|
172
|
+
reason: "Approved package/environment setup must run in Docker workspace-write sandbox mode.",
|
|
173
|
+
sandboxMode,
|
|
174
|
+
packageInstallPolicy,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
allowed: true,
|
|
181
|
+
...classification,
|
|
182
|
+
sandboxMode,
|
|
183
|
+
packageInstallPolicy,
|
|
184
|
+
};
|
|
185
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import { getProviderDefaults, normalizeRoutingMode, selectModelRoute } from "./model-routing.js";
|
|
4
|
+
import { normalizePackageInstallPolicy, normalizeSandboxMode } from "./command-policy.js";
|
|
5
|
+
|
|
6
|
+
function parseBoolean(value, fallback) {
|
|
7
|
+
if (value === undefined) return fallback;
|
|
8
|
+
return String(value).toLowerCase() === "true";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function parseNumber(value, fallback) {
|
|
12
|
+
const parsed = Number(value);
|
|
13
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function parseList(value) {
|
|
17
|
+
if (!value) return [];
|
|
18
|
+
return String(value)
|
|
19
|
+
.split(",")
|
|
20
|
+
.map((item) => item.trim())
|
|
21
|
+
.filter(Boolean);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolveRuntimeConfig(args, overrides = {}) {
|
|
25
|
+
const requestedProvider =
|
|
26
|
+
overrides.provider ||
|
|
27
|
+
args.provider ||
|
|
28
|
+
process.env.AGENT_PROVIDER ||
|
|
29
|
+
(process.env.DEEPSEEK_API_KEY ? "deepseek" : process.env.OPENAI_API_KEY ? "openai" : "deepseek");
|
|
30
|
+
const routingMode = normalizeRoutingMode(overrides.routingMode || args.routingMode || process.env.AGENT_ROUTING_MODE || "smart");
|
|
31
|
+
const route = selectModelRoute({
|
|
32
|
+
routingMode,
|
|
33
|
+
provider: requestedProvider,
|
|
34
|
+
model: overrides.model || args.model || process.env.LLM_MODEL || "",
|
|
35
|
+
goal: args.goal || "",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const defaults = getProviderDefaults(route.provider);
|
|
39
|
+
const baseDir = path.resolve(overrides.baseDir || process.cwd());
|
|
40
|
+
const dockerRequested = parseBoolean(overrides.useDockerSandbox ?? args.useDockerSandbox ?? process.env.USE_DOCKER_SANDBOX, false);
|
|
41
|
+
const requestedSandboxMode =
|
|
42
|
+
overrides.sandboxMode || args.sandboxMode || process.env.SANDBOX_MODE || (dockerRequested ? "docker-readonly" : "host");
|
|
43
|
+
const sandboxMode = normalizeSandboxMode(requestedSandboxMode);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...defaults,
|
|
47
|
+
baseDir,
|
|
48
|
+
goal: args.goal || "",
|
|
49
|
+
startUrl: args.startUrl || "",
|
|
50
|
+
resume: args.resume || "",
|
|
51
|
+
sessionId: overrides.sessionId || args.sessionId || process.env.SESSION_ID || `web-agent-${crypto.randomUUID()}`,
|
|
52
|
+
routingMode,
|
|
53
|
+
routeReason: route.reason,
|
|
54
|
+
routeComplexityScore: route.complexityScore,
|
|
55
|
+
requestedProvider,
|
|
56
|
+
requestedModel: overrides.model || args.model || process.env.LLM_MODEL || "",
|
|
57
|
+
provider: route.provider,
|
|
58
|
+
apiKey: overrides.apiKey || defaults.apiKey,
|
|
59
|
+
baseURL: overrides.baseURL || defaults.baseURL,
|
|
60
|
+
model: route.model || defaults.model,
|
|
61
|
+
maxSteps: parseNumber(overrides.maxSteps ?? args.maxSteps ?? process.env.MAX_STEPS, 15),
|
|
62
|
+
headless: parseBoolean(overrides.headless ?? args.headless ?? process.env.HEADLESS, false),
|
|
63
|
+
allowedDomains: Array.isArray(overrides.allowedDomains)
|
|
64
|
+
? overrides.allowedDomains
|
|
65
|
+
: parseList(process.env.ALLOWED_DOMAINS),
|
|
66
|
+
allowPasswords: parseBoolean(overrides.allowPasswords ?? process.env.ALLOW_PASSWORDS, false),
|
|
67
|
+
allowDestructive: parseBoolean(overrides.allowDestructive ?? process.env.ALLOW_DESTRUCTIVE, false),
|
|
68
|
+
allowShellTool: parseBoolean(overrides.allowShellTool ?? args.allowShellTool ?? process.env.ALLOW_SHELL_TOOL, false),
|
|
69
|
+
allowWrapperTools: parseBoolean(
|
|
70
|
+
overrides.allowWrapperTools ?? args.allowWrapperTools ?? process.env.ALLOW_WRAPPER_TOOLS,
|
|
71
|
+
false
|
|
72
|
+
),
|
|
73
|
+
wrapperTimeoutMs: parseNumber(overrides.wrapperTimeoutMs ?? process.env.WRAPPER_TIMEOUT_MS, 120000),
|
|
74
|
+
sandboxMode,
|
|
75
|
+
packageInstallPolicy: normalizePackageInstallPolicy(
|
|
76
|
+
overrides.packageInstallPolicy || args.packageInstallPolicy || process.env.PACKAGE_INSTALL_POLICY || "prompt"
|
|
77
|
+
),
|
|
78
|
+
useDockerSandbox: sandboxMode !== "host" || dockerRequested,
|
|
79
|
+
dockerSandboxImage: overrides.dockerSandboxImage || process.env.DOCKER_SANDBOX_IMAGE || "agintiflow-sandbox:latest",
|
|
80
|
+
commandCwd: path.resolve(overrides.commandCwd || args.commandCwd || process.env.COMMAND_CWD || process.cwd()),
|
|
81
|
+
sessionsDir: path.resolve(baseDir, ".sessions"),
|
|
82
|
+
onLog: overrides.onLog,
|
|
83
|
+
onEvent: overrides.onEvent,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function loadConfig(args) {
|
|
88
|
+
return resolveRuntimeConfig(args);
|
|
89
|
+
}
|