MCPcopy Create free account
hub / github.com/callstack/agent-device / inferFillText

Function inferFillText

src/daemon/action-utils.ts:3–23  ·  view source on GitHub ↗
(action: SessionAction)

Source from the content-addressed store, hash-verified

1import type { SessionAction } from './types.ts';
2
3export function inferFillText(action: SessionAction): string {
4 const resultText = action.result?.text;
5 if (typeof resultText === 'string' && resultText.trim().length > 0) {
6 return resultText;
7 }
8 const positionals = action.positionals ?? [];
9 if (positionals.length === 0) return '';
10 const first = positionals[0];
11 if (first?.startsWith('@')) {
12 if (positionals.length >= 3) return positionals.slice(2).join(' ').trim();
13 return positionals.slice(1).join(' ').trim();
14 }
15 if (
16 positionals.length >= 3 &&
17 !Number.isNaN(Number(positionals[0])) &&
18 !Number.isNaN(Number(positionals[1]))
19 ) {
20 return positionals.slice(2).join(' ').trim();
21 }
22 return positionals.slice(1).join(' ').trim();
23}
24
25export function uniqueStrings(values: string[]): string[] {
26 const seen = new Set<string>();

Callers 2

optimizeFillActionFunction · 0.90
healReplayActionFunction · 0.90

Calls 1

startsWithMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…