wizards 0.2.42 → 0.2.43
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.
- package/apps/runtime/dist/app.js +37 -3
- package/apps/runtime/dist/authoring/guide.js +5 -2
- package/apps/runtime/dist/browser/fast/action-space.js +162 -0
- package/apps/runtime/dist/browser/fast/classifier.js +91 -0
- package/apps/runtime/dist/browser/fast/decide.js +171 -0
- package/apps/runtime/dist/browser/fast/driver.js +141 -0
- package/apps/runtime/dist/browser/fast/instructions.js +33 -0
- package/apps/runtime/dist/browser/fast/run.js +249 -0
- package/apps/runtime/dist/browser/fast/span-picker.js +153 -0
- package/apps/runtime/dist/browser/fast/text-helper.js +178 -0
- package/apps/runtime/dist/browser/snapshot.js +335 -0
- package/apps/runtime/dist/db/migrations/tenant/0011_runners.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0011_snapshot.json +2956 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +4 -0
- package/apps/runtime/dist/engine/resources.js +109 -0
- package/apps/runtime/dist/engine/runner.js +7 -3
- package/apps/runtime/dist/engine/steps.js +89 -10
- package/apps/runtime/dist/env.js +9 -0
- package/apps/runtime/dist/harness/claude.js +9 -1
- package/apps/runtime/dist/link-preview.js +4 -3
- package/apps/runtime/dist/mcp/tools.js +1 -1
- package/apps/runtime/dist/media/conversation.js +177 -0
- package/apps/runtime/dist/models.js +17 -0
- package/apps/runtime/dist/plugins/loader.js +48 -2
- package/apps/runtime/dist/plugins/registry.js +1 -0
- package/apps/runtime/dist/plugins/runs.js +205 -0
- package/apps/runtime/dist/routes/runs.js +206 -22
- package/apps/runtime/dist/routes/studio.js +12 -1
- package/apps/runtime/dist/services/cloud.js +1 -0
- package/apps/runtime/dist/services/runners.js +138 -0
- package/apps/runtime/dist/services/runs.js +83 -45
- package/apps/runtime/dist/services/wizard-icon.js +12 -0
- package/apps/runtime/dist/services/wizards.js +5 -1
- package/apps/runtime/dist/tools/browser.js +426 -97
- package/apps/runtime/dist/tools/index.js +50 -3
- package/apps/web/dist/assets/ChangelogDialog-8qS5utcR.js +1 -0
- package/apps/web/dist/assets/ChatView-Bx1KVCEf.js +10 -0
- package/apps/web/dist/assets/{CreditsDialog-DPglouDr.js → CreditsDialog-BCuDsatt.js} +1 -1
- package/apps/web/dist/assets/EditorPage-_Sbj-mSD.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-CQN5acxA.js → FlowPreview-COgjib4H.js} +1 -1
- package/apps/web/dist/assets/{Harness-BFxUFB7B.js → Harness-BaxjV1Ng.js} +2 -2
- package/apps/web/dist/assets/HomePage-BlD0wZB0.js +1 -0
- package/apps/web/dist/assets/ImportWizard-BZDtNJg1.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-Ci_x__p9.js +2 -0
- package/apps/web/dist/assets/ProjectPage-NwFut2Z-.js +2 -0
- package/apps/web/dist/assets/PublicRunner-rHdvK18v.js +1 -0
- package/apps/web/dist/assets/RunDrawer-Dp-JowDX.js +4 -0
- package/apps/web/dist/assets/RunnerView-DSlReODC.js +2 -0
- package/apps/web/dist/assets/SettingsPage-2Bw-D3hC.js +1 -0
- package/apps/web/dist/assets/SetupPage-DHESCsTb.js +1 -0
- package/apps/web/dist/assets/SharePage-DdJ-qD-B.js +1 -0
- package/apps/web/dist/assets/ThemeSwitch-BkodFy16.js +1 -0
- package/apps/web/dist/assets/arrow-right-pf8p4FIz.js +1 -0
- package/apps/web/dist/assets/changelog-cmQb-lZW.js +1 -0
- package/apps/web/dist/assets/{circle-alert-B0rwkpC7.js → circle-alert-Gn4D6etf.js} +1 -1
- package/apps/web/dist/assets/{copy-DgbMaHoj.js → copy-C3D7PBYL.js} +1 -1
- package/apps/web/dist/assets/{definition-FVgbAXOo.js → definition-AlI4g-wR.js} +2 -2
- package/apps/web/dist/assets/{external-link-pP6YfR9-.js → external-link-M3mEgZA-.js} +1 -1
- package/apps/web/dist/assets/globe-BnaeE83w.js +1 -0
- package/apps/web/dist/assets/{image-D2X6TWdq.js → image-BuasG4Jr.js} +1 -1
- package/apps/web/dist/assets/index-BdrX1tJ4.js +78 -0
- package/apps/web/dist/assets/index-D6vcOCCh.css +1 -0
- package/apps/web/dist/assets/{lock-BG4mi_lJ.js → lock-CrB_z7n3.js} +1 -1
- package/apps/web/dist/assets/{meta-BD9yulXs.js → meta-CT4LmQ7g.js} +1 -1
- package/apps/web/dist/assets/mouse-pointer-click-BurvPVO8.js +1 -0
- package/apps/web/dist/assets/{pen-line-D54vxrGl.js → pen-line-BA6l84zC.js} +1 -1
- package/apps/web/dist/assets/{refresh-cw-DvTgdpdf.js → refresh-cw-DEKCEuIO.js} +1 -1
- package/apps/web/dist/assets/{session-CT1AZIlE.js → session-DCcgTTmG.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-DJATAPGg.js → settings-menu-C9fE9M0f.js} +1 -1
- package/apps/web/dist/assets/star-BwhVXiJM.js +1 -0
- package/apps/web/dist/assets/{trash-DAcf34LR.js → trash-WwlTeE_V.js} +1 -1
- package/apps/web/dist/assets/{type-BU0mWqf3.js → type-kpWj7Zf1.js} +1 -1
- package/apps/web/dist/assets/ui-Wxaw_APn.js +9 -0
- package/apps/web/dist/assets/{video-C6qoFAAs.js → video-U-idAC66.js} +1 -1
- package/apps/web/dist/assets/volume-2-BwidpioC.js +1 -0
- package/apps/web/dist/assets/{wand-sparkles-Bw4tu2An.js → wand-sparkles-DaINku4r.js} +1 -1
- package/apps/web/dist/embed.js +119 -4
- package/apps/web/dist/index.html +12 -11
- package/apps/web/dist/mcp/flow.html +45 -45
- package/modules/calls/dist/client.css +3 -0
- package/modules/calls/dist/client.js +1 -0
- package/modules/calls/engenty.plugin.json +8 -0
- package/modules/calls/migrations/0001_init.sql +26 -0
- package/modules/calls/package.json +25 -0
- package/modules/calls/src/openai.ts +155 -0
- package/modules/calls/src/plugin.ts +407 -0
- package/modules/calls/src/rules.ts +226 -0
- package/modules/calls/src/schema.ts +39 -0
- package/modules/calls/src/session.ts +353 -0
- package/modules/calls/src/store.ts +124 -0
- package/modules/calls/src/twilio.ts +90 -0
- package/modules/calls/tsconfig.json +10 -0
- package/modules/calls/ui/Settings.tsx +137 -0
- package/modules/calls/ui/app.ts +50 -0
- package/modules/calls/ui/messages.ts +81 -0
- package/modules/calls/ui/parts.tsx +36 -0
- package/modules/calls/ui/plugin.tsx +15 -0
- package/modules/sms/dist/client.css +3 -0
- package/modules/sms/dist/client.js +1 -0
- package/modules/sms/engenty.plugin.json +8 -0
- package/modules/sms/migrations/0001_init.sql +26 -0
- package/modules/sms/package.json +25 -0
- package/modules/sms/src/plugin.ts +324 -0
- package/modules/sms/src/schema.ts +26 -0
- package/modules/sms/src/store.ts +140 -0
- package/modules/sms/src/surface.ts +70 -0
- package/modules/sms/src/twilio.ts +130 -0
- package/modules/sms/tsconfig.json +10 -0
- package/modules/sms/ui/Settings.tsx +113 -0
- package/modules/sms/ui/Share.tsx +78 -0
- package/modules/sms/ui/app.ts +51 -0
- package/modules/sms/ui/messages.ts +72 -0
- package/modules/sms/ui/parts.tsx +36 -0
- package/modules/sms/ui/plugin.tsx +20 -0
- package/modules/whatsapp/dist/client.css +3 -0
- package/modules/whatsapp/dist/client.js +1 -0
- package/modules/whatsapp/engenty.plugin.json +8 -0
- package/modules/whatsapp/migrations/0001_init.sql +30 -0
- package/modules/whatsapp/package.json +25 -0
- package/modules/whatsapp/src/graph.ts +271 -0
- package/modules/whatsapp/src/inbound.ts +143 -0
- package/modules/whatsapp/src/plugin.ts +369 -0
- package/modules/whatsapp/src/schema.ts +32 -0
- package/modules/whatsapp/src/store.ts +156 -0
- package/modules/whatsapp/src/surface.ts +127 -0
- package/modules/whatsapp/tsconfig.json +10 -0
- package/modules/whatsapp/ui/Settings.tsx +141 -0
- package/modules/whatsapp/ui/Share.tsx +78 -0
- package/modules/whatsapp/ui/app.ts +54 -0
- package/modules/whatsapp/ui/messages.ts +82 -0
- package/modules/whatsapp/ui/parts.tsx +36 -0
- package/modules/whatsapp/ui/plugin.tsx +20 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +259 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +17 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.d.ts +174 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.js +816 -0
- package/node_modules/@engenty-wizards/plugin-sdk/package.json +2 -1
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +8 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.js +21 -0
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +61 -3
- package/node_modules/@engenty-wizards/shared/dist/run.js +16 -0
- package/node_modules/@engenty-wizards/shared/dist/runners.d.ts +81 -0
- package/node_modules/@engenty-wizards/shared/dist/runners.js +146 -0
- package/package.json +1 -1
- package/apps/web/dist/assets/ChangelogDialog-BxRBTR8P.js +0 -1
- package/apps/web/dist/assets/EditorPage-BKAFzzWk.js +0 -3
- package/apps/web/dist/assets/HomePage-BZuwrr-b.js +0 -1
- package/apps/web/dist/assets/ImportWizard-JGMemER4.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-BwHAsJwj.js +0 -2
- package/apps/web/dist/assets/ProjectPage--ijr1jPE.js +0 -2
- package/apps/web/dist/assets/PublicRunner-D9Oe-_vs.js +0 -1
- package/apps/web/dist/assets/RunDrawer-BfociUm2.js +0 -4
- package/apps/web/dist/assets/RunnerView-D2b84UTY.js +0 -2
- package/apps/web/dist/assets/SettingsPage-9rk9IRdr.js +0 -1
- package/apps/web/dist/assets/SetupPage-BUJh_v9q.js +0 -1
- package/apps/web/dist/assets/SharePage-sNJ_s1RE.js +0 -1
- package/apps/web/dist/assets/ThemeSwitch-NDTEeh0R.js +0 -1
- package/apps/web/dist/assets/arrow-right-C1xLSnNa.js +0 -1
- package/apps/web/dist/assets/changelog-BSVi9hHS.js +0 -1
- package/apps/web/dist/assets/index-CBjgitjd.js +0 -78
- package/apps/web/dist/assets/index-gTcC8eX6.css +0 -1
- package/apps/web/dist/assets/star-CaOg5c-D.js +0 -1
- package/apps/web/dist/assets/ui-Bxf6zX5k.js +0 -9
- package/apps/web/dist/assets/volume-2-Dw4p9Ln4.js +0 -1
|
@@ -3,6 +3,7 @@ import { isTextMime } from "@engenty-wizards/shared/workspace";
|
|
|
3
3
|
import { createTool } from "@mastra/core/tools";
|
|
4
4
|
import { MCPClient } from "@mastra/mcp";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { documentMime, parseDocument } from "../documents/parse.js";
|
|
6
7
|
import { generateImageMedia } from "../media/generate.js";
|
|
7
8
|
import { markMedia } from "../media/marking.js";
|
|
8
9
|
import { gatewayTools, isHarnessVendor } from "../models.js";
|
|
@@ -18,6 +19,31 @@ import { pluginTools, spaceContextOf } from "./plugin.js";
|
|
|
18
19
|
import { projectTools } from "./project.js";
|
|
19
20
|
import { clip, FileKeeper } from "./shared.js";
|
|
20
21
|
import { storeTools } from "./store.js";
|
|
22
|
+
/**
|
|
23
|
+
* Whether a fetched body is text a model can read: a text type, or no type and next to no
|
|
24
|
+
* bytes that only decode as replacement or control characters.
|
|
25
|
+
*/
|
|
26
|
+
function isReadable(type, body) {
|
|
27
|
+
if (isTextMime(type) ||
|
|
28
|
+
type.includes("html") ||
|
|
29
|
+
type.includes("xml") ||
|
|
30
|
+
type.includes("json") ||
|
|
31
|
+
type.includes("javascript")) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (type && type !== "application/octet-stream") {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const sample = body.slice(0, 4000);
|
|
38
|
+
let odd = 0;
|
|
39
|
+
for (let i = 0; i < sample.length; i++) {
|
|
40
|
+
const code = sample.charCodeAt(i);
|
|
41
|
+
if (code === 0xfffd || code < 0x09 || (code > 0x0d && code < 0x20)) {
|
|
42
|
+
odd++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return odd <= sample.length * 0.01;
|
|
46
|
+
}
|
|
21
47
|
/** The tools an agent step may use: exactly what its definition allowlists. */
|
|
22
48
|
export async function buildStepTools(step, ctx, resolved, uploads) {
|
|
23
49
|
const tools = {};
|
|
@@ -54,8 +80,29 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
|
|
|
54
80
|
signal: AbortSignal.any([ctx.signal, AbortSignal.timeout(20_000)]),
|
|
55
81
|
headers: { "user-agent": "Mozilla/5.0 (compatible; engenty-wizards/0.1)" },
|
|
56
82
|
});
|
|
57
|
-
const type = res.headers.get("content-type") ?? "";
|
|
58
|
-
const
|
|
83
|
+
const type = (res.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
|
|
84
|
+
const data = new Uint8Array(await res.arrayBuffer());
|
|
85
|
+
const name = new URL(res.url || safe.toString()).pathname.split("/").pop() || "download";
|
|
86
|
+
const mime = documentMime(name, type);
|
|
87
|
+
// A PDF or Word file is read by its own text; an image or other bytes are not text at all.
|
|
88
|
+
if (mime === "application/pdf" || mime.includes("word")) {
|
|
89
|
+
const doc = await parseDocument({ data, name, mime }, { charge: (usd) => ctx.chargeUsd(usd), signal: ctx.signal, call: ctx.call }).catch(() => null);
|
|
90
|
+
return doc
|
|
91
|
+
? { status: res.status, url: res.url, content: clip(doc.markdown) }
|
|
92
|
+
: { status: res.status, url: res.url, error: `The ${mime} file could not be read.` };
|
|
93
|
+
}
|
|
94
|
+
const body = new TextDecoder().decode(data);
|
|
95
|
+
if (!isReadable(type, body)) {
|
|
96
|
+
return {
|
|
97
|
+
status: res.status,
|
|
98
|
+
url: res.url,
|
|
99
|
+
type: type || "unknown",
|
|
100
|
+
bytes: data.length,
|
|
101
|
+
note: type.startsWith("image/")
|
|
102
|
+
? "An image, not a page: the address works. Its bytes are not text and are not shown."
|
|
103
|
+
: "Not a text page: its bytes are not shown.",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
59
106
|
const text = type.includes("html") ? htmlToMarkdown(body) : body;
|
|
60
107
|
return { status: res.status, url: res.url, content: clip(text) };
|
|
61
108
|
},
|
|
@@ -89,7 +136,7 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
|
|
|
89
136
|
}
|
|
90
137
|
const files = new FileKeeper(ctx, assets);
|
|
91
138
|
if (allowed.has("browser")) {
|
|
92
|
-
Object.assign(tools, browserTools(ctx, assets, files));
|
|
139
|
+
Object.assign(tools, await browserTools(ctx, assets, files));
|
|
93
140
|
}
|
|
94
141
|
// The wizard's lists and files, the documents the person gave and the project's documents are
|
|
95
142
|
// always at hand.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{t as r}from"./preload-helper-CNEI7N0N.js";import{M as i,a,f as o,g as s,i as c,s as l}from"./ui-Wxaw_APn.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):i(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/engenty-wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await r(async()=>{let{default:e}=await import(`./changelog-cmQb-lZW.js`);return{default:e}},[])).default}function v({open:e,onClose:t,version:n}){let[r,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||r)return;let t=!1;return _(n).then(e=>{t||v(e)}),()=>{t=!0}},[e,r,n]),(0,u.useEffect)(()=>{e||b(``)},[e]);let x=r?g(r,y):[];return(0,d.jsxs)(c,{open:e,onClose:t,title:i(`about.changelog`),wide:!0,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:i(`about.changelogHint`)}),r===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(o,{})}):r.length===0?(0,d.jsx)(a,{children:i(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{type:`search`,value:y,placeholder:i(`about.search`),onChange:e=>b(e.target.value)}),x.length===0?(0,d.jsx)(a,{children:i(`about.noMatches`)}):null,x.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`ul`,{className:`mt-3 flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:s(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:i(`about.breaking`)}):null]})]},e.id)})})]},e.version??`unreleased`))]})]})}export{v as ChangelogDialog};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,S as i,g as a,o}from"./definition-AlI4g-wR.js";import{t as s}from"./react-dom-DenslgJm.js";import{A as c,F as l,K as u,L as d,M as f,O as p,R as m,S as h,U as g,W as _,b as v,f as y,g as b,h as x,k as S,l as C,o as w}from"./ui-Wxaw_APn.js";import{_ as T,a as E,c as D,d as O,f as k,g as A,i as j,l as M,m as N,n as P,o as F,p as I,r as L,s as ee,u as te,v as R}from"./RunnerView-DSlReODC.js";import{t as z}from"./video-U-idAC66.js";import{t as ne}from"./volume-2-BwidpioC.js";import{L as re,T as ie,b as ae,f as oe,h as se}from"./index-BdrX1tJ4.js";var ce={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};ce.node;var le=u(ce),ue={name:`mic-off`,size:24,node:[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]};ue.node;var de=u(ue),fe={name:`phone-off`,size:24,node:[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]};fe.node;var pe=u(fe),me={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};me.node;var he=u(me),ge={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};ge.node;var _e=u(ge),ve={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};ve.node;var ye=u(ve),be=s(),B=e(t(),1),xe=`wz.readAloud`,V=typeof window<`u`&&`speechSynthesis`in window&&`SpeechSynthesisUtterance`in window;function Se(){try{return localStorage.getItem(xe)===`1`}catch{return!1}}function Ce(e){try{localStorage.setItem(xe,e?`1`:`0`)}catch{}}function we(e){let t=window.speechSynthesis.getVoices(),n=e.slice(0,2);return t.find(t=>t.lang===e&&t.default)??t.find(t=>t.lang===e)??t.find(e=>e.lang.startsWith(n)&&e.default)??t.find(e=>e.lang.startsWith(n))??null}function Te(e,t=c,n=!1){if(!V||!e.trim())return;let r=window.speechSynthesis;n&&r.cancel();let i=t===`de`?`de-DE`:`en-US`,a=new SpeechSynthesisUtterance(e.trim().slice(0,2e3));a.lang=i;let o=we(i);o&&(a.voice=o),r.speak(a)}function Ee(){V&&window.speechSynthesis.cancel()}function De(){let[e,t]=(0,B.useState)(()=>V&&Se()),n=(0,B.useCallback)(e=>{t(e),Ce(e),e||Ee()},[]);return(0,B.useEffect)(()=>{V&&window.speechSynthesis.getVoices()},[]),(0,B.useEffect)(()=>()=>Ee(),[]),[e,n]}function Oe(e,t,n,r){let i=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!e){i.current=null;return}let a=n.map(e=>e.key);if(!i.current){i.current=new Set(a);let e=[...n].reverse().find(e=>e.who===`bot`&&e.spoken!==!1);if(e){let n=r(e.key);n&&Te(n,t,!0)}return}let o=n.filter(e=>!i.current?.has(e.key));for(let e of a)i.current.add(e);o.some(e=>e.who===`me`)&&Ee();for(let e of o)if(e.who===`bot`&&e.spoken!==!1){let n=r(e.key);n&&Te(n,t)}},[e,t,n,r])}var H=e(n(),1),ke=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Ae({since:e}){let[t,n]=(0,B.useState)(Date.now());if((0,B.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,H.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function U({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:b(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,H.jsx)(y,{className:`size-5`}):a})}function je({voice:e}){let t=(0,B.useRef)(null),{captions:n}=e;return(0,B.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,H.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,H.jsx)(`li`,{className:b(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,H.jsx)(`div`,{ref:t})]})}):null}function Me({voice:e,view:t,video:n,className:i}){let a=e.state===`live`,o=e.state===`connecting`,[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>{c(a?Date.now():null)},[a]);let d=async()=>{u(!1),await e.start(),n&&await e.startCamera()},p=()=>{e.stop(),u(!0)},h=n||e.camera,g=[...e.captions].reverse().find(e=>e.who===`bot`),_=[...e.captions].reverse().find(e=>e.who===`me`),v=e.speaking?f(`talk.speaking`):e.listening?f(`talk.listening`):a?f(`talk.live`):o?f(`talk.connecting`):l?f(`video.ended`):``;return(0,H.jsxs)(`section`,{className:b(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,i),children:[(0,H.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),v?(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[a?(0,H.jsx)(`span`,{className:b(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,v]}):null,(0,H.jsx)(Ae,{since:s})]}),(0,H.jsxs)(`div`,{className:b(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,h?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!h&&a&&e.captions.length?`h-[38%]`:h?``:`flex-1`),children:[(0,H.jsxs)(`div`,{className:b(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!h&&`hidden`),children:[(0,H.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:b(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,H.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,H.jsx)(_e,{className:`size-8`}),(0,H.jsx)(`span`,{className:`text-[0.8125rem]`,children:f(`video.cameraOff`)})]}),(0,H.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[f(`video.you`),e.muted?(0,H.jsx)(de,{className:`ml-1.5 inline size-3`}):null]})]}),(0,H.jsxs)(`div`,{className:b(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,h?`bg-neutral-900`:`bg-transparent`,h&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,H.jsx)(`div`,{className:b(`rounded-full transition-shadow duration-500`,!h&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!h&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,H.jsx)(r,{kind:t?.wizard.avatar??`round`,size:h?140:200,fluffy:!0,interactive:!1})}),h?(0,H.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),a&&!h?(0,H.jsx)(je,{voice:e}):a&&(g||_)?(0,H.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[_?(0,H.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:_.text}):null,g?(0,H.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:g.text}):null]})}):null,e.error?(0,H.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,H.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{label:f(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,H.jsx)(de,{className:`size-5`}):(0,H.jsx)(m,{className:`size-5`})}),(0,H.jsx)(U,{label:f(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,H.jsx)(z,{className:`size-5`}):(0,H.jsx)(_e,{className:`size-5`})}),e.camera&&ke?(0,H.jsx)(U,{label:f(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,H.jsx)(N,{className:`size-5`})}):null,(0,H.jsx)(U,{label:f(`video.leave`),danger:!0,onClick:p,children:(0,H.jsx)(pe,{className:`size-5`})})]}):(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:o||!t?.talk,onClick:()=>void d(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[o?(0,H.jsx)(y,{className:`size-4`}):n?(0,H.jsx)(z,{className:`size-5`}):(0,H.jsx)(m,{className:`size-5`}),f(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,H.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:f(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ne=e=>o[e.kind]!==`device`,Pe=1024,Fe=4e3;function Ie(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Le(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),r.join(`
|
|
2
|
+
`);if(e.status===`running`){let t=[...e.events].reverse().find(e=>e.type===`tool`||e.type===`info`||e.type===`step_started`);return r.push(`working on: ${e.step?.title??``}`),t&&r.push(`doing: ${S(t)}`),r.join(`
|
|
3
|
+
`)}if(e.status===`done`){r.push(`done. made:`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.title}: ${Ie(n?.text,400)||`(a file, on the screen)`}`);return r.join(`
|
|
4
|
+
`)}if(e.status===`failed`)return r.push(`failed: ${e.error??``}; go_back or the person retries on the screen`),r.join(`
|
|
5
|
+
`);if(t){r.push(`page: ${t.step.title}`);for(let e of t.fields){let n=t.values[e.id],i=n!=null&&n!==``,a=Ne(e)?`by voice`:e.kind===`image`?`with the camera (take_photo) or on the screen`:`on the screen only`,o=e.options?.length?`; options: ${e.options.join(` | `)}`:``;r.push(`- field ${e.id} (${e.kind}${e.required?`, required`:``}, ${a}): ${e.label}${e.help?` – ${e.help}`:``}${o}${i?` = ${Ie(String(Array.isArray(n)?n.join(`, `):n),120)}`:` = (open)`}`)}return r.join(`
|
|
6
|
+
`)}if(e.step?.type===`review`){r.push(`review: ${e.step.title}`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.id} "${t.title}": ${Ie(n?.text,600)||`(a picture or file, on the screen)`}`);return r.push(`regenerate allowed: ${e.step.regenerate?`yes`:`no`}`),r.join(`
|
|
7
|
+
`)}return r.push(`step: ${e.step?.title??``}`),r.join(`
|
|
8
|
+
`)}function Re(e,t,n,r){let[i,a]=(0,B.useState)(`off`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!1),[g,_]=(0,B.useState)(`environment`),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)([]),S=(0,B.useRef)(null),C=(0,B.useRef)(null),w=(0,B.useRef)(0),T=(0,B.useRef)(!1);T.current=p;let E=(0,B.useRef)(null),D=(0,B.useRef)(null),O=(0,B.useRef)(null),k=(0,B.useRef)(null),A=(0,B.useRef)(t);A.current=t;let j=(0,B.useRef)(r);j.current=r;let M=(0,B.useRef)(n);M.current=n;let N=(0,B.useRef)(``),P=(0,B.useCallback)(e=>{let t=D.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),F=(0,B.useCallback)(()=>{let e=S.current;if(!T.current||!e||e.videoWidth===0)return null;let t=Math.min(1,Pe/e.videoWidth),n=document.createElement(`canvas`);return n.width=Math.round(e.videoWidth*t),n.height=Math.round(e.videoHeight*t),n.getContext(`2d`)?.drawImage(e,0,0,n.width,n.height),n.toDataURL(`image/jpeg`,.75)},[]),I=(0,B.useCallback)(()=>{for(let e of C.current?.getTracks()??[])e.stop();C.current=null,S.current&&(S.current.srcObject=null),m(!1)},[]),L=(0,B.useCallback)(async e=>{if(C.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});C.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;_(n===`user`||n===`environment`?n:t),S.current&&(S.current.srcObject=e,await S.current.play().catch(()=>void 0)),m(!0)}catch(e){s(e.name===`NotAllowedError`?f(`talk.cameraDenied`):e.message)}},[]),ee=(0,B.useCallback)(async()=>{let e=g===`user`?`environment`:`user`;I(),await L(e)},[g,I,L]),te=(0,B.useCallback)(()=>{y(e=>{for(let t of k.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),R=(0,B.useCallback)(()=>{I(),D.current?.close(),D.current=null,E.current?.close(),E.current=null;for(let e of k.current?.getTracks()??[])e.stop();k.current=null,O.current&&=(O.current.srcObject=null,O.current.remove(),null),N.current=``,l(!1),d(!1),y(!1),a(`off`)},[I]);(0,B.useEffect)(()=>()=>R(),[R]);let z=(0,B.useCallback)(async(t,n)=>{let r=A.current,i=j.current,a=M.current;switch(t){case`get_state`:return r?Le(r,i,T.current):`no run`;case`look`:{let e=F();return e?(P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows right now`},{type:`input_image`,image_url:e}]}}),`a picture arrived as the next message`):`the camera is off; ask the person to switch it on`}case`take_photo`:{if(!i)return`no page is open`;let t=i.fields.find(e=>e.id===String(n.field??``));if(t?.kind!==`image`)return`no such photo field on this page`;let r=F();if(!r)return`the camera is off; ask the person to switch it on`;try{let n=await(await fetch(r)).blob(),a=new File([n],`photo-${Date.now()}.jpg`,{type:`image/jpeg`}),o=await h.upload(`/api/runs/${e}/uploads`,a),s=i.values[t.id],c=t.multiple?[...Array.isArray(s)?s:s?[s]:[],o.id]:o.id,l=i.setField(t.id,c);return l?`refused: ${l}`:`the photo is in the field`}catch(e){return`failed: ${e.message}`}}case`set_field`:{if(!i)return`no page is open`;let e=i.setField(String(n.field??``),n.value);return e?`refused: ${e}`:`kept`}case`submit_page`:{if(!i)return`no page is open`;let e=i.fields.filter(e=>e.required&&Ne(e)&&e.kind!==`toggle`&&(i.values[e.id]===void 0||i.values[e.id]===null||i.values[e.id]===``));return e.length?`still open: ${e.map(e=>e.id).join(`, `)}`:(i.submit(),`sent; wait for the next state`)}case`accept_review`:return r?.step?.type===`review`?await a.accept(r.step.id)?`accepted`:a.error??`refused`:`no review is open`;case`regenerate`:return r?.step?.type===`review`?await a.regenerate(r.step.id,String(n.target??``),String(n.note??``))?`the wizard makes it again; wait`:a.error??`refused`:`no review is open`;case`answer_ask`:if(!r?.ask)return`no question is open`;try{return await h.post(`/api/runs/${e}/ask/${r.ask.id}`,{type:n.allow?`done`:`skip`}),n.allow?`allowed`:`skipped`}catch(e){return`refused: ${e.message}`}case`go_back`:return await a.back()?`went back; wait for the state`:a.error??`refused`;default:return`unknown tool ${t}`}},[e,F,P]),ne=(0,B.useCallback)(async()=>{if(!E.current){s(null),x([]),a(`connecting`);try{let t=await h.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:!0});k.current=n;let r=new RTCPeerConnection;E.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),O.current=i,r.ontrack=e=>{i.srcObject=e.streams[0]};for(let e of n.getTracks())r.addTrack(e,n);let o=r.createDataChannel(`oai-events`);D.current=o,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:l(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:l(!1);break;case`input_audio_buffer.speech_started`:{d(!0);let e=Date.now()-w.current>Fe?F():null;e&&(w.current=Date.now(),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows while speaking`},{type:`input_image`,image_url:e}]}}));break}case`input_audio_buffer.speech_stopped`:d(!1);break;case`response.output_audio_transcript.done`:case`conversation.item.input_audio_transcription.completed`:{let e=String(t.transcript??``).trim();if(e){let n=t.type===`response.output_audio_transcript.done`?`bot`:`me`;x(t=>[...t.slice(-199),{id:`${Date.now()}:${n}`,who:n,text:e}])}break}case`response.function_call_arguments.done`:{let e=String(t.name??``),n=String(t.call_id??``),r={};try{r=JSON.parse(String(t.arguments??`{}`))}catch{}z(e,r).then(e=>{P({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:n,output:e}}),P({type:`response.create`})});break}case`error`:s(String(t.error?.message??`error`))}},o.onopen=()=>{a(`live`);let e=A.current;e&&(N.current=Le(e,j.current,T.current),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${N.current}\n\nGreet the person in one sentence and ask the first open field.`}]}}),P({type:`response.create`}))},o.onclose=()=>{E.current===r&&R()};let c=await r.createOffer();await r.setLocalDescription(c);let u=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!u.ok)throw Error(`${f(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){R(),s(e.name===`NotAllowedError`?f(`chat.micDenied`):e.message),a(`error`)}}},[e,z,F,P,R]);return(0,B.useEffect)(()=>{if(i!==`live`||!t)return;let e=Le(t,r,p);if(e===N.current)return;let n=N.current;N.current=e,P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${e}`}]}}),(t.status===`running`&&n.startsWith(`status: running`)&&!n.includes(`working on: `)||t.status!==`running`||n.split(`
|
|
9
|
+
`)[1]!==e.split(`
|
|
10
|
+
`)[1])&&P({type:`response.create`})},[i,t,r,p,P]),{state:i,error:o,speaking:c,listening:u,start:ne,stop:R,camera:p,facing:g,startCamera:L,stopCamera:I,flipCamera:ee,muted:v,toggleMute:te,captions:b,video:S}}var W=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),G=(e,t,n)=>({key:e,who:`me`,node:t,...n}),ze=(0,B.createContext)(null),K=(0,B.createContext)(null);function Be(){return(0,B.useContext)(K)?.voice??null}function Ve({children:e}){let t=(0,B.useContext)(ze);return t?(0,be.createPortal)(e,t):null}function He({header:e,footer:t,children:n}){let[r,i]=(0,B.useState)(null),a=(0,B.useRef)(null),o=(0,B.useRef)(null),s=(0,B.useRef)(!0);return(0,B.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,H.jsx)(ze.Provider,{value:r,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,H.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,H.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,H.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,H.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function q({avatar:e,lines:t}){let n=(0,B.useContext)(K),i=(0,B.useMemo)(()=>t.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[t]),a=(0,B.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);Oe(!!n?.readAloud,n?.lang??c,i,a);let o=[];for(let e of t){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.map((t,n)=>t.who===`bot`?(0,H.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,H.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,H.jsx)(r,{kind:e,size:30,interactive:n>=o.length-2})}),(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:t.lines.map(e=>(0,H.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:b(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?b(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},t.lines[0].key):t.lines.map(e=>(0,H.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,H.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,H.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,H.jsx)(R,{className:`size-3`}),` `,f(`chat.change`)]}):null]},e.key)))}function Ue(){return(0,H.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":f(`run.working`),children:[0,1,2].map(e=>(0,H.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function J({children:e}){return(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var Y=(e,t)=>W(e,(0,H.jsx)(J,{children:t}),{bare:!0});function X({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:b(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[a?(0,H.jsx)(y,{className:`size-4`}):null,t]})}function Z({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:o,onSend:s}){let[c,u]=(0,B.useState)(e),d=(0,B.useRef)(null),p=o??d,h=(0,B.useContext)(K),g=v(c,u,{endpoint:h?`/api/runs/${h.runId}/transcribe`:void 0}),S=!!h&&g.supported&&!a;(0,B.useEffect)(()=>{if(!S)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),g.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,g.toggle]),(0,B.useEffect)(()=>{!ae&&!a&&p.current?.focus()},[a,p]);let C=()=>{i||a||(g.listening&&g.toggle(),s(c)!==!1&&u(``))},E=g.listening?f(`chat.listening`):g.processing?f(`chat.transcribing`):t,D=h?.voice??null,O=!!h?.call,k=h&&!O&&(V||S||D)?(0,H.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[D?(0,H.jsx)(w,{label:f(D.state===`live`?`talk.stop`:D.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":D.state===`live`,disabled:D.state===`connecting`,onClick:()=>D.state===`live`?D.stop():void D.start(),className:b(`size-9`,D.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,D.state===`off`&&h.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:D.state===`connecting`?(0,H.jsx)(y,{className:`size-4`}):D.state===`live`?(0,H.jsx)(pe,{className:`size-4`}):(0,H.jsx)(T,{className:`size-4`})}):null,D?.state===`live`?(0,H.jsx)(w,{label:f(D.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":D.camera,onClick:()=>D.camera?D.stopCamera():void D.startCamera(),className:b(`size-9`,D.camera&&`text-ink`),children:D.camera?(0,H.jsx)(z,{className:`size-4`}):(0,H.jsx)(_e,{className:`size-4`})}):null,V?(0,H.jsx)(w,{label:f(h.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":h.readAloud,onClick:()=>h.setReadAloud(!h.readAloud),className:b(`size-9`,h.readAloud&&`text-ink`),children:h.readAloud?(0,H.jsx)(ne,{className:`size-4`}):(0,H.jsx)(ye,{className:`size-4`})}):null,S?(0,H.jsx)(w,{label:f(g.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":g.listening,disabled:g.processing,onClick:g.toggle,className:b(`size-9`,g.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:g.processing?(0,H.jsx)(y,{className:`size-4`}):g.listening?(0,H.jsx)(l,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,H.jsx)(m,{className:`size-4`})}):null]}):null;return(0,H.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),C()},children:[D&&!O?(0,H.jsx)(`video`,{ref:D.video,muted:!0,playsInline:!0,autoPlay:!0,className:b(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,D.camera?`block`:`hidden`)}):null,(0,H.jsxs)(`div`,{className:b(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,a&&`opacity-60`),children:[k,n?(0,H.jsx)(x,{ref:p,minRows:1,maxRows:6,value:c,disabled:a,placeholder:E,autoCapitalize:`sentences`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!ae&&!e.nativeEvent.isComposing&&(e.preventDefault(),C())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,H.jsx)(`input`,{ref:p,...r,value:c,disabled:a,placeholder:E,enterKeyHint:`send`,onChange:e=>u(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,H.jsx)(`button`,{type:`submit`,"aria-label":f(`chat.send`),title:f(`chat.send`),disabled:i||a,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:i?(0,H.jsx)(y,{className:`size-4`}):(0,H.jsx)(_,{className:`size-4`})})]}),g.error?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:g.error===`denied`?f(`chat.micDenied`):g.error}):O?null:D?.error?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:D.error}):D?.state===`live`?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:D.speaking?f(`talk.speaking`):D.listening?f(`talk.listening`):f(`talk.live`)}):h?.talk&&D?.state===`off`?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:f(`talk.hint`)}):null]})}function Q({placeholder:e=f(`chat.above`)}){return(0,H.jsx)(Ve,{children:(0,H.jsx)(Z,{disabled:!0,placeholder:e,onSend:()=>!1})})}function We(e){let t=o[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var Ge=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function Ke(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(Ge(t))return e.required&&!n?f(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return f(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return f(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?f(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?f(`run.filesMin`,{n:t.length,min:e.min}):null}function qe(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function Je({field:e}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,H.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function Ye({step:e,only:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,H.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,H.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function Xe({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,H.jsx)(H.Fragment,{children:typeof t==`string`&&t?t:f(`chat.connected`)});if(e.kind===`list`)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(g,{className:`size-4`}),` `,f(`chat.checked`)]});if(e.kind===`toggle`)return(0,H.jsx)(H.Fragment,{children:f(t===!0?`run.yes`:`run.no`)});if(Ge(t))return(0,H.jsx)(`span`,{className:`italic opacity-80`,children:f(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,H.jsx)(H.Fragment,{children:t.join(`, `)});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,H.jsx)(H.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(c,{dateStyle:`long`}).format(e)})}case`color`:return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,H.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,H.jsx)(`img`,{src:p(`/api/runs/${n}/assets/${t}`),alt:``,className:b(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(d,{className:`size-4`}),` `,f(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(m,{className:`size-4`}),` `,f(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,H.jsx)(H.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,H.jsx)(H.Fragment,{children:f(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,H.jsx)(H.Fragment,{children:String(t)})}}function Ze(e,t,n,r,i,a){let o=[W(t,(0,H.jsx)(Ye,{step:e,only:a}))];for(let e of i)a||o.push(W(`${t}:${e.id}`,(0,H.jsx)(Je,{field:e}))),o.push(G(`${t}:${e.id}:a`,(0,H.jsx)(Xe,{field:e,value:n[e.id],runId:r})));return o}var Qe=(e,t)=>e.fields.filter(e=>!e.when&&!a(e)||t[e.id]!==void 0&&t[e.id]!==null);function $e(e,t){let n=[];e.wizard.description&&n.push(W(`hello`,e.wizard.description)),e.wizard.intro&&n.push(W(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...Ze(r,i,e.values,e.id,Qe(r,e.values),t))}else r.type===`review`&&(n.push(W(i,(0,H.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(G(`${i}:a`,f(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function et(e,t){return e.fields.filter(e=>!a(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function tt({view:e,run:t,step:n,before:r}){let a=(0,B.useMemo)(()=>et(n,e),[n,e]),o=e.known??{},[s,c]=(0,B.useState)(()=>P(n,e)),[l,u]=(0,B.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?i(et(n,e),e.known??{},P(n,e)).slice(0,-1).map(e=>e.id):[]),[d,p]=(0,B.useState)({}),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!1),v=i(a,o,s),y=v.filter(e=>l.includes(e.id)),b=v.find(e=>!l.includes(e.id)),x=a.length===1?a[0]:void 0,S=y.at(-1),C=S?()=>u(e=>e.filter(e=>e!==S.id)):void 0;(0,B.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=i(a,o,s),r=n.findIndex(t=>e.includes(t.id));r>=0&&(u(n.slice(0,r).map(e=>e.id)),p(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(_)},T=(0,B.useContext)(K),D=(0,B.useRef)(s);D.current=s;let O=T?.bindPage,k=(0,B.useRef)(w);k.current=w,(0,B.useEffect)(()=>{if(!O)return;let e=i(a,o,s);return O({step:n,fields:e,values:s,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Ke(r,n)||(c(e=>({...e,[t]:n})),u(e=>e.includes(t)?e:[...e,t]),p({}),null):`no such field on this page`},submit:()=>k.current(D.current)}),()=>O(null)},[O,n,a,o,s]);let A=e=>{if(!b)return!1;let t=Ke(b,e);if(t)return p({[b.id]:t}),!1;let n={...s,[b.id]:e},r=[...l,b.id];return c(n),u(r),p({}),i(a,o,n).some(e=>!r.includes(e.id))||w(n),!0},j=[...r.map(e=>l.length?{...e,onEdit:void 0}:e),...Ze(n,`now:${n.id}`,s,e.id,y,x).map((e,t,n)=>t===n.length-1&&e.who===`me`&&b?{...e,onEdit:C}:e)];b?(We(b)===`control`?j.push(W(`now:${n.id}:${b.id}:control`,(0,H.jsx)(E,{field:b,value:s[b.id],values:s,runId:e.id,view:e,closed:e.closed?.[b.id],onChange:e=>c(t=>({...t,[b.id]:e})),onBusy:h}),{wide:!0})):x||j.push(W(`now:${n.id}:${b.id}`,(0,H.jsx)(Je,{field:b}))),d[b.id]&&j.push(W(`now:${n.id}:${b.id}:error`,d[b.id],{tone:`error`}))):t.busy||g?j.push(W(`sending`,(0,H.jsx)(Ue,{}))):t.error&&j.push(W(`send-error`,t.error,{tone:`error`}));let M=(0,H.jsx)(Q,{});if(g||!b&&l.length>0&&t.busy)M=(0,H.jsx)(Q,{placeholder:f(`run.working`)});else if(!b)j.push(Y(`now:${n.id}:go`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(X,{primary:!0,busy:t.busy,onClick:()=>w(s),children:n.cta||f(`run.next`)}),C?(0,H.jsx)(X,{onClick:C,disabled:t.busy,children:f(`run.back`)}):null]})));else{let r=We(b),i=!b.required&&b.kind!==`connection`&&b.kind!==`list`?(0,H.jsx)(X,{onClick:()=>A(void 0),children:f(`chat.skip`)}):null;if(r===`typed`){i&&j.push(Y(`now:${n.id}:${b.id}:replies`,i));let e=s[b.id];M=(0,H.jsx)(Ve,{children:(0,H.jsx)(Z,{initial:Ge(e)?``:String(e),multiline:b.kind===`textarea`,placeholder:b.placeholder||(x?b.label:f(`chat.placeholder`)),inputProps:nt(b),busy:t.busy,onSend:e=>A(qe(b,e))},b.id)})}else if(r===`tapped`)j.push(W(`now:${n.id}:${b.id}:replies`,(0,H.jsx)(rt,{field:b,view:e,value:s[b.id],onAnswer:A}),{bare:!0}));else{let e=v.filter(e=>!l.includes(e.id)).length===1;j.push(Y(`now:${n.id}:${b.id}:replies`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(X,{primary:!0,disabled:m,onClick:()=>A(s[b.id]),children:e&&n.cta?n.cta:f(`chat.send`)}),i]})))}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q,{avatar:e.wizard.avatar,lines:j}),M]})}function nt(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return F(e)}}function rt({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,B.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,H.jsxs)(J,{children:[(0,H.jsx)(X,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:f(`run.no`)}),(0,H.jsx)(X,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:f(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,H.jsxs)(J,{children:[s.map(e=>(0,H.jsx)(X,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:e},e)),(0,H.jsx)(X,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?f(`chat.send`):f(`chat.skip`)})]}):(0,H.jsxs)(J,{children:[s.map(e=>(0,H.jsx)(X,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:e},e)),e.required?null:(0,H.jsx)(X,{onClick:()=>r(void 0),children:f(`chat.skip`)})]})}function it({view:e}){let t=(0,B.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,B.useState)(Date.now());(0,B.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),o=a.at(-1),s=[...a].reverse().find(ot),c=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,H.jsxs)(`div`,{className:b(`flex max-w-full flex-col gap-1`,s?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??f(`run.working`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(Ue,{}),(0,H.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??f(`run.working`)}),(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:f(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),o&&o!==s?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,H.jsx)(re,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,H.jsx)(`span`,{className:`truncate`,children:S(o)})]}):null,s&&e.status===`running`?(0,H.jsx)(ct,{runId:e.id,event:s}):null,c.length?(0,H.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:c.slice(-6).map(t=>(0,H.jsx)(`img`,{src:p(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var at=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function ot(e){return!!e.note&&at.has(e.note.code)}var st=1e4;function ct({runId:e,event:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(`agent`),[o,s]=(0,B.useState)(!1),c=t.note?.code;if((0,B.useEffect)(()=>{c===`personDrives`?a(`person`):c===`agentDrives`&&a(`agent`)},[c]),(0,B.useEffect)(()=>{let t=()=>h.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,st);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let l=i===`person`,u=async()=>{s(!0);try{let t=await h.post(`/api/runs/${e}/browser/seat`,{to:l?`agent`:`person`});a(t.seat)}catch{}finally{s(!1)}};return(0,H.jsx)(k,{runId:e,driving:l,caption:S(t),hint:f(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,H.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void u(),className:b(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,l?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[l?(0,H.jsx)(he,{className:`size-3.5`}):(0,H.jsx)(le,{className:`size-3.5`}),f(l?`browser.handBack`:`browser.takeOver`)]})},n??0)}function $({children:e,end:t}){return(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function lt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[s,c]=(0,B.useState)(o.length===1?o[0].step.id:null),l=(0,B.useRef)(null),u=[...r,...i.map((e,t)=>G(`review:${n.id}:asked:${t}`,e)),W(`review:${n.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,H.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...o.map(({step:t,output:r})=>W(`review:${n.id}:${t.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{children:t.title}),(0,H.jsx)(se,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{c(t.id),l.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>W(`review:${n.id}:list:${t.def.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{children:t.def.title}),t.def.check?(0,H.jsx)(ee,{runId:e.id,list:t}):(0,H.jsx)(M,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&u.push(W(`review-error`,t.error,{tone:`error`}));let d=n.regenerate&&o.length>0;return u.push(Y(`review:${n.id}:replies`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(X,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,H.jsx)(g,{className:`size-4`}),` `,f(`run.accept`)]}),d&&o.length>1?o.map(({step:e})=>(0,H.jsx)(X,{on:s===e.id,onClick:()=>c(e.id),children:e.title},e.id)):null]}))),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q,{avatar:e.wizard.avatar,lines:u}),d?(0,H.jsx)(Ve,{children:(0,H.jsx)(Z,{multiline:!0,inputRef:l,busy:t.busy,placeholder:o.length>1&&!s?f(`run.feedbackPick`):f(`run.feedbackPlaceholder`),disabled:!s,onSend:e=>{let r=e.trim();return!r||!s?!1:(a(r),t.regenerate(n.id,s,r),!0)}})}):(0,H.jsx)(Q,{})]})}function ut({view:e,run:t,step:n,before:r,onRestart:i}){let a=e.shown.filter(e=>e.output),o=`/api/runs/${e.id}`,s=[...r,W(`result:${n.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,H.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...a.map(({step:e,output:t,formats:n,label:r})=>W(`result:${e.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{end:(0,H.jsx)(oe,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,H.jsx)(se,{base:o,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,H.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:f(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>W(`result:list:${t.def.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{end:(0,H.jsx)(D,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,H.jsx)(M,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return s.push(Y(`result:replies`,(0,H.jsxs)(H.Fragment,{children:[a.length?(0,H.jsx)(I,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null}):null,i?(0,H.jsxs)(X,{onClick:i,children:[(0,H.jsx)(A,{className:`size-4`}),` `,f(`run.again`)]}):null,e.canBack?(0,H.jsx)(X,{onClick:()=>void t.back(),disabled:t.busy,children:f(`run.back`)}):null,e.keeps?(0,H.jsx)(`span`,{className:`ml-1`,children:(0,H.jsx)(te,{runId:e.id})}):null]}))),(0,H.jsx)(q,{avatar:e.wizard.avatar,lines:s})}function dt({runId:e,onRestart:t,onView:n,header:r,footer:i,talk:a=!1,call:o=!1}){let s=j(e),{view:l}=s,[u,d]=(0,B.useState)(null),p=Re(e,l,s,u);(0,B.useEffect)(()=>{n?.(l)},[l,n]);let[m,h]=De(),g=(0,B.useMemo)(()=>({runId:e,lang:l?.lang??c,readAloud:m,setReadAloud:h,voice:l?.talk?p:null,talk:a,call:!!o,bindPage:d}),[e,l?.lang,l?.talk,m,h,p,a,o]);ie(l?.status===`running`&&!l.ask),L(l);let[_,v]=(0,B.useState)({}),[b,x]=(0,B.useState)(null);(0,B.useEffect)(()=>{l&&l.status!==`running`&&x(null)},[l]);let S;if(s.notFound)S=(0,H.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:f(`run.notFound`)});else if(!l)S=(0,H.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,H.jsx)(y,{})});else{let e=l.step,n=l.status===`waiting_input`,r=$e(l,l.canBack&&n&&!s.busy?()=>void s.back():void 0);if(l.status===`running`&&l.ask)S=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q,{avatar:l.wizard.avatar,lines:[...r,W(`ask:${l.ask.id}`,(0,H.jsx)(O,{runId:l.id,ask:l.ask}),{wide:!0})]}),(0,H.jsx)(Q,{})]});else if(l.status===`running`)S=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q,{avatar:l.wizard.avatar,lines:[...r,...b?[G(`note`,b)]:[],W(`working:${e?.id}`,(0,H.jsx)(it,{view:l}),{wide:l.events.some(t=>t.stepId===e?.id&&ot(t))?`most`:void 0})]}),(0,H.jsx)(Q,{placeholder:f(`run.working`)})]});else if(l.status===`failed`)S=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q,{avatar:l.wizard.avatar,lines:[...r,W(`failed`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:f(`run.failed`)}),l.error?(0,H.jsx)(`span`,{className:`mt-0.5 block`,children:(0,H.jsx)(C,{text:l.error})}):null]}),{tone:`error`}),Y(`failed:replies`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(X,{primary:!0,busy:s.busy,onClick:()=>void s.retry(),children:[(0,H.jsx)(A,{className:`size-4`}),` `,f(`run.retry`)]}),l.canBack?(0,H.jsx)(X,{onClick:()=>void s.back(),disabled:s.busy,children:f(`run.back`)}):null]}))]}),(0,H.jsx)(Q,{})]});else if(l.status===`cancelled`)S=(0,H.jsx)(q,{avatar:l.wizard.avatar,lines:[...r,W(`cancelled`,f(`run.cancelled`)),...t?[Y(`cancelled:replies`,(0,H.jsxs)(X,{primary:!0,onClick:t,children:[(0,H.jsx)(A,{className:`size-4`}),` `,f(`run.again`)]}))]:[]]});else if(e?.type===`page`)S=(0,H.jsx)(tt,{view:l,run:s,step:e,before:r},e.id);else if(e?.type===`review`){let t=l.shown.map(e=>e.output?.at??``).join(`|`);S=(0,H.jsx)(lt,{view:l,run:s,step:e,before:r,asked:_[e.id]??[],onNote:t=>{x(t),v(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else S=e?.type===`result`?(0,H.jsx)(ut,{view:l,run:s,step:e,before:r,onRestart:t}):(0,H.jsx)(q,{avatar:l.wizard.avatar,lines:r})}return o?(0,H.jsx)(K.Provider,{value:g,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,H.jsx)(Me,{voice:p,view:l,video:o===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,H.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,H.jsx)(He,{footer:i,children:S})})]})}):(0,H.jsx)(K.Provider,{value:g,children:(0,H.jsx)(He,{header:r,footer:i,children:S})})}export{q as a,X as i,He as n,Y as o,Q as r,Be as s,dt as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{t as r}from"./preload-helper-CNEI7N0N.js";import{
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{t as r}from"./preload-helper-CNEI7N0N.js";import{A as i,M as a,a as o,f as s,i as c,s as l}from"./ui-Wxaw_APn.js";import{t as u}from"./external-link-M3mEgZA-.js";var d=e(t(),1),f=[{name:`engenty wizards`,description:{de:`KI-Wizards aus einer Beschreibung, mit einem Link geteilt.`,en:`AI wizards built from a description, shared with a link.`},homepage:`https://github.com/engenty/engenty-wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:{de:`Konnektoren, Datentabellen, Suche und die Engenties stammen aus dem engenty-Framework.`,en:`Connectors, data tables, search and the engenties come from the engenty framework.`},homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],p=[{name:`Mastra`,description:{de:`Agent-Framework hinter den KI-Schritten.`,en:`Agent framework behind the AI steps.`},homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:{de:`Modell-Aufrufe für Text, Bild, Video und Sprache.`,en:`Model calls for text, image, video and speech.`},homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:{de:`MCP-Server zum Bauen von Wizards, MCP-Client für Werkzeuge der Schritte.`,en:`MCP server for building wizards, MCP client for the steps' tools.`},homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:{de:`HTTP-API der Runtime.`,en:`The runtime's HTTP API.`},homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:{de:`Schema und Migrationen der Datenbanken.`,en:`Schema and migrations of the databases.`},homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:{de:`Eine Datenbank je Mandant, lokal als Datei oder bei Turso.`,en:`One database per tenant, a local file or at Turso.`},homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:{de:`Browser-Schritte sowie PDF- und PNG-Export.`,en:`Browser steps and the PDF and PNG export.`},homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`agentOS`,description:{de:`Sandbox für Code-Schritte ohne Docker.`,en:`Sandbox for code steps without Docker.`},homepage:`https://github.com/rivet-dev/agentos`,license:`Apache-2.0`},{name:`React`,description:{de:`UI-Bibliothek der Web-App.`,en:`UI library of the web app.`},homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:{de:`Build-Werkzeug der Web-App.`,en:`Build tool of the web app.`},homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:{de:`Styling der Oberfläche.`,en:`Styling of the interface.`},homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:{de:`Das Diagramm der Schritte im Editor.`,en:`The diagram of steps in the editor.`},homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:{de:`Server-Daten in der Web-App.`,en:`Server data in the web app.`},homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:{de:`Das Terminal auf der Seite, in dem sich KI-Clients anmelden.`,en:`The terminal on the page where AI clients sign in.`},homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:{de:`Icons.`,en:`Icons.`},homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:{de:`Schrift der Oberfläche.`,en:`Typeface of the interface.`},homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:{de:`Schrift der Überschriften.`,en:`Typeface of the headings.`},homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:{de:`Erzeugt den Changelog aus den Commits.`,en:`Generates the changelog from the commits.`},homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],m=e(n(),1),h=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function g({name:e,homepage:t,version:n,license:r,description:i}){return(0,m.jsxs)(`li`,{className:`py-2.5`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,m.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,m.jsx)(u,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,m.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,m.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,m.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,m.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function _({title:e,hint:t,children:n}){return(0,m.jsxs)(`section`,{className:`mt-6`,children:[(0,m.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,m.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function v({credits:e}){return(0,m.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,m.jsx)(g,{name:e.name,homepage:e.homepage,license:e.license,description:e.description[i]},e.name))})}function y({label:e,packages:t}){return(0,m.jsxs)(`div`,{className:`mt-4`,children:[(0,m.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,m.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,m.jsx)(g,{...e},e.name))})]})}function b({open:e,onClose:t}){let[n,i]=(0,d.useState)(null),[u,g]=(0,d.useState)(``);(0,d.useEffect)(()=>{if(!e||n)return;let t=!1;return r(()=>import(`./oss-credits-CIxnNZor.js`).then(e=>{t||i(e.default)}),[]),()=>{t=!0}},[e,n]),(0,d.useEffect)(()=>{e||g(``)},[e]);let b=u.trim().toLowerCase(),x=e=>b?e.filter(e=>h(b,e.name,e.license,e.description.de,e.description.en)):e,S=e=>b?e.filter(e=>h(b,e.name,e.license,e.version)):e,C=x(f),w=x(p),T=n?[{id:`shared`,label:a(`about.creditsShared`),packages:S(n.shared)},...n.groups.map(e=>({id:e.id,label:e.label,packages:S(e.packages)}))].filter(e=>e.packages.length>0):[],E=C.length===0&&w.length===0&&T.length===0;return(0,m.jsxs)(c,{open:e,onClose:t,title:a(`about.credits`),wide:!0,children:[(0,m.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:a(`about.creditsHint`)}),(0,m.jsx)(l,{type:`search`,value:u,placeholder:a(`about.search`),onChange:e=>g(e.target.value)}),C.length>0?(0,m.jsx)(_,{title:a(`about.creditsProduct`),children:(0,m.jsx)(v,{credits:C})}):null,w.length>0?(0,m.jsx)(_,{title:a(`about.creditsBuiltWith`),children:(0,m.jsx)(v,{credits:w})}):null,n===null?(0,m.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,m.jsx)(s,{})}):T.length>0?(0,m.jsx)(_,{title:a(`about.creditsDeps`),hint:b?void 0:a(`about.creditsDepsHint`),children:T.map(e=>(0,m.jsx)(y,{label:e.label,packages:e.packages},e.id))}):null,n!==null&&E?(0,m.jsx)(o,{children:a(`about.noMatches`)}):null]})}export{b as CreditsDialog};
|