MCPcopy
hub / github.com/callstack/agent-device / dispatchFindReadOnlyViaRuntime

Function dispatchFindReadOnlyViaRuntime

src/daemon/selector-runtime.ts:65–103  ·  view source on GitHub ↗
(
  params: SelectorRuntimeParams,
)

Source from the content-addressed store, hash-verified

63 | null;
64
65export async function dispatchFindReadOnlyViaRuntime(
66 params: SelectorRuntimeParams,
67): Promise<DaemonResponse | null> {
68 const { req } = params;
69 if (req.command !== 'find') return null;
70 const args = req.positionals ?? [];
71 if (args.length === 0) return errorResponse('INVALID_ARGS', 'find requires a locator or text');
72 const parsed = parseFindArgs(args);
73 if (!parsed.query) return errorResponse('INVALID_ARGS', 'find requires a value');
74 if (req.flags?.findFirst && req.flags?.findLast) {
75 return errorResponse('INVALID_ARGS', 'find accepts only one of --first or --last');
76 }
77 const action = parsed.action;
78 if (!isReadOnlyFindAction(action)) return null;
79
80 const resolvedRuntime = await createSelectorRuntime(params, {
81 requireSession: false,
82 capability: 'find',
83 });
84 if (!resolvedRuntime.ok) return resolvedRuntime.response;
85
86 return await toDaemonResponse(async () => {
87 const result = await resolvedRuntime.runtime.selectors.find({
88 session: params.sessionName,
89 requestId: req.meta?.requestId,
90 locator: parsed.locator,
91 query: parsed.query,
92 action,
93 timeoutMs: parsed.timeoutMs,
94 });
95 recordIfSession(
96 params.sessionStore,
97 params.sessionName,
98 req,
99 buildFindRecordResult(result, action),
100 );
101 return toDaemonFindData(result);
102 });
103}
104
105export async function dispatchGetViaRuntime(
106 params: SelectorRuntimeParams,

Callers 1

handleFindCommandsFunction · 0.90

Calls 8

errorResponseFunction · 0.90
parseFindArgsFunction · 0.90
createSelectorRuntimeFunction · 0.90
recordIfSessionFunction · 0.90
buildFindRecordResultFunction · 0.90
toDaemonFindDataFunction · 0.90
toDaemonResponseFunction · 0.85
isReadOnlyFindActionFunction · 0.70

Tested by

no test coverage detected