@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.
- package/README.md +66 -2
- package/dist/boxes/ai-pages.d.ts +15 -0
- package/dist/boxes/ai-pages.js +1 -0
- package/dist/boxes/ai.d.ts +2 -0
- package/dist/boxes/ai.js +1 -0
- package/dist/features/ai-assets/README.md +26 -0
- package/dist/features/ai-assets/components/McpClientToolsPanel.d.ts +6 -0
- package/dist/features/ai-assets/components/McpClientToolsPanel.js +1 -0
- package/dist/features/ai-assets/components/McpEditorLayout.d.ts +29 -0
- package/dist/features/ai-assets/components/McpEditorLayout.js +1 -0
- package/dist/features/ai-assets/components/McpKeysPanel.d.ts +7 -0
- package/dist/features/ai-assets/components/McpKeysPanel.js +1 -0
- package/dist/features/ai-assets/components/McpSyncedData.d.ts +13 -0
- package/dist/features/ai-assets/components/McpSyncedData.js +1 -0
- package/dist/features/ai-assets/components/McpTables.d.ts +36 -0
- package/dist/features/ai-assets/components/McpTables.js +1 -0
- package/dist/features/ai-assets/components/Panels.d.ts +27 -0
- package/dist/features/ai-assets/components/Panels.js +1 -0
- package/dist/features/ai-assets/components/RegistryPages.d.ts +29 -0
- package/dist/features/ai-assets/components/RegistryPages.js +1 -0
- package/dist/features/ai-assets/components/SpecEditors.d.ts +27 -0
- package/dist/features/ai-assets/components/SpecEditors.js +2 -0
- package/dist/features/ai-assets/components/ToolEditor.d.ts +16 -0
- package/dist/features/ai-assets/components/ToolEditor.js +3 -0
- package/dist/features/ai-assets/components/ToolTestForm.d.ts +8 -0
- package/dist/features/ai-assets/components/ToolTestForm.js +1 -0
- package/dist/features/ai-assets/components/fields.d.ts +82 -0
- package/dist/features/ai-assets/components/fields.js +3 -0
- package/dist/features/ai-assets/components/mcp-headings.d.ts +1 -0
- package/dist/features/ai-assets/components/mcp-headings.js +1 -0
- package/dist/features/ai-assets/hooks/useAssets.d.ts +161 -0
- package/dist/features/ai-assets/hooks/useAssets.js +1 -0
- package/dist/features/ai-assets/hooks/useControlTowerTabs.d.ts +10 -0
- package/dist/features/ai-assets/hooks/useControlTowerTabs.js +1 -0
- package/dist/features/ai-assets/index.d.ts +1 -0
- package/dist/features/ai-assets/index.js +1 -0
- package/dist/features/ai-assets/model/endpoints.d.ts +2 -0
- package/dist/features/ai-assets/model/endpoints.js +1 -0
- package/dist/features/ai-assets/model/kinds.d.ts +12 -0
- package/dist/features/ai-assets/model/kinds.js +1 -0
- package/dist/features/ai-assets/model/mcp.d.ts +21 -0
- package/dist/features/ai-assets/model/mcp.js +1 -0
- package/dist/features/ai-assets/model/routes.d.ts +6 -0
- package/dist/features/ai-assets/model/routes.js +1 -0
- package/dist/features/ai-assets/model/tool-contract.d.ts +68 -0
- package/dist/features/ai-assets/model/tool-contract.js +7 -0
- package/dist/features/ai-assets/pages/AssetDesignerPage.d.ts +6 -0
- package/dist/features/ai-assets/pages/AssetDesignerPage.js +1 -0
- package/dist/features/ai-assets/pages/AssetsPage.d.ts +10 -0
- package/dist/features/ai-assets/pages/AssetsPage.js +1 -0
- package/dist/features/ai-assets/pages/GuardrailPolicyPage.d.ts +2 -0
- package/dist/features/ai-assets/pages/GuardrailPolicyPage.js +3 -0
- package/dist/features/ai-assets/pages/GuardrailsPage.d.ts +5 -0
- package/dist/features/ai-assets/pages/GuardrailsPage.js +1 -0
- package/dist/features/ai-assets/pages/LlmProviderPage.d.ts +2 -0
- package/dist/features/ai-assets/pages/LlmProviderPage.js +1 -0
- package/dist/features/ai-assets/pages/LlmProvidersPage.d.ts +2 -0
- package/dist/features/ai-assets/pages/LlmProvidersPage.js +1 -0
- package/dist/features/ai-assets/pages/McpClientPage.d.ts +2 -0
- package/dist/features/ai-assets/pages/McpClientPage.js +1 -0
- package/dist/features/ai-assets/pages/McpPage.d.ts +2 -0
- package/dist/features/ai-assets/pages/McpPage.js +1 -0
- package/dist/features/ai-assets/pages/McpServerPage.d.ts +2 -0
- package/dist/features/ai-assets/pages/McpServerPage.js +1 -0
- package/dist/features/ai-assets/pages/NewToolPage.d.ts +3 -0
- package/dist/features/ai-assets/pages/NewToolPage.js +1 -0
- package/dist/features/ai-studio/README.md +19 -0
- package/dist/features/ai-studio/components/StudioPages.d.ts +1 -0
- package/dist/features/ai-studio/components/StudioPages.js +1 -0
- package/dist/features/ai-studio/index.d.ts +2 -0
- package/dist/features/ai-studio/index.js +1 -0
- package/dist/features/ai-studio/model/demo-data.d.ts +44 -0
- package/dist/features/ai-studio/model/demo-data.js +1 -0
- package/dist/features/ai-studio/model/studio-pages.d.ts +64 -0
- package/dist/features/ai-studio/model/studio-pages.js +1 -0
- package/dist/features/ai-studio/pages/AiStudioPage.d.ts +3 -0
- package/dist/features/ai-studio/pages/AiStudioPage.js +1 -0
- package/dist/features/ai-studio/pages/StudioInventoryPage.d.ts +8 -0
- package/dist/features/ai-studio/pages/StudioInventoryPage.js +1 -0
- package/dist/features/document-analysis/README.md +13 -0
- package/dist/features/document-analysis/components/AnalysisModelPanel.d.ts +5 -0
- package/dist/features/document-analysis/components/AnalysisModelPanel.js +1 -0
- package/dist/features/document-analysis/components/AttributeEditor.d.ts +10 -0
- package/dist/features/document-analysis/components/AttributeEditor.js +5 -0
- package/dist/features/document-analysis/components/CategoryEditor.d.ts +11 -0
- package/dist/features/document-analysis/components/CategoryEditor.js +1 -0
- package/dist/features/document-analysis/components/CategoryGrid.d.ts +11 -0
- package/dist/features/document-analysis/components/CategoryGrid.js +1 -0
- package/dist/features/document-analysis/components/DefinitionDetail.d.ts +9 -0
- package/dist/features/document-analysis/components/DefinitionDetail.js +1 -0
- package/dist/features/document-analysis/components/DefinitionEditor.d.ts +10 -0
- package/dist/features/document-analysis/components/DefinitionEditor.js +1 -0
- package/dist/features/document-analysis/components/DetailsPanel.d.ts +10 -0
- package/dist/features/document-analysis/components/DetailsPanel.js +1 -0
- package/dist/features/document-analysis/components/FieldGrid.d.ts +8 -0
- package/dist/features/document-analysis/components/FieldGrid.js +1 -0
- package/dist/features/document-analysis/components/HistoryDialog.d.ts +7 -0
- package/dist/features/document-analysis/components/HistoryDialog.js +1 -0
- package/dist/features/document-analysis/components/LifecycleDialog.d.ts +16 -0
- package/dist/features/document-analysis/components/LifecycleDialog.js +1 -0
- package/dist/features/document-analysis/components/SubFieldTree.d.ts +9 -0
- package/dist/features/document-analysis/components/SubFieldTree.js +1 -0
- package/dist/features/document-analysis/components/TestResult.d.ts +5 -0
- package/dist/features/document-analysis/components/TestResult.js +1 -0
- package/dist/features/document-analysis/components/parts.d.ts +27 -0
- package/dist/features/document-analysis/components/parts.js +1 -0
- package/dist/features/document-analysis/hooks/useDocumentAnalysis.d.ts +111 -0
- package/dist/features/document-analysis/hooks/useDocumentAnalysis.js +1 -0
- package/dist/features/document-analysis/index.d.ts +1 -0
- package/dist/features/document-analysis/index.js +1 -0
- package/dist/features/document-analysis/model/fieldKinds.d.ts +106 -0
- package/dist/features/document-analysis/model/fieldKinds.js +1 -0
- package/dist/features/document-analysis/model/presentation.d.ts +4 -0
- package/dist/features/document-analysis/model/presentation.js +1 -0
- package/dist/features/document-analysis/pages/AnalyzerAdminPage.d.ts +2 -0
- package/dist/features/document-analysis/pages/AnalyzerAdminPage.js +1 -0
- package/dist/shared/api/document-analysis.d.ts +56 -0
- package/dist/shared/api/document-analysis.js +1 -0
- package/dist/shared/api/guardrails.d.ts +74 -0
- package/dist/shared/api/guardrails.js +1 -0
- package/dist/shared/api/llm-providers.d.ts +59 -0
- package/dist/shared/api/llm-providers.js +1 -0
- package/package.json +24 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as e}from"react";import{Input as t}from"@/shared/components/ui/input";import{SettingsFeedback as n}from"@/shared/components/workspace/SettingsFeedback";import{AdminDialog as r,FormActions as i,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={clone:`Edit as a new version`,publish:`Deploy`,delete:`Delete definition`,evaluation:`Record test result`,"delete-field":`Delete field`,"delete-category":`Delete category`};export function LifecycleDialog({intent:u,saved:d,target:f,busy:p,error:m,close:h,reload:g,submit:_}){let[v,y]=e(u===`clone`?`Changes after deployment`:``),[b,x]=e(``),[S,C]=e(!0),w=u===`delete`||u===`delete-field`||u===`delete-category`,T=u===`clone`?`Deployed versions never change. This copies everything into ${d.data.name} v${d.data.version_no+1}, which you can edit and deploy as ${d.data.name}_v${d.data.version_no+1}.`:u===`publish`?`Create ${d.data.provider_analyzer_id} in the AI service with the registered AI model. After deployment this version is locked.`:u===`evaluation`?`Run a few real documents through ${d.data.provider_analyzer_id}, then record what you tested and whether the results were right.`:u===`delete`?`Delete this version from the AI service and from this list. A classifier that still uses it prevents deletion.`:`Remove ${f?.name??`this item`} from the draft.`;return s(r,{title:l[u],description:T,close:h,busy:p,children:c(`form`,{onSubmit:e=>{e.preventDefault(),u===`clone`?_({type:`clone`,reason:v.trim()}):u===`evaluation`?_({type:`evaluation`,reference:b.trim(),passed:S}):(u===`delete-field`||u===`delete-category`)&&f?_({type:u,id:f.id}):(u===`publish`||u===`delete`)&&_({type:u})},children:[c(`div`,{className:`mb-4 rounded-xl border bg-muted/30 p-3 text-sm`,children:[s(`span`,{className:`font-semibold`,children:d.data.name}),c(`span`,{className:`ml-2 text-muted-foreground`,children:[`Version `,d.data.version_no]}),f&&s(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:f.name})]}),u===`clone`&&s(a,{label:`What will you change?`,children:s(t,{required:!0,value:v,disabled:p,maxLength:2e3,onChange:e=>y(e.target.value),placeholder:`What will change in this version?`})}),u===`evaluation`&&c(`div`,{className:`grid gap-4`,children:[s(a,{label:`What did you test?`,help:`For example: three recent slips from two senders.`,children:s(t,{required:!0,value:b,maxLength:2e3,disabled:p,onChange:e=>x(e.target.value)})}),s(a,{label:`Result`,children:c(`select`,{className:o,value:S?`passed`:`failed`,disabled:p,onChange:e=>C(e.target.value===`passed`),children:[s(`option`,{value:`passed`,children:`Results were right`}),s(`option`,{value:`failed`,children:`Needs changes`})]})})]}),u===`publish`&&s(`p`,{className:`text-sm text-muted-foreground`,children:`A classifier can deploy only when every analyzer it extracts with is deployed.`}),s(`div`,{className:`mt-4`,children:s(n,{error:m,reload:g})}),s(i,{busy:p,close:h,destructive:w,disabled:u===`clone`&&!v.trim()||u===`evaluation`&&!b.trim(),label:u===`clone`?`Create version`:u===`evaluation`?`Save result`:w?`Delete`:`Deploy`})]})})}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SubField } from '../model/fieldKinds';
|
|
2
|
+
/** Edit the values of a Group or Table row; nested Groups and Tables open beneath their row. */
|
|
3
|
+
export declare function SubFieldTree({ value, depth, path, busy, onChange, }: {
|
|
4
|
+
value: SubField[];
|
|
5
|
+
depth: number;
|
|
6
|
+
path: string;
|
|
7
|
+
busy: boolean;
|
|
8
|
+
onChange: (next: SubField[]) => void;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Plus as e,Trash2 as t}from"lucide-react";import{Button as n}from"@/shared/components/ui/button";import{Input as r}from"@/shared/components/ui/input";import{cn as i}from"@/shared/lib/utils";import{allowedKinds as a,blankSub as o,childDepth as s,subKinds as c}from"../model/fieldKinds";import{control as l}from"../model/presentation";import{jsxs as u,jsx as d}from"react/jsx-runtime";export function SubFieldTree({value:f,depth:p,path:m,busy:h,onChange:g}){let _=a(p),v=(e,t)=>g(f.map(n=>n.key===e?{...n,...t}:n));return u(`div`,{className:i(`grid gap-2`,p>s(`group`)&&`border-l-2 pl-3`),children:[f.map((e,a)=>{let y=`${m}${e.name.trim()||`value ${a+1}`}`,b=e.kind===`group`||e.kind===`table`;return u(`div`,{className:`grid gap-2`,children:[u(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,10rem)_minmax(0,8rem)_minmax(0,1fr)_auto]`,children:[d(r,{"aria-label":`${y} name`,value:e.name,disabled:h,placeholder:`name`,onChange:t=>v(e.key,{name:t.target.value})}),u(`div`,{className:`flex gap-1`,children:[d(`select`,{"aria-label":`${y} kind`,className:l,value:e.kind,disabled:h,onChange:t=>{let n=_.find(e=>e===t.target.value);n&&v(e.key,{kind:n,children:(n===`group`||n===`table`)&&!e.children.length?[o()]:e.children})},children:c.filter(e=>_.includes(e.value)).map(e=>u(`option`,{value:e.value,children:[e.label,` · `,e.type]},e.value))}),e.kind===`list`&&u(`select`,{"aria-label":`${y} list of`,className:i(l,`w-24`),value:e.listItem,disabled:h,onChange:t=>v(e.key,{listItem:t.target.value===`number`?`number`:`string`}),children:[d(`option`,{value:`string`,children:`of text`}),d(`option`,{value:`number`,children:`of numbers`})]})]}),d(r,{"aria-label":`${y} description`,value:e.description,disabled:h,placeholder:`What this value holds`,onChange:t=>v(e.key,{description:t.target.value})}),d(n,{variant:`destructive`,type:`button`,size:`icon`,"aria-label":`Remove ${y}`,disabled:h||f.length===1,onClick:()=>g(f.filter(t=>t.key!==e.key)),children:d(t,{})})]}),b&&u(`div`,{className:`ml-4`,children:[d(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e.kind===`table`?`Columns of each row`:`Values in this group`}),d(SubFieldTree,{value:e.children,depth:p+s(e.kind),path:`${y} › `,busy:h,onChange:t=>v(e.key,{children:t})})]})]},e.key)}),d(`div`,{children:u(n,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>g([...f,o()]),children:[d(e,{}),`Add value`,m?` to ${m.replace(/ › $/,``)}`:``]})})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRecord as e}from"@/shared/api/http";import{DataTable as t}from"@/shared/components/workspace/DataTable";import{cn as n}from"@/shared/lib/utils";import{jsx as r,jsxs as i}from"react/jsx-runtime";const a=t=>Array.isArray(t)?t.filter(t=>e(t)&&typeof t.field_name==`string`&&typeof t.path==`string`):[];function o(e){return typeof e==`boolean`?e?`Yes`:`No`:typeof e==`object`?JSON.stringify(e):String(e)}function s({value:e}){return e==null?r(`span`,{className:`text-muted-foreground`,children:`—`}):i(`span`,{className:n(`rounded-badge px-2.5 py-1 text-xs font-medium`,e>=.8?`bg-success/10 text-success`:`bg-warning/15 text-warning-foreground`),children:[Math.round(e*100),`%`]})}const c=[``,`pl-4`,`pl-8`,`pl-12`,`pl-16`];function l(e,t){let u=c[Math.min(t,c.length-1)],d=e.fields??e.items,f=e.path.endsWith(`]`)?`${e.field_name} ${e.path.slice(e.path.lastIndexOf(`[`))}`:e.field_name;return d?[r(`tr`,{children:i(`td`,{colSpan:5,className:n(`pt-2 pb-1 text-xs font-semibold`,u),children:[f,i(`span`,{className:`ml-2 font-sans font-normal text-muted-foreground`,children:[e.items?`${e.items.length} ${e.items.length===1?`row`:`rows`}`:`group`,e.method?` · ${e.method}`:``]})]})},e.path),...a(d).flatMap(e=>l(e,t+1))]:[i(`tr`,{className:`align-top`,children:[r(`td`,{className:n(`py-1.5 pr-3 text-xs break-words`,u),title:e.path,children:f}),r(`td`,{className:`py-2 pr-3 text-xs break-words`,children:e.found?o(e.value):r(`span`,{className:`text-muted-foreground italic`,children:`Not found`})}),r(`td`,{className:`py-2 pr-3 text-xs capitalize`,children:e.method??`—`}),r(`td`,{className:`py-2 pr-3 text-xs`,"data-grid-value":e.confidence==null?void 0:`${Math.round(e.confidence*100)}%`,"data-grid-sort":e.confidence,children:r(s,{value:e.confidence})}),i(`td`,{className:`py-2 text-xs text-muted-foreground`,children:[e.page??`—`,e.source&&r(`span`,{className:`block truncate text-[12px]`,title:e.source,"aria-label":`Source region ${e.source}`,children:e.source})]})]},e.path)]}export function TestResult({run:e}){return i(`div`,{className:`grid gap-3`,children:[e.warnings.length>0&&r(`ul`,{role:`alert`,className:`rounded-lg border border-warning/30 bg-warning/10 p-3 text-xs`,children:e.warnings.map(e=>r(`li`,{children:e},e))}),e.parts.map((e,n)=>{let o=a(e.fields);return i(`section`,{className:`rounded-xl border`,"aria-label":`Part ${n+1}`,children:[i(`header`,{className:`flex flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[r(`span`,{className:`font-semibold`,children:e.category??`Whole file`}),i(`span`,{className:`text-xs text-muted-foreground`,children:[`pages `,e.start_page??`?`,`–`,e.end_page??`?`]}),r(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.analyzer_id??`not extracted`})]}),o.length?r(`div`,{className:`overflow-x-auto px-3 pb-2`,children:i(t,{"aria-label":`Extracted fields for part ${n+1}`,className:`w-full min-w-[44rem] table-fixed text-left`,children:[i(`colgroup`,{children:[r(`col`,{className:`w-[26%]`}),r(`col`,{}),r(`col`,{className:`w-20`}),r(`col`,{className:`w-24`}),r(`col`,{className:`w-40`})]}),r(`thead`,{className:`text-xs text-muted-foreground`,children:i(`tr`,{children:[r(`th`,{className:`py-1.5 font-medium`,children:`Field`}),r(`th`,{className:`py-1.5 font-medium`,children:`Value`}),r(`th`,{className:`py-1.5 font-medium`,children:`Method`}),r(`th`,{className:`py-1.5 font-medium`,children:`Confidence`}),r(`th`,{className:`py-1.5 font-medium`,children:`Page · source`})]})}),r(`tbody`,{children:o.flatMap(e=>l(e,0))})]})}):r(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:e.analyzer_id?`No values found.`:`Recognised only: this category has no analyzer.`})]},n)}),i(`details`,{className:`rounded-xl border p-3 text-xs`,children:[r(`summary`,{className:`cursor-pointer font-medium`,children:`Result as JSON`}),r(`pre`,{className:`mt-2 font-mono leading-5 break-all whitespace-pre-wrap`,children:JSON.stringify(e,null,2)})]})]})}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { AnalyzerState } from '@/shared/api/document-analysis';
|
|
3
|
+
export declare function StateBadge({ state }: {
|
|
4
|
+
state: AnalyzerState;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function FormField({ label, children, help, }: {
|
|
7
|
+
label: string;
|
|
8
|
+
children: ReactElement<{
|
|
9
|
+
id?: string;
|
|
10
|
+
'aria-describedby'?: string;
|
|
11
|
+
}>;
|
|
12
|
+
help?: string;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export declare function AdminDialog({ title, description, close, busy, children, }: {
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
close: () => void;
|
|
18
|
+
busy?: boolean;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
export declare function FormActions({ busy, close, label, disabled, destructive, }: {
|
|
22
|
+
busy: boolean;
|
|
23
|
+
close: () => void;
|
|
24
|
+
label?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
destructive?: boolean;
|
|
27
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cloneElement as e,useId as t}from"react";import{Dialog as n}from"@base-ui/react/dialog";import{CheckCircle2 as r,CircleDashed as i,Clock3 as a,TriangleAlert as o,X as s}from"lucide-react";import{Button as c}from"@/shared/components/ui/button";import{cn as l}from"@/shared/lib/utils";import{jsx as u,jsxs as d}from"react/jsx-runtime";export function StateBadge({state:e}){let t=e===`ACTIVE`,n=e===`FAILED`||e===`DELETE_FAILED`,s=t?r:n?o:e===`DRAFT`?i:a;return d(`span`,{className:l(`inline-flex items-center gap-1.5 rounded-badge border px-2.5 py-1 text-xs font-medium whitespace-nowrap`,t?`border-success/25 bg-success/10 text-success`:n?`border-destructive/25 bg-destructive/10 text-destructive`:`border-border bg-muted text-muted-foreground`),children:[u(s,{className:`size-3`,"aria-hidden":`true`}),e.toLowerCase().replaceAll(`_`,` `)]})}export function FormField({label:n,children:r,help:i}){let a=t();return d(`div`,{className:`grid gap-1.5 text-sm`,children:[u(`label`,{htmlFor:a,className:`font-medium`,children:n}),e(r,{id:a,"aria-describedby":i?`${a}-help`:void 0}),i&&u(`p`,{id:`${a}-help`,className:`text-xs leading-5 text-muted-foreground`,children:i})]})}export function AdminDialog({title:e,description:t,close:r,busy:i,children:a}){return u(n.Root,{open:!0,onOpenChange:e=>{!e&&!i&&r()},children:d(n.Portal,{children:[u(n.Backdrop,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm`}),d(n.Popup,{className:`fixed top-1/2 left-1/2 z-50 max-h-[90svh] w-[calc(100%_-_2rem)] max-w-2xl -translate-1/2 overflow-y-auto rounded-2xl border bg-popover p-5 shadow-xl sm:p-6`,children:[d(`div`,{className:`flex items-start justify-between gap-4`,children:[d(`div`,{children:[u(n.Title,{className:`text-lg font-semibold`,children:e}),u(n.Description,{className:`mt-1 text-sm leading-6 text-muted-foreground`,children:t})]}),u(c,{variant:`ghost`,size:`icon`,"aria-label":`Close editor`,disabled:i,onClick:r,children:u(s,{})})]}),u(`div`,{className:`mt-5`,children:a})]})]})})}export function FormActions({busy:e,close:t,label:n=`Save changes`,disabled:r=!1,destructive:i=!1}){return d(`div`,{className:`mt-5 flex justify-end gap-2 border-t pt-4`,children:[u(c,{type:`button`,variant:`outline`,disabled:e,onClick:t,children:`Cancel`}),u(c,{type:`submit`,variant:i?`destructive`:`default`,disabled:e||r,children:e?`Working…`:n})]})}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type AnalyzerKind, type AnalyzerUpdate, type CategoryWrite, type FieldWrite, type VersionedAnalyzer } from '@/shared/api/document-analysis';
|
|
2
|
+
export declare function useDefinitions(tenant: string, kind: AnalyzerKind, status: string, offset: number, enabled: boolean, grid?: {
|
|
3
|
+
search?: string;
|
|
4
|
+
sortBy?: string;
|
|
5
|
+
sortDirection?: 'asc' | 'desc';
|
|
6
|
+
}): import("@tanstack/react-query").UseQueryResult<{
|
|
7
|
+
items: import("@/shared/api/generated/schema").components["schemas"]["AnalyzerRead"][];
|
|
8
|
+
total: number;
|
|
9
|
+
}, Error>;
|
|
10
|
+
export declare function useDefinition(tenant: string, id: string | null, enabled: boolean): import("@tanstack/react-query").UseQueryResult<VersionedAnalyzer, Error>;
|
|
11
|
+
export declare function useAnalysisModel(tenant: string): import("@tanstack/react-query").UseQueryResult<{
|
|
12
|
+
current: import("@/shared/api/generated/schema").components["schemas"]["AnalysisModelRead"] | null;
|
|
13
|
+
available: import("@/shared/api/generated/schema").components["schemas"]["AvailableModel"][];
|
|
14
|
+
}, Error>;
|
|
15
|
+
export declare function useSetAnalysisModel(tenant: string): import("@tanstack/react-query").UseMutationResult<{
|
|
16
|
+
id: string;
|
|
17
|
+
version_no: number;
|
|
18
|
+
completion_model: string;
|
|
19
|
+
model_version: string;
|
|
20
|
+
deployment: string;
|
|
21
|
+
}, Error, {
|
|
22
|
+
completion_model: string;
|
|
23
|
+
model_version: string;
|
|
24
|
+
}, unknown>;
|
|
25
|
+
export declare function useTargets(tenant: string, enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
26
|
+
id: string;
|
|
27
|
+
tenant_id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
version_no: number;
|
|
30
|
+
version: number;
|
|
31
|
+
kind: string;
|
|
32
|
+
status: import("@/shared/api/generated/schema").components["schemas"]["DeploymentState"];
|
|
33
|
+
definition_status: import("@/shared/api/generated/schema").components["schemas"]["siriuss__capabilities__configuration__model__DefinitionStatus"];
|
|
34
|
+
description: string;
|
|
35
|
+
model_role: import("@/shared/api/generated/schema").components["schemas"]["ModelRole"];
|
|
36
|
+
model_profile_id: string | null;
|
|
37
|
+
provider_analyzer_id: string;
|
|
38
|
+
provider_config: import("@/shared/api/generated/schema").components["schemas"]["JsonObject"];
|
|
39
|
+
reason: string;
|
|
40
|
+
content_hash: string | null;
|
|
41
|
+
evaluation: import("@/shared/api/generated/schema").components["schemas"]["JsonObject"] | null;
|
|
42
|
+
last_error: string | null;
|
|
43
|
+
fields: import("@/shared/api/generated/schema").components["schemas"]["FieldRead"][];
|
|
44
|
+
categories: import("@/shared/api/generated/schema").components["schemas"]["CategoryRead"][];
|
|
45
|
+
created_at: number | null;
|
|
46
|
+
created_by: string | null;
|
|
47
|
+
updated_at: number | null;
|
|
48
|
+
updated_by: string | null;
|
|
49
|
+
}[], Error>;
|
|
50
|
+
export declare function useDefinitionPreview(tenant: string, id: string, enabled: boolean): import("@tanstack/react-query").UseQueryResult<Record<string, unknown>, Error>;
|
|
51
|
+
export declare function useDefinitionAudit(tenant: string, id: string, enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
52
|
+
id: string;
|
|
53
|
+
analyzer_id: string;
|
|
54
|
+
action: string;
|
|
55
|
+
actor: string;
|
|
56
|
+
at: number;
|
|
57
|
+
detail: string;
|
|
58
|
+
}[], Error>;
|
|
59
|
+
type Change = {
|
|
60
|
+
type: 'metadata';
|
|
61
|
+
input: AnalyzerUpdate;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'clone';
|
|
64
|
+
reason: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'field';
|
|
67
|
+
input: FieldWrite;
|
|
68
|
+
id?: string;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'delete-field';
|
|
71
|
+
id: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'category';
|
|
74
|
+
input: CategoryWrite;
|
|
75
|
+
id?: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'delete-category';
|
|
78
|
+
id: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'evaluation';
|
|
81
|
+
reference: string;
|
|
82
|
+
passed: boolean;
|
|
83
|
+
} | {
|
|
84
|
+
type: 'publish' | 'sync' | 'delete';
|
|
85
|
+
};
|
|
86
|
+
export type DefinitionCommand = {
|
|
87
|
+
saved: VersionedAnalyzer;
|
|
88
|
+
change: Change;
|
|
89
|
+
};
|
|
90
|
+
/** Mutations run once and use the editor's original ETag, never a refetched replacement. */
|
|
91
|
+
export declare function useDefinitionActions(tenant: string): import("@tanstack/react-query").UseMutationResult<void | VersionedAnalyzer, Error, DefinitionCommand, unknown>;
|
|
92
|
+
export declare function useCreateDefinition(tenant: string): import("@tanstack/react-query").UseMutationResult<VersionedAnalyzer, Error, {
|
|
93
|
+
name: string;
|
|
94
|
+
kind: import("@/shared/api/generated/schema").components["schemas"]["AnalyzerKind"];
|
|
95
|
+
description: string;
|
|
96
|
+
model_role?: import("@/shared/api/generated/schema").components["schemas"]["ModelRole"] | null;
|
|
97
|
+
model_profile_id?: string | null;
|
|
98
|
+
provider_config?: import("@/shared/api/generated/schema").components["schemas"]["JsonObject"];
|
|
99
|
+
reason: string;
|
|
100
|
+
}, unknown>;
|
|
101
|
+
/** Running a test costs a provider call, so it never retries on its own. */
|
|
102
|
+
export declare function useTestRun(tenant: string, id: string): import("@tanstack/react-query").UseMutationResult<{
|
|
103
|
+
analyzer_id: string;
|
|
104
|
+
parts: import("@/shared/api/generated/schema").components["schemas"]["TestPartRead"][];
|
|
105
|
+
warnings: string[];
|
|
106
|
+
raw?: {
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
} | null;
|
|
109
|
+
}, Error, File, unknown>;
|
|
110
|
+
export declare function useDriftCheck(tenant: string): import("@tanstack/react-query").UseMutationResult<import("@/shared/api/document-analysis").DriftReport, Error, void, unknown>;
|
|
111
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMutation as e,useQuery as t,useQueryClient as n}from"@tanstack/react-query";import{cloneAnalyzer as r,createAnalyzer as i,deleteAnalyzer as a,deleteCategory as o,deleteField as s,evaluateAnalyzer as c,getAnalyzer as l,getAnalyzerAudit as u,getAnalyzers as d,getAnalysisModel as f,getRoutingTargets as p,previewAnalyzer as m,publishAnalyzer as h,reconcileAnalyzers as g,saveCategory as _,saveField as v,setAnalysisModel as y,testAnalyzer as b,syncAnalyzer as x,updateAnalyzer as S}from"@/shared/api/document-analysis";const C=e=>[`document-analysis`,e],w=(e,t)=>[...C(e),`detail`,t],T={staleTime:1/0,refetchOnWindowFocus:!1};export function useDefinitions(e,n,r,i,a,o={}){return t({queryKey:[...C(e),`list`,n,r,i,o],queryFn:({signal:t})=>d(e,n,{status:r,offset:i,...o},t),enabled:a,...T})}export function useDefinition(e,n,r){return t({queryKey:w(e,n??``),queryFn:({signal:t})=>l(e,n??``,t),enabled:r&&!!n,...T})}export function useAnalysisModel(e){return t({queryKey:[...C(e),`analysis-model`],queryFn:({signal:t})=>f(e,t),enabled:!!e,...T})}export function useSetAnalysisModel(t){let r=n();return e({mutationFn:e=>y(t,e),onSuccess:()=>r.invalidateQueries({queryKey:[...C(t),`analysis-model`]}),retry:!1})}export function useTargets(e,n){return t({queryKey:[...C(e),`targets`],queryFn:({signal:t})=>p(e,t),enabled:n,...T})}export function useDefinitionPreview(e,n,r){return t({queryKey:[...C(e),`preview`,n],queryFn:({signal:t})=>m(e,n,t),enabled:r,...T,retry:!1})}export function useDefinitionAudit(e,n,r){return t({queryKey:[...C(e),`audit`,n],queryFn:({signal:t})=>u(e,n,t),enabled:r,...T})}export function useDefinitionActions(t){let i=n(),l=()=>i.invalidateQueries({queryKey:C(t)});return e({mutationFn:async({saved:e,change:n})=>{switch(n.type){case`metadata`:return S(t,e,n.input);case`clone`:return r(t,e,n.reason);case`field`:return v(t,e,n.input,n.id);case`delete-field`:return s(t,e,n.id);case`category`:return _(t,e,n.input,n.id);case`delete-category`:return o(t,e,n.id);case`evaluation`:return c(t,e,n.reference,n.passed);case`publish`:return h(t,e);case`sync`:return x(t,e);case`delete`:return a(t,e)}},onSuccess:async(e,n)=>{e&&i.setQueryData(w(t,e.data.id),e),n.change.type===`delete`&&i.removeQueries({queryKey:w(t,n.saved.data.id)}),await l()},onError:()=>{l()},retry:!1})}export function useCreateDefinition(t){let r=n();return e({mutationFn:e=>i(t,e),onSuccess:async e=>{r.setQueryData(w(t,e.data.id),e),await r.invalidateQueries({queryKey:[...C(t),`list`]})},retry:!1})}export function useTestRun(t,r){let i=n();return e({mutationFn:e=>b(t,r,e),onSuccess:()=>i.invalidateQueries({queryKey:[...C(t),`audit`,r]}),retry:!1})}export function useDriftCheck(t){return e({mutationFn:()=>g(t),retry:!1})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AnalyzersPage, ClassifiersPage } from './pages/AnalyzerAdminPage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{AnalyzersPage,ClassifiersPage}from"./pages/AnalyzerAdminPage";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { AnalyzerField, FieldWrite } from '@/shared/api/document-analysis';
|
|
2
|
+
/** Plain-language kinds; each maps to exactly one documented type shape. */
|
|
3
|
+
export declare const fieldKinds: readonly [{
|
|
4
|
+
readonly value: 'text';
|
|
5
|
+
readonly label: 'Text';
|
|
6
|
+
readonly type: 'string';
|
|
7
|
+
readonly help: 'A name, reference, address or any written value.';
|
|
8
|
+
}, {
|
|
9
|
+
readonly value: 'number';
|
|
10
|
+
readonly label: 'Number';
|
|
11
|
+
readonly type: 'number';
|
|
12
|
+
readonly help: 'An amount, count, rate or percentage.';
|
|
13
|
+
}, {
|
|
14
|
+
readonly value: 'date';
|
|
15
|
+
readonly label: 'Date';
|
|
16
|
+
readonly type: 'date';
|
|
17
|
+
readonly help: 'A calendar date, such as inception date.';
|
|
18
|
+
}, {
|
|
19
|
+
readonly value: 'boolean';
|
|
20
|
+
readonly label: 'Yes / No';
|
|
21
|
+
readonly type: 'boolean';
|
|
22
|
+
readonly help: 'A stated yes or no answer.';
|
|
23
|
+
}, {
|
|
24
|
+
readonly value: 'choice';
|
|
25
|
+
readonly label: 'Choice';
|
|
26
|
+
readonly type: 'string + enum';
|
|
27
|
+
readonly help: 'One value from a list of options you define.';
|
|
28
|
+
}, {
|
|
29
|
+
readonly value: 'list';
|
|
30
|
+
readonly label: 'List';
|
|
31
|
+
readonly type: 'array';
|
|
32
|
+
readonly help: 'Several text or number values, such as hazards.';
|
|
33
|
+
}, {
|
|
34
|
+
readonly value: 'table';
|
|
35
|
+
readonly label: 'Table';
|
|
36
|
+
readonly type: 'array of objects';
|
|
37
|
+
readonly help: 'Rows with columns, such as locations or claims.';
|
|
38
|
+
}, {
|
|
39
|
+
readonly value: 'group';
|
|
40
|
+
readonly label: 'Group';
|
|
41
|
+
readonly type: 'object';
|
|
42
|
+
readonly help: 'Related values kept together, such as an address or an amount with its currency.';
|
|
43
|
+
}];
|
|
44
|
+
export type FieldKind = (typeof fieldKinds)[number]['value'];
|
|
45
|
+
/** How the AI produces the value; a Choice is always classified. */
|
|
46
|
+
export declare const fieldMethods: readonly [{
|
|
47
|
+
readonly value: 'extract';
|
|
48
|
+
readonly label: 'Extract';
|
|
49
|
+
readonly help: 'Copy the value exactly as the document states it.';
|
|
50
|
+
}, {
|
|
51
|
+
readonly value: 'generate';
|
|
52
|
+
readonly label: 'Generate';
|
|
53
|
+
readonly help: 'The AI works the value out, e.g. a summary or a derived total.';
|
|
54
|
+
}, {
|
|
55
|
+
readonly value: 'classify';
|
|
56
|
+
readonly label: 'Classify';
|
|
57
|
+
readonly help: 'The AI picks one of your options.';
|
|
58
|
+
}];
|
|
59
|
+
export type FieldMethod = (typeof fieldMethods)[number]['value'];
|
|
60
|
+
export declare const methodLabel: (method: string | null | undefined) => "Classify" | "Extract" | "Generate";
|
|
61
|
+
/** A value inside a Group or a Table row. */
|
|
62
|
+
export type SubKind = 'text' | 'number' | 'date' | 'boolean' | 'list' | 'group' | 'table';
|
|
63
|
+
export type ListItem = 'string' | 'number';
|
|
64
|
+
export type SubField = {
|
|
65
|
+
key: string;
|
|
66
|
+
name: string;
|
|
67
|
+
kind: SubKind;
|
|
68
|
+
description: string;
|
|
69
|
+
listItem: ListItem;
|
|
70
|
+
children: SubField[];
|
|
71
|
+
};
|
|
72
|
+
export declare const subKinds: {
|
|
73
|
+
value: SubKind;
|
|
74
|
+
label: string;
|
|
75
|
+
type: string;
|
|
76
|
+
}[];
|
|
77
|
+
export declare const MAX_DEPTH = 3;
|
|
78
|
+
export declare const blankSub: (kind?: SubKind) => SubField;
|
|
79
|
+
/** Shape depth used below a node at `depth`: groups add one level, tables add two. */
|
|
80
|
+
export declare function allowedKinds(depth: number): SubKind[];
|
|
81
|
+
/** The depth of the children of a top-level Group (1) or Table (2). */
|
|
82
|
+
export declare const childDepth: (kind: FieldKind | SubKind) => 1 | 2;
|
|
83
|
+
export declare function toProperties(children: SubField[]): Record<string, unknown>;
|
|
84
|
+
export declare function toShape(sub: SubField): Record<string, unknown>;
|
|
85
|
+
export declare function childrenOf(properties: unknown): SubField[];
|
|
86
|
+
export declare function kindOf(field: Pick<AnalyzerField, 'field_type' | 'method' | 'items'>): FieldKind;
|
|
87
|
+
/** The standard type a kind maps to, e.g. Group → object. */
|
|
88
|
+
export declare const standardType: (field: AnalyzerField) => "array" | "array of objects" | "boolean" | "date" | "number" | "object" | "string" | "string + enum";
|
|
89
|
+
export declare function kindLabel(field: AnalyzerField): string;
|
|
90
|
+
/** Nested values of a Table or Group, for the read-only grid. */
|
|
91
|
+
export declare function subFieldsOf(field: Pick<AnalyzerField, 'items' | 'properties'>): SubField[];
|
|
92
|
+
export declare const namePattern: RegExp;
|
|
93
|
+
/** Problems a user can fix in the builder before anything is sent. */
|
|
94
|
+
export declare function subFieldProblems(children: SubField[], depth: number): string[];
|
|
95
|
+
/** Build the API field from the plain-language kind and method. */
|
|
96
|
+
export declare function toFieldWrite(input: {
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
kind: FieldKind;
|
|
100
|
+
method: FieldMethod;
|
|
101
|
+
confidence: boolean;
|
|
102
|
+
choices: string[];
|
|
103
|
+
listItem: ListItem;
|
|
104
|
+
children: SubField[];
|
|
105
|
+
sortOrder: number;
|
|
106
|
+
}): FieldWrite;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRecord as e}from"@/shared/api/http";export const fieldKinds=[{value:`text`,label:`Text`,type:`string`,help:`A name, reference, address or any written value.`},{value:`number`,label:`Number`,type:`number`,help:`An amount, count, rate or percentage.`},{value:`date`,label:`Date`,type:`date`,help:`A calendar date, such as inception date.`},{value:`boolean`,label:`Yes / No`,type:`boolean`,help:`A stated yes or no answer.`},{value:`choice`,label:`Choice`,type:`string + enum`,help:`One value from a list of options you define.`},{value:`list`,label:`List`,type:`array`,help:`Several text or number values, such as hazards.`},{value:`table`,label:`Table`,type:`array of objects`,help:`Rows with columns, such as locations or claims.`},{value:`group`,label:`Group`,type:`object`,help:`Related values kept together, such as an address or an amount with its currency.`}];export const fieldMethods=[{value:`extract`,label:`Extract`,help:`Copy the value exactly as the document states it.`},{value:`generate`,label:`Generate`,help:`The AI works the value out, e.g. a summary or a derived total.`},{value:`classify`,label:`Classify`,help:`The AI picks one of your options.`}];export const methodLabel=e=>fieldMethods.find(t=>t.value===(e??`extract`))?.label??`Extract`;export const subKinds=[{value:`text`,label:`Text`,type:`string`},{value:`number`,label:`Number`,type:`number`},{value:`date`,label:`Date`,type:`date`},{value:`boolean`,label:`Yes / No`,type:`boolean`},{value:`list`,label:`List`,type:`array`},{value:`group`,label:`Group`,type:`object`},{value:`table`,label:`Table`,type:`array of objects`}];export const MAX_DEPTH=3;let t=0;export const blankSub=(e=`text`)=>({key:`sub-${++t}`,name:``,kind:e,description:``,listItem:`string`,children:[]});export function allowedKinds(e){return subKinds.map(e=>e.value).filter(t=>t===`table`?e+2<=3:t===`group`||t===`list`?e+1<=3:e<=3)}export const childDepth=e=>e===`table`?2:1;function n(e){return e===`text`?`string`:e}export function toProperties(e){return Object.fromEntries(e.filter(e=>e.name.trim()).map(e=>[e.name.trim(),toShape(e)]))}export function toShape(e){let t=e.description.trim()||e.name.trim();switch(e.kind){case`group`:return{type:`object`,description:t,properties:toProperties(e.children)};case`table`:return{type:`array`,description:t,items:{type:`object`,properties:toProperties(e.children)}};case`list`:return{type:`array`,description:t,items:{type:e.listItem}};default:return{type:n(e.kind),description:t}}}function r(t,n){let r=blankSub();if(r.name=t,!e(n))return r;if(r.description=typeof n.description==`string`?n.description:``,n.type===`object`)r.kind=`group`,r.children=childrenOf(n.properties);else if(n.type===`array`){let t=e(n.items)?n.items:{};t.type===`object`?(r.kind=`table`,r.children=childrenOf(t.properties)):(r.kind=`list`,r.listItem=t.type===`number`?`number`:`string`)}else r.kind=n.type===`number`||n.type===`date`||n.type===`boolean`?n.type:`text`;return r}export function childrenOf(t){return e(t)?Object.entries(t).map(([e,t])=>r(e,t)):[]}export function kindOf(t){if(t.method===`classify`)return`choice`;switch(t.field_type){case`string`:return`text`;case`object`:return`group`;case`array`:return e(t.items)&&t.items.type===`object`?`table`:`list`;default:return t.field_type}}export const standardType=e=>fieldKinds.find(t=>t.value===kindOf(e))?.type??e.field_type;export function kindLabel(t){let n=kindOf(t),r=fieldKinds.find(e=>e.value===n)?.label??n;return n===`choice`&&t.enum_values?.length?`${r}: ${t.enum_values.join(`, `)}`:n===`list`&&e(t.items)&&t.items.type===`number`?`List of numbers`:r}export function subFieldsOf(t){return childrenOf(e(t.items)?t.items.properties:t.properties)}export const namePattern=/^[A-Za-z][A-Za-z0-9_]{0,63}$/;export function subFieldProblems(e,t){let n=e.filter(e=>e.name.trim()),r=n.map(e=>e.name.trim()),i=[];n.length||i.push(`Add at least one value.`),r.some(e=>!namePattern.test(e))&&i.push(`Names use letters, digits or underscores and start with a letter.`),new Set(r).size!==r.length&&i.push(`Names must be unique at each level.`);for(let e of n)allowedKinds(t).includes(e.kind)||i.push(`${e.name} nests deeper than three levels.`),(e.kind===`group`||e.kind===`table`)&&i.push(...subFieldProblems(e.children,t+childDepth(e.kind)));return[...new Set(i)]}export function toFieldWrite(e){let t=e.kind===`choice`?`classify`:e.method,n={name:e.name.trim(),description:e.description.trim(),sort_order:e.sortOrder,estimate_source_and_confidence:t===`extract`||e.confidence,items:null,properties:null,enum_values:null,method:t};switch(e.kind){case`text`:return{...n,field_type:`string`};case`choice`:return{...n,field_type:`string`,enum_values:e.choices};case`list`:return{...n,field_type:`array`,items:{type:e.listItem}};case`table`:return{...n,field_type:`array`,items:{type:`object`,properties:toProperties(e.children)}};case`group`:return{...n,field_type:`object`,properties:toProperties(e.children)};default:return{...n,field_type:e.kind}}}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnalyzerState } from '@/shared/api/document-analysis';
|
|
2
|
+
export declare const control = "h-9 w-full rounded-lg border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50";
|
|
3
|
+
export declare const states: AnalyzerState[];
|
|
4
|
+
export declare function formatTime(value: number | null): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatInstant as e}from"@/shared/lib/datetime";export const control=`h-9 w-full rounded-lg border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`;export const states=[`DRAFT`,`PUBLISHING`,`ACTIVE`,`FAILED`,`DELETING`,`DELETE_FAILED`];export function formatTime(t){return e(t||null)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GridHeader as e,GridHeaderSlot as t}from"@/shared/components/workspace/GridHeader";import{DataTable as n}from"@/shared/components/workspace/DataTable";import{useGrid as r}from"@/shared/hooks/useGrid";import{SortHeader as i}from"@/shared/components/workspace/SortHeader";import{useDebouncedValue as a}from"@/shared/hooks/useDebouncedValue";import{useState as o}from"react";import{useSearchParams as s}from"react-router-dom";import{ArrowLeft as ee,ArrowRight as te,FileSliders as c,GitBranch as l,Plus as u,ScanSearch as ne}from"lucide-react";import{useSession as d}from"@/shared/auth/session-context";import{pageAccess as f}from"@/shared/auth/page-access";import{ErrorNotice as p}from"@/shared/components/layout/ErrorNotice";import{Button as m}from"@/shared/components/ui/button";import{BackLink as h}from"@/shared/components/workspace/BackLink";import{ControlHeader as g}from"@/shared/components/workspace/ControlHeader";import{useTenantScope as _}from"@/shared/hooks/useTenantScope";import{RefreshButton as v}from"@/shared/components/workspace/RefreshButton";import{SearchInput as y}from"@/shared/components/workspace/SearchInput";import{cn as b}from"@/shared/lib/utils";import{AnalysisModelPanel as x}from"../components/AnalysisModelPanel";import{DefinitionDetail as S}from"../components/DefinitionDetail";import{DefinitionEditor as C}from"../components/DefinitionEditor";import{StateBadge as w}from"../components/parts";import{formatTime as T}from"../model/presentation";import{useCreateDefinition as E,useDefinition as D,useDefinitions as re,useDriftCheck as ie}from"../hooks/useDocumentAnalysis";import{notify as ae}from"@/shared/lib/notify";import{jsxs as O,jsx as k,Fragment as A}from"react/jsx-runtime";function j({tenant:f,kind:_}){let[j,M]=o(null),{can:N}=d(),P=N(_===`CLASSIFIER`?`extraction.classifier.write`:`extraction.analyzer.write`),[F,I]=s(),[L,R]=o(!1),z=F.get(`selected`),B=Number(F.get(`offset`)??0),V=Number.isInteger(B)&&B>=0?B:0,H=r({},F.get(`search`)??``),U=a(H.search),W=re(f,_,``,V,!0,{search:U,sortBy:H.sort.by,sortDirection:H.sort.direction}),G=D(f,z,!0),K=E(f),q=ie(f),J=_===`CLASSIFIER`,Y=J?`classifier`:`analyzer`,oe=J?l:c;function X(e,t){I(n=>{let r=new URLSearchParams(n);return t?r.set(e,t):r.delete(e),e===`state`&&r.delete(`offset`),r},{replace:!(e===`selected`&&t&&!F.get(`selected`))})}function Z(e){X(`selected`,e)}let Q=W.data?.items??[],$=e=>{H.toggleSort(e),X(`offset`,``)};if(z){let e=new URLSearchParams(F);return e.delete(`selected`),O(`div`,{className:`flex min-w-0 flex-col`,children:[k(h,{to:{search:e.toString()},children:J?`Document classifiers`:`Document analyzers`}),G.data?G.data.data.kind===_?O(A,{children:[G.error&&k(p,{error:G.error,retry:()=>void G.refetch()}),k(S,{saved:G.data,tenant:f,kind:_,choose:Z,close:()=>Z(``),reload:()=>void G.refetch()})]}):O(`p`,{role:`alert`,className:`rounded-xl border bg-card p-4 text-sm`,children:[`This definition belongs on the `,J?`analyzers`:`classifiers`,` page.`]}):G.isError?k(p,{error:G.error,retry:()=>void G.refetch()}):k(`output`,{className:`block rounded-2xl border bg-card p-8 text-sm`,children:`Loading definition…`})]},z)}return O(A,{children:[k(g,{title:J?`Document classifiers`:`Document analyzers`,description:J?`Recognise each kind of document and pass it to the analyzer that extracts its fields.`:`One analyzer per kind of document: list the fields to extract, then deploy.`,actions:O(A,{children:[O(m,{variant:`outline`,disabled:q.isPending,onClick:()=>q.mutate(),children:[k(ne,{}),q.isPending?`Checking…`:`Check deployments`]}),O(m,{disabled:!P,onClick:()=>{K.reset(),R(!0)},children:[k(u,{}),J?`Classifier`:`Analyzer`]})]})}),q.error&&k(`div`,{className:`mb-4`,children:k(p,{error:q.error,retry:()=>q.mutate()})}),q.data&&O(`output`,{className:b(`mb-4 block rounded-xl border p-4 text-sm`,q.data.missing.length?`border-warning/30 bg-warning/10`:`border-success/25 bg-success/5`),children:[O(`div`,{className:`flex items-center justify-between gap-3`,children:[k(`p`,{className:`font-semibold`,children:q.data.missing.length?`${q.data.missing.length} deployed definitions are missing from the AI service`:`All ${q.data.checked} deployed definitions are present in the AI service`}),k(m,{variant:`ghost`,size:`sm`,onClick:()=>q.reset(),children:`Dismiss`})]}),q.data.missing.length>0&&k(`ul`,{className:`mt-2 list-inside list-disc space-y-1 text-xs break-all`,children:q.data.missing.map(e=>k(`li`,{children:e},e))})]}),k(x,{tenant:f,canManage:P}),k(`div`,{className:`min-w-0`,children:O(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border bg-card`,"aria-label":J?`Classifier directory`:`Analyzer directory`,children:[O(e,{children:[k(y,{label:`Filter ${Y} definitions`,placeholder:`Filter across all columns...`,value:H.search,onChange:e=>{H.setSearch(e),X(`offset`,``)},className:`w-64 max-w-full`}),k(t,{ref:M}),k(v,{fetching:W.isFetching,onRefresh:()=>void W.refetch()})]}),W.isPending?O(`output`,{className:`block p-8 text-sm text-muted-foreground`,children:[`Loading `,J?`classifiers`:`analyzers`,`…`]}):W.isError?k(`div`,{className:`p-4`,children:k(p,{error:W.error,retry:()=>void W.refetch()})}):Q.length?k(`div`,{className:`overflow-x-auto`,children:O(n,{columnsToolbar:j,externalSearch:!0,pageOnly:!0,className:`w-full text-left text-sm`,children:[k(`caption`,{className:`sr-only`,children:J?`Classifier revisions`:`Analyzer revisions`}),k(`thead`,{className:`border-b bg-muted/25 text-xs text-muted-foreground`,children:O(`tr`,{children:[k(i,{column:`name`,label:`Definition`,sort:H.sort,onSort:$,className:`px-4 py-3 font-medium`}),k(i,{column:`version`,label:`Version`,sort:H.sort,onSort:$,className:`px-3 py-3 font-medium`}),k(i,{column:`status`,label:`State`,sort:H.sort,onSort:$,className:`px-3 py-3 font-medium`}),k(i,{column:`provider_id`,label:`Deployed ID`,sort:H.sort,onSort:$,className:`px-3 py-3 font-medium`}),k(i,{column:`updated_at`,label:`Updated`,sort:H.sort,onSort:$,className:`px-4 py-3 font-medium`})]})}),k(`tbody`,{className:`divide-y`,children:Q.map(e=>O(`tr`,{className:`hover:bg-muted/30`,children:[O(`td`,{className:`px-4 py-3`,children:[k(`button`,{className:`max-w-64 truncate text-left font-semibold text-primary underline-offset-4 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Open ${e.name} version ${e.version_no}`,onClick:()=>Z(e.id),children:e.name}),k(`p`,{className:`mt-1 max-w-64 truncate text-xs text-muted-foreground`,title:e.last_error??e.description,children:e.last_error??e.description})]}),O(`td`,{className:`px-3 py-3 text-xs whitespace-nowrap`,children:[`v`,e.version_no]}),k(`td`,{className:`px-3 py-3`,"data-grid-value":e.status,children:k(w,{state:e.status})}),k(`td`,{className:`px-3 py-3 text-xs whitespace-nowrap`,children:e.provider_analyzer_id}),k(`td`,{className:`px-4 py-3 text-xs whitespace-nowrap text-muted-foreground`,"data-grid-sort":e.updated_at,children:T(e.updated_at)})]},e.id))})]})}):O(`div`,{className:`p-8 text-center`,children:[k(`span`,{className:`glass-tile mx-auto mb-3 grid size-11 place-items-center rounded-xl`,children:k(oe,{className:`size-5`,"aria-hidden":`true`})}),k(`h2`,{className:`font-semibold`,children:W.data.total?`No matching definitions on this page`:`Create your first ${Y}`}),k(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:W.data.total?`Clear the filter or move to another page.`:J?`Create a classifier, add a category per kind of document, and pick the analyzer for each.`:`Create an analyzer for a kind of document, then add the fields to extract.`}),!W.data.total&&O(m,{className:`mt-4`,size:`sm`,disabled:!P,onClick:()=>{K.reset(),R(!0)},children:[k(u,{}),J?`Classifier`:`Analyzer`]})]}),W.data&&O(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t px-4 py-3 text-xs text-muted-foreground`,children:[k(`span`,{children:W.data.total?`${V+1}–${Math.min(V+W.data.items.length,W.data.total)} of ${W.data.total}`:`0 definitions`}),O(`div`,{className:`flex gap-2`,children:[O(m,{size:`sm`,variant:`outline`,"aria-label":`Previous page`,disabled:!V||W.isFetching,onClick:()=>X(`offset`,String(Math.max(0,V-20))),children:[k(ee,{}),`Previous`]}),O(m,{size:`sm`,variant:`outline`,"aria-label":`Next page`,disabled:V+W.data.items.length>=W.data.total||W.isFetching,onClick:()=>X(`offset`,String(V+20)),children:[`Next`,k(te,{})]})]})]})]})}),L&&k(C,{kind:_,busy:K.isPending,error:K.error,close:()=>R(!1),reload:()=>K.reset(),create:e=>{K.mutate(e,{onSuccess:e=>{R(!1),ae.success(_===`CLASSIFIER`?`Classifier created.`:`Analyzer created.`),I(t=>{let n=new URLSearchParams(t);return n.set(`selected`,e.data.id),n.delete(`offset`),n.delete(`state`),n.delete(`search`),n},{replace:!0})}})}})]})}function M({kind:e}){let{user:t,can:n}=d(),r=_(),i=t?.tenant_id??r.tenantId??``,a=n((e===`CLASSIFIER`?f.classifiers:f.analyzers).permission);return k(`div`,{className:`workspace-admin min-w-0`,children:a?k(A,{children:k(j,{tenant:i,kind:e},`${e}:${i}`)}):k(`p`,{role:`alert`,children:`You do not have access to document analysis administration.`})})}export function AnalyzersPage(){return k(M,{kind:`EXTRACTOR`})}export function ClassifiersPage(){return k(M,{kind:`CLASSIFIER`})}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { components } from '@/shared/api/generated/schema';
|
|
2
|
+
export type Analyzer = components['schemas']['AnalyzerRead'];
|
|
3
|
+
export type AnalyzerCreate = components['schemas']['AnalyzerCreate'];
|
|
4
|
+
export type AnalyzerUpdate = components['schemas']['AnalyzerUpdate'];
|
|
5
|
+
export type AnalyzerField = components['schemas']['FieldRead'];
|
|
6
|
+
export type FieldWrite = components['schemas']['FieldWrite'];
|
|
7
|
+
export type AnalyzerCategory = components['schemas']['CategoryRead'];
|
|
8
|
+
export type CategoryWrite = components['schemas']['CategoryWrite'];
|
|
9
|
+
export type AnalysisModel = components['schemas']['AnalysisModelRead'];
|
|
10
|
+
export type AnalysisModelState = components['schemas']['AnalysisModelState'];
|
|
11
|
+
export type AnalyzerAudit = components['schemas']['AuditRead'];
|
|
12
|
+
export type TestRun = components['schemas']['TestRunRead'];
|
|
13
|
+
export type AnalyzerState = components['schemas']['DeploymentState'];
|
|
14
|
+
export type AnalyzerKind = 'EXTRACTOR' | 'CLASSIFIER';
|
|
15
|
+
export type AnalyzerPage = components['schemas']['AnalyzerList'];
|
|
16
|
+
export type VersionedAnalyzer = {
|
|
17
|
+
data: Analyzer;
|
|
18
|
+
etag: string;
|
|
19
|
+
};
|
|
20
|
+
export type DriftReport = {
|
|
21
|
+
missing: string[];
|
|
22
|
+
checked: number;
|
|
23
|
+
};
|
|
24
|
+
/** Server-paginated definitions; the two pages use the same management resource. */
|
|
25
|
+
export declare function getAnalyzers(tenant: string, kind: AnalyzerKind, filters?: {
|
|
26
|
+
status?: string;
|
|
27
|
+
offset?: number;
|
|
28
|
+
search?: string;
|
|
29
|
+
sortBy?: string;
|
|
30
|
+
sortDirection?: 'asc' | 'desc';
|
|
31
|
+
}, signal?: AbortSignal): Promise<AnalyzerPage>;
|
|
32
|
+
export declare const getAnalyzer: (tenant: string, id: string, signal?: AbortSignal) => Promise<VersionedAnalyzer>;
|
|
33
|
+
/** The AI model every analyzer deploys with, and the models the service offers. */
|
|
34
|
+
export declare function getAnalysisModel(tenant: string, signal?: AbortSignal): Promise<AnalysisModelState>;
|
|
35
|
+
export declare function setAnalysisModel(tenant: string, input: {
|
|
36
|
+
completion_model: string;
|
|
37
|
+
model_version: string;
|
|
38
|
+
}): Promise<AnalysisModel>;
|
|
39
|
+
/** Read every active extractor page so target choices never silently omit later pages. */
|
|
40
|
+
export declare function getRoutingTargets(tenant: string, signal?: AbortSignal): Promise<Analyzer[]>;
|
|
41
|
+
export declare const createAnalyzer: (tenant: string, input: AnalyzerCreate) => Promise<VersionedAnalyzer>;
|
|
42
|
+
export declare const updateAnalyzer: (tenant: string, saved: VersionedAnalyzer, input: AnalyzerUpdate) => Promise<VersionedAnalyzer>;
|
|
43
|
+
export declare const cloneAnalyzer: (tenant: string, saved: VersionedAnalyzer, reason: string) => Promise<VersionedAnalyzer>;
|
|
44
|
+
export declare const saveField: (tenant: string, saved: VersionedAnalyzer, input: FieldWrite, id?: string) => Promise<VersionedAnalyzer>;
|
|
45
|
+
export declare const deleteField: (tenant: string, saved: VersionedAnalyzer, id: string) => Promise<VersionedAnalyzer>;
|
|
46
|
+
export declare const saveCategory: (tenant: string, saved: VersionedAnalyzer, input: CategoryWrite, id?: string) => Promise<VersionedAnalyzer>;
|
|
47
|
+
export declare const deleteCategory: (tenant: string, saved: VersionedAnalyzer, id: string) => Promise<VersionedAnalyzer>;
|
|
48
|
+
export declare const evaluateAnalyzer: (tenant: string, saved: VersionedAnalyzer, reference: string, passed: boolean) => Promise<VersionedAnalyzer>;
|
|
49
|
+
export declare const publishAnalyzer: (tenant: string, saved: VersionedAnalyzer) => Promise<VersionedAnalyzer>;
|
|
50
|
+
export declare const syncAnalyzer: (tenant: string, saved: VersionedAnalyzer) => Promise<VersionedAnalyzer>;
|
|
51
|
+
export declare function deleteAnalyzer(tenant: string, saved: VersionedAnalyzer): Promise<void>;
|
|
52
|
+
/** Run a deployed revision on one file; the result is the analyzer's own data model. */
|
|
53
|
+
export declare function testAnalyzer(tenant: string, id: string, file: File): Promise<TestRun>;
|
|
54
|
+
export declare function previewAnalyzer(tenant: string, id: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
55
|
+
export declare function getAnalyzerAudit(tenant: string, id: string, signal?: AbortSignal): Promise<AnalyzerAudit[]>;
|
|
56
|
+
export declare function reconcileAnalyzers(tenant: string): Promise<DriftReport>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ApiError as e,request as t}from"@/shared/api/client";import{isRecord as n}from"@/shared/api/http";function r(e,t,n={}){let r=new URLSearchParams({...e?{tenant_id:e}:{},...n});return`/api/v1/${t}${r.size>0?`?${r}`:``}`}function i(t){if(!n(t)||typeof t.id!=`string`||typeof t.version!=`number`||typeof t.name!=`string`||typeof t.description!=`string`||t.kind!==`EXTRACTOR`&&t.kind!==`CLASSIFIER`||!n(t.provider_config)||!Array.isArray(t.fields)||!Array.isArray(t.categories)||typeof t.status!=`string`)throw new e(`The document definition response could not be verified.`);return t}async function a(n,r={}){let a=new Headers,o=await t(n,r,!1,a),s=a.get(`ETag`);if(!s||!/^"[1-9][0-9]*"$/.test(s))throw new e(`The definition version could not be verified. Refresh before editing.`);return{data:i(o),etag:s}}export async function getAnalyzers(a,o,s={},c){let l=await t(r(a,`analyzers`,{kind:o,limit:`20`,offset:String(s.offset??0),search:s.search??``,sort_by:s.sortBy??``,sort_direction:s.sortDirection??`asc`,...s.status?{status:s.status}:{}}),{signal:c});if(!n(l)||!Array.isArray(l.items)||typeof l.total!=`number`)throw new e(`Document definitions could not be loaded.`);return{items:l.items.map(i),total:l.total}}export const getAnalyzer=(e,t,n)=>a(r(e,`analyzers/${encodeURIComponent(t)}`),{signal:n});export async function getAnalysisModel(i,a){let o=await t(r(i,`analyzers/analysis-model`),{signal:a});if(!n(o)||!Array.isArray(o.available)||!(o.current===null||n(o.current)&&typeof o.current.id==`string`))throw new e(`The AI model setting could not be loaded.`);return o}export async function setAnalysisModel(i,a){let o=await t(r(i,`analyzers/analysis-model`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});if(!n(o)||typeof o.completion_model!=`string`)throw new e(`The AI model setting could not be saved.`);return o}export async function getRoutingTargets(e,t){let n=[];for(let r=0;;r+=20){let i=await getAnalyzers(e,`EXTRACTOR`,{status:`ACTIVE`,offset:r},t);if(n.push(...i.items),n.length>=i.total||i.items.length===0)return n}}function o(e,t,n,i,o){return a(r(e,t),{method:n,headers:{...i===void 0?{}:{"Content-Type":`application/json`},...o?{"If-Match":o}:{}},...i===void 0?{}:{body:JSON.stringify(i)}})}export const createAnalyzer=(e,t)=>o(e,`analyzers`,`POST`,t);export const updateAnalyzer=(e,t,n)=>o(e,`analyzers/${t.data.id}`,`PATCH`,n,t.etag);export const cloneAnalyzer=(e,t,n)=>o(e,`analyzers/${t.data.id}/new-version`,`POST`,{reason:n},t.etag);export const saveField=(e,t,n,r)=>o(e,`analyzers/${t.data.id}/fields${r?`/${r}`:``}`,r?`PUT`:`POST`,n,t.etag);export const deleteField=(e,t,n)=>o(e,`analyzers/${t.data.id}/fields/${n}`,`DELETE`,void 0,t.etag);export const saveCategory=(e,t,n,r)=>o(e,`classifiers/${t.data.id}/categories${r?`/${r}`:``}`,r?`PUT`:`POST`,n,t.etag);export const deleteCategory=(e,t,n)=>o(e,`classifiers/${t.data.id}/categories/${n}`,`DELETE`,void 0,t.etag);export const evaluateAnalyzer=(e,t,n,r)=>o(e,`analyzers/${t.data.id}/evaluation`,`POST`,{reference:n,passed:r},t.etag);export const publishAnalyzer=(e,t)=>o(e,`analyzers/${t.data.id}/publish`,`POST`,void 0,t.etag);export const syncAnalyzer=(e,t)=>o(e,`analyzers/${t.data.id}/sync`,`POST`,void 0,t.etag);export async function deleteAnalyzer(e,n){await t(r(e,`analyzers/${n.data.id}`),{method:`DELETE`,headers:{"If-Match":n.etag}})}export async function testAnalyzer(i,a,o){let s=new FormData;s.append(`file`,o);let c=await t(r(i,`analyzers/${a}/test`),{method:`POST`,body:s});if(!n(c)||!Array.isArray(c.parts))throw new e(`The test result could not be read.`);return c}export async function previewAnalyzer(i,a,o){let s=await t(r(i,`analyzers/${a}/preview`),{signal:o});if(!n(s))throw new e(`The definition preview could not be loaded.`);return s}export async function getAnalyzerAudit(i,a,o){let s=await t(r(i,`analyzers/${a}/audit`),{signal:o});if(!Array.isArray(s)||!s.every(e=>n(e)&&typeof e.action==`string`))throw new e(`The management history could not be loaded.`);return s}export async function reconcileAnalyzers(i){let a=await t(r(i,`analyzers/reconcile`));if(!n(a)||!Array.isArray(a.active_in_db_but_missing_in_provider)||!a.active_in_db_but_missing_in_provider.every(e=>typeof e==`string`)||typeof a.checked!=`number`)throw new e(`The drift report could not be verified.`);return{missing:a.active_in_db_but_missing_in_provider,checked:a.checked}}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { components } from '@/shared/api/generated/schema';
|
|
2
|
+
import type { TenantScope } from '@/shared/api/ai-assets';
|
|
3
|
+
export type Guardrail = components['schemas']['GuardrailRead'];
|
|
4
|
+
export type GuardrailStage = components['schemas']['GuardrailStage'];
|
|
5
|
+
/** Where in a run each guardrail acts, in run order. */
|
|
6
|
+
export declare const guardrailStageLabels: Record<GuardrailStage, string>;
|
|
7
|
+
/** The query key of the platform guardrails as one customer runs them. */
|
|
8
|
+
export declare const guardrailsKey: (tenantId: TenantScope) => string[];
|
|
9
|
+
/** The platform guardrails, with the customer's on/off switches applied. */
|
|
10
|
+
export declare function getGuardrails(tenantId: TenantScope, signal?: AbortSignal): Promise<Guardrail[]>;
|
|
11
|
+
/** Switch a platform guardrail that is not locked on or off; the next run follows it. */
|
|
12
|
+
export declare const switchGuardrail: (key: string, enabled: boolean, tenantId: TenantScope) => Promise<{
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
stage: components["schemas"]["GuardrailStage"];
|
|
17
|
+
active: boolean;
|
|
18
|
+
locked: boolean;
|
|
19
|
+
switched_off: boolean;
|
|
20
|
+
switched_at: number | null;
|
|
21
|
+
switched_by: string | null;
|
|
22
|
+
settings: components["schemas"]["GuardrailSettingRead"][];
|
|
23
|
+
}>;
|
|
24
|
+
type Schemas = components['schemas'];
|
|
25
|
+
export type GuardrailPolicy = Schemas['GuardrailPolicyRead'];
|
|
26
|
+
export type GuardrailPolicyWrite = Schemas['GuardrailPolicyWrite'];
|
|
27
|
+
export type PolicyCheck = Schemas['PolicyCheck'];
|
|
28
|
+
export type PolicyStage = Schemas['PolicyStage'];
|
|
29
|
+
export type PolicyAction = Schemas['PolicyAction'];
|
|
30
|
+
export type TargetKind = Schemas['TargetKind'];
|
|
31
|
+
export type HarmCategory = Schemas['HarmCategory'];
|
|
32
|
+
export type GuardrailTry = Schemas['GuardrailTryRead'];
|
|
33
|
+
export type GuardrailPolicyList = {
|
|
34
|
+
items: GuardrailPolicy[];
|
|
35
|
+
contentSafetyReady: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** Labels, grouped by what they name. */
|
|
38
|
+
export declare const policyActionLabels: Record<PolicyAction, string>;
|
|
39
|
+
export declare const policyCheckLabels: Record<PolicyCheck, string>;
|
|
40
|
+
export declare const policyCheckHints: Record<PolicyCheck, string>;
|
|
41
|
+
export declare const policyStageLabels: Record<PolicyStage, string>;
|
|
42
|
+
export declare const harmCategoryLabels: Record<HarmCategory, string>;
|
|
43
|
+
export declare const severityLabels: Record<number, string>;
|
|
44
|
+
export declare const targetKindLabels: Record<TargetKind, string>;
|
|
45
|
+
/** The query key of a customer's guardrail policies (list and editor share it). */
|
|
46
|
+
export declare const guardrailPoliciesKey: (tenantId: TenantScope) => string[];
|
|
47
|
+
/** A customer's guardrail policies. A change applies to the next run. */
|
|
48
|
+
export declare const guardrailPolicies: {
|
|
49
|
+
list: (tenantId: TenantScope, signal?: AbortSignal) => Promise<GuardrailPolicyList>;
|
|
50
|
+
get: (id: string, tenantId: TenantScope) => Promise<{
|
|
51
|
+
data: GuardrailPolicy;
|
|
52
|
+
etag: string;
|
|
53
|
+
}>;
|
|
54
|
+
create: (input: GuardrailPolicyWrite, tenantId: TenantScope) => Promise<{
|
|
55
|
+
data: GuardrailPolicy;
|
|
56
|
+
etag: string;
|
|
57
|
+
}>;
|
|
58
|
+
update: (id: string, input: GuardrailPolicyWrite, etag: string, tenantId: TenantScope) => Promise<{
|
|
59
|
+
data: GuardrailPolicy;
|
|
60
|
+
etag: string;
|
|
61
|
+
}>;
|
|
62
|
+
remove: (id: string, etag: string, tenantId: TenantScope) => Promise<void>;
|
|
63
|
+
try: (id: string, input: {
|
|
64
|
+
text: string;
|
|
65
|
+
stage: 'input' | 'output';
|
|
66
|
+
tool: boolean;
|
|
67
|
+
}, tenantId: TenantScope) => Promise<{
|
|
68
|
+
passed: boolean;
|
|
69
|
+
trips: components["schemas"]["GuardrailTripRead"][];
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
/** The write body of a stored policy, with changes (the list's on/off switch uses it). */
|
|
73
|
+
export declare function policyWrite(policy: GuardrailPolicy, changes?: Partial<GuardrailPolicyWrite>): GuardrailPolicyWrite;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ApiError as e,request as t}from"@/shared/api/client";import{isRecord as n}from"@/shared/api/http";export const guardrailStageLabels={input:`Input`,output:`Output`,data:`Personal data`,tool:`Tool calls`};export const guardrailsKey=e=>[`guardrails`,e??`own`];const r=(e,t)=>t?`/api/v1/guardrails${e}?tenant_id=${encodeURIComponent(t)}`:`/api/v1/guardrails${e}`;export async function getGuardrails(i,a){let o=await t(r(``,i),{signal:a});if(!n(o)||!Array.isArray(o.items))throw new e(`The API returned an invalid guardrail list.`);return o.items}export const switchGuardrail=async(e,n,i)=>await t(r(`/${encodeURIComponent(e)}`,i),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({is_enabled:n})});export const policyActionLabels={block:`Block`,flag:`Flag`};export const policyCheckLabels={blocked_terms:`Blocked terms`,harmful_content:`Harmful content`,prompt_shield:`Prompt Shields`};export const policyCheckHints={blocked_terms:`Words or phrases the text must not contain. Checked on the platform.`,harmful_content:`Hate, self-harm, sexual or violent content at or above a severity. Azure AI Content Safety.`,prompt_shield:`Jailbreaks in what a run is asked, injected instructions in what a tool returns. Azure AI Content Safety.`};export const policyStageLabels={both:`Input and output`,input:`Input`,output:`Output`};export const harmCategoryLabels={Hate:`Hate`,SelfHarm:`Self-harm`,Sexual:`Sexual`,Violence:`Violence`};export const severityLabels={2:`Low`,4:`Medium`,6:`High`};export const targetKindLabels={agent:`Agent`,flow:`Flow`,skill:`Skill`,tool:`Tool`};const i=`/api/v1/guardrail-policies`;export const guardrailPoliciesKey=e=>[`guardrail-policies`,e??`own`];const a=(e,t)=>t?`${i}${e}?tenant_id=${encodeURIComponent(t)}`:`${i}${e}`,o=(e,t,n)=>({method:e,headers:{...t===void 0?{}:{"Content-Type":`application/json`},...n?{"If-Match":n}:{}},...t===void 0?{}:{body:JSON.stringify(t)}});async function s(r,i={}){let a=new Headers,o=await t(r,i,!1,a);if(!n(o)||typeof o.version!=`number`)throw new e(`The API returned an invalid guardrail.`);return{data:o,etag:a.get(`ETag`)??`"${o.version}"`}}export const guardrailPolicies={list:async(r,i)=>{let o=await t(a(``,r),{signal:i});if(!n(o)||!Array.isArray(o.items))throw new e(`The API returned an invalid guardrail list.`);return{items:o.items,contentSafetyReady:o.content_safety_ready===!0}},get:(e,t)=>s(a(`/${encodeURIComponent(e)}`,t)),create:(e,t)=>s(a(``,t),o(`POST`,e)),update:(e,t,n,r)=>s(a(`/${encodeURIComponent(e)}`,r),o(`PUT`,t,n)),remove:async(e,n,r)=>{await t(a(`/${encodeURIComponent(e)}`,r),o(`DELETE`,void 0,n))},try:async(e,n,r)=>await t(a(`/${encodeURIComponent(e)}/try`,r),o(`POST`,n))};export function policyWrite(e,t={}){return{name:e.name,description:e.description,check:e.check,stage:e.stage,action:e.action,is_enabled:e.is_enabled,everywhere:e.everywhere,targets:e.targets,terms:e.terms,categories:e.categories,severity:e.severity,...t}}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { components } from '@/shared/api/generated/schema';
|
|
2
|
+
import type { TenantScope } from '@/shared/api/ai-assets';
|
|
3
|
+
type Schemas = components['schemas'];
|
|
4
|
+
export type LlmProvider = Schemas['LlmProviderRead'];
|
|
5
|
+
export type LlmProviderWrite = Schemas['LlmProviderWrite'];
|
|
6
|
+
export type LlmVendor = Schemas['LlmVendor'];
|
|
7
|
+
export type LlmAuth = Schemas['LlmAuth'];
|
|
8
|
+
export type LlmConnection = Schemas['LlmConnectionRead'];
|
|
9
|
+
/** The query key of a tenant's providers (lists, pickers and editors share it). */
|
|
10
|
+
export declare const llmProvidersKey: (tenantId: TenantScope) => string[];
|
|
11
|
+
/** The models agents and skills run on (AI Studio). Keys go in, never come out. */
|
|
12
|
+
export declare const llmProviders: {
|
|
13
|
+
list: (tenantId: TenantScope, signal?: AbortSignal) => Promise<{
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
provider: components["schemas"]["LlmVendor"];
|
|
18
|
+
model_id: string;
|
|
19
|
+
base_url: string | null;
|
|
20
|
+
api_version: string | null;
|
|
21
|
+
auth: components["schemas"]["LlmAuth"];
|
|
22
|
+
has_api_key: boolean;
|
|
23
|
+
api_key_masked: string | null;
|
|
24
|
+
temperature: number | null;
|
|
25
|
+
max_tokens: number | null;
|
|
26
|
+
extra_params: {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
is_default: boolean;
|
|
30
|
+
is_enabled: boolean;
|
|
31
|
+
tags: string[];
|
|
32
|
+
version: number;
|
|
33
|
+
created_at: number;
|
|
34
|
+
created_by: string;
|
|
35
|
+
updated_at: number;
|
|
36
|
+
updated_by: string;
|
|
37
|
+
}[]>;
|
|
38
|
+
get: (id: string, tenantId: TenantScope) => Promise<{
|
|
39
|
+
data: LlmProvider;
|
|
40
|
+
etag: string;
|
|
41
|
+
}>;
|
|
42
|
+
create: (input: LlmProviderWrite, tenantId: TenantScope) => Promise<{
|
|
43
|
+
data: LlmProvider;
|
|
44
|
+
etag: string;
|
|
45
|
+
}>;
|
|
46
|
+
update: (id: string, input: LlmProviderWrite, etag: string, tenantId: TenantScope) => Promise<{
|
|
47
|
+
data: LlmProvider;
|
|
48
|
+
etag: string;
|
|
49
|
+
}>;
|
|
50
|
+
remove: (id: string, etag: string, tenantId: TenantScope) => Promise<void>;
|
|
51
|
+
test: (id: string, tenantId: TenantScope) => Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
response_time_ms: number;
|
|
54
|
+
response_preview: string;
|
|
55
|
+
error: string;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
export declare const vendorLabels: Record<LlmVendor, string>;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ApiError as e,request as t}from"@/shared/api/client";import{isRecord as n}from"@/shared/api/http";const r=`/api/v1/llm-providers`;export const llmProvidersKey=e=>[`llm-providers`,e??`own`];const i=(e,t)=>t?`${r}${e}?tenant_id=${encodeURIComponent(t)}`:`${r}${e}`,a=(e,t,n)=>({method:e,headers:{...t===void 0?{}:{"Content-Type":`application/json`},...n?{"If-Match":n}:{}},...t===void 0?{}:{body:JSON.stringify(t)}});async function o(r,i={}){let a=new Headers,o=await t(r,i,!1,a);if(!n(o)||typeof o.version!=`number`)throw new e(`The API returned an invalid LLM provider.`);return{data:o,etag:a.get(`ETag`)??`"${o.version}"`}}export const llmProviders={list:async(r,a)=>{let o=await t(i(``,r),{signal:a});if(!n(o)||!Array.isArray(o.items))throw new e(`The API returned an invalid list.`);return o.items},get:(e,t)=>o(i(`/${encodeURIComponent(e)}`,t)),create:(e,t)=>o(i(``,t),a(`POST`,e)),update:(e,t,n,r)=>o(i(`/${encodeURIComponent(e)}`,r),a(`PUT`,t,n)),remove:async(e,n,r)=>{await t(i(`/${encodeURIComponent(e)}`,r),a(`DELETE`,void 0,n))},test:async(e,n)=>await t(i(`/${encodeURIComponent(e)}/test`,n),a(`POST`))};export const vendorLabels={anthropic:`Anthropic`,azure_claude:`Azure Claude`,openai:`OpenAI`,azure_openai:`Azure OpenAI`,custom:`Custom (OpenAI-compatible)`};
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssiriuss/ai",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Sirius UI AI: AI assets, AI Studio, document analysis.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"ai",
|
|
8
|
+
"agents",
|
|
9
|
+
"llm",
|
|
10
|
+
"guardrails"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@ssiriuss/core": "0.0.1"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
"./*": "./dist/*"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|