@burdenoff/microfe-vibecontrols 2026.529.5 → 2026.529.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.
@@ -1,22 +1,28 @@
1
1
  import { useTerminalCapabilityUrl as e } from "../../hooks/useTerminalCapabilityUrl.js";
2
- import { forwardRef as t } from "react";
3
- import { Fragment as n, jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as t, useEffect as n } from "react";
3
+ import { Fragment as r, jsx as i } from "react/jsx-runtime";
4
4
  //#region src/components/sessions/TerminalIframe.tsx
5
- var i = t(function({ sessionId: t, agentId: i, baseTtydUrl: a, title: o, className: s, allow: c, onLoad: l, onError: u, fallback: d }, f) {
6
- let { url: p, remint: m } = e(i, t, a);
7
- return p ? /* @__PURE__ */ r("iframe", {
8
- ref: f,
9
- src: p,
10
- title: o,
11
- className: s,
12
- allow: c,
13
- onLoad: l,
5
+ var a = t(function({ sessionId: t, agentId: a, baseTtydUrl: o, title: s, className: c, allow: l, onLoad: u, onError: d, fallback: f }, p) {
6
+ let { url: m, remint: h } = e(a, t, o);
7
+ return n(() => {
8
+ function e(e) {
9
+ let n = e?.data;
10
+ !n || typeof n != "object" || n.type === "vt-token-request" && (typeof n.sid != "string" || n.sid !== t || h());
11
+ }
12
+ return window.addEventListener("message", e), () => window.removeEventListener("message", e);
13
+ }, [t, h]), m ? /* @__PURE__ */ i("iframe", {
14
+ ref: p,
15
+ src: m,
16
+ title: s,
17
+ className: c,
18
+ allow: l,
19
+ onLoad: u,
14
20
  onError: () => {
15
- m(), u?.();
21
+ h(), d?.();
16
22
  }
17
- }) : /* @__PURE__ */ r(n, { children: d ?? null });
23
+ }) : /* @__PURE__ */ i(r, { children: f ?? null });
18
24
  });
19
25
  //#endregion
20
- export { i as TerminalIframe };
26
+ export { a as TerminalIframe };
21
27
 
22
28
  //# sourceMappingURL=TerminalIframe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalIframe.js","names":[],"sources":["../../../src/components/sessions/TerminalIframe.tsx"],"sourcesContent":["/**\n * TerminalIframe — renders the ttyd iframe with an F3-compliant\n * capability token appended as a `#vt=<token>` URL fragment.\n *\n * Each tab in the sessions terminal panel needs its own capability mint\n * (the iframe-token is scoped to `/terminal/<sessionId>`). React hooks\n * can't be called in a `tabs.map(...)` loop, so the iframe rendering is\n * extracted here and the hook runs per component instance.\n *\n * Stale browser tabs and reopened sessions hit a 10-minute cookie TTL\n * inside the agent; `onError` triggers `remint()` which re-fetches a\n * fresh token and re-iframes.\n */\nimport { type ReactNode, forwardRef } from 'react';\n\nimport { useTerminalCapabilityUrl } from '@/hooks/useTerminalCapabilityUrl';\n\nexport interface TerminalIframeProps {\n /** Session id — used as resourceId for the capability mint. */\n sessionId: string;\n /** Agent id owning this session — required for the mint mutation. */\n agentId: string | null | undefined;\n /** Bare ttyd tunnel URL from `session.ttydUrl`. Hook strips any legacy ?apiKey=. */\n baseTtydUrl: string | null | undefined;\n /** Title for accessibility. */\n title: string;\n /** Optional className for the iframe. */\n className?: string;\n /** Permissions-Policy allow attribute (clipboard). */\n allow?: string;\n /** Called on iframe load. Use to flip connection status to connected. */\n onLoad?: () => void;\n /** Called on iframe error. We re-mint internally + bubble the event. */\n onError?: () => void;\n /** Slot for fallback content when no URL is available yet. */\n fallback?: ReactNode;\n}\n\nexport const TerminalIframe = forwardRef<HTMLIFrameElement, TerminalIframeProps>(\n function TerminalIframe(\n { sessionId, agentId, baseTtydUrl, title, className, allow, onLoad, onError, fallback },\n ref\n ) {\n const { url, remint } = useTerminalCapabilityUrl(agentId, sessionId, baseTtydUrl);\n\n if (!url) {\n return <>{fallback ?? null}</>;\n }\n\n return (\n <iframe\n ref={ref}\n src={url}\n title={title}\n className={className}\n allow={allow}\n onLoad={onLoad}\n onError={() => {\n // Re-mint on any iframe error — covers both 401 (cookie expired\n // mid-session) and network blips.\n remint();\n onError?.();\n }}\n />\n );\n }\n);\n"],"mappings":";;;;AAsCA,IAAa,IAAiB,EAC5B,SACE,EAAE,cAAW,YAAS,gBAAa,UAAO,cAAW,UAAO,WAAQ,YAAS,eAC7E,GACA;CACA,IAAM,EAAE,QAAK,cAAW,EAAyB,GAAS,GAAW,EAAY;AAMjF,QAJK,IAKH,kBAAC,UAAD;EACO;EACL,KAAK;EACE;EACI;EACJ;EACC;EACR,eAAe;AAIb,GADA,GAAQ,EACR,KAAW;;EAEb,CAAA,GAjBK,kBAAA,GAAA,EAAA,UAAG,KAAY,MAAQ,CAAA;EAoBnC"}
1
+ {"version":3,"file":"TerminalIframe.js","names":[],"sources":["../../../src/components/sessions/TerminalIframe.tsx"],"sourcesContent":["/**\n * TerminalIframe — renders the ttyd iframe with an F3-compliant\n * capability token appended as a `#vt=<token>` URL fragment.\n *\n * Each tab in the sessions terminal panel needs its own capability mint\n * (the iframe-token is scoped to `/terminal/<sessionId>`). React hooks\n * can't be called in a `tabs.map(...)` loop, so the iframe rendering is\n * extracted here and the hook runs per component instance.\n *\n * Stale browser tabs and reopened sessions hit a 10-minute cookie TTL\n * inside the agent; `onError` triggers `remint()` which re-fetches a\n * fresh token and re-iframes.\n */\nimport { type ReactNode, forwardRef, useEffect } from 'react';\n\nimport { useTerminalCapabilityUrl } from '@/hooks/useTerminalCapabilityUrl';\n\nexport interface TerminalIframeProps {\n /** Session id — used as resourceId for the capability mint. */\n sessionId: string;\n /** Agent id owning this session — required for the mint mutation. */\n agentId: string | null | undefined;\n /** Bare ttyd tunnel URL from `session.ttydUrl`. Hook strips any legacy ?apiKey=. */\n baseTtydUrl: string | null | undefined;\n /** Title for accessibility. */\n title: string;\n /** Optional className for the iframe. */\n className?: string;\n /** Permissions-Policy allow attribute (clipboard). */\n allow?: string;\n /** Called on iframe load. Use to flip connection status to connected. */\n onLoad?: () => void;\n /** Called on iframe error. We re-mint internally + bubble the event. */\n onError?: () => void;\n /** Slot for fallback content when no URL is available yet. */\n fallback?: ReactNode;\n}\n\nexport const TerminalIframe = forwardRef<HTMLIFrameElement, TerminalIframeProps>(\n function TerminalIframe(\n { sessionId, agentId, baseTtydUrl, title, className, allow, onLoad, onError, fallback },\n ref\n ) {\n const { url, remint } = useTerminalCapabilityUrl(agentId, sessionId, baseTtydUrl);\n\n // F3 cookie-shim postMessage bridge.\n //\n // When the agent's bootstrap HTML rejects the iframe-token with\n // `code: 'expired'` or `code: 'replayed'`, it posts a\n // `{type: 'vt-token-request', sid}` message to its parent window\n // (this microfe) asking for a fresh mint. We listen for it and\n // call `remint()` so `useTerminalCapabilityUrl` issues a new\n // capability and the iframe src updates with a fresh `#vt=…`.\n //\n // This unblocks two real-world cases:\n // 1. React Strict Mode double-renders the iframe in dev, so the\n // first token's JTI gets consumed before the visible iframe\n // navigates — second navigation hits `replayed`.\n // 2. Operator leaves the tab idle past the 60s mint TTL — next\n // navigation hits `expired`.\n // Without the bridge the bootstrap dead-ends on \"Terminal\n // authentication failed\" until the operator manually reloads.\n useEffect(() => {\n function onMsg(ev: MessageEvent) {\n const data = ev?.data;\n if (!data || typeof data !== 'object') return;\n if (data.type !== 'vt-token-request') return;\n if (typeof data.sid !== 'string' || data.sid !== sessionId) return;\n remint();\n }\n window.addEventListener('message', onMsg);\n return () => window.removeEventListener('message', onMsg);\n }, [sessionId, remint]);\n\n if (!url) {\n return <>{fallback ?? null}</>;\n }\n\n return (\n <iframe\n ref={ref}\n src={url}\n title={title}\n className={className}\n allow={allow}\n onLoad={onLoad}\n onError={() => {\n // Re-mint on any iframe error — covers both 401 (cookie expired\n // mid-session) and network blips.\n remint();\n onError?.();\n }}\n />\n );\n }\n);\n"],"mappings":";;;;AAsCA,IAAa,IAAiB,EAC5B,SACE,EAAE,cAAW,YAAS,gBAAa,UAAO,cAAW,UAAO,WAAQ,YAAS,eAC7E,GACA;CACA,IAAM,EAAE,QAAK,cAAW,EAAyB,GAAS,GAAW,EAAY;AAmCjF,QAhBA,QAAgB;EACd,SAAS,EAAM,GAAkB;GAC/B,IAAM,IAAO,GAAI;AACb,IAAC,KAAQ,OAAO,KAAS,YACzB,EAAK,SAAS,uBACd,OAAO,EAAK,OAAQ,YAAY,EAAK,QAAQ,KACjD,GAAQ;;AAGV,SADA,OAAO,iBAAiB,WAAW,EAAM,QAC5B,OAAO,oBAAoB,WAAW,EAAM;IACxD,CAAC,GAAW,EAAO,CAAC,EAElB,IAKH,kBAAC,UAAD;EACO;EACL,KAAK;EACE;EACI;EACJ;EACC;EACR,eAAe;AAIb,GADA,GAAQ,EACR,KAAW;;EAEb,CAAA,GAjBK,kBAAA,GAAA,EAAA,UAAG,KAAY,MAAQ,CAAA;EAoBnC"}