@nocobase/portal-template-default 1.0.16 → 1.0.17
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/AGENTS.md +8 -0
- package/README.MD +4 -0
- package/dist/assets/{LineDraw-vPRTWiQ5.js → LineDraw-BBB5hwuJ.js} +1 -1
- package/dist/assets/{SymbolDraw-DOl_Tss3.js → SymbolDraw-CKS3uUb_.js} +1 -1
- package/dist/assets/{VisualMapping-j08W3KBm.js → VisualMapping-BCwaW3TD.js} +1 -1
- package/dist/assets/auth-method-demo-BdCCvEEz.js +1 -0
- package/dist/assets/{auto-login-provider-Bukw7zEe.js → auto-login-provider-DO5Il6Dp.js} +2 -2
- package/dist/assets/auto-login-provider-TQ08B6-i.js +1 -0
- package/dist/assets/auto-redirect-provider-ButXp0A3.js +1 -0
- package/dist/assets/auto-redirect-provider-DnGGP2Vn.js +1 -0
- package/dist/assets/auto-redirect-provider-ja-vFPaF.js +1 -0
- package/dist/assets/calendar-C7xnRgOT.js +1 -0
- package/dist/assets/{cas-sign-in-button-BQn3Mttx.js → cas-sign-in-button-BZCa4lR6.js} +1 -1
- package/dist/assets/{components-BT5mL9gW.js → components-_g-GjQeV.js} +3 -3
- package/dist/assets/{configuration-gate-BJoadoA6.js → configuration-gate-B4XVz7tS.js} +1 -1
- package/dist/assets/{createClipPathFromCoordSys-m8IbnJ1z.js → createClipPathFromCoordSys-z9Kmh-tu.js} +1 -1
- package/dist/assets/createSeriesDataSimply-CPqysF0K.js +1 -0
- package/dist/assets/{customGraphicKeyframeAnimation-CYLPurwK.js → customGraphicKeyframeAnimation-DMU5crAu.js} +1 -1
- package/dist/assets/demo-BPlae2bp.js +1 -0
- package/dist/assets/demo-Bj_Y0RrW.js +1 -0
- package/dist/assets/demo-CKPAQOib.js +1 -0
- package/dist/assets/demo-CXRTPvIx.js +1 -0
- package/dist/assets/demo-DJuVDu1n.js +1 -0
- package/dist/assets/demo-DUmWU7ik.js +1 -0
- package/dist/assets/demo-NhIzFRE1.js +1 -0
- package/dist/assets/{dingtalk-sign-in-button-DSluFaP9.js → dingtalk-sign-in-button-DMPgE5kT.js} +1 -1
- package/dist/assets/{echarts-preview-mRXoEciY.js → echarts-preview-R96Pbqmz.js} +1 -1
- package/dist/assets/{echarts-runtime-CvLr4Slh.js → echarts-runtime-Ce_z2eX_.js} +3 -3
- package/dist/assets/{echarts-runtime-advanced-BC1tvfQ0.js → echarts-runtime-advanced-Dr80KHJR.js} +1 -1
- package/dist/assets/{echarts-runtime-common-DhNaV5B8.js → echarts-runtime-common-DB95Yfc1.js} +1 -1
- package/dist/assets/{echarts-runtime-components-BiioS8t1.js → echarts-runtime-components-DCJEaTJk.js} +1 -1
- package/dist/assets/{echarts-runtime-hierarchy-CAWqYvFh.js → echarts-runtime-hierarchy-CezgZs9O.js} +1 -1
- package/dist/assets/{floating-RVbHvIiD.js → floating-O9WmiDXk.js} +2 -2
- package/dist/assets/index-BBKV6O5d.css +1 -0
- package/dist/assets/{index-Dw20Lzpp.js → index-CPzehPGe.js} +3 -3
- package/dist/assets/index-Cc6awvdg.js +1064 -0
- package/dist/assets/index-ChA0z9ke.js +38 -0
- package/dist/assets/{index-BysibBZu.js → index-DgB7uTMs.js} +2 -2
- package/dist/assets/{index-C-tdHirk.js → index-DroUAK80.js} +1 -1
- package/dist/assets/index-WKvygTBp.js +59 -0
- package/dist/assets/{labelHelper-DbITmOUW.js → labelHelper-Dk5jkiD-.js} +1 -1
- package/dist/assets/ldap-sign-in-form-CKN4l7qM.js +1 -0
- package/dist/assets/{oidc-sign-in-button-Cgpa8Qzj.js → oidc-sign-in-button-BIRonrpC.js} +1 -1
- package/dist/assets/{page-context-AU6RU0Qi.js → page-context-DAiW_dId.js} +4 -4
- package/dist/assets/prompt-card-rGZqpqkF.js +1 -0
- package/dist/assets/prompt-output-B4h3uLWf.js +1 -0
- package/dist/assets/saml-sign-in-button-B4ugaLIb.js +1 -0
- package/dist/assets/{sectorHelper-C6L782Ue.js → sectorHelper-BuxrrJrA.js} +1 -1
- package/dist/assets/shortcut-BhKXxJLs.js +47 -0
- package/dist/assets/{sms-sign-in-form-Bo2WLZuP.js → sms-sign-in-form-DKpxRDdZ.js} +1 -1
- package/dist/assets/{static.browser-CoPxsICt.js → static.browser-kzzpH0Xt.js} +1 -1
- package/dist/assets/switch-BdVxPIVU.js +1 -0
- package/dist/assets/{tool-cards-ipgJ_3Ec.js → tool-cards-CpczIke-.js} +3 -3
- package/dist/assets/{use-authenticator-sign-in-BzFeh7qe.js → use-authenticator-sign-in-CIj210ry.js} +1 -1
- package/dist/assets/use-dingtalk-sign-in-BW4kkXD3.js +1 -0
- package/dist/assets/{use-wecom-sign-in-PPIMLvGa.js → use-wecom-sign-in-dIqMtcN9.js} +1 -1
- package/dist/assets/{wecom-sign-in-button-rUq9RW8R.js → wecom-sign-in-button-Dn_2zDab.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/index.raw.html +2 -2
- package/package.json +9 -1
- package/src/App.tsx +5 -2
- package/src/app/extension.ts +2 -0
- package/src/app/extensions.tsx +18 -6
- package/src/app/route-access-guard.tsx +22 -0
- package/src/app/route-runtime.ts +173 -0
- package/src/app/routes.tsx +2 -2
- package/src/components/app-shell/header.tsx +56 -1
- package/src/components/app-shell/sidebar.tsx +14 -2
- package/src/extensions/nocobase-acl/README.md +28 -14
- package/src/extensions/nocobase-acl/demo/index.tsx +87 -15
- package/src/extensions/nocobase-acl/demo/prompt-generator.tsx +1 -0
- package/src/extensions/nocobase-mail/README.md +74 -0
- package/src/extensions/nocobase-mail/components/index.ts +79 -0
- package/src/extensions/nocobase-mail/components/mail-api.ts +423 -0
- package/src/extensions/nocobase-mail/components/mail-attachment-list.tsx +67 -0
- package/src/extensions/nocobase-mail/components/mail-compose-attachments.tsx +166 -0
- package/src/extensions/nocobase-mail/components/mail-compose.tsx +1071 -0
- package/src/extensions/nocobase-mail/components/mail-detail.tsx +653 -0
- package/src/extensions/nocobase-mail/components/mail-draft-autosave.ts +26 -0
- package/src/extensions/nocobase-mail/components/mail-empty.tsx +48 -0
- package/src/extensions/nocobase-mail/components/mail-filters.tsx +277 -0
- package/src/extensions/nocobase-mail/components/mail-inbox.tsx +544 -0
- package/src/extensions/nocobase-mail/components/mail-inline-images.ts +69 -0
- package/src/extensions/nocobase-mail/components/mail-label-badge.tsx +25 -0
- package/src/extensions/nocobase-mail/components/mail-label-manager.tsx +271 -0
- package/src/extensions/nocobase-mail/components/mail-labels-editor.tsx +267 -0
- package/src/extensions/nocobase-mail/components/mail-mass-tracking.tsx +271 -0
- package/src/extensions/nocobase-mail/components/mail-note-editor.tsx +99 -0
- package/src/extensions/nocobase-mail/components/mail-recipient-input.tsx +260 -0
- package/src/extensions/nocobase-mail/components/mail-reply-quote.ts +28 -0
- package/src/extensions/nocobase-mail/components/mail-rich-editor.tsx +287 -0
- package/src/extensions/nocobase-mail/components/mail-send-actions.tsx +238 -0
- package/src/extensions/nocobase-mail/components/mail-senders.ts +61 -0
- package/src/extensions/nocobase-mail/components/mail-settings-drawer.tsx +708 -0
- package/src/extensions/nocobase-mail/components/mail-showcase-layout.tsx +64 -0
- package/src/extensions/nocobase-mail/components/mail-signature-manager.tsx +258 -0
- package/src/extensions/nocobase-mail/components/mail-signatures.ts +25 -0
- package/src/extensions/nocobase-mail/components/mail-table.tsx +476 -0
- package/src/extensions/nocobase-mail/components/mail-template-manager.tsx +204 -0
- package/src/extensions/nocobase-mail/components/mail-toolbar.tsx +155 -0
- package/src/extensions/nocobase-mail/components/mail-unread.tsx +111 -0
- package/src/extensions/nocobase-mail/components/types.ts +297 -0
- package/src/extensions/nocobase-mail/components/use-mail-compose.tsx +262 -0
- package/src/extensions/nocobase-mail/components/use-mail-mass-messages.ts +54 -0
- package/src/extensions/nocobase-mail/components/use-mail-messages.ts +113 -0
- package/src/extensions/nocobase-mail/components/use-mail-signatures.ts +122 -0
- package/src/extensions/nocobase-mail/components/use-mail-templates.ts +54 -0
- package/src/extensions/nocobase-mail/extension.tsx +105 -0
- package/src/extensions/nocobase-mail/index.ts +1 -0
- package/src/extensions/nocobase-mail/mail-demo-pages.tsx +503 -0
- package/src/extensions/nocobase-mail/mail-pages.tsx +201 -0
- package/src/extensions/nocobase-mail/tests/mail-quote-html-regression.mjs +51 -0
- package/src/extensions/nocobase-mail/tests/mail-regression.mjs +649 -0
- package/src/extensions/nocobase-users-example/app-routes.tsx +121 -0
- package/src/extensions/nocobase-users-example/extension.tsx +2 -100
- package/src/extensions/nocobase-users-example/index.ts +1 -0
- package/src/lib/nocobase/acl/menu.ts +17 -3
- package/src/lib/nocobase/acl/types.ts +4 -0
- package/src/locales/en-US.ts +2 -1
- package/src/locales/zh-CN.ts +2 -1
- package/src/providers/runtime-config.ts +18 -0
- package/src/routes.tsx +10 -0
- package/src/vite-env.d.ts +3 -0
- package/vite.config.ts +8 -0
- package/dist/assets/auth-method-demo-B2qcpY8z.js +0 -1
- package/dist/assets/auto-login-provider-BMtzvdxG.js +0 -1
- package/dist/assets/auto-redirect-provider-C6GNPg5r.js +0 -1
- package/dist/assets/auto-redirect-provider-D5c6kN2R.js +0 -1
- package/dist/assets/auto-redirect-provider-iTzGEDpU.js +0 -1
- package/dist/assets/calendar-Dv2RNnsr.js +0 -1
- package/dist/assets/card-C9Hpeq1c.js +0 -1
- package/dist/assets/createSeriesDataSimply-DKUV5b5e.js +0 -1
- package/dist/assets/demo-BWGOwqtJ.js +0 -1
- package/dist/assets/demo-BWbcvkya.js +0 -1
- package/dist/assets/demo-DIASSPgn.js +0 -1
- package/dist/assets/demo-DuZ6asUU.js +0 -1
- package/dist/assets/demo-Dxcy4bDE.js +0 -1
- package/dist/assets/demo-YpEC76uw.js +0 -1
- package/dist/assets/demo-wzkoR8T2.js +0 -1
- package/dist/assets/index-CBZbj45X.js +0 -58
- package/dist/assets/index-CgkdZ6Oc.js +0 -686
- package/dist/assets/index-NH3aqqQz.css +0 -1
- package/dist/assets/index-hSBzW-VA.js +0 -43
- package/dist/assets/ldap-sign-in-form-BOMNDTkK.js +0 -1
- package/dist/assets/prompt-card-FWugRgi-.js +0 -1
- package/dist/assets/prompt-output-DMTuTNab.js +0 -1
- package/dist/assets/saml-sign-in-button-qt8bMeoQ.js +0 -1
- package/dist/assets/shortcut-Bu7jT_-w.js +0 -47
- package/dist/assets/switch-DQkkIE7G.js +0 -1
- package/dist/assets/use-dingtalk-sign-in-mrq6K5Yx.js +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{y as S,z as U,j as e,A as E,b as A,D as Q,C as c,p as X,q as Y,t as T,v as w,w as Z,x as v,E as ee,F as se,k as u,l as h,m as P,n as p,o as D,I as k,T as te,B as F,G as re,a as ne,H as ae,R as ie,U as M,J as y,K as m,P as oe,M as le,N as de,O as ce,Q as me,V as ue}from"./index-Cc6awvdg.js";import{P as he}from"./prompt-output-B4h3uLWf.js";/**
|
|
2
|
+
* @license lucide-react v0.487.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const pe=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]],_=S("layout-panel-top",pe);/**
|
|
7
|
+
* @license lucide-react v0.487.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const xe=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],G=S("lock-keyhole",xe);/**
|
|
12
|
+
* @license lucide-react v0.487.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const fe=[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]],ge=S("user-round-cog",fe),B=s=>({resource:s.resource,action:s.action,id:s.id,field:s.field,dataSourceKey:s.dataSourceKey});function je({children:s,anyOf:t,allOf:r,roles:a,fallback:n=e.jsx(E,{})}){const i=U(),o=!(t!=null&&t.length)||t.some(f=>i(B(f))),x=!(r!=null&&r.length)||r.every(f=>i(B(f)));return i({roles:a})&&o&&x?s:n}function L({children:s,resource:t,action:r,id:a,dataSourceKey:n,fallback:i="hidden"}){return U()({resource:t,action:r,id:a,dataSourceKey:n})?s:i==="hidden"?null:i==="forbidden"?e.jsx(E,{className:"min-h-40"}):i}function C({children:s,resource:t,action:r,field:a,dataSourceKey:n,fallback:i=null}){return U()({resource:t,action:r,field:a,dataSourceKey:n})?s:i}function d({children:s,roles:t,permissions:r={},recordPermissions:a=[]}){const n=A.useMemo(()=>{const i=Array.from(new Set(Object.keys(r).map(l=>l.slice(0,l.lastIndexOf(":"))))),o={status:"ready",permissions:{currentRole:t.length>1?"__union__":t[0],roles:t,roleMode:t.length>1?"allow-use-union":"default",resources:i,actions:r,actionAlias:{list:"list",get:"get",create:"create",update:"update",destroy:"destroy"},snippets:[]}},x=new Map(a.map(l=>[`${l.dataSourceKey??"main"}:${l.resource}:${l.action}:${l.id}`,l.allowed]));return{getState:()=>o,subscribe:()=>()=>{},load:async()=>o,retry:async()=>o,clear:()=>{},recordPermissions:{getState:()=>x,subscribe:()=>()=>{},getPermission:({dataSourceKey:l="main",resource:f,action:H,id:J})=>x.get(`${l}:${f}:${H}:${J}`)}}},[r,a,t]);return e.jsx(Q,{store:n,children:s})}const be=[["roles","RoleConstraint","undefined","Checks the current effective roles with anyOf, allOf, and noneOf."],["resource / action","string","undefined","Checks a NocoBase resource action. When roles are also present, both checks must pass."],["id / field","BaseKey / string","undefined","Optionally narrows the decision to one record or field."],["fallback","ReactNode","null","Renders when the access request is denied."]],ye=[["anyOf","AclPermission[]","undefined","Allows the page when any listed permission is available."],["allOf","AclPermission[]","undefined","Requires every listed permission before rendering the page."],["roles","RoleConstraint","undefined","Requires the current effective roles to match anyOf, allOf, and noneOf constraints."],["fallback","ReactNode","AccessDenied","Replaces the complete page when its permission test fails."],["children","ReactNode","required","The protected page content."]],we=[["resource","string","required","NocoBase collection or ACL resource name."],["action","string","required","Resource action such as list, show, create, edit, or delete."],["id","BaseKey","undefined","Optional record ID for record-scoped permission checks."],["dataSourceKey","string","undefined","Selects a non-main NocoBase data source."],["fallback",'"hidden" | "forbidden" | ReactNode','"hidden"',"Hides the region or replaces it with a local denied state."],["children","ReactNode","required","The protected page region."]],ve=[["resource","string","required","NocoBase collection containing the field."],["action","string","required","The action whose field whitelist should be checked."],["field","string","required","Exact NocoBase field name."],["dataSourceKey","string","undefined","Selects a non-main NocoBase data source."],["fallback","ReactNode","null","Optional read-only replacement for a denied field."],["children","ReactNode","required","The protected field or field group."]],Ne=[["AclStoreProvider","{ store, children }","required","Connects React ACL hooks and components to the application aclStore. The Starter mounts it at the application root."],["useGetRoles","() => QueryResult<string[]>","-","Returns the current effective ACL role names, including all participating roles in union mode."]];function Ae(){return e.jsxs("section",{className:"space-y-5 border-t pt-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Permission boundaries"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Components behind the patterns"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Use the smallest boundary that matches the intended user experience: complete page, independent region, or individual field."})]}),e.jsxs("div",{className:"space-y-7",children:[e.jsx(g,{title:"CanAccess",description:"The Starter access boundary for role-only, resource-only, or combined permission checks.",rows:be}),e.jsx(g,{title:"AclPage",description:"Protects a complete route or business page. This corresponds to the Page permission pattern above.",rows:ye}),e.jsx(g,{title:"AclRegion",description:"Protects one independent area inside a larger page. This corresponds to the Region permission pattern.",rows:we}),e.jsx(g,{title:"AclField",description:"Protects one field or field group. This corresponds to the Field permission pattern.",rows:ve}),e.jsx(g,{title:"ACL context APIs",description:"Read the active role context from the application ACL store. Demo previews use an isolated in-memory store with the same evaluator.",rows:Ne})]})]})}function g({title:s,description:t,rows:r}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:s}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(c,{className:"gap-0 overflow-hidden py-0",children:e.jsxs(X,{children:[e.jsx(Y,{children:e.jsxs(T,{children:[e.jsx(w,{children:"Prop"}),e.jsx(w,{children:"Type"}),e.jsx(w,{children:"Default"}),e.jsx(w,{children:"Description"})]})}),e.jsx(Z,{children:r.map(([a,n,i,o])=>e.jsxs(T,{children:[e.jsx(v,{className:"font-mono text-xs font-medium",children:a}),e.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:n}),e.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:i}),e.jsx(v,{className:"min-w-72 whitespace-normal text-muted-foreground",children:o})]},a))})]})})]})}function ke({config:s}){const[t,r]=A.useState(s.defaultScene),[a,n]=A.useState(s.defaultTarget),i=A.useMemo(()=>`Build a complete NocoBase ACL scene in the NocoBase Admin Starter.
|
|
17
|
+
|
|
18
|
+
Business scene
|
|
19
|
+
- Page or feature: ${t}
|
|
20
|
+
- Permission target: ${a}
|
|
21
|
+
- Use realistic fixed sample content so the permission behavior is visible immediately.
|
|
22
|
+
- Build the complete page section and user flow, not an isolated ACL snippet.
|
|
23
|
+
|
|
24
|
+
ACL scenario
|
|
25
|
+
${s.requirements}
|
|
26
|
+
|
|
27
|
+
Implementation contract
|
|
28
|
+
- Use the Starter's built-in NocoBase accessControlProvider and ACL store.
|
|
29
|
+
- NocoBase roles:check is the source of truth. Do not create a second permission store. Use configured role names only when the requirement explicitly includes a role constraint.
|
|
30
|
+
- Import the Starter CanAccess from @/components/access-control/can-access. Use it with AclPage, AclRegion, and AclField for permission presentation. Do not copy their checks into local booleans or role comparisons.
|
|
31
|
+
- For route-level role access, define the route once with defineAppRoutes in src/routes.tsx and put the constraint in access.roles. Let the route runtime control both its menu item and direct URL.
|
|
32
|
+
- Use useGetRoles only when UI needs to display or pass through the current effective ACL roles; it is not a replacement permission evaluator.
|
|
33
|
+
- Keep backend ACL enforcement in place; frontend checks only control presentation and navigation.
|
|
34
|
+
- Import reusable components from the installed local entry point at @/extensions/nocobase-acl when page composition is needed.
|
|
35
|
+
- Resource actions use the application names list, show, create, edit, and delete. Let the Starter map them to NocoBase list/get/create/update/destroy.
|
|
36
|
+
- Preserve dataSourceKey when the collection belongs to a non-main data source.
|
|
37
|
+
- Show an understandable forbidden or hidden state where appropriate.
|
|
38
|
+
- Deliver complete React component code, resource metadata, route integration, and the visible sample UI.`,[s.requirements,t,a]);return e.jsxs("details",{className:"group rounded-xl border bg-muted/15",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium marker:hidden",children:[e.jsx(ee,{className:"size-4 text-primary"}),"Prompt generator",e.jsx("span",{className:"ml-auto text-xs font-normal text-muted-foreground",children:s.title}),e.jsx(se,{className:"size-4 text-muted-foreground transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"grid items-start gap-5 border-t p-4 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(c,{className:"gap-0 py-0",children:[e.jsxs(u,{className:"border-b py-4",children:[e.jsx(h,{className:"text-base",children:"Scenario settings"}),e.jsx(P,{children:s.description})]}),e.jsxs(p,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:`${s.title}-scene`,children:"Business scene"}),e.jsx(k,{id:`${s.title}-scene`,value:t,onChange:o=>r(o.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:`${s.title}-target`,children:"Permission target"}),e.jsx(te,{id:`${s.title}-target`,value:a,onChange:o=>n(o.target.value),className:"min-h-24"})]})]})]}),e.jsx(he,{description:"Updates as you change the business scene and permission target.",prompt:i})]})]})}function j({eyebrow:s,title:t,description:r,children:a,prompt:n}){return e.jsxs("section",{className:"space-y-5 border-t pt-8",children:[e.jsxs("div",{children:[e.jsx(F,{variant:"outline",children:s}),e.jsx("h2",{className:"mt-3 text-2xl font-semibold tracking-[-0.025em]",children:t}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-muted-foreground",children:r})]}),a,e.jsx(ke,{config:n})]})}const R=[{id:1,name:"Alex Johnson",username:"alex",email:"alex@example.com",phone:"+1 202 555 0148",role:"Administrator"},{id:2,name:"Jamie Chen",username:"jamie",email:"jamie@example.com",phone:"+1 202 555 0186",role:"Member"},{id:3,name:"Morgan Lee",username:"morgan",email:"morgan@example.com",phone:"+1 202 555 0162",role:"Member"}],Pe={anyOf:["admin"]},V=me([{name:"dashboard",path:"/dashboard",resource:{meta:{label:"Dashboard",icon:e.jsx(_,{})}}},{name:"users",path:"/users",resource:{meta:{label:"Users",icon:e.jsx(M,{})}},access:{roles:Pe}},{name:"roles",path:"/roles",resource:{meta:{label:"Roles",icon:e.jsx(ge,{})}}}]),Re=ue(V),Ce=Re.map(s=>({key:s.name,name:s.name,route:typeof s.list=="string"?s.list:void 0,meta:s.meta,children:[]})),Se={"users:list":{},"departments:list":{}},Ue={"users:list":{}},Te={"users:get":{},"users:create":{},"users:update":{},"users:destroy":{}},De={"users:get":{},"users:update":{},"users:destroy":{}},Be=R.flatMap(s=>[{resource:"users",action:"update",id:s.id,allowed:!1},{resource:"users",action:"destroy",id:s.id,allowed:!1}]),Le={"users:update":{fields:["nickname","email","phone"]}},qe={"users:update":{fields:["nickname"]}};function Ee(){return e.jsxs("div",{className:"space-y-10 pb-12",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-[-0.025em] sm:text-3xl",children:"Permission patterns"}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:"Compare the authorized and restricted outcomes of navigation, pages, regions, record actions, and form fields using the same fixed data."})]}),e.jsx(j,{eyebrow:"Navigation permission",title:"Role-restricted routes disappear from navigation",description:"A route outside the current effective role is removed from the sidebar and its direct URL is guarded. Other accessible navigation remains unchanged.",prompt:{title:"Resource navigation",description:"Generate application resources, sidebar behavior, and guarded routes backed by NocoBase collections.",defaultScene:"User and role administration",defaultTarget:"Allow administrators to open Users, but remove it from navigation and block its direct URL for other roles.",requirements:`- Define application-owned navigation once through defineAppRoutes in src/routes.tsx.
|
|
39
|
+
- Put role constraints in the route access.roles field using anyOf, allOf, or noneOf.
|
|
40
|
+
- Let the route runtime generate the Refine resource, filter the sidebar item, and wrap the direct route with CanAccess.
|
|
41
|
+
- Do not repeat the same role list in Resource meta or a manually written route guard.
|
|
42
|
+
- Keep resource/action, record, region, and field permissions in their dedicated ACL boundaries.
|
|
43
|
+
- Let the Starter choose the first accessible route after inaccessible leaves and empty groups are removed.`},children:e.jsx(b,{allowedTitle:"Users permission granted",deniedTitle:"Users permission denied",allowed:e.jsx(d,{roles:["admin"],children:e.jsx(q,{})}),denied:e.jsx(d,{roles:["member"],children:e.jsx(q,{})})})}),e.jsx(j,{eyebrow:"Page permission",title:"A complete page is either available or replaced",description:"Page-level permission is useful when the whole route has one business purpose. Denial produces an understandable destination instead of a blank screen.",prompt:{title:"Page permission",description:"Generate a complete page whose availability depends on NocoBase permissions.",defaultScene:"User directory and account administration page",defaultTarget:"Allow administrators and user managers to render the complete page.",requirements:`- Wrap the complete business page with AclPage.
|
|
44
|
+
- Use the AclPage roles prop with anyOf, allOf, or noneOf for page-level role access.
|
|
45
|
+
- Keep anyOf and allOf for resource permissions when the page also needs collection access.
|
|
46
|
+
- Provide a useful page-level fallback instead of rendering an empty screen.
|
|
47
|
+
- Keep each inner data region independently protected when the page combines multiple collections.`},children:e.jsx(b,{allowedTitle:"Page allowed",deniedTitle:"Page denied",allowed:e.jsx(d,{roles:["user-manager"],children:e.jsx(O,{})}),denied:e.jsx(d,{roles:["member"],children:e.jsx(O,{})})})}),e.jsx(j,{eyebrow:"Region permission",title:"Only the protected region changes",description:"On a page with multiple resources, denying Departments hides only that panel and must not affect the Users table.",prompt:{title:"Region permission",description:"Generate a multi-resource page where each region follows its own collection ACL.",defaultScene:"Organization management dashboard",defaultTarget:"Keep Users visible while hiding the denied Departments panel.",requirements:`- Keep the outer page visible when its page-level permission is satisfied.
|
|
48
|
+
- Wrap every collection-backed panel in its own AclRegion.
|
|
49
|
+
- Enable each data query only when the corresponding list permission is allowed.
|
|
50
|
+
- Use fallback="hidden" so denied regions do not reveal unavailable resources or placeholders.
|
|
51
|
+
- Never use permission for one collection to hide unrelated tables or controls.`},children:e.jsx(b,{allowedTitle:"Both regions allowed",deniedTitle:"Departments resource hidden",allowed:e.jsx(d,{roles:["member"],permissions:Se,children:e.jsx(z,{})}),denied:e.jsx(d,{roles:["member"],permissions:Ue,children:e.jsx(z,{})})})}),e.jsx(j,{eyebrow:"Action and record permission",title:"Only unavailable actions are removed",description:"Collection permission controls global actions such as Create. Record ACL metadata controls Edit and Delete for each individual row.",prompt:{title:"Action permission",description:"Generate a data table whose toolbar and row actions respond to collection and record scopes.",defaultScene:"User administration table",defaultTarget:"Allow all actions for one user record and show a view-only row when update and delete are denied.",requirements:`- Use the Starter dataProvider so X-With-ACL-Meta captures NocoBase allowedActions from list, get, and getMany responses.
|
|
52
|
+
- Use the built-in Create, Show, Edit, and Delete buttons; do not manually compare user IDs or role names.
|
|
53
|
+
- Collection-level denial hides the action everywhere.
|
|
54
|
+
- Record-level allowedActions must hide or disable only the affected row action.
|
|
55
|
+
- Keep 403 responses authenticated and let NocoBase perform the final action validation.`},children:e.jsx(b,{allowedTitle:"Create and row actions allowed",deniedTitle:"Create, Update, and Delete denied",allowed:e.jsx(d,{roles:["admin"],permissions:Te,children:e.jsx($,{})}),denied:e.jsx(d,{roles:["viewer"],permissions:De,recordPermissions:Be,children:e.jsx($,{})})})}),e.jsx(j,{eyebrow:"Field permission",title:"A form can mix editable, read-only, and hidden fields",description:"Field ACL does not have to hide the complete form. Only protected inputs change, while permitted fields remain usable.",prompt:{title:"Field permission",description:"Generate a form or detail page whose individual fields follow NocoBase field ACL.",defaultScene:"User profile edit form",defaultTarget:"Allow nickname editing, make email read-only, and hide phone when those fields are denied.",requirements:`- Wrap each protected field or field group with AclField.
|
|
56
|
+
- Pass the collection resource, application action, and exact field name.
|
|
57
|
+
- Choose whether a denied field is hidden, replaced by read-only output, or shown with a custom fallback.
|
|
58
|
+
- Do not infer field access from the overall edit permission.
|
|
59
|
+
- Submit only values the current UI is allowed to edit; NocoBase still performs final field validation.`},children:e.jsx(b,{allowedTitle:"All fields editable",deniedTitle:"Email read-only and phone hidden",allowed:e.jsx(d,{roles:["admin"],permissions:Le,children:e.jsx(I,{})}),denied:e.jsx(d,{roles:["member"],permissions:qe,children:e.jsx(I,{})})})}),e.jsx(Ae,{})]})}function b({allowedTitle:s,deniedTitle:t,allowed:r,denied:a}){return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-emerald-700 dark:text-emerald-400",children:[e.jsx(re,{className:"size-4"}),s]}),r]}),e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-amber-700 dark:text-amber-400",children:[e.jsx(G,{className:"size-4"}),t]}),a]})]})}function q(){const s=ne(),t=s.status==="ready"?ae(Ce,s.permissions):[],r=t.some(n=>n.name==="users"),a=V.find(n=>n.name==="users");return e.jsxs("div",{className:"grid min-h-48 grid-cols-[150px_minmax(0,1fr)] overflow-hidden rounded-xl border bg-background",children:[e.jsxs("aside",{className:"border-r bg-muted/35 p-3",children:[e.jsx("div",{className:"mb-3 text-xs font-semibold text-muted-foreground",children:"Workspace"}),t.map(n=>{var i,o;return e.jsx(Oe,{icon:(i=n.meta)==null?void 0:i.icon,label:String(((o=n.meta)==null?void 0:o.label)??n.name),active:r?n.name==="users":n.name==="dashboard"},n.name)})]}),e.jsx("div",{className:"flex items-center justify-center p-5 text-center",children:e.jsx(ie,{access:a==null?void 0:a.access,fallback:e.jsxs("div",{children:[e.jsx(_,{className:"mx-auto size-7 text-muted-foreground"}),e.jsx("div",{className:"mt-2 font-medium",children:"Dashboard"}),e.jsx("div",{className:"mt-1 max-w-48 text-xs text-muted-foreground",children:"Users is absent from navigation and its direct route is guarded."})]}),children:e.jsxs("div",{children:[e.jsx(M,{className:"mx-auto size-7 text-primary"}),e.jsx("div",{className:"mt-2 font-medium",children:"Users"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Route is available"})]})})})]})}function Oe({icon:s,label:t,active:r=!1}){return e.jsxs("div",{className:`mb-1 flex items-center gap-2 rounded-md px-2 py-2 text-xs ${r?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:[e.jsx("span",{className:"[&_svg]:size-3.5",children:s}),t]})}function O(){return e.jsx(je,{roles:{anyOf:["admin","user-manager"]},fallback:e.jsx($e,{}),children:e.jsx(ze,{})})}function ze(){return e.jsxs(c,{children:[e.jsxs(u,{children:[e.jsx(h,{children:"User directory"}),e.jsx(P,{children:"3 users"})]}),e.jsx(p,{children:e.jsx(W,{})})]})}function $e(){return e.jsx("div",{className:"flex min-h-64 items-center justify-center rounded-xl border border-dashed bg-background p-6 text-center",children:e.jsxs("div",{children:[e.jsx(G,{className:"mx-auto size-8 text-muted-foreground"}),e.jsx("div",{className:"mt-3 font-medium",children:"You cannot open this page"}),e.jsx("p",{className:"mx-auto mt-1 max-w-xs text-sm text-muted-foreground",children:"Ask an administrator for access to the user directory or return to an available page."}),e.jsx(m,{className:"mt-4",variant:"outline",size:"sm",children:"Return to dashboard"})]})})}function z(){return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border bg-background p-3 md:flex-row",children:[e.jsx(L,{resource:"users",action:"list",children:e.jsxs(c,{size:"sm",className:"min-w-0 flex-1",children:[e.jsx(u,{children:e.jsx(h,{children:"Users"})}),e.jsx(p,{children:e.jsx(W,{limit:2})})]})}),e.jsx(L,{resource:"departments",action:"list",children:e.jsxs(c,{size:"sm",className:"md:w-56",children:[e.jsx(u,{children:e.jsx(h,{children:"Departments"})}),e.jsxs(p,{className:"space-y-2",children:[e.jsx(K,{title:"Engineering",name:"engineering"}),e.jsx(K,{title:"Operations",name:"operations"})]})]})})]})}function $(){return e.jsxs(c,{children:[e.jsxs(u,{className:"flex-row items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(h,{children:"Users"}),e.jsx(P,{children:"Record actions"})]}),e.jsx(y,{resource:"users",action:"create",children:e.jsxs(m,{size:"sm",children:[e.jsx(oe,{})," New user"]})})]}),e.jsx(p,{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[420px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-3 font-medium",children:"User"}),e.jsx("th",{className:"pb-3 font-medium",children:"Role"}),e.jsx("th",{className:"pb-3 text-right font-medium",children:"Actions"})]})}),e.jsx("tbody",{children:R.slice(0,2).map(s=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-3 font-medium",children:s.name}),e.jsx("td",{className:"py-3 text-muted-foreground",children:s.role}),e.jsx("td",{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(y,{resource:"users",action:"show",id:s.id,children:e.jsx(m,{variant:"ghost",size:"icon-sm","aria-label":"View user",children:e.jsx(le,{})})}),e.jsx(y,{resource:"users",action:"edit",id:s.id,children:e.jsx(m,{variant:"ghost",size:"icon-sm","aria-label":"Edit user",children:e.jsx(de,{})})}),e.jsx(y,{resource:"users",action:"delete",id:s.id,children:e.jsx(m,{variant:"ghost",size:"icon-sm","aria-label":"Delete user",children:e.jsx(ce,{})})})]})})]},s.id))})]})})]})}function I(){const s=R[1];return e.jsxs(c,{children:[e.jsxs(u,{children:[e.jsx(h,{children:"Edit profile"}),e.jsx(P,{children:s.name})]}),e.jsxs(p,{className:"space-y-4",children:[e.jsx(C,{resource:"users",action:"edit",field:"nickname",children:e.jsx(N,{label:"Nickname",children:e.jsx(k,{defaultValue:s.name})})}),e.jsx(C,{resource:"users",action:"edit",field:"email",fallback:e.jsx(N,{label:"Email",children:e.jsxs("div",{className:"rounded-md border bg-muted/45 px-3 py-2 text-sm text-muted-foreground",children:[s.email,e.jsx(F,{className:"ml-2",variant:"outline",children:"Read only"})]})}),children:e.jsx(N,{label:"Email",children:e.jsx(k,{defaultValue:s.email})})}),e.jsx(C,{resource:"users",action:"edit",field:"phone",children:e.jsx(N,{label:"Phone",children:e.jsx(k,{defaultValue:s.phone})})}),e.jsx(y,{resource:"users",action:"edit",children:e.jsx(m,{size:"sm",children:"Save changes"})})]})]})}function N({label:s,children:t}){return e.jsxs("label",{className:"block space-y-2",children:[e.jsx("span",{className:"text-xs font-medium",children:s}),t]})}function W({limit:s=3}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[360px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-3 font-medium",children:"User"}),e.jsx("th",{className:"pb-3 font-medium",children:"Email"})]})}),e.jsx("tbody",{children:R.slice(0,s).map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsxs("td",{className:"py-3",children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.username})]}),e.jsx("td",{className:"py-3 text-muted-foreground",children:t.email})]},t.id))})]})})}function K({title:s,name:t}){return e.jsxs("div",{className:"rounded-lg border px-3 py-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"mt-0.5 font-mono text-xs text-muted-foreground",children:t})]})}export{Ee as AclPatternsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ar as t,H as u}from"./echarts-runtime-
|
|
1
|
+
import{ar as t,H as u}from"./echarts-runtime-Ce_z2eX_.js";function o(r,l){var e=r.mapDimensionsAll("defaultedLabel"),a=e.length;if(a===1){var n=t(r,l,e[0]);return n!=null?n+"":null}else if(a){for(var s=[],f=0;f<e.length;f++)s.push(t(r,l,e[f]));return s.join(" ")}}function v(r,l){var e=r.mapDimensionsAll("defaultedLabel");if(!u(l))return l+"";for(var a=[],n=0;n<e.length;n++){var s=r.getDimensionIndex(e[n]);s>=0&&a.push(l[s])}return a.join(" ")}export{o as a,v as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as i,j as e,o as l,I as x,be as g,K as f}from"./index-Cc6awvdg.js";import{u as j}from"./use-authenticator-sign-in-CIj210ry.js";function w(s){return j(s)}function b({authenticator:s,onSignIn:t}){var o;const[n,c]=i.useState(""),[r,d]=i.useState(""),{signIn:p,isPending:u}=w(s.name),m=((o=s.options)==null?void 0:o.autoSignup)===!0;return e.jsxs("form",{className:"space-y-5",onSubmit:a=>{if(a.preventDefault(),t){t({account:n,password:r});return}p({account:n,password:r})},children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:`${s.name}-ldap-account`,children:"Account"}),e.jsx(x,{id:`${s.name}-ldap-account`,value:n,onChange:a=>c(a.target.value),autoComplete:"username",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:`${s.name}-ldap-password`,children:"Password"}),e.jsx(g,{id:`${s.name}-ldap-password`,value:r,onChange:a=>d(a.target.value),autoComplete:"current-password",required:!0})]}),e.jsx(f,{type:"submit",className:"w-full",disabled:!t&&u,children:!t&&u?"Signing in…":"Sign in"}),m&&e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"An account will be created automatically after the first successful LDAP sign-in."})]})}export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b5 as g,b as o,b6 as m,b7 as d,j as t,aN as b,aP as f,aQ as h,K as x,b8 as v,r as p}from"./index-Cc6awvdg.js";function w(r){const[e]=g(),[i,a]=o.useState(!1),[n,l]=o.useState(),u=o.useMemo(()=>{if(e.get("authenticator")!==r.name)return;const s=e.get("error");return s?new Error(s):void 0},[r.name,e]);return{signIn:o.useCallback(async()=>{l(void 0),a(!0);try{const s=m(e.get("to")||e.get("redirect")||"/"),c=await d.action("oidc","getAuthUrl",{method:"POST",authenticator:r.name,includeRole:!1,withAclMeta:!1,body:{redirect:s}});if(!c)throw new Error("NocoBase did not return an OIDC authorization URL.");window.location.replace(d.resolveUrl(c))}catch(s){l(s instanceof Error?s:new Error("Unable to start OIDC sign-in.")),a(!1)}},[r.name,e]),isPending:i,error:n??u}}function E({authenticator:r,onSignIn:e}){const{signIn:i,isPending:a,error:n}=w(r);return t.jsxs("div",{className:"space-y-3",children:[n&&t.jsxs(b,{variant:"destructive",children:[t.jsx(f,{children:"OIDC sign-in failed"}),t.jsx(h,{children:n.message})]}),t.jsxs(x,{type:"button",variant:"outline",className:"w-full",disabled:!e&&a,onClick:e??i,children:[t.jsx(v,{}),!e&&a?"Redirecting…":p(r.title||r.authTypeTitle||"OIDC")]})]})}export{E as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aB as F,b as t,j as e,C as j,k as A,l as T,n as P,o as i,I as y,T as U,d as k,e as N,f as C,g as S,i as l,a6 as R,a9 as ce,aa as de,ab as me,a8 as ue,aC as M,B as b,_ as $,$ as B,ae as D,aE as _,aD as J,aJ as he,aK as xe,K as pe,aL as ge}from"./index-Cc6awvdg.js";import{A as je}from"./configuration-gate-B4XVz7tS.js";import{S as fe}from"./switch-BdVxPIVU.js";import{P as ve}from"./prompt-card-rGZqpqkF.js";import"./prompt-output-B4h3uLWf.js";function ye(n,r){for(const[o,c]of Object.entries(r)){const u=o;n.setValue(u,c,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}}const be=n=>!["nathan","dara"].includes(n.toLowerCase());function we(){var X,Y;const{employees:n}=F(),r=n.filter(a=>be(a.username)),[o,c]=t.useState(((X=r[0])==null?void 0:X.username)??((Y=n[0])==null?void 0:Y.username)??""),[u,d]=t.useState("Customer renewal workspace"),[p,g]=t.useState("Show a customer renewal detail with account health, contract value, renewal date, owner, recent activity, and a working AI conversation beside it."),[m,f]=t.useState("Review renewal risk"),[s,I]=t.useState("Review this customer renewal, identify risks, and recommend the next action."),[h,v]=t.useState(!1),[w,K]=t.useState("shortcut"),[x,z]=t.useState("renewal-detail"),[V,ee]=t.useState("Customer renewal detail"),[q,te]=t.useState("context"),[H,se]=t.useState("update_renewal_plan"),[O,ae]=t.useState("Update the renewal risk level and the visible follow-up note on the page."),[W,ne]=t.useState("ASK"),re=t.useMemo(()=>{var Z;const a=((Z=n.find(le=>le.username===o))==null?void 0:Z.nickname)??o,Q=`{ type: "page-element", id: "${x}", title: "${V}" }`,G=w==="manual"?!1:h,oe={shortcut:`Place an AIEmployeeShortcut in the page header, visually separated from the registered business element. Target the embedded chat controller and configure this task on its tasks prop:
|
|
2
2
|
- Title: ${m}
|
|
3
3
|
- User message: ${s}
|
|
4
4
|
- Auto send: ${G}
|
|
@@ -45,7 +45,7 @@ AI employee and task
|
|
|
45
45
|
|
|
46
46
|
Business context
|
|
47
47
|
- Context id: ${x}
|
|
48
|
-
- Context title: ${
|
|
48
|
+
- Context title: ${V}
|
|
49
49
|
- Register a visible, meaningful business element with this stable id.
|
|
50
50
|
- Resolve its content at task or message send time so the AI always receives the latest displayed values.
|
|
51
51
|
- Prefer useAIPageElementHandle so the registered ref and context reference cannot drift apart.
|
|
@@ -68,6 +68,6 @@ Implementation requirements
|
|
|
68
68
|
- Manual Pick affects only the current composed message.
|
|
69
69
|
- Preserve NocoBase streaming, conversation history, Tool approval, and resume behavior.
|
|
70
70
|
- Use shadcn/Base UI components and the existing Registry components.
|
|
71
|
-
- Deliver the complete component code, including sample state, context registration, task configuration, chat layout, and all visible business UI.`},[h,q,x,L,o,n,w,p,u,s,m,O,H,W]);return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(j,{className:"gap-0 py-0",children:[e.jsx(A,{className:"border-b py-4",children:e.jsx(T,{children:"Scene settings"})}),e.jsxs(P,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-title",children:"Scene title"}),e.jsx(y,{id:"context-generator-scene-title",value:u,onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-brief",children:"Business scene"}),e.jsx(U,{id:"context-generator-scene-brief",value:p,onChange:a=>g(a.target.value),className:"min-h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"AI employee"}),e.jsxs(k,{value:o,onValueChange:a=>a&&c(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsx(S,{children:(r.length?r:n).map(a=>e.jsx(l,{value:a.username,children:a.nickname},a.username))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-title",children:"Task title"}),e.jsx(y,{id:"context-generator-task-title",value:m,onChange:a=>f(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-message",children:"Task message"}),e.jsx(U,{id:"context-generator-task-message",value:s,onChange:a=>I(a.target.value),className:"min-h-24"})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto send"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Otherwise fill the composer for review."})]}),e.jsx(fe,{checked:w==="manual"?!1:h,disabled:w==="manual",onCheckedChange:v})]}),w==="manual"?e.jsx("p",{className:"-mt-3 text-xs leading-5 text-muted-foreground",children:"Manual Pick keeps the message in the composer so context can be selected before sending."}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Context integration"}),e.jsxs(k,{value:w,onValueChange:a=>a&&K(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"shortcut",children:"Shortcut task"}),e.jsx(l,{value:"preset",children:"Conversation preset task"}),e.jsx(l,{value:"scope",children:"Scope inheritance"}),e.jsx(l,{value:"manual",children:"Manual Pick"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-id",children:"Context id"}),e.jsx(y,{id:"context-generator-id",value:x,onChange:a=>z(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-title",children:"Context title"}),e.jsx(y,{id:"context-generator-title",value:L,onChange:a=>ee(a.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Page capability"}),e.jsxs(k,{value:q,onValueChange:a=>a&&te(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"context",children:"Context only"}),e.jsx(l,{value:"form-filler",children:"Built-in Form filler"}),e.jsx(l,{value:"custom-tool",children:"Custom frontend Tool"})]})]})]}),q==="custom-tool"?e.jsxs("div",{className:"space-y-4 rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-name",children:"Tool name"}),e.jsx(y,{id:"context-generator-tool-name",value:H,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-action",children:"Business action"}),e.jsx(U,{id:"context-generator-tool-action",value:O,onChange:a=>ae(a.target.value),className:"min-h-20"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Permission"}),e.jsxs(k,{value:W,onValueChange:a=>a&&ne(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"ASK",children:"ASK"}),e.jsx(l,{value:"ALLOW",children:"ALLOW"})]})]})]})]}):null]})]}),e.jsx(ve,{title:"Complete page context scene prompt",description:"Copy this prompt to generate the business page, AI interaction, context binding, and working conversation as one complete scene.",prompt:re})]})}function ke(){return e.jsx(R,{id:"page-element-demo",children:e.jsx(Ne,{})})}function Ne(){const[n,r]=t.useState("Northwind Studio"),[o,c]=t.useState("ops@northwind.test"),[u,d]=t.useState("high"),[p,g]=t.useState(!1),{id:m,addWorkContext:f,focusComposer:s}=ce(),{registeredCount:I,startPicking:h}=de(),v=t.useMemo(()=>[{key:"pick-page-element",label:"Pick page element",icon:e.jsx(me,{}),disabled:I===0,onClick:()=>h({chatId:m,onSelect:x=>{f(x),s()}})},{key:"web-search",label:"Web search",icon:e.jsx(ue,{}),active:p,onClick:()=>g(x=>!x)}],[f,m,s,I,h,p]),w=M({id:"customer-intake-form",title:"Customer intake form",kind:"form",getContext:()=>({form:"customer-intake",values:{customerName:n,contactEmail:o,priority:u}})}),K=M({id:"customer-health-summary",title:"Customer health summary",kind:"record-detail",getContext:()=>({resource:"customers",record:{name:n,plan:"Enterprise",healthScore:86,openRequests:3,renewalDate:"2026-09-30"}})});return e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] lg:grid-cols-[minmax(0,1fr)_390px]",children:[e.jsxs("div",{className:"space-y-4 bg-muted/15 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Customer workspace"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"The form and detail card are registered page elements."})]}),e.jsx(b,{variant:"outline",children:"2 selectable elements"})]}),e.jsxs(j,{ref:w,className:"transition-shadow",children:[e.jsxs(A,{children:[e.jsx(T,{children:"Customer intake form"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Update a value, then pick this form to capture its current state."})]}),e.jsxs(P,{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"page-context-customer-name",children:"Customer name"}),e.jsx(y,{id:"page-context-customer-name",value:n,onChange:x=>r(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"page-context-contact-email",children:"Contact email"}),e.jsx(y,{id:"page-context-contact-email",value:o,onChange:x=>c(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:u,onValueChange:x=>x&&d(x),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{ref:K,className:"transition-shadow",children:[e.jsx(A,{children:e.jsx(T,{children:"Customer health summary"})}),e.jsx(P,{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[["Plan","Enterprise"],["Health score","86 / 100"],["Open requests","3"],["Renewal","Sep 30, 2026"]].map(([x,z])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:x}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:z})]},x))})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card lg:border-l lg:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{composerActions:v,showConversationToggle:!1,enableAttachments:!0,attachmentActionIndex:1,disclaimer:!1})})})]})})}const V=n=>!["nathan","dara"].includes(n.username.toLowerCase());function Ve(){return e.jsx(je,{children:e.jsx(Ce,{})})}function Ce(){return e.jsxs("div",{className:"space-y-12 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"AI Components"}),e.jsx(b,{variant:"outline",children:"Conversation context"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Page context and frontend tools"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Connect AI employees to live React page state. Start with manual context selection, configure task context, then expose fixed or custom frontend capabilities that can safely update the page."})]})}),e.jsx(E,{eyebrow:"Manual context",title:"Pick page context while composing a message",description:"The user can pick any registered page element from the composer. Its current content is added to this message without changing task configuration.",children:e.jsx(ke,{})}),e.jsx(E,{eyebrow:"Task context · Shortcut",title:"Reference page context from a Shortcut task",description:"The Shortcut task stores a page-element reference in message.workContext and reads its latest content when the user starts the task.",children:e.jsx(Te,{})}),e.jsx(E,{eyebrow:"Task context · Conversation preset",title:"Reference page context from a conversation preset task",description:"The AIChatProvider employeeTasks configuration uses the same message.workContext reference, but exposes the task in the conversation empty state instead of through a Shortcut.",children:e.jsx(Pe,{})}),e.jsx(E,{eyebrow:"Task context · Scope inheritance",title:"Inherit the surrounding page context",description:"A Shortcut or AIChatProvider inside AIPageContextScope inherits that context. A task-level message.workContext still takes precedence when configured.",children:e.jsx(Ie,{})}),e.jsx(E,{eyebrow:"Built-in frontend tool",title:"Fill a registered React form with Form filler",description:"Form filler is registered once by AIProvider. The form exposes its identifier, field schema, live values, and setter through useAIForm; it is not part of the custom frontend Tool catalog.",children:e.jsx(Se,{})}),e.jsx(E,{eyebrow:"Custom frontend tool",title:"Expose a page-specific action to the AI employee",description:"A registered page element can advertise custom Tools through the NocoBase loadFrontendTool and executeFrontendTool protocol. The example uses ASK permission and updates only the local quote preview.",children:e.jsx(Ae,{})}),e.jsx(E,{eyebrow:"Prompt generator",title:"Generate a complete page context scene",description:"Describe the business scene, select the AI employee and task, then generate the full page surface, context binding, conversation layout, and optional frontend capability together.",children:e.jsx(we,{})})]})}function Se(){const{employees:n}=F(),r=n.find(s=>s.username==="form_assistant")??n.find(s=>s.username.toLowerCase()==="dex")??n.filter(V)[0],o=D(),[c,u]=t.useState("Acme Logistics is evaluating the enterprise plan. The main contact is Jordan Lee at jordan.lee@acme.test. This is a high-priority opportunity."),d=he({defaultValues:{company:"",contactName:"",email:"",priority:"normal"}}),p=t.useMemo(()=>[{name:"company",title:"Company",type:"string",required:!0},{name:"contactName",title:"Contact name",type:"string",required:!0},{name:"email",title:"Email",type:"email"},{name:"priority",title:"Priority",type:"string",enum:["low","normal","high"]}],[]),g=xe({id:"lead-intake-form",title:"Lead intake form",fields:p,getValues:d.getValues,setValues:s=>ye(d,s)}),m=t.useMemo(()=>({type:"page-element",id:"lead-intake-form",title:"Lead intake form",kind:"form"}),[]),f=t.useMemo(()=>({title:"Fill lead form",message:{user:`Extract the lead details from the following text and fill the current form. Do not submit it.
|
|
71
|
+
- Deliver the complete component code, including sample state, context registration, task configuration, chat layout, and all visible business UI.`},[h,q,x,V,o,n,w,p,u,s,m,O,H,W]);return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(j,{className:"gap-0 py-0",children:[e.jsx(A,{className:"border-b py-4",children:e.jsx(T,{children:"Scene settings"})}),e.jsxs(P,{className:"space-y-5 py-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-title",children:"Scene title"}),e.jsx(y,{id:"context-generator-scene-title",value:u,onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-scene-brief",children:"Business scene"}),e.jsx(U,{id:"context-generator-scene-brief",value:p,onChange:a=>g(a.target.value),className:"min-h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"AI employee"}),e.jsxs(k,{value:o,onValueChange:a=>a&&c(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsx(S,{children:(r.length?r:n).map(a=>e.jsx(l,{value:a.username,children:a.nickname},a.username))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-title",children:"Task title"}),e.jsx(y,{id:"context-generator-task-title",value:m,onChange:a=>f(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-task-message",children:"Task message"}),e.jsx(U,{id:"context-generator-task-message",value:s,onChange:a=>I(a.target.value),className:"min-h-24"})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Auto send"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Otherwise fill the composer for review."})]}),e.jsx(fe,{checked:w==="manual"?!1:h,disabled:w==="manual",onCheckedChange:v})]}),w==="manual"?e.jsx("p",{className:"-mt-3 text-xs leading-5 text-muted-foreground",children:"Manual Pick keeps the message in the composer so context can be selected before sending."}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Context integration"}),e.jsxs(k,{value:w,onValueChange:a=>a&&K(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"shortcut",children:"Shortcut task"}),e.jsx(l,{value:"preset",children:"Conversation preset task"}),e.jsx(l,{value:"scope",children:"Scope inheritance"}),e.jsx(l,{value:"manual",children:"Manual Pick"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-id",children:"Context id"}),e.jsx(y,{id:"context-generator-id",value:x,onChange:a=>z(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-title",children:"Context title"}),e.jsx(y,{id:"context-generator-title",value:V,onChange:a=>ee(a.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Page capability"}),e.jsxs(k,{value:q,onValueChange:a=>a&&te(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"context",children:"Context only"}),e.jsx(l,{value:"form-filler",children:"Built-in Form filler"}),e.jsx(l,{value:"custom-tool",children:"Custom frontend Tool"})]})]})]}),q==="custom-tool"?e.jsxs("div",{className:"space-y-4 rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-name",children:"Tool name"}),e.jsx(y,{id:"context-generator-tool-name",value:H,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"context-generator-tool-action",children:"Business action"}),e.jsx(U,{id:"context-generator-tool-action",value:O,onChange:a=>ae(a.target.value),className:"min-h-20"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Permission"}),e.jsxs(k,{value:W,onValueChange:a=>a&&ne(a),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"ASK",children:"ASK"}),e.jsx(l,{value:"ALLOW",children:"ALLOW"})]})]})]})]}):null]})]}),e.jsx(ve,{title:"Complete page context scene prompt",description:"Copy this prompt to generate the business page, AI interaction, context binding, and working conversation as one complete scene.",prompt:re})]})}function ke(){return e.jsx(R,{id:"page-element-demo",children:e.jsx(Ne,{})})}function Ne(){const[n,r]=t.useState("Northwind Studio"),[o,c]=t.useState("ops@northwind.test"),[u,d]=t.useState("high"),[p,g]=t.useState(!1),{id:m,addWorkContext:f,focusComposer:s}=ce(),{registeredCount:I,startPicking:h}=de(),v=t.useMemo(()=>[{key:"pick-page-element",label:"Pick page element",icon:e.jsx(me,{}),disabled:I===0,onClick:()=>h({chatId:m,onSelect:x=>{f(x),s()}})},{key:"web-search",label:"Web search",icon:e.jsx(ue,{}),active:p,onClick:()=>g(x=>!x)}],[f,m,s,I,h,p]),w=M({id:"customer-intake-form",title:"Customer intake form",kind:"form",getContext:()=>({form:"customer-intake",values:{customerName:n,contactEmail:o,priority:u}})}),K=M({id:"customer-health-summary",title:"Customer health summary",kind:"record-detail",getContext:()=>({resource:"customers",record:{name:n,plan:"Enterprise",healthScore:86,openRequests:3,renewalDate:"2026-09-30"}})});return e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] lg:grid-cols-[minmax(0,1fr)_390px]",children:[e.jsxs("div",{className:"space-y-4 bg-muted/15 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Customer workspace"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"The form and detail card are registered page elements."})]}),e.jsx(b,{variant:"outline",children:"2 selectable elements"})]}),e.jsxs(j,{ref:w,className:"transition-shadow",children:[e.jsxs(A,{children:[e.jsx(T,{children:"Customer intake form"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Update a value, then pick this form to capture its current state."})]}),e.jsxs(P,{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"page-context-customer-name",children:"Customer name"}),e.jsx(y,{id:"page-context-customer-name",value:n,onChange:x=>r(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"page-context-contact-email",children:"Contact email"}),e.jsx(y,{id:"page-context-contact-email",value:o,onChange:x=>c(x.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:u,onValueChange:x=>x&&d(x),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{ref:K,className:"transition-shadow",children:[e.jsx(A,{children:e.jsx(T,{children:"Customer health summary"})}),e.jsx(P,{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[["Plan","Enterprise"],["Health score","86 / 100"],["Open requests","3"],["Renewal","Sep 30, 2026"]].map(([x,z])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:x}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:z})]},x))})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card lg:border-l lg:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{composerActions:v,showConversationToggle:!1,enableAttachments:!0,attachmentActionIndex:1,disclaimer:!1})})})]})})}const L=n=>!["nathan","dara"].includes(n.username.toLowerCase());function Me(){return e.jsx(je,{children:e.jsx(Ce,{})})}function Ce(){return e.jsxs("div",{className:"space-y-12 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"AI Components"}),e.jsx(b,{variant:"outline",children:"Conversation context"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Page context and frontend tools"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Connect AI employees to live React page state. Start with manual context selection, configure task context, then expose fixed or custom frontend capabilities that can safely update the page."})]})}),e.jsx(E,{eyebrow:"Manual context",title:"Pick page context while composing a message",description:"The user can pick any registered page element from the composer. Its current content is added to this message without changing task configuration.",children:e.jsx(ke,{})}),e.jsx(E,{eyebrow:"Task context · Shortcut",title:"Reference page context from a Shortcut task",description:"The Shortcut task stores a page-element reference in message.workContext and reads its latest content when the user starts the task.",children:e.jsx(Te,{})}),e.jsx(E,{eyebrow:"Task context · Conversation preset",title:"Reference page context from a conversation preset task",description:"The AIChatProvider employeeTasks configuration uses the same message.workContext reference, but exposes the task in the conversation empty state instead of through a Shortcut.",children:e.jsx(Pe,{})}),e.jsx(E,{eyebrow:"Task context · Scope inheritance",title:"Inherit the surrounding page context",description:"A Shortcut or AIChatProvider inside AIPageContextScope inherits that context. A task-level message.workContext still takes precedence when configured.",children:e.jsx(Ie,{})}),e.jsx(E,{eyebrow:"Built-in frontend tool",title:"Fill a registered React form with Form filler",description:"Form filler is registered once by AIProvider. The form exposes its identifier, field schema, live values, and setter through useAIForm; it is not part of the custom frontend Tool catalog.",children:e.jsx(Se,{})}),e.jsx(E,{eyebrow:"Custom frontend tool",title:"Expose a page-specific action to the AI employee",description:"A registered page element can advertise custom Tools through the NocoBase loadFrontendTool and executeFrontendTool protocol. The example uses ASK permission and updates only the local quote preview.",children:e.jsx(Ae,{})}),e.jsx(E,{eyebrow:"Prompt generator",title:"Generate a complete page context scene",description:"Describe the business scene, select the AI employee and task, then generate the full page surface, context binding, conversation layout, and optional frontend capability together.",children:e.jsx(we,{})})]})}function Se(){const{employees:n}=F(),r=n.find(s=>s.username==="form_assistant")??n.find(s=>s.username.toLowerCase()==="dex")??n.filter(L)[0],o=D(),[c,u]=t.useState("Acme Logistics is evaluating the enterprise plan. The main contact is Jordan Lee at jordan.lee@acme.test. This is a high-priority opportunity."),d=he({defaultValues:{company:"",contactName:"",email:"",priority:"normal"}}),p=t.useMemo(()=>[{name:"company",title:"Company",type:"string",required:!0},{name:"contactName",title:"Contact name",type:"string",required:!0},{name:"email",title:"Email",type:"email"},{name:"priority",title:"Priority",type:"string",enum:["low","normal","high"]}],[]),g=xe({id:"lead-intake-form",title:"Lead intake form",fields:p,getValues:d.getValues,setValues:s=>ye(d,s)}),m=t.useMemo(()=>({type:"page-element",id:"lead-intake-form",title:"Lead intake form",kind:"form"}),[]),f=t.useMemo(()=>({title:"Fill lead form",message:{user:`Extract the lead details from the following text and fill the current form. Do not submit it.
|
|
72
72
|
|
|
73
|
-
${c}`},autoSend:!0}),[c]);return e.jsx(J,{context:m,children:e.jsx(R,{id:"form-filler-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[610px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"space-y-5 bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Source content"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Edit this text, then ask the AI employee to fill the registered form below."})]}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:`Ask ${r.nickname}`,size:34})]})}),e.jsx(P,{children:e.jsx(U,{value:c,onChange:s=>u(s.target.value),className:"min-h-28"})})]}),e.jsxs("form",{ref:g,className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b p-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Lead intake form"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Form filler changes visible values only. It never submits the form."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"useAIForm"}),e.jsx(pe,{type:"button",variant:"outline",size:"sm",onClick:()=>d.reset({company:"",contactName:"",email:"",priority:"normal"}),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-4 p-5 sm:grid-cols-2",children:[e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-company",children:"Company"}),e.jsx(y,{id:"form-filler-company",...d.register("company")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-contact",children:"Contact name"}),e.jsx(y,{id:"form-filler-contact",...d.register("contactName")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-email",children:"Email"}),e.jsx(y,{id:"form-filler-email",type:"email",...d.register("email")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:d.watch("priority"),onValueChange:s=>s&&d.setValue("priority",s,{shouldDirty:!0,shouldTouch:!0}),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[610px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Ae(){const{employees:n}=F(),r=n.filter(V)[0],o=D(),[c,u]=t.useState(0),[d,p]=t.useState("Not reviewed"),g=24e3,m=g*(1-c/100),f=t.useMemo(()=>[{name:"update_quote_discount",title:"Update quote discount",description:"Update the discount percentage and review note shown on the current quote. This changes the page preview only and does not save the quote.",permission:"ASK",inputSchema:{type:"object",properties:{discountPercent:{type:"number",minimum:0,maximum:30,description:"Discount percentage applied to the quote."},note:{type:"string",description:"Short explanation shown in the review note."}},required:["discountPercent","note"],additionalProperties:!1},execute:h=>{const v=h&&typeof h=="object"&&!Array.isArray(h)?h:{};return typeof v.discountPercent!="number"||v.discountPercent<0||v.discountPercent>30||typeof v.note!="string"?{status:"error",content:"Provide a discount from 0 to 30 and a review note."}:(u(v.discountPercent),p(v.note),{status:"success",content:`Updated the quote preview to a ${v.discountPercent}% discount.`})}}],[]),s=ge({id:"quote-review-card",title:"Quote review",kind:"record-detail",tools:f,getContext:()=>({resource:"quotes",record:{quoteNumber:"QT-2026-1048",customer:"Northwind Studio",baseAmount:g,discountPercent:c,total:m,approvalNote:d}})}),I=t.useMemo(()=>({title:"Apply review discount",message:{user:"Update the current quote preview to use a 12% discount and set the review note to 'Approved for the renewal discussion'."},autoSend:!0}),[]);return e.jsx(J,{context:s.context,children:e.jsx(R,{id:"custom-frontend-tool-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:s.ref,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Quote review"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"QT-2026-1048 · Northwind Studio"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"outline",children:"Custom Tool"}),e.jsx(b,{variant:"secondary",children:"ASK"})]})]})}),e.jsxs(P,{className:"space-y-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[["Base amount",`$${g.toLocaleString()}`],["Discount",`${c}%`],["Preview total",`$${m.toLocaleString()}`]].map(([h,v])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:h}),e.jsx("div",{className:"mt-1 font-medium",children:v})]},h))}),e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Review note"}),e.jsx("div",{className:"mt-1 text-sm",children:d})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t pt-4",children:[e.jsx("p",{className:"max-w-lg text-xs leading-5 text-muted-foreground",children:"The page element registers update_quote_discount. Its full input schema is loaded only when the AI chooses this Tool. Approval is controlled by the ASK permission."}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[I],label:`Ask ${r.nickname}`,size:34})]})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Te(){const{employees:n}=F(),r=n.filter(V)[0],o=D(),[c,u]=t.useState("Payment callback reached the order service twelve minutes late."),[d,p]=t.useState("high"),g=t.useMemo(()=>({type:"page-element",id:"selected-support-case",title:"Selected support case"}),[]),m=M({id:"selected-support-case",title:"Selected support case",kind:"editable-record",getContext:()=>({resource:"supportTickets",values:{summary:c,severity:d}})}),f=t.useMemo(()=>({title:"Analyze selected case",message:{user:"Analyze the selected support case.",workContext:[g]},autoSend:!1}),[g]);return e.jsx(R,{id:"shortcut-task-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected support case"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value before running either task."})]}),e.jsx(b,{variant:"secondary",children:"Task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"selected-context-summary",children:"Summary"}),e.jsx(y,{id:"selected-context-summary",value:c,onChange:s=>u(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Severity"}),e.jsxs(k,{value:d,onValueChange:s=>s&&p(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"medium",children:"Medium"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{className:"mt-5 border-dashed bg-background/80",children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Task shortcut area"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"This button is outside the selected page element. Its task explicitly references “Selected support case”."})]}),e.jsx(b,{variant:"outline",children:"Explicit reference"})]})}),e.jsx(P,{children:e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:"Analyze selected case",size:34})})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Pe(){const{employees:n}=F(),r=n.filter(V)[0],[o,c]=t.useState("Enterprise workspace expansion"),[u,d]=t.useState("likely"),p=t.useMemo(()=>({type:"page-element",id:"selected-opportunity",title:"Selected opportunity"}),[]),g=M({id:"selected-opportunity",title:"Selected opportunity",kind:"record-detail",getContext:()=>({resource:"opportunities",record:{name:o,forecast:u}})}),m=t.useMemo(()=>({title:"Prepare opportunity brief",message:{user:"Prepare a brief for the selected opportunity.",workContext:[p]},autoSend:!1}),[p]),f=t.useMemo(()=>({[r.username]:[m]}),[r.username,m]);return e.jsx(R,{id:"preset-task-context-demo",defaultEmployee:r.username,employeeTasks:f,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:g,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected opportunity"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value, then select the preset task in the chat."})]}),e.jsx(b,{variant:"secondary",children:"Preset task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"preset-context-opportunity",children:"Opportunity"}),e.jsx(y,{id:"preset-context-opportunity",value:o,onChange:s=>c(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Forecast"}),e.jsxs(k,{value:u,onValueChange:s=>s&&d(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"pipeline",children:"Pipeline"}),e.jsx(l,{value:"likely",children:"Likely"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"No Shortcut is used here. “Prepare opportunity brief” comes from AIChatProvider.employeeTasks and appears in the conversation empty state."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Ie(){const{employees:n}=F(),r=n.filter(V)[0],o=D(),[c,u]=t.useState("Northwind Finance"),[d,p]=t.useState("negotiation"),g=t.useMemo(()=>({type:"page-element",id:"inherited-renewal-context",title:"Current account renewal"}),[]),m=M({id:"inherited-renewal-context",title:"Current account renewal",kind:"record-detail",getContext:()=>({resource:"accounts",record:{accountName:c,stage:d}})}),f=t.useMemo(()=>({title:"Review current renewal",message:{user:"Review the current account renewal."},autoSend:!1}),[]),s=t.useMemo(()=>({title:"Recommend next renewal action",message:{user:"Recommend the next renewal action."},autoSend:!1}),[]),I=t.useMemo(()=>({[r.username]:[s]}),[r.username,s]);return e.jsx(J,{context:g,children:e.jsx(R,{id:"inherited-context-demo",controller:o,defaultEmployee:r.username,employeeTasks:I,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Current account renewal"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Shortcut and conversation are inside this context scope."})]}),e.jsx(b,{variant:"outline",children:"Inherited"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"inherited-account-name",children:"Account"}),e.jsx(y,{id:"inherited-account-name",value:c,onChange:h=>u(h.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Renewal stage"}),e.jsxs(k,{value:d,onValueChange:h=>h&&p(h),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"discovery",children:"Discovery"}),e.jsx(l,{value:"negotiation",children:"Negotiation"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Shortcut task without message.workContext"}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:"Review current renewal",size:34})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"The preset task “Recommend next renewal action” also has no task context, so it inherits this scope."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function E({eyebrow:n,title:r,description:o,children:c}){return e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:n}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:r}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:o})]}),c]})}export{Ve as PageContextPage};
|
|
73
|
+
${c}`},autoSend:!0}),[c]);return e.jsx(J,{context:m,children:e.jsx(R,{id:"form-filler-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[610px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"space-y-5 bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Source content"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Edit this text, then ask the AI employee to fill the registered form below."})]}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:`Ask ${r.nickname}`,size:34})]})}),e.jsx(P,{children:e.jsx(U,{value:c,onChange:s=>u(s.target.value),className:"min-h-28"})})]}),e.jsxs("form",{ref:g,className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b p-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Lead intake form"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Form filler changes visible values only. It never submits the form."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"secondary",children:"useAIForm"}),e.jsx(pe,{type:"button",variant:"outline",size:"sm",onClick:()=>d.reset({company:"",contactName:"",email:"",priority:"normal"}),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-4 p-5 sm:grid-cols-2",children:[e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-company",children:"Company"}),e.jsx(y,{id:"form-filler-company",...d.register("company")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-contact",children:"Contact name"}),e.jsx(y,{id:"form-filler-contact",...d.register("contactName")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"form-filler-email",children:"Email"}),e.jsx(y,{id:"form-filler-email",type:"email",...d.register("email")})]}),e.jsxs("label",{className:"space-y-2",children:[e.jsx(i,{children:"Priority"}),e.jsxs(k,{value:d.watch("priority"),onValueChange:s=>s&&d.setValue("priority",s,{shouldDirty:!0,shouldTouch:!0}),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"normal",children:"Normal"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[610px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Ae(){const{employees:n}=F(),r=n.filter(L)[0],o=D(),[c,u]=t.useState(0),[d,p]=t.useState("Not reviewed"),g=24e3,m=g*(1-c/100),f=t.useMemo(()=>[{name:"update_quote_discount",title:"Update quote discount",description:"Update the discount percentage and review note shown on the current quote. This changes the page preview only and does not save the quote.",permission:"ASK",inputSchema:{type:"object",properties:{discountPercent:{type:"number",minimum:0,maximum:30,description:"Discount percentage applied to the quote."},note:{type:"string",description:"Short explanation shown in the review note."}},required:["discountPercent","note"],additionalProperties:!1},execute:h=>{const v=h&&typeof h=="object"&&!Array.isArray(h)?h:{};return typeof v.discountPercent!="number"||v.discountPercent<0||v.discountPercent>30||typeof v.note!="string"?{status:"error",content:"Provide a discount from 0 to 30 and a review note."}:(u(v.discountPercent),p(v.note),{status:"success",content:`Updated the quote preview to a ${v.discountPercent}% discount.`})}}],[]),s=ge({id:"quote-review-card",title:"Quote review",kind:"record-detail",tools:f,getContext:()=>({resource:"quotes",record:{quoteNumber:"QT-2026-1048",customer:"Northwind Studio",baseAmount:g,discountPercent:c,total:m,approvalNote:d}})}),I=t.useMemo(()=>({title:"Apply review discount",message:{user:"Update the current quote preview to use a 12% discount and set the review note to 'Approved for the renewal discussion'."},autoSend:!0}),[]);return e.jsx(J,{context:s.context,children:e.jsx(R,{id:"custom-frontend-tool-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:s.ref,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Quote review"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"QT-2026-1048 · Northwind Studio"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"outline",children:"Custom Tool"}),e.jsx(b,{variant:"secondary",children:"ASK"})]})]})}),e.jsxs(P,{className:"space-y-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[["Base amount",`$${g.toLocaleString()}`],["Discount",`${c}%`],["Preview total",`$${m.toLocaleString()}`]].map(([h,v])=>e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:h}),e.jsx("div",{className:"mt-1 font-medium",children:v})]},h))}),e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Review note"}),e.jsx("div",{className:"mt-1 text-sm",children:d})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t pt-4",children:[e.jsx("p",{className:"max-w-lg text-xs leading-5 text-muted-foreground",children:"The page element registers update_quote_discount. Its full input schema is loaded only when the AI chooses this Tool. Approval is controlled by the ASK permission."}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[I],label:`Ask ${r.nickname}`,size:34})]})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function Te(){const{employees:n}=F(),r=n.filter(L)[0],o=D(),[c,u]=t.useState("Payment callback reached the order service twelve minutes late."),[d,p]=t.useState("high"),g=t.useMemo(()=>({type:"page-element",id:"selected-support-case",title:"Selected support case"}),[]),m=M({id:"selected-support-case",title:"Selected support case",kind:"editable-record",getContext:()=>({resource:"supportTickets",values:{summary:c,severity:d}})}),f=t.useMemo(()=>({title:"Analyze selected case",message:{user:"Analyze the selected support case.",workContext:[g]},autoSend:!1}),[g]);return e.jsx(R,{id:"shortcut-task-context-demo",controller:o,defaultEmployee:r.username,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsxs("div",{className:"bg-muted/15 p-4 sm:p-5",children:[e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected support case"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value before running either task."})]}),e.jsx(b,{variant:"secondary",children:"Task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"selected-context-summary",children:"Summary"}),e.jsx(y,{id:"selected-context-summary",value:c,onChange:s=>u(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Severity"}),e.jsxs(k,{value:d,onValueChange:s=>s&&p(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"low",children:"Low"}),e.jsx(l,{value:"medium",children:"Medium"}),e.jsx(l,{value:"high",children:"High"})]})]})]})]})]}),e.jsxs(j,{className:"mt-5 border-dashed bg-background/80",children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Task shortcut area"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"This button is outside the selected page element. Its task explicitly references “Selected support case”."})]}),e.jsx(b,{variant:"outline",children:"Explicit reference"})]})}),e.jsx(P,{children:e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:"Analyze selected case",size:34})})]})]}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Pe(){const{employees:n}=F(),r=n.filter(L)[0],[o,c]=t.useState("Enterprise workspace expansion"),[u,d]=t.useState("likely"),p=t.useMemo(()=>({type:"page-element",id:"selected-opportunity",title:"Selected opportunity"}),[]),g=M({id:"selected-opportunity",title:"Selected opportunity",kind:"record-detail",getContext:()=>({resource:"opportunities",record:{name:o,forecast:u}})}),m=t.useMemo(()=>({title:"Prepare opportunity brief",message:{user:"Prepare a brief for the selected opportunity.",workContext:[p]},autoSend:!1}),[p]),f=t.useMemo(()=>({[r.username]:[m]}),[r.username,m]);return e.jsx(R,{id:"preset-task-context-demo",defaultEmployee:r.username,employeeTasks:f,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:g,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Selected opportunity"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Change a value, then select the preset task in the chat."})]}),e.jsx(b,{variant:"secondary",children:"Preset task context"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"preset-context-opportunity",children:"Opportunity"}),e.jsx(y,{id:"preset-context-opportunity",value:o,onChange:s=>c(s.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Forecast"}),e.jsxs(k,{value:u,onValueChange:s=>s&&d(s),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"pipeline",children:"Pipeline"}),e.jsx(l,{value:"likely",children:"Likely"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"No Shortcut is used here. “Prepare opportunity brief” comes from AIChatProvider.employeeTasks and appears in the conversation empty state."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})}function Ie(){const{employees:n}=F(),r=n.filter(L)[0],o=D(),[c,u]=t.useState("Northwind Finance"),[d,p]=t.useState("negotiation"),g=t.useMemo(()=>({type:"page-element",id:"inherited-renewal-context",title:"Current account renewal"}),[]),m=M({id:"inherited-renewal-context",title:"Current account renewal",kind:"record-detail",getContext:()=>({resource:"accounts",record:{accountName:c,stage:d}})}),f=t.useMemo(()=>({title:"Review current renewal",message:{user:"Review the current account renewal."},autoSend:!1}),[]),s=t.useMemo(()=>({title:"Recommend next renewal action",message:{user:"Recommend the next renewal action."},autoSend:!1}),[]),I=t.useMemo(()=>({[r.username]:[s]}),[r.username,s]);return e.jsx(J,{context:g,children:e.jsx(R,{id:"inherited-context-demo",controller:o,defaultEmployee:r.username,employeeTasks:I,children:e.jsx(j,{className:"gap-0 overflow-hidden py-0",children:e.jsxs("div",{className:"grid min-h-[560px] xl:grid-cols-[minmax(0,1fr)_410px]",children:[e.jsx("div",{className:"bg-muted/15 p-4 sm:p-5",children:e.jsxs(j,{ref:m,children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(T,{children:"Current account renewal"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Shortcut and conversation are inside this context scope."})]}),e.jsx(b,{variant:"outline",children:"Inherited"})]})}),e.jsxs(P,{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{htmlFor:"inherited-account-name",children:"Account"}),e.jsx(y,{id:"inherited-account-name",value:c,onChange:h=>u(h.target.value)})]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsx(i,{children:"Renewal stage"}),e.jsxs(k,{value:d,onValueChange:h=>h&&p(h),children:[e.jsx(N,{className:"w-full",children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(l,{value:"discovery",children:"Discovery"}),e.jsx(l,{value:"negotiation",children:"Negotiation"}),e.jsx(l,{value:"committed",children:"Committed"})]})]})]}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Shortcut task without message.workContext"}),e.jsx(_,{aiEmployee:r.username,target:o,tasks:[f],label:"Review current renewal",size:34})]}),e.jsx("div",{className:"rounded-lg border bg-background p-3 text-xs leading-5 text-muted-foreground",children:"The preset task “Recommend next renewal action” also has no task context, so it inherits this scope."})]})]})}),e.jsx("div",{className:"min-h-0 border-t bg-card xl:border-l xl:border-t-0",children:e.jsx($,{className:"h-[560px] rounded-none border-0",children:e.jsx(B,{showConversationToggle:!1,disclaimer:!1})})})]})})})})}function E({eyebrow:n,title:r,description:o,children:c}){return e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:n}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:r}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:o})]}),c]})}export{Me as PageContextPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as o}from"./index-Cc6awvdg.js";import{P as p}from"./prompt-output-B4h3uLWf.js";function x({title:r,description:t,prompt:m}){return o.jsx(p,{title:r,description:t,prompt:m,promptClassName:"max-h-[620px]"})}export{x as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as o,j as e,C as f,K as h,G as j,bF as y,c as i}from"./index-Cc6awvdg.js";function w({className:c,copiedLabel:n="Copied",copyErrorLabel:p="Clipboard access failed. Select the prompt and copy it manually.",copyLabel:d="Copy prompt",description:l,prompt:t,promptClassName:x,title:m="Generated prompt"}){const[s,a]=o.useState(!1),[u,r]=o.useState(!1);return e.jsxs(f,{className:i("min-w-0 gap-0 overflow-hidden py-0",c),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium",children:m}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l})]}),e.jsxs(h,{type:"button",size:"sm",className:"shrink-0",onClick:async()=>{try{await navigator.clipboard.writeText(t),r(!1),a(!0),window.setTimeout(()=>a(!1),1500)}catch{r(!0)}},children:[s?e.jsx(j,{}):e.jsx(y,{}),s?n:d]})]}),u?e.jsx("p",{className:"border-b px-4 py-2 text-xs text-destructive",children:p}):null,e.jsx("pre",{className:i("max-h-[560px] overflow-auto whitespace-pre-wrap bg-muted/25 p-5 font-mono text-xs leading-5 text-muted-foreground",x),children:t})]})}export{w as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b5 as m,b as o,b6 as g,b7 as d,j as t,aN as b,aP as f,aQ as h,K as x,b8 as v,r as S}from"./index-Cc6awvdg.js";function p(r){const[e]=m(),[i,a]=o.useState(!1),[n,l]=o.useState(),u=o.useMemo(()=>{if(e.get("authenticator")!==r.name)return;const s=e.get("error");return s?new Error(s):void 0},[r.name,e]);return{signIn:o.useCallback(async()=>{l(void 0),a(!0);try{const s=g(e.get("to")||e.get("redirect")||"/"),c=await d.action("saml","getAuthUrl",{method:"POST",authenticator:r.name,includeRole:!1,withAclMeta:!1,body:{redirect:s}});if(!c)throw new Error("NocoBase did not return a SAML authorization URL.");window.location.replace(d.resolveUrl(c))}catch(s){l(s instanceof Error?s:new Error("Unable to start SAML sign-in.")),a(!1)}},[r.name,e]),isPending:i,error:n??u}}function j({authenticator:r,onSignIn:e}){const{signIn:i,isPending:a,error:n}=p(r);return t.jsxs("div",{className:"space-y-3",children:[n&&t.jsxs(b,{variant:"destructive",children:[t.jsx(f,{children:"SAML sign-in failed"}),t.jsx(h,{children:n.message})]}),t.jsxs(x,{type:"button",variant:"outline",className:"w-full",disabled:!e&&a,onClick:e??i,children:[t.jsx(v,{}),!e&&a?"Redirecting…":S(r.title||r.authTypeTitle||"SAML")]})]})}export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as m,P as y,H as A,m as I,aq as R}from"./echarts-runtime-
|
|
1
|
+
import{_ as m,P as y,H as A,m as I,aq as R}from"./echarts-runtime-Ce_z2eX_.js";var p=(function(){function u(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0}return u})(),b=(function(u){m(s,u);function s(a){var r=u.call(this,a)||this;return r.type="sausage",r}return s.prototype.getDefaultShape=function(){return new p},s.prototype.buildPath=function(a,r){var e=r.cx,i=r.cy,o=Math.max(r.r0||0,0),h=Math.max(r.r,0),d=(h-o)*.5,v=o+d,t=r.startAngle,n=r.endAngle,c=r.clockwise,l=Math.PI*2,M=c?n-t<l:t-n<l;M||(t=n-(c?l:-l));var f=Math.cos(t),g=Math.sin(t),P=Math.cos(n),S=Math.sin(n);M?(a.moveTo(f*o+e,g*o+i),a.arc(f*v+e,g*v+i,d,-Math.PI+t,t,!c)):a.moveTo(f*h+e,g*h+i),a.arc(e,i,h,t,n,!c),a.arc(P*v+e,S*v+i,d,n-Math.PI*2,n-Math.PI,!c),o!==0&&a.arc(e,i,o,n,t,c)},s})(y);function k(u,s,a){var r=u.get("borderRadius");if(r==null)return a?{cornerRadius:0}:null;A(r)||(r=[r,r,r,r]);var e=Math.abs(s.r||0-s.r0||0);return{cornerRadius:I(r,function(i){return R(i,e)})}}export{b as S,k as g};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import{b as c,ah as ye,ai as Pe,aj as Ee,ak as we,al as H,j as e,am as Re,an as $e,ao as Ue,ap as We,aq as ze,ar as de,as as De,at as Be,au as Ne,av as Oe,aw as Ce,ax as Fe,ay as Le,az as Ve,c as Q,F as qe,aA as _e,aB as Se,ae as He,aC as Ge,B as Y,aD as Ke,C as X,aE as ee,a6 as ce,k as te,l as se,n as ae,_ as me,$ as ue,aa as Je,aF as Z,d as O,e as F,f as L,g as V,i as S,I as he,K as J,P as Xe,O as Qe,h as Ye,aG as Ze,T as pe,ab as et,aH as tt,aI as st}from"./index-Cc6awvdg.js";import{S as xe}from"./switch-BdVxPIVU.js";import{P as at}from"./prompt-card-rGZqpqkF.js";import{A as nt}from"./configuration-gate-B4XVz7tS.js";import"./prompt-output-B4h3uLWf.js";const Ae=c.createContext(void 0);function Ie(){const a=c.useContext(Ae);if(a===void 0)throw new Error(ye(10));return a}const ot={value:()=>null},it=c.forwardRef(function(o,m){const{render:x,className:k,disabled:r=!1,hiddenUntilFound:u,keepMounted:i,loopFocus:y,onValueChange:g,multiple:$=!1,orientation:f="vertical",value:R,defaultValue:v,style:z,...w}=o,A=Pe(),I=c.useMemo(()=>{if(R===void 0)return v??[]},[R,v]),N=c.useRef([]),[d,b]=Ee({controlled:R,default:I,name:"Accordion",state:"value"}),M=we((P,D,p)=>{if($)if(D){const j=d.slice();if(j.push(P),g==null||g(j,p),p.isCanceled)return;b(j)}else{const j=d.filter(B=>B!==P);if(g==null||g(j,p),p.isCanceled)return;b(j)}else{const j=d[0]===P?[]:[P];if(g==null||g(j,p),p.isCanceled)return;b(j)}}),h=c.useMemo(()=>({value:d,disabled:r,orientation:f}),[d,r,f]),T=c.useMemo(()=>({disabled:r,handleValueChange:M,hiddenUntilFound:u??!1,keepMounted:i??!1,state:h,value:d}),[r,M,u,i,h,d]),l=H("div",o,{state:h,ref:m,props:[{dir:A},w],stateAttributesMapping:ot});return e.jsx(Ae.Provider,{value:T,children:e.jsx(Re,{elementsRef:N,children:l})})}),Me=c.createContext(void 0);function ne(){const a=c.useContext(Me);if(a===void 0)throw new Error(ye(9));return a}let lt=(function(a){return a.index="data-index",a.disabled="data-disabled",a.open="data-open",a})({});const oe={...Ue,index:a=>Number.isInteger(a)?{[lt.index]:String(a)}:null,...$e,value:()=>null},rt=c.forwardRef(function(o,m){const{className:x,disabled:k=!1,onOpenChange:r,render:u,value:i,style:y,...g}=o,{ref:$,index:f}=We(),R=ze(m,$),{disabled:v,handleValueChange:z,state:w,value:A}=Ie(),I=de(),N=i??I,d=k||v,b=c.useMemo(()=>{if(!A)return!1;for(let E=0;E<A.length;E+=1)if(A[E]===N)return!0;return!1},[A,N]),M=we((E,W)=>{r==null||r(E,W),!W.isCanceled&&z(N,E,W)}),h=De({open:b,onOpenChange:M,disabled:d}),T=c.useMemo(()=>({open:h.open,disabled:h.disabled,transitionStatus:h.transitionStatus}),[h.open,h.disabled,h.transitionStatus]),l=c.useMemo(()=>({...h,onOpenChange:M,state:T}),[h,T,M]),P=c.useMemo(()=>({...w,hidden:!b&&!h.mounted,index:f,disabled:d,open:b}),[h.mounted,d,f,b,w]),D=de(),[p,j]=c.useState(),B=c.useMemo(()=>({open:b,state:P,setTriggerId:j,triggerId:p??D}),[D,b,P,j,p]),q=H("div",o,{state:P,ref:R,props:g,stateAttributesMapping:oe});return e.jsx(Be.Provider,{value:l,children:e.jsx(Me.Provider,{value:B,children:q})})}),dt=c.forwardRef(function(o,m){const{render:x,className:k,style:r,...u}=o,{state:i}=ne();return H("h3",o,{state:i,ref:m,props:u,stateAttributesMapping:oe})}),ct=c.forwardRef(function(o,m){const{disabled:x,className:k,id:r,render:u,nativeButton:i=!0,style:y,...g}=o,{panelId:$,open:f,handleTrigger:R,disabled:v}=Ne(),z=x||v,{getButtonProps:w,buttonRef:A}=Oe({disabled:z,focusableWhenDisabled:!0,native:i}),{state:I,setTriggerId:N,triggerId:d}=ne();return Ce(()=>(r&&N(r),()=>{N(void 0)}),[r,N]),H("button",o,{state:I,ref:[m,A],props:[{"aria-controls":f?$:void 0,"aria-expanded":f,id:d,onClick:R},g,w],stateAttributesMapping:Fe})});let ge=(function(a){return a.accordionPanelHeight="--accordion-panel-height",a.accordionPanelWidth="--accordion-panel-width",a})({});const mt=c.forwardRef(function(o,m){const{className:x,hiddenUntilFound:k,keepMounted:r,id:u,render:i,style:y,...g}=o,{hiddenUntilFound:$,keepMounted:f}=Ie(),{mounted:R,onOpenChange:v,open:z,panelId:w,setMounted:A,setOpen:I,setPanelIdState:N,transitionStatus:d}=Ne(),b=k??$,M=r??f;Ce(()=>{if(u)return N(u),()=>{N(void 0)}},[u,N]);const{height:h,props:T,ref:l,shouldPreventOpenAnimation:P,shouldRender:D,transitionStatus:p,width:j}=Le({externalRef:m,hiddenUntilFound:b,id:u??w,keepMounted:M,mounted:R,onOpenChange:v,open:z,setMounted:A,setOpen:I,transitionStatus:d}),{state:B,triggerId:q}=ne(),E={...B,transitionStatus:p},W=Ve(y,E),G=H("div",{...o,style:void 0},{state:E,ref:l,props:[T,{"aria-labelledby":q,role:"region",style:{[ge.accordionPanelHeight]:h===void 0?"auto":`${h}px`,[ge.accordionPanelWidth]:j===void 0?"auto":`${j}px`}},g,W?{style:W}:void 0,P?{style:{animationName:"none"}}:void 0],stateAttributesMapping:oe});return D?G:null});function ut({className:a,...o}){return e.jsx(it,{"data-slot":"accordion",className:Q("flex w-full flex-col",a),...o})}function ht({className:a,...o}){return e.jsx(rt,{"data-slot":"accordion-item",className:Q("not-last:border-b",a),...o})}function pt({className:a,children:o,...m}){return e.jsx(dt,{className:"flex",children:e.jsxs(ct,{"data-slot":"accordion-trigger",className:Q("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",a),...m,children:[o,e.jsx(qe,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),e.jsx(_e,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function xt({className:a,children:o,...m}){return e.jsx(mt,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up",...m,children:e.jsx("div",{className:Q("h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",a),children:o})})}const fe={title:"Analyze this ticket",message:{system:"Review the current ticket, identify operational risk, and suggest the next action.",user:"Analyze the current ticket and recommend the next action."},autoSend:!0,model:{llmService:"openai",model:"gpt-5"},webSearch:!0,skillSettings:{skills:["ticket-analysis"],tools:["inspect-record"]}},be={title:"Draft a customer reply",message:{user:"Draft a concise customer reply for the current ticket."},autoSend:!1,skillSettings:{skills:["response-drafting"],tools:["inspect-record"]}},je={title:"Review operational risk",message:{system:"Review the current queue, identify operational risk, and prioritize the next actions.",user:"Review the current ticket queue and identify operational risk."},autoSend:!1,skillSettings:{skills:["ticket-analysis"],tools:["inspect-record"]}},C={id:"TK-1042",title:"Payment callback delayed",status:"Open",requester:"Northwind Finance",createdAt:"July 22, 2026 · 09:42",description:"Payment succeeded, but the callback reached the order service twelve minutes late. The customer needs an impact assessment and a response before the next settlement window."},gt=[C,{id:"TK-1041",title:"Unable to update profile"},{id:"TK-1038",title:"Invoice export formatting"}],Te=a=>!["nathan","dara"].includes(a.username.toLowerCase());function St(){return e.jsx(nt,{children:e.jsx(ft,{})})}function ft(){const{employees:a}=Se(),o=He(),m=a.filter(Te),x=m.find(y=>y.username.toLowerCase()==="atlas")??m[0],k=m.find(y=>y.username!==x.username)??x,r=m.find(y=>y.username.toLowerCase()==="atlas")??m.find(y=>y.username!==x.username)??x,u=Ge({id:"support-ticket-detail",title:`${C.id} · ${C.title}`,kind:"record-detail",getContext:()=>({resource:"supportTickets",record:C})}),i=c.useMemo(()=>({[x.username]:[fe,be],...k.username!==x.username?{[k.username]:[je]}:{}}),[x.username,k.username]);return e.jsxs("div",{className:"space-y-12 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{variant:"secondary",children:"AI Components"}),e.jsx(Y,{variant:"outline",children:"Employee capability"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Employee tasks"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Bind reusable tasks to AI employees. Tasks can appear directly inside a chat when the employee is selected, or be triggered from contextual buttons elsewhere in the application."})]})}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Scenario 1 · Multiple tasks"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Trigger employee tasks from a business record"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"The Shortcut component can still sit in a detail header and provide the current record as work context. Opening it shows the configured analysis and reply tasks below the employee greeting."})]}),e.jsx(Ke,{context:{type:"page-element",id:"support-ticket-detail",title:`${C.id} · ${C.title}`},children:e.jsxs(X,{ref:u,className:"gap-0 overflow-hidden py-0",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b p-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:C.id}),e.jsx(Y,{variant:"outline",children:C.status})]}),e.jsx("h3",{className:"mt-2 text-lg font-semibold tracking-tight",children:C.title})]}),e.jsx(ee,{aiEmployee:x.username,tasks:[fe,be],label:`Ask ${x.nickname}`,size:34})]}),e.jsxs("div",{className:"grid gap-5 p-5 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Requester"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:C.requester})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Created"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:C.createdAt})]})]}),e.jsxs("div",{className:"border-t p-5",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6",children:C.description})]})]})})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Scenario 2 · Explicit target"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Send a shortcut task to a designated embedded chat"}),e.jsxs("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:["The shortcut receives the embedded chat Controller directly. Its Provider explicitly configures ",r.nickname," and an employee task set. It does not need a global target ID and cannot accidentally trigger another conversation on the same page."]})]}),e.jsx(ce,{id:"shortcut-embedded-chat",controller:o,defaultEmployee:r.username,children:e.jsxs("div",{className:"grid items-stretch gap-5 xl:grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs(X,{children:[e.jsx(te,{children:e.jsx(se,{className:"text-base",children:"Risk review workspace"})}),e.jsxs(ae,{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"The embedded chat starts without preset tasks. Clicking the Shortcut injects “Review operational risk” into this specific conversation, where the user can choose it before the request is placed in the composer."}),e.jsx(ee,{aiEmployee:r.username,target:o,tasks:[je],auto:!1,context:[{type:"table",title:"Open ticket queue",content:gt}],label:`Ask ${r.nickname}`,size:36})]})]}),e.jsx(me,{className:"h-[560px] min-h-0",children:e.jsx(ue,{})})]})})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Scenario 3 · Chat-bound tasks"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Show tasks when the selected employee changes"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"This conversation window binds task lists directly to business AI employees. Starting a new conversation or switching employees in the composer immediately replaces the empty-state tasks. Employees without a binding keep the normal greeting-only state."})]}),e.jsxs("div",{className:"grid items-stretch gap-5 xl:grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs(X,{children:[e.jsx(te,{children:e.jsx(se,{className:"text-base",children:"Employee task bindings"})}),e.jsxs(ae,{className:"space-y-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/25 p-3 font-mono text-xs leading-5",children:[e.jsx("div",{children:x.username}),e.jsx("div",{className:"pl-4",children:"Analyze this ticket"}),e.jsx("div",{className:"pl-4",children:"Draft a customer reply"}),k.username!==x.username?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2",children:k.username}),e.jsx("div",{className:"pl-4",children:"Review operational risk"})]}):null]}),e.jsx("p",{children:"Switch employees from the bottom of the chat to preview each configured task list."}),e.jsxs("p",{children:["The same ",e.jsx("code",{children:"employeeTasks"})," parameter works in page, embedded, side-panel, dialog, and mobile containers."]})]})]}),e.jsx(ce,{id:"employee-task-scenario-chat",defaultEmployee:x.username,employeeTasks:i,children:e.jsx(me,{className:"h-[620px] min-h-0",children:e.jsx(ue,{})})})]})]}),e.jsx(kt,{embeddedController:o})]})}const bt=[{value:"ticket-analysis",label:"Ticket analysis"},{value:"response-drafting",label:"Response drafting"},{value:"workflow-design",label:"Workflow design"}],jt=[{value:"inspect-record",label:"Inspect record"},{value:"search-records",label:"Search records"},{value:"update-record",label:"Update record"}],ke=[{id:"analyze-ticket",employee:"",title:"Analyze this ticket",background:"Identify operational risk and recommend the next action.",userMessage:"Analyze the current ticket and recommend the next action.",autoSend:!0,workContext:[{type:"page-element",id:"support-ticket-detail",title:`${C.id} · ${C.title}`}],model:"gpt-5",webSearch:!0,skillsMode:"custom",skills:["ticket-analysis"],toolsMode:"custom",tools:["inspect-record"]},{id:"draft-reply",employee:"",title:"Draft a customer reply",background:"Write a concise and helpful response using the ticket context.",userMessage:"Draft a customer reply for the current ticket.",autoSend:!1,workContext:[],model:"default",webSearch:!1,skillsMode:"custom",skills:["response-drafting"],toolsMode:"preset",tools:[]}];function kt({embeddedController:a}){var E,W,G,ie,le;const{employees:o,models:m}=Se(),{registeredCount:x,startPicking:k}=Je(),r=o.filter(Te),u=r.find(t=>t.username.toLowerCase()==="atlas")??r[0],[i,y]=c.useState("shortcut"),[g,$]=c.useState("the ticket detail header actions"),[f,R]=c.useState(u.username),[v,z]=c.useState(u.username),[w,A]=c.useState("global-side-panel"),[I,N]=c.useState("embedded"),[d,b]=c.useState(()=>ke.map(t=>({...t,employee:u.username}))),[M,h]=c.useState(ke[0].id),T=i==="chat-tasks"?d.filter(t=>t.employee===v):d,l=T.find(t=>t.id===M)??T[0],P=c.useMemo(()=>d.map(t=>{const n=Z(m,t.model),s=t.skillsMode==="custom"||t.toolsMode==="custom";return{title:t.title,message:{system:t.background||void 0,user:t.userMessage||void 0,workContext:t.workContext.length?t.workContext:void 0},autoSend:t.autoSend,model:n?{llmService:n.llmService,model:n.value}:void 0,webSearch:t.webSearch,skillSettings:s?{skills:t.skillsMode==="custom"?t.skills:void 0,tools:t.toolsMode==="custom"?t.tools:void 0}:void 0}}),[m,d]),D=c.useMemo(()=>{const t=(s,U)=>{var re;const _=s.model==="default"?"Use the AI employee default":((re=m.find(K=>K.value===s.model))==null?void 0:re.label)??s.model;return`${U+1}. ${s.title}
|
|
2
|
+
- Background: ${s.background||"None"}
|
|
3
|
+
- Default user message: ${s.userMessage||"None"}
|
|
4
|
+
- Send automatically: ${s.autoSend}
|
|
5
|
+
- Work context: ${s.workContext.map(K=>K.title??K.id).join(", ")||"Inherit the surrounding context"}
|
|
6
|
+
- Model: ${_}
|
|
7
|
+
- Web search: ${s.webSearch}
|
|
8
|
+
- Skills: ${s.skillsMode==="preset"?"Use the AI employee defaults":s.skills.join(", ")||"Disabled"}
|
|
9
|
+
- Tools: ${s.toolsMode==="preset"?"Use the AI employee defaults":s.tools.join(", ")||"Disabled"}`},n=i==="chat-tasks"?Array.from(new Set(d.map(s=>s.employee))).map(s=>{const U=d.filter(_=>_.employee===s);return`AI employee: ${s}
|
|
10
|
+
${U.map(t).join(`
|
|
11
|
+
`)}`}).join(`
|
|
12
|
+
|
|
13
|
+
`):d.map(t).join(`
|
|
14
|
+
`);if(i==="chat-tasks"){const s={page:"a dedicated page",embedded:"an embedded block in the page","side-panel":"a push side panel",dialog:"a dialog"}[I];return`Add an AI conversation window to ${g} using ${s}.
|
|
15
|
+
|
|
16
|
+
Employee task bindings:
|
|
17
|
+
${n}
|
|
18
|
+
|
|
19
|
+
Implementation requirements:
|
|
20
|
+
- Render AIChatWindow in the selected container and wrap it with AIChatProvider.
|
|
21
|
+
- Configure AIChatProvider with employeeTasks grouped by AI employee username.
|
|
22
|
+
- When the user starts a new conversation or switches AI employees, show the matching tasks below that employee’s greeting.
|
|
23
|
+
- Employees without configured tasks must keep the greeting-only empty state.
|
|
24
|
+
- Selecting a task must respect autoSend: either send immediately or fill the composer for review.
|
|
25
|
+
- Resolve task message.workContext when the task starts so selected page elements use their latest values.
|
|
26
|
+
- When a task has no message.workContext, inherit the context surrounding the Shortcut or AIChatProvider.
|
|
27
|
+
- Preserve every task’s background prompt, model override, Web search setting, Skills, Tools, and work context.
|
|
28
|
+
- Keep the employeeTasks capability independent of the container so the same configuration works in page, embedded, side-panel, dialog, and mobile layouts.
|
|
29
|
+
- Use the existing AIProvider/AIChatProvider runtime with shadcn/Base UI components.`}return`Add an AI employee shortcut to ${g}.
|
|
30
|
+
|
|
31
|
+
Shortcut configuration:
|
|
32
|
+
- AI employee: ${f}
|
|
33
|
+
- Target conversation: ${w==="global-side-panel"?"the default global push side panel":"the embedded chat rendered in this page section"}
|
|
34
|
+
- Include the current record or form values as work context.
|
|
35
|
+
|
|
36
|
+
Tasks:
|
|
37
|
+
${n}
|
|
38
|
+
|
|
39
|
+
Implementation requirements:
|
|
40
|
+
- Use AIEmployeeShortcut and pass all configured tasks through its tasks prop.
|
|
41
|
+
- When multiple tasks are provided, open a new conversation and show the tasks below the AI employee greeting.
|
|
42
|
+
- Selecting a task must respect that task's autoSend setting: either send immediately or fill the composer for review.
|
|
43
|
+
- Resolve task message.workContext when the task starts so selected page elements use their latest values.
|
|
44
|
+
- When a task has no message.workContext, inherit the context surrounding the Shortcut or AIChatProvider.
|
|
45
|
+
- Preserve each task's background prompt, work context, model override, Web search setting, Skills, and Tools.
|
|
46
|
+
- ${w==="global-side-panel"?"Use the global AI chat controller; do not pass a target prop.":"Create a dedicated controller with useAIChatController(), bind it to the embedded AIChatProvider, and pass it through the shortcut target prop."}
|
|
47
|
+
- Use the existing AIProvider and AIChatProvider runtime with shadcn/Base UI components.`},[I,f,i,g,m,w,d]),p=t=>{l&&b(n=>n.map(s=>s.id===l.id?{...s,...t}:s))},j=()=>{const t=`task-${crypto.randomUUID()}`;b(n=>[...n,{id:t,employee:i==="chat-tasks"?v:f,title:`Task ${n.length+1}`,background:"",userMessage:"",autoSend:!1,workContext:[],model:"default",webSearch:!1,skillsMode:"preset",skills:[],toolsMode:"preset",tools:[]}]),h(t)},B=t=>{if(d.length===1)return;const n=d.filter(s=>s.id!==t);if(b(n),M===t){const s=i==="chat-tasks"?n.find(U=>U.employee===v):n[0];h((s==null?void 0:s.id)??"")}},q=(t,n,s)=>{if(!l)return;const U=l[t];p({[t]:s?[...U,n]:U.filter(_=>_!==n)})};return e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Employee tasks prompt"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:"Generate an integration prompt"}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Choose whether tasks are exposed through a contextual Shortcut or directly by the selected employee in a chat. Both modes share the same task, model, Web search, Skills, and Tools configuration."})]}),e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(X,{className:"gap-0 py-0",children:[e.jsx(te,{className:"py-4",children:e.jsx(se,{className:"text-base",children:"Employee task configuration"})}),e.jsxs(ae,{className:"space-y-4 pb-4",children:[e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Integration"}),e.jsxs(O,{value:i,onValueChange:t=>{if(!t)return;const n=t;y(n),$(n==="shortcut"?"the ticket detail header actions":"the ticket detail page");const s=n==="chat-tasks"?d.find(U=>U.employee===v):d[0];h((s==null?void 0:s.id)??"")},children:[e.jsx(F,{className:"w-full",children:e.jsx(L,{children:i==="shortcut"?"Contextual Shortcut":"Tasks inside a chat"})}),e.jsxs(V,{children:[e.jsx(S,{value:"shortcut",children:"Contextual Shortcut"}),e.jsx(S,{value:"chat-tasks",children:"Tasks inside a chat"})]})]})]}),i==="chat-tasks"?e.jsxs("label",{className:"block space-y-2 border-t pt-4 text-xs font-medium",children:[e.jsx("span",{children:"AI employee"}),e.jsxs(O,{value:v,onValueChange:t=>{var n;t&&(z(t),h(((n=d.find(s=>s.employee===t))==null?void 0:n.id)??""))},children:[e.jsx(F,{className:"w-full",children:e.jsx(L,{children:((E=r.find(t=>t.username===v))==null?void 0:E.nickname)??v})}),e.jsx(V,{children:r.map(t=>e.jsx(S,{value:t.username,children:t.nickname},t.username))})]}),e.jsx("span",{className:"block font-normal leading-5 text-muted-foreground",children:"Select an employee first, then configure the tasks shown in that employee’s new-conversation state."})]}):null,e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[i==="shortcut"?e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"AI employee"}),e.jsxs(O,{value:f,onValueChange:t=>t&&R(t),children:[e.jsx(F,{className:"w-full",children:e.jsx(L,{children:((W=r.find(t=>t.username===f))==null?void 0:W.nickname)??f})}),e.jsx(V,{children:r.map(t=>e.jsx(S,{value:t.username,children:t.nickname},t.username))})]})]}):null,e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Placement"}),e.jsx(he,{value:g,onChange:t=>$(t.target.value)})]}),i==="chat-tasks"?e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Chat container"}),e.jsxs(O,{value:I,onValueChange:t=>t&&N(t),children:[e.jsx(F,{className:"w-full",children:e.jsx(L,{children:{page:"Page",embedded:"Embedded block","side-panel":"Side panel",dialog:"Dialog"}[I]})}),e.jsxs(V,{children:[e.jsx(S,{value:"page",children:"Page"}),e.jsx(S,{value:"embedded",children:"Embedded block"}),e.jsx(S,{value:"side-panel",children:"Side panel"}),e.jsx(S,{value:"dialog",children:"Dialog"})]})]})]}):null]}),i==="shortcut"?e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Target conversation"}),e.jsxs(O,{value:w,onValueChange:t=>t&&A(t),children:[e.jsx(F,{className:"w-full",children:e.jsx(L,{children:w==="global-side-panel"?"Global side panel":"Embedded chat"})}),e.jsxs(V,{children:[e.jsx(S,{value:"global-side-panel",children:"Global side panel"}),e.jsx(S,{value:"embedded",children:"Embedded chat"})]})]})]}):null,e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Tasks"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[T.length," configured task",T.length===1?"":"s",i==="chat-tasks"?" for this employee":""]})]}),e.jsxs(J,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(Xe,{})," Add task"]})]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:T.map((t,n)=>e.jsxs("div",{className:t.id===(l==null?void 0:l.id)?"flex items-center gap-2 rounded-lg border border-foreground/25 bg-muted/60 p-1":"flex items-center gap-2 rounded-lg border p-1",children:[e.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-1.5 text-left",onClick:()=>h(t.id),children:[e.jsxs("span",{className:"block truncate text-xs font-medium",children:[n+1,". ",t.title]}),e.jsxs("span",{className:"block text-[10px] text-muted-foreground",children:[t.autoSend?"Auto send":"Fill composer",t.workContext.length?" · Task context":"",t.webSearch?" · Web search":""]})]}),e.jsx(J,{variant:"ghost",size:"icon-xs",disabled:d.length===1,"aria-label":`Remove ${t.title}`,onClick:()=>B(t.id),children:e.jsx(Qe,{})})]},t.id))})]}),l?e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Title"}),e.jsx(he,{value:l.title,onChange:t=>p({title:t.target.value})})]}),e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Model"}),e.jsxs(O,{value:l.model,onValueChange:t=>t&&p({model:t}),children:[e.jsx(F,{className:"w-full",children:e.jsx(L,{className:"min-w-0 overflow-hidden",children:e.jsx("span",{className:"block min-w-0 truncate",title:l.model==="default"?"Use employee default":((G=Z(m,l.model))==null?void 0:G.label)??l.model,children:l.model==="default"?"Use employee default":((ie=Z(m,l.model))==null?void 0:ie.label)??l.model})})}),e.jsxs(V,{children:[e.jsx(S,{value:"default",children:"Use employee default"}),e.jsx(Ye,{}),e.jsx(Ze,{models:m})]})]})]})]}),e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Default user message"}),e.jsx(pe,{className:"min-h-16",value:l.userMessage,onChange:t=>p({userMessage:t.target.value})})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5 text-sm",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"Auto send"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Otherwise the message is placed in the composer."})]}),e.jsx(xe,{size:"sm",checked:l.autoSend,onCheckedChange:t=>p({autoSend:t})})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Work context"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Select a page context for this task. Without one, the task inherits its surrounding context."})]}),e.jsxs(J,{variant:"outline",size:"sm",disabled:x===0,onClick:()=>k({onSelect:t=>p({workContext:[{type:t.type,id:t.id,title:t.title,kind:t.kind}]})}),children:[e.jsx(et,{})," Pick context"]})]}),l.workContext.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-xs",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title??t.id??t.type}),e.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Remove task context",onClick:()=>p({workContext:[]}),children:e.jsx(tt,{})})]},`${t.type}:${t.id??n}`))]}),e.jsx(ut,{children:e.jsxs(ht,{value:"advanced-task-settings",className:"rounded-lg border px-3",children:[e.jsx(pt,{className:"no-underline hover:no-underline",children:e.jsxs("span",{children:[e.jsx("span",{className:"block",children:"Advanced task settings"}),e.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:"Background, Web search, Skills, and Tools"})]})}),e.jsxs(xt,{className:"space-y-4 pt-1",children:[e.jsxs("label",{className:"block space-y-2 text-xs font-medium",children:[e.jsx("span",{children:"Background"}),e.jsx(pe,{className:"min-h-16",value:l.background,onChange:t=>p({background:t.target.value})})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-lg border px-3 py-2.5 text-sm",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"Web search"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Subject to the selected LLM service capability."})]}),e.jsx(xe,{size:"sm",checked:l.webSearch,onCheckedChange:t=>p({webSearch:t})})]}),e.jsx(ve,{title:"Skills",mode:l.skillsMode,values:l.skills,options:bt,onModeChange:t=>p({skillsMode:t}),onToggle:(t,n)=>q("skills",t,n)}),e.jsx(ve,{title:"Tools",mode:l.toolsMode,values:l.tools,options:jt,onModeChange:t=>p({toolsMode:t}),onToggle:(t,n)=>q("tools",t,n)})]})]})})]}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t pt-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:i==="shortcut"?"Live shortcut preview":"Chat-bound task configuration"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:i==="shortcut"?"Multiple tasks appear in the chat empty state after opening.":"Use the third scenario above to preview employee switching."})]}),i==="shortcut"?e.jsx(ee,{aiEmployee:f,tasks:P,target:w==="embedded"?a:void 0,label:`Ask ${((le=r.find(t=>t.username===f))==null?void 0:le.nickname)??f}`,size:34}):null]})]})]}),e.jsx(at,{title:i==="shortcut"?"Add an AI employee task shortcut":"Add employee tasks to a chat",description:i==="shortcut"?"The prompt includes every task, capability override, and target conversation.":"The prompt groups configured tasks by business AI employee and selected chat container.",prompt:D})]})]})}function ve({title:a,mode:o,values:m,options:x,onModeChange:k,onToggle:r}){return e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:a}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Preset inherits the AI employee configuration."})]}),e.jsxs(O,{value:o,onValueChange:u=>u&&k(u),children:[e.jsx(F,{size:"sm",className:"w-28",children:e.jsx(L,{children:o==="preset"?"Preset":"Custom"})}),e.jsxs(V,{children:[e.jsx(S,{value:"preset",children:"Preset"}),e.jsx(S,{value:"custom",children:"Custom"})]})]})]}),o==="custom"?e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:x.map(u=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md bg-muted/40 px-2.5 py-2 text-xs",children:[e.jsx(st,{checked:m.includes(u.value),onCheckedChange:i=>r(u.value,i)}),e.jsx("span",{children:u.label})]},u.value))}):null]})}export{St as ShortcutPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,
|
|
1
|
+
import{b as a,b7 as y,j as e,aN as b,aP as j,aQ as A,o as S,I as v,K as w}from"./index-Cc6awvdg.js";import{u as C}from"./use-authenticator-sign-in-CIj210ry.js";function E(n){var x;const s=C(n.name),[l,r]=a.useState(!1),[g,d]=a.useState(),[c,t]=a.useState(),[f,m]=a.useState(Date.now()),i=typeof((x=n.options)==null?void 0:x.verifier)=="string"?n.options.verifier:"";a.useEffect(()=>{if(!c||c<=Date.now())return;const u=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(u)},[c]);const h=a.useMemo(()=>c?Math.max(0,Math.ceil((c-f)/1e3)):0,[c,f]);return{sendCode:a.useCallback(async u=>{if(!u)throw new Error("Enter a phone number first.");if(!i)throw new Error("The SMS verifier is not configured.");if(!(h>0)){d(void 0),r(!0);try{const o=await y.action("smsOTP","publicCreate",{method:"POST",authenticator:null,includeRole:!1,withAclMeta:!1,body:{action:"auth:signIn",verifier:i,uuid:u}}),p=o!=null&&o.expiresAt?Date.parse(o.expiresAt):Date.now()+6e4;m(Date.now()),t(p)}catch(o){const p=o instanceof Error?o:new Error("Unable to send the verification code.");throw d(p),p}finally{r(!1)}}},[h,i]),signIn:(u,o)=>s.signIn({uuid:u,code:o}),isSendingCode:l,isSigningIn:s.isPending,retryAfter:h,error:g??s.error}}function M({authenticator:n,onSendCode:s,onSignIn:l}){var m;const[r,g]=a.useState(""),[d,c]=a.useState(""),t=E(n),f=((m=n.options)==null?void 0:m.autoSignup)===!0;return e.jsxs("form",{className:"space-y-5",onSubmit:i=>{if(i.preventDefault(),l){l({phone:r,code:d});return}t.signIn(r,d)},children:[t.error&&e.jsxs(b,{variant:"destructive",children:[e.jsx(j,{children:"SMS sign-in failed"}),e.jsx(A,{children:t.error.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:`${n.name}-phone`,children:"Phone"}),e.jsx(v,{id:`${n.name}-phone`,type:"tel",value:r,onChange:i=>g(i.target.value),autoComplete:"tel",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:`${n.name}-code`,children:"Verification code"}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2",children:[e.jsx(v,{id:`${n.name}-code`,inputMode:"numeric",value:d,onChange:i=>c(i.target.value),autoComplete:"one-time-code",required:!0}),e.jsx(w,{type:"button",variant:"outline",disabled:!s&&(t.isSendingCode||t.retryAfter>0)||!r,onClick:()=>{if(s){s(r);return}t.sendCode(r).catch(()=>{})},children:!s&&t.isSendingCode?"Sending…":!s&&t.retryAfter>0?`Retry in ${t.retryAfter}s`:"Send code"})]})]}),e.jsx(w,{type:"submit",className:"w-full",disabled:!l&&t.isSigningIn,children:!l&&t.isSigningIn?"Signing in…":"Sign in"}),f&&e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"An account will be created automatically if this phone number is new."})]})}export{M as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{bI as Kc,bK as mc}from"./index-Cc6awvdg.js";function qc(q,Ne){for(var b=0;b<Ne.length;b++){const gn=Ne[b];if(typeof gn!="string"&&!Array.isArray(gn)){for(const vn in gn)if(vn!=="default"&&!(vn in q)){const zn=Object.getOwnPropertyDescriptor(gn,vn);zn&&Object.defineProperty(q,vn,zn.get?zn:{enumerable:!0,get:()=>gn[vn]})}}}return Object.freeze(Object.defineProperty(q,Symbol.toStringTag,{value:"Module"}))}var Le={},Be={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-dom-server.browser.production.js
|
|
4
4
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as s,ah as ne,aS as de,aT as re,aU as se,aV as ie,aq as le,ar as ce,aW as oe,aj as ue,aX as fe,aw as pe,aY as he,av as be,aZ as ve,a_ as ge,a$ as ke,al as M,j as f,b0 as me,b1 as ye,b2 as xe,b3 as we,b4 as Ce,c as Pe}from"./index-Cc6awvdg.js";const T=s.createContext(void 0);function Ee(){const e=s.useContext(T);if(e===void 0)throw new Error(ne(63));return e}let F=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const V={...de,checked(e){return e?{[F.checked]:""}:{[F.unchecked]:""}}},ze=s.forwardRef(function(d,l){const{checked:y,className:L,defaultChecked:x,"aria-labelledby":g,form:p,id:q,inputRef:N,name:w,nativeButton:h=!1,onCheckedChange:k,readOnly:c=!1,required:b=!1,disabled:H=!1,render:Ie,uncheckedValue:C,value:P,style:Re,...W}=d,{clearErrors:O}=re(),{state:E,setTouched:S,setDirty:U,validityData:Y,setFilled:m,setFocused:z,validationMode:_,disabled:J,name:X,validation:o}=se(),{labelId:Z}=ie(),t=J||H,u=X??w,r=s.useRef(null),$=le(r,N,o.inputRef),v=s.useRef(null),B=ce(),I=oe({id:q,implicit:!1,controlRef:v}),R=h?void 0:I,[n,G]=ue({controlled:y,default:!!x,name:"Switch",state:"checked"});fe(v,B,n,void 0,!t,w),pe(()=>{r.current&&m(r.current.checked)},[r,m]),he(n,()=>{O(u),U(n!==Y.initialValue),m(n),o.change(n)});const{getButtonProps:Q,buttonRef:D}=be({disabled:t,native:h}),A=ve(g,Z,r,!h,R),ee={id:h?I:B,role:"switch","aria-checked":n,"aria-readonly":c||void 0,"aria-required":b||void 0,"aria-labelledby":A,onFocus(){t||z(!0)},onBlur(){const a=r.current;!a||t||(S(!0),z(!1),_==="onBlur"&&o.commit(a.checked))},onClick(a){if(c||t)return;a.preventDefault();const i=r.current;i&&i.dispatchEvent(new(me(i)).PointerEvent("click",{bubbles:!0,shiftKey:a.shiftKey,ctrlKey:a.ctrlKey,altKey:a.altKey,metaKey:a.metaKey}))}},ae=ge({checked:n,disabled:t,form:p,id:R,name:u,required:b,style:u?ye:xe,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:$,onChange(a){if(a.nativeEvent.defaultPrevented)return;if(c){a.preventDefault();return}const i=a.currentTarget.checked,K=we(Ce,a.nativeEvent);k==null||k(i,K),!K.isCanceled&&G(i)},onFocus(){var a;(a=v.current)==null||a.focus()}},a=>o.getValidationProps(t,a),P!==void 0?{value:P}:ke),j=s.useMemo(()=>({...E,checked:n,disabled:t,readOnly:c,required:b}),[E,n,t,c,b]),te=M("span",d,{state:j,ref:[l,v,D],props:[ee,W,Q,a=>o.getValidationProps(t,a)],stateAttributesMapping:V});return f.jsxs(T.Provider,{value:j,children:[te,!n&&u&&C!==void 0&&f.jsx("input",{type:"hidden",form:p,name:u,value:C,disabled:t}),f.jsx("input",{...ae,suppressHydrationWarning:!0})]})}),Be=s.forwardRef(function(d,l){const{render:y,className:L,style:x,...g}=d,p=Ee();return M("span",d,{state:p,ref:l,stateAttributesMapping:V,props:g})});function Ke({className:e,size:d="default",...l}){return f.jsx(ze,{"data-slot":"switch","data-size":d,className:Pe("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",e),...l,children:f.jsx(Be,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}export{Ke as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as i,j as e,B as w,
|
|
1
|
+
import{b as i,j as e,B as w,C as u,k as m,l as h,n as x,aR as y,I as k,d as N,e as C,f as T,g as R,i as A,T as S}from"./index-Cc6awvdg.js";import{P as I}from"./prompt-output-B4h3uLWf.js";import{S as W}from"./switch-BdVxPIVU.js";const o={suggestions:{type:"dynamic-tool",toolName:"suggestions",toolCallId:"tool-demo-suggestions",state:"input-available",input:{options:["Summarize the operational risks","Draft a weekly support report","Propose the next automation"]}},report:{type:"dynamic-tool",toolName:"businessReportGenerator",toolCallId:"tool-demo-report",state:"output-available",input:{title:"Customer support operations · Weekly review",summary:"Ticket volume remained stable while SLA exposure concentrated in two queues.",markdown:`# Weekly support review
|
|
2
2
|
|
|
3
3
|
## Executive summary
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ Ticket volume remained stable, but unresolved priority requests increased in the
|
|
|
12
12
|
|
|
13
13
|
- Reassign unowned priority tickets before the next shift.
|
|
14
14
|
- Add an SLA warning automation for billing requests.
|
|
15
|
-
- Review the onboarding knowledge-base gaps with the support lead.`,charts:[{title:"Open tickets by queue",options:{xAxis:{type:"category",data:["Billing","Onboarding","API","General"]},yAxis:{type:"value"},series:[{type:"bar",data:[31,26,18,14]}]}},{title:"SLA exposure trend",options:{xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri"]},yAxis:{type:"value"},series:[{type:"line",smooth:!0,data:[8,11,9,15,12]}]}}]},output:{ready:!0}},chart:{type:"dynamic-tool",toolName:"chartGenerator",toolCallId:"tool-demo-chart",state:"output-available",input:{options:{tooltip:{trigger:"axis"},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]},yAxis:{type:"value"},series:[{type:"bar",name:"Tickets",data:[42,64,51,78,58,86,72]}]}},output:{ready:!0}},subAgent:{type:"dynamic-tool",toolName:"dispatch-sub-agent-task",toolCallId:"tool-demo-sub-agent",state:"input-available",input:{username:"dex",question:"Review the current ticket categories and identify where automation would remove the most repetitive work."}},workflow:{type:"dynamic-tool",toolName:"aiEmployeeWorkflowTaskOutput",toolCallId:"tool-demo-workflow",state:"input-available",input:{workflowTitle:"Publish weekly service review",result:{audience:"Support leadership",format:"Markdown report",records:128,delivery:"Team workspace"}}},approval:{type:"dynamic-tool",toolName:"updateRecords",toolCallId:"tool-demo-approval",state:"input-available",input:{collection:"tickets",action:"Assign priority tickets to the on-call team"}},preparing:{type:"dynamic-tool",toolName:"inspectWorkspace",toolCallId:"tool-demo-preparing",state:"input-streaming",input:{scope:"support operations"}},running:{type:"dynamic-tool",toolName:"searchRecords",toolCallId:"tool-demo-running",state:"input-available",input:{collection:"tickets",filter:{status:"open"}}},completed:{type:"dynamic-tool",toolName:"inspectWorkspace",toolCallId:"tool-demo-completed",state:"output-available",input:{scope:"support operations"},output:{reviewed:!0}},failed:{type:"dynamic-tool",toolName:"publishReport",toolCallId:"tool-demo-failed",state:"output-error",input:{destination:"leadership workspace"},errorText:"The current role cannot publish to this workspace."}},B=[["Suggestions","Let the user choose how the AI should continue.",o.suggestions],["Business report","Open a generated report for preview and export.",o.report],["Chart","Render generated visualization options as an inline preview.",o.chart],["Sub-agent","Show delegated AI employee work without expanding the whole payload.",o.subAgent],["Workflow output","Present structured workflow results in a business-friendly card.",o.workflow]];function
|
|
15
|
+
- Review the onboarding knowledge-base gaps with the support lead.`,charts:[{title:"Open tickets by queue",options:{xAxis:{type:"category",data:["Billing","Onboarding","API","General"]},yAxis:{type:"value"},series:[{type:"bar",data:[31,26,18,14]}]}},{title:"SLA exposure trend",options:{xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri"]},yAxis:{type:"value"},series:[{type:"line",smooth:!0,data:[8,11,9,15,12]}]}}]},output:{ready:!0}},chart:{type:"dynamic-tool",toolName:"chartGenerator",toolCallId:"tool-demo-chart",state:"output-available",input:{options:{tooltip:{trigger:"axis"},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]},yAxis:{type:"value"},series:[{type:"bar",name:"Tickets",data:[42,64,51,78,58,86,72]}]}},output:{ready:!0}},subAgent:{type:"dynamic-tool",toolName:"dispatch-sub-agent-task",toolCallId:"tool-demo-sub-agent",state:"input-available",input:{username:"dex",question:"Review the current ticket categories and identify where automation would remove the most repetitive work."}},workflow:{type:"dynamic-tool",toolName:"aiEmployeeWorkflowTaskOutput",toolCallId:"tool-demo-workflow",state:"input-available",input:{workflowTitle:"Publish weekly service review",result:{audience:"Support leadership",format:"Markdown report",records:128,delivery:"Team workspace"}}},approval:{type:"dynamic-tool",toolName:"updateRecords",toolCallId:"tool-demo-approval",state:"input-available",input:{collection:"tickets",action:"Assign priority tickets to the on-call team"}},preparing:{type:"dynamic-tool",toolName:"inspectWorkspace",toolCallId:"tool-demo-preparing",state:"input-streaming",input:{scope:"support operations"}},running:{type:"dynamic-tool",toolName:"searchRecords",toolCallId:"tool-demo-running",state:"input-available",input:{collection:"tickets",filter:{status:"open"}}},completed:{type:"dynamic-tool",toolName:"inspectWorkspace",toolCallId:"tool-demo-completed",state:"output-available",input:{scope:"support operations"},output:{reviewed:!0}},failed:{type:"dynamic-tool",toolName:"publishReport",toolCallId:"tool-demo-failed",state:"output-error",input:{destination:"leadership workspace"},errorText:"The current role cannot publish to this workspace."}},B=[["Suggestions","Let the user choose how the AI should continue.",o.suggestions],["Business report","Open a generated report for preview and export.",o.report],["Chart","Render generated visualization options as an inline preview.",o.chart],["Sub-agent","Show delegated AI employee work without expanding the whole payload.",o.subAgent],["Workflow output","Present structured workflow results in a business-friendly card.",o.workflow]];function D(){const[r,l]=i.useState("Waiting for a decision"),[n,g]=i.useState("Waiting for workflow review");return e.jsxs("div",{className:"space-y-10 pb-12",children:[e.jsx("section",{className:"flex flex-wrap items-start justify-between gap-5 border-b pb-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"secondary",children:"AI Components"}),e.jsx(w,{variant:"outline",children:"Tool renderers"})]}),e.jsx("h1",{className:"mt-4 text-3xl font-semibold tracking-[-0.035em]",children:"Tool Cards"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-muted-foreground",children:"Specialized tools render their complete business interaction. Tools without a registered renderer fall back to the shared status, approval, error, and input disclosure card."})]})}),e.jsxs("section",{className:"space-y-5",children:[e.jsx(f,{eyebrow:"Specialized renderers",title:"Adapt NocoBase tool results to the job they represent",description:"These cards follow the original AI employee patterns while using the starter's shadcn and Base UI component system."}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:B.map(([t,d,a])=>e.jsxs(u,{className:"gap-0 py-0",children:[e.jsxs(m,{className:"border-b py-4",children:[e.jsx(h,{className:"text-base",children:t}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:d})]}),e.jsxs(x,{className:"p-4",children:[e.jsx(y,{part:a,approval:a.toolName==="aiEmployeeWorkflowTaskOutput"?{required:!0,status:"pending"}:void 0,onDecision:async c=>{a.toolName==="aiEmployeeWorkflowTaskOutput"&&g(c==="approve"?"Workflow output approved":c==="reject"?"Workflow output rejected":"Revision requested")}}),a.toolName==="aiEmployeeWorkflowTaskOutput"?e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:n}):null]})]},t))})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsx(f,{eyebrow:"Default Tool Card",title:"One shared shell for every normal tool state",description:"Tools without a specialized renderer still use the same compact status, input disclosure, error, and permission behavior."}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:[[["Preparing input",o.preparing],["Running",o.running],["Completed",o.completed],["Failed",o.failed]].map(([t,d])=>e.jsxs(u,{className:"gap-0 py-0",children:[e.jsx(m,{className:"border-b py-3",children:e.jsx(h,{className:"text-sm",children:t})}),e.jsx(x,{className:"p-4",children:e.jsx(y,{part:d})})]},t)),e.jsxs(u,{className:"gap-0 py-0 md:col-span-2 xl:col-span-2",children:[e.jsx(m,{className:"border-b py-3",children:e.jsx(h,{className:"text-sm",children:"Approval required"})}),e.jsxs(x,{className:"p-4",children:[e.jsx(y,{part:o.approval,approval:{required:!0,status:"pending"},onDecision:async t=>{l(t==="approve"?"The tool was allowed.":"The tool was denied.")}}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r})]})]})]})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsx(f,{eyebrow:"Code prompt",title:"Generate an implementation prompt for a specialized Tool Card",description:"Choose the nearest existing renderer and describe the business interaction. The generated prompt tells the coding agent exactly where and how to implement it."}),e.jsx(E,{})]})]})}const v={suggestions:{label:"Suggestions",guidance:"Follow SuggestionsRenderer for selectable options that call onEdit with the user's choice."},"business-report":{label:"Business report",guidance:"Follow BusinessReportRenderer for an inline summary that opens a larger preview or export dialog."},chart:{label:"Chart",guidance:"Follow ChartRenderer for a compact visual preview derived from structured tool arguments."},"sub-agent":{label:"Sub-agent",guidance:"Follow SubAgentRenderer for a compact entity card with expandable task details."},workflow:{label:"Workflow output",guidance:"Follow WorkflowRenderer for structured results and card-owned Reject, Revise, and Approve actions."}};function E(){const[r,l]=i.useState("reviewSupportQueue"),[n,g]=i.useState("workflow"),[t,d]=i.useState("Show the affected support records, summarize the proposed changes, and let the user approve, request a revision, or reject the operation."),[a,c]=i.useState(!0),b=v[n],j=`Implement a specialized NocoBase AI Tool Card for the tool "${r||"customTool"}" in the shadcn Registry source at registry/nocobase-ai.
|
|
16
16
|
|
|
17
17
|
Business interaction:
|
|
18
18
|
${t||"Render the tool's business-specific interaction."}
|
|
@@ -37,4 +37,4 @@ Implementation requirements:
|
|
|
37
37
|
Verification:
|
|
38
38
|
- Run pnpm build from the Registry source repository.
|
|
39
39
|
- Run the relevant regression checks and a scoped ESLint check.
|
|
40
|
-
- Verify the card in light and dark themes, narrow chat panels, expanded dialogs, pending approval, completed, and error states.`;return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(u,{className:"gap-0 py-0",children:[e.jsxs(m,{className:"border-b py-4",children:[e.jsx(h,{className:"text-base",children:"Describe the Tool Card"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"The examples above remain the visual reference; these values define the implementation task."})]}),e.jsxs(x,{className:"space-y-5 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium",htmlFor:"tool-name",children:"Tool name"}),e.jsx(k,{id:"tool-name",value:r,onChange:s=>l(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium",children:"Closest example"}),e.jsxs(N,{value:n,onValueChange:s=>{if(!s)return;const p=s;g(p),c(p==="workflow")},children:[e.jsx(C,{className:"w-full",children:e.jsx(T,{children:b.label})}),e.jsx(R,{children:Object.entries(v).map(([s,p])=>e.jsx(A,{value:s,children:p.label},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium",htmlFor:"tool-behavior",children:"Business interaction"}),e.jsx(S,{id:"tool-behavior",className:"min-h-28",value:t,onChange:s=>d(s.target.value)})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 border-t pt-4 text-sm",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"Card owns approval UI"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Enable for actions such as Approve, Revise, and Reject."})]}),e.jsx(W,{size:"sm",checked:a,onCheckedChange:c})]})]})]}),e.jsx(I,{title:"Coding prompt",description:"Ready to paste into an implementation task.",prompt:j,promptClassName:"max-h-[720px] min-h-[560px]"})]})}function
|
|
40
|
+
- Verify the card in light and dark themes, narrow chat panels, expanded dialogs, pending approval, completed, and error states.`;return e.jsxs("div",{className:"grid items-start gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs(u,{className:"gap-0 py-0",children:[e.jsxs(m,{className:"border-b py-4",children:[e.jsx(h,{className:"text-base",children:"Describe the Tool Card"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"The examples above remain the visual reference; these values define the implementation task."})]}),e.jsxs(x,{className:"space-y-5 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium",htmlFor:"tool-name",children:"Tool name"}),e.jsx(k,{id:"tool-name",value:r,onChange:s=>l(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium",children:"Closest example"}),e.jsxs(N,{value:n,onValueChange:s=>{if(!s)return;const p=s;g(p),c(p==="workflow")},children:[e.jsx(C,{className:"w-full",children:e.jsx(T,{children:b.label})}),e.jsx(R,{children:Object.entries(v).map(([s,p])=>e.jsx(A,{value:s,children:p.label},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium",htmlFor:"tool-behavior",children:"Business interaction"}),e.jsx(S,{id:"tool-behavior",className:"min-h-28",value:t,onChange:s=>d(s.target.value)})]}),e.jsxs("label",{className:"flex items-center justify-between gap-4 border-t pt-4 text-sm",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium",children:"Card owns approval UI"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Enable for actions such as Approve, Revise, and Reject."})]}),e.jsx(W,{size:"sm",checked:a,onCheckedChange:c})]})]})]}),e.jsx(I,{title:"Coding prompt",description:"Ready to paste into an implementation task.",prompt:j,promptClassName:"max-h-[720px] min-h-[560px]"})]})}function f({eyebrow:r,title:l,description:n}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:r}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:l}),e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-muted-foreground",children:n})]})}export{D as ToolCardsPage};
|