feat(sdk): add strict mode and explicit fallback policy to runtime bridge
This commit is contained in:
@@ -4,6 +4,7 @@ import type { QueryCommandResolution } from './query/query-command-resolution-st
|
||||
import { resolveQueryCommand } from './query/query-command-resolution-strategy.js';
|
||||
import { QueryExecutionPolicy } from './query-execution-policy.js';
|
||||
import { QueryNativeHotpathAdapter } from './query-native-hotpath-adapter.js';
|
||||
import { GSDToolsError } from './gsd-tools-error.js';
|
||||
|
||||
export interface RuntimeBridgeExecuteInput {
|
||||
legacyCommand: string;
|
||||
@@ -25,6 +26,10 @@ export class QueryRuntimeBridge {
|
||||
private readonly executionPolicy: QueryExecutionPolicy,
|
||||
private readonly nativeHotpathAdapter: QueryNativeHotpathAdapter,
|
||||
private readonly shouldUseNativeQuery: () => boolean,
|
||||
private readonly options?: {
|
||||
strictSdk?: boolean;
|
||||
allowFallbackToSubprocess?: boolean;
|
||||
},
|
||||
) {}
|
||||
|
||||
getRegistry(): QueryRegistry {
|
||||
@@ -36,6 +41,15 @@ export class QueryRuntimeBridge {
|
||||
}
|
||||
|
||||
async execute(input: RuntimeBridgeExecuteInput): Promise<unknown> {
|
||||
if (this.options?.strictSdk && !this.registry.has(input.registryCommand)) {
|
||||
throw GSDToolsError.failure(
|
||||
`Strict SDK mode: command '${input.registryCommand}' has no native adapter`,
|
||||
input.legacyCommand,
|
||||
input.legacyArgs,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
return this.executionPolicy.execute({
|
||||
legacyCommand: input.legacyCommand,
|
||||
legacyArgs: input.legacyArgs,
|
||||
@@ -45,6 +59,7 @@ export class QueryRuntimeBridge {
|
||||
projectDir: input.projectDir,
|
||||
workstream: input.workstream,
|
||||
preferNativeQuery: this.shouldUseNativeQuery(),
|
||||
allowFallbackToSubprocess: this.options?.allowFallbackToSubprocess,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user