Files
77905af66a fix(team): bind native team lifecycle to an immutable instance id (#4059)
* fix(team): bind native team lifecycle to an immutable instance id

Reserve a UUID before startup effects so shutdown, MCP cleanup, and
SessionEnd cannot adopt a newer same-name team. Keep cleanup receipts
outside the disposable state root so interrupted disposal can retry
without touching a successor.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(team): persist Claude session ownership for SessionEnd cleanup

SessionEnd was matching the ending Claude session against a tmux target, so owned teams were preserved. Record leader_session_id on config and treat a positively absent dedicated window as retryable cleanup evidence.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(team): align lifecycle fixtures with owned tmux identity

Keep production fail-closed. Tests now supply valid server identity and
launch evidence, and interruption tests build runtime-cli so CI can run
the kill-pane guard without committing bridge/.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(test): restore typecheck and CI baselines for team instance lifecycle

- widen getWorkerLiveness mock return types so tsc (and the dist build the
  e2e/npm-pack suites depend on) stops failing with 10 TS errors
- accept esbuild's hoisted import.meta shim spelling in the runtime-cli
  package-dir regression assertion
- give the interrupted-shutdown fixture a platform-shaped process identity so
  isProcessIdentityDead() can prove the owner dead and adoption runs
- regenerate inventory-graph baseline for the new source content

* chore(inventory): regenerate graph baseline after dev merge

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: clawdbot <clawdbot@users.noreply.github.com>
2026-09-21 12:05:33 +09:00

45 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
import * as esbuild from 'esbuild';
import { mkdir } from 'fs/promises';
const outfile = 'bridge/runtime-cli.cjs';
await mkdir('bridge', { recursive: true });
const watchMode = process.argv.includes('--watch');
const buildConfig = {
entryPoints: ['src/team/runtime-cli.ts'],
bundle: true,
preserveSymlinks: true,
platform: 'node',
target: 'node18',
format: 'cjs',
outfile,
// Inject import.meta.url polyfill for CJS format
banner: {
js: 'const importMetaUrl = require("url").pathToFileURL(__filename);',
},
define: {
'import.meta.url': 'importMetaUrl',
},
// Note: platform:'node' auto-externalizes all Node built-in subpaths (fs/promises, etc.)
external: [
'fs', 'fs/promises', 'path', 'os', 'util', 'stream', 'events',
'buffer', 'crypto', 'http', 'https', 'url',
'child_process', 'assert', 'module', 'net', 'tls',
'dns', 'readline', 'tty', 'worker_threads',
'@ast-grep/napi', 'better-sqlite3',
// jsonc-parser has dynamic requires that don't bundle well; we use a custom parser
'jsonc-parser',
],
};
if (watchMode) {
const ctx = await esbuild.context(buildConfig);
await ctx.watch();
console.error(`Watching ${outfile}...`);
} else {
await esbuild.build(buildConfig);
console.error(`Built ${outfile}`);
}