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

Function parseGetTarget

src/daemon/selector-runtime.ts:441–468  ·  view source on GitHub ↗
(req: DaemonRequest)

Source from the content-addressed store, hash-verified

439}
440
441function parseGetTarget(req: DaemonRequest):
442 | {
443 ok: true;
444 target:
445 | { kind: 'ref'; ref: string; fallbackLabel?: string }
446 | { kind: 'selector'; selector: string };
447 }
448 | { ok: false; response: DaemonResponse } {
449 const refInput = req.positionals?.[1] ?? '';
450 if (refInput.startsWith('@')) {
451 return {
452 ok: true,
453 target: {
454 kind: 'ref',
455 ref: refInput,
456 fallbackLabel: req.positionals.length > 2 ? req.positionals.slice(2).join(' ').trim() : '',
457 },
458 };
459 }
460 const selector = req.positionals?.slice(1).join(' ').trim() ?? '';
461 if (!selector) {
462 return {
463 ok: false,
464 response: errorResponse('INVALID_ARGS', 'get requires @ref or selector expression'),
465 };
466 }
467 return { ok: true, target: { kind: 'selector', selector } };
468}
469
470function toWaitTarget(parsed: WaitParsed, session: SessionState | undefined) {
471 if (parsed.kind === 'sleep') return { kind: 'sleep' as const, durationMs: parsed.durationMs };

Callers 1

dispatchGetViaRuntimeFunction · 0.85

Calls 2

errorResponseFunction · 0.90
startsWithMethod · 0.80

Tested by

no test coverage detected