refactor: launch external tools without Room credentials or hook settings

A Launcher launch still opens the tool in the active workspace's folder,
tracks its process, streams observed output and stops it. What it no
longer does:

- set WAGGLE_SIGNAL_EMIT, WAGGLE_SIDECAR_URL, HIVE_MIND_DATA_DIR or the
  Room identity variables (WAGGLE_RUN_ID, WAGGLE_ROOM_ID,
  WAGGLE_DANCE_TEAM_ID, WAGGLE_SENDER_ID, WAGGLE_RUN_TOKEN). Only the
  removed coding-agent hooks and the WaggleDance CLI read them. The
  external-process allowlist now admits WAGGLE_WORKSPACE_ID alone;
- issue a run credential. Run tokens existed for Room workers (the dance
  CLI and OpenClaw's model calls), so the registry's credential store,
  the middleware's run-token bearer on /v1/chat/completions and the
  proxy's per-run model scope go. While an agent run with a model is
  active, the proxy still serves only the session bearer.

The run record that a launch creates in the agent-run registry stays: it
backs cancel from the Room canvas, which this change does not remove.
This commit is contained in:
shumeiko.it
2026-11-01 11:12:31 +01:00
parent 80db300485
commit 25f95c584b
12 changed files with 65 additions and 665 deletions

View File

@@ -69,9 +69,6 @@ describe('launchTool', () => {
id: 'claude-code',
installedPath: 'C:\\tools\\claude.exe',
workspaceId: 'ws-isolated',
runId: 'run-1',
roomId: 'room-1',
runToken: 'narrow-room-token',
deps: {
platform: 'win32',
baseEnv: {
@@ -108,13 +105,12 @@ describe('launchTool', () => {
HERMES_HOME: 'D:\\Hermes Data',
TERM: 'xterm-256color',
WAGGLE_WORKSPACE_ID: 'ws-isolated',
WAGGLE_RUN_TOKEN: 'narrow-room-token',
});
for (const name of [
'ANTHROPIC_API_KEY', 'OPENAI_API_KEY', 'OPENROUTER_API_KEY',
'GEMINI_API_KEY', 'STRIPE_SECRET_KEY', 'AWS_SECRET_ACCESS_KEY',
'DATABASE_URL', 'SSH_AUTH_SOCK', 'GIT_ASKPASS', 'HTTPS_PROXY',
'NODE_OPTIONS',
'NODE_OPTIONS', 'WAGGLE_RUN_TOKEN',
]) {
expect(calls[0].options.env?.[name], name).toBeUndefined();
}
@@ -237,69 +233,22 @@ describe('launchTool', () => {
});
});
// ── launchTool — self-enabling signal env (#1) ──────────────────────
// A dock launch should light the SignalBus it was built to feed: the
// launched tool's hive-mind hook only emits when WAGGLE_SIGNAL_EMIT is
// truthy, and it posts to WAGGLE_SIDECAR_URL. Without these the whole
// detect→launch→hook→bus→UI pipeline stays dark.
// ── launchTool — no hook or Room env ─────────────────────────────────
// The coding-agent hooks and Waggle Room are not part of the community
// edition, so a launch sets only the workspace id.
describe('launchTool — self-enabling signal env', () => {
it('injects WAGGLE_SIGNAL_EMIT=1 by default (lights the bus)', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code',
installedPath: '/usr/local/bin/claude',
deps: { spawnDetached },
});
expect(calls[0].options.env?.WAGGLE_SIGNAL_EMIT).toBe('1');
});
it('omits WAGGLE_SIGNAL_EMIT when signalEmit:false (silent launch opt-out)', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code',
installedPath: '/usr/local/bin/claude',
signalEmit: false,
deps: { spawnDetached },
});
expect(calls[0].options.env?.WAGGLE_SIGNAL_EMIT).toBeUndefined();
});
it('injects WAGGLE_SIDECAR_URL when provided', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code',
installedPath: '/usr/local/bin/claude',
sidecarUrl: 'http://127.0.0.1:7777',
deps: { spawnDetached },
});
expect(calls[0].options.env?.WAGGLE_SIDECAR_URL).toBe('http://127.0.0.1:7777');
});
it('does not inject WAGGLE_SIDECAR_URL when absent', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code',
installedPath: '/usr/local/bin/claude',
deps: { spawnDetached },
});
expect(calls[0].options.env?.WAGGLE_SIDECAR_URL).toBeUndefined();
});
it('injects signal env alongside WAGGLE_WORKSPACE_ID', () => {
describe('launchTool env', () => {
it('sets only WAGGLE_WORKSPACE_ID among Waggle variables', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code',
installedPath: '/usr/local/bin/claude',
workspaceId: 'ws-1',
sidecarUrl: 'http://127.0.0.1:3333',
deps: { spawnDetached },
});
expect(calls[0].options.env).toMatchObject({
WAGGLE_WORKSPACE_ID: 'ws-1',
WAGGLE_SIGNAL_EMIT: '1',
WAGGLE_SIDECAR_URL: 'http://127.0.0.1:3333',
deps: { spawnDetached, baseEnv: { PATH: '/usr/bin' } },
});
const waggleVars = Object.keys(calls[0].options.env ?? {})
.filter((name) => name.startsWith('WAGGLE_') || name.startsWith('HIVE_MIND_'));
expect(waggleVars).toEqual(['WAGGLE_WORKSPACE_ID']);
});
});
@@ -403,36 +352,6 @@ describe('launchTool observe mode', () => {
});
});
describe('launchTool collaboration env', () => {
it('injects the canonical Waggle data root', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code',
installedPath: '/usr/local/bin/claude',
dataDir: '/waggle-data',
deps: { spawnDetached },
});
expect(calls[0].options.env?.HIVE_MIND_DATA_DIR).toBe('/waggle-data');
});
it('injects only the narrow Room credential and canonical run identity', () => {
const { calls, spawnDetached } = captureSpawn();
launchTool({
id: 'claude-code', installedPath: '/usr/local/bin/claude',
runId: 'run-1', roomId: 'room-1', runToken: 'secret-run-token',
deps: { spawnDetached },
});
expect(calls[0].options.env).toMatchObject({
WAGGLE_RUN_ID: 'run-1',
WAGGLE_ROOM_ID: 'room-1',
WAGGLE_DANCE_TEAM_ID: 'room::room-1',
WAGGLE_SENDER_ID: 'run::run-1',
WAGGLE_RUN_TOKEN: 'secret-run-token',
});
expect(calls[0].options.env?.WAGGLE_SESSION_TOKEN).toBeUndefined();
});
});
describe('resolveSpawnInvocation', () => {
it('rejects unrecognized Windows batch shims instead of invoking cmd.exe', () => {
expect(() => resolveSpawnInvocation(