@volter/supercode-teams 0.2.26 → 0.2.28

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.
Files changed (2) hide show
  1. package/bin/workspace.mjs +13 -0
  2. package/package.json +1 -1
package/bin/workspace.mjs CHANGED
@@ -636,6 +636,16 @@ async function syncCommand(sub, { flags, rest, output, client, context, team, ho
636
636
  usage('teams sync add|list|show|pause|resume|remove');
637
637
  }
638
638
 
639
+ // Asks the connector this machine runs for a context to stop, through its control socket, and waits (bounded) for
640
+ // its process to end.
641
+ async function stopRunningConnector(saved) {
642
+ const running = saved?.process;
643
+ if (!running?.socket || !running?.token || !(await activeSocket(running.socket))) return;
644
+ await requestStop(running.socket, running.token);
645
+ const alive = () => { try { process.kill(running.pid, 0); return true; } catch (error) { return error.code === 'EPERM'; } };
646
+ for (let waited = 0; running.pid > 0 && alive() && waited < 15_000; waited += 250) await new Promise(resolve => setTimeout(resolve, 250));
647
+ }
648
+
639
649
  async function connectorCommand(verb, { flags, rest, output, client, context, team, contextName }, home) {
640
650
  requireArgs(rest, 0, 0, `teams ${verb}`); const state = new WorkspaceContexts(home).connector(context.server_id, context.team_id);
641
651
  if (verb === 'status') {
@@ -680,6 +690,9 @@ async function connectorCommand(verb, { flags, rest, output, client, context, te
680
690
  if (flags.install || (!flags.foreground && process.stdin.isTTY && process.stdout.isTTY)) {
681
691
  const serviceBin = process.env.SUPERCODE_BIN;
682
692
  if (!serviceBin) unsupported('--install requires invocation through the native supercode CLI');
693
+ // Ending a Windows task ends only the console host it started, never the connector under it, so the task
694
+ // would refuse its new run while the old connector went on: the running one is asked to stop first.
695
+ if (process.platform === 'win32') await stopRunningConnector(saved);
683
696
  try { service = JSON.parse(execFileSync(serviceBin, ['__teams-connector-service', 'install', contextName, path, context.server_id, context.team_id], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })); }
684
697
  catch (error) {
685
698
  // A platform with no service manager still connects: here, for as long as this terminal runs it. Anything else is an error.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "type": "module",
5
5
  "description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
6
6
  "license": "MIT",