Skip to content

Commit 860c160

Browse files
committed
computer: export the not-callable error message from the runtime
The runtime and the exec tool each built the same "backend is not callable" message from scratch, so the two user-visible copies could drift. Export the message from the runtime and build the runtime's own throw from it, giving the tool one source to reuse.
1 parent 017399c commit 860c160

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/computer/src/runtime/runtime.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ interface WorkspaceRuntimeRouterOptions {
1919
resolveBackendId: (id: string | undefined) => string;
2020
}
2121

22+
// The error a caller sees when it hands structured `input` to a
23+
// backend that does not accept it. Exported so the exec tool rejects
24+
// with the same wording the runtime raises, instead of a second copy
25+
// that could drift.
26+
export function notCallableMessage(backend: string): string {
27+
return `Backend ${JSON.stringify(backend)} is not callable; it does not accept structured input.`;
28+
}
29+
2230
export class WorkspaceRuntime {
2331
readonly #options: WorkspaceRuntimeRouterOptions;
2432

@@ -42,9 +50,7 @@ export class WorkspaceRuntime {
4250
if (options.id !== undefined) assertExecutionId(options.id);
4351
const backend = this.#backend(options.backend);
4452
if (options.input !== undefined && !this.#options.callableBackendIds.has(backend)) {
45-
throw new Error(
46-
`Backend ${JSON.stringify(backend)} is not callable; it does not accept structured input.`,
47-
);
53+
throw new Error(notCallableMessage(backend));
4854
}
4955
const runtime = await this.#options.backendHandle(backend);
5056
const envelope = await runtime.exec({

0 commit comments

Comments
 (0)