Skip to content
Merged
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
5 changes: 5 additions & 0 deletions docs/entry-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ of throwing. `invocation.kind` stays surface-specific (`tool`, `event`, `cli`,
`processLifetime` is reserved for the framework-owned process identity and hit
counter, so provider filenames must not derive that key.

Route-unit and CLI-dispatch tests inject provider values through the same
`context` seam as identity axes (`renderRoute(id, { context: { providers:
{ library: fixture } } })`); the harness never executes conventional provider
modules, so a test chooses exactly the values a component observes.

### Handler request context

Conventional route components receive only their surface props, such as
Expand Down
34 changes: 34 additions & 0 deletions packages/agent-bundle/tests/route-unit/render-route.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Agent, agent } from '@agent-bundle/runtime';
import { describe, expect, it } from '@rstest/core';
import { createElement } from 'react';

import Echo from '../../fixtures/route-harness/src/mcp/harness/tools/echo.tsx';
import { AgentTestError } from '../../src/test/errors.ts';
Expand Down Expand Up @@ -261,6 +263,38 @@ describe('renderRoute through the real renderer', () => {
.toHaveValue(undefined);
});

it('mounts provider fixture values through the context seam instead of executing provider modules', async () => {
const library = { stages: ['discover', 'curate'], tooling: { ffmpeg: { available: false } } };
const Providers = async (): Promise<unknown> => {
const { providers } = await agent();
return createElement(Agent.Result, {
value: {
frozen: Object.isFrozen(providers),
keys: Object.keys(providers).sort(),
library: providers['library'] as never,
},
}, createElement(Agent.Text, null, 'providers observed'));
};

const rendered = await renderRoute({ default: Providers as never }, {
context: { providers: { library } },
routeId: 'tool:harness/providers (module)',
});

expectDocument(rendered).toHaveStatus('success').toHaveValue({
frozen: true,
keys: ['library'],
library,
});

// A render without fixtures observes an empty, frozen provider map — the
// harness never runs conventional src/providers modules on the test's behalf.
const unfixtured = await renderRoute({ default: Providers as never }, {
routeId: 'tool:harness/providers (module)',
});
expectDocument(unfixtured).toHaveValue({ frozen: true, keys: [], library: undefined });
});

it('renders a route module handed in directly, without the compiled manifest', async () => {
const rendered = await renderRoute({ default: Echo }, {
input: { message: 'module form' },
Expand Down
Loading