@fieldwangai/agentflow 0.1.99 → 0.1.101

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.
@@ -31,6 +31,17 @@ function childEnv(options = {}, extra = {}) {
31
31
  return { ...process.env, ...readMergedEnvObject(userId), ...optEnv, ...extra };
32
32
  }
33
33
 
34
+ function notifyPromptAgentChild(options, child) {
35
+ if (typeof options?.onChild !== "function") return;
36
+ try {
37
+ options.onChild(child || null, {
38
+ processGroup: Boolean(options.detached) && process.platform !== "win32",
39
+ });
40
+ } catch {
41
+ // Child tracking must not interfere with the runner.
42
+ }
43
+ }
44
+
34
45
  function cursorAttemptOptions(options = {}) {
35
46
  const baseEnv = childEnv(options);
36
47
  const attempts = Array.isArray(options._agentflowCursorApiKeyAttempts)
@@ -1330,7 +1341,9 @@ export function runCursorAgentWithPrompt(cliWorkspace, promptText, options = {})
1330
1341
  stdio: ["ignore", "pipe", useStderrInherit ? "inherit" : "pipe"],
1331
1342
  shell: false,
1332
1343
  env: childEnv(options, cursorApiKeyEnv(cursorSelection)),
1344
+ detached: Boolean(options.detached) && process.platform !== "win32",
1333
1345
  });
1346
+ notifyPromptAgentChild(options, child);
1334
1347
 
1335
1348
  let lastResult = null;
1336
1349
  let hadError = false;
@@ -1551,6 +1564,7 @@ export function runOpenCodeAgentWithPrompt(cliWorkspace, promptText, options = {
1551
1564
  stdio: ["ignore", "pipe", "pipe"],
1552
1565
  shell: false,
1553
1566
  env: childEnv(options),
1567
+ detached: Boolean(options.detached) && process.platform !== "win32",
1554
1568
  };
1555
1569
  if (options.force) {
1556
1570
  spawnOpts.env = {
@@ -1562,6 +1576,7 @@ export function runOpenCodeAgentWithPrompt(cliWorkspace, promptText, options = {
1562
1576
  }
1563
1577
 
1564
1578
  const child = spawn(opencodeCmd, args, spawnOpts);
1579
+ notifyPromptAgentChild(options, child);
1565
1580
 
1566
1581
  const emit = (payload) => {
1567
1582
  try {
@@ -1664,7 +1679,9 @@ export function runClaudeCodeAgentWithPrompt(cliWorkspace, promptText, options =
1664
1679
  stdio: ["ignore", "pipe", useStderrInherit ? "inherit" : "pipe"],
1665
1680
  shell: false,
1666
1681
  env: childEnv(options),
1682
+ detached: Boolean(options.detached) && process.platform !== "win32",
1667
1683
  });
1684
+ notifyPromptAgentChild(options, child);
1668
1685
 
1669
1686
  let lastResult = null;
1670
1687
  let hadError = false;
@@ -1845,7 +1862,9 @@ export function runCodexAgentWithPrompt(cliWorkspace, promptText, options = {})
1845
1862
  stdio: ["ignore", "pipe", useStderrInherit ? "inherit" : "pipe"],
1846
1863
  shell: false,
1847
1864
  env: childEnv(options),
1865
+ detached: Boolean(options.detached) && process.platform !== "win32",
1848
1866
  });
1867
+ notifyPromptAgentChild(options, child);
1849
1868
 
1850
1869
  let hadError = false;
1851
1870
  let emittedNatural = false;
@@ -417,6 +417,8 @@ export function startComposerAgent(opts) {
417
417
  const common = {
418
418
  onStreamEvent: opts.onStreamEvent,
419
419
  onToolCall: opts.onToolCall,
420
+ onChild: opts.onChild,
421
+ detached: Boolean(opts.detached),
420
422
  force: Boolean(opts.force),
421
423
  env,
422
424
  };