@lazyingart/agintiflow 0.20.137 → 0.20.138

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.137",
3
+ "version": "0.20.138",
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,27 @@ 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
+ 'api_key = os.environ.get("DEEPSEEK_API_KEY")',
1042
+ 'client = OpenAI(api_key=api_key, base_url="https://api.deepseek.com")',
1043
+ "print(client)",
1044
+ "",
1045
+ ].join("\n"),
1046
+ mode: "create",
1047
+ },
1048
+ {
1049
+ commandCwd: workspace,
1050
+ allowFileTools: true,
1051
+ }
1052
+ );
1053
+ assert(safeEnvReferenceResult.ok, "write_file should allow safe env-var credential references in source code");
1054
+
1034
1055
  const redactedContentResult = await executeWorkspaceTool(
1035
1056
  "write_file",
1036
1057
  {
@@ -1127,6 +1148,7 @@ try {
1127
1148
  "patch_move_no_overwrite",
1128
1149
  "block_env",
1129
1150
  "block_secret_write_content",
1151
+ "allow_safe_env_reference_content",
1130
1152
  "allow_redacted_write_content",
1131
1153
  "block_secret_patch_content",
1132
1154
  "block_outside",
@@ -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,35 @@ 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 envName = String.raw`[A-Z][A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET|PASSWORD|PASSWD|GRSAI|VENICE)[A-Z0-9_]*`;
214
+
215
+ text = text.replace(
216
+ new RegExp(String.raw`\b${keyName}\s*=\s*(?:os\.environ\.get|os\.getenv)\(\s*["']${envName}["'](?:\s*,\s*(?:None|""|''))?\s*\)`, "gi"),
217
+ "safe_credential_ref=[ENV_REF]"
218
+ );
219
+ text = text.replace(
220
+ new RegExp(String.raw`\b${keyName}\s*=\s*(?:os\.environ|env)\[\s*["']${envName}["']\s*\]`, "gi"),
221
+ "safe_credential_ref=[ENV_REF]"
222
+ );
223
+ text = text.replace(
224
+ new RegExp(String.raw`\b${keyName}\s*=\s*(?:process\.env\.${envName}|Deno\.env\.get\(\s*["']${envName}["']\s*\))`, "gi"),
225
+ "safe_credential_ref=[ENV_REF]"
226
+ );
227
+ text = text.replace(
228
+ new RegExp(String.raw`([,(]\s*)${keyName}\s*=\s*[A-Za-z_$][\w$]*(?=\s*[,)\n])`, "gi"),
229
+ "$1safe_credential_ref=[VAR_REF]"
230
+ );
231
+ text = text.replace(
232
+ new RegExp(String.raw`([,{]\s*)${keyName}\s*:\s*[A-Za-z_$][\w$]*(?=\s*[,}\n])`, "gi"),
233
+ "$1safe_credential_ref=[VAR_REF]"
234
+ );
235
+
236
+ return text;
237
+ }
238
+
210
239
  function writeContentPolicy(toolName, args, operations = null) {
211
240
  if (toolName === "write_file") return secretContentPolicy(args.content || "");
212
241
  if (toolName !== "apply_patch") return { allowed: true };