@ssiriuss/ai 0.0.0-stage → 0.0.1

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.
Files changed (123) hide show
  1. package/README.md +66 -2
  2. package/dist/boxes/ai-pages.d.ts +15 -0
  3. package/dist/boxes/ai-pages.js +1 -0
  4. package/dist/boxes/ai.d.ts +2 -0
  5. package/dist/boxes/ai.js +1 -0
  6. package/dist/features/ai-assets/README.md +26 -0
  7. package/dist/features/ai-assets/components/McpClientToolsPanel.d.ts +6 -0
  8. package/dist/features/ai-assets/components/McpClientToolsPanel.js +1 -0
  9. package/dist/features/ai-assets/components/McpEditorLayout.d.ts +29 -0
  10. package/dist/features/ai-assets/components/McpEditorLayout.js +1 -0
  11. package/dist/features/ai-assets/components/McpKeysPanel.d.ts +7 -0
  12. package/dist/features/ai-assets/components/McpKeysPanel.js +1 -0
  13. package/dist/features/ai-assets/components/McpSyncedData.d.ts +13 -0
  14. package/dist/features/ai-assets/components/McpSyncedData.js +1 -0
  15. package/dist/features/ai-assets/components/McpTables.d.ts +36 -0
  16. package/dist/features/ai-assets/components/McpTables.js +1 -0
  17. package/dist/features/ai-assets/components/Panels.d.ts +27 -0
  18. package/dist/features/ai-assets/components/Panels.js +1 -0
  19. package/dist/features/ai-assets/components/RegistryPages.d.ts +29 -0
  20. package/dist/features/ai-assets/components/RegistryPages.js +1 -0
  21. package/dist/features/ai-assets/components/SpecEditors.d.ts +27 -0
  22. package/dist/features/ai-assets/components/SpecEditors.js +2 -0
  23. package/dist/features/ai-assets/components/ToolEditor.d.ts +16 -0
  24. package/dist/features/ai-assets/components/ToolEditor.js +3 -0
  25. package/dist/features/ai-assets/components/ToolTestForm.d.ts +8 -0
  26. package/dist/features/ai-assets/components/ToolTestForm.js +1 -0
  27. package/dist/features/ai-assets/components/fields.d.ts +82 -0
  28. package/dist/features/ai-assets/components/fields.js +3 -0
  29. package/dist/features/ai-assets/components/mcp-headings.d.ts +1 -0
  30. package/dist/features/ai-assets/components/mcp-headings.js +1 -0
  31. package/dist/features/ai-assets/hooks/useAssets.d.ts +161 -0
  32. package/dist/features/ai-assets/hooks/useAssets.js +1 -0
  33. package/dist/features/ai-assets/hooks/useControlTowerTabs.d.ts +10 -0
  34. package/dist/features/ai-assets/hooks/useControlTowerTabs.js +1 -0
  35. package/dist/features/ai-assets/index.d.ts +1 -0
  36. package/dist/features/ai-assets/index.js +1 -0
  37. package/dist/features/ai-assets/model/endpoints.d.ts +2 -0
  38. package/dist/features/ai-assets/model/endpoints.js +1 -0
  39. package/dist/features/ai-assets/model/kinds.d.ts +12 -0
  40. package/dist/features/ai-assets/model/kinds.js +1 -0
  41. package/dist/features/ai-assets/model/mcp.d.ts +21 -0
  42. package/dist/features/ai-assets/model/mcp.js +1 -0
  43. package/dist/features/ai-assets/model/routes.d.ts +6 -0
  44. package/dist/features/ai-assets/model/routes.js +1 -0
  45. package/dist/features/ai-assets/model/tool-contract.d.ts +68 -0
  46. package/dist/features/ai-assets/model/tool-contract.js +7 -0
  47. package/dist/features/ai-assets/pages/AssetDesignerPage.d.ts +6 -0
  48. package/dist/features/ai-assets/pages/AssetDesignerPage.js +1 -0
  49. package/dist/features/ai-assets/pages/AssetsPage.d.ts +10 -0
  50. package/dist/features/ai-assets/pages/AssetsPage.js +1 -0
  51. package/dist/features/ai-assets/pages/GuardrailPolicyPage.d.ts +2 -0
  52. package/dist/features/ai-assets/pages/GuardrailPolicyPage.js +3 -0
  53. package/dist/features/ai-assets/pages/GuardrailsPage.d.ts +5 -0
  54. package/dist/features/ai-assets/pages/GuardrailsPage.js +1 -0
  55. package/dist/features/ai-assets/pages/LlmProviderPage.d.ts +2 -0
  56. package/dist/features/ai-assets/pages/LlmProviderPage.js +1 -0
  57. package/dist/features/ai-assets/pages/LlmProvidersPage.d.ts +2 -0
  58. package/dist/features/ai-assets/pages/LlmProvidersPage.js +1 -0
  59. package/dist/features/ai-assets/pages/McpClientPage.d.ts +2 -0
  60. package/dist/features/ai-assets/pages/McpClientPage.js +1 -0
  61. package/dist/features/ai-assets/pages/McpPage.d.ts +2 -0
  62. package/dist/features/ai-assets/pages/McpPage.js +1 -0
  63. package/dist/features/ai-assets/pages/McpServerPage.d.ts +2 -0
  64. package/dist/features/ai-assets/pages/McpServerPage.js +1 -0
  65. package/dist/features/ai-assets/pages/NewToolPage.d.ts +3 -0
  66. package/dist/features/ai-assets/pages/NewToolPage.js +1 -0
  67. package/dist/features/ai-studio/README.md +19 -0
  68. package/dist/features/ai-studio/components/StudioPages.d.ts +1 -0
  69. package/dist/features/ai-studio/components/StudioPages.js +1 -0
  70. package/dist/features/ai-studio/index.d.ts +2 -0
  71. package/dist/features/ai-studio/index.js +1 -0
  72. package/dist/features/ai-studio/model/demo-data.d.ts +44 -0
  73. package/dist/features/ai-studio/model/demo-data.js +1 -0
  74. package/dist/features/ai-studio/model/studio-pages.d.ts +64 -0
  75. package/dist/features/ai-studio/model/studio-pages.js +1 -0
  76. package/dist/features/ai-studio/pages/AiStudioPage.d.ts +3 -0
  77. package/dist/features/ai-studio/pages/AiStudioPage.js +1 -0
  78. package/dist/features/ai-studio/pages/StudioInventoryPage.d.ts +8 -0
  79. package/dist/features/ai-studio/pages/StudioInventoryPage.js +1 -0
  80. package/dist/features/document-analysis/README.md +13 -0
  81. package/dist/features/document-analysis/components/AnalysisModelPanel.d.ts +5 -0
  82. package/dist/features/document-analysis/components/AnalysisModelPanel.js +1 -0
  83. package/dist/features/document-analysis/components/AttributeEditor.d.ts +10 -0
  84. package/dist/features/document-analysis/components/AttributeEditor.js +5 -0
  85. package/dist/features/document-analysis/components/CategoryEditor.d.ts +11 -0
  86. package/dist/features/document-analysis/components/CategoryEditor.js +1 -0
  87. package/dist/features/document-analysis/components/CategoryGrid.d.ts +11 -0
  88. package/dist/features/document-analysis/components/CategoryGrid.js +1 -0
  89. package/dist/features/document-analysis/components/DefinitionDetail.d.ts +9 -0
  90. package/dist/features/document-analysis/components/DefinitionDetail.js +1 -0
  91. package/dist/features/document-analysis/components/DefinitionEditor.d.ts +10 -0
  92. package/dist/features/document-analysis/components/DefinitionEditor.js +1 -0
  93. package/dist/features/document-analysis/components/DetailsPanel.d.ts +10 -0
  94. package/dist/features/document-analysis/components/DetailsPanel.js +1 -0
  95. package/dist/features/document-analysis/components/FieldGrid.d.ts +8 -0
  96. package/dist/features/document-analysis/components/FieldGrid.js +1 -0
  97. package/dist/features/document-analysis/components/HistoryDialog.d.ts +7 -0
  98. package/dist/features/document-analysis/components/HistoryDialog.js +1 -0
  99. package/dist/features/document-analysis/components/LifecycleDialog.d.ts +16 -0
  100. package/dist/features/document-analysis/components/LifecycleDialog.js +1 -0
  101. package/dist/features/document-analysis/components/SubFieldTree.d.ts +9 -0
  102. package/dist/features/document-analysis/components/SubFieldTree.js +1 -0
  103. package/dist/features/document-analysis/components/TestResult.d.ts +5 -0
  104. package/dist/features/document-analysis/components/TestResult.js +1 -0
  105. package/dist/features/document-analysis/components/parts.d.ts +27 -0
  106. package/dist/features/document-analysis/components/parts.js +1 -0
  107. package/dist/features/document-analysis/hooks/useDocumentAnalysis.d.ts +111 -0
  108. package/dist/features/document-analysis/hooks/useDocumentAnalysis.js +1 -0
  109. package/dist/features/document-analysis/index.d.ts +1 -0
  110. package/dist/features/document-analysis/index.js +1 -0
  111. package/dist/features/document-analysis/model/fieldKinds.d.ts +106 -0
  112. package/dist/features/document-analysis/model/fieldKinds.js +1 -0
  113. package/dist/features/document-analysis/model/presentation.d.ts +4 -0
  114. package/dist/features/document-analysis/model/presentation.js +1 -0
  115. package/dist/features/document-analysis/pages/AnalyzerAdminPage.d.ts +2 -0
  116. package/dist/features/document-analysis/pages/AnalyzerAdminPage.js +1 -0
  117. package/dist/shared/api/document-analysis.d.ts +56 -0
  118. package/dist/shared/api/document-analysis.js +1 -0
  119. package/dist/shared/api/guardrails.d.ts +74 -0
  120. package/dist/shared/api/guardrails.js +1 -0
  121. package/dist/shared/api/llm-providers.d.ts +59 -0
  122. package/dist/shared/api/llm-providers.js +1 -0
  123. package/package.json +24 -4
