npm.io
0.1.2 • Published 1 week ago

@particle-academy/fancy-auto-common

Licence
MIT
Version
0.1.2
Deps
0
Size
76 kB
Vulns
0
Weekly
0

@particle-academy/fancy-auto-common

Fancified

Shared headless primitives for autonomous UX drivers — the common core behind agent-integrations (agent-driven UX) and fancy-flow's FlowRunnerUx (flow-driven UX).

Zero runtime dependencies. The core entry is React-free; the optional /react entry adds a subscription hook.

npm install @particle-academy/fancy-auto-common

What's in it

  • Activity busemitActivity / onActivity / readActivityHistory. The event type, AutoActivityEvent, carries a source: "agent" | "flow" discriminant and is a back-compat superset of agent-integrations' historical AgentActivityEvent (same flat agentId / agentName / agentColor fields), so presence cursors, highlights, and screen-presence badges work for agents and flow runs alike.
  • Effect-dispatch registrycreateEffectDispatcher(effects, { actor }). A typed map of named, host-provided UX effects (toast, navigate, confirm, …). Agent tools and flow nodes both reduce to "invoke effect X with params"; every dispatch optionally broadcasts an activity event so presence / logging / undo compose for free.
  • Per-actor undo stackpushUndoEntry / undoOne / redoOne, keyed by actor id so multiple agents or flow runs rewind independently.
  • Presence typesPresenceParticipant, PresenceCursor.

Core (React-free)

import { createEffectDispatcher, onActivity } from "@particle-academy/fancy-auto-common";

const dispatch = createEffectDispatcher(
  { toast: ({ title }) => showToast(title) },
  { actor: { id: "run-1", source: "flow" } },
);

onActivity((e) => console.log(e.action), { source: "flow" });
await dispatch.dispatch("toast", { title: "Hello from a flow" }); // emits ux_toast activity

React

import { useActivity } from "@particle-academy/fancy-auto-common/react";

const { events, latest } = useActivity({ source: "flow" });

MIT Particle Academy


Star Fancy UI

If this package is useful to you, a quick on the repo really helps us build a better kit. Thank you!

Keywords