feat: initial commit — extracted from comfy-cloud
Anything-can-drive-the-UI command bus. Single dispatch point for LLM tool
calls, scripts, and (optional) WebSocket remote control. JSON canonical
form plus a plain-text DSL sugar layer. Includes a visible virtual cursor
that animates to elements before commands act on them.
Modules:
- bus.ts — CommandBus class, dispatch, handlers, vars, history,
listActions, readState. Built-in handlers: navigate, click,
fill, submit, select, wait, wait_for, scroll, read, expect,
set
- parser.ts — DSL ↔ JSON, with quoted values, # comments, # speed:
directive, $name = <cmd> assignment, $var interpolation,
expect assertions
- script.ts — script runner; loads /scripts/<name>.script, supports
sub-scripts via `run` command
- cursor.ts — virtual cursor + ripple, speed-controlled, aria-hidden
- provider.tsx — React glue: registers `navigate` via react-router, mounts
cursor, exposes window.commandBus / runScript /
runScriptText for console use
- ws.ts — optional WebSocket producer (connectCommandSocket)
- llm-bridge.ts — buildSystemPrompt (DSL ref + live action snapshot),
extractActionBlocks, runActionBlocks, estimateTokens,
trimMessages
- index.tsx — barrel re-exports
Peer deps: react, react-router (consuming app provides).
Originally inline in `comfy-cloud/app/lib/`. Extracted as part of the
crema-app-aifirst-template scaffolding.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
30
src/index.tsx
Normal file
30
src/index.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
// PURPOSE: Anything-can-drive-the-UI command bus. Single dispatch point for
|
||||
// LLM tool calls, scripts, and remote control. JSON canonical form
|
||||
// plus a plain-text DSL sugar layer. Includes a visible "virtual
|
||||
// cursor" that animates to elements before commands act on them, so
|
||||
// LLM-driven sessions are legible to a watching human.
|
||||
// ===========================================================================
|
||||
// EXPORTS
|
||||
// Bus: commandBus (singleton), CommandBus (class)
|
||||
// Types: Command, Handler, HandlerContext, DispatchOptions,
|
||||
// ActionDescriptor, HistoryEntry
|
||||
// Parser: parseScript, parseLine, stringifyScript, ScriptOptions, ParsedScript
|
||||
// Runner: runScript, runScriptText, RunScriptOptions
|
||||
// Cursor: ensureCursor, showCursor, hideCursor, removeCursor,
|
||||
// moveCursorTo, moveCursorToElement, clickRipple, setCursorSpeed
|
||||
// Provider: CommandBusProvider — registers `navigate` via react-router,
|
||||
// mounts the cursor, exposes window.commandBus
|
||||
// WebSocket: connectCommandSocket, CommandSocket
|
||||
// LLM bridge: buildSystemPrompt, extractActionBlocks, runActionBlocks,
|
||||
// estimateTokens, trimMessages, RunActionBlocksResult,
|
||||
// SystemPromptContext
|
||||
// ===========================================================================
|
||||
"use client";
|
||||
|
||||
export * from "./bus"
|
||||
export * from "./parser"
|
||||
export * from "./script"
|
||||
export * from "./cursor"
|
||||
export * from "./ws"
|
||||
export * from "./llm-bridge"
|
||||
export { CommandBusProvider } from "./provider"
|
||||
Reference in New Issue
Block a user