wizards 0.3.3 → 0.3.5
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/authoring/guide.js +1 -0
- package/apps/runtime/dist/docs/dev/plugins/reference.md +10 -2
- package/apps/runtime/dist/docs/dev/plugins/runners.md +11 -8
- package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
- package/apps/runtime/dist/docs/user/build-a-wizard.md +4 -4
- package/apps/runtime/dist/docs/user/plugins.md +2 -2
- package/apps/runtime/dist/docs/user/test-and-share.md +38 -42
- package/apps/runtime/dist/docs/user/troubleshooting.md +2 -2
- package/apps/runtime/dist/docs/user/wordpress.md +4 -4
- package/apps/runtime/dist/plugins/loader.js +6 -1
- package/apps/runtime/dist/services/runners.js +27 -3
- package/apps/web/dist/assets/AboutDialog-D1N4-3FE.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-DlyLGXEt.js → ChangelogDialog-VEBTlC3f.js} +1 -1
- package/apps/web/dist/assets/ChatView-DSRUEpb6.js +10 -0
- package/apps/web/dist/assets/EditorPage-UkaHDklX.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-CadiWN9G.js → FlowPreview-86xWWfdk.js} +1 -1
- package/apps/web/dist/assets/{Harness-DgWuB2-F.js → Harness-CF6H2TYJ.js} +2 -2
- package/apps/web/dist/assets/Marketplace-C-Vz3yEk.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-Cc7gDitg.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-sY5q-l99.js +7 -0
- package/apps/web/dist/assets/ProjectPage-iSdpJAZS.js +2 -0
- package/apps/web/dist/assets/PublicRunner-BgRXMUxS.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-Bxbgr2n2.js → ReadOnly-mhKW496R.js} +1 -1
- package/apps/web/dist/assets/RunDrawer-B0gJzdxH.js +4 -0
- package/apps/web/dist/assets/RunnerView-CTRFgyu5.js +1 -0
- package/apps/web/dist/assets/SettingsPage-CBF8i6j6.js +1 -0
- package/apps/web/dist/assets/SetupPage-Fpz9aSLN.js +1 -0
- package/apps/web/dist/assets/{SharePage-DsFzI-1G.js → SharePage-Dv3Csh4A.js} +1 -1
- package/apps/web/dist/assets/{brand-cgisQRwA.js → brand-BamUjXVr.js} +1 -1
- package/apps/web/dist/assets/changelog-ViHoNW7e.js +1 -0
- package/apps/web/dist/assets/{circle-alert-R2GwpaDI.js → circle-alert-CYs622_r.js} +1 -1
- package/apps/web/dist/assets/{esm-DRDDKpw8.js → esm-B52LIMhP.js} +1 -1
- package/apps/web/dist/assets/index-Bdx1Qity.js +11 -0
- package/apps/web/dist/assets/index-CDdJDojq.css +1 -0
- package/apps/web/dist/assets/{lock-BqMtfg3I.js → lock-BvSWZOin.js} +1 -1
- package/apps/web/dist/assets/phone-CI2Flerg.js +1 -0
- package/apps/web/dist/assets/{session-Dej-L4l9.js → session-BEHF6g4Y.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-sIgeY5QS.js → settings-menu-BOOPxcJH.js} +1 -1
- package/apps/web/dist/assets/{ui-aWLrX8hF.js → ui-CMdSOoUZ.js} +2 -2
- package/apps/web/dist/assets/{upload-CNYeHI5s.js → upload-Cz9HgBT9.js} +1 -1
- package/apps/web/dist/assets/{volume-2-B7cfghgd.js → volume-2-CyQuz1nn.js} +1 -1
- package/apps/web/dist/index.html +7 -7
- package/apps/web/dist/mcp/flow.html +2 -2
- package/modules/sms/dist/client.css +1 -1
- package/modules/sms/dist/client.js +1 -1
- package/modules/sms/package.json +0 -1
- package/modules/sms/src/plugin.ts +5 -0
- package/modules/sms/ui/Share.tsx +26 -44
- package/modules/sms/ui/messages.ts +0 -2
- package/modules/whatsapp/dist/client.css +1 -1
- package/modules/whatsapp/dist/client.js +1 -1
- package/modules/whatsapp/package.json +0 -1
- package/modules/whatsapp/src/plugin.ts +5 -0
- package/modules/whatsapp/ui/Share.tsx +26 -44
- package/modules/whatsapp/ui/messages.ts +0 -2
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +22 -0
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +3 -2
- package/package.json +1 -1
- package/apps/web/dist/assets/AboutDialog-ClutoziK.js +0 -1
- package/apps/web/dist/assets/ChatView-CTnOltHO.js +0 -10
- package/apps/web/dist/assets/EditorPage-NaMKxhKa.js +0 -3
- package/apps/web/dist/assets/Marketplace-VfuV7iFH.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-MXYuyvc_.js +0 -1
- package/apps/web/dist/assets/ProjectPage-BbsrriDW.js +0 -2
- package/apps/web/dist/assets/PublicRunner-BKoYVOyc.js +0 -1
- package/apps/web/dist/assets/RunDrawer-BGFgcCWn.js +0 -4
- package/apps/web/dist/assets/RunnerView-DESr9uke.js +0 -1
- package/apps/web/dist/assets/SettingsPage-fr8EiAhX.js +0 -1
- package/apps/web/dist/assets/SetupPage-nHrjDwuL.js +0 -1
- package/apps/web/dist/assets/changelog-BNtpwpok.js +0 -1
- package/apps/web/dist/assets/index-CcfHTBq_.js +0 -11
- package/apps/web/dist/assets/index-unSi7__V.css +0 -1
|
@@ -184,6 +184,11 @@ export default definePlugin((wizards) => {
|
|
|
184
184
|
},
|
|
185
185
|
problem: async () =>
|
|
186
186
|
(await getAccount(db())) ? null : "Keine Nummer verbunden (Einstellungen → WhatsApp)",
|
|
187
|
+
// The share dialog's row: the number, the keyword and the link that writes it.
|
|
188
|
+
address: async (wizard) => {
|
|
189
|
+
const b = await bindingView(wizard.id);
|
|
190
|
+
return b.number ? { number: `+${b.number}`, keyword: b.keyword, link: b.link } : null;
|
|
191
|
+
},
|
|
187
192
|
});
|
|
188
193
|
|
|
189
194
|
// Meta checks the address once, with the verify token the settings show.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { StudioShareSectionProps } from "@engenty-wizards/plugin-sdk/studio";
|
|
2
2
|
import { Input } from "@engenty-wizards/web/ui";
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import {
|
|
5
|
-
import { renderSVG } from "uqr";
|
|
4
|
+
import { useState } from "react";
|
|
6
5
|
import { api, type Binding, errorText, KEY, t } from "./app";
|
|
7
|
-
import { CopyButton } from "./parts";
|
|
8
6
|
|
|
9
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* In the share dialog's settings, while WhatsApp is on: the keyword that picks the wizard. Its
|
|
9
|
+
* number, its link and the QR code the dialog shows itself, from the runner's address.
|
|
10
|
+
*/
|
|
10
11
|
export function ShareSection({ wizard }: StudioShareSectionProps) {
|
|
11
12
|
const cache = useQueryClient();
|
|
12
13
|
const binding = useQuery({
|
|
@@ -18,14 +19,13 @@ export function ShareSection({ wizard }: StudioShareSectionProps) {
|
|
|
18
19
|
mutationFn: (keyword: string) => api().put<Binding>(`/binding/${wizard.id}`, { keyword }),
|
|
19
20
|
onSuccess: async () => {
|
|
20
21
|
setDraft(null);
|
|
21
|
-
|
|
22
|
+
// The dialog's row shows the keyword and the link that writes it.
|
|
23
|
+
await Promise.all([
|
|
24
|
+
cache.invalidateQueries({ queryKey: [KEY, "binding", wizard.id] }),
|
|
25
|
+
cache.invalidateQueries({ queryKey: ["wizard-runners", wizard.id] }),
|
|
26
|
+
]);
|
|
22
27
|
},
|
|
23
28
|
});
|
|
24
|
-
const link = binding.data?.link ?? null;
|
|
25
|
-
const svg = useMemo(
|
|
26
|
-
() => (link ? renderSVG(link, { ecc: "M", border: 1, pixelSize: 6 }) : ""),
|
|
27
|
-
[link],
|
|
28
|
-
);
|
|
29
29
|
if (!binding.data) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
@@ -38,41 +38,23 @@ export function ShareSection({ wizard }: StudioShareSectionProps) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
return (
|
|
41
|
-
<div className="flex
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
<div className="flex flex-col gap-1.5">
|
|
42
|
+
<label className="flex flex-col gap-1.5">
|
|
43
|
+
<span className="font-medium text-[0.875rem]">{t("keyword")}</span>
|
|
44
|
+
<Input
|
|
45
|
+
value={keyword}
|
|
46
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
47
|
+
onBlur={commit}
|
|
48
|
+
onKeyDown={(e) => {
|
|
49
|
+
if (e.key === "Enter") {
|
|
50
|
+
e.currentTarget.blur();
|
|
51
|
+
}
|
|
52
|
+
}}
|
|
53
|
+
className="max-w-xs"
|
|
50
54
|
/>
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
<span className="shrink-0 text-ink-3">{t("keyword")}</span>
|
|
55
|
-
<Input
|
|
56
|
-
value={keyword}
|
|
57
|
-
onChange={(e) => setDraft(e.target.value)}
|
|
58
|
-
onBlur={commit}
|
|
59
|
-
onKeyDown={(e) => {
|
|
60
|
-
if (e.key === "Enter") {
|
|
61
|
-
e.currentTarget.blur();
|
|
62
|
-
}
|
|
63
|
-
}}
|
|
64
|
-
className="h-8 max-w-xs text-[0.8125rem]"
|
|
65
|
-
/>
|
|
66
|
-
</label>
|
|
67
|
-
{link ? (
|
|
68
|
-
<div className="flex min-w-0 items-center gap-1">
|
|
69
|
-
<span className="select-all truncate text-ink-3">{link}</span>
|
|
70
|
-
<CopyButton text={link} />
|
|
71
|
-
</div>
|
|
72
|
-
) : null}
|
|
73
|
-
<p className="text-ink-3">{t("keywordHint")}</p>
|
|
74
|
-
{save.error ? <p className="text-rose">{errorText(save.error)}</p> : null}
|
|
75
|
-
</div>
|
|
55
|
+
</label>
|
|
56
|
+
<p className="text-[0.8125rem] text-ink-3">{t("keywordHint")}</p>
|
|
57
|
+
{save.error ? <p className="text-[0.8125rem] text-rose">{errorText(save.error)}</p> : null}
|
|
76
58
|
</div>
|
|
77
59
|
);
|
|
78
60
|
}
|
|
@@ -32,7 +32,6 @@ export const messages = {
|
|
|
32
32
|
keyword: "Stichwort",
|
|
33
33
|
keywordHint:
|
|
34
34
|
"Wer dieses Wort an die Nummer schreibt, startet den Wizard. Der Link und der QR-Code schreiben es vor.",
|
|
35
|
-
link: "Link",
|
|
36
35
|
error_bad_keyword:
|
|
37
36
|
"Ein Stichwort besteht aus Buchstaben, Ziffern, Leerzeichen und Bindestrichen, bis zu 40.",
|
|
38
37
|
error_keyword_taken: "Ein anderer Wizard hat dieses Stichwort schon.",
|
|
@@ -72,7 +71,6 @@ export const messages = {
|
|
|
72
71
|
keyword: "Keyword",
|
|
73
72
|
keywordHint:
|
|
74
73
|
"Whoever writes this word to the number starts the wizard. The link and the QR code write it for them.",
|
|
75
|
-
link: "Link",
|
|
76
74
|
error_bad_keyword: "A keyword is letters, digits, spaces and dashes, up to 40.",
|
|
77
75
|
error_keyword_taken: "Another wizard has this keyword already.",
|
|
78
76
|
error_no_token: "An access token is needed.",
|
|
@@ -640,6 +640,19 @@ export interface PluginRunnerRequest {
|
|
|
640
640
|
path: string;
|
|
641
641
|
query: URLSearchParams;
|
|
642
642
|
}
|
|
643
|
+
/**
|
|
644
|
+
* Where a person reaches a wizard through a channel runner, as the share dialog shows it: the
|
|
645
|
+
* number with the keyword that picks the wizard there, and the link that opens the channel with
|
|
646
|
+
* the keyword written.
|
|
647
|
+
*/
|
|
648
|
+
export interface PluginRunnerAddress {
|
|
649
|
+
/** The number people write to or call, with the country code: `+43660…`. */
|
|
650
|
+
number?: string | null;
|
|
651
|
+
/** The word that picks this wizard on that number. */
|
|
652
|
+
keyword?: string | null;
|
|
653
|
+
/** Opens the channel with the keyword written (`sms:…`, `https://wa.me/…`): copied, and as a QR code. */
|
|
654
|
+
link?: string | null;
|
|
655
|
+
}
|
|
643
656
|
/**
|
|
644
657
|
* A runner: a door a wizard runs through, beside the built-in page and chat. A `page` runner is
|
|
645
658
|
* served at `/w/<token>/<id>` for every wizard that switched it on; a `channel` runner has an
|
|
@@ -662,6 +675,15 @@ export interface PluginRunner {
|
|
|
662
675
|
* studio lists the runners; a runner with a problem cannot be switched on.
|
|
663
676
|
*/
|
|
664
677
|
problem?(): string | null | Promise<string | null>;
|
|
678
|
+
/**
|
|
679
|
+
* A channel runner: where a person reaches the wizard, for the share dialog; null while the
|
|
680
|
+
* runner is not set up. Asked inside the tenant for each wizard that has the runner on.
|
|
681
|
+
*/
|
|
682
|
+
address?(wizard: {
|
|
683
|
+
id: string;
|
|
684
|
+
title: string;
|
|
685
|
+
token: string;
|
|
686
|
+
}): PluginRunnerAddress | null | Promise<PluginRunnerAddress | null>;
|
|
665
687
|
}
|
|
666
688
|
/** How a run answers a review: accept it, with edited texts where the review allows, or ask for one of the shown steps again. */
|
|
667
689
|
export type PluginReviewAction = {
|
|
@@ -64,8 +64,9 @@ export interface StudioShareSectionProps {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* A runner's own
|
|
68
|
-
* the
|
|
67
|
+
* A runner's own settings for a wizard, in the share dialog's settings while the runner is on:
|
|
68
|
+
* the keyword that picks it, say. Its address and link the dialog shows itself, from the
|
|
69
|
+
* runner's `address`. One per runner.
|
|
69
70
|
*/
|
|
70
71
|
export interface StudioShareSection {
|
|
71
72
|
/** The runner's id, as the server half registered it. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wizards",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Make a wish. Get your wizard. It guides you step by step. Let AI do the work. Runs on your machine, on the AI subscription you already have.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"homepage": "https://engenty.ai",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{t as r}from"./logo-C4V2_3Ar.js";import{t as i}from"./preload-helper-CNEI7N0N.js";import{Ct as a,Dt as o,Kt as s,Tt as c,Zt as l,ct as u,dt as d,gt as f,lt as p,ut as m,xt as h,yt as g}from"./ui-aWLrX8hF.js";import{H as _,U as v,et as y}from"./index-CcfHTBq_.js";import{c as b,f as x}from"./settings-menu-sIgeY5QS.js";import{ReleaseNotes as S,loadReleases as C,releaseDate as w,releaseLabel as T}from"./ChangelogDialog-DlyLGXEt.js";var E=e(t(),1),D=[{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/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`}],O=[{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`}],k=e(n(),1),A=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function j({name:e,homepage:t,version:n,license:r,description:i}){return(0,k.jsxs)(`li`,{className:`py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,k.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,k.jsx)(s,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,k.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,k.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function M({title:e,hint:t,children:n}){return(0,k.jsxs)(`section`,{className:`mt-6`,children:[(0,k.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,k.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function N({credits:e}){return(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,k.jsx)(j,{name:e.name,homepage:e.homepage,license:e.license,description:e.description[a]},e.name))})}function P({label:e,packages:t}){return(0,k.jsxs)(`div`,{className:`mt-4`,children:[(0,k.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,k.jsx)(j,{...e},e.name))})]})}function F({active:e}){let[t,n]=(0,E.useState)(null),[r,a]=(0,E.useState)(``);(0,E.useEffect)(()=>{if(!e||t)return;let r=!1;return i(()=>import(`./oss-credits-BQQX0kvk.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,E.useEffect)(()=>{e||a(``)},[e]);let o=r.trim().toLowerCase(),s=e=>o?e.filter(e=>A(o,e.name,e.license,e.description.de,e.description.en)):e,l=e=>o?e.filter(e=>A(o,e.name,e.license,e.version)):e,u=s(D),m=s(O),h=t?[{id:`shared`,label:c(`about.creditsShared`),packages:l(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:l(e.packages)}))].filter(e=>e.packages.length>0):[],g=u.length===0&&m.length===0&&h.length===0;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:c(`about.creditsHint`)}),(0,k.jsx)(d,{type:`search`,value:r,placeholder:c(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,k.jsx)(M,{title:c(`about.creditsProduct`),children:(0,k.jsx)(N,{credits:u})}):null,m.length>0?(0,k.jsx)(M,{title:c(`about.creditsBuiltWith`),children:(0,k.jsx)(N,{credits:m})}):null,t===null?(0,k.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,k.jsx)(f,{})}):h.length>0?(0,k.jsx)(M,{title:c(`about.creditsDeps`),hint:o?void 0:c(`about.creditsDepsHint`),children:h.map(e=>(0,k.jsx)(P,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,k.jsx)(p,{children:c(`about.noMatches`)}):null]})}var I=[`new`,`earlier`,`credits`],L=e=>c(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),R=e=>e===1?c(`about.change`):c(`about.changes`,{n:e});function z({open:e,onClose:t,me:n}){let i=n?.mode===`local`,{data:a,latest:s}=v(i&&e),[d,p]=(0,E.useState)(null),[D,O]=(0,E.useState)(`new`),A=x(I.indexOf(D)),j=a?.newer&&s?s:y;(0,E.useEffect)(()=>{if(!e)return;let t=!1;return p(null),C(j===`0.3.3`?void 0:j).then(e=>{t||p(e)}),()=>{t=!0}},[e,j]);let M=d?.find(e=>e.version===`v${j}`)??d?.[0]??null,N=d?.filter(e=>e!==M)??[],P=i?a?.kind??null:`cloud`;return(0,k.jsxs)(u,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,k.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,k.jsx)(m,{label:c(`common.close`),onClick:t,children:(0,k.jsx)(o,{className:`size-4`})})}),(0,k.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,k.jsx)(r,{size:96}),(0,k.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,k.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,k.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,k.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[c(`about.version`,{v:y}),P?` · ${c(`about.kind.${P}`)}`:``]})]}),i?(0,k.jsx)(`div`,{className:`mt-5`,children:(0,k.jsx)(_,{enabled:e})}):null,(0,k.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,k.jsx)(g,{value:D,onChange:O,options:I.map(e=>({id:e,label:L(e)})),label:c(`about.title`)})}),(0,k.jsxs)(`div`,{className:h(`mt-5`,b(A)),children:[D===`new`?d===null?(0,k.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,k.jsx)(f,{})}):M?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[T(M),(0,k.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:w(M)})]}),(0,k.jsx)(`div`,{className:`mt-3`,children:(0,k.jsx)(S,{release:M})})]}):(0,k.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:c(`about.changelogEmpty`)}):null,D===`earlier`?(0,k.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:N.map(e=>(0,k.jsxs)(`details`,{className:`group/r py-2`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(l,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,k.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:T(e)}),(0,k.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:w(e)}),(0,k.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:R(e.commits.length)})]}),(0,k.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,k.jsx)(S,{release:e})})]},e.version??`unreleased`))}):null,D===`credits`?(0,k.jsx)(F,{active:!0}):null]},D)]})}export{z as AboutDialog};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,At as i,Ct as a,D as o,E as s,F as c,It as l,Mt as u,Nt as d,O as f,Ot as p,Q as m,S as h,St as g,T as _,Tt as v,Vt as y,W as b,X as x,_ as S,a as C,bt as w,en as T,et as E,g as D,gt as O,i as k,jt as A,k as j,m as M,nn as N,on as P,pt as F,tt as I,ut as L,v as ee,w as te,xt as R,zt as z}from"./ui-aWLrX8hF.js";import{r as ne}from"./brand-cgisQRwA.js";import{n as re,r as ie}from"./RunnerView-DESr9uke.js";import{t as ae}from"./volume-2-B7cfghgd.js";import{X as oe,Y as se,Z as ce,ot as le,pt as ue,rt as de,t as fe}from"./index-CcfHTBq_.js";var pe={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`}]]};pe.node;var me=P(pe),he={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`}]]};he.node;var ge=P(he),_e={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`}]]};_e.node;var ve=P(_e),ye={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`}]]};ye.node;var be=P(ye),xe=ue(),B=e(t(),1),V=e(n(),1),Se=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Ce({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,V.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function H({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,V.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:R(`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,V.jsx)(O,{className:`size-5`}):a})}function we({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,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,V.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,V.jsx)(`li`,{className:R(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,V.jsx)(`div`,{ref:t})]})}):null}function Te({voice:e,view:t,video:n,className:r}){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()},f=()=>{e.stop(),u(!0)},m=n||e.camera,h=[...e.captions].reverse().find(e=>e.who===`bot`),g=[...e.captions].reverse().find(e=>e.who===`me`),_=e.speaking?v(`talk.speaking`):e.listening?v(`talk.listening`):a?v(`talk.live`):o?v(`talk.connecting`):l?v(`video.ended`):``;return(0,V.jsxs)(`section`,{className:R(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,V.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),_?(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[a?(0,V.jsx)(`span`,{className:R(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,_]}):null,(0,V.jsx)(Ce,{since:s})]}),(0,V.jsxs)(`div`,{className:R(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,m?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!m&&a&&e.captions.length?`h-[38%]`:m?``:`flex-1`),children:[(0,V.jsxs)(`div`,{className:R(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!m&&`hidden`),children:[(0,V.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:R(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,V.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,V.jsx)(ve,{className:`size-8`}),(0,V.jsx)(`span`,{className:`text-[0.8125rem]`,children:v(`video.cameraOff`)})]}),(0,V.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[v(`video.you`),e.muted?(0,V.jsx)(le,{className:`ml-1.5 inline size-3`}):null]})]}),(0,V.jsxs)(`div`,{className:R(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,m?`bg-neutral-900`:`bg-transparent`,m&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,V.jsx)(`div`,{className:R(`rounded-full transition-shadow duration-500`,!m&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!m&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,V.jsx)(ne,{kind:t?.wizard.avatar??`round`,size:m?140:200,fluffy:!0,interactive:!1})}),m?(0,V.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&&!m?(0,V.jsx)(we,{voice:e}):a&&(h||g)?(0,V.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[g?(0,V.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:g.text}):null,h?(0,V.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:h.text}):null]})}):null,e.error?(0,V.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,V.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(H,{label:v(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,V.jsx)(le,{className:`size-5`}):(0,V.jsx)(y,{className:`size-5`})}),(0,V.jsx)(H,{label:v(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,V.jsx)(p,{className:`size-5`}):(0,V.jsx)(ve,{className:`size-5`})}),e.camera&&Se?(0,V.jsx)(H,{label:v(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,V.jsx)(i,{className:`size-5`})}):null,(0,V.jsx)(H,{label:v(`video.leave`),danger:!0,onClick:f,children:(0,V.jsx)(de,{className:`size-5`})})]}):(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,V.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,V.jsx)(O,{className:`size-4`}):n?(0,V.jsx)(p,{className:`size-5`}):(0,V.jsx)(y,{className:`size-5`}),v(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,V.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:v(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ee=e=>c[e.kind]!==`device`,De=1024,Oe=4e3;function U(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function ke(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: ${g(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}: ${U(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=Ee(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?` = ${U(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}": ${U(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 Ae(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),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(`environment`),[g,_]=(0,B.useState)(!1),[y,b]=(0,B.useState)([]),x=(0,B.useRef)(null),S=(0,B.useRef)(null),w=(0,B.useRef)(0),T=(0,B.useRef)(!1);T.current=f;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=x.current;if(!T.current||!e||e.videoWidth===0)return null;let t=Math.min(1,De/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 S.current?.getTracks()??[])e.stop();S.current=null,x.current&&(x.current.srcObject=null),p(!1)},[]),L=(0,B.useCallback)(async e=>{if(S.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});S.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;h(n===`user`||n===`environment`?n:t),x.current&&(x.current.srcObject=e,await x.current.play().catch(()=>void 0)),p(!0)}catch(e){s(e.name===`NotAllowedError`?v(`talk.cameraDenied`):e.message)}},[]),ee=(0,B.useCallback)(async()=>{let e=m===`user`?`environment`:`user`;I(),await L(e)},[m,I,L]),te=(0,B.useCallback)(()=>{_(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),_(!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?ke(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 C.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&&Ee(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 C.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),b([]),a(`connecting`);try{let t=await C.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>Oe?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`;b(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=ke(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(`${v(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){R(),s(e.name===`NotAllowedError`?v(`chat.micDenied`):e.message),a(`error`)}}},[e,z,F,P,R]);return(0,B.useEffect)(()=>{if(i!==`live`||!t)return;let e=ke(t,r,f);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,f,P]),{state:i,error:o,speaking:c,listening:u,start:ne,stop:R,camera:f,facing:m,startCamera:L,stopCamera:I,flipCamera:ee,muted:g,toggleMute:te,captions:y,video:x}}var W=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),G=(e,t,n)=>({key:e,who:`me`,node:t,...n}),je=(0,B.createContext)(null),K=(0,B.createContext)(null);function Me(){return(0,B.useContext)(K)?.voice??null}function Ne({children:e}){let t=(0,B.useContext)(je);return t?(0,xe.createPortal)(e,t):null}function Pe({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,V.jsx)(je.Provider,{value:r,children:(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,V.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,V.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,V.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,V.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),r=(0,B.useMemo)(()=>t.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[t]),i=(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},[]);ce(!!n?.readAloud,n?.lang??a,r,i);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,V.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,V.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,V.jsx)(ne,{kind:e,size:30,interactive:n>=o.length-2})}),(0,V.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:t.lines.map(e=>(0,V.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:R(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?R(`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,V.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,V.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,V.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,V.jsx)(l,{className:`size-3`}),` `,v(`chat.change`)]}):null]},e.key)))}function Fe(){return(0,V.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":v(`run.working`),children:[0,1,2].map(e=>(0,V.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,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var Y=(e,t)=>W(e,(0,V.jsx)(J,{children:t}),{bare:!0});function X({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:R(`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,V.jsx)(O,{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,l]=(0,B.useState)(e),u=(0,B.useRef)(null),d=o??u,f=(0,B.useContext)(K),h=k(c,l,{endpoint:f?`/api/runs/${f.runId}/transcribe`:void 0}),g=!!f&&h.supported&&!a;(0,B.useEffect)(()=>{if(!g)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),h.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,h.toggle]),(0,B.useEffect)(()=>{!m&&!a&&d.current?.focus()},[a,d]);let _=()=>{i||a||(h.listening&&h.toggle(),s(c)!==!1&&l(``))},b=h.listening?v(`chat.listening`):h.processing?v(`chat.transcribing`):t,x=f?.voice??null,S=!!f?.call,C=f&&!S&&(se||g||x)?(0,V.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[x?(0,V.jsx)(L,{label:v(x.state===`live`?`talk.stop`:x.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":x.state===`live`,disabled:x.state===`connecting`,onClick:()=>x.state===`live`?x.stop():void x.start(),className:R(`size-9`,x.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,x.state===`off`&&f.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:x.state===`connecting`?(0,V.jsx)(O,{className:`size-4`}):x.state===`live`?(0,V.jsx)(de,{className:`size-4`}):(0,V.jsx)(ie,{className:`size-4`})}):null,x?.state===`live`?(0,V.jsx)(L,{label:v(x.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":x.camera,onClick:()=>x.camera?x.stopCamera():void x.startCamera(),className:R(`size-9`,x.camera&&`text-ink`),children:x.camera?(0,V.jsx)(p,{className:`size-4`}):(0,V.jsx)(ve,{className:`size-4`})}):null,se?(0,V.jsx)(L,{label:v(f.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":f.readAloud,onClick:()=>f.setReadAloud(!f.readAloud),className:R(`size-9`,f.readAloud&&`text-ink`),children:f.readAloud?(0,V.jsx)(ae,{className:`size-4`}):(0,V.jsx)(be,{className:`size-4`})}):null,g?(0,V.jsx)(L,{label:v(h.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":h.listening,disabled:h.processing,onClick:h.toggle,className:R(`size-9`,h.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:h.processing?(0,V.jsx)(O,{className:`size-4`}):h.listening?(0,V.jsx)(A,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,V.jsx)(y,{className:`size-4`})}):null]}):null;return(0,V.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),_()},children:[x&&!S?(0,V.jsx)(`video`,{ref:x.video,muted:!0,playsInline:!0,autoPlay:!0,className:R(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,x.camera?`block`:`hidden`)}):null,(0,V.jsxs)(`div`,{className:R(`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:[C,n?(0,V.jsx)(w,{ref:d,minRows:1,maxRows:6,value:c,disabled:a,placeholder:b,autoCapitalize:`sentences`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!m&&!e.nativeEvent.isComposing&&(e.preventDefault(),_())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,V.jsx)(`input`,{ref:d,...r,value:c,disabled:a,placeholder:b,enterKeyHint:`send`,onChange:e=>l(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,V.jsx)(`button`,{type:`submit`,"aria-label":v(`chat.send`),title:v(`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,V.jsx)(O,{className:`size-4`}):(0,V.jsx)(N,{className:`size-4`})})]}),h.error?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:h.error===`denied`?v(`chat.micDenied`):h.error}):S?null:x?.error?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:x.error}):x?.state===`live`?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:x.speaking?v(`talk.speaking`):x.listening?v(`talk.listening`):v(`talk.live`)}):f?.talk&&x?.state===`off`?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:v(`talk.hint`)}):null]})}function Q({placeholder:e=v(`chat.above`)}){return(0,V.jsx)(Ne,{children:(0,V.jsx)(Z,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Ie(e){let t=c[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var Le=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function Re(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(Le(t))return e.required&&!n?v(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return v(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return v(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?v(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?v(`run.filesMin`,{n:t.length,min:e.min}):null}function ze(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 Be({field:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,V.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function Ve({step:e,only:t}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,V.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,V.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function He({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,V.jsx)(V.Fragment,{children:typeof t==`string`&&t?t:v(`chat.connected`)});if(e.kind===`list`)return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(T,{className:`size-4`}),` `,v(`chat.checked`)]});if(e.kind===`toggle`)return(0,V.jsx)(V.Fragment,{children:v(t===!0?`run.yes`:`run.no`)});if(Le(t))return(0,V.jsx)(`span`,{className:`italic opacity-80`,children:v(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,V.jsx)(V.Fragment,{children:t.join(`, `)});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,V.jsx)(V.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(a,{dateStyle:`long`}).format(e)})}case`color`:return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,V.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,V.jsx)(`img`,{src:M(`/api/runs/${n}/assets/${t}`),alt:``,className:R(`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,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(z,{className:`size-4`}),` `,v(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(y,{className:`size-4`}),` `,v(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,V.jsx)(V.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,V.jsx)(V.Fragment,{children:v(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,V.jsx)(V.Fragment,{children:String(t)})}}function Ue(e,t,n,r,i,a){let o=[W(t,(0,V.jsx)(Ve,{step:e,only:a}))];for(let e of i)a||o.push(W(`${t}:${e.id}`,(0,V.jsx)(Be,{field:e}))),o.push(G(`${t}:${e.id}:a`,(0,V.jsx)(He,{field:e,value:n[e.id],runId:r})));return o}var We=(e,t)=>e.fields.filter(e=>!e.when&&!b(e)||t[e.id]!==void 0&&t[e.id]!==null);function Ge(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(...Ue(r,i,e.values,e.id,We(r,e.values),t))}else r.type===`review`&&(n.push(W(i,(0,V.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(G(`${i}:a`,v(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function Ke(e,t){return e.fields.filter(e=>!b(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function qe({view:e,run:t,step:n,before:r}){let i=(0,B.useMemo)(()=>Ke(n,e),[n,e]),a=e.known??{},[o,s]=(0,B.useState)(()=>D(n,e)),[c,l]=(0,B.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?x(Ke(n,e),e.known??{},D(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,B.useState)({}),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(!1),g=x(i,a,o),_=g.filter(e=>c.includes(e.id)),y=g.find(e=>!c.includes(e.id)),b=i.length===1?i[0]:void 0,S=_.at(-1),C=S?()=>l(e=>e.filter(e=>e!==S.id)):void 0;(0,B.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=x(i,a,o),r=n.findIndex(t=>e.includes(t.id));r>=0&&(l(n.slice(0,r).map(e=>e.id)),d(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(h)},T=(0,B.useContext)(K),E=(0,B.useRef)(o);E.current=o;let O=T?.bindPage,k=(0,B.useRef)(w);k.current=w,(0,B.useEffect)(()=>{if(!O)return;let e=x(i,a,o);return O({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Re(r,n)||(s(e=>({...e,[t]:n})),l(e=>e.includes(t)?e:[...e,t]),d({}),null):`no such field on this page`},submit:()=>k.current(E.current)}),()=>O(null)},[O,n,i,a,o]);let A=e=>{if(!y)return!1;let t=Re(y,e);if(t)return d({[y.id]:t}),!1;let n={...o,[y.id]:e},r=[...c,y.id];return s(n),l(r),d({}),x(i,a,n).some(e=>!r.includes(e.id))||w(n),!0},j=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...Ue(n,`now:${n.id}`,o,e.id,_,b).map((e,t,n)=>t===n.length-1&&e.who===`me`&&y?{...e,onEdit:C}:e)];y?(Ie(y)===`control`?j.push(W(`now:${n.id}:${y.id}:control`,(0,V.jsx)(te,{field:y,value:o[y.id],values:o,runId:e.id,view:e,closed:e.closed?.[y.id],onChange:e=>s(t=>({...t,[y.id]:e})),onBusy:p}),{wide:!0})):b||j.push(W(`now:${n.id}:${y.id}`,(0,V.jsx)(Be,{field:y}))),u[y.id]&&j.push(W(`now:${n.id}:${y.id}:error`,u[y.id],{tone:`error`}))):t.busy||m?j.push(W(`sending`,(0,V.jsx)(Fe,{}))):t.error&&j.push(W(`send-error`,t.error,{tone:`error`}));let M=(0,V.jsx)(Q,{});if(m||!y&&c.length>0&&t.busy)M=(0,V.jsx)(Q,{placeholder:v(`run.working`)});else if(!y)j.push(Y(`now:${n.id}:go`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(X,{primary:!0,busy:t.busy,onClick:()=>w(o),children:n.cta||v(`run.next`)}),C?(0,V.jsx)(X,{onClick:C,disabled:t.busy,children:v(`run.back`)}):null]})));else{let r=Ie(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,V.jsx)(X,{onClick:()=>A(void 0),children:v(`chat.skip`)}):null;if(r===`typed`){i&&j.push(Y(`now:${n.id}:${y.id}:replies`,i));let e=o[y.id];M=(0,V.jsx)(Ne,{children:(0,V.jsx)(Z,{initial:Le(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:v(`chat.placeholder`)),inputProps:Je(y),busy:t.busy,onSend:e=>A(ze(y,e))},y.id)})}else if(r===`tapped`)j.push(W(`now:${n.id}:${y.id}:replies`,(0,V.jsx)(Ye,{field:y,view:e,value:o[y.id],onAnswer:A}),{bare:!0}));else{let e=g.filter(e=>!c.includes(e.id)).length===1;j.push(Y(`now:${n.id}:${y.id}:replies`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(X,{primary:!0,disabled:f,onClick:()=>A(o[y.id]),children:e&&n.cta?n.cta:v(`chat.send`)}),i]})))}}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(q,{avatar:e.wizard.avatar,lines:j}),M]})}function Je(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 _(e)}}function Ye({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,V.jsxs)(J,{children:[(0,V.jsx)(X,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:v(`run.no`)}),(0,V.jsx)(X,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:v(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,V.jsxs)(J,{children:[s.map(e=>(0,V.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,V.jsx)(X,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?v(`chat.send`):v(`chat.skip`)})]}):(0,V.jsxs)(J,{children:[s.map(e=>(0,V.jsx)(X,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:e},e)),e.required?null:(0,V.jsx)(X,{onClick:()=>r(void 0),children:v(`chat.skip`)})]})}function Xe({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(Qe),c=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,V.jsxs)(`div`,{className:R(`flex max-w-full flex-col gap-1`,s?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??v(`run.working`),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(Fe,{}),(0,V.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??v(`run.working`)}),(0,V.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:v(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),o&&o!==s?(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,V.jsx)(u,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,V.jsx)(`span`,{className:`truncate`,children:g(o)})]}):null,s&&e.status===`running`?(0,V.jsx)(et,{runId:e.id,event:s}):null,c.length?(0,V.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:c.slice(-6).map(t=>(0,V.jsx)(`img`,{src:M(`/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 Ze=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Qe(e){return!!e.note&&Ze.has(e.note.code)}var $e=1e4;function et({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=()=>C.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,$e);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let l=i===`person`,u=async()=>{s(!0);try{let t=await C.post(`/api/runs/${e}/browser/seat`,{to:l?`agent`:`person`});a(t.seat)}catch{}finally{s(!1)}};return(0,V.jsx)(I,{runId:e,driving:l,caption:g(t),hint:v(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,V.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void u(),className:R(`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,V.jsx)(ge,{className:`size-3.5`}):(0,V.jsx)(me,{className:`size-3.5`}),v(l?`browser.handBack`:`browser.takeOver`)]})},n??0)}function $({children:e,end:t}){return(0,V.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function tt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[c,l]=(0,B.useState)(o.length===1?o[0].step.id:null),u=(0,B.useRef)(null),d=[...r,...i.map((e,t)=>G(`review:${n.id}:asked:${t}`,e)),W(`review:${n.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,V.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,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{children:t.title}),(0,V.jsx)(h,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{l(t.id),u.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>W(`review:${n.id}:list:${t.def.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{children:t.def.title}),t.def.check?(0,V.jsx)(s,{runId:e.id,list:t}):(0,V.jsx)(f,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&d.push(W(`review-error`,t.error,{tone:`error`}));let p=n.regenerate&&o.length>0;return d.push(Y(`review:${n.id}:replies`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(X,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,V.jsx)(T,{className:`size-4`}),` `,v(`run.accept`)]}),p&&o.length>1?o.map(({step:e})=>(0,V.jsx)(X,{on:c===e.id,onClick:()=>l(e.id),children:e.title},e.id)):null]}))),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(q,{avatar:e.wizard.avatar,lines:d}),p?(0,V.jsx)(Ne,{children:(0,V.jsx)(Z,{multiline:!0,inputRef:u,busy:t.busy,placeholder:o.length>1&&!c?v(`run.feedbackPick`):v(`run.feedbackPlaceholder`),disabled:!c,onSend:e=>{let r=e.trim();return!r||!c?!1:(a(r),t.regenerate(n.id,c,r),!0)}})}):(0,V.jsx)(Q,{})]})}function nt({view:e,run:t,step:n,before:r,onRestart:i}){let a=e.shown.filter(e=>e.output),s=`/api/runs/${e.id}`,c=[...r,W(`result:${n.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,V.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,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{end:(0,V.jsx)(ee,{base:s,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,V.jsx)(h,{base:s,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,V.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:v(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>W(`result:list:${t.def.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{end:(0,V.jsx)(o,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,V.jsx)(f,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return c.push(Y(`result:replies`,(0,V.jsxs)(V.Fragment,{children:[a.length?(0,V.jsx)(fe,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null}):null,i?(0,V.jsxs)(X,{onClick:i,children:[(0,V.jsx)(d,{className:`size-4`}),` `,v(`run.again`)]}):null,e.canBack?(0,V.jsx)(X,{onClick:()=>void t.back(),disabled:t.busy,children:v(`run.back`)}):null,e.keeps?(0,V.jsx)(`span`,{className:`ml-1`,children:(0,V.jsx)(j,{runId:e.id})}):null]}))),(0,V.jsx)(q,{avatar:e.wizard.avatar,lines:c})}function rt({runId:e,onRestart:t,onView:n,header:i,footer:o,talk:s=!1,call:c=!1}){let l=re(e),{view:u}=l,[f,p]=(0,B.useState)(null),m=Ae(e,u,l,f);(0,B.useEffect)(()=>{n?.(u)},[u,n]);let[h,g]=oe(),_=(0,B.useMemo)(()=>({runId:e,lang:u?.lang??a,readAloud:h,setReadAloud:g,voice:u?.talk?m:null,talk:s,call:!!c,bindPage:p}),[e,u?.lang,u?.talk,h,g,m,s,c]);r(u?.status===`running`&&!u.ask),S(u);let[y,b]=(0,B.useState)({}),[x,C]=(0,B.useState)(null);(0,B.useEffect)(()=>{u&&u.status!==`running`&&C(null)},[u]);let w;if(l.notFound)w=(0,V.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:v(`run.notFound`)});else if(!u)w=(0,V.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,V.jsx)(O,{})});else{let e=u.step,n=u.status===`waiting_input`,r=Ge(u,u.canBack&&n&&!l.busy?()=>void l.back():void 0);if(u.status===`running`&&u.ask)w=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(q,{avatar:u.wizard.avatar,lines:[...r,W(`ask:${u.ask.id}`,(0,V.jsx)(E,{runId:u.id,ask:u.ask}),{wide:!0})]}),(0,V.jsx)(Q,{})]});else if(u.status===`running`)w=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(q,{avatar:u.wizard.avatar,lines:[...r,...x?[G(`note`,x)]:[],W(`working:${e?.id}`,(0,V.jsx)(Xe,{view:u}),{wide:u.events.some(t=>t.stepId===e?.id&&Qe(t))?`most`:void 0})]}),(0,V.jsx)(Q,{placeholder:v(`run.working`)})]});else if(u.status===`failed`)w=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(q,{avatar:u.wizard.avatar,lines:[...r,W(`failed`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:v(`run.failed`)}),u.error?(0,V.jsx)(`span`,{className:`mt-0.5 block`,children:(0,V.jsx)(F,{text:u.error})}):null]}),{tone:`error`}),Y(`failed:replies`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(X,{primary:!0,busy:l.busy,onClick:()=>void l.retry(),children:[(0,V.jsx)(d,{className:`size-4`}),` `,v(`run.retry`)]}),u.canBack?(0,V.jsx)(X,{onClick:()=>void l.back(),disabled:l.busy,children:v(`run.back`)}):null]}))]}),(0,V.jsx)(Q,{})]});else if(u.status===`cancelled`)w=(0,V.jsx)(q,{avatar:u.wizard.avatar,lines:[...r,W(`cancelled`,v(`run.cancelled`)),...t?[Y(`cancelled:replies`,(0,V.jsxs)(X,{primary:!0,onClick:t,children:[(0,V.jsx)(d,{className:`size-4`}),` `,v(`run.again`)]}))]:[]]});else if(e?.type===`page`)w=(0,V.jsx)(qe,{view:u,run:l,step:e,before:r},e.id);else if(e?.type===`review`){let t=u.shown.map(e=>e.output?.at??``).join(`|`);w=(0,V.jsx)(tt,{view:u,run:l,step:e,before:r,asked:y[e.id]??[],onNote:t=>{C(t),b(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else w=e?.type===`result`?(0,V.jsx)(nt,{view:u,run:l,step:e,before:r,onRestart:t}):(0,V.jsx)(q,{avatar:u.wizard.avatar,lines:r})}return c?(0,V.jsx)(K.Provider,{value:_,children:(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,V.jsx)(Te,{voice:m,view:u,video:c===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,V.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,V.jsx)(Pe,{footer:o,children:w})})]})}):(0,V.jsx)(K.Provider,{value:_,children:(0,V.jsx)(Pe,{header:i,footer:o,children:w})})}export{q as a,X as i,Pe as n,Y as o,Q as r,Me as s,rt as t};
|