MCPcopy Index your code
hub / github.com/callstack/agent-device / dispatchKnownCommand

Function dispatchKnownCommand

src/core/dispatch.ts:214–233  ·  view source on GitHub ↗
(
  device: DeviceInfo,
  interactor: Interactor,
  command: string,
  positionals: string[],
  outPath: string | undefined,
  context: DispatchContext | undefined,
  runnerCtx: RunnerContext,
)

Source from the content-addressed store, hash-verified

212};
213
214async function dispatchKnownCommand(
215 device: DeviceInfo,
216 interactor: Interactor,
217 command: string,
218 positionals: string[],
219 outPath: string | undefined,
220 context: DispatchContext | undefined,
221 runnerCtx: RunnerContext,
222): Promise<Record<string, unknown> | void> {
223 // `Object.hasOwn` keeps the lookup behaviorless: any unknown command —
224 // including inherited keys like `toString` — falls through to the same
225 // `INVALID_ARGS` error the former `default:` branch threw.
226 const handler = Object.hasOwn(DISPATCH_HANDLERS, command)
227 ? DISPATCH_HANDLERS[command as DispatchCommand]
228 : undefined;
229 if (!handler) {
230 throw new AppError('INVALID_ARGS', `Unknown command: ${command}`);
231 }
232 return await handler({ device, interactor, positionals, outPath, context, runnerCtx });
233}
234
235// ---------------------------------------------------------------------------
236// Command handlers

Callers 1

dispatchCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected