@aglyn/plugins-ai 1.0.0-beta.229 → 1.0.0-beta.230
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/README.md +3 -3
- package/package.json +17 -17
- package/src/lib/activity/ai-activity-actions.js +7 -1
- package/src/lib/activity/ai-activity-actions.js.map +1 -1
- package/src/lib/components/ai-automation-zones.d.ts +38 -0
- package/src/lib/components/ai-automation-zones.js +5 -1
- package/src/lib/components/ai-automation-zones.js.map +1 -1
- package/src/lib/components/ai-brief-dialog.component.d.ts +20 -2
- package/src/lib/components/ai-brief-dialog.component.js +87 -8
- package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
- package/src/lib/components/ai-campaign-create.component.d.ts +54 -0
- package/src/lib/components/ai-campaign-create.component.js +270 -0
- package/src/lib/components/ai-campaign-create.component.js.map +1 -0
- package/src/lib/components/ai-describe-automation.component.d.ts +8 -3
- package/src/lib/components/ai-describe-automation.component.js +15 -6
- package/src/lib/components/ai-describe-automation.component.js.map +1 -1
- package/src/lib/components/ai-describe-button.component.d.ts +20 -8
- package/src/lib/components/ai-describe-button.component.js +19 -36
- package/src/lib/components/ai-describe-button.component.js.map +1 -1
- package/src/lib/components/ai-describe-email.component.d.ts +31 -0
- package/src/lib/components/ai-describe-email.component.js +22 -0
- package/src/lib/components/ai-describe-email.component.js.map +1 -0
- package/src/lib/components/ai-describe-org-automation.component.d.ts +36 -0
- package/src/lib/components/ai-describe-org-automation.component.js +238 -0
- package/src/lib/components/ai-describe-org-automation.component.js.map +1 -0
- package/src/lib/components/ai-experiment-cards.component.d.ts +9 -1
- package/src/lib/components/ai-experiment-cards.component.js +104 -18
- package/src/lib/components/ai-experiment-cards.component.js.map +1 -1
- package/src/lib/components/ai-explain-automation.component.js +1 -5
- package/src/lib/components/ai-explain-automation.component.js.map +1 -1
- package/src/lib/components/ai-funnel-zones.component.d.ts +61 -0
- package/src/lib/components/ai-funnel-zones.component.js +178 -0
- package/src/lib/components/ai-funnel-zones.component.js.map +1 -0
- package/src/lib/components/ai-insight-card.component.d.ts +42 -0
- package/src/lib/components/ai-insight-card.component.js +137 -0
- package/src/lib/components/ai-insight-card.component.js.map +1 -0
- package/src/lib/components/ai-insight-dialog.component.d.ts +6 -0
- package/src/lib/components/ai-insight-dialog.component.js +9 -3
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
- package/src/lib/components/ai-job-plan.component.d.ts +7 -2
- package/src/lib/components/ai-job-plan.component.js +35 -5
- package/src/lib/components/ai-job-plan.component.js.map +1 -1
- package/src/lib/components/ai-job-requests.d.ts +17 -1
- package/src/lib/components/ai-job-requests.js +39 -3
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-logic-zones.d.ts +64 -0
- package/src/lib/components/ai-logic-zones.js +18 -0
- package/src/lib/components/ai-logic-zones.js.map +1 -0
- package/src/lib/components/ai-logic.component.d.ts +77 -0
- package/src/lib/components/ai-logic.component.js +553 -0
- package/src/lib/components/ai-logic.component.js.map +1 -0
- package/src/lib/components/ai-marketing-insight.component.d.ts +30 -0
- package/src/lib/components/ai-marketing-insight.component.js +80 -0
- package/src/lib/components/ai-marketing-insight.component.js.map +1 -0
- package/src/lib/components/ai-media-create.component.d.ts +55 -0
- package/src/lib/components/ai-media-create.component.js +433 -0
- package/src/lib/components/ai-media-create.component.js.map +1 -0
- package/src/lib/components/ai-overlay-cards.component.d.ts +83 -0
- package/src/lib/components/ai-overlay-cards.component.js +505 -0
- package/src/lib/components/ai-overlay-cards.component.js.map +1 -0
- package/src/lib/components/ai-product-zones.d.ts +5 -0
- package/src/lib/components/ai-product-zones.js +1 -1
- package/src/lib/components/ai-product-zones.js.map +1 -1
- package/src/lib/components/ai-products-create-button.component.d.ts +42 -0
- package/src/lib/components/ai-products-create-button.component.js +67 -0
- package/src/lib/components/ai-products-create-button.component.js.map +1 -0
- package/src/lib/components/ai-products-hub-card.component.js +100 -81
- package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
- package/src/lib/components/ai-revise-automation.component.d.ts +16 -0
- package/src/lib/components/ai-revise-automation.component.js +207 -0
- package/src/lib/components/ai-revise-automation.component.js.map +1 -0
- package/src/lib/components/ai-site-build-page.component.js +140 -16
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +53 -0
- package/src/lib/components/ai-upsell-dialog.component.js +177 -0
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -0
- package/src/lib/components/assist-build-card.component.d.ts +42 -0
- package/src/lib/components/assist-build-card.component.js +183 -0
- package/src/lib/components/assist-build-card.component.js.map +1 -0
- package/src/lib/components/assist-edit-canvas.d.ts +2 -0
- package/src/lib/components/assist-edit-canvas.js +56 -1
- package/src/lib/components/assist-edit-canvas.js.map +1 -1
- package/src/lib/components/assist-jobs-drawer.component.js +48 -3
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
- package/src/lib/components/assist-panel.component.js +51 -2
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/components/use-ai-job-run.d.ts +3 -14
- package/src/lib/components/use-ai-job-run.js +0 -50
- package/src/lib/components/use-ai-job-run.js.map +1 -1
- package/src/lib/jobs/ai-build-capabilities.d.ts +58 -0
- package/src/lib/jobs/ai-build-capabilities.js +256 -0
- package/src/lib/jobs/ai-build-capabilities.js.map +1 -0
- package/src/lib/jobs/ai-build-unit-outcome.d.ts +52 -0
- package/src/lib/jobs/ai-build-unit-outcome.js +138 -0
- package/src/lib/jobs/ai-build-unit-outcome.js.map +1 -0
- package/src/lib/jobs/ai-job-build-step.d.ts +144 -0
- package/src/lib/jobs/ai-job-build-step.js +657 -0
- package/src/lib/jobs/ai-job-build-step.js.map +1 -0
- package/src/lib/jobs/ai-job-draft-ids.js +9 -1
- package/src/lib/jobs/ai-job-draft-ids.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.d.ts +14 -4
- package/src/lib/jobs/ai-job-drafts.js +25 -4
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-logic-step.d.ts +107 -0
- package/src/lib/jobs/ai-job-logic-step.js +395 -0
- package/src/lib/jobs/ai-job-logic-step.js.map +1 -0
- package/src/lib/jobs/ai-job-overlay-copy.d.ts +70 -0
- package/src/lib/jobs/ai-job-overlay-copy.js +178 -0
- package/src/lib/jobs/ai-job-overlay-copy.js.map +1 -0
- package/src/lib/jobs/ai-job-page-step.js +6 -6
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.d.ts +26 -1
- package/src/lib/jobs/ai-job-plan-step.js +79 -11
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-step.d.ts +15 -1
- package/src/lib/jobs/ai-job-site-step.js +200 -58
- package/src/lib/jobs/ai-job-site-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +22 -1
- package/src/lib/jobs/ai-job-text-step.js +12 -0
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-job-workflow-step.d.ts +54 -4
- package/src/lib/jobs/ai-job-workflow-step.js +318 -13
- package/src/lib/jobs/ai-job-workflow-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +80 -2
- package/src/lib/jobs/ai-jobs.js +377 -13
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-logic-records.d.ts +40 -0
- package/src/lib/jobs/ai-logic-records.js +55 -0
- package/src/lib/jobs/ai-logic-records.js.map +1 -0
- package/src/lib/jobs/ai-site-publish.d.ts +7 -0
- package/src/lib/jobs/ai-site-publish.js +9 -0
- package/src/lib/jobs/ai-site-publish.js.map +1 -1
- package/src/lib/jobs/ai-workflow-records.d.ts +4 -0
- package/src/lib/jobs/ai-workflow-records.js +40 -1
- package/src/lib/jobs/ai-workflow-records.js.map +1 -1
- package/src/lib/model/ai-automation-draft.d.ts +18 -0
- package/src/lib/model/ai-automation-draft.js +86 -0
- package/src/lib/model/ai-automation-draft.js.map +1 -1
- package/src/lib/model/ai-build-job.d.ts +201 -0
- package/src/lib/model/ai-build-job.js +471 -0
- package/src/lib/model/ai-build-job.js.map +1 -0
- package/src/lib/model/ai-build-plan.d.ts +61 -0
- package/src/lib/model/ai-build-plan.js +154 -9
- package/src/lib/model/ai-build-plan.js.map +1 -1
- package/src/lib/model/ai-build-progress.d.ts +56 -0
- package/src/lib/model/ai-build-progress.js +128 -0
- package/src/lib/model/ai-build-progress.js.map +1 -0
- package/src/lib/model/ai-insight.d.ts +20 -10
- package/src/lib/model/ai-insight.js +72 -9
- package/src/lib/model/ai-insight.js.map +1 -1
- package/src/lib/model/ai-job-activity.js +3 -1
- package/src/lib/model/ai-job-activity.js.map +1 -1
- package/src/lib/model/ai-jobs.types.d.ts +80 -2
- package/src/lib/model/ai-jobs.types.js +3 -1
- package/src/lib/model/ai-jobs.types.js.map +1 -1
- package/src/lib/model/ai-logic-job.d.ts +108 -0
- package/src/lib/model/ai-logic-job.js +327 -0
- package/src/lib/model/ai-logic-job.js.map +1 -0
- package/src/lib/model/ai-media-credits.d.ts +52 -0
- package/src/lib/model/ai-media-credits.js +61 -0
- package/src/lib/model/ai-media-credits.js.map +1 -0
- package/src/lib/model/ai-overlay-copy.d.ts +114 -0
- package/src/lib/model/ai-overlay-copy.js +175 -0
- package/src/lib/model/ai-overlay-copy.js.map +1 -0
- package/src/lib/model/ai-site-build-progress.d.ts +20 -3
- package/src/lib/model/ai-site-build-progress.js +170 -10
- package/src/lib/model/ai-site-build-progress.js.map +1 -1
- package/src/lib/model/ai-svg.d.ts +69 -0
- package/src/lib/model/ai-svg.js +265 -0
- package/src/lib/model/ai-svg.js.map +1 -0
- package/src/lib/model/ai-usage-by-user.d.ts +3 -2
- package/src/lib/model/ai-usage-by-user.js.map +1 -1
- package/src/lib/model/ai-workflow-job.d.ts +92 -4
- package/src/lib/model/ai-workflow-job.js +124 -7
- package/src/lib/model/ai-workflow-job.js.map +1 -1
- package/src/lib/model/assist-build.d.ts +58 -0
- package/src/lib/model/assist-build.js +52 -0
- package/src/lib/model/assist-build.js.map +1 -0
- package/src/lib/model/assist-edit.d.ts +48 -3
- package/src/lib/model/assist-edit.js +48 -4
- package/src/lib/model/assist-edit.js.map +1 -1
- package/src/lib/plugin-config.js +2 -0
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +240 -11
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/providers/catalog.d.ts +81 -4
- package/src/lib/providers/catalog.js +80 -9
- package/src/lib/providers/catalog.js.map +1 -1
- package/src/lib/providers/image-contract.d.ts +116 -0
- package/src/lib/providers/image-contract.js +74 -0
- package/src/lib/providers/image-contract.js.map +1 -0
- package/src/lib/providers/model-choice.js +11 -0
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/providers/routing.js +18 -0
- package/src/lib/providers/routing.js.map +1 -1
- package/src/lib/providers/vertex-image.d.ts +121 -0
- package/src/lib/providers/vertex-image.js +312 -0
- package/src/lib/providers/vertex-image.js.map +1 -0
- package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
- package/src/lib/runtime/ai-doctrine-validators.js +89 -0
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +11 -5
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/runtime/ai-eval-live.js +4 -0
- package/src/lib/runtime/ai-eval-live.js.map +1 -1
- package/src/lib/runtime/ai-eval.d.ts +15 -1
- package/src/lib/runtime/ai-eval.js +52 -1
- package/src/lib/runtime/ai-eval.js.map +1 -1
- package/src/lib/runtime/experiment-variant-copy.d.ts +34 -0
- package/src/lib/runtime/experiment-variant-copy.js +102 -0
- package/src/lib/runtime/experiment-variant-copy.js.map +1 -0
- package/src/lib/server/ai-experiment-versions.d.ts +51 -0
- package/src/lib/server/ai-experiment-versions.js +270 -0
- package/src/lib/server/ai-experiment-versions.js.map +1 -0
- package/src/lib/server/ai-jobs-resume.js +74 -4
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/server/ai-media-image.d.ts +66 -0
- package/src/lib/server/ai-media-image.js +521 -0
- package/src/lib/server/ai-media-image.js.map +1 -0
- package/src/lib/server/ai-media-svg.d.ts +91 -0
- package/src/lib/server/ai-media-svg.js +186 -0
- package/src/lib/server/ai-media-svg.js.map +1 -0
- package/src/lib/server/assist-build.d.ts +54 -0
- package/src/lib/server/assist-build.js +121 -0
- package/src/lib/server/assist-build.js.map +1 -0
- package/src/lib/server/assist-chat.js +108 -12
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/assist-edit.js +213 -3
- package/src/lib/server/assist-edit.js.map +1 -1
- package/src/lib/server/assist-view-context.js +242 -4
- package/src/lib/server/assist-view-context.js.map +1 -1
- package/src/lib/server.js +26 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tools/ai-logic-tool.d.ts +27 -0
- package/src/lib/tools/ai-logic-tool.js +207 -0
- package/src/lib/tools/ai-logic-tool.js.map +1 -0
- package/src/lib/tools/ai-overlay-tool.d.ts +35 -0
- package/src/lib/tools/ai-overlay-tool.js +107 -0
- package/src/lib/tools/ai-overlay-tool.js.map +1 -0
- package/src/lib/tools/ai-workflow-tool.d.ts +11 -0
- package/src/lib/tools/ai-workflow-tool.js +31 -0
- package/src/lib/tools/ai-workflow-tool.js.map +1 -1
- package/src/lib/usage/assist-job-refund.d.ts +28 -1
- package/src/lib/usage/assist-job-refund.js +44 -9
- package/src/lib/usage/assist-job-refund.js.map +1 -1
- package/src/lib/usage/assist-usage.d.ts +5 -0
- package/src/lib/usage/assist-usage.js +2 -0
- package/src/lib/usage/assist-usage.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-describe-automation.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleHostAutomationsZoneProps } from './ai-automation-zones'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport { openAiJobs } from './ai-jobs-store'\nimport { aiJobProblem, useAiJobRun, useAiJobsVerdict } from './use-ai-job-run'\n\n/**\n * \"Create with AI\" on the Automation page's Actions (AGL-2919), beside Add action\n * and Recipes through the `hostAutomations` zone: a description becomes a\n * `workflow` job that drafts one automation, switched off.\n *\n * The dialog follows the shared brief dialog's shape — one text box, what\n * happens next, and the action that starts the job — and then follows the\n * job, because an automation's draft needs no plan to confirm: when it is\n * written, the dialog says what to fill in and opens it in the Actions editor.\n */\n\n/** The longest description a job admits. */\nconst BRIEF_MAX_CHARS = 4_000\n\nexport const AI_AUTOMATION_BRIEF_COPY = {\n title: 'Describe an automation',\n briefLabel: 'What should happen, and when?',\n placeholder:\n 'When someone submits the newsletter form, add them to the newsletter list, make them ' +\n 'a lead and send them a welcome email',\n next:\n 'The automation is drafted switched off, using only the triggers and steps your plan ' +\n 'includes. Anything it needs that your site does not have yet is left for you to fill in.',\n submit: 'Draft the automation',\n started:\n 'The automation is being drafted. This can take a few minutes. You can close this ' +\n 'window: the draft appears in the list, switched off, when it is ready. Open AI ' +\n 'jobs to follow it meanwhile.',\n drafted: 'Drafted',\n review: 'Review it',\n notListed: 'The draft is saved. It appears in the list in a moment.',\n failed: 'The automation could not be drafted. Try again.',\n} as const\n\nexport interface AiAutomationBriefDialogProps {\n open: boolean\n onClose: () => void\n orgId: string | undefined\n hostId: string\n /** Who is signed in, whose token the requests carry. */\n user: Parameters<typeof useAiJobRun>[0]\n /** Opens a listed action in the Actions editor; `false` when the list has not read it yet. */\n openAction: (actionId: string) => boolean\n}\n\nexport function AiAutomationBriefDialog(props: AiAutomationBriefDialogProps) {\n const { open, onClose, orgId, hostId, user, openAction } = props\n const copy = AI_AUTOMATION_BRIEF_COPY\n const help = pluginDocsHelp('aiAutomations')\n const [brief, setBrief] = useState('')\n const [notListed, setNotListed] = useState(false)\n const run = useAiJobRun(user, copy.failed)\n const { job, starting, running, notice, reset } = run\n\n // Opening or closing starts over and stops following: a job still drafting\n // carries on in AI jobs, and its draft appears in the list when it is written.\n useEffect(() => {\n reset()\n setNotListed(false)\n }, [open, reset])\n\n const draft = job?.status === 'done' ? job.outputs.find((output) => output.resource === 'workflow') : undefined\n const problem = aiJobProblem(job, copy.failed) ?? (job?.status === 'done' && !draft ? copy.failed : null)\n const asking = !job || Boolean(notice)\n\n const start = async () => {\n const trimmed = brief.trim()\n if (!orgId || !trimmed) return\n setNotListed(false)\n if (await run.start({ orgId, hostId, kind: 'workflow', brief: trimmed, inputs: { mode: 'draft' } })) {\n setBrief('')\n }\n }\n\n const review = () => {\n if (!draft) return\n if (openAction(draft.id)) onClose()\n else setNotListed(true)\n }\n\n return (\n <Dialog open={open} onClose={starting ? undefined : onClose} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy.title}</DialogTitle>\n <DialogContent>\n {asking ? (\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy.briefLabel}\n placeholder={copy.placeholder}\n multiline\n minRows={4}\n value={brief}\n onChange={(event) => setBrief(event.target.value.slice(0, BRIEF_MAX_CHARS))}\n helperText={`${brief.length.toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={starting}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy.next}{' '}\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Typography>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n ) : (\n <Stack spacing={2} sx={{ pt: 1 }}>\n {running && job ? (\n <Alert\n severity=\"info\"\n icon={<CircularProgress size={18} aria-label=\"Drafting\" />}\n action={\n // Follows the job in the Assist panel (AGL-3593); the dialog\n // covers it, so it closes.\n <Button\n color=\"inherit\"\n size=\"small\"\n variant=\"outlined\"\n onClick={() => {\n openAiJobs({ jobId: job.id })\n onClose()\n }}\n >\n {'Open AI jobs'}\n </Button>\n }\n >\n {copy.started}\n </Alert>\n ) : null}\n {draft ? (\n <Alert severity=\"success\">\n <Typography variant=\"body2\" sx={{ fontWeight: 600 }}>\n {`${copy.drafted}: ${draft.label}`}\n </Typography>\n {draft.note ? <Typography variant=\"body2\">{draft.note}</Typography> : null}\n </Alert>\n ) : null}\n {problem ? <Alert severity={job?.status === 'failed' ? 'error' : 'warning'}>{problem}</Alert> : null}\n {notListed ? <Alert severity=\"info\">{copy.notListed}</Alert> : null}\n </Stack>\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={starting}>\n {asking ? 'Cancel' : 'Close'}\n </Button>\n {asking ? (\n <Button\n variant=\"contained\"\n onClick={() => void start()}\n disabled={starting || !orgId || !brief.trim()}\n >\n {copy.submit}\n </Button>\n ) : draft ? (\n <Button variant=\"contained\" onClick={review}>\n {copy.review}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * Renders nothing until the jobs route has answered for this workspace, and\n * nothing when it says the feature is not this workspace's.\n */\nexport function AiDescribeAutomationButton({ hostId, orgId, openAction }: ConsoleHostAutomationsZoneProps) {\n const { data: user } = useUser()\n const verdict = useAiJobsVerdict(user, orgId)\n const [open, setOpen] = useState(false)\n\n if (verdict !== 'ready') return null\n return (\n <>\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {'Create with AI'}\n </Button>\n <AiAutomationBriefDialog\n open={open}\n onClose={() => setOpen(false)}\n orgId={orgId}\n hostId={hostId}\n user={user}\n openAction={openAction}\n />\n </>\n )\n}\n\nexport default AiDescribeAutomationButton\n"],"names":["pluginDocsHelp","mdiCreation","MdiIcon","useUser","Alert","Button","CircularProgress","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useEffect","useState","openAiJobs","aiJobProblem","useAiJobRun","useAiJobsVerdict","BRIEF_MAX_CHARS","AI_AUTOMATION_BRIEF_COPY","title","briefLabel","placeholder","next","submit","started","drafted","review","notListed","failed","AiAutomationBriefDialog","props","open","onClose","orgId","hostId","user","openAction","copy","help","brief","setBrief","setNotListed","run","job","starting","running","notice","reset","draft","status","outputs","find","output","resource","undefined","problem","asking","Boolean","start","trimmed","trim","kind","inputs","mode","id","fullWidth","maxWidth","spacing","sx","pt","label","multiline","minRows","value","onChange","event","target","slice","helperText","length","toLocaleString","disabled","autoFocus","variant","color","href","rel","excerpt","severity","icon","size","aria-label","action","onClick","jobId","fontWeight","note","AiDescribeAutomationButton","data","verdict","setOpen","startIcon","path"],"mappings":"AAAA;;AAEA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,MAAM,EACNC,gBAAgB,EAChBC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,Q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mC;IACvG,MAAM,EAAE8D,MAAM/D,IAAI,EAAE,GAAGpC;IACvB,MAAMoG,UAAUnF,iBAAiBmB,MAAMF;IACvC,MAAM,CAACF,MAAMqE,QAAQ,GAAGxF,SAAS;IAEjC,IAAIuF,YAAY,SAAS,OAAO;IAChC,qBACE;;0BACE,KAAClG;gBACCyF,MAAK;gBACLP,SAAQ;gBACRkB,yBAAW,KAACvG;oBAAQwG,MAAMzG,YAAYyG,IAAI;;gBAC1CT,SAAS,IAAMO,QAAQ;0BAEtB;;0BAEH,KAACvE;gBACCE,MAAMA;gBACNC,SAAS,IAAMoE,QAAQ;gBACvBnE,OAAOA;gBACPC,QAAQA;gBACRC,MAAMA;gBACNC,YAAYA;;;;AAIpB;AAEA,eAAe6D,2BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-describe-automation.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleWidgetEntitlementProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport type { ConsoleHostAutomationsZoneProps } from './ai-automation-zones'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport { openAiJobs } from './ai-jobs-store'\nimport { AiUpsellButton } from './ai-upsell-dialog.component'\nimport { aiJobProblem, useAiJobRun } from './use-ai-job-run'\n\n/**\n * \"Create with AI\" on the Automation page's Actions (AGL-2919), beside Add action\n * and Recipes through the `hostAutomations` zone: a description becomes a\n * `workflow` job that drafts one automation, switched off.\n *\n * The dialog follows the shared brief dialog's shape — one text box, what\n * happens next, and the action that starts the job — and then follows the\n * job, because an automation's draft needs no plan to confirm: when it is\n * written, the dialog says what to fill in and opens it in the Actions editor.\n */\n\n/** The longest description a job admits. */\nconst BRIEF_MAX_CHARS = 4_000\n\nexport const AI_AUTOMATION_BRIEF_COPY = {\n title: 'Describe an automation',\n briefLabel: 'What should happen, and when?',\n placeholder:\n 'When someone submits the newsletter form, add them to the newsletter list, make them ' +\n 'a lead and send them a welcome email',\n next:\n 'The automation is drafted switched off, using only the triggers and steps your plan ' +\n 'includes. Anything it needs that your site does not have yet is left for you to fill in.',\n submit: 'Draft the automation',\n started:\n 'The automation is being drafted. This can take a few minutes. You can close this ' +\n 'window: the draft appears in the list, switched off, when it is ready. Open AI ' +\n 'jobs to follow it meanwhile.',\n drafted: 'Drafted',\n review: 'Review it',\n notListed: 'The draft is saved. It appears in the list in a moment.',\n failed: 'The automation could not be drafted. Try again.',\n} as const\n\nexport interface AiAutomationBriefDialogProps {\n open: boolean\n onClose: () => void\n orgId: string | undefined\n hostId: string\n /** Who is signed in, whose token the requests carry. */\n user: Parameters<typeof useAiJobRun>[0]\n /** Opens a listed action in the Actions editor; `false` when the list has not read it yet. */\n openAction: (actionId: string) => boolean\n}\n\nexport function AiAutomationBriefDialog(props: AiAutomationBriefDialogProps) {\n const { open, onClose, orgId, hostId, user, openAction } = props\n const copy = AI_AUTOMATION_BRIEF_COPY\n const help = pluginDocsHelp('aiAutomations')\n const [brief, setBrief] = useState('')\n const [notListed, setNotListed] = useState(false)\n const run = useAiJobRun(user, copy.failed)\n const { job, starting, running, notice, reset } = run\n\n // Opening or closing starts over and stops following: a job still drafting\n // carries on in AI jobs, and its draft appears in the list when it is written.\n useEffect(() => {\n reset()\n setNotListed(false)\n }, [open, reset])\n\n const draft = job?.status === 'done' ? job.outputs.find((output) => output.resource === 'workflow') : undefined\n const problem = aiJobProblem(job, copy.failed) ?? (job?.status === 'done' && !draft ? copy.failed : null)\n const asking = !job || Boolean(notice)\n\n const start = async () => {\n const trimmed = brief.trim()\n if (!orgId || !trimmed) return\n setNotListed(false)\n if (await run.start({ orgId, hostId, kind: 'workflow', brief: trimmed, inputs: { mode: 'draft' } })) {\n setBrief('')\n }\n }\n\n const review = () => {\n if (!draft) return\n if (openAction(draft.id)) onClose()\n else setNotListed(true)\n }\n\n return (\n <Dialog open={open} onClose={starting ? undefined : onClose} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy.title}</DialogTitle>\n <DialogContent>\n {asking ? (\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy.briefLabel}\n placeholder={copy.placeholder}\n multiline\n minRows={4}\n value={brief}\n onChange={(event) => setBrief(event.target.value.slice(0, BRIEF_MAX_CHARS))}\n helperText={`${brief.length.toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={starting}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy.next}{' '}\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Typography>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n ) : (\n <Stack spacing={2} sx={{ pt: 1 }}>\n {running && job ? (\n <Alert\n severity=\"info\"\n icon={<CircularProgress size={18} aria-label=\"Drafting\" />}\n action={\n // Follows the job in the Assist panel (AGL-3593); the dialog\n // covers it, so it closes.\n <Button\n color=\"inherit\"\n size=\"small\"\n variant=\"outlined\"\n onClick={() => {\n openAiJobs({ jobId: job.id })\n onClose()\n }}\n >\n {'Open AI jobs'}\n </Button>\n }\n >\n {copy.started}\n </Alert>\n ) : null}\n {draft ? (\n <Alert severity=\"success\">\n <Typography variant=\"body2\" sx={{ fontWeight: 600 }}>\n {`${copy.drafted}: ${draft.label}`}\n </Typography>\n {draft.note ? <Typography variant=\"body2\">{draft.note}</Typography> : null}\n </Alert>\n ) : null}\n {problem ? <Alert severity={job?.status === 'failed' ? 'error' : 'warning'}>{problem}</Alert> : null}\n {notListed ? <Alert severity=\"info\">{copy.notListed}</Alert> : null}\n </Stack>\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={starting}>\n {asking ? 'Cancel' : 'Close'}\n </Button>\n {asking ? (\n <Button\n variant=\"contained\"\n onClick={() => void start()}\n disabled={starting || !orgId || !brief.trim()}\n >\n {copy.submit}\n </Button>\n ) : draft ? (\n <Button variant=\"contained\" onClick={review}>\n {copy.review}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * Drawn at once, from the gates the shell resolved before mounting it (the\n * plan, `ai.generate`, the site's AI switch and the release flag); nothing is\n * asked of a server to draw it (AGL-3601). The start door decides when the\n * description is sent, and says why in the dialog if it refuses. On a plan\n * that could buy the AI add-on, the shell mounts it with `entitled={false}`\n * and the same button opens the add-on's dialog.\n */\nexport function AiDescribeAutomationButton({\n hostId,\n orgId,\n openAction,\n entitled,\n upgrade,\n}: ConsoleHostAutomationsZoneProps & ConsoleWidgetEntitlementProps) {\n const { data: user } = useUser()\n const [open, setOpen] = useState(false)\n\n if (entitled === false) {\n return upgrade ? <AiUpsellButton kind=\"workflow\" upgrade={upgrade} /> : null\n }\n return (\n <>\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {'Create with AI'}\n </Button>\n <AiAutomationBriefDialog\n open={open}\n onClose={() => setOpen(false)}\n orgId={orgId}\n hostId={hostId}\n user={user}\n openAction={openAction}\n />\n </>\n )\n}\n\nexport default AiDescribeAutomationButton\n"],"names":["pluginDocsHelp","mdiCreation","MdiIcon","useUser","Alert","Button","CircularProgress","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useEffect","useState","openAiJobs","AiUpsellButton","aiJobProblem","useAiJobRun","BRIEF_MAX_CHARS","AI_AUTOMATION_BRIEF_COPY","title","briefLabel","placeholder","next","submit","started","drafted","review","notListed","failed","AiAutomationBriefDialog","props","open","onClose","orgId","hostId","user","openAction","copy","help","brief","setBrief","setNotListed","run","job","starting","running","notice","reset","draft","status","outputs","find","output","resource","undefined","problem","asking","Boolean","start","trimmed","trim","kind","inputs","mode","id","fullWidth","maxWidth","spacing","sx","pt","label","multiline","minRows","value","onChange","event","target","slice","helperText","length","toLocaleString","disabled","autoFocus","variant","color","href","rel","excerpt","severity","icon","size","aria-label","action","onClick","jobId","fontWeight","note","AiDescribeAutomationButton","entitled","upgrade","data","setOpen","startIcon","path"],"mappings":"AAAA;;AAEA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,cAAc,QAAQ,mCAAkC;AAGjE,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,MAAM,EACNC,gBAAgB,EAChBC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,SAASC,UAAU,QAAQ,qBAAiB;AAC5C,SAASC,cAAc,QAAQ,kCAA8B;AAC7D,SAASC,YAAY,EAAEC,WAAW,QAAQ,sBAAkB;AAE5D;;;;;;;;;CASC,GAED,0CAA0C,GAC1C,MAAMC,kBAAkB;AAExB,OAAO,MAAMC,2BAA2B;IACtCC,OAAO;IACPC,YAAY;IACZC,aACE,0FACA;IACFC,MACE,yFACA;IACFC,QAAQ;IACRC,SACE,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,yBAAW,KAACxG;oBAAQyG,MAAM1G,YAAY0G,IAAI;;gBAC1CV,SAAS,IAAMQ,QAAQ;0BAEtB;;0BAEH,KAACxE;gBACCE,MAAMA;gBACNC,SAAS,IAAMqE,QAAQ;gBACvBpE,OAAOA;gBACPC,QAAQA;gBACRC,MAAMA;gBACNC,YAAYA;;;;AAIpB;AAEA,eAAe6D,2BAA0B"}
|
|
@@ -14,20 +14,32 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import type { ConsoleHostComponentsZoneProps, ConsoleHostLayoutsZoneProps, ConsoleHostScreensZoneProps, ConsoleHostTemplatesZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
|
|
17
|
+
import type { ConsoleHostComponentsZoneProps, ConsoleHostLayoutsZoneProps, ConsoleHostScreensZoneProps, ConsoleHostTemplatesZoneProps, ConsoleWidgetEntitlementProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
|
|
18
18
|
import { type AiBriefKind } from './ai-brief-dialog.component';
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* "Create with AI" (AGL-2907, AGL-3043, AGL-3051): a job from a brief, beside the
|
|
21
|
+
* create actions of the page that lists what the job makes — a page on
|
|
22
|
+
* Screens, a page template on Templates, a layout on Layouts, a form on Forms
|
|
23
|
+
* and a reusable component on Components — each mounted through that page's
|
|
24
|
+
* zone. The Assist panel's AI jobs opens the same dialog for a page.
|
|
25
|
+
*/
|
|
26
|
+
export interface AiDescribeButtonProps extends ConsoleHostScreensZoneProps, ConsoleWidgetEntitlementProps {
|
|
20
27
|
/** The job the brief starts: what the page the button sits on lists. */
|
|
21
28
|
kind: AiBriefKind;
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* Drawn at once, from the gates the shell already resolved client-side before
|
|
32
|
+
* mounting it: the plan, the member's `ai.generate`, the site's AI switch and
|
|
33
|
+
* the `release_ai_generative` flag (the widget's `releaseFlag`). Nothing is
|
|
34
|
+
* asked of a server to draw it (AGL-3601): the start door decides when the
|
|
35
|
+
* brief is sent, and its refusal — a plan, a permission, a lockdown — is said
|
|
36
|
+
* in the dialog, in its own words.
|
|
37
|
+
*
|
|
38
|
+
* On a plan that could buy the AI add-on and has not, the shell mounts it with
|
|
39
|
+
* `entitled={false}` and an `upgrade` link, and the same button opens the
|
|
40
|
+
* add-on's dialog instead of the brief, without asking anything either.
|
|
29
41
|
*/
|
|
30
|
-
export declare function AiDescribeButton({ kind, hostId, orgId }: AiDescribeButtonProps): import("react").JSX.Element;
|
|
42
|
+
export declare function AiDescribeButton({ kind, hostId, orgId, entitled, upgrade, }: AiDescribeButtonProps): import("react").JSX.Element;
|
|
31
43
|
/** A page template from a brief, on the Templates page (`hostTemplates`). */
|
|
32
44
|
export declare function AiDescribeTemplateButton(props: ConsoleHostTemplatesZoneProps): import("react").JSX.Element;
|
|
33
45
|
/** A layout from a brief, on the Layouts page (`hostLayouts`). */
|
|
@@ -3,48 +3,31 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
4
|
import { mdiCreation } from "@aglyn/shared-data-mdi";
|
|
5
5
|
import { MdiIcon } from "@aglyn/shared-ui-jsx";
|
|
6
|
-
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
7
6
|
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
8
7
|
import { Button } from "@mui/material";
|
|
9
|
-
import {
|
|
8
|
+
import { useState } from "react";
|
|
10
9
|
import { AiBriefDialog } from "./ai-brief-dialog.component.js";
|
|
10
|
+
import { AiUpsellButton } from "./ai-upsell-dialog.component.js";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
* Drawn at once, from the gates the shell already resolved client-side before
|
|
13
|
+
* mounting it: the plan, the member's `ai.generate`, the site's AI switch and
|
|
14
|
+
* the `release_ai_generative` flag (the widget's `releaseFlag`). Nothing is
|
|
15
|
+
* asked of a server to draw it (AGL-3601): the start door decides when the
|
|
16
|
+
* brief is sent, and its refusal — a plan, a permission, a lockdown — is said
|
|
17
|
+
* in the dialog, in its own words.
|
|
18
|
+
*
|
|
19
|
+
* On a plan that could buy the AI add-on and has not, the shell mounts it with
|
|
20
|
+
* `entitled={false}` and an `upgrade` link, and the same button opens the
|
|
21
|
+
* add-on's dialog instead of the brief, without asking anything either.
|
|
22
|
+
*/ export function AiDescribeButton({ kind, hostId, orgId, entitled, upgrade }) {
|
|
19
23
|
const { data: user } = useUser();
|
|
20
|
-
// Held in a ref so the probe keys on WHO is signed in, never on the
|
|
21
|
-
// identity of the object that says so.
|
|
22
|
-
const userRef = useRef(user);
|
|
23
|
-
userRef.current = user;
|
|
24
|
-
const uid = (_ref = user == null ? void 0 : user.uid) != null ? _ref : null;
|
|
25
|
-
const [verdict, setVerdict] = useState('checking');
|
|
26
24
|
const [open, setOpen] = useState(false);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (active) {
|
|
34
|
-
setVerdict(response.status === 404 || response.status === 403 ? 'hidden' : 'ready');
|
|
35
|
-
}
|
|
36
|
-
} catch (unused) {
|
|
37
|
-
if (active) setVerdict('hidden');
|
|
38
|
-
}
|
|
39
|
-
})();
|
|
40
|
-
return ()=>{
|
|
41
|
-
active = false;
|
|
42
|
-
};
|
|
43
|
-
}, [
|
|
44
|
-
orgId,
|
|
45
|
-
uid
|
|
46
|
-
]);
|
|
47
|
-
if (verdict !== 'ready') return null;
|
|
25
|
+
if (entitled === false) {
|
|
26
|
+
return upgrade ? /*#__PURE__*/ _jsx(AiUpsellButton, {
|
|
27
|
+
kind: kind,
|
|
28
|
+
upgrade: upgrade
|
|
29
|
+
}) : null;
|
|
30
|
+
}
|
|
48
31
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
49
32
|
children: [
|
|
50
33
|
/*#__PURE__*/ _jsx(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-describe-button.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConsoleHostComponentsZoneProps,\n ConsoleHostLayoutsZoneProps,\n ConsoleHostScreensZoneProps,\n ConsoleHostTemplatesZoneProps,\n} from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-describe-button.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConsoleHostComponentsZoneProps,\n ConsoleHostLayoutsZoneProps,\n ConsoleHostScreensZoneProps,\n ConsoleHostTemplatesZoneProps,\n ConsoleWidgetEntitlementProps,\n} from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { Button } from '@mui/material'\nimport { useState } from 'react'\nimport { AiBriefDialog, type AiBriefKind } from './ai-brief-dialog.component'\nimport { AiUpsellButton } from './ai-upsell-dialog.component'\n\n/**\n * \"Create with AI\" (AGL-2907, AGL-3043, AGL-3051): a job from a brief, beside the\n * create actions of the page that lists what the job makes — a page on\n * Screens, a page template on Templates, a layout on Layouts, a form on Forms\n * and a reusable component on Components — each mounted through that page's\n * zone. The Assist panel's AI jobs opens the same dialog for a page.\n */\n\nexport interface AiDescribeButtonProps\n extends ConsoleHostScreensZoneProps,\n ConsoleWidgetEntitlementProps {\n /** The job the brief starts: what the page the button sits on lists. */\n kind: AiBriefKind\n}\n\n/**\n * Drawn at once, from the gates the shell already resolved client-side before\n * mounting it: the plan, the member's `ai.generate`, the site's AI switch and\n * the `release_ai_generative` flag (the widget's `releaseFlag`). Nothing is\n * asked of a server to draw it (AGL-3601): the start door decides when the\n * brief is sent, and its refusal — a plan, a permission, a lockdown — is said\n * in the dialog, in its own words.\n *\n * On a plan that could buy the AI add-on and has not, the shell mounts it with\n * `entitled={false}` and an `upgrade` link, and the same button opens the\n * add-on's dialog instead of the brief, without asking anything either.\n */\nexport function AiDescribeButton({\n kind,\n hostId,\n orgId,\n entitled,\n upgrade,\n}: AiDescribeButtonProps) {\n const { data: user } = useUser()\n const [open, setOpen] = useState(false)\n\n if (entitled === false) {\n return upgrade ? <AiUpsellButton kind={kind} upgrade={upgrade} /> : null\n }\n return (\n <>\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {'Create with AI'}\n </Button>\n <AiBriefDialog\n kind={kind}\n open={open}\n onClose={() => setOpen(false)}\n orgId={orgId}\n hostId={hostId}\n user={user}\n />\n </>\n )\n}\n\n/** A page template from a brief, on the Templates page (`hostTemplates`). */\nexport function AiDescribeTemplateButton(props: ConsoleHostTemplatesZoneProps) {\n return <AiDescribeButton {...props} kind=\"template\" />\n}\n\n/** A layout from a brief, on the Layouts page (`hostLayouts`). */\nexport function AiDescribeLayoutButton(props: ConsoleHostLayoutsZoneProps) {\n return <AiDescribeButton {...props} kind=\"layout\" />\n}\n\n/**\n * A form from a brief, on the Forms page (`hostForms`, which the forms plugin\n * hosts on the `hostScreens` contract).\n */\nexport function AiDescribeFormButton(props: ConsoleHostScreensZoneProps) {\n return <AiDescribeButton {...props} kind=\"form\" />\n}\n\n/** A reusable component from a brief, on the Components page (`hostComponents`). */\nexport function AiDescribeComponentButton(props: ConsoleHostComponentsZoneProps) {\n return <AiDescribeButton {...props} kind=\"component\" />\n}\n\nexport default AiDescribeButton\n"],"names":["mdiCreation","MdiIcon","useUser","Button","useState","AiBriefDialog","AiUpsellButton","AiDescribeButton","kind","hostId","orgId","entitled","upgrade","data","user","open","setOpen","size","variant","startIcon","path","onClick","onClose","AiDescribeTemplateButton","props","AiDescribeLayoutButton","AiDescribeFormButton","AiDescribeComponentButton"],"mappings":"AAAA;;;AA0BA,SAASA,WAAW,QAAQ,yBAAwB;AACpD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SAASC,MAAM,QAAQ,gBAAe;AACtC,SAASC,QAAQ,QAAQ,QAAO;AAChC,SAASC,aAAa,QAA0B,iCAA6B;AAC7E,SAASC,cAAc,QAAQ,kCAA8B;AAiB7D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,iBAAiB,EAC/BC,IAAI,EACJC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,OAAO,EACe;IACtB,MAAM,EAAEC,MAAMC,IAAI,EAAE,GAAGZ;IACvB,MAAM,CAACa,MAAMC,QAAQ,GAAGZ,SAAS;IAEjC,IAAIO,aAAa,OAAO;QACtB,OAAOC,wBAAU,KAACN;YAAeE,MAAMA;YAAMI,SAASA;aAAc;IACtE;IACA,qBACE;;0BACE,KAACT;gBACCc,MAAK;gBACLC,SAAQ;gBACRC,yBAAW,KAAClB;oBAAQmB,MAAMpB,YAAYoB,IAAI;;gBAC1CC,SAAS,IAAML,QAAQ;0BAEtB;;0BAEH,KAACX;gBACCG,MAAMA;gBACNO,MAAMA;gBACNO,SAAS,IAAMN,QAAQ;gBACvBN,OAAOA;gBACPD,QAAQA;gBACRK,MAAMA;;;;AAId;AAEA,2EAA2E,GAC3E,OAAO,SAASS,yBAAyBC,KAAoC;IAC3E,qBAAO,KAACjB,+BAAqBiB;QAAOhB,MAAK;;AAC3C;AAEA,gEAAgE,GAChE,OAAO,SAASiB,uBAAuBD,KAAkC;IACvE,qBAAO,KAACjB,+BAAqBiB;QAAOhB,MAAK;;AAC3C;AAEA;;;CAGC,GACD,OAAO,SAASkB,qBAAqBF,KAAkC;IACrE,qBAAO,KAACjB,+BAAqBiB;QAAOhB,MAAK;;AAC3C;AAEA,kFAAkF,GAClF,OAAO,SAASmB,0BAA0BH,KAAqC;IAC7E,qBAAO,KAACjB,+BAAqBiB;QAAOhB,MAAK;;AAC3C;AAEA,eAAeD,iBAAgB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { ConsoleHostScreensZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
|
|
18
|
+
/**
|
|
19
|
+
* "Create with AI" for email (AGL-3596): the same button and dialog as a
|
|
20
|
+
* page's, a form's or a template's, beside New template on the email
|
|
21
|
+
* plugin's `hostEmailTemplates` zone (the `hostScreens` contract: the site
|
|
22
|
+
* and its org). The Campaigns section's door is a widget of its own
|
|
23
|
+
* (`ai-campaign-create.component`), on the marketing plugin's `hostCampaigns`.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* An email design from a brief, on a site's email templates
|
|
27
|
+
* (`hostEmailTemplates`). Its dialog also offers to draft the campaign that
|
|
28
|
+
* would send it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function AiDescribeEmailButton(props: ConsoleHostScreensZoneProps): import("react").JSX.Element;
|
|
31
|
+
export default AiDescribeEmailButton;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { AiDescribeButton } from "./ai-describe-button.component.js";
|
|
5
|
+
/**
|
|
6
|
+
* "Create with AI" for email (AGL-3596): the same button and dialog as a
|
|
7
|
+
* page's, a form's or a template's, beside New template on the email
|
|
8
|
+
* plugin's `hostEmailTemplates` zone (the `hostScreens` contract: the site
|
|
9
|
+
* and its org). The Campaigns section's door is a widget of its own
|
|
10
|
+
* (`ai-campaign-create.component`), on the marketing plugin's `hostCampaigns`.
|
|
11
|
+
*/ /**
|
|
12
|
+
* An email design from a brief, on a site's email templates
|
|
13
|
+
* (`hostEmailTemplates`). Its dialog also offers to draft the campaign that
|
|
14
|
+
* would send it.
|
|
15
|
+
*/ export function AiDescribeEmailButton(props) {
|
|
16
|
+
return /*#__PURE__*/ _jsx(AiDescribeButton, _extends({}, props, {
|
|
17
|
+
kind: "email"
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
export default AiDescribeEmailButton;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=ai-describe-email.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-describe-email.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleHostScreensZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AiDescribeButton } from './ai-describe-button.component'\n\n/**\n * \"Create with AI\" for email (AGL-3596): the same button and dialog as a\n * page's, a form's or a template's, beside New template on the email\n * plugin's `hostEmailTemplates` zone (the `hostScreens` contract: the site\n * and its org). The Campaigns section's door is a widget of its own\n * (`ai-campaign-create.component`), on the marketing plugin's `hostCampaigns`.\n */\n\n/**\n * An email design from a brief, on a site's email templates\n * (`hostEmailTemplates`). Its dialog also offers to draft the campaign that\n * would send it.\n */\nexport function AiDescribeEmailButton(props: ConsoleHostScreensZoneProps) {\n return <AiDescribeButton {...props} kind=\"email\" />\n}\n\nexport default AiDescribeEmailButton\n"],"names":["AiDescribeButton","AiDescribeEmailButton","props","kind"],"mappings":"AAAA;;;AAoBA,SAASA,gBAAgB,QAAQ,oCAAgC;AAEjE;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,SAASC,sBAAsBC,KAAkC;IACtE,qBAAO,KAACF,+BAAqBE;QAAOC,MAAK;;AAC3C;AAEA,eAAeF,sBAAqB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { ConsoleWidgetEntitlementProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
|
|
18
|
+
import type { ConsoleOrgAutomationsZoneProps } from './ai-automation-zones';
|
|
19
|
+
export declare const AI_ORG_AUTOMATION_COPY: {
|
|
20
|
+
readonly create: "Create with AI";
|
|
21
|
+
readonly title: "Describe an org automation";
|
|
22
|
+
readonly label: "What should happen, and when?";
|
|
23
|
+
readonly placeholder: "When someone books on any of our sites, make them a contact, tag them booked and send them a welcome email";
|
|
24
|
+
readonly next: "It is drafted from what an org automation can start on and do, and opens in the editor switched off, where you choose its sites and save it. Lists, campaigns or datasets your workspace does not have are left for you to pick.";
|
|
25
|
+
readonly submit: "Draft the automation";
|
|
26
|
+
readonly running: "Drafting it. This can take a few minutes.";
|
|
27
|
+
readonly ready: "Drafted";
|
|
28
|
+
readonly open: "Open in the editor";
|
|
29
|
+
readonly notOpened: "It could not be opened in the editor. Check the page for why, then try again.";
|
|
30
|
+
readonly failed: "The automation could not be drafted. Try again.";
|
|
31
|
+
};
|
|
32
|
+
export declare function AiDescribeOrgAutomationButton({ orgId, triggers, steps, propose, entitled, upgrade, }: ConsoleOrgAutomationsZoneProps & ConsoleWidgetEntitlementProps): import("react").JSX.Element;
|
|
33
|
+
export declare namespace AiDescribeOrgAutomationButton {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
export default AiDescribeOrgAutomationButton;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { pluginDocsHelp } from "@aglyn/aglyn/app-utils/docs-help";
|
|
4
|
+
import { mdiCreation } from "@aglyn/shared-data-mdi";
|
|
5
|
+
import { MdiIcon } from "@aglyn/shared-ui-jsx";
|
|
6
|
+
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
7
|
+
import { Alert, Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Link, Stack, TextField, Typography } from "@mui/material";
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
import { AI_ORG_AUTOMATION_RESOURCE, aiOrgAutomationInputs, readAiOrgAutomationProposal } from "../model/ai-workflow-job.js";
|
|
10
|
+
import { openAiJobs } from "./ai-jobs-store.js";
|
|
11
|
+
import { AiUpsellButton } from "./ai-upsell-dialog.component.js";
|
|
12
|
+
import { aiJobProblem, useAiJobRun } from "./use-ai-job-run.js";
|
|
13
|
+
/**
|
|
14
|
+
* "Create with AI" on the workspace's Org automations (AGL-3603), in that
|
|
15
|
+
* section's card header through the `orgAutomations` zone: a description
|
|
16
|
+
* becomes a `workflow` job drafting one of the WORKSPACE's automations, held
|
|
17
|
+
* to the triggers and steps the zone says an org automation may use.
|
|
18
|
+
*
|
|
19
|
+
* Nothing is written. The job's proposal opens in the section's editor as a
|
|
20
|
+
* new automation, unsaved and switched off; the person picks the sites it
|
|
21
|
+
* runs on and saves it with the editor's own Save, through the section's
|
|
22
|
+
* route — or closes the editor, and nothing changes.
|
|
23
|
+
*/ const BRIEF_MAX_CHARS = 4000;
|
|
24
|
+
export const AI_ORG_AUTOMATION_COPY = {
|
|
25
|
+
create: 'Create with AI',
|
|
26
|
+
title: 'Describe an org automation',
|
|
27
|
+
label: 'What should happen, and when?',
|
|
28
|
+
placeholder: 'When someone books on any of our sites, make them a contact, tag them booked and send them a welcome email',
|
|
29
|
+
next: 'It is drafted from what an org automation can start on and do, and opens in the editor switched off, where you choose its sites and save it. Lists, campaigns or datasets your workspace does not have are left for you to pick.',
|
|
30
|
+
submit: 'Draft the automation',
|
|
31
|
+
running: 'Drafting it. This can take a few minutes.',
|
|
32
|
+
ready: 'Drafted',
|
|
33
|
+
open: 'Open in the editor',
|
|
34
|
+
notOpened: 'It could not be opened in the editor. Check the page for why, then try again.',
|
|
35
|
+
failed: 'The automation could not be drafted. Try again.'
|
|
36
|
+
};
|
|
37
|
+
/** The proposal a finished job wrote, with what to decide, or `null`. */ function proposalOf(job) {
|
|
38
|
+
var _output_note;
|
|
39
|
+
if ((job == null ? void 0 : job.status) !== 'done') return null;
|
|
40
|
+
const output = job.outputs.find((one)=>one.resource === AI_ORG_AUTOMATION_RESOURCE);
|
|
41
|
+
const automation = readAiOrgAutomationProposal(output == null ? void 0 : output.proposal);
|
|
42
|
+
return automation && output ? {
|
|
43
|
+
automation,
|
|
44
|
+
label: output.label,
|
|
45
|
+
note: (_output_note = output.note) != null ? _output_note : null
|
|
46
|
+
} : null;
|
|
47
|
+
}
|
|
48
|
+
export function AiDescribeOrgAutomationButton({ orgId, triggers, steps, propose, entitled, upgrade }) {
|
|
49
|
+
var _aiJobProblem;
|
|
50
|
+
const copy = AI_ORG_AUTOMATION_COPY;
|
|
51
|
+
const help = pluginDocsHelp('aiAutomations', {
|
|
52
|
+
anchor: '#org-automations'
|
|
53
|
+
});
|
|
54
|
+
const { data: user } = useUser();
|
|
55
|
+
const run = useAiJobRun(user, copy.failed);
|
|
56
|
+
const { job, starting, running, notice, reset } = run;
|
|
57
|
+
const [open, setOpen] = useState(false);
|
|
58
|
+
const [brief, setBrief] = useState('');
|
|
59
|
+
const [notOpened, setNotOpened] = useState(false);
|
|
60
|
+
// Opening or closing starts over and stops following: a job still drafting
|
|
61
|
+
// carries on in AI jobs.
|
|
62
|
+
useEffect(()=>{
|
|
63
|
+
reset();
|
|
64
|
+
setNotOpened(false);
|
|
65
|
+
}, [
|
|
66
|
+
open,
|
|
67
|
+
reset
|
|
68
|
+
]);
|
|
69
|
+
// Drawn from the shell's gates alone (AGL-3601): nothing asks a server
|
|
70
|
+
// until it is used, and a plan without the add-on gets the add-on's dialog.
|
|
71
|
+
if (entitled === false) return upgrade ? /*#__PURE__*/ _jsx(AiUpsellButton, {
|
|
72
|
+
kind: "workflow",
|
|
73
|
+
upgrade: upgrade
|
|
74
|
+
}) : null;
|
|
75
|
+
const ready = proposalOf(job);
|
|
76
|
+
const problem = (_aiJobProblem = aiJobProblem(job, copy.failed)) != null ? _aiJobProblem : (job == null ? void 0 : job.status) === 'done' && !ready ? copy.failed : null;
|
|
77
|
+
const asking = !job || Boolean(notice);
|
|
78
|
+
const close = ()=>setOpen(false);
|
|
79
|
+
const start = async ()=>{
|
|
80
|
+
const trimmed = brief.trim();
|
|
81
|
+
if (!orgId || !trimmed) return;
|
|
82
|
+
setNotOpened(false);
|
|
83
|
+
const inputs = aiOrgAutomationInputs({
|
|
84
|
+
triggers,
|
|
85
|
+
steps
|
|
86
|
+
});
|
|
87
|
+
if (await run.start({
|
|
88
|
+
orgId,
|
|
89
|
+
hostId: null,
|
|
90
|
+
kind: 'workflow',
|
|
91
|
+
brief: trimmed,
|
|
92
|
+
inputs
|
|
93
|
+
})) setBrief('');
|
|
94
|
+
};
|
|
95
|
+
const apply = ()=>{
|
|
96
|
+
if (!ready) return;
|
|
97
|
+
if (propose(ready.automation)) close();
|
|
98
|
+
else setNotOpened(true);
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
101
|
+
children: [
|
|
102
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
103
|
+
size: "small",
|
|
104
|
+
variant: "outlined",
|
|
105
|
+
startIcon: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
106
|
+
path: mdiCreation.path
|
|
107
|
+
}),
|
|
108
|
+
onClick: ()=>setOpen(true),
|
|
109
|
+
children: copy.create
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ _jsxs(Dialog, {
|
|
112
|
+
open: open,
|
|
113
|
+
onClose: starting ? undefined : close,
|
|
114
|
+
fullWidth: true,
|
|
115
|
+
maxWidth: "sm",
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
118
|
+
children: copy.title
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
121
|
+
children: asking ? /*#__PURE__*/ _jsxs(Stack, {
|
|
122
|
+
spacing: 2,
|
|
123
|
+
sx: {
|
|
124
|
+
pt: 1
|
|
125
|
+
},
|
|
126
|
+
children: [
|
|
127
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
128
|
+
label: copy.label,
|
|
129
|
+
placeholder: copy.placeholder,
|
|
130
|
+
multiline: true,
|
|
131
|
+
minRows: 4,
|
|
132
|
+
value: brief,
|
|
133
|
+
onChange: (event)=>setBrief(event.target.value.slice(0, BRIEF_MAX_CHARS)),
|
|
134
|
+
helperText: `${brief.length.toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`,
|
|
135
|
+
disabled: starting,
|
|
136
|
+
autoFocus: true
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
139
|
+
variant: "body2",
|
|
140
|
+
color: "text.secondary",
|
|
141
|
+
children: [
|
|
142
|
+
copy.next,
|
|
143
|
+
' ',
|
|
144
|
+
/*#__PURE__*/ _jsx(Link, {
|
|
145
|
+
href: help.href,
|
|
146
|
+
target: "_blank",
|
|
147
|
+
rel: "noopener",
|
|
148
|
+
title: help.excerpt,
|
|
149
|
+
children: 'How it works'
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
}),
|
|
153
|
+
notice ? /*#__PURE__*/ _jsx(Alert, {
|
|
154
|
+
severity: "warning",
|
|
155
|
+
children: notice
|
|
156
|
+
}) : null
|
|
157
|
+
]
|
|
158
|
+
}) : /*#__PURE__*/ _jsxs(Stack, {
|
|
159
|
+
spacing: 2,
|
|
160
|
+
sx: {
|
|
161
|
+
pt: 1
|
|
162
|
+
},
|
|
163
|
+
children: [
|
|
164
|
+
running && job ? /*#__PURE__*/ _jsx(Alert, {
|
|
165
|
+
severity: "info",
|
|
166
|
+
icon: /*#__PURE__*/ _jsx(CircularProgress, {
|
|
167
|
+
size: 18,
|
|
168
|
+
"aria-label": "Drafting"
|
|
169
|
+
}),
|
|
170
|
+
action: /*#__PURE__*/ _jsx(Button, {
|
|
171
|
+
color: "inherit",
|
|
172
|
+
size: "small",
|
|
173
|
+
variant: "outlined",
|
|
174
|
+
onClick: ()=>{
|
|
175
|
+
openAiJobs({
|
|
176
|
+
jobId: job.id
|
|
177
|
+
});
|
|
178
|
+
close();
|
|
179
|
+
},
|
|
180
|
+
children: 'Open AI jobs'
|
|
181
|
+
}),
|
|
182
|
+
children: copy.running
|
|
183
|
+
}) : null,
|
|
184
|
+
ready ? /*#__PURE__*/ _jsxs(Alert, {
|
|
185
|
+
severity: "success",
|
|
186
|
+
children: [
|
|
187
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
188
|
+
variant: "body2",
|
|
189
|
+
sx: {
|
|
190
|
+
fontWeight: 600
|
|
191
|
+
},
|
|
192
|
+
children: `${copy.ready}: ${ready.label}`
|
|
193
|
+
}),
|
|
194
|
+
ready.note ? /*#__PURE__*/ _jsx(Typography, {
|
|
195
|
+
variant: "body2",
|
|
196
|
+
children: ready.note
|
|
197
|
+
}) : null
|
|
198
|
+
]
|
|
199
|
+
}) : null,
|
|
200
|
+
problem ? /*#__PURE__*/ _jsx(Alert, {
|
|
201
|
+
severity: (job == null ? void 0 : job.status) === 'failed' ? 'error' : 'warning',
|
|
202
|
+
children: problem
|
|
203
|
+
}) : null,
|
|
204
|
+
notOpened ? /*#__PURE__*/ _jsx(Alert, {
|
|
205
|
+
severity: "warning",
|
|
206
|
+
children: copy.notOpened
|
|
207
|
+
}) : null
|
|
208
|
+
]
|
|
209
|
+
})
|
|
210
|
+
}),
|
|
211
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
212
|
+
children: [
|
|
213
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
214
|
+
onClick: close,
|
|
215
|
+
disabled: starting,
|
|
216
|
+
children: asking ? 'Cancel' : 'Close'
|
|
217
|
+
}),
|
|
218
|
+
asking ? /*#__PURE__*/ _jsx(Button, {
|
|
219
|
+
variant: "contained",
|
|
220
|
+
onClick: ()=>void start(),
|
|
221
|
+
disabled: starting || !orgId || !brief.trim(),
|
|
222
|
+
children: copy.submit
|
|
223
|
+
}) : ready ? /*#__PURE__*/ _jsx(Button, {
|
|
224
|
+
variant: "contained",
|
|
225
|
+
onClick: apply,
|
|
226
|
+
children: copy.open
|
|
227
|
+
}) : null
|
|
228
|
+
]
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
AiDescribeOrgAutomationButton.displayName = 'AiDescribeOrgAutomationButton';
|
|
236
|
+
export default AiDescribeOrgAutomationButton;
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=ai-describe-org-automation.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-describe-org-automation.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleWidgetEntitlementProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_ORG_AUTOMATION_RESOURCE,\n aiOrgAutomationInputs,\n readAiOrgAutomationProposal,\n type AiOrgAutomationProposal,\n} from '../model/ai-workflow-job'\nimport type { ConsoleOrgAutomationsZoneProps } from './ai-automation-zones'\nimport { openAiJobs } from './ai-jobs-store'\nimport { AiUpsellButton } from './ai-upsell-dialog.component'\nimport { aiJobProblem, useAiJobRun } from './use-ai-job-run'\n\n/**\n * \"Create with AI\" on the workspace's Org automations (AGL-3603), in that\n * section's card header through the `orgAutomations` zone: a description\n * becomes a `workflow` job drafting one of the WORKSPACE's automations, held\n * to the triggers and steps the zone says an org automation may use.\n *\n * Nothing is written. The job's proposal opens in the section's editor as a\n * new automation, unsaved and switched off; the person picks the sites it\n * runs on and saves it with the editor's own Save, through the section's\n * route — or closes the editor, and nothing changes.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\nexport const AI_ORG_AUTOMATION_COPY = {\n create: 'Create with AI',\n title: 'Describe an org automation',\n label: 'What should happen, and when?',\n placeholder:\n 'When someone books on any of our sites, make them a contact, tag them booked and send them a welcome email',\n next:\n 'It is drafted from what an org automation can start on and do, and opens in the editor switched off, where you choose its sites and save it. Lists, campaigns or datasets your workspace does not have are left for you to pick.',\n submit: 'Draft the automation',\n running: 'Drafting it. This can take a few minutes.',\n ready: 'Drafted',\n open: 'Open in the editor',\n notOpened: 'It could not be opened in the editor. Check the page for why, then try again.',\n failed: 'The automation could not be drafted. Try again.',\n} as const\n\n/** The proposal a finished job wrote, with what to decide, or `null`. */\nfunction proposalOf(job: AiJobSummary | null): { automation: AiOrgAutomationProposal; label: string; note: string | null } | null {\n if (job?.status !== 'done') return null\n const output = job.outputs.find((one) => one.resource === AI_ORG_AUTOMATION_RESOURCE)\n const automation = readAiOrgAutomationProposal(output?.proposal)\n return automation && output ? { automation, label: output.label, note: output.note ?? null } : null\n}\n\nexport function AiDescribeOrgAutomationButton({\n orgId,\n triggers,\n steps,\n propose,\n entitled,\n upgrade,\n}: ConsoleOrgAutomationsZoneProps & ConsoleWidgetEntitlementProps) {\n const copy = AI_ORG_AUTOMATION_COPY\n const help = pluginDocsHelp('aiAutomations', { anchor: '#org-automations' })\n const { data: user } = useUser()\n const run = useAiJobRun(user, copy.failed)\n const { job, starting, running, notice, reset } = run\n const [open, setOpen] = useState(false)\n const [brief, setBrief] = useState('')\n const [notOpened, setNotOpened] = useState(false)\n\n // Opening or closing starts over and stops following: a job still drafting\n // carries on in AI jobs.\n useEffect(() => {\n reset()\n setNotOpened(false)\n }, [open, reset])\n\n // Drawn from the shell's gates alone (AGL-3601): nothing asks a server\n // until it is used, and a plan without the add-on gets the add-on's dialog.\n if (entitled === false) return upgrade ? <AiUpsellButton kind=\"workflow\" upgrade={upgrade} /> : null\n const ready = proposalOf(job)\n const problem = aiJobProblem(job, copy.failed) ?? (job?.status === 'done' && !ready ? copy.failed : null)\n const asking = !job || Boolean(notice)\n const close = () => setOpen(false)\n\n const start = async () => {\n const trimmed = brief.trim()\n if (!orgId || !trimmed) return\n setNotOpened(false)\n const inputs = aiOrgAutomationInputs({ triggers, steps })\n if (await run.start({ orgId, hostId: null, kind: 'workflow', brief: trimmed, inputs })) setBrief('')\n }\n const apply = () => {\n if (!ready) return\n if (propose(ready.automation)) close()\n else setNotOpened(true)\n }\n\n return (\n <>\n <Button size=\"small\" variant=\"outlined\" startIcon={<MdiIcon path={mdiCreation.path} />} onClick={() => setOpen(true)}>\n {copy.create}\n </Button>\n <Dialog open={open} onClose={starting ? undefined : close} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy.title}</DialogTitle>\n <DialogContent>\n {asking ? (\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy.label}\n placeholder={copy.placeholder}\n multiline\n minRows={4}\n value={brief}\n onChange={(event) => setBrief(event.target.value.slice(0, BRIEF_MAX_CHARS))}\n helperText={`${brief.length.toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={starting}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy.next}{' '}\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Typography>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n ) : (\n <Stack spacing={2} sx={{ pt: 1 }}>\n {running && job ? (\n <Alert\n severity=\"info\"\n icon={<CircularProgress size={18} aria-label=\"Drafting\" />}\n action={\n <Button\n color=\"inherit\"\n size=\"small\"\n variant=\"outlined\"\n onClick={() => {\n openAiJobs({ jobId: job.id })\n close()\n }}\n >\n {'Open AI jobs'}\n </Button>\n }\n >\n {copy.running}\n </Alert>\n ) : null}\n {ready ? (\n <Alert severity=\"success\">\n <Typography variant=\"body2\" sx={{ fontWeight: 600 }}>\n {`${copy.ready}: ${ready.label}`}\n </Typography>\n {ready.note ? <Typography variant=\"body2\">{ready.note}</Typography> : null}\n </Alert>\n ) : null}\n {problem ? <Alert severity={job?.status === 'failed' ? 'error' : 'warning'}>{problem}</Alert> : null}\n {notOpened ? <Alert severity=\"warning\">{copy.notOpened}</Alert> : null}\n </Stack>\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={close} disabled={starting}>\n {asking ? 'Cancel' : 'Close'}\n </Button>\n {asking ? (\n <Button variant=\"contained\" onClick={() => void start()} disabled={starting || !orgId || !brief.trim()}>\n {copy.submit}\n </Button>\n ) : ready ? (\n <Button variant=\"contained\" onClick={apply}>\n {copy.open}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n </>\n )\n}\nAiDescribeOrgAutomationButton.displayName = 'AiDescribeOrgAutomationButton'\n\nexport default AiDescribeOrgAutomationButton\n"],"names":["pluginDocsHelp","mdiCreation","MdiIcon","useUser","Alert","Button","CircularProgress","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useEffect","useState","AI_ORG_AUTOMATION_RESOURCE","aiOrgAutomationInputs","readAiOrgAutomationProposal","openAiJobs","AiUpsellButton","aiJobProblem","useAiJobRun","BRIEF_MAX_CHARS","AI_ORG_AUTOMATION_COPY","create","title","label","placeholder","next","submit","running","ready","open","notOpened","failed","proposalOf","job","output","status","outputs","find","one","resource","automation","proposal","note","AiDescribeOrgAutomationButton","orgId","triggers","steps","propose","entitled","upgrade","copy","help","anchor","data","user","run","starting","notice","reset","setOpen","brief","setBrief","setNotOpened","kind","problem","asking","Boolean","close","start","trimmed","trim","inputs","hostId","apply","size","variant","startIcon","path","onClick","onClose","undefined","fullWidth","maxWidth","spacing","sx","pt","multiline","minRows","value","onChange","event","target","slice","helperText","length","toLocaleString","disabled","autoFocus","color","href","rel","excerpt","severity","icon","aria-label","action","jobId","id","fontWeight","displayName"],"mappings":"AAAA;;AAoBA,SAASA,cAAc,QAAQ,mCAAkC;AACjE,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,MAAM,EACNC,gBAAgB,EAChBC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,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