Skip to content

Commit 34b0230

Browse files
test(typegen): pin that harness calls stay legal without context under provider typegen
The #409 acceptance pinned `renderRoute(id)` as a compile error once the augmentation declares provider keys. With the harness mounting the project's providers itself that call is the artifact-faithful one, so it now typechecks clean alongside a call that passes only `input`, while a partial explicit fixture still fails on the missing key and a direct runAgentRequest still requires `providers`.
1 parent a366054 commit 34b0230

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎packages/agent-bundle/tests/provider-typegen.test.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ it('types (await agent()).providers.<key> from the generated provider declaratio
113113
'export const wrong = async (): Promise<number> => (await agent()).providers.library;',
114114
'',
115115
].join('\n')),
116-
// Contexts that do not run src/providers/* — a custom runAgentRequest host
117-
// or a route-unit fixture — must supply the declared keys, or the handler's
118-
// typed `providers.library` would dereference undefined at runtime.
116+
// A custom runAgentRequest host runs no src/providers/*, so it must supply
117+
// the declared keys, or the handler's typed `providers.library` would
118+
// dereference undefined at runtime. The harness mounts the project's
119+
// providers itself, so a call without `context` is legal and observes the
120+
// real values; an explicit `context.providers` fixture must be complete.
119121
writeProjectFile(root, 'custom-scope.ts', [
120122
"import { runAgentRequest } from '@agent-bundle/runtime';",
121123
"import { renderRoute } from 'agent-bundle/test';",
@@ -125,6 +127,8 @@ it('types (await agent()).providers.<key> from the generated provider declaratio
125127
'export const complete = async (): Promise<void> => {',
126128
" await runAgentRequest({ invocation: { kind: 'tool' }, providers: { buildNumber: 7, library } }, async () => undefined);",
127129
" await renderRoute('tool:curator/status', { context: { providers: { buildNumber: 7, library } } });",
130+
" await renderRoute('tool:curator/status');",
131+
" await renderRoute('tool:curator/status', { input: {} });",
128132
'};',
129133
'',
130134
].join('\n')),
@@ -138,7 +142,6 @@ it('types (await agent()).providers.<key> from the generated provider declaratio
138142
"import type { LibraryContext } from './src/providers/library.js';",
139143
"const library: LibraryContext = { stages: ['discover'], surface: 'tool' };",
140144
"export const partial = renderRoute('tool:curator/status', { context: { providers: { library } } });",
141-
"export const absent = renderRoute('tool:curator/status');",
142145
'',
143146
].join('\n')),
144147
]);
@@ -160,7 +163,6 @@ it('types (await agent()).providers.<key> from the generated provider declaratio
160163
expect(missingProviders).toHaveLength(1);
161164
expect(missingProviders[0]).toContain("Property 'providers' is missing");
162165
const missingFixture = typecheck(root, 'missing-fixture.ts');
163-
expect(missingFixture).toHaveLength(2);
166+
expect(missingFixture).toHaveLength(1);
164167
expect(missingFixture[0]).toContain("Property '\"buildNumber\"' is missing");
165-
expect(missingFixture[1]).toContain('Expected 2 arguments, but got 1.');
166168
});

0 commit comments

Comments
 (0)