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

Function dispatchGetViaRuntime

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

Source from the content-addressed store, hash-verified

103}
104
105export async function dispatchGetViaRuntime(
106 params: SelectorRuntimeParams,
107): Promise<DaemonResponse | null> {
108 const { req } = params;
109 if (req.command !== 'get') return null;
110 const sub = req.positionals?.[0];
111 if (sub !== 'text' && sub !== 'attrs') {
112 return errorResponse('INVALID_ARGS', 'get only supports text or attrs');
113 }
114 const target = parseGetTarget(req);
115 if (!target.ok) return target.response;
116 if (target.target.kind === 'ref') {
117 const invalidRefFlagsResponse = refSnapshotFlagGuardResponse('get', req.flags);
118 if (invalidRefFlagsResponse) return invalidRefFlagsResponse;
119 }
120 if (target.target.kind === 'selector') {
121 const directResponse = await dispatchDirectIosSelectorGet(params, sub, target.target.selector);
122 if (directResponse) return directResponse;
123 }
124
125 const resolvedRuntime = await createSelectorRuntime(params, {
126 requireSession: true,
127 capability: 'get',
128 });
129 if (!resolvedRuntime.ok) return resolvedRuntime.response;
130
131 return await toDaemonResponse(async () => {
132 const result = await resolvedRuntime.runtime.selectors.get({
133 session: params.sessionName,
134 requestId: req.meta?.requestId,
135 property: sub,
136 target: target.target,
137 });
138 recordIfSession(
139 params.sessionStore,
140 params.sessionName,
141 req,
142 buildGetRecordResult(result, sub),
143 );
144 return toDaemonGetData(result);
145 });
146}
147
148export async function dispatchIsViaRuntime(
149 params: SelectorRuntimeParams,

Callers 1

Calls 10

errorResponseFunction · 0.90
createSelectorRuntimeFunction · 0.90
recordIfSessionFunction · 0.90
buildGetRecordResultFunction · 0.90
toDaemonGetDataFunction · 0.90
parseGetTargetFunction · 0.85
toDaemonResponseFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected