@quadient/skillshare 1.19.1 → 1.19.2

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.
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import { open } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
4
  import { createInterface } from 'node:readline';
5
+ import { setTimeout as delay } from 'node:timers/promises';
5
6
  import { resolveAgentCommand } from './agents-executable.js';
6
7
  /**
7
8
  * Starts an agent that speaks newline-delimited JSON on stdio. Tokens go through the environment only. A separate
@@ -96,9 +97,11 @@ export async function startAgentProcess(options) {
96
97
  };
97
98
  child.stdin?.end();
98
99
  signal('SIGTERM');
99
- await bounded(exited, 5000);
100
- // A shell may exit before its descendants. End the remaining process group too.
101
- signal('SIGKILL');
100
+ // The agent may exit while descendants are still flushing their data, even with no inherited stdio.
101
+ // Give the whole group the grace period; the parent's exit alone must not trigger SIGKILL.
102
+ const stopped = child.pid ? await waitForProcessGroupExit(child.pid) : await bounded(exited, 5000);
103
+ if (!stopped)
104
+ signal('SIGKILL');
102
105
  }
103
106
  else if (running && child.pid) {
104
107
  // Kill the complete tree in one operation. Gracefully ending cmd first loses the descendant PIDs.
@@ -126,6 +129,23 @@ export async function startAgentProcess(options) {
126
129
  },
127
130
  };
128
131
  }
132
+ async function waitForProcessGroupExit(pid) {
133
+ const deadline = performance.now() + 5000;
134
+ while (true) {
135
+ try {
136
+ process.kill(-pid, 0);
137
+ }
138
+ catch (error) {
139
+ if (error.code === 'ESRCH')
140
+ return true;
141
+ // An inaccessible group is not proof that its processes have exited. Keep the wait bounded.
142
+ }
143
+ const remaining = deadline - performance.now();
144
+ if (remaining <= 0)
145
+ return false;
146
+ await delay(Math.min(50, remaining));
147
+ }
148
+ }
129
149
  async function bounded(promise, milliseconds) {
130
150
  let timer;
131
151
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadient/skillshare",
3
- "version": "1.19.1",
3
+ "version": "1.19.2",
4
4
  "description": "Skillshare CLI for installing and publishing Quadient skills",
5
5
  "type": "module",
6
6
  "bin": {