@@ -0,0 +1 @@
1
+ import{NumberInput as e}from"@/shared/components/workspace/NumberInput";import{useState as t}from"react";import{useMutation as n,useQuery as r,useQueryClient as i}from"@tanstack/react-query";import{useNavigate as a,useParams as o,useSearchParams as s}from"react-router-dom";import{LogIn as c,Plus as ee,Save as te,X as ne,Zap as re}from"lucide-react";import{createAsset as ie,getAsset as l,saveAssetDraft as ae,testAsset as oe}from"@/shared/api/ai-assets";import{authProfiles as u,KEPT_IN_STUDIO as d,profileCredentials as se}from"@/shared/api/integrations";import{useSession as f}from"@/shared/auth/session-context";import{Button as p}from"@/shared/components/ui/button";import{Input as m}from"@/shared/components/ui/input";import{Textarea as ce}from"@/shared/components/ui/textarea";import{ChooseTenant as h}from"@/shared/components/workspace/ChooseTenant";import{CopyValue as le}from"@/shared/components/workspace/CopyValue";import{ModalField as g,modalSelect as _}from"@/shared/components/workspace/Modal";import{useProfileSignIn as ue}from"@/shared/hooks/useProfileSignIn";import{useTenantScope as v}from"@/shared/hooks/useTenantScope";import{cn as de}from"@/shared/lib/utils";import{McpEditorLayout as fe,FormSection as y,StatusBadge as pe}from"../components/McpEditorLayout";import{McpSyncedData as me}from"../components/McpSyncedData";import{Problems as b,VersionsPanel as he}from"../components/Panels";import{assetsKey as x}from"../hooks/useAssets";import{authOf as S,managedCredential as C,mcpAuthOptions as ge,oauthCallback as w,profileKind as T,publishDraft as _e,slug as ve}from"../model/mcp";import{designerPath as ye,listPath as be}from"../model/routes";import{notify as E}from"@/shared/lib/notify";import{jsx as D,jsxs as O,Fragment as k}from"react/jsx-runtime";function A(e,t){let n=e?.spec??{},r=t.find(e=>e.name===n.auth_profile),i=e?C(e.name):``,a=n.auth_profile?r&&r.name===i?S(r.kind):`existing`:`none`,o=r?.name===i?r.config:{};return{display:e?.display_name??e?.name??``,description:e?.description??``,transport:n.transport??`streamable_http`,url:n.url??``,timeout:n.timeout_s??30,auth:a,existing:a===`existing`?n.auth_profile??``:``,clientId:o.client_id??``,authorizeUrl:o.authorize_url??``,tokenUrl:o.token_url??``,scope:o.scope??``,header:o.header??``,secret:``,approval:n.approval===`always`,enabled:n.enabled!==!1,tags:(n.tags??[]).join(`, `),headers:Object.entries(n.headers??{}).map(([e,t])=>({name:e,value:t}))}}export function McpClientPage(){let{id:e=`new`}=o(),{can:t}=f(),n=v(),i=e===`new`,a=r({queryKey:[...x(n.tenantId),`asset`,`mcp_client`,e],queryFn:()=>l(`mcp_client`,e,n.tenantId),enabled:n.ready&&!i,retry:!1}),s=r({queryKey:[`integration-studio`,`profiles`,n.tenantId??`own`],queryFn:({signal:e})=>u.list(n.tenantId,e),enabled:n.ready&&t(`admin.integration.read`),retry:!1});if(!t(`ai.catalog.read`))return D(`p`,{role:`alert`,children:`You do not have access to the AI registry.`});if(!n.ready)return D(h,{children:`MCP clients belong to one customer.`});let c=a.error??s.error;return c?D(b,{error:c}):!i&&!a.data||!s.data?D(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading…`}):D(j,{saved:a.data??null,profiles:s.data,tenantId:n.tenantId,writable:t(`ai.asset.write`)},a.data?.etag??`new`)}function j({saved:r,profiles:o,tenantId:l,writable:h}){let v=i(),S=a(),{can:j}=f(),[M,xe]=s(),N=M.get(`tab`)??`details`,[P,Se]=t(()=>A(r?.data??null,o)),[F,I]=t(null),L=e=>Se(t=>({...t,...e})),R=r?.data.name??ve(P.display),z=o.find(e=>e.name===C(R)),B=!!z?.credentials?.secret_stored,V=()=>{v.invalidateQueries({queryKey:x(l)}),v.invalidateQueries({queryKey:[`integration-studio`]})},H=ue(V),U=T[P.auth],Ce=U!==void 0&&!B&&!P.secret,W=!!z?.credentials?.signed_in;async function G(){let e=null,t=null;if(P.auth===`existing`&&(e=P.existing||null),U){e=C(R);let n={};U===`api_key_header`&&P.header.trim()&&(n.header=P.header.trim()),(U===`oauth2_client_credentials`||U===`oauth2_authorization_code`)&&(n.client_id=P.clientId.trim(),n.token_url=P.tokenUrl.trim(),P.scope.trim()&&(n.scope=P.scope.trim())),U===`oauth2_authorization_code`&&(n.authorize_url=P.authorizeUrl.trim());let r=z?.display_name??(P.display.trim()?`${P.display.trim()} credential`:null),i={name:e,display_name:r,kind:U,config:n,secret_ref:d,enabled:z?.enabled??!0},a=z?await u.update(z.id,i,`"${z.version}"`):await u.create(i,l);t=a.data.id,P.secret&&await se.storeSecret(a.data.id,P.secret)}let n={...r?.data.spec??{},transport:P.transport,url:P.url.trim(),auth_profile:e,timeout_s:P.timeout,approval:P.approval?`always`:`never`,enabled:P.enabled,tags:P.tags.split(`,`).map(e=>e.trim()).filter(Boolean),headers:Object.fromEntries(P.headers.filter(e=>e.name.trim()).map(e=>[e.name.trim(),e.value]))},i={display_name:P.display.trim()||null,description:P.description,spec:n},a=r?await ae(`mcp_client`,r.data.id,i,r.etag,l):await ie(`mcp_client`,{name:R,...i},l);return await _e(`mcp_client`,a.data.id,l),V(),{id:a.data.id,profileId:t}}let K=(e,t=``)=>{r&&r.data.id===e||S(`${ye(`mcp_client`,e)}${t}`)},q=n({mutationFn:G,onSuccess:({id:e})=>{E.success(r?`MCP client saved.`:`MCP client created.`),K(e)}}),J=n({mutationFn:async()=>{let e=await G();return{id:e.id,result:await oe(`mcp_client`,e.id,{},null,l)}},onSuccess:({id:e,result:t})=>{let n=t.output?.tools??[];I({ok:!0,text:`Connected · ${n.length} tools listed`}),E.success(n.length===1?`Connected: 1 tool listed.`:`Connected: ${n.length} tools listed.`),K(e)},onError:e=>{I({ok:!1,text:e.message}),E.error(`Connection failed: ${e.message}`)}}),Y=n({mutationFn:G,onSuccess:({id:e,profileId:t})=>{t&&H.connect(t),K(e)}}),X=q.isPending||J.isPending||Y.isPending,Z=R.length>=2&&/^https?:\/\/|^wss?:\/\//.test(P.url.trim())&&!Ce&&(P.auth!==`existing`||P.existing!==``)&&(U!==`oauth2_client_credentials`||!!(P.clientId&&P.tokenUrl))&&(U!==`oauth2_authorization_code`||!!(P.clientId&&P.tokenUrl&&P.authorizeUrl)),Q=r?P.enabled?P.auth===`authorization_code`&&!W?[`warn`,`Needs sign-in`]:[`good`,`Active`]:[`plain`,`Disabled`]:[`plain`,`New`],$=D(m,{id:`mcp-secret`,type:`password`,autoComplete:`new-password`,placeholder:B?`•••••••• stored, type to replace`:``,value:P.secret,onChange:e=>L({secret:e.target.value})});return O(fe,{back:be(`mcp_client`),backLabel:`MCP clients`,title:r?P.display||r.data.name:`New MCP client`,subtitle:P.url||`Connect an outside MCP server our agents can use.`,badge:D(pe,{tone:Q[0],children:Q[1]}),tab:N,onTab:e=>xe(t=>{let n=new URLSearchParams(t);return e===`details`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0}),tabs:[{id:`details`,label:`Details`},{id:`versions`,label:`Versions`,disabled:!r},{id:`synced`,label:`Synced data`,disabled:!r}],actions:h&&N===`details`&&O(k,{children:[O(p,{variant:`outline`,disabled:!Z||X,onClick:()=>J.mutate(),children:[D(re,{}),` `,J.isPending?`Testing…`:`Test connection`]}),P.auth===`authorization_code`&&O(p,{variant:`outline`,disabled:!Z||X||!!H.waiting,onClick:()=>Y.mutate(),children:[D(c,{}),H.waiting?`Waiting for sign-in…`:W?`Reconnect`:`Connect`]}),O(p,{type:`submit`,form:`mcp-client-form`,disabled:!Z||X,children:[D(te,{}),` `,q.isPending?`Saving…`:r?`Save`:`Create`]})]}),children:[N===`details`&&O(`form`,{id:`mcp-client-form`,"aria-label":`MCP client details`,className:`max-w-6xl`,onSubmit:e=>{e.preventDefault(),q.mutate()},children:[(F||H.blockedUrl||q.error||Y.error||H.error)&&O(`div`,{className:`mb-4 space-y-2`,children:[F&&D(`output`,{className:de(`block text-sm`,F.ok?`text-success-foreground`:`text-destructive`),children:F.text}),H.blockedUrl&&O(`p`,{className:`text-sm`,children:[`The sign-in window was blocked.`,` `,D(`a`,{href:H.blockedUrl,target:`_blank`,rel:`noreferrer`,className:`text-primary underline`,children:`Open the sign-in`})]}),D(b,{error:q.error??Y.error??H.error})]}),O(`fieldset`,{disabled:!h,className:`min-w-0`,children:[O(y,{title:`General`,description:`How the client is named and found.`,children:[D(g,{label:`Name`,htmlFor:`mcp-name`,hint:!r&&R?`Reference: ${R}`:void 0,children:D(m,{id:`mcp-name`,required:!0,maxLength:120,placeholder:`GitHub MCP Server`,value:P.display,onChange:e=>L({display:e.target.value})})}),D(g,{label:`Status`,htmlFor:`mcp-enabled`,children:O(`select`,{id:`mcp-enabled`,className:_,value:P.enabled?`active`:`disabled`,onChange:e=>L({enabled:e.target.value===`active`}),children:[D(`option`,{value:`active`,children:`Active`}),D(`option`,{value:`disabled`,children:`Disabled`})]})}),D(g,{label:`Description`,htmlFor:`mcp-description`,wide:!0,children:D(ce,{id:`mcp-description`,rows:2,maxLength:2e3,value:P.description,onChange:e=>L({description:e.target.value})})}),D(g,{label:`Tags`,htmlFor:`mcp-tags`,wide:!0,hint:`Comma separated.`,children:D(m,{id:`mcp-tags`,placeholder:`mcp, github, oauth, streamable-http`,value:P.tags,onChange:e=>L({tags:e.target.value})})})]}),O(y,{title:`Connection`,description:`Where the MCP server listens.`,children:[D(g,{label:`Transport`,htmlFor:`mcp-transport`,children:O(`select`,{id:`mcp-transport`,className:_,value:P.transport,onChange:e=>L({transport:e.target.value}),children:[D(`option`,{value:`streamable_http`,children:`HTTP (streamable)`}),D(`option`,{value:`websocket`,children:`WebSocket`})]})}),D(g,{label:`Protocol version`,htmlFor:`mcp-protocol`,hint:`Negotiated with the server on connect.`,children:D(m,{id:`mcp-protocol`,readOnly:!0,value:`2025-11-25 (down to 2024-11-05)`})}),D(g,{label:`Endpoint URL`,htmlFor:`mcp-url`,wide:!0,children:D(m,{id:`mcp-url`,required:!0,placeholder:`https://api.githubcopilot.com/mcp/`,value:P.url,onChange:e=>L({url:e.target.value})})}),O(`div`,{className:`space-y-1.5 md:col-span-2`,children:[O(`div`,{className:`flex items-center justify-between`,children:[D(`span`,{className:`text-sm font-medium`,children:`Headers (optional)`}),O(p,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>L({headers:[...P.headers,{name:``,value:``}]}),children:[D(ee,{}),` Add header`]})]}),P.headers.map((e,t)=>O(`div`,{className:`grid grid-cols-[1fr_2fr_auto] gap-2`,children:[D(m,{"aria-label":`Header ${t+1} name`,placeholder:`X-Tenant`,value:e.name,onChange:e=>L({headers:P.headers.map((n,r)=>r===t?{...n,name:e.target.value}:n)})}),D(m,{"aria-label":`Header ${t+1} value`,placeholder:`acme`,value:e.value,onChange:e=>L({headers:P.headers.map((n,r)=>r===t?{...n,value:e.target.value}:n)})}),D(p,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove header ${t+1}`,onClick:()=>L({headers:P.headers.filter((e,n)=>n!==t)}),children:D(ne,{})})]},t)),D(`p`,{className:`text-xs text-muted-foreground`,children:`Sent with every call. Not for secrets: those belong in Authentication.`})]})]}),O(y,{title:`Authentication`,description:`How we prove who we are. Secrets are encrypted and never shown again.`,children:[D(g,{label:`Auth type`,htmlFor:`mcp-auth`,children:D(`select`,{id:`mcp-auth`,className:_,value:P.auth,onChange:e=>L({auth:e.target.value}),children:ge.map(e=>D(`option`,{value:e.value,children:e.label},e.value))})}),P.auth===`existing`?D(g,{label:`Credential`,htmlFor:`mcp-existing`,children:O(`select`,{id:`mcp-existing`,className:_,value:P.existing,onChange:e=>L({existing:e.target.value}),children:[D(`option`,{value:``,children:`Choose…`}),o.map(e=>D(`option`,{value:e.name,children:e.display_name??e.name},e.id))]})}):P.auth===`api_key`?D(g,{label:`Header`,htmlFor:`mcp-header`,children:D(m,{id:`mcp-header`,placeholder:`X-API-Key`,value:P.header,onChange:e=>L({header:e.target.value})})}):D(`div`,{className:`hidden md:block`}),(P.auth===`bearer`||P.auth===`api_key`)&&D(g,{label:P.auth===`bearer`?`Bearer token`:`API key`,htmlFor:`mcp-secret`,wide:!0,children:$}),(P.auth===`client_credentials`||P.auth===`authorization_code`)&&O(k,{children:[D(g,{label:`Client ID`,htmlFor:`mcp-client-id`,children:D(m,{id:`mcp-client-id`,autoComplete:`off`,value:P.clientId,onChange:e=>L({clientId:e.target.value})})}),D(g,{label:`Client secret`,htmlFor:`mcp-secret`,children:$}),P.auth===`authorization_code`&&D(g,{label:`Authorize endpoint`,htmlFor:`mcp-authorize`,wide:!0,children:D(m,{id:`mcp-authorize`,placeholder:`https://github.com/login/oauth/authorize`,value:P.authorizeUrl,onChange:e=>L({authorizeUrl:e.target.value})})}),D(g,{label:`Token URL`,htmlFor:`mcp-token`,wide:!0,children:D(m,{id:`mcp-token`,placeholder:`https://github.com/login/oauth/access_token`,value:P.tokenUrl,onChange:e=>L({tokenUrl:e.target.value})})}),D(g,{label:`Scope (optional)`,htmlFor:`mcp-scope`,wide:!0,children:D(m,{id:`mcp-scope`,placeholder:`repo read:user`,value:P.scope,onChange:e=>L({scope:e.target.value})})}),P.auth===`authorization_code`&&D(g,{label:`Redirect URI`,htmlFor:`mcp-redirect`,wide:!0,hint:`Register it as the callback URL of the provider’s OAuth app.`,children:D(le,{id:`mcp-redirect`,label:`redirect URI`,value:z?.credentials?.redirect_uri??w()})})]})]}),O(y,{title:`Usage`,description:`How agents call this server’s tools.`,children:[D(g,{label:`Timeout (seconds)`,htmlFor:`mcp-timeout`,children:D(e,{id:`mcp-timeout`,min:1,max:300,value:P.timeout,onValueChange:e=>L({timeout:e})})}),D(g,{label:`Approval`,htmlFor:`mcp-approval`,children:O(`select`,{id:`mcp-approval`,className:_,value:P.approval?`always`:`never`,onChange:e=>L({approval:e.target.value===`always`}),children:[D(`option`,{value:`never`,children:`Agents call tools directly`}),D(`option`,{value:`always`,children:`Ask a person before each call`})]})})]})]})]}),N===`versions`&&r&&D(he,{asset:r.data,tenantId:l,canPublish:j(`ai.asset.publish`)}),N===`synced`&&r&&D(me,{client:r,tenantId:l,writable:h})]})}
@@ -0,0 +1,2 @@
1
+ /** MCP: outside MCP servers our agents use (clients) and the MCP servers we publish. */
2
+ export declare function McpPage(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{PageTabs as e}from"@/shared/components/workspace/PageTabs";import{GridHeader as t,GridHeaderSlot as n}from"@/shared/components/workspace/GridHeader";import{useState as r}from"react";import{useQuery as i}from"@tanstack/react-query";import{Link as a,useNavigate as o,useSearchParams as s}from"react-router-dom";import{Cable as c,Plug as l,Plus as ee,Search as u,Server as d}from"lucide-react";import{mcpServerKeys as f}from"@/shared/api/ai-assets";import{authProfiles as p}from"@/shared/api/integrations";import{useSession as m}from"@/shared/auth/session-context";import{Input as h}from"@/shared/components/ui/input";import{ChooseTenant as g}from"@/shared/components/workspace/ChooseTenant";import{ControlHeader as _}from"@/shared/components/workspace/ControlHeader";import{RefreshButton as v}from"@/shared/components/workspace/RefreshButton";import{SplitButton as y}from"@/shared/components/workspace/SplitButton";import{ViewToggle as te}from"@/shared/components/workspace/ViewToggle";import{useTenantScope as b}from"@/shared/hooks/useTenantScope";import{useViewMode as x}from"@/shared/hooks/useViewMode";import{StatusBadge as S}from"../components/McpEditorLayout";import{McpClientsTable as C,McpServersTable as w}from"../components/McpTables";import{assetsKey as T,useAssets as E}from"../hooks/useAssets";import{endpoint as D}from"../model/endpoints";import{assetTitle as O}from"../model/kinds";import{designerPath as k}from"../model/routes";import{matchesSearch as A}from"@/shared/lib/search";import{jsx as j,jsxs as M,Fragment as N}from"react/jsx-runtime";const P=[{id:`mcp_client`,label:`MCP Clients`,icon:l},{id:`mcp_server`,label:`MCP Servers`,icon:d}],F=(e,t)=>A(t,[e.name,e.display_name,e.description,e.connection?.url,...e.connection?.tags??[]]);export function McpPage(){let[a,l]=r(null),{can:d}=m(),S=b(),D=o(),[O,A]=x(`sirius-mcp-view`,`list`),[L,R]=s(),z=e=>R(t=>{let n=new URLSearchParams(t);return Object.entries(e).forEach(([e,t])=>t?n.set(e,t):n.delete(e)),n},{replace:!0}),B=L.get(`tab`)===`mcp_server`?`mcp_server`:`mcp_client`,V=d(`ai.catalog.read`),H=d(`ai.asset.write`),U=V&&S.ready,W=E(`mcp_client`,S.tenantId,U),G=E(`mcp_server`,S.tenantId,U),K=U&&d(`admin.integration.read`),q=i({queryKey:[`integration-studio`,`profiles`,S.tenantId??`own`],queryFn:({signal:e})=>p.list(S.tenantId,e),enabled:K,retry:!1}),J=i({queryKey:[...T(S.tenantId),`mcp-server-keys`],queryFn:({signal:e})=>f.list(S.tenantId,void 0,e),enabled:K,retry:!1}),Y=L.get(`q`)??``,X=B===`mcp_client`?W:G,Z=(X.data??[]).filter(e=>F(e,Y)),Q=e=>void D(k(B,e)),$=e=>void D(k(e,`new`));return M(`div`,{className:`workspace-admin flex min-h-0 flex-col gap-4`,children:[j(_,{title:`MCP`,icon:c,description:`Connect to outside MCP servers and publish our own.`,actions:H&&S.ready&&M(y,{onClick:()=>$(B),menuLabel:`Create another kind of MCP record`,actions:P.filter(e=>e.id!==B).map(e=>({label:e.id===`mcp_client`?`Client`:`Server`,icon:e.icon,onSelect:()=>$(e.id)})),children:[j(ee,{}),B===`mcp_client`?`Client`:`Server`]})}),V?S.ready?M(N,{children:[j(`div`,{className:`mb-3`,children:j(e,{label:`MCP kinds`,current:B,tabs:P.map(e=>({...e,count:(e.id===`mcp_client`?W:G).data?.length}))})}),M(`section`,{"aria-label":B===`mcp_client`?`MCP clients`:`MCP servers`,className:`overflow-x-auto rounded-xl border bg-card`,children:[M(t,{children:[M(`div`,{className:`relative w-64`,children:[j(u,{className:`absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),j(h,{"aria-label":`Search servers and clients`,placeholder:`Search servers and clients…`,className:`pl-9`,value:L.get(`q`)??``,onChange:e=>z({q:e.target.value})})]}),j(n,{ref:l}),M(`div`,{className:`ml-auto flex items-center gap-2`,children:[j(te,{mode:O,onChange:A}),j(v,{fetching:X.isFetching,onRefresh:()=>void X.refetch()})]})]}),X.error?j(`p`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:X.error.message}):X.isPending?j(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Loading…`}):Z.length===0?j(`p`,{className:`border-t p-8 text-center text-sm text-muted-foreground`,children:Y?`Nothing matches this search.`:B===`mcp_client`?`No MCP clients found.`:`No MCP servers yet. Create one to expose your tools, skills and agents.`}):O===`cards`?j(I,{items:Z,kind:B}):B===`mcp_client`?j(C,{columnsToolbar:a,clients:Z,profiles:q.data??[],tenantId:S.tenantId,writable:H,onEdit:Q}):j(w,{columnsToolbar:a,servers:Z,keys:J.data??[],tenantId:S.tenantId,writable:H,onEdit:Q,onKeys:e=>void D(`${k(`mcp_server`,e.id)}?tab=keys`)})]})]}):j(g,{children:`MCP clients and servers belong to one customer.`}):j(`p`,{role:`alert`,children:`Your account does not have permission to view the AI registry.`})]})}function I({items:e,kind:t}){return j(`ul`,{className:`grid gap-3 border-t p-3 sm:grid-cols-2 xl:grid-cols-3`,children:e.map(e=>{let n=e.connection,r=!!e.published_number;return j(`li`,{children:M(a,{to:k(t,e.id),className:`flex h-full flex-col gap-2 rounded-lg border bg-background p-3 transition-colors hover:border-primary/50`,children:[M(`div`,{className:`flex items-start justify-between gap-2`,children:[j(`span`,{className:`truncate font-medium`,children:O(e)}),t===`mcp_client`?j(S,{tone:n?.enabled===!1?`plain`:`good`,children:n?.enabled===!1?`Disabled`:`Active`}):j(S,{tone:r?`good`:`warn`,children:r?`Live`:`Draft`})]}),j(`code`,{className:`truncate text-xs text-muted-foreground`,children:t===`mcp_client`?n?.url??`—`:D(`/mcp/${e.name}`)}),j(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:e.description||`No description`}),j(`div`,{className:`mt-auto flex flex-wrap gap-1 pt-1 text-xs text-muted-foreground`,children:t===`mcp_client`?M(N,{children:[M(`span`,{children:[e.linked_tools??0,` tools synced`]}),(n?.tags??[]).slice(0,4).map(e=>j(`span`,{className:`rounded bg-muted px-1.5`,children:e},e))]}):M(`span`,{children:[(e.exposes?.tools??0)+(e.exposes?.skills??0)+(e.exposes?.agents??0),` `,`exposed`]})})]})},e.id)})})}
@@ -0,0 +1,2 @@
1
+ /** An MCP server we publish: Details, Versions, Access keys. `new` creates. */
2
+ export declare function McpServerPage(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useState as e}from"react";import{useMutation as t,useQuery as n,useQueryClient as r}from"@tanstack/react-query";import{useNavigate as i,useParams as a,useSearchParams as o}from"react-router-dom";import{Save as s}from"lucide-react";import{createAsset as c,getAsset as l,saveAssetDraft as u}from"@/shared/api/ai-assets";import{useSession as d}from"@/shared/auth/session-context";import{Button as f}from"@/shared/components/ui/button";import{Input as p}from"@/shared/components/ui/input";import{Textarea as m}from"@/shared/components/ui/textarea";import{ChooseTenant as h}from"@/shared/components/workspace/ChooseTenant";import{CopyValue as g}from"@/shared/components/workspace/CopyValue";import{ModalField as _}from"@/shared/components/workspace/Modal";import{useTenantScope as v}from"@/shared/hooks/useTenantScope";import{FormSection as y,McpEditorLayout as b,StatusBadge as x}from"../components/McpEditorLayout";import{McpKeysPanel as S}from"../components/McpKeysPanel";import{Problems as C,VersionsPanel as w}from"../components/Panels";import{assetsKey as T,useAssets as E}from"../hooks/useAssets";import{endpoint as D}from"../model/endpoints";import{assetTitle as O}from"../model/kinds";import{publishDraft as k,slug as A}from"../model/mcp";import{designerPath as j,listPath as M}from"../model/routes";import{notify as N}from"@/shared/lib/notify";import{jsx as P,jsxs as F}from"react/jsx-runtime";export function McpServerPage(){let{id:e=`new`}=a(),{can:t}=d(),r=v(),i=e===`new`,o=n({queryKey:[...T(r.tenantId),`asset`,`mcp_server`,e],queryFn:()=>l(`mcp_server`,e,r.tenantId),enabled:r.ready&&!i,retry:!1});return t(`ai.catalog.read`)?r.ready?o.error?P(C,{error:o.error}):!i&&!o.data?P(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading…`}):P(I,{saved:o.data??null,tenantId:r.tenantId,writable:t(`ai.asset.write`)},o.data?.etag??`new`):P(h,{children:`MCP servers belong to one customer.`}):P(`p`,{role:`alert`,children:`You do not have access to the AI registry.`})}function I({saved:n,tenantId:a,writable:l}){let h=r(),v=i(),{can:E}=d(),[O,I]=o(),R=O.get(`tab`)??`details`,z=n?.data.spec??{},[B,V]=e(n?.data.display_name??n?.data.name??``),[H,U]=e(n?.data.description??``),[W,G]=e(z.instructions??``),[K,q]=e({tools:z.tools??[],skills:z.skills??[],agents:z.agents??[]}),[J,Y]=e(``),X=n?.data.name??A(B),Z=K.tools.length+K.skills.length+K.agents.length,Q=t({mutationFn:async()=>{let e={display_name:B.trim()||null,description:H,spec:{...n?.data.spec??{},instructions:W,...K}},t=n?await u(`mcp_server`,n.data.id,e,n.etag,a):await c(`mcp_server`,{name:X,...e},a);return await k(`mcp_server`,t.data.id,a),t.data.id},onSuccess:e=>{h.invalidateQueries({queryKey:T(a)}),N.success(n?`MCP server saved.`:`MCP server created.`),n||v(j(`mcp_server`,e))}}),$=e=>t=>q(n=>({...n,[e]:t}));return F(b,{back:M(`mcp_server`),backLabel:`MCP servers`,title:n?B||n.data.name:`New MCP server`,subtitle:X?D(`/mcp/${X}`):`Publish tools, skills and agents as one server.`,badge:n?P(x,{tone:n.data.published_number?`good`:`warn`,children:n.data.published_number?`Live · v${n.data.published_number}`:`Draft`}):P(x,{tone:`plain`,children:`New`}),tab:R,onTab:e=>I(t=>{let n=new URLSearchParams(t);return e===`details`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0}),tabs:[{id:`details`,label:`Details`},{id:`versions`,label:`Versions`,disabled:!n},{id:`keys`,label:`Access keys`,disabled:!n||!E(`admin.integration.read`)}],actions:l&&R===`details`&&F(f,{type:`submit`,form:`mcp-server-form`,disabled:X.length<2||Z===0||Q.isPending,children:[P(s,{}),` `,Q.isPending?`Saving…`:n?`Save`:`Create`]}),children:[R===`details`&&F(`form`,{id:`mcp-server-form`,"aria-label":`MCP server details`,className:`max-w-6xl`,onSubmit:e=>{e.preventDefault(),Q.mutate()},children:[P(`div`,{className:`mb-4`,children:P(C,{error:Q.error})}),F(`fieldset`,{disabled:!l,className:`min-w-0`,children:[F(y,{title:`General`,description:`How callers know this server.`,children:[P(_,{label:`Name`,htmlFor:`server-name`,hint:!n&&X?`Endpoint: /mcp/${X}`:void 0,children:P(p,{id:`server-name`,required:!0,maxLength:120,placeholder:`Claims assistant`,value:B,onChange:e=>V(e.target.value)})}),P(_,{label:`Endpoint`,htmlFor:`server-endpoint`,children:P(g,{id:`server-endpoint`,label:`endpoint`,value:X?D(`/mcp/${X}`):``})}),P(_,{label:`Description`,htmlFor:`server-description`,wide:!0,children:P(m,{id:`server-description`,rows:2,maxLength:2e3,value:H,onChange:e=>U(e.target.value)})}),P(_,{label:`Instructions for callers (optional)`,htmlFor:`server-instructions`,wide:!0,hint:`Sent to MCP clients when they connect.`,children:P(m,{id:`server-instructions`,rows:3,maxLength:4e3,value:W,onChange:e=>G(e.target.value)})})]}),P(y,{title:`Expose (${Z})`,description:`Published tools, skills and agents. Each skill and agent becomes one tool.`,children:F(`div`,{className:`space-y-3 md:col-span-2`,children:[P(p,{"aria-label":`Filter tools, skills and agents`,placeholder:`Filter…`,className:`h-8 w-64`,value:J,onChange:e=>Y(e.target.value.toLowerCase())}),F(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[P(L,{label:`Tools`,kind:`tool`,chosen:K.tools,query:J,tenantId:a,onChange:$(`tools`)}),P(L,{label:`Skills`,kind:`skill`,chosen:K.skills,query:J,tenantId:a,onChange:$(`skills`)}),P(L,{label:`Agents`,kind:`agent`,chosen:K.agents,query:J,tenantId:a,onChange:$(`agents`)})]})]})})]})]}),R===`versions`&&n&&P(w,{asset:n.data,tenantId:a,canPublish:E(`ai.asset.publish`)}),R===`keys`&&n&&P(S,{server:n.data,tenantId:a})]})}function L({label:e,kind:t,chosen:n,query:r,tenantId:i,onChange:a}){let o=E(t,i,!0),s=(o.data??[]).filter(e=>e.pinned_version_id),c=s.filter(e=>`${e.name} ${e.display_name??``}`.toLowerCase().includes(r));return F(`fieldset`,{className:`flex min-h-0 flex-col rounded-lg border`,children:[P(`legend`,{className:`sr-only`,children:e}),F(`div`,{className:`flex items-center justify-between border-b px-3 py-2 text-sm font-medium`,children:[e,F(`span`,{className:`text-xs text-muted-foreground`,children:[n.length,`/`,s.length]})]}),P(`div`,{className:`p-1`,children:o.isPending?P(`p`,{className:`p-2 text-xs text-muted-foreground`,children:`Loading…`}):c.length===0?P(`p`,{className:`p-2 text-xs text-muted-foreground`,children:`None published.`}):c.map(e=>{let r=`pick-${t}-${e.id}`;return F(`label`,{htmlFor:r,className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-muted/60`,children:[P(`input`,{id:r,type:`checkbox`,checked:n.includes(e.name),onChange:t=>a(t.target.checked?[...n,e.name]:n.filter(t=>t!==e.name))}),P(`span`,{className:`truncate`,children:O(e)})]},e.id)})})]})}
@@ -0,0 +1,3 @@
1
+ /** A new tool, step by step: details, source, inputs & outputs, settings. Created in one
2
+ * call with its whole spec; the designer opens next for versions and tests. */
3
+ export declare function NewToolPage(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useState as e}from"react";import{useNavigate as t}from"react-router-dom";import{ArrowLeft as n,ArrowRight as r,Check as i,Plus as a,Wrench as o}from"lucide-react";import{useSession as s}from"@/shared/auth/session-context";import{Button as c}from"@/shared/components/ui/button";import{ChooseTenant as l}from"@/shared/components/workspace/ChooseTenant";import{ControlHeader as u}from"@/shared/components/workspace/ControlHeader";import{useTenantScope as d}from"@/shared/hooks/useTenantScope";import{cn as f}from"@/shared/lib/utils";import{AreaField as p,Section as m,TextField as h}from"../components/fields";import{Problems as g}from"../components/Panels";import{ToolInputsOutputs as _,ToolSettings as v,ToolSource as y}from"../components/ToolEditor";import{useAssetActions as b}from"../hooks/useAssets";import{designerPath as x,listPath as S}from"../model/routes";import{NEW_TOOL_SPEC as C}from"../model/tool-contract";import{BackLink as w}from"@/shared/components/workspace/BackLink";import{useGoBack as T}from"@/shared/hooks/useGoBack";import{jsx as E,jsxs as D,Fragment as O}from"react/jsx-runtime";const k=[`Details`,`Source`,`Inputs & outputs`,`Settings`],A=/^[a-z][a-z0-9_.-]{1,62}$/,j=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^[^a-z]+/,``).replace(/_+$/,``).slice(0,63);export function NewToolPage(){let{can:M}=s(),N=d(),P=t(),{goBack:F}=T(S(`tool`)),I=b(`tool`,N.tenantId),[L,R]=e(0),[z,B]=e(``),[V,H]=e(``),[U,W]=e(``),[G,K]=e(C);if(!M(`ai.asset.write`))return E(`p`,{role:`alert`,children:`You may not create tools.`});if(!N.ready)return E(l,{children:`Tools belong to one customer.`});let q=A.test(z),J=L===k.length-1,Y=e=>K(t=>({...t,...e}));return D(`div`,{className:`workspace-admin flex min-h-0 flex-col`,children:[E(w,{to:S(`tool`),children:`Tools`}),E(u,{title:`New tool`,description:`The leaf that does the work: a REST call, coded function or script.`,icon:o,actions:D(O,{children:[E(c,{variant:`outline`,onClick:F,children:`Cancel`}),L>0&&D(c,{variant:`outline`,onClick:()=>R(L-1),children:[E(n,{}),` Previous`]}),J?D(c,{disabled:!q||I.create.isPending,onClick:()=>I.create.mutate({name:z,display_name:V.trim()||null,description:U,spec:G},{onSuccess:e=>void P(x(`tool`,e.data.id),{replace:!0})}),children:[E(a,{}),` `,I.create.isPending?`Creating…`:`Create tool`]}):D(c,{disabled:!q,onClick:()=>R(L+1),children:[`Next `,E(r,{})]})]})}),E(`nav`,{"aria-label":`Steps`,className:`mb-3`,children:E(`ol`,{className:`flex flex-wrap items-center gap-2`,children:k.map((e,t)=>{let n=t<L,r=t===L;return D(`li`,{className:`flex items-center gap-2`,children:[t>0&&E(`span`,{"aria-hidden":`true`,className:`h-px w-6 bg-border`}),D(`button`,{type:`button`,"aria-current":r?`step`:void 0,disabled:!q&&t>0,onClick:()=>R(t),className:f(`flex items-center gap-2 rounded-full border px-3 py-1 text-sm transition-colors disabled:opacity-50`,r?`border-primary bg-primary/5 font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),children:[E(`span`,{className:f(`flex size-5 items-center justify-center rounded-full text-xs`,n||r?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground`),children:n?E(i,{className:`size-3`,"aria-hidden":`true`}):t+1}),e]})]},e)})})}),E(g,{error:I.create.error}),L===0&&D(m,{title:`Details`,children:[D(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[E(h,{label:`Display name`,value:V,max:120,placeholder:`Create a claim`,onChange:e=>{H(e),z&&z!==j(V)||B(j(e))}}),E(h,{label:`Name`,value:z,mono:!0,max:63,onChange:B,hint:z&&!q?`Lower-case letters, digits and . _ - ; starts with a letter.`:`The stable reference agents, skills and flows use.`})]}),E(p,{label:`Description`,value:U,rows:3,max:2e3,onChange:W,hint:`Models read it to decide when to call this tool.`})]}),L===1&&E(y,{spec:G,set:Y,tenantId:N.tenantId}),L===2&&E(_,{spec:G,set:Y}),L===3&&E(v,{spec:G,set:Y})]})}
@@ -0,0 +1,19 @@
1
+ # Ai studio
2
+
3
+ Routes import only `index.ts` (AiStudioPage, InsightsPage, AgenticFlowsPage). `AiStudioPage` has
4
+ no content of its own: `/ai-studio` opens Insights, and old `?view=` links open the page that owns
5
+ that section. Features never import each other; shared code lives in `src/shared/`.
6
+
7
+ **Insights** (`/ai-studio/insights`) reads `GET /api/v1/ai-insights` and
8
+ `GET /api/v1/human-tasks/metrics`. Until the tenant has activity (`has_activity` false, or no
9
+ human tasks) each part shows the built-in preview from `model/insights.ts`, shaped exactly like
10
+ the API's answer, so the page switches to real data by itself.
11
+
12
+ | Folder | What lives there |
13
+ | ------------- | --------------------------------------------------------------------------- |
14
+ | `pages/` | Routed pages (exported through `index.ts`) |
15
+ | `components/` | The feature's UI parts; `insights/` holds the insight charts, cards, tables |
16
+ | `hooks/` | `useInsights`: the page's queries and the switch from preview to real data |
17
+ | `model/` | Pure logic: data shapes, derived figures, formatting, the preview |
18
+
19
+ Tests live in `src/test/features/ai-studio/`, mirroring these folders.
@@ -0,0 +1 @@
1
+ export declare function AgenticFlowsPage(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{StudioInventoryPage as e}from"../pages/StudioInventoryPage";import{studioPages as t}from"../model/studio-pages";import{jsx as n}from"react/jsx-runtime";export function AgenticFlowsPage(){return n(e,{page:t.flows})}
@@ -0,0 +1,2 @@
1
+ export { AiStudioPage } from './pages/AiStudioPage';
2
+ export { AgenticFlowsPage } from './components/StudioPages';
@@ -0,0 +1 @@
1
+ export{AiStudioPage}from"./pages/AiStudioPage";export{AgenticFlowsPage}from"./components/StudioPages";
@@ -0,0 +1,44 @@
1
+ export type StudioSectionId = 'flows' | 'agents' | 'tools' | 'skills' | 'guardrails' | 'mcp-servers' | 'mcp-clients' | 'a2a';
2
+ export type StudioMetric = {
3
+ label: string;
4
+ value: string;
5
+ note: string;
6
+ };
7
+ export type StudioConnection = {
8
+ direction: 'Uses' | 'Used by' | 'Routes to' | 'Protects' | 'Exposes' | 'Triggered by' | 'Hands off to';
9
+ name: string;
10
+ kind: string;
11
+ };
12
+ export type StudioItem = {
13
+ id: string;
14
+ name: string;
15
+ kind: string;
16
+ status: 'Active' | 'Ready' | 'Draft' | 'Degraded' | 'Platform managed';
17
+ description: string;
18
+ tags: readonly string[];
19
+ metrics: readonly StudioMetric[];
20
+ details: readonly {
21
+ label: string;
22
+ value: string;
23
+ }[];
24
+ connections: readonly StudioConnection[];
25
+ };
26
+ export type StudioSection = {
27
+ id: StudioSectionId;
28
+ label: string;
29
+ shortLabel: string;
30
+ description: string;
31
+ searchLabel: string;
32
+ boundary: string;
33
+ items: readonly StudioItem[];
34
+ };
35
+ export declare const studioSections: readonly StudioSection[];
36
+ export declare function findStudioSection(value: string | null): StudioSection;
37
+ /**
38
+ * Sample run history of a demo record: 14 durations and 7 outcomes, fixed per id so the
39
+ * page looks the same on every visit. Demo only; real pages pass real history.
40
+ */
41
+ export declare function sampleHistory(id: string): {
42
+ durations: number[];
43
+ outcomes: boolean[];
44
+ };
@@ -0,0 +1 @@
1
+ const e=[{id:`flows`,label:`Agentic flows`,shortLabel:`Flows`,description:`Follow each business journey end to end: what starts it, which agents and tools it calls, and where people step in.`,searchLabel:`Search flows`,boundary:`Sample flows only. Design and publish real flows in the Workflow designer; nothing here starts a run.`,items:[{id:`record-intake`,name:`Record intake`,kind:`Agentic flow`,status:`Active`,description:`Turns a sender email into a record: reads intent, extracts the documents and opens the analysis case.`,tags:[`Email`,`Extraction`,`HITL`],metrics:[{label:`Runs · 24h`,value:`642`,note:`Started by email.received`},{label:`Success`,value:`96.4%`,note:`Completed without a failed step`},{label:`P95 duration`,value:`2m 10s`,note:`End to end, excluding human wait`}],details:[{label:`Trigger`,value:`email.received`},{label:`Steps`,value:`Intent → extract → classify → triage → review`},{label:`Version`,value:`v7 · published`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Uses`,name:`Email Intent Agent`,kind:`Agent`},{direction:`Uses`,name:`Content Understanding · prebuilt-document`,kind:`LLM provider`},{direction:`Hands off to`,name:`Analysis review`,kind:`Agentic flow`}]},{id:`document-extraction`,name:`Document extraction`,kind:`Agentic flow`,status:`Active`,description:`Classifies each attachment (application form form, schedule, history report) and extracts its fields with page-level evidence.`,tags:[`Extraction`,`Evidence`],metrics:[{label:`Runs · 24h`,value:`1,914`,note:`Started by record.documents_received`},{label:`Success`,value:`98.1%`,note:`Completed without a failed step`},{label:`P95 duration`,value:`48s`,note:`End to end, excluding human wait`}],details:[{label:`Trigger`,value:`record.documents_received`},{label:`Steps`,value:`Classify → analyze → validate → store`},{label:`Version`,value:`v11 · published`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Uses`,name:`Content Understanding · prebuilt-document`,kind:`LLM provider`},{direction:`Protects`,name:`Grounded Output Check`,kind:`Guardrail`},{direction:`Used by`,name:`Record intake`,kind:`Agentic flow`}]},{id:`product-recommendation`,name:`Product recommendation`,kind:`Agentic flow`,status:`Active`,description:`Matches the extracted risk to eligible products and rules, and explains every match and exclusion.`,tags:[`Products`,`Rules`],metrics:[{label:`Runs · 24h`,value:`388`,note:`Started by record.triaged`},{label:`Success`,value:`94.8%`,note:`Completed without a failed step`},{label:`P95 duration`,value:`19s`,note:`End to end, excluding human wait`}],details:[{label:`Trigger`,value:`record.triaged`},{label:`Steps`,value:`Criteria → rules → rank → explain`},{label:`Version`,value:`v4 · published`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Uses`,name:`Product Catalogue Search`,kind:`Tool`},{direction:`Uses`,name:`Appetite Matching`,kind:`Skill`},{direction:`Hands off to`,name:`Analysis review`,kind:`Agentic flow`}]},{id:`analysis-review`,name:`Analysis review`,kind:`Agentic flow`,status:`Active`,description:`Puts low-confidence fields and the recommendation in front of an analyst, and resumes when they approve.`,tags:[`HITL`,`SLA`],metrics:[{label:`Runs · 24h`,value:`211`,note:`Started by review.requested`},{label:`Success`,value:`91.5%`,note:`Completed without a failed step`},{label:`P95 duration`,value:`6m 40s`,note:`End to end, excluding human wait`}],details:[{label:`Trigger`,value:`review.requested`},{label:`Steps`,value:`Assign → review → approve or return`},{label:`Version`,value:`v3 · published`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Triggered by`,name:`Record intake`,kind:`Agentic flow`},{direction:`Uses`,name:`Risk Summarizer`,kind:`Agent`},{direction:`Hands off to`,name:`Sender acknowledgement`,kind:`Agentic flow`}]},{id:`sender-acknowledgement`,name:`Sender acknowledgement`,kind:`Agentic flow`,status:`Draft`,description:`Drafts the reply to the sender with what was received, what is missing and the next step, for a person to send.`,tags:[`Sender`,`Draft`],metrics:[{label:`Runs · 24h`,value:`0`,note:`Started by record.reviewed`},{label:`Success`,value:`—`,note:`Completed without a failed step`},{label:`P95 duration`,value:`—`,note:`End to end, excluding human wait`}],details:[{label:`Trigger`,value:`record.reviewed`},{label:`Steps`,value:`Draft → policy check → send for approval`},{label:`Version`,value:`v1 · draft`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Uses`,name:`Sender Response Draft`,kind:`Agent`},{direction:`Protects`,name:`External communication policy`,kind:`Guardrail`}]}]},{id:`agents`,label:`Agents`,shortLabel:`Agents`,description:`See each agent, its model, attached capabilities and recent operating posture.`,searchLabel:`Search agents`,boundary:`Catalog visualization only. Create, edit, publish and test actions are not connected.`,items:[{id:`email-intent`,name:`Email Intent Agent`,kind:`Event-driven agent`,status:`Active`,description:`Reads each inbound sender email once and returns its intent (new request, change, question) with the configured fields.`,tags:[`Email intake`,`MAF`,`Structured output`],metrics:[{label:`Runs · 24h`,value:`1,286`,note:`99.2% completed`},{label:`P95 latency`,value:`3.1s`,note:`Within 5s target`},{label:`Avg. cost`,value:`$0.006`,note:`Per email`}],details:[{label:`Agent name`,value:`email-intent-agent`},{label:`Model`,value:`Azure OpenAI · gpt-4.1`},{label:`Trigger`,value:`email.received`},{label:`Shape`,value:`One structured call · no tools or history`}],connections:[{direction:`Triggered by`,name:`Record intake`,kind:`Agentic flow`},{direction:`Hands off to`,name:`Record Triage`,kind:`Agent`},{direction:`Protects`,name:`Content Safety Baseline`,kind:`Guardrail`}]},{id:`record-triage`,name:`Record Triage`,kind:`Event-driven agent`,status:`Active`,description:`Assesses an intake package, identifies missing evidence and hands structured facts to analysis.`,tags:[`Intake`,`MAF`,`A2A enabled`],metrics:[{label:`Runs · 24h`,value:`428`,note:`97.9% completed`},{label:`P95 latency`,value:`8.4s`,note:`Within 12s target`},{label:`Avg. cost`,value:`$0.041`,note:`Per completed run`}],details:[{label:`Model route`,value:`Balanced reasoning`},{label:`Trigger`,value:`intake_case.documents_extracted`},{label:`Version`,value:`v12 · published`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Uses`,name:`Record evidence`,kind:`Skill`},{direction:`Uses`,name:`Policy system lookup`,kind:`Tool`},{direction:`Protects`,name:`PII output policy`,kind:`Guardrail`}]},{id:`risk-summarizer`,name:`Risk Summarizer`,kind:`Specialist agent`,status:`Ready`,description:`Builds a concise risk narrative from extracted facts while preserving citations to source documents.`,tags:[`Analysis`,`Grounded`],metrics:[{label:`Runs · 24h`,value:`191`,note:`99.1% completed`},{label:`P95 latency`,value:`5.7s`,note:`Within 8s target`},{label:`Citations`,value:`94%`,note:`Outputs with evidence`}],details:[{label:`Model route`,value:`Fast grounded`},{label:`Invocation`,value:`Workflow step`},{label:`Version`,value:`v7 · published`},{label:`Owner`,value:`Analysis AI`}],connections:[{direction:`Uses`,name:`Risk narrative`,kind:`Skill`},{direction:`Uses`,name:`Document search`,kind:`Tool`},{direction:`Used by`,name:`New request intake`,kind:`Workflow`}]},{id:`sender-response`,name:`Sender Response Draft`,kind:`Human-assisted agent`,status:`Draft`,description:`Prepares a sender follow-up draft from unresolved record questions for a human to review.`,tags:[`Communications`,`HITL`],metrics:[{label:`Evaluation set`,value:`36`,note:`Sample conversations`},{label:`Pass rate`,value:`86%`,note:`Target is 92%`},{label:`Open findings`,value:`4`,note:`Before publish`}],details:[{label:`Model route`,value:`Balanced reasoning`},{label:`Invocation`,value:`Explicit review action`},{label:`Version`,value:`v3 · draft`},{label:`Owner`,value:`Distribution AI`}],connections:[{direction:`Uses`,name:`Sender communication`,kind:`Skill`},{direction:`Protects`,name:`External communication policy`,kind:`Guardrail`}]}]},{id:`tools`,label:`Tools`,shortLabel:`Tools`,description:`Inspect callable capabilities and where agents or workflows consume them.`,searchLabel:`Search tools`,boundary:`Catalog visualization only. Tool invocations and credential changes are disabled.`,items:[{id:`document-search`,name:`Document Search`,kind:`Native function`,status:`Active`,description:`Retrieves grounded passages and page references from documents in the current case.`,tags:[`Read only`,`Case scoped`],metrics:[{label:`Calls · 24h`,value:`1,842`,note:`99.8% succeeded`},{label:`P95 latency`,value:`420ms`,note:`Warm index`},{label:`Consumers`,value:`4`,note:`Published agents`}],details:[{label:`Executor`,value:`Python function`},{label:`Input`,value:`case_id, query, top_k`},{label:`Output`,value:`Passages with page evidence`},{label:`Timeout`,value:`3 seconds`}],connections:[{direction:`Used by`,name:`Risk Summarizer`,kind:`Agent`},{direction:`Used by`,name:`Claims Evidence Review`,kind:`Skill`}]},{id:`policy-system`,name:`Policy System Lookup`,kind:`REST integration`,status:`Ready`,description:`Reads policy and account facts through the approved policy-system integration.`,tags:[`GET`,`OAuth profile`],metrics:[{label:`Calls · 24h`,value:`613`,note:`98.6% succeeded`},{label:`P95 latency`,value:`780ms`,note:`1.5s deadline`},{label:`Retries`,value:`11`,note:`Bounded backoff`}],details:[{label:`Executor`,value:`Approved REST integration`},{label:`Destination`,value:`policy-system`},{label:`Credential`,value:`Managed credential profile`},{label:`Data mode`,value:`Read only`}],connections:[{direction:`Used by`,name:`Record Triage`,kind:`Agent`},{direction:`Protects`,name:`Outbound destination policy`,kind:`Guardrail`}]},{id:`product-catalog-mcp`,name:`Product Catalogue Search`,kind:`MCP tool`,status:`Active`,description:`Searches product appetite and eligibility capabilities exposed by an internal MCP server.`,tags:[`MCP`,`Read only`],metrics:[{label:`Calls · 24h`,value:`366`,note:`99.4% succeeded`},{label:`P95 latency`,value:`640ms`,note:`Healthy`},{label:`Consumers`,value:`2`,note:`Agents`}],details:[{label:`Executor`,value:`MCP client`},{label:`Server`,value:`Product Catalogue MCP`},{label:`Tool name`,value:`search_products`},{label:`Approval`,value:`Not required · read only`}],connections:[{direction:`Routes to`,name:`Product Catalogue MCP`,kind:`MCP server`},{direction:`Used by`,name:`Product Recommendation`,kind:`Agent`}]}]},{id:`skills`,label:`Skills`,shortLabel:`Skills`,description:`Review reusable instruction packages and the agents that load them.`,searchLabel:`Search skills`,boundary:`Catalog visualization only. Skill files and instructions are not editable here.`,items:[{id:`record-evidence`,name:`Record Evidence`,kind:`Instruction skill`,status:`Active`,description:`Rules for separating supplied evidence, inferred facts and unresolved questions.`,tags:[`Grounding`,`Business`],metrics:[{label:`Agents`,value:`3`,note:`Attached`},{label:`Resources`,value:`5`,note:`Markdown references`},{label:`Evaluation`,value:`96%`,note:`42 scenarios`}],details:[{label:`Version`,value:`v9 · published`},{label:`Entry file`,value:`SKILL.md`},{label:`Scope`,value:`Record documents`},{label:`Owner`,value:`Business AI`}],connections:[{direction:`Used by`,name:`Record Triage`,kind:`Agent`},{direction:`Used by`,name:`Risk Summarizer`,kind:`Agent`}]},{id:`appetite-matching`,name:`Appetite Matching`,kind:`Instruction + tool skill`,status:`Ready`,description:`Guides product eligibility comparisons and requires cited rule evidence.`,tags:[`Products`,`Tool enabled`],metrics:[{label:`Agents`,value:`1`,note:`Attached`},{label:`Resources`,value:`3`,note:`Instructions and examples`},{label:`Evaluation`,value:`93%`,note:`30 scenarios`}],details:[{label:`Version`,value:`v4 · published`},{label:`Entry file`,value:`SKILL.md`},{label:`Allowed tool`,value:`Product Catalogue Search`},{label:`Owner`,value:`Product AI`}],connections:[{direction:`Uses`,name:`Product Catalogue Search`,kind:`Tool`},{direction:`Used by`,name:`Product Recommendation`,kind:`Agent`}]},{id:`sender-communication`,name:`Sender Communication`,kind:`Instruction skill`,status:`Draft`,description:`Tone, evidence and escalation guidance for external sender communications.`,tags:[`External`,`HITL required`],metrics:[{label:`Agents`,value:`1`,note:`Draft attachment`},{label:`Resources`,value:`2`,note:`Instructions and examples`},{label:`Evaluation`,value:`86%`,note:`Below publish target`}],details:[{label:`Version`,value:`v3 · draft`},{label:`Entry file`,value:`SKILL.md`},{label:`Approval`,value:`Human review required`},{label:`Owner`,value:`Distribution AI`}],connections:[{direction:`Used by`,name:`Sender Response Draft`,kind:`Agent`},{direction:`Protects`,name:`External communication policy`,kind:`Guardrail`}]}]},{id:`guardrails`,label:`Guardrails`,shortLabel:`Guardrails`,description:`Visualize safety coverage and recent policy outcomes across AI workloads.`,searchLabel:`Search guardrails`,boundary:`Read-only platform posture. Policies are configured and evaluated in Azure AI Foundry.`,items:[{id:`content-safety`,name:`Content Safety Baseline`,kind:`Foundry content filter`,status:`Platform managed`,description:`Platform baseline for harmful prompt and response categories.`,tags:[`Input`,`Output`,`Foundry`],metrics:[{label:`Protected runs`,value:`100%`,note:`Published agents`},{label:`Blocks · 24h`,value:`7`,note:`0 critical`},{label:`Review trend`,value:`Stable`,note:`7-day window`}],details:[{label:`Enforcement`,value:`Input and output`},{label:`Configuration`,value:`Azure AI Foundry`},{label:`Failure mode`,value:`Block and record outcome`},{label:`Last observed`,value:`2 minutes ago`}],connections:[{direction:`Protects`,name:`All published agents`,kind:`Agent group`},{direction:`Protects`,name:`Workflow model calls`,kind:`Workflow group`}]},{id:`pii-output`,name:`PII Output Policy`,kind:`Output policy`,status:`Active`,description:`Flags sensitive identifiers before generated text leaves an internal workflow.`,tags:[`Output`,`PII`],metrics:[{label:`Protected runs`,value:`82%`,note:`Targeted workloads`},{label:`Flags · 24h`,value:`23`,note:`4 required review`},{label:`False-positive`,value:`1.2%`,note:`Sampled reviews`}],details:[{label:`Enforcement`,value:`Flag and continue`},{label:`Configuration`,value:`Platform policy registry`},{label:`Escalation`,value:`Workflow policy decides`},{label:`Last observed`,value:`6 minutes ago`}],connections:[{direction:`Protects`,name:`Record Triage`,kind:`Agent`},{direction:`Protects`,name:`Sender Response Draft`,kind:`Agent`}]},{id:`grounded-output`,name:`Grounded Output Check`,kind:`Evidence policy`,status:`Degraded`,description:`Checks whether material generated claims retain a source citation.`,tags:[`Evidence`,`Monitor`],metrics:[{label:`Protected runs`,value:`64%`,note:`Grounded agents`},{label:`Flags · 24h`,value:`31`,note:`8 above baseline`},{label:`Pass rate`,value:`91%`,note:`Target is 95%`}],details:[{label:`Enforcement`,value:`Monitor and flag`},{label:`Configuration`,value:`Evaluation service`},{label:`Current issue`,value:`Citation coverage below target`},{label:`Last observed`,value:`1 minute ago`}],connections:[{direction:`Protects`,name:`Risk Summarizer`,kind:`Agent`},{direction:`Protects`,name:`Record Evidence`,kind:`Skill`}]}]},{id:`mcp-servers`,label:`Servers`,shortLabel:`Servers`,description:`MCP servers the platform publishes: endpoint, transport, authentication and the tools each exposes.`,searchLabel:`Search MCP servers`,boundary:`Connectivity visualization only. No server is published and no client secret is shown.`,items:[{id:`business-operations-server`,name:`Business Operations MCP`,kind:`MCP server`,status:`Active`,description:`Publishes approved case and intake tools for authenticated internal consumers.`,tags:[`Streamable HTTP`,`Internal`],metrics:[{label:`Tools`,value:`6`,note:`Read 4 · write 2`},{label:`Sessions`,value:`18`,note:`Last 15 minutes`},{label:`Availability`,value:`99.97%`,note:`7-day window`}],details:[{label:`Role`,value:`Server`},{label:`Transport`,value:`Streamable HTTP`},{label:`Authentication`,value:`Managed identity / OAuth`},{label:`Published card`,value:`Internal discovery only`}],connections:[{direction:`Exposes`,name:`Case search`,kind:`Tool`},{direction:`Exposes`,name:`Create review request`,kind:`Tool`},{direction:`Used by`,name:`Operations assistant`,kind:`MCP client`}]},{id:`product-catalog-server`,name:`Product Catalogue MCP`,kind:`MCP server`,status:`Ready`,description:`Exposes product search and eligibility evidence as read-only tools.`,tags:[`Streamable HTTP`,`Read only`],metrics:[{label:`Tools`,value:`3`,note:`All read only`},{label:`Sessions`,value:`7`,note:`Last 15 minutes`},{label:`Availability`,value:`99.91%`,note:`7-day window`}],details:[{label:`Role`,value:`Server`},{label:`Transport`,value:`Streamable HTTP`},{label:`Authentication`,value:`Workload identity`},{label:`Published card`,value:`Internal discovery only`}],connections:[{direction:`Exposes`,name:`Search products`,kind:`Tool`},{direction:`Exposes`,name:`Read eligibility evidence`,kind:`Tool`},{direction:`Used by`,name:`Product Catalogue Search`,kind:`MCP client tool`}]},{id:`claims-operations-server`,name:`Claims Operations MCP`,kind:`MCP server`,status:`Draft`,description:`Will publish FNOL lookup and claim-status tools for partner portals.`,tags:[`Streamable HTTP`,`Partner`],metrics:[{label:`Tools`,value:`2`,note:`Read only`},{label:`Sessions`,value:`0`,note:`Not published`},{label:`Availability`,value:`—`,note:`Not published`}],details:[{label:`Role`,value:`Server`},{label:`Endpoint`,value:`/mcp/claims`},{label:`Transport`,value:`Streamable HTTP`},{label:`Authentication`,value:`OAuth 2.0 client credentials`}],connections:[{direction:`Exposes`,name:`Claim status`,kind:`Tool`},{direction:`Exposes`,name:`FNOL lookup`,kind:`Tool`}]}]},{id:`mcp-clients`,label:`Clients`,shortLabel:`Clients`,description:`Outside MCP servers the platform connects to: transport, status, the tools imported from each and the last sync.`,searchLabel:`Search MCP clients`,boundary:`Connectivity visualization only. No outside server is called and no secret is shown.`,items:[{id:`sharepoint-client`,name:`Knowledge Library Client`,kind:`MCP client`,status:`Degraded`,description:`Connects approved agents to curated analysis guidance from an external MCP service.`,tags:[`Client`,`External`],metrics:[{label:`Imported tools`,value:`4`,note:`Allow-listed`},{label:`Calls · 24h`,value:`289`,note:`96.2% succeeded`},{label:`P95 latency`,value:`2.1s`,note:`Above 1.5s target`}],details:[{label:`Role`,value:`Client`},{label:`Transport`,value:`Streamable HTTP`},{label:`Authentication`,value:`Named credential profile`},{label:`Issue`,value:`Remote latency elevated`}],connections:[{direction:`Exposes`,name:`Search guidance`,kind:`Imported tool`},{direction:`Used by`,name:`Risk Summarizer`,kind:`Agent`}]},{id:`servicenow-client`,name:`ServiceNow MCP`,kind:`MCP client`,status:`Active`,description:`Imports case and knowledge tools from the customer ServiceNow instance.`,tags:[`Client`,`External`],metrics:[{label:`Imported tools`,value:`5`,note:`Allow-listed`},{label:`Calls · 24h`,value:`1,042`,note:`99.4% succeeded`},{label:`Last sync`,value:`12 min ago`,note:`Tool list unchanged`}],details:[{label:`Role`,value:`Client`},{label:`Transport`,value:`Streamable HTTP`},{label:`Authentication`,value:`OAuth 2.0 (named credential)`},{label:`Linked tools`,value:`Create case · Update case · Search KB · +2`}],connections:[{direction:`Exposes`,name:`Create case`,kind:`Imported tool`},{direction:`Used by`,name:`Record Triage`,kind:`Agent`}]},{id:`compliance-client`,name:`Compliance Screening MCP`,kind:`MCP client`,status:`Ready`,description:`Screens customer parties against restricted parties lists through a vendor MCP server.`,tags:[`Client`,`Vendor`,`stdio`],metrics:[{label:`Imported tools`,value:`1`,note:`Read only`},{label:`Calls · 24h`,value:`77`,note:`100% succeeded`},{label:`Last sync`,value:`1 h ago`,note:`Tool list unchanged`}],details:[{label:`Role`,value:`Client`},{label:`Transport`,value:`stdio (sidecar)`},{label:`Authentication`,value:`API key (key vault)`},{label:`Linked tools`,value:`Screen party`}],connections:[{direction:`Exposes`,name:`Screen party`,kind:`Imported tool`},{direction:`Used by`,name:`Analysis review`,kind:`Agentic flow`}]}]},{id:`a2a`,label:`A2A agents`,shortLabel:`A2A`,description:`Visualize discoverable partner agents, capabilities and recent task exchanges.`,searchLabel:`Search A2A agents`,boundary:`Protocol visualization only. Agent cards are samples and no A2A request is sent.`,items:[{id:`claims-evidence-agent`,name:`Claims Evidence Agent`,kind:`Partner agent`,status:`Active`,description:`Accepts bounded evidence-review tasks and returns cited observations.`,tags:[`A2A`,`Internal partner`],metrics:[{label:`Tasks · 24h`,value:`74`,note:`98.6% completed`},{label:`Active now`,value:`3`,note:`No tasks waiting`},{label:`P95 duration`,value:`19s`,note:`30s deadline`}],details:[{label:`Agent card`,value:`https://claims-agent.example/.well-known/agent-card.json`},{label:`Protocol`,value:`A2A`},{label:`Authentication`,value:`Workload identity profile`},{label:`Streaming`,value:`Supported`}],connections:[{direction:`Exposes`,name:`Review claim evidence`,kind:`A2A skill`},{direction:`Used by`,name:`Claims intake workflow`,kind:`Workflow`}]},{id:`product-recommendation-agent`,name:`Product Recommendation Agent`,kind:`Partner agent`,status:`Ready`,description:`Returns ranked product candidates with rule evidence for a supplied risk profile.`,tags:[`A2A`,`Product domain`],metrics:[{label:`Tasks · 24h`,value:`51`,note:`100% completed`},{label:`Active now`,value:`1`,note:`2 slots free`},{label:`P95 duration`,value:`11s`,note:`20s deadline`}],details:[{label:`Agent card`,value:`https://products-agent.example/.well-known/agent-card.json`},{label:`Protocol`,value:`A2A`},{label:`Authentication`,value:`OAuth client profile`},{label:`Streaming`,value:`Not required`}],connections:[{direction:`Exposes`,name:`Recommend products`,kind:`A2A skill`},{direction:`Uses`,name:`Product Catalogue MCP`,kind:`MCP server`}]},{id:`sender-enrichment-agent`,name:`Sender Enrichment Agent`,kind:`External partner agent`,status:`Degraded`,description:`Returns organization enrichment facts from an approved external partner.`,tags:[`A2A`,`External`],metrics:[{label:`Tasks · 24h`,value:`29`,note:`93.1% completed`},{label:`Active now`,value:`0`,note:`2 retries delayed`},{label:`P95 duration`,value:`28s`,note:`Above 20s target`}],details:[{label:`Agent card`,value:`https://sender-agent.example/.well-known/agent-card.json`},{label:`Protocol`,value:`A2A`},{label:`Authentication`,value:`Named partner credential`},{label:`Issue`,value:`Partner latency elevated`}],connections:[{direction:`Exposes`,name:`Enrich organization`,kind:`A2A skill`},{direction:`Used by`,name:`Record Triage`,kind:`Agent`}]}]}];export const studioSections=e;export function findStudioSection(t){let n=e.find(e=>e.id===t);if(n)return n;let r=e.find(e=>e.id===`agents`);if(!r)throw Error(`AI Studio requires an agents section.`);return r}export function sampleHistory(e){let t=0x811c9dc5,n=()=>{for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return t=Math.imul(t^t>>>13,0x4bf19f61),(t>>>0)%1e3/1e3};return{durations:Array.from({length:14},()=>Math.round(2+n()*6)),outcomes:Array.from({length:7},()=>n()>.12)}}
@@ -0,0 +1,64 @@
1
+ import type { LucideIcon } from 'lucide-react';
2
+ import type { StudioSectionId } from './demo-data';
3
+ export declare const sectionIcons: Record<StudioSectionId, LucideIcon>;
4
+ /** One AI Studio page: its menu place, what it is for, and which sample sections it shows. */
5
+ export type StudioPageDef = {
6
+ path: string;
7
+ title: string;
8
+ description: string;
9
+ icon: LucideIcon;
10
+ /** More than one section shows as tabs (Control Tower). */
11
+ sections: readonly StudioSectionId[];
12
+ };
13
+ export declare const studioPages: {
14
+ readonly controlTower: {
15
+ readonly path: "/ai-studio/control-tower";
16
+ readonly title: 'Control Tower';
17
+ readonly description: 'The model providers every agent runs on.';
18
+ readonly icon: LucideIcon;
19
+ readonly sections: readonly ["guardrails"];
20
+ };
21
+ readonly flows: {
22
+ readonly path: "/ai-studio/flows";
23
+ readonly title: 'Agentic flows';
24
+ readonly description: 'Each business journey end to end: trigger, agents, tools and human steps.';
25
+ readonly icon: LucideIcon;
26
+ readonly sections: readonly ["flows"];
27
+ };
28
+ readonly agents: {
29
+ readonly path: "/ai-studio/agents";
30
+ readonly title: 'AI agents';
31
+ readonly description: 'Every agent, its model, what it may use and how it is performing, including partner agents over A2A.';
32
+ readonly icon: LucideIcon;
33
+ readonly sections: readonly ["agents", "a2a"];
34
+ };
35
+ readonly skills: {
36
+ readonly path: "/ai-studio/skills";
37
+ readonly title: 'Skills';
38
+ readonly description: 'Packaged instructions and references that agents load for a task.';
39
+ readonly icon: LucideIcon;
40
+ readonly sections: readonly ["skills"];
41
+ };
42
+ readonly tools: {
43
+ readonly path: "/ai-studio/tools";
44
+ readonly title: 'Tools';
45
+ readonly description: 'Functions, integrations and MCP tools agents may call, with their limits.';
46
+ readonly icon: LucideIcon;
47
+ readonly sections: readonly ["tools"];
48
+ };
49
+ readonly mcp: {
50
+ readonly path: "/ai-studio/mcp";
51
+ readonly title: 'MCP';
52
+ readonly description: 'MCP servers the platform publishes, and the outside servers it connects to.';
53
+ readonly icon: LucideIcon;
54
+ readonly sections: readonly ["mcp-servers", "mcp-clients"];
55
+ };
56
+ readonly a2a: {
57
+ readonly path: "/ai-studio/a2a";
58
+ readonly title: 'A2A agents';
59
+ readonly description: 'Partner agents reachable over A2A, their skills and recent exchanges.';
60
+ readonly icon: LucideIcon;
61
+ readonly sections: readonly ["a2a"];
62
+ };
63
+ };
64
+ export declare const studioPageList: readonly StudioPageDef[];
@@ -0,0 +1 @@
1
+ import{Bot as e,Cable as t,Plug as n,Network as r,ShieldCheck as i,Sparkles as a,TowerControl as o,Workflow as s,Wrench as c}from"lucide-react";import{paths as l}from"@/app/paths";export const sectionIcons={flows:s,agents:e,tools:c,skills:a,guardrails:i,"mcp-servers":t,"mcp-clients":n,a2a:r};export const studioPages={controlTower:{path:l.controlTower,title:`Control Tower`,description:`The model providers every agent runs on.`,icon:o,sections:[`guardrails`]},flows:{path:l.agenticFlows,title:`Agentic flows`,description:`Each business journey end to end: trigger, agents, tools and human steps.`,icon:s,sections:[`flows`]},agents:{path:l.aiAgents,title:`AI agents`,description:`Every agent, its model, what it may use and how it is performing, including partner agents over A2A.`,icon:e,sections:[`agents`,`a2a`]},skills:{path:l.aiSkills,title:`Skills`,description:`Packaged instructions and references that agents load for a task.`,icon:a,sections:[`skills`]},tools:{path:l.aiTools,title:`Tools`,description:`Functions, integrations and MCP tools agents may call, with their limits.`,icon:c,sections:[`tools`]},mcp:{path:l.mcp,title:`MCP`,description:`MCP servers the platform publishes, and the outside servers it connects to.`,icon:t,sections:[`mcp-servers`,`mcp-clients`]},a2a:{path:l.a2a,title:`A2A agents`,description:`Partner agents reachable over A2A, their skills and recent exchanges.`,icon:r,sections:[`a2a`]}};export const studioPageList=Object.values(studioPages);
@@ -0,0 +1,3 @@
1
+ /** `/ai-studio` has no page of its own: it opens Insights, the first AI Studio page.
2
+ * Links from before the split (`/ai-studio?view=tools`) open the page that now owns it. */
3
+ export declare function AiStudioPage(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{Navigate as e,useSearchParams as t}from"react-router-dom";import{paths as n}from"@/app/paths";import{studioPageList as r}from"../model/studio-pages";import{jsx as i}from"react/jsx-runtime";export function AiStudioPage(){let[a]=t(),o=a.get(`view`),s=o&&r.find(e=>e.sections.some(e=>e===o));return i(e,{replace:!0,to:s?{pathname:s.path,search:s.sections.length>1?`?tab=${o}`:``}:n.aiInsights})}
@@ -0,0 +1,8 @@
1
+ import { type PageTab } from '@/shared/components/workspace/PageTabs';
2
+ import { type StudioPageDef } from '../model/studio-pages';
3
+ /** One AI Studio page: header with headline numbers, an explanation, then the inventory grid. */
4
+ export declare function StudioInventoryPage({ page, tabs, }: {
5
+ page: StudioPageDef;
6
+ /** Tabs shared with live pages (Control Tower); otherwise one tab per sample section. */
7
+ tabs?: readonly PageTab[];
8
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{tabBarClass as e,tabClass as t}from"@/shared/components/workspace/tab-styles";import{Link as n,useSearchParams as r}from"react-router-dom";import{ArrowRight as i,Info as a,Network as o,Search as s}from"lucide-react";import{Badge as c}from"@/shared/components/ui/badge";import{Input as l}from"@/shared/components/ui/input";import{ControlHeader as u}from"@/shared/components/workspace/ControlHeader";import{PageTabs as d}from"@/shared/components/workspace/PageTabs";import{InsightGrid as f}from"@/shared/components/workspace/insight-grid";import{cn as p}from"@/shared/lib/utils";import{findStudioSection as m,sampleHistory as h}from"../model/demo-data";import{sectionIcons as g}from"../model/studio-pages";import{matchesSearch as _}from"@/shared/lib/search";import{jsx as v,jsxs as y}from"react/jsx-runtime";const b={Active:`good`,Ready:`info`,Draft:`neutral`,Degraded:`warn`,"Platform managed":`info`};function x(e,t){let n=h(e.id);return{id:e.id,title:e.name,subtitle:e.description,icon:t,status:{label:e.status,tone:b[e.status]},badges:[e.kind,...e.tags.slice(0,2)],metrics:e.metrics.map(e=>({label:e.label,value:e.value})),trend:{points:n.durations,label:`Sample duration trend of the last 14 runs`},outcomes:n.outcomes}}function S({children:e}){return v(`h3`,{className:`text-[12px] font-semibold tracking-wider text-muted-foreground uppercase`,children:e})}function C({item:e}){return y(`section`,{"aria-label":`${e.name} details`,className:`grid gap-5 xl:grid-cols-3`,children:[y(`div`,{children:[v(S,{children:`Metrics`}),v(`ul`,{className:`mt-2 space-y-1.5 text-xs`,children:e.metrics.map(e=>y(`li`,{className:`flex items-baseline gap-2`,children:[v(`span`,{className:`w-24 shrink-0 text-muted-foreground`,children:e.label}),v(`span`,{className:`font-semibold tabular-nums`,children:e.value}),y(`span`,{className:`text-muted-foreground`,children:[`· `,e.note]})]},e.label))}),v(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:e.tags.map(e=>v(c,{variant:`secondary`,children:e},e))})]}),y(`div`,{children:[v(S,{children:`Configuration`}),v(`dl`,{className:`mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs`,children:e.details.map(e=>y(`div`,{className:`contents`,children:[v(`dt`,{className:`text-muted-foreground`,children:e.label}),v(`dd`,{className:`min-w-0 font-medium break-words`,children:e.value})]},e.label))})]}),y(`div`,{children:[v(S,{children:`Connected to`}),v(`ul`,{className:`mt-2 space-y-1.5 text-xs`,children:e.connections.map(e=>y(`li`,{className:`flex items-center gap-2 rounded-md border bg-background px-2 py-1.5`,children:[v(o,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":`true`}),v(`span`,{className:`w-20 shrink-0 text-muted-foreground`,children:e.direction}),v(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),v(`span`,{className:`shrink-0 rounded-badge bg-muted px-2.5 py-1 text-xs text-muted-foreground`,children:e.kind})]},`${e.direction}-${e.name}`))})]})]})}function w({section:e}){return y(`aside`,{"aria-label":`About this page`,className:`mb-3 flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 px-4 py-3 text-xs`,children:[v(a,{className:`mt-0.5 size-4 shrink-0 text-primary`,"aria-hidden":`true`}),y(`div`,{className:`min-w-0 space-y-0.5`,children:[y(`p`,{className:`font-medium text-foreground`,children:[`Preview with sample data `,v(`span`,{className:`sr-only`,children:`(DEMO DATA)`}),v(`span`,{"aria-hidden":`true`,className:`ml-2 rounded-badge bg-primary px-2.5 py-1 text-xs font-semibold text-primary-foreground`,children:`DEMO DATA`})]}),y(`p`,{className:`text-muted-foreground`,children:[e.description,` These records show how the page will look once it is connected to the platform; no settings, credentials or runtime state are changed.`]}),v(`p`,{className:`text-muted-foreground`,children:e.boundary})]})]})}export function StudioInventoryPage({page:a,tabs:o}){let[c,h]=r(),b=a.sections.map(e=>m(e)),S=b.find(e=>e.id===c.get(`tab`))??b[0],T=c.get(`q`)??``,E=e=>h(t=>{let n=new URLSearchParams(t);return Object.entries(e).forEach(([e,t])=>t?n.set(e,t):n.delete(e)),n},{replace:!0}),D=S.items.filter(e=>_(T,[e.name,e.kind,e.description,...e.tags])),O=g[S.id];return y(`div`,{children:[v(u,{title:a.title,description:a.description,icon:a.icon}),o&&v(`div`,{className:`mb-3`,children:v(d,{label:`${a.title} sections`,tabs:o,current:S.id})}),!o&&b.length>1&&v(`nav`,{"aria-label":`${a.title} sections`,className:p(e,`mb-3`),children:b.map(e=>{let r=g[e.id],i=e.id===S.id;return y(n,{to:{search:`?tab=${e.id}`},replace:!0,"aria-current":i?`page`:void 0,className:t(i),children:[v(r,{className:`size-4`,"aria-hidden":`true`}),e.label,v(`span`,{className:`rounded-badge bg-muted px-2 text-[12px] text-muted-foreground tabular-nums`,children:e.items.length})]},e.id)})}),v(w,{section:S}),v(f,{label:`${S.label} inventory`,rows:D.map(e=>x(e,O)),densityKey:`sirius-studio-density`,empty:T?`Nothing matches this search.`:`No records in this section yet.`,toolbar:y(`label`,{className:`relative block w-64 max-w-full`,children:[v(`span`,{className:`sr-only`,children:S.searchLabel}),v(s,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),v(l,{"aria-label":S.searchLabel,value:T,onChange:e=>E({q:e.target.value}),placeholder:`${S.searchLabel}…`,className:`h-8 pl-9`})]}),renderDetail:e=>{let t=S.items.find(t=>t.id===e.id);return t?v(C,{item:t}):null}},S.id),y(`p`,{className:`mt-3 flex items-center gap-1 text-[12px] text-muted-foreground`,children:[v(i,{className:`size-3`,"aria-hidden":`true`}),`Expand a row (or press Space on it) to see its configuration and what it is connected to.`]})]})}
@@ -0,0 +1,13 @@
1
+ # Document analysis
2
+
3
+ Routes import only `index.ts` (AnalyzersPage, ClassifiersPage). Features never import each other; shared code
4
+ lives in `src/shared/`.
5
+
6
+ | Folder | What lives there |
7
+ | ------------- | ------------------------------------------------------------------------ |
8
+ | `pages/` | Routed pages (exported through `index.ts`) |
9
+ | `components/` | The feature's UI parts, grouped in subfolders where they belong together |
10
+ | `model/` | Pure logic: data shapes, presentation, charts, forms, query keys |
11
+ | `hooks/` | React hooks: queries, mutations and feature state |
12
+
13
+ Tests live in `src/test/features/document-analysis/`, mirroring these folders.
@@ -0,0 +1,5 @@
1
+ /** Step 1 on both pages: the AI model every analyzer and classifier deploys with. */
2
+ export declare function AnalysisModelPanel({ tenant, canManage }: {
3
+ tenant: string;
4
+ canManage: boolean;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useId as e,useState as t}from"react";import{Cpu as n,Pencil as r}from"lucide-react";import{ErrorNotice as i}from"@/shared/components/layout/ErrorNotice";import{Button as a}from"@/shared/components/ui/button";import{Input as o}from"@/shared/components/ui/input";import{SettingsFeedback as s}from"@/shared/components/workspace/SettingsFeedback";import{cn as c}from"@/shared/lib/utils";import{control as l}from"../model/presentation";import{useAnalysisModel as u,useSetAnalysisModel as d}from"../hooks/useDocumentAnalysis";import{notify as f}from"@/shared/lib/notify";import{jsx as p,jsxs as m}from"react/jsx-runtime";export function AnalysisModelPanel({tenant:h,canManage:g}){let _=u(h),v=d(h),y=e(),[b,x]=t(!1),[S,C]=t(``),[w,T]=t(``);if(_.isPending)return p(`output`,{className:`mb-4 block text-sm text-muted-foreground`,children:`Loading AI model…`});if(_.isError)return p(`div`,{className:`mb-4`,children:p(i,{error:_.error,retry:()=>void _.refetch()})});let E=_.data.current,D=!E||b;return m(`section`,{"aria-label":`AI model`,className:c(`mb-4 rounded-xl border px-4 py-3`,E?`bg-card`:`border-warning/40 bg-warning/10`),children:[m(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[m(`div`,{className:`flex items-center gap-3`,children:[p(`span`,{className:`glass-tile grid size-9 place-items-center rounded-lg`,children:p(n,{className:`size-4`,"aria-hidden":`true`})}),m(`div`,{children:[p(`p`,{className:`text-sm font-semibold`,children:E?`AI model`:`Step 1 · Choose the AI model`}),p(`p`,{className:`text-xs text-muted-foreground`,children:E?`${E.completion_model} · version ${E.model_version} · used by every new deployment`:`Analyzers and classifiers deploy with this model. Set it once for this customer.`})]})]}),E&&!b&&g&&m(a,{size:`sm`,variant:`outline`,onClick:()=>{C(E.completion_model),T(E.model_version),v.reset(),x(!0)},children:[p(r,{}),`Change`]})]}),D&&g&&m(`form`,{className:`mt-3 flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),v.mutate({completion_model:S,model_version:w.trim()},{onSuccess:()=>{x(!1),f.success(`AI model saved.`)}})},children:[m(`label`,{className:`grid w-full gap-1 text-xs font-medium sm:w-72`,children:[`Model`,m(`select`,{className:l,value:S,required:!0,disabled:v.isPending,onChange:e=>C(e.target.value),children:[p(`option`,{value:``,children:`Choose a model…`}),_.data.available.map(e=>m(`option`,{value:e.name,children:[e.name,` (deployment `,e.deployment,`)`]},e.name))]})]}),m(`div`,{className:`grid w-full gap-1 text-xs font-medium sm:w-40`,children:[p(`label`,{htmlFor:y,children:`Exact version`}),p(o,{id:y,value:w,required:!0,disabled:v.isPending,placeholder:`2025-04-14`,onChange:e=>T(e.target.value)})]}),p(a,{type:`submit`,size:`sm`,disabled:v.isPending||!S||!w.trim(),children:v.isPending?`Saving…`:`Save model`}),E&&p(a,{type:`button`,size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>x(!1),children:`Cancel`}),!_.data.available.length&&p(`p`,{className:`basis-full text-xs text-muted-foreground`,children:`The AI service lists no models. Map a model to a deployment in its default model deployments, then reload this page.`}),p(`div`,{className:`basis-full`,children:p(s,{error:v.error,reload:()=>void _.refetch()})})]}),D&&!g&&p(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Ask an administrator to choose the AI model.`})]})}
@@ -0,0 +1,10 @@
1
+ import type { AnalyzerField, FieldWrite } from '@/shared/api/document-analysis';
2
+ export declare function AttributeEditor({ initial, nextOrder, busy, error, close, reload, save, }: {
3
+ initial?: AnalyzerField;
4
+ nextOrder: number;
5
+ busy: boolean;
6
+ error: Error | null;
7
+ close: () => void;
8
+ reload: () => void;
9
+ save: (input: FieldWrite) => void;
10
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import{useState as e}from"react";import{isRecord as t}from"@/shared/api/http";import{Input as n}from"@/shared/components/ui/input";import{Textarea as r}from"@/shared/components/ui/textarea";import{SettingsFeedback as i}from"@/shared/components/workspace/SettingsFeedback";import{blankSub as a,childDepth as o,fieldKinds as s,fieldMethods as c,kindOf as l,subFieldProblems as u,subFieldsOf as d,toFieldWrite as f}from"../model/fieldKinds";import{AdminDialog as p,FormActions as m,FormField as h}from"./parts";import{control as g}from"../model/presentation";import{SubFieldTree as _}from"./SubFieldTree";import{jsxs as v,jsx as y}from"react/jsx-runtime";export function AttributeEditor({initial:b,nextOrder:x,busy:S,error:C,close:w,reload:T,save:E}){let[D,O]=e(b?.name??``),[k,A]=e(b?.description??``),[j,M]=e(b?l(b):`text`),[N,P]=e(b?.method===`generate`?`generate`:`extract`),[F,I]=e(b?.estimate_source_and_confidence??!0),[L,R]=e(b?.enum_values?.join(`
2
+ `)??``),[z,B]=e(t(b?.items)&&b.items.type===`number`?`number`:`string`),[V,H]=e(()=>{let e=b?d(b):[];return e.length?e:[a()]}),[U,W]=e(null),G=j===`table`||j===`group`,K=j===`choice`?`classify`:N,q=L.split(`
3
+ `).map(e=>e.trim()).filter(Boolean),J=f({name:D,description:k,kind:j,method:N,confidence:F,choices:q,listItem:z,children:V,sortOrder:b?.sort_order??x});return y(p,{title:b?`Edit field ${b.name}`:`Add a field`,description:`Name the value, choose its kind and how the AI gets it, and describe where it appears. The description is the AI's instruction, so be specific.`,close:w,busy:S,children:v(`form`,{onSubmit:e=>{if(e.preventDefault(),W(null),j===`choice`&&(q.length<2||new Set(q).size!==q.length)){W(`A choice needs at least two different options, one per line.`);return}let t=G?u(V,o(j)):[];t.length?W(t.join(` `)):E(J)},children:[v(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[y(h,{label:`Field name`,help:`Shown exactly like this in the deployed analyzer. Letters, digits and underscores.`,children:y(n,{value:D,required:!0,pattern:`[A-Za-z][A-Za-z0-9_]{0,63}`,maxLength:64,disabled:S,placeholder:`customer_name`,onChange:e=>O(e.target.value)})}),y(h,{label:`Kind of value`,help:s.find(e=>e.value===j)?.help,children:y(`select`,{className:g,disabled:S,value:j,onChange:e=>{let t=s.find(t=>t.value===e.target.value);t&&M(t.value)},children:s.map(e=>v(`option`,{value:e.value,children:[e.label,` · `,e.type]},e.value))})}),y(h,{label:`Method`,help:c.find(e=>e.value===K)?.help,children:y(`select`,{className:g,disabled:S||j===`choice`,value:K,onChange:e=>{let t=c.find(t=>t.value===e.target.value);t&&t.value!==`classify`&&P(t.value)},children:c.filter(e=>j===`choice`==(e.value===`classify`)).map(e=>y(`option`,{value:e.value,children:e.label},e.value))})}),v(`div`,{className:`grid content-start gap-1.5 text-sm`,children:[y(`span`,{className:`font-medium`,children:`Source and confidence`}),v(`label`,{className:`flex h-9 items-center gap-2`,children:[y(`input`,{type:`checkbox`,className:`accent-primary`,checked:K===`extract`||F,disabled:S||K===`extract`,onChange:e=>I(e.target.checked)}),`Return source and confidence`]}),y(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:K===`extract`?`Always on for Extract: shows where the value is on the page.`:`Page location and a confidence score, for review.`})]}),y(`div`,{className:`sm:col-span-2`,children:y(h,{label:K===`generate`?`What should the AI work out?`:`What to extract`,help:`Where it appears, the labels it is printed under, and how to tell it apart from similar values.`,children:y(r,{value:k,onChange:e=>A(e.target.value),required:!0,rows:3,disabled:S,maxLength:1e4,placeholder:`Name of the customer. May be labelled Customer, Client or Account.`})})}),j===`choice`&&y(`div`,{className:`sm:col-span-2`,children:y(h,{label:`Options`,help:`One option per line, at least two.`,children:y(r,{required:!0,rows:4,value:L,onChange:e=>R(e.target.value),disabled:S,placeholder:`new_business
4
+ renewal
5
+ mid_term_adjustment`})})}),j===`list`&&y(h,{label:`List of`,children:v(`select`,{className:g,value:z,disabled:S,onChange:e=>B(e.target.value===`number`?`number`:`string`),children:[y(`option`,{value:`string`,children:`Text values`}),y(`option`,{value:`number`,children:`Numbers`})]})})]}),G&&v(`fieldset`,{className:`mt-4 rounded-xl border p-3`,children:[y(`legend`,{className:`px-1 text-sm font-medium`,children:j===`table`?`Columns of each row`:`Values in this group`}),y(`p`,{className:`mb-3 text-xs leading-5 text-muted-foreground`,children:`A value can itself be a Group, Table or List. Only kinds that stay within the service's three nesting levels are offered.`}),y(_,{value:V,depth:o(j),path:``,busy:S,onChange:H})]}),v(`details`,{className:`mt-4 rounded-xl border p-3 text-xs`,children:[y(`summary`,{className:`cursor-pointer font-medium`,children:`Field definition sent to the AI service`}),y(`pre`,{className:`mt-2 font-mono leading-5 break-all whitespace-pre-wrap`,children:JSON.stringify({[J.name||`field_name`]:{type:J.field_type,description:J.description,method:J.method,estimateSourceAndConfidence:J.estimate_source_and_confidence,...J.items?{items:J.items}:{},...J.properties?{properties:J.properties}:{},...J.enum_values?{enum:J.enum_values}:{}}},null,2)})]}),U&&y(`p`,{role:`alert`,className:`mt-4 text-sm text-destructive`,children:U}),y(`div`,{className:`mt-4`,children:y(i,{error:C,reload:T})}),y(m,{busy:S,close:w,label:b?`Save field`:`Add field`,disabled:!D.trim()||!k.trim()})]})})}
@@ -0,0 +1,11 @@
1
+ import type { AnalyzerCategory, CategoryWrite } from '@/shared/api/document-analysis';
2
+ export declare function CategoryEditor({ tenant, initial, nextOrder, busy, error, close, reload, save, }: {
3
+ tenant: string;
4
+ initial?: AnalyzerCategory;
5
+ nextOrder: number;
6
+ busy: boolean;
7
+ error: Error | null;
8
+ close: () => void;
9
+ reload: () => void;
10
+ save: (input: CategoryWrite) => void;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useState as e}from"react";import{ErrorNotice as t}from"@/shared/components/layout/ErrorNotice";import{Input as n}from"@/shared/components/ui/input";import{Textarea as r}from"@/shared/components/ui/textarea";import{SettingsFeedback as i}from"@/shared/components/workspace/SettingsFeedback";import{AdminDialog as a,FormActions as o,FormField as s}from"./parts";import{control as c}from"../model/presentation";import{useTargets as l}from"../hooks/useDocumentAnalysis";import{jsx as u,jsxs as d}from"react/jsx-runtime";export function CategoryEditor({tenant:f,initial:p,nextOrder:m,busy:h,error:g,close:_,reload:v,save:y}){let[b,x]=e(p?.category??``),[S,C]=e(p?.description??``),[w,T]=e(p?.target_analyzer_id??``),E=l(f,!0),D=p?.category===`other`,O=!!w&&!E.data?.some(e=>e.id===w);return u(a,{title:p?`Edit category ${p.category}`:`Add a document category`,description:`Name a kind of document, describe how to recognise it, and choose the analyzer that extracts its fields.`,close:_,busy:h,children:d(`form`,{onSubmit:e=>{e.preventDefault(),y({category:b.trim(),description:S.trim(),target_analyzer_id:D?null:w||null,sort_order:p?.sort_order??m})},children:[d(`div`,{className:`grid gap-4`,children:[u(s,{label:`Category name`,help:`Shown exactly like this in the deployed classifier. Lowercase letters, digits and underscores.`,children:u(n,{required:!0,disabled:h||D,value:b,pattern:`[a-z][a-z0-9_]{1,63}`,maxLength:64,placeholder:`placement_slip`,onChange:e=>x(e.target.value)})}),u(s,{label:`How to recognise it`,help:`What the document contains and how it differs from similar documents. The classifier decides from this text alone.`,children:u(r,{required:!0,rows:4,value:S,onChange:e=>C(e.target.value),disabled:h,maxLength:1e4})}),u(s,{label:`Extract with`,help:D?`Unrecognised parts come back with category other and no fields; they are never extracted.`:`Only deployed analyzers can be chosen. Deploy the analyzer first if it is missing.`,children:d(`select`,{className:c,value:D?``:w,disabled:h||D||E.isPending,onChange:e=>T(e.target.value),children:[u(`option`,{value:``,children:`Recognise only — no extraction`}),O&&u(`option`,{value:w,disabled:!0,children:`Chosen analyzer is no longer deployed — choose another`}),E.data?.map(e=>u(`option`,{value:e.id,children:e.provider_analyzer_id},e.id))]})}),E.isError&&u(t,{error:E.error,retry:()=>void E.refetch()})]}),u(`div`,{className:`mt-4`,children:u(i,{error:g,reload:v})}),u(o,{busy:h,close:_,label:p?`Save category`:`Add category`,disabled:!b.trim()||!S.trim()||!D&&O})]})})}
@@ -0,0 +1,11 @@
1
+ import type { Analyzer, AnalyzerCategory } from '@/shared/api/document-analysis';
2
+ export declare function CategoryGrid({ categories, targets, editable, busy, loadingTargets, route, edit, remove, }: {
3
+ categories: AnalyzerCategory[];
4
+ targets: Analyzer[];
5
+ editable: boolean;
6
+ busy: boolean;
7
+ loadingTargets: boolean;
8
+ route: (category: AnalyzerCategory, target: string) => void;
9
+ edit: (category: AnalyzerCategory) => void;
10
+ remove: (category: AnalyzerCategory) => void;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{DataTable as e}from"@/shared/components/workspace/DataTable";import{Pencil as t,Trash2 as n}from"lucide-react";import{Button as r}from"@/shared/components/ui/button";import{cn as i}from"@/shared/lib/utils";import{control as a}from"../model/presentation";import{jsx as o,jsxs as s}from"react/jsx-runtime";export function CategoryGrid({categories:c,targets:l,editable:u,busy:d,loadingTargets:f,route:p,edit:m,remove:h}){let g=new Set(l.map(e=>e.id)),_=e=>e?l.find(t=>t.id===e)?.provider_analyzer_id??`an analyzer that is not deployed`:`Recognise only`;return o(`div`,{className:`overflow-x-auto`,children:s(e,{className:`w-full min-w-[52rem] table-fixed text-left text-sm`,children:[s(`colgroup`,{children:[o(`col`,{className:`w-[20%]`}),o(`col`,{}),o(`col`,{className:`w-[26%]`}),o(`col`,{className:`w-24`})]}),o(`thead`,{className:`border-b text-xs text-muted-foreground`,children:s(`tr`,{children:[o(`th`,{className:`py-2 pr-3 font-medium`,children:`Category`}),o(`th`,{className:`py-2 pr-3 font-medium`,children:`How to recognise it`}),o(`th`,{className:`py-2 pr-3 font-medium`,children:`Extract with`}),o(`th`,{className:`py-2 text-right font-medium`,children:`Actions`})]})}),o(`tbody`,{className:`divide-y`,children:[...c].sort((e,t)=>Number(e.category===`other`)-Number(t.category===`other`)||e.sort_order-t.sort_order).map(e=>{let c=e.category===`other`,v=e.target_analyzer_id??``;return s(`tr`,{className:`align-top`,children:[o(`td`,{className:`py-3 pr-3 text-xs font-semibold break-words`,children:e.category}),o(`td`,{className:`py-3 pr-3 text-xs leading-5 break-words text-muted-foreground`,children:e.description}),o(`td`,{className:`py-3 pr-3`,children:c?o(`span`,{className:`text-xs text-muted-foreground`,children:`Returned as other · never extracted`}):u?s(`select`,{"aria-label":`Extract ${e.category} with`,className:i(a,`h-8 text-xs`),value:v,disabled:d||f,onChange:t=>p(e,t.target.value),children:[o(`option`,{value:``,children:`Recognise only`}),v&&!g.has(v)&&o(`option`,{value:v,disabled:!0,children:`Not deployed yet`}),l.map(e=>o(`option`,{value:e.id,children:e.provider_analyzer_id},e.id))]}):o(`span`,{className:`text-xs`,children:_(e.target_analyzer_id)})}),o(`td`,{className:`py-3 text-right`,children:s(`div`,{className:`flex justify-end gap-1`,children:[o(r,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit category ${e.category}`,disabled:!u||d,onClick:()=>m(e),children:o(t,{})}),o(r,{variant:`destructive`,size:`icon-sm`,"aria-label":`Delete category ${e.category}`,disabled:!u||d||c,onClick:()=>h(e),children:o(n,{})})]})})]},e.id)})})]})})}
@@ -0,0 +1,9 @@
1
+ import type { AnalyzerKind, VersionedAnalyzer } from '@/shared/api/document-analysis';
2
+ export declare function DefinitionDetail({ saved, tenant, kind, choose, reload, close, }: {
3
+ saved: VersionedAnalyzer;
4
+ tenant: string;
5
+ kind: AnalyzerKind;
6
+ choose: (id: string) => void;
7
+ reload: () => void;
8
+ close: () => void;
9
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useState as e}from"react";import{Tabs as t}from"@base-ui/react/tabs";import{CheckCircle2 as ee,Circle as te,ClipboardCheck as n,CloudUpload as ne,Copy as re,History as r,Play as ie,Plus as ae,RefreshCw as oe,Save as se,Trash2 as ce,Undo2 as le}from"lucide-react";import{useSession as ue}from"@/shared/auth/session-context";import{ErrorNotice as i}from"@/shared/components/layout/ErrorNotice";import{usePageCrumb as de}from"@/shared/components/layout/page-crumb";import{Button as a}from"@/shared/components/ui/button";import{SettingsFeedback as fe}from"@/shared/components/workspace/SettingsFeedback";import{SplitButton as pe}from"@/shared/components/workspace/SplitButton";import{cn as me}from"@/shared/lib/utils";import{AnalysisModelPanel as he}from"./AnalysisModelPanel";import{AttributeEditor as ge}from"./AttributeEditor";import{CategoryEditor as _e}from"./CategoryEditor";import{CategoryGrid as ve}from"./CategoryGrid";import{DetailsPanel as ye,detailsFormId as be}from"./DetailsPanel";import{FieldGrid as xe}from"./FieldGrid";import{HistoryDialog as Se}from"./HistoryDialog";import{LifecycleDialog as Ce}from"./LifecycleDialog";import{StateBadge as o}from"./parts";import{TestResult as we}from"./TestResult";import{formatTime as Te}from"../model/presentation";import{useAnalysisModel as Ee,useDefinitionActions as De,useDefinitionPreview as Oe,useTargets as ke,useTestRun as Ae}from"../hooks/useDocumentAnalysis";import{notify as s}from"@/shared/lib/notify";import{jsx as c,jsxs as l,Fragment as u}from"react/jsx-runtime";export function DefinitionDetail({saved:d,tenant:f,kind:je,choose:Me,reload:p,close:Ne}){let m=d.data,h=je===`CLASSIFIER`;de(`${m.name} v${m.version_no}`);let{can:g}=ue(),_=g(h?`extraction.classifier.write`:`extraction.analyzer.write`),[v,y]=e(null),[b,x]=e(``),[S,Pe]=e(!1),[Fe,Ie]=e(0),[C,Le]=e(null),w=Ae(f,m.id),T=De(f),E=Ee(f),D=ke(f,h&&g(`extraction.analyzer.read`)),O=T.isPending,k=m.status===`DRAFT`,A=m.status===`ACTIVE`,j=m.status===`FAILED`,M=_&&k,N=m.status===`PUBLISHING`||m.status===`DELETING`,P=m.evaluation?.passed===!0,F=m.categories.filter(e=>e.category!==`other`),I=F.filter(e=>e.target_analyzer_id),Re=new Set(D.data?.map(e=>e.id)),L=I.filter(e=>!Re.has(e.target_analyzer_id??``)),R=E.data?.current,ze=Object.keys(typeof m.provider_config.config==`object`&&m.provider_config.config?m.provider_config.config:{}).length,z=[{key:`model`,label:`AI model`,done:!!R||!!m.model_profile_id,detail:R?`${R.completion_model} · ${R.model_version}`:`Not chosen yet`},{key:`details`,label:`Details`,done:!!m.description.trim(),detail:`Description and ${ze} settings`},h?{key:`definition`,label:`Categories`,done:F.length>0&&I.length>0&&!L.length,detail:L.length?`Deploy first: ${L.map(e=>e.category).join(`, `)}`:`${F.length} categories, ${I.length} extracted`}:{key:`definition`,label:`Fields`,done:m.fields.length>0,detail:m.fields.length?`${m.fields.length} fields to extract`:`Add the values to extract`},{key:`deploy`,label:`Deploy`,done:A,detail:A?`Live as ${m.provider_analyzer_id}`:`Deploys as ${m.provider_analyzer_id}`},{key:`test`,label:`Test`,done:P,detail:P?`Results recorded as right`:m.evaluation?`Last test needs changes`:`Try real documents`}],B=z.slice(0,3).filter(e=>!e.done),Be=!B.length&&(!h||D.isSuccess),[Ve,V]=e(null),H=Ve??(E.isPending?`details`:z.find(e=>!e.done)?.key??`details`),U=Oe(f,m.id,H===`deploy`),W=e=>{T.reset(),x(``),y(e)},G=()=>{y(null),T.reset(),p()};async function K(e){try{let t=await T.mutateAsync(e);y(null),e.change.type===`delete`?(s.success(h?`Classifier deleted.`:`Analyzer deleted.`),Ne()):t&&e.change.type===`clone`?(s.success(h?`Classifier cloned.`:`Analyzer cloned.`),Me(t.data.id)):x(e.change.type===`publish`?`Deployed as ${m.provider_analyzer_id}.`:e.change.type===`sync`?`Status checked.`:e.change.type===`evaluation`?`Test result recorded.`:`Saved.`)}catch{}}let q=(e,t)=>W({type:`action`,intent:e,target:t,saved:d}),He=(e,t)=>void K({saved:d,change:{type:`category`,id:e.id,input:{category:e.category,description:e.description,target_analyzer_id:t||null,sort_order:e.sort_order}}}),J=Math.max(-1,...(h?m.categories:m.fields).map(e=>e.sort_order))+1,Y=!_||O,X={label:`History`,icon:r,onSelect:()=>W({type:`history`})},[Z=X,...Q]=[...k||j?[{label:j?`Retry deploy`:`Deploy`,icon:ne,onSelect:()=>q(`publish`),disabled:Y||!Be,title:B[0]?`${B[0].label}: ${B[0].detail}`:void 0}]:[],...N||j?[{label:`Check status`,icon:oe,onSelect:()=>void K({saved:d,change:{type:`sync`}}),disabled:Y}]:[],...A?[{label:`Record test`,icon:n,onSelect:()=>q(`evaluation`),disabled:Y}]:[],...A||j?[{label:`Edit as new version`,icon:re,onSelect:()=>q(`clone`),disabled:Y}]:[],X],$=Z.icon??r;return l(`section`,{className:`min-w-0`,"aria-label":`Selected definition`,children:[l(`div`,{className:`rounded-2xl border bg-card`,children:[l(`div`,{className:`border-b p-4 sm:p-5`,children:[l(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`h2`,{className:`truncate text-lg font-semibold`,children:m.name}),l(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,m.version_no]}),c(o,{state:m.status}),c(`span`,{className:`rounded-badge border bg-muted/40 px-2.5 py-1 text-xs`,title:`The ID shown in the AI service`,children:m.provider_analyzer_id})]}),c(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-muted-foreground`,children:m.description})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[H===`details`&&M&&l(a,{type:`submit`,form:be,size:`sm`,variant:`outline`,disabled:O||!S,children:[c(se,{}),O?`Saving…`:`Save`]}),H===`details`&&M&&l(a,{size:`sm`,variant:`outline`,disabled:O||!S,onClick:()=>Ie(e=>e+1),children:[c(le,{}),`Undo changes`]}),H===`test`&&A&&l(a,{size:`sm`,disabled:!_||O||!C||w.isPending,onClick:()=>C&&w.mutate(C),children:[c(ie,{}),w.isPending?`Testing…`:`Run test`]}),Q.length?l(pe,{size:`sm`,variant:k||j?`default`:`outline`,disabled:Z.disabled,title:Z.title,onClick:Z.onSelect,actions:Q,menuLabel:`More actions`,children:[c($,{}),Z.label]}):l(a,{size:`sm`,variant:`outline`,onClick:Z.onSelect,children:[c($,{}),Z.label]}),l(a,{variant:`destructive`,size:`sm`,disabled:!_||O||N,onClick:()=>q(`delete`),children:[c(ce,{}),m.status===`DELETE_FAILED`?`Retry delete`:`Delete`]})]})]}),b&&c(`output`,{className:`mt-3 block text-sm text-success`,children:b}),!v&&c(`div`,{className:`mt-3`,children:c(fe,{error:T.error,reload:p})}),m.last_error&&l(`div`,{role:`alert`,className:`mt-3 rounded-lg border border-destructive/25 bg-destructive/5 p-3 text-sm text-destructive`,children:[c(`strong`,{className:`block`,children:`Last operation failed`}),m.last_error]})]}),l(t.Root,{value:H,onValueChange:e=>{let t=z.find(t=>t.key===e);t&&V(t.key)},children:[c(t.List,{"aria-label":`Steps`,className:`grid gap-2 border-b p-4 sm:grid-cols-3 sm:p-5 xl:grid-cols-5`,children:z.map((e,n)=>l(t.Tab,{value:e.key,onClick:()=>V(e.key),className:me(`flex items-start gap-2 rounded-xl border px-3 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring`,e.done?`border-success/30 bg-success/5`:`bg-muted/20`,H===e.key&&`ring-2 ring-primary`),children:[e.done?c(ee,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}):c(te,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),l(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block text-sm font-medium`,children:[n+1,`. `,e.label]}),c(`span`,{className:`block text-xs leading-5 break-words text-muted-foreground`,children:e.detail})]})]},e.key))}),l(t.Panel,{value:H,className:`min-w-0 p-4 sm:p-5`,children:[H===`model`&&c(he,{tenant:f,canManage:_}),H===`details`&&c(ye,{saved:d,editable:M,busy:O,save:e=>void K({saved:d,change:{type:`metadata`,input:e}}),onDirtyChange:Pe},`${d.etag}-${Fe}`),H===`definition`&&l(u,{children:[l(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[l(`p`,{className:`text-sm text-muted-foreground`,children:[h?`Each category says how to recognise a document and which analyzer extracts it.`:`Each field is one value the analyzer returns, with the name you give it.`,!k&&` This version is deployed and locked; edit it as a new version.`]}),M&&l(a,{size:`sm`,disabled:O,onClick:()=>W(h?{type:`category`,saved:d}:{type:`field`,saved:d}),children:[c(ae,{}),h?`Add category`:`Add field`]})]}),h?l(u,{children:[c(ve,{categories:m.categories,targets:D.data??[],editable:M,busy:O,loadingTargets:D.isPending,route:He,edit:e=>W({type:`category`,saved:d,category:e}),remove:e=>q(`delete-category`,{id:e.id,name:e.category})}),D.isError&&c(i,{error:D.error,retry:()=>void D.refetch()})]}):c(xe,{fields:m.fields,editable:M,busy:O,edit:e=>W({type:`field`,saved:d,field:e}),remove:e=>q(`delete-field`,{id:e.id,name:e.name})})]}),H===`deploy`&&l(`div`,{className:`grid gap-4`,children:[l(`dl`,{className:`grid gap-x-6 gap-y-2 text-sm sm:grid-cols-[auto_minmax(0,1fr)]`,children:[c(`dt`,{className:`text-muted-foreground`,children:`Deployed ID`}),c(`dd`,{children:m.provider_analyzer_id}),c(`dt`,{className:`text-muted-foreground`,children:`AI model`}),c(`dd`,{children:A?`Pinned at deployment`:R?`${R.completion_model} · ${R.model_version}`:`Not chosen yet`}),c(`dt`,{className:`text-muted-foreground`,children:`State`}),c(`dd`,{children:c(o,{state:m.status})})]}),k&&B.length>0&&c(`ul`,{className:`list-inside list-disc text-sm text-muted-foreground`,children:B.map(e=>l(`li`,{children:[e.label,`: `,e.detail]},e.key))}),l(`details`,{className:`rounded-xl border p-3`,children:[c(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Exactly what is sent to the AI service`}),U.isPending?c(`output`,{className:`mt-2 block text-sm`,children:`Building the definition…`}):U.isError?c(`div`,{className:`mt-2`,children:c(i,{error:U.error,retry:()=>void U.refetch()})}):c(`pre`,{className:`mt-2 rounded-lg bg-muted/30 p-3 font-mono text-xs leading-6 break-all whitespace-pre-wrap`,children:JSON.stringify(U.data,null,2)}),m.content_hash&&l(`p`,{className:`mt-2 text-xs break-all text-muted-foreground`,children:[`Deployed content hash `,m.content_hash]})]})]}),H===`test`&&l(`div`,{className:`grid gap-4 text-sm`,children:[c(`p`,{className:`max-w-3xl leading-6 text-muted-foreground`,children:A?`Choose a real document and run the test. You get exactly this definition’s data model: each value with its confidence and page. Then record whether the results were right.`:`Deploy this version first, then test it with real documents.`}),A&&l(`label`,{className:`grid max-w-xl gap-1 text-sm`,children:[c(`span`,{className:`font-medium`,children:`Test document`}),c(`input`,{type:`file`,accept:`.pdf,.png,.jpg,.jpeg,.tif,.tiff,.bmp,.heif,.docx,.xlsx,.pptx,.txt,.md,.html,.eml,.msg,.csv`,disabled:w.isPending,onChange:e=>{w.reset(),Le(e.target.files?.[0]??null)},className:`rounded-lg border bg-background p-2 text-sm`})]}),w.isPending&&l(`output`,{className:`text-muted-foreground`,children:[`Analysing `,C?.name,`… this can take a minute.`]}),w.error&&c(i,{error:w.error}),w.data&&c(we,{run:w.data}),m.evaluation&&l(`div`,{className:`rounded-xl border p-3`,children:[l(`p`,{className:`font-medium`,children:[`Recorded: `,P?`results were right`:`needs changes`]}),l(`p`,{className:`text-xs text-muted-foreground`,children:[String(m.evaluation.reference??``),typeof m.evaluation.recorded_at==`number`&&` · ${Te(m.evaluation.recorded_at)}`]})]})]})]},H)]})]}),v?.type===`history`&&c(Se,{tenant:f,definition:m,close:()=>y(null)}),v?.type===`field`&&c(ge,{initial:v.field,nextOrder:J,busy:O,error:T.error,close:()=>y(null),reload:G,save:e=>void K({saved:v.saved,change:{type:`field`,input:e,id:v.field?.id}})}),v?.type===`category`&&c(_e,{tenant:f,initial:v.category,nextOrder:J,busy:O,error:T.error,close:()=>y(null),reload:G,save:e=>void K({saved:v.saved,change:{type:`category`,input:e,id:v.category?.id}})}),v?.type===`action`&&c(Ce,{intent:v.intent,saved:v.saved,target:v.target,busy:O,error:T.error,close:()=>y(null),reload:G,submit:e=>void K({saved:v.saved,change:e})})]})}
@@ -0,0 +1,10 @@
1
+ import type { AnalyzerCreate, AnalyzerKind } from '@/shared/api/document-analysis';
2
+ /** Create a definition; its details and settings are edited on the Details tab afterwards. */
3
+ export declare function DefinitionEditor({ kind, busy, error, close, reload, create, }: {
4
+ kind: AnalyzerKind;
5
+ busy: boolean;
6
+ error: Error | null;
7
+ close: () => void;
8
+ reload: () => void;
9
+ create: (input: AnalyzerCreate) => void;
10
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useState as e}from"react";import{Input as t}from"@/shared/components/ui/input";import{Textarea as n}from"@/shared/components/ui/textarea";import{SettingsFeedback as r}from"@/shared/components/workspace/SettingsFeedback";import{AdminDialog as i,FormActions as a,FormField as o}from"./parts";import{jsx as s,jsxs as c}from"react/jsx-runtime";const l=/^[a-z][a-z0-9_]{1,55}$/;export function DefinitionEditor({kind:u,busy:d,error:f,close:p,reload:m,create:h}){let[g,_]=e(``),[v,y]=e(``),b=u===`CLASSIFIER`,x=b?`classifier`:`analyzer`,S=l.test(g.trim());return s(i,{title:`New ${x}`,description:b?`A classifier recognises each document type and passes it to the analyzer that extracts its fields.`:`An analyzer extracts the fields you list from one kind of document.`,close:p,busy:d,children:c(`form`,{onSubmit:e=>{e.preventDefault(),h({name:g.trim(),description:v.trim(),reason:`Initial definition`,kind:b?`classifier`:`extractor`,model_role:b?`classification`:`extraction_accurate`,provider_config:{baseAnalyzerId:`prebuilt-document`,config:{returnDetails:!0,...b?{enableSegment:!0}:{}}}})},children:[c(`div`,{className:`grid gap-4`,children:[s(o,{label:`Name`,help:S?`Deploys as ${g.trim()}_v1. The name cannot change later.`:`Lowercase letters, digits and underscores, starting with a letter (2–56 characters).`,children:s(t,{value:g,disabled:d,onChange:e=>_(e.target.value),required:!0,pattern:`[a-z][a-z0-9_]{1,55}`,maxLength:56,placeholder:b?`intake_classifier`:`placement_slip`})}),s(o,{label:b?`What it classifies`:`Which document it reads`,help:`The AI reads this as context: say what the document is and what is extracted. You can adjust reading settings on the Details tab.`,children:s(n,{value:v,onChange:e=>y(e.target.value),required:!0,disabled:d,rows:3,maxLength:1e4})})]}),s(`div`,{className:`mt-4`,children:s(r,{error:f,reload:m})}),s(a,{busy:d,close:p,label:`Create ${x}`,disabled:!S||!v.trim()})]})})}
@@ -0,0 +1,10 @@
1
+ import type { AnalyzerUpdate, VersionedAnalyzer } from '@/shared/api/document-analysis';
2
+ export declare const detailsFormId = "definition-details";
3
+ /** Description and settings; the page toolbar's Save submits this form by its id. */
4
+ export declare function DetailsPanel({ saved, editable, busy, save, onDirtyChange, }: {
5
+ saved: VersionedAnalyzer;
6
+ editable: boolean;
7
+ busy: boolean;
8
+ save: (input: AnalyzerUpdate) => void;
9
+ onDirtyChange: (dirty: boolean) => void;
10
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{useEffect as e,useId as t,useState as n}from"react";import{isRecord as r}from"@/shared/api/http";import{Textarea as i}from"@/shared/components/ui/textarea";import{FormField as a}from"./parts";import{control as o}from"../model/presentation";import{jsx as s,jsxs as c}from"react/jsx-runtime";const l=[{title:`Reading the document`,toggles:[{key:`enableOcr`,label:`Read scanned pages (OCR)`,help:`Needed for scans, photos and image PDFs. Turn off for digital PDFs to go faster.`,default:!0},{key:`enableLayout`,label:`Understand layout`,help:`Paragraphs, sections and reading order. Needed for accurate tables and sections.`,default:!0},{key:`enableFormula`,label:`Detect formulas`,help:`Mathematical formulas as LaTeX. Rarely needed for business documents.`,default:!0},{key:`enableBarcode`,label:`Read barcodes and QR codes`,help:`Decodes barcodes printed on the document.`,default:!0},{key:`enableFigureDescription`,label:`Describe figures and images`,help:`Writes a text description of each figure or diagram.`,default:!1},{key:`enableFigureAnalysis`,label:`Analyse charts and diagrams`,help:`Turns charts into data and identifies diagram parts.`,default:!1}]},{title:`Results`,toggles:[{key:`returnDetails`,label:`Return details`,help:`Confidence scores, positions and text spans. Needed for review and checking.`,default:!0},{key:`estimateFieldSourceAndConfidence`,label:`Source and confidence for every field`,help:`Default for fields that do not set it themselves. Extract fields always return it.`,default:!1},{key:`omitContent`,label:`Return only the routed results`,help:`Leave out the classifier’s own result and keep only routed analyzers’ output. Usually leave off: it also drops each part’s category and pages, and parts with no analyzer (including other) disappear from the response.`,default:!1,classifier:!0}]},{title:`Splitting files`,toggles:[{key:`enableSegment`,label:`Split files that contain several documents`,help:`Each part is classified and extracted on its own.`,default:!0,classifier:!0},{key:`segmentPerPage`,label:`One part per page`,help:`Treat every page as its own document instead of finding boundaries.`,default:!1,classifier:!0}]}];export const detailsFormId=`definition-details`;export function DetailsPanel({saved:u,editable:d,busy:f,save:p,onDirtyChange:m}){let h=u.data,g=h.kind===`CLASSIFIER`,_=r(h.provider_config.config)?h.provider_config.config:{},v=l.map(e=>({...e,toggles:e.toggles.filter(e=>g||!e.classifier)})).filter(e=>e.toggles.length),y=Object.fromEntries(v.flatMap(e=>e.toggles.map(e=>[e.key,typeof _[e.key]==`boolean`?_[e.key]:e.default]))),[b,x]=n(h.description),[S,C]=n(y),[w,T]=n(_.tableFormat===`markdown`?`markdown`:`html`),E=t(),D=b.trim()!==h.description||w!==(_.tableFormat===`markdown`?`markdown`:`html`)||Object.keys(S).some(e=>S[e]!==y[e]),O=d&&D&&!!b.trim();e(()=>m(O),[O,m]);let k=!d||f;return c(`form`,{id:`definition-details`,className:`grid gap-5`,onSubmit:e=>{e.preventDefault(),O&&p({description:b.trim(),reason:`Updated details`,provider_config:{...h.provider_config,baseAnalyzerId:`prebuilt-document`,config:Object.fromEntries(Object.entries({..._,...S,tableFormat:w}).filter(([e])=>g||e!==`omitContent`))}})},children:[c(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,16rem)_minmax(0,1fr)]`,children:[c(`div`,{className:`grid content-start gap-1 text-sm`,children:[s(`span`,{className:`font-medium`,children:`Name`}),s(`span`,{children:h.name}),c(`span`,{className:`text-xs text-muted-foreground`,children:[`Deploys as `,s(`span`,{children:h.provider_analyzer_id}),`. The name cannot change.`]})]}),s(a,{label:g?`What it classifies`:`Which document it reads`,help:`The AI reads this as context: say what the document is and what is extracted.`,children:s(i,{value:b,onChange:e=>x(e.target.value),required:!0,disabled:k,rows:3,maxLength:1e4})})]}),s(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:v.map(e=>c(`fieldset`,{className:`rounded-xl border p-3`,children:[s(`legend`,{className:`px-1 text-sm font-medium`,children:e.title}),c(`div`,{className:`grid gap-3`,children:[e.toggles.map(e=>c(`label`,{className:`flex items-start gap-2 text-sm`,children:[s(`input`,{type:`checkbox`,className:`mt-1 accent-primary`,checked:S[e.key],disabled:k,onChange:t=>C(n=>({...n,[e.key]:t.target.checked}))}),c(`span`,{children:[e.label,c(`span`,{className:`block text-xs leading-5 text-muted-foreground`,children:[e.help,` Default `,e.default?`on`:`off`,`.`]})]})]},e.key)),e.title===`Results`&&c(`div`,{className:`grid gap-1 text-sm`,children:[s(`label`,{htmlFor:E,children:`Table format`}),c(`select`,{id:E,className:o,value:w,disabled:k,onChange:e=>T(e.target.value===`markdown`?`markdown`:`html`),children:[s(`option`,{value:`html`,children:`HTML (keeps complex tables)`}),s(`option`,{value:`markdown`,children:`Markdown (simple tables)`})]})]})]})]},e.title))}),!d&&s(`p`,{className:`text-xs text-muted-foreground`,children:h.status===`DRAFT`?`You can view these settings; changing them needs management access.`:`This version is deployed and locked. Use Edit as new version to change it.`})]})}
@@ -0,0 +1,8 @@
1
+ import type { AnalyzerField } from '@/shared/api/document-analysis';
2
+ export declare function FieldGrid({ fields, editable, busy, edit, remove, }: {
3
+ fields: AnalyzerField[];
4
+ editable: boolean;
5
+ busy: boolean;
6
+ edit: (field: AnalyzerField) => void;
7
+ remove: (field: AnalyzerField) => void;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{DataTable as e}from"@/shared/components/workspace/DataTable";import{Pencil as t,Trash2 as n}from"lucide-react";import{Button as r}from"@/shared/components/ui/button";import{kindLabel as i,methodLabel as a,standardType as o,subFieldsOf as s}from"../model/fieldKinds";import{jsx as c,jsxs as l}from"react/jsx-runtime";const u=e=>e.kind===`list`?`list of ${e.listItem===`number`?`numbers`:`text`} · array`:e.kind===`group`?`group · object`:e.kind===`table`?`table · array of objects`:e.kind;function d({values:e}){return c(`ul`,{className:`mt-1 grid gap-0.5 border-l pl-2`,children:e.map(e=>l(`li`,{className:`text-[12px] break-words`,children:[e.name,c(`span`,{className:`ml-1 font-sans text-muted-foreground`,children:u(e)}),e.children.length>0&&c(d,{values:e.children})]},e.key))})}export function FieldGrid({fields:u,editable:f,busy:p,edit:m,remove:h}){return c(`div`,{className:`overflow-x-auto`,children:l(e,{empty:`No fields yet. Add each value you want from this document, for example customer_name.`,className:`w-full min-w-[52rem] table-fixed text-left text-sm`,children:[l(`colgroup`,{children:[c(`col`,{className:`w-[18%]`}),c(`col`,{className:`w-[24%]`}),c(`col`,{className:`w-[14%]`}),c(`col`,{}),c(`col`,{className:`w-24`})]}),c(`thead`,{className:`border-b text-xs text-muted-foreground`,children:l(`tr`,{children:[c(`th`,{className:`py-2 pr-3 font-medium`,children:`Field`}),c(`th`,{className:`py-2 pr-3 font-medium`,children:`Kind`}),c(`th`,{className:`py-2 pr-3 font-medium`,children:`Method`}),c(`th`,{className:`py-2 pr-3 font-medium`,children:`What to extract`}),c(`th`,{className:`py-2 text-right font-medium`,children:`Actions`})]})}),c(`tbody`,{className:`divide-y`,children:[...u].sort((e,t)=>e.sort_order-t.sort_order).map(e=>{let u=s(e);return l(`tr`,{className:`align-top`,children:[c(`td`,{className:`py-3 pr-3 text-xs font-semibold break-words`,children:e.name}),l(`td`,{className:`py-3 pr-3 text-xs`,children:[i(e),l(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,o(e)]}),u.length>0&&c(d,{values:u})]}),l(`td`,{className:`py-3 pr-3 text-xs`,children:[a(e.method),e.estimate_source_and_confidence&&c(`span`,{className:`block text-muted-foreground`,children:`+ source & confidence`})]}),c(`td`,{className:`py-3 pr-3 text-xs leading-5 break-words text-muted-foreground`,children:e.description}),c(`td`,{className:`py-3 text-right`,children:l(`div`,{className:`flex justify-end gap-1`,children:[c(r,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit field ${e.name}`,disabled:!f||p,onClick:()=>m(e),children:c(t,{})}),c(r,{variant:`destructive`,size:`icon-sm`,"aria-label":`Delete field ${e.name}`,disabled:!f||p,onClick:()=>h(e),children:c(n,{})})]})})]},e.id)})})]})})}
@@ -0,0 +1,7 @@
1
+ import type { Analyzer } from '@/shared/api/document-analysis';
2
+ /** Who changed what and when, newest first; a record, not a step, so it opens on demand. */
3
+ export declare function HistoryDialog({ tenant, definition, close, }: {
4
+ tenant: string;
5
+ definition: Analyzer;
6
+ close: () => void;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ import{ErrorNotice as e}from"@/shared/components/layout/ErrorNotice";import{usePersonName as t}from"@/shared/hooks/usePersonNames";import{AdminDialog as n}from"./parts";import{formatTime as r}from"../model/presentation";import{useDefinitionAudit as i}from"../hooks/useDocumentAnalysis";import{ActorName as a}from"@/shared/components/workspace/PersonName";import{jsx as o,jsxs as s}from"react/jsx-runtime";export function HistoryDialog({tenant:c,definition:l,close:u}){let d=i(c,l.id,!0),f=t(l.updated_by)||`—`;return o(n,{title:`History of ${l.provider_analyzer_id}`,description:`Last change: “${l.reason}” by ${f} on ${r(l.updated_at)}.`,close:u,children:d.isPending?o(`output`,{className:`text-sm`,children:`Loading history…`}):d.isError?o(e,{error:d.error,retry:()=>void d.refetch()}):d.data.length?o(`ol`,{className:`relative ml-2 border-l`,children:[...d.data].reverse().map(e=>s(`li`,{className:`relative pb-4 pl-4`,children:[o(`span`,{className:`absolute top-1.5 -left-[5px] size-2.5 rounded-full border bg-primary`,"aria-hidden":`true`}),o(`p`,{className:`text-sm font-medium capitalize`,children:e.action.toLowerCase().replaceAll(`_`,` `)}),s(`p`,{className:`text-xs text-muted-foreground`,children:[o(a,{actor:e.actor}),` · `,r(e.at)]}),e.detail&&o(`p`,{className:`text-xs text-muted-foreground`,children:e.detail})]},e.id))}):o(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing recorded yet.`})})}
@@ -0,0 +1,16 @@
1
+ import type { VersionedAnalyzer } from '@/shared/api/document-analysis';
2
+ import type { DefinitionCommand } from '../hooks/useDocumentAnalysis';
3
+ export type LifecycleIntent = 'clone' | 'publish' | 'delete' | 'evaluation' | 'delete-field' | 'delete-category';
4
+ export declare function LifecycleDialog({ intent, saved, target, busy, error, close, reload, submit, }: {
5
+ intent: LifecycleIntent;
6
+ saved: VersionedAnalyzer;
7
+ target?: {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ busy: boolean;
12
+ error: Error | null;
13
+ close: () => void;
14
+ reload: () => void;
15
+ submit: (change: DefinitionCommand['change']) => void;
16
+ }): import("react").JSX.Element;