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:
@@ -23,13 +23,11 @@ import {
|
||||
async function createTestServer(opts?: {
|
||||
rateLimiter?: { maxRequests?: number; windowMs?: number };
|
||||
sessionToken?: string;
|
||||
authenticateRunToken?: (token: string) => boolean;
|
||||
}) {
|
||||
const server = Fastify({ logger: false });
|
||||
await server.register(securityMiddleware, {
|
||||
rateLimiter: opts?.rateLimiter,
|
||||
sessionToken: opts?.sessionToken,
|
||||
authenticateRunToken: opts?.authenticateRunToken,
|
||||
});
|
||||
|
||||
// Simple test routes
|
||||
@@ -424,52 +422,21 @@ describe('Bearer Token Authentication', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('accepts a narrow run token only as a Bearer on the model completion route', async () => {
|
||||
const runToken = 'run-token-with-enough-entropy-1234567890';
|
||||
const server = await createTestServer({
|
||||
sessionToken: TEST_TOKEN,
|
||||
authenticateRunToken: (candidate) => candidate === runToken,
|
||||
});
|
||||
it('accepts only the session token on the model completion route (no run tokens)', async () => {
|
||||
const server = await createTestServer({ sessionToken: TEST_TOKEN });
|
||||
try {
|
||||
const completion = await server.inject({
|
||||
method: 'POST', url: '/v1/chat/completions',
|
||||
headers: { authorization: `Bearer ${runToken}` },
|
||||
headers: { authorization: `Bearer ${TEST_TOKEN}` },
|
||||
});
|
||||
expect(completion.statusCode).toBe(200);
|
||||
|
||||
const unrelated = await server.inject({
|
||||
method: 'GET', url: '/api/test',
|
||||
headers: { 'x-waggle-run-token': runToken },
|
||||
});
|
||||
expect(unrelated.statusCode).toBe(401);
|
||||
const unrelatedBearer = await server.inject({
|
||||
method: 'GET', url: '/api/test',
|
||||
headers: { authorization: `Bearer ${runToken}` },
|
||||
});
|
||||
expect(unrelatedBearer.statusCode).toBe(401);
|
||||
const wrongTransport = await server.inject({
|
||||
const runTokenShaped = await server.inject({
|
||||
method: 'POST', url: '/v1/chat/completions',
|
||||
headers: { 'x-waggle-run-token': runToken },
|
||||
headers: { authorization: 'Bearer run-token-with-enough-entropy-1234567890' },
|
||||
});
|
||||
expect(wrongTransport.statusCode).toBe(401);
|
||||
// The WaggleDance transport no longer accepts run tokens in either form.
|
||||
const danceHeader = await server.inject({
|
||||
method: 'POST', url: '/api/waggle-dance/signal',
|
||||
headers: { 'x-waggle-run-token': runToken },
|
||||
});
|
||||
expect(danceHeader.statusCode).toBe(401);
|
||||
expect(danceHeader.json().code).toBe('MISSING_TOKEN');
|
||||
const danceBearer = await server.inject({
|
||||
method: 'POST', url: '/api/waggle-dance/signal',
|
||||
headers: { authorization: `Bearer ${runToken}` },
|
||||
});
|
||||
expect(danceBearer.statusCode).toBe(401);
|
||||
const wrongCompletion = await server.inject({
|
||||
method: 'POST', url: '/v1/chat/completions',
|
||||
headers: { authorization: 'Bearer wrong-run-token-with-enough-entropy-123' },
|
||||
});
|
||||
expect(wrongCompletion.statusCode).toBe(401);
|
||||
expect(wrongCompletion.json().code).toBe('INVALID_TOKEN');
|
||||
expect(runTokenShaped.statusCode).toBe(401);
|
||||
expect(runTokenShaped.json().code).toBe('INVALID_TOKEN');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user