@lazyingart/agintiflow 0.20.137 → 0.20.139
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/package.json +1 -1
- package/scripts/smoke-coding-tools.js +24 -0
- package/src/workspace-tools.js +36 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazyingart/agintiflow",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.139",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -1031,6 +1031,29 @@ try {
|
|
|
1031
1031
|
if (error.code !== "ENOENT") throw error;
|
|
1032
1032
|
});
|
|
1033
1033
|
|
|
1034
|
+
const safeEnvReferenceResult = await executeWorkspaceTool(
|
|
1035
|
+
"write_file",
|
|
1036
|
+
{
|
|
1037
|
+
path: "scripts/safe-env-reference.py",
|
|
1038
|
+
content: [
|
|
1039
|
+
"import os",
|
|
1040
|
+
"from openai import OpenAI",
|
|
1041
|
+
"def load_api_key():",
|
|
1042
|
+
' return os.environ.get("DEEPSEEK_API_KEY")',
|
|
1043
|
+
"api_key = load_api_key()",
|
|
1044
|
+
'client = OpenAI(api_key=api_key, base_url="https://api.deepseek.com")',
|
|
1045
|
+
"print(client)",
|
|
1046
|
+
"",
|
|
1047
|
+
].join("\n"),
|
|
1048
|
+
mode: "create",
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
commandCwd: workspace,
|
|
1052
|
+
allowFileTools: true,
|
|
1053
|
+
}
|
|
1054
|
+
);
|
|
1055
|
+
assert(safeEnvReferenceResult.ok, "write_file should allow safe env-var credential references in source code");
|
|
1056
|
+
|
|
1034
1057
|
const redactedContentResult = await executeWorkspaceTool(
|
|
1035
1058
|
"write_file",
|
|
1036
1059
|
{
|
|
@@ -1127,6 +1150,7 @@ try {
|
|
|
1127
1150
|
"patch_move_no_overwrite",
|
|
1128
1151
|
"block_env",
|
|
1129
1152
|
"block_secret_write_content",
|
|
1153
|
+
"allow_safe_env_reference_content",
|
|
1130
1154
|
"allow_redacted_write_content",
|
|
1131
1155
|
"block_secret_patch_content",
|
|
1132
1156
|
"block_outside",
|
package/src/workspace-tools.js
CHANGED
|
@@ -198,7 +198,7 @@ function pathPolicy(toolName, relativePath) {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
function secretContentPolicy(content) {
|
|
201
|
-
if (!hasSensitiveText(content)) return { allowed: true };
|
|
201
|
+
if (!hasSensitiveText(stripSafeCredentialReferences(content))) return { allowed: true };
|
|
202
202
|
return {
|
|
203
203
|
allowed: false,
|
|
204
204
|
reason:
|
|
@@ -207,6 +207,41 @@ function secretContentPolicy(content) {
|
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
function stripSafeCredentialReferences(content) {
|
|
211
|
+
let text = String(content ?? "");
|
|
212
|
+
const keyName = String.raw`(?:api[_-]?key|token|secret|password|passwd|npm_token|_authToken|grsai|venice_api_key)`;
|
|
213
|
+
const codeKeyName = String.raw`(?:api[_-]?key|apiKey|token|secret|password|passwd|npmToken|authToken|grsai|veniceApiKey|venice_api_key)`;
|
|
214
|
+
const codeExpression = String.raw`[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\([^"'\n]*\))?`;
|
|
215
|
+
const envName = String.raw`[A-Z][A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET|PASSWORD|PASSWD|GRSAI|VENICE)[A-Z0-9_]*`;
|
|
216
|
+
|
|
217
|
+
text = text.replace(
|
|
218
|
+
new RegExp(String.raw`\b${keyName}\s*=\s*(?:os\.environ\.get|os\.getenv)\(\s*["']${envName}["'](?:\s*,\s*(?:None|""|''))?\s*\)`, "gi"),
|
|
219
|
+
"safe_credential_ref=[ENV_REF]"
|
|
220
|
+
);
|
|
221
|
+
text = text.replace(
|
|
222
|
+
new RegExp(String.raw`\b${keyName}\s*=\s*(?:os\.environ|env)\[\s*["']${envName}["']\s*\]`, "gi"),
|
|
223
|
+
"safe_credential_ref=[ENV_REF]"
|
|
224
|
+
);
|
|
225
|
+
text = text.replace(
|
|
226
|
+
new RegExp(String.raw`\b${keyName}\s*=\s*(?:process\.env\.${envName}|Deno\.env\.get\(\s*["']${envName}["']\s*\))`, "gi"),
|
|
227
|
+
"safe_credential_ref=[ENV_REF]"
|
|
228
|
+
);
|
|
229
|
+
text = text.replace(
|
|
230
|
+
new RegExp(String.raw`([,(]\s*)${keyName}\s*=\s*[A-Za-z_$][\w$]*(?=\s*[,)\n])`, "gi"),
|
|
231
|
+
"$1safe_credential_ref=[VAR_REF]"
|
|
232
|
+
);
|
|
233
|
+
text = text.replace(
|
|
234
|
+
new RegExp(String.raw`\b${codeKeyName}\s*=\s*${codeExpression}(?=\s*[,;)\n])`, "g"),
|
|
235
|
+
"safe_credential_ref=[EXPR_REF]"
|
|
236
|
+
);
|
|
237
|
+
text = text.replace(
|
|
238
|
+
new RegExp(String.raw`([,{]\s*)${keyName}\s*:\s*[A-Za-z_$][\w$]*(?=\s*[,}\n])`, "gi"),
|
|
239
|
+
"$1safe_credential_ref=[VAR_REF]"
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return text;
|
|
243
|
+
}
|
|
244
|
+
|
|
210
245
|
function writeContentPolicy(toolName, args, operations = null) {
|
|
211
246
|
if (toolName === "write_file") return secretContentPolicy(args.content || "");
|
|
212
247
|
if (toolName !== "apply_patch") return { allowed: true };
|