#!/usr/bin/env node // steward - command-line entry point. // // steward doctor check config, paths, and credentials (lab 00) // steward ask "question" one stateless model call (lab 00) // steward chat --ephemeral chat with tools, memory lost on exit (lab 01) // steward chat [--session ] the full assistant, durable (lab 02+) // steward sessions list sessions (lab 02) // steward show [--session ] print a session's event log (lab 02) // steward usage tokens and cost per session (lab 03) // steward init copy the example study workspace (lab 04) // steward audit [count] last tool decisions (lab 05) // steward memory [path] list or print long-term memory (lab 06) // steward serve [--no-terminal] gateway: web chat, scheduler, terminal (labs 08-12) // steward jobs [run ] list scheduled jobs, or run one now (lab 09) // steward eval [name] [--repeat N] behavioral evals with the real model (lab 11) // steward backup [folder] copy the data folder (lab 12) // // Every command accepts --config . import { randomBytes } from 'node:crypto'; import { cp, readdir } from 'node:fs/promises'; import { serve, type ServerType } from '@hono/node-server'; import { existsSync } from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { parseArgs } from 'node:util'; import { createApp } from './app.ts'; import { runTerminalChat, formatUsage, TerminalAdapter } from './channels/terminal.ts'; import { createWebApp, WebAdapter } from './channels/web.ts'; import { Gateway } from './gateway/gateway.ts'; import { loadScenarios, runScenario } from './evals/runner.ts'; import { backupDataDir } from './runtime/backup.ts'; import { LockError, ProcessLock } from './runtime/lock.ts'; import { Scheduler } from './scheduler/scheduler.ts'; import { loadConfig, type StewardConfig } from './config/config.ts'; import { buildSystemPrompt } from './context/system-prompt.ts'; import { cacheHitRate, formatUsd, totalCost } from './context/usage.ts'; import { AnthropicModel } from './core/anthropic-model.ts'; import type { BetaMessageParam } from './core/model.ts'; import { runTurn, type TurnUsage } from './core/turn-loop.ts'; import { MemoryStore } from './memory/memory-store.ts'; import { AuditLog } from './security/audit.ts'; import type { Session } from './sessions/session.ts'; import { SessionStore, sessionKey } from './sessions/session-store.ts'; import { timeTools } from './tools/time-tools.ts'; import { Workspace } from './tools/workspace.ts'; const LAB_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); const USAGE = `Usage: steward [options] Commands: doctor check config, paths, and credentials ask "" one stateless model call (no history, no tools) chat [--ephemeral] chat in the terminal (--ephemeral: time tools only, nothing saved) sessions list sessions show print the current session's events usage tokens and cost per session init copy the example study workspace (only into an empty workspace) audit [count] the last tool decisions (default 20) memory [path] list long-term memory, or print one entry serve [--no-terminal] web chat + scheduler (+ terminal when interactive) jobs [run ] list scheduled jobs, or run one now eval [name] [--repeat N] run behavioral evals against the real model (costs money) backup [folder] copy the data folder to /steward-backup-