@lazyingart/agintiflow 0.20.133 → 0.20.135

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.133",
3
+ "version": "0.20.135",
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",
@@ -14,7 +14,7 @@ AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-a
14
14
 
15
15
  Project-oriented programming for agentic workflows.
16
16
 
17
- AAPS is a prompt-native programming language and visual studio for turning prompts into structured, verifiable pipelines. It connects wet and dry experiments, hardware and software, and human intent with executable agent work through tasks, typed inputs, declared outputs, validation gates, recovery steps, and durable artifacts.
17
+ AAPS is a project oriented and prompt-native programming language and visual studio for turning prompts into structured, verifiable pipelines. It connects wet and dry experiments, hardware and software, and human intent with executable agent work through tasks, typed inputs, declared outputs, validation gates, recovery steps, and durable artifacts.
18
18
 
19
19
  ## Shorter Version
20
20
 
@@ -66,9 +66,25 @@ try {
66
66
  const veniceDefaults = getProviderDefaults("venice");
67
67
  assert(veniceDefaults.provider === "venice" && veniceDefaults.model === "venice-uncensored-1-2", "venice provider defaults are not available");
68
68
 
69
+ process.env.DEEPSEEK_API_KEY = "ambient-deepseek-key";
70
+ process.env.VENICE_API_KEY = "ambient-venice-key";
71
+ process.env.GRSAI_API_KEY = "ambient-grsai-key";
72
+ let status = providerKeyStatus(tempRoot);
73
+ assert(status.deepseek && status.venice && status.grsai, "ambient provider keys were not detected");
74
+ assert(status.localEnv, "ambient provider keys were not persisted into local .aginti/.env");
75
+ const localEnv = await fs.readFile(path.join(tempRoot, ".aginti", ".env"), "utf8");
76
+ assert(localEnv.includes("DEEPSEEK_API_KEY="), "ambient DeepSeek key was not saved locally");
77
+ assert(localEnv.includes("VENICE_API_KEY="), "ambient Venice key was not saved locally");
78
+ assert(localEnv.includes("GRSAI_API_KEY="), "ambient GRS AI key was not saved locally");
79
+ delete process.env.DEEPSEEK_API_KEY;
80
+ delete process.env.VENICE_API_KEY;
81
+ delete process.env.GRSAI_API_KEY;
82
+ status = providerKeyStatus(tempRoot);
83
+ assert(status.deepseek && status.venice && status.grsai, "persisted provider keys were not reloaded after ambient env was cleared");
84
+
69
85
  await setProviderKey(tempRoot, "qwen", "test-qwen-key");
70
86
  await setProviderKey(tempRoot, "venice", "test-venice-key");
71
- let status = providerKeyStatus(tempRoot);
87
+ status = providerKeyStatus(tempRoot);
72
88
  assert(status.qwen, "qwen key status was not detected");
73
89
  assert(status.venice, "venice key status was not detected");
74
90
  assert(status.envVars.qwen.includes("QWEN_API_KEY"), "qwen env var name was not reported");
@@ -103,6 +119,7 @@ try {
103
119
  "provider-key-preview",
104
120
  "qwen-defaults",
105
121
  "venice-defaults",
122
+ "ambient-key-autopersist",
106
123
  "qwen-key-status",
107
124
  "venice-key-status",
108
125
  "cli-key-status-redacted",
@@ -179,6 +179,12 @@ const multipleRequestedToolCalls = parseTextToolCalls(
179
179
  );
180
180
  assert(multipleRequestedToolCalls.length === 2, "Requested tools parser did not detect multiple function-call texts");
181
181
  assert(multipleRequestedToolCalls[1].function.name === "inspect_project", "Requested tools parser returned wrong second requested tool");
182
+ const xmlTextToolCalls = parseTextToolCalls(
183
+ '<tool_calls>\n<tool_call name="inspect_project">{"project_path":"/workspace"}</tool_call>\n<tool_call name="list_files">{"path":".","depth":2}</tool_call>\n</tool_calls>'
184
+ );
185
+ assert(xmlTextToolCalls.length === 2, "XML text tool-call parser did not detect multiple calls");
186
+ assert(xmlTextToolCalls[0].function.name === "inspect_project", "XML text tool-call parser returned wrong first tool");
187
+ assert(xmlTextToolCalls[1].function.arguments.includes('"depth":2'), "XML text tool-call parser returned wrong arguments");
182
188
  const malformedRequestedToolResponse = normalizeTextToolCallResponse({
183
189
  choices: [
184
190
  {
@@ -204,6 +204,7 @@ export function parseTextToolCalls(content = "") {
204
204
 
205
205
  const calls = [];
206
206
  for (const call of parseRequestedToolCalls(text)) calls.push(call);
207
+ for (const call of parseXmlToolCalls(text, calls.length)) calls.push(call);
207
208
  const jsonBlock = text.match(/TOOL_CALLS\s*:\s*```(?:json)?\s*([\s\S]*?)```/i);
208
209
  if (jsonBlock?.[1]) {
209
210
  try {
@@ -258,7 +259,51 @@ export function parseTextToolCalls(content = "") {
258
259
 
259
260
  function hasTextToolCallMarker(content = "") {
260
261
  const text = String(content || "");
261
- return text.includes("[TOOL_CALLS]") || /TOOL_CALLS\s*:/i.test(text) || /Requested tools?\s*:/i.test(text);
262
+ return (
263
+ text.includes("[TOOL_CALLS]") ||
264
+ /TOOL_CALLS\s*:/i.test(text) ||
265
+ /Requested tools?\s*:/i.test(text) ||
266
+ /<tool_calls?>/i.test(text)
267
+ );
268
+ }
269
+
270
+ function decodeXmlToolArgs(value = "") {
271
+ return String(value || "")
272
+ .trim()
273
+ .replace(/&quot;/g, '"')
274
+ .replace(/&apos;/g, "'")
275
+ .replace(/&lt;/g, "<")
276
+ .replace(/&gt;/g, ">")
277
+ .replace(/&amp;/g, "&");
278
+ }
279
+
280
+ function parseXmlToolCalls(content = "", offset = 0) {
281
+ const text = String(content || "");
282
+ const calls = [];
283
+ const pattern = /<tool_call\b([^>]*)>([\s\S]*?)<\/tool_call>/gi;
284
+ let match;
285
+ while ((match = pattern.exec(text))) {
286
+ const attrs = match[1] || "";
287
+ const name =
288
+ attrs.match(/\bname\s*=\s*"([^"]+)"/i)?.[1]?.trim() ||
289
+ attrs.match(/\bname\s*=\s*'([^']+)'/i)?.[1]?.trim();
290
+ if (!name) continue;
291
+ const rawArgs = decodeXmlToolArgs(match[2]);
292
+ try {
293
+ JSON.parse(rawArgs || "{}");
294
+ } catch {
295
+ continue;
296
+ }
297
+ calls.push({
298
+ id: `text-tool-${offset + calls.length + 1}`,
299
+ type: "function",
300
+ function: {
301
+ name,
302
+ arguments: rawArgs || "{}",
303
+ },
304
+ });
305
+ }
306
+ return calls;
262
307
  }
263
308
 
264
309
  function findMatchingParen(text = "", openIndex = 0) {
@@ -330,6 +375,7 @@ function textBeforeToolCallMarker(content = "") {
330
375
  .split("[TOOL_CALLS]")[0]
331
376
  .split("TOOL_CALLS:")[0]
332
377
  .split(/Requested tools?\s*:/i)[0]
378
+ .split(/<tool_calls?>/i)[0]
333
379
  .split("<|tool_call>")[0]
334
380
  .trim();
335
381
  }
package/src/project.js CHANGED
@@ -51,6 +51,16 @@ const PROVIDER_KEY_CANDIDATES = {
51
51
  grsai: ["GRSAI", "GRSAI_API_KEY"],
52
52
  };
53
53
 
54
+ const AMBIENT_PROVIDER_KEYS = [
55
+ "DEEPSEEK_API_KEY",
56
+ "OPENAI_API_KEY",
57
+ "QWEN_API_KEY",
58
+ "VENICE_API_KEY",
59
+ "GRSAI",
60
+ "GRSAI_API_KEY",
61
+ "LLM_API_KEY",
62
+ ];
63
+
54
64
  export function resolveProjectRoot(input = process.cwd()) {
55
65
  return path.resolve(input || process.cwd());
56
66
  }
@@ -206,6 +216,55 @@ export function parseEnvText(text = "") {
206
216
  return values;
207
217
  }
208
218
 
219
+ function ensureSecretGitignoreLinesSync(gitignorePath) {
220
+ const lines = [".aginti/.env", ".aginti/.env.*", "!.aginti/.env.example"];
221
+ let current = "";
222
+ try {
223
+ current = fs.readFileSync(gitignorePath, "utf8");
224
+ } catch {
225
+ current = "";
226
+ }
227
+ const existing = new Set(current.split(/\r?\n/).map((line) => line.trim()));
228
+ const missing = lines.filter((line) => !existing.has(line));
229
+ if (missing.length === 0) return;
230
+ const prefix = current && !current.endsWith("\n") ? "\n" : "";
231
+ fs.writeFileSync(gitignorePath, `${current}${prefix}${missing.join("\n")}\n`, "utf8");
232
+ }
233
+
234
+ function persistAmbientProviderKeysSync(paths) {
235
+ let parsed = {};
236
+ try {
237
+ parsed = parseEnvText(fs.readFileSync(paths.envPath, "utf8"));
238
+ } catch {
239
+ parsed = {};
240
+ }
241
+
242
+ let changed = false;
243
+ const persistedKeys = [];
244
+ for (const keyName of AMBIENT_PROVIDER_KEYS) {
245
+ const value = String(process.env[keyName] || "").trim();
246
+ if (!value || parsed[keyName]) continue;
247
+ parsed[keyName] = value;
248
+ persistedKeys.push(keyName);
249
+ changed = true;
250
+ }
251
+ if (!changed) return { persisted: false, keys: [] };
252
+
253
+ fs.mkdirSync(paths.controlDir, { recursive: true });
254
+ ensureSecretGitignoreLinesSync(paths.gitignorePath);
255
+ const output = Object.entries(parsed)
256
+ .filter(([key]) => LOCAL_ENV_KEYS.has(key))
257
+ .map(([key, value]) => `${key}=${JSON.stringify(value)}`)
258
+ .join("\n");
259
+ fs.writeFileSync(paths.envPath, `${output}\n`, { mode: 0o600 });
260
+ try {
261
+ fs.chmodSync(paths.envPath, 0o600);
262
+ } catch {
263
+ // chmod can fail on non-POSIX filesystems; the file still remains local and gitignored.
264
+ }
265
+ return { persisted: true, keys: persistedKeys };
266
+ }
267
+
209
268
  export function loadProjectEnv(projectRoot = process.cwd(), { override = false } = {}) {
210
269
  const paths = projectPaths(projectRoot);
211
270
  const envPaths = [paths.rootEnvPath, paths.envPath];
@@ -222,10 +281,14 @@ export function loadProjectEnv(projectRoot = process.cwd(), { override = false }
222
281
  // Ignore missing or unreadable optional local env files.
223
282
  }
224
283
  }
284
+ const ambient = persistAmbientProviderKeysSync(paths);
285
+ if (ambient.persisted && !loadedPaths.includes(paths.envPath)) loadedPaths.push(paths.envPath);
225
286
  return {
226
287
  loaded: loadedPaths.length > 0,
227
288
  path: paths.envPath,
228
289
  paths: loadedPaths,
290
+ ambientPersisted: ambient.persisted,
291
+ ambientKeys: ambient.keys,
229
292
  };
230
293
  }
231
294