ghostykit 0.6.4 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,6 +70,15 @@ export interface PilotoProps extends UsePilotOptions {
70
70
  text: string;
71
71
  key?: string | number;
72
72
  } | null;
73
+ /**
74
+ * Trabajo que sigue FUERA del run (ayudantes en segundo plano, una tarea larga): con el run ya
75
+ * cerrado, el hilo enseña `label` y cuenta desde `since` (ms) para que no parezca terminado.
76
+ * Con un run vivo manda su propia espera. `null` = nada pendiente.
77
+ */
78
+ background?: {
79
+ label: string;
80
+ since: number;
81
+ } | null;
73
82
  /** Referencias controladas (si no, Piloto las guarda; agrégalas con `ref.addReference`). */
74
83
  references?: Reference[];
75
84
  onReferencesChange?: (refs: Reference[]) => void;
@@ -1,6 +1,8 @@
1
1
  /** Los tres puntitos de «escribiendo» (color y animación en CSS: `gc-typing`). */
2
2
  export declare function TypingDots(): import("react").JSX.Element;
3
- export declare function WaitLabel({ since, showDuration, step, }: {
3
+ export declare function WaitLabel({ since, showDuration, step, text, }: {
4
+ /** Frase fija que gana a las del turno (p. ej. «2 ayudantes trabajando» con el run ya cerrado). */
5
+ text?: string | null;
4
6
  /** El paso con nombre en curso (`STEP_STARTED`): si `strings.steps` lo nombra, esa es la frase. */
5
7
  step?: string | null;
6
8
  /** Desde que se MANDÓ el mensaje (no desde que se montó la etiqueta). */
@@ -2285,7 +2285,8 @@ function TypingDots() {
2285
2285
  function WaitLabel({
2286
2286
  since,
2287
2287
  showDuration = true,
2288
- step
2288
+ step,
2289
+ text
2289
2290
  }) {
2290
2291
  const { strings: t } = usePiloto();
2291
2292
  const [mounted] = useState7(() => Date.now());
@@ -2297,7 +2298,7 @@ function WaitLabel({
2297
2298
  const seconds = Math.max(0, Math.floor((now - (since || mounted)) / 1e3));
2298
2299
  const phrases = t.thinkingPhrases;
2299
2300
  const stepText = step ? t.steps?.[step] : void 0;
2300
- const what = stepText ? stepText : phrases?.length ? seconds >= STILL_WORKING_S ? t.stillWorking : phrases[Math.floor(seconds / 4) % phrases.length] : t.howItGoes(seconds);
2301
+ const what = text ? text : stepText ? stepText : phrases?.length ? seconds >= STILL_WORKING_S ? t.stillWorking : phrases[Math.floor(seconds / 4) % phrases.length] : t.howItGoes(seconds);
2301
2302
  return /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-0.5 text-sm text-text-secondary", children: /* @__PURE__ */ jsxs7("p", { className: "flex items-center", children: [
2302
2303
  /* @__PURE__ */ jsx9(AnimatePresence2, { mode: "wait", initial: false, children: /* @__PURE__ */ jsx9(
2303
2304
  motion2.span,
@@ -2399,11 +2400,13 @@ function usePilot(transport, opts = {}) {
2399
2400
  if (!steering && (input.messages.length || input.resume?.length || input.forwardedProps?.continueRun)) liveRun.current = input.runId;
2400
2401
  optsRef.current.onSend?.(input);
2401
2402
  let ended = false;
2403
+ let gotEvent = false;
2402
2404
  try {
2403
2405
  await t.run(
2404
2406
  input,
2405
2407
  (e) => {
2406
2408
  if (c.signal.aborted) return;
2409
+ gotEvent = true;
2407
2410
  optsRef.current.onEvent?.(e);
2408
2411
  if (e.type === "RUN_FINISHED" || e.type === "RUN_ERROR") {
2409
2412
  ended = true;
@@ -2415,6 +2418,11 @@ function usePilot(transport, opts = {}) {
2415
2418
  );
2416
2419
  } catch (err) {
2417
2420
  if (c.signal.aborted) return;
2421
+ if (gotEvent && !(err instanceof PilotHttpError)) {
2422
+ if (!reopening) return runNow({ messages: [] }, true);
2423
+ commit(sendFailed(ref.current, "Se cort\xF3 la conexi\xF3n con el agente."));
2424
+ return;
2425
+ }
2418
2426
  const code = err instanceof PilotHttpError ? err.code : void 0;
2419
2427
  if (code === "run_not_live" && steering && userMsg) {
2420
2428
  const { text } = fromUserMessage(userMsg.content);
@@ -2912,6 +2920,10 @@ var Piloto = forwardRef3(function Piloto2(props, handle) {
2912
2920
  /* @__PURE__ */ jsx10(TypingDots, {}),
2913
2921
  /* @__PURE__ */ jsx10(WaitLabel, { since: state.turnStartedAt, step: state.step, showDuration: features.duration !== false })
2914
2922
  ] }),
2923
+ !busy && props.background && /* @__PURE__ */ jsxs8("div", { "data-background": true, className: "flex flex-col gap-1.5", children: [
2924
+ /* @__PURE__ */ jsx10(TypingDots, {}),
2925
+ /* @__PURE__ */ jsx10(WaitLabel, { text: props.background.label, since: props.background.since, showDuration: features.duration !== false })
2926
+ ] }),
2915
2927
  notice && /* @__PURE__ */ jsx10("p", { className: "text-sm text-text-tertiary", children: notice }),
2916
2928
  error && /* @__PURE__ */ jsx10("p", { className: "text-sm text-text-danger", children: error })
2917
2929
  ] }),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ghostykit",
3
- "version": "0.6.4",
4
- "description": "Ghosty Autopilot \u2014 the autopilot chat for your React app, on AG-UI: works with LangGraph, Mastra, CrewAI or any AG-UI agent. Streaming text, agent steps, human approval cards (interrupt/resume), attachments and voice.",
3
+ "version": "0.6.6",
4
+ "description": "Ghosty Autopilot — the autopilot chat for your React app, on AG-UI: works with LangGraph, Mastra, CrewAI or any AG-UI agent. Streaming text, agent steps, human approval cards (interrupt/resume), attachments and voice.",
5
5
  "type": "module",
6
6
  "main": "./dist/core/index.js",
7
7
  "types": "./dist/core/index.d.ts",