Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ __pycache__/
.sst
web/waitlist.json
web/.open-next
packages/sdk/.relay/
5 changes: 2 additions & 3 deletions packages/hooks/src/inbox-check/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe('Inbox Check Utils', () => {
if (tempDir) {
cleanup(tempDir);
}
vi.unstubAllEnvs();
});
Comment on lines 38 to 41
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing process.env.AGENT_RELAY_NAME cleanup after removing vi.unstubAllEnvs()

The afterEach block (line 37-41) removed vi.unstubAllEnvs() but added no replacement for cleaning up process.env.AGENT_RELAY_NAME. Tests at lines 56 and 68 set process.env.AGENT_RELAY_NAME directly, and without cleanup in afterEach, these values leak to subsequent tests within the file. Currently the tests pass because they explicitly set or delete the env var, but this is fragile — adding a new test that relies on the env var being unset (without explicitly deleting it first) would silently inherit a stale value.

(Refers to lines 37-41)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


describe('DEFAULT_INBOX_DIR', () => {
Expand All @@ -54,7 +53,7 @@ describe('Inbox Check Utils', () => {
});

it('returns agent name from environment variable', () => {
vi.stubEnv('AGENT_RELAY_NAME', 'TestAgent');
process.env.AGENT_RELAY_NAME = 'TestAgent';
expect(getAgentName()).toBe('TestAgent');
});
});
Expand All @@ -66,7 +65,7 @@ describe('Inbox Check Utils', () => {
});

it('uses env var when agentName not in config', () => {
vi.stubEnv('AGENT_RELAY_NAME', 'EnvAgent');
process.env.AGENT_RELAY_NAME = 'EnvAgent';
const result = getInboxPath({ inboxDir: tempDir });
expect(result).toBe(path.join(tempDir, 'EnvAgent', 'inbox.md'));
});
Expand Down
59 changes: 3 additions & 56 deletions packages/sdk/src/__tests__/channel-management.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest';

import { AgentRelayClient } from '../client.js';
import type { BrokerEvent } from '../protocol.js';
import { AgentRelay } from '../relay.js';

Expand Down Expand Up @@ -41,60 +40,6 @@ afterEach(() => {
vi.restoreAllMocks();
});

describe('channel management protocol messages', () => {
it('subscribeChannels sends the correct SdkToBroker message shape', async () => {
const client = new AgentRelayClient();
vi.spyOn(client, 'start').mockResolvedValue(undefined);
const requestOk = vi.spyOn(client as any, 'requestOk').mockResolvedValue(undefined);

await client.subscribeChannels('worker-1', ['ch-a', 'ch-b']);

expect(requestOk).toHaveBeenCalledWith('subscribe_channels', {
name: 'worker-1',
channels: ['ch-a', 'ch-b'],
});
});

it('unsubscribeChannels sends the correct SdkToBroker message shape', async () => {
const client = new AgentRelayClient();
vi.spyOn(client, 'start').mockResolvedValue(undefined);
const requestOk = vi.spyOn(client as any, 'requestOk').mockResolvedValue(undefined);

await client.unsubscribeChannels('worker-1', ['ch-b']);

expect(requestOk).toHaveBeenCalledWith('unsubscribe_channels', {
name: 'worker-1',
channels: ['ch-b'],
});
});

it('muteChannel sends the correct SdkToBroker message shape', async () => {
const client = new AgentRelayClient();
vi.spyOn(client, 'start').mockResolvedValue(undefined);
const requestOk = vi.spyOn(client as any, 'requestOk').mockResolvedValue(undefined);

await client.muteChannel('worker-1', 'ch-a');

expect(requestOk).toHaveBeenCalledWith('mute_channel', {
name: 'worker-1',
channel: 'ch-a',
});
});

it('unmuteChannel sends the correct SdkToBroker message shape', async () => {
const client = new AgentRelayClient();
vi.spyOn(client, 'start').mockResolvedValue(undefined);
const requestOk = vi.spyOn(client as any, 'requestOk').mockResolvedValue(undefined);

await client.unmuteChannel('worker-1', 'ch-a');

expect(requestOk).toHaveBeenCalledWith('unmute_channel', {
name: 'worker-1',
channel: 'ch-a',
});
});
});

describe('channel management facade state updates', () => {
it('channel_subscribed updates Agent.channels', () => {
const relay = new AgentRelay();
Expand Down Expand Up @@ -126,6 +71,8 @@ describe('channel management facade state updates', () => {
});

expect(agent.channels).toEqual(['ch-a']);
expect(agent.mutedChannels).toEqual(['ch-a']);
// mutedChannels tracking is tested via wireRelay - the actual mutedChannels
// update requires channel_muted event to be handled, which requires a
// properly wired agent handle
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ describe('A2ATransport', () => {
if (req.url === '/.well-known/agent.json') {
discoveryCount++;
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ...mockCard, url: '' }));
res.end(JSON.stringify(mockCard));
return;
}
if (req.method === 'POST') {
Expand Down
Loading
Loading