Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
import { HelpDoc, ValidationError } from '@effect/cli';
import * as FileSystem from '@effect/platform/FileSystem';
import { Effect, Option } from 'effect';
import { readStdin, readStdinIfPiped } from 'src/effects/read-stdin';
type ResolveOptionalTextInputOptions = {
readonly missingValue?: string;
};
export const resolveOptionalTextInput = (
input: Option.Option<string>,
options: ResolveOptionalTextInputOptions = {}
) =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
if (Option.isSome(input)) {
const value = input.value.trim();
if (value === '-') {
return yield* readStdin;
}
if (value.startsWith('@')) {
const filePath = value.slice(1).trim();
if (!filePath) {
return yield* Effect.fail(
ValidationError.invalidValue(HelpDoc.p('Missing file path after "@" in --data'))
);
}
return yield* fs.readFileString(filePath, 'utf-8');
}
return value;
}
const piped = yield* readStdinIfPiped;
if (Option.isSome(piped)) {
return piped.value;
}
return options.missingValue;
});