1import * as Effect from "effect/Effect";
2import { Argument, Command } from "effect/cli";
3
4import { runClaudeHistoryWorker } from "../claudeHistoryWorker.ts";
5
6/**
7 * Hosts the Claude history worker inside the CLI executable. The npm bundle
8 * runs it as a sibling `claudeHistoryWorker.mjs` under the host Node; the
9 * single-executable has no Node to run a script with, so the adapter invokes
10 * this hidden subcommand on its own executable instead.
11 */
12export const claudeHistoryCommand = Command.make("__claude-history", {
13 method: Argument.String("method"),
14 sessionId: Argument.String("session-id"),
15 options: Argument.String("options").pipe(Argument.optional),
16}).pipe(
17 Command.unlisted,
18 Command.withHandler(({ method, sessionId, options }) =>
19 Effect.promise(() =>
20 runClaudeHistoryWorker(
21 method,
22 sessionId,
23 options._tag === "Some" ? options.value : undefined,
24 ),
25 ),
26 ),
27);