The best way to control Claude Code, Codex and more from any computer or phone

main
ts 23 lines 797 Bytes
Raw
1 import { OrchestrationGetWorkflowScriptError } from "@t3tools/contracts";
2 import * as Effect from "effect/Effect";
3 import { readContainedWorkflowFile } from "./workflowFileRead.ts";
4
5 export const readWorkflowScript = Effect.fn("orchestration.readWorkflowScript")(function* (input: {
6 readonly scriptPath: string;
7 }) {
8 const file = yield* readContainedWorkflowFile({
9 path: input.scriptPath,
10 extension: ".js",
11 byteCap: 256 * 1024,
12 }).pipe(
13 Effect.mapError(
14 (error) =>
15 new OrchestrationGetWorkflowScriptError({
16 reason: error.reason === "wrong-extension" ? "not-js" : error.reason,
17 scriptPath: error.path,
18 cause: error,
19 }),
20 ),
21 );
22 return { scriptPath: file.path, contents: file.contents, truncated: file.truncated };
23 });