@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,82 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { AssetKind, TenantScope } from '@/shared/api/ai-assets';
|
|
3
|
+
/** Form parts every designer section shares. */
|
|
4
|
+
export declare const selectClass = "h-8 w-full rounded-md border bg-background px-2 text-sm";
|
|
5
|
+
export declare function Field({ label, hint, children, className, }: {
|
|
6
|
+
label: string;
|
|
7
|
+
hint?: ReactNode;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export declare function Section({ title, children }: {
|
|
12
|
+
title: string;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
export declare function TextField({ label, value, onChange, placeholder, hint, max, mono, }: {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
onChange: (value: string) => void;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
hint?: ReactNode;
|
|
21
|
+
max?: number;
|
|
22
|
+
mono?: boolean;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
export declare function AreaField({ label, value, onChange, placeholder, hint, rows, max, }: {
|
|
25
|
+
label: string;
|
|
26
|
+
value: string;
|
|
27
|
+
onChange: (value: string) => void;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
hint?: ReactNode;
|
|
30
|
+
rows?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
}): import("react").JSX.Element;
|
|
33
|
+
export declare function NumberField({ label, value, onChange, min, max, hint, }: {
|
|
34
|
+
label: string;
|
|
35
|
+
value: number;
|
|
36
|
+
onChange: (value: number) => void;
|
|
37
|
+
min: number;
|
|
38
|
+
max: number;
|
|
39
|
+
hint?: ReactNode;
|
|
40
|
+
}): import("react").JSX.Element;
|
|
41
|
+
export declare function SelectField<T extends string>({ label, value, options, onChange, hint, }: {
|
|
42
|
+
label: string;
|
|
43
|
+
value: T;
|
|
44
|
+
options: readonly {
|
|
45
|
+
value: T;
|
|
46
|
+
label: string;
|
|
47
|
+
}[];
|
|
48
|
+
onChange: (value: T) => void;
|
|
49
|
+
hint?: ReactNode;
|
|
50
|
+
}): import("react").JSX.Element;
|
|
51
|
+
export declare function Toggle({ label, checked, onChange, hint, }: {
|
|
52
|
+
label: string;
|
|
53
|
+
checked: boolean;
|
|
54
|
+
onChange: (checked: boolean) => void;
|
|
55
|
+
hint?: ReactNode;
|
|
56
|
+
}): import("react").JSX.Element;
|
|
57
|
+
/** A JSON value edited as text; the value updates only while the text parses. */
|
|
58
|
+
export declare function JsonField({ label, value, onChange, hint, rows, }: {
|
|
59
|
+
label: string;
|
|
60
|
+
value: unknown;
|
|
61
|
+
onChange: (value: Record<string, unknown>) => void;
|
|
62
|
+
hint?: ReactNode;
|
|
63
|
+
rows?: number;
|
|
64
|
+
}): import("react").JSX.Element;
|
|
65
|
+
/** A list of short strings (tags, modes, allowed tools), one per line. */
|
|
66
|
+
export declare function ListField({ label, value, onChange, placeholder, hint, }: {
|
|
67
|
+
label: string;
|
|
68
|
+
value: readonly string[];
|
|
69
|
+
onChange: (value: string[]) => void;
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
hint?: ReactNode;
|
|
72
|
+
}): import("react").JSX.Element;
|
|
73
|
+
/** Choose assets of one kind by name; chosen ones show as removable chips. */
|
|
74
|
+
export declare function AssetPicker({ label, kind, value, onChange, tenantId, exclude, hint, }: {
|
|
75
|
+
label: string;
|
|
76
|
+
kind: AssetKind;
|
|
77
|
+
value: readonly string[];
|
|
78
|
+
onChange: (value: string[]) => void;
|
|
79
|
+
tenantId: TenantScope;
|
|
80
|
+
exclude?: string;
|
|
81
|
+
hint?: ReactNode;
|
|
82
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{NumberInput as e}from"@/shared/components/workspace/NumberInput";import{useState as t}from"react";import{X as n}from"lucide-react";import{Input as r}from"@/shared/components/ui/input";import{Textarea as i}from"@/shared/components/ui/textarea";import{cn as a}from"@/shared/lib/utils";import{useAssets as o}from"../hooks/useAssets";import{assetTitle as s}from"../model/kinds";import{jsx as c,jsxs as l}from"react/jsx-runtime";export const selectClass=`h-8 w-full rounded-md border bg-background px-2 text-sm`;export function Field({label:e,hint:t,children:n,className:r}){return l(`label`,{className:a(`grid content-start gap-1.5 text-xs font-medium`,r),children:[e,n,t&&c(`span`,{className:`font-normal text-muted-foreground`,children:t})]})}export function Section({title:e,children:t}){return l(`section`,{className:`space-y-3 rounded-xl border bg-card p-4`,"aria-label":e,children:[c(`h2`,{className:`text-sm font-semibold`,children:e}),t]})}export function TextField({label:e,value:t,onChange:n,placeholder:i,hint:a,max:o=1e3,mono:s}){return c(Field,{label:e,hint:a,children:c(r,{value:t,maxLength:o,placeholder:i,className:s?`font-mono text-xs`:void 0,onChange:e=>n(e.target.value)})})}export function AreaField({label:e,value:t,onChange:n,placeholder:r,hint:a,rows:o=8,max:s=16e3}){return c(Field,{label:e,hint:a,children:c(i,{value:t,rows:o,maxLength:s,placeholder:r,onChange:e=>n(e.target.value)})})}export function NumberField({label:t,value:n,onChange:r,min:i,max:a,hint:o}){return c(Field,{label:t,hint:o,children:c(e,{min:i,max:a,value:n,onValueChange:r})})}export function SelectField({label:e,value:t,options:n,onChange:r,hint:i}){return c(Field,{label:e,hint:i,children:c(`select`,{className:`h-8 w-full rounded-md border bg-background px-2 text-sm`,value:t,onChange:e=>r(e.target.value),children:n.map(e=>c(`option`,{value:e.value,children:e.label},e.value))})})}export function Toggle({label:e,checked:t,onChange:n,hint:r}){return l(`label`,{className:`flex items-start gap-2 text-sm`,children:[c(`input`,{type:`checkbox`,className:`mt-0.5`,checked:t,onChange:e=>n(e.target.checked)}),l(`span`,{children:[c(`span`,{className:`font-medium`,children:e}),r&&c(`span`,{className:`block text-xs text-muted-foreground`,children:r})]})]})}export function JsonField({label:e,value:n,onChange:r,hint:a,rows:o=8}){let[s,l]=t(()=>JSON.stringify(n??{},null,2)),[u,d]=t(``);return c(Field,{label:e,hint:u?c(`span`,{className:`text-destructive`,children:u}):a,children:c(i,{value:s,rows:o,className:`font-mono text-xs`,onChange:e=>{l(e.target.value);try{let t=JSON.parse(e.target.value||`{}`);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Enter a JSON object.`);d(``),r(t)}catch(e){d(e instanceof Error?e.message:`Enter valid JSON.`)}}})})}export function ListField({label:e,value:n,onChange:r,placeholder:a,hint:o}){let[s,l]=t(()=>n.join(`
|
|
2
|
+
`));return c(Field,{label:e,hint:o,children:c(i,{value:s,rows:3,placeholder:a,className:`font-mono text-xs`,onChange:e=>{l(e.target.value),r(e.target.value.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean))}})})}export function AssetPicker({label:e,kind:t,value:r,onChange:i,tenantId:a,exclude:u,hint:d}){let f=o(t,a,!0),p=(f.data??[]).filter(e=>e.name!==u&&!r.includes(e.name)),m=e=>{let t=f.data?.find(t=>t.name===e);return t?s(t):e};return c(Field,{label:e,hint:d,children:l(`div`,{className:`flex flex-wrap gap-1.5`,children:[r.map(e=>{let t=f.data?.find(t=>t.name===e);return l(`span`,{className:`flex items-center gap-1 rounded-badge border bg-muted/40 px-2.5 py-1 text-xs`,children:[m(e),t&&!t.pinned_version_id&&c(`span`,{className:`text-warning-foreground`,children:`· draft`}),c(`button`,{type:`button`,"aria-label":`Remove ${m(e)}`,className:`rounded text-muted-foreground hover:text-destructive`,onClick:()=>i(r.filter(t=>t!==e)),children:c(n,{className:`size-3`,"aria-hidden":`true`})})]},e)}),l(`select`,{"aria-label":`Add ${e.toLowerCase()}`,className:`h-7 rounded-md border bg-background px-2 text-xs`,value:``,onChange:e=>e.target.value&&i([...r,e.target.value]),children:[c(`option`,{value:``,children:p.length?`Add…`:`Nothing to add`}),p.map(e=>l(`option`,{value:e.name,children:[s(e),e.pinned_version_id?``:` (draft)`]},e.id))]})]})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mcpHeadings(names: string[]): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cn as e}from"@/shared/lib/utils";import{jsx as t}from"react/jsx-runtime";export function mcpHeadings(n){return t(`thead`,{className:`border-y bg-muted/40`,children:t(`tr`,{children:n.map(n=>t(`th`,{scope:`col`,className:e(`px-3 py-2.5 text-xs font-medium text-muted-foreground`,[`Linked tools`,`Tools`,`Actions`].includes(n)&&`text-right`),children:n},n))})})}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { saveAssetDraft, type AssetKind, type TenantScope } from '@/shared/api/ai-assets';
|
|
2
|
+
export declare const assetsKey: (tenantId: TenantScope) => readonly ['ai-assets', string];
|
|
3
|
+
/** The agent runtimes this deployment runs (from the agent spec). */
|
|
4
|
+
export declare function useAgentSpec(enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
json_schema: {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
runtimes: string[];
|
|
9
|
+
defaults: import("@/shared/api/generated/schema").components["schemas"]["AgentSpec"];
|
|
10
|
+
}, Error>;
|
|
11
|
+
export declare function useAssets(kind: AssetKind, tenantId: TenantScope, enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
12
|
+
id: string;
|
|
13
|
+
kind: import("@/shared/api/generated/schema").components["schemas"]["AssetKind"];
|
|
14
|
+
name: string;
|
|
15
|
+
display_name: string | null;
|
|
16
|
+
description: string;
|
|
17
|
+
pinned_version_id: string | null;
|
|
18
|
+
published_number: number | null;
|
|
19
|
+
version: number;
|
|
20
|
+
updated_at: number;
|
|
21
|
+
linked_tools?: number | null;
|
|
22
|
+
connection?: import("@/shared/api/generated/schema").components["schemas"]["McpConnection"] | null;
|
|
23
|
+
exposes?: import("@/shared/api/generated/schema").components["schemas"]["McpExposure"] | null;
|
|
24
|
+
tool?: import("@/shared/api/generated/schema").components["schemas"]["ToolSummary"] | null;
|
|
25
|
+
contract?: import("@/shared/api/generated/schema").components["schemas"]["AssetContract"] | null;
|
|
26
|
+
}[], Error>;
|
|
27
|
+
export declare function useAsset(kind: AssetKind, id: string, tenantId: TenantScope, enabled: boolean): import("@tanstack/react-query").UseQueryResult<import("@/shared/api/ai-assets").Versioned<{
|
|
28
|
+
id: string;
|
|
29
|
+
kind: import("@/shared/api/generated/schema").components["schemas"]["AssetKind"];
|
|
30
|
+
name: string;
|
|
31
|
+
display_name: string | null;
|
|
32
|
+
description: string;
|
|
33
|
+
pinned_version_id: string | null;
|
|
34
|
+
published_number: number | null;
|
|
35
|
+
version: number;
|
|
36
|
+
updated_at: number;
|
|
37
|
+
linked_tools?: number | null;
|
|
38
|
+
connection?: import("@/shared/api/generated/schema").components["schemas"]["McpConnection"] | null;
|
|
39
|
+
exposes?: import("@/shared/api/generated/schema").components["schemas"]["McpExposure"] | null;
|
|
40
|
+
tool?: import("@/shared/api/generated/schema").components["schemas"]["ToolSummary"] | null;
|
|
41
|
+
contract?: import("@/shared/api/generated/schema").components["schemas"]["AssetContract"] | null;
|
|
42
|
+
spec: {
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
};
|
|
45
|
+
versions: import("@/shared/api/generated/schema").components["schemas"]["VersionRead"][];
|
|
46
|
+
}>, Error>;
|
|
47
|
+
export declare function useA2aTasks(id: string, tenantId: TenantScope, enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
48
|
+
task_id: string;
|
|
49
|
+
context_id: string;
|
|
50
|
+
state: string;
|
|
51
|
+
caller: string;
|
|
52
|
+
started_at: number;
|
|
53
|
+
updated_at: number;
|
|
54
|
+
task: {
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
}[], Error>;
|
|
58
|
+
/**
|
|
59
|
+
* Every change of one kind refreshes the registry lists and the open asset afterwards, and
|
|
60
|
+
* confirms with a toast ("Agent saved.").
|
|
61
|
+
*/
|
|
62
|
+
export declare function useAssetActions(kind: AssetKind, tenantId: TenantScope): {
|
|
63
|
+
create: import("@tanstack/react-query").UseMutationResult<import("@/shared/api/ai-assets").Versioned<{
|
|
64
|
+
id: string;
|
|
65
|
+
kind: import("@/shared/api/generated/schema").components["schemas"]["AssetKind"];
|
|
66
|
+
name: string;
|
|
67
|
+
display_name: string | null;
|
|
68
|
+
description: string;
|
|
69
|
+
pinned_version_id: string | null;
|
|
70
|
+
published_number: number | null;
|
|
71
|
+
version: number;
|
|
72
|
+
updated_at: number;
|
|
73
|
+
linked_tools?: number | null;
|
|
74
|
+
connection?: import("@/shared/api/generated/schema").components["schemas"]["McpConnection"] | null;
|
|
75
|
+
exposes?: import("@/shared/api/generated/schema").components["schemas"]["McpExposure"] | null;
|
|
76
|
+
tool?: import("@/shared/api/generated/schema").components["schemas"]["ToolSummary"] | null;
|
|
77
|
+
contract?: import("@/shared/api/generated/schema").components["schemas"]["AssetContract"] | null;
|
|
78
|
+
spec: {
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
};
|
|
81
|
+
versions: import("@/shared/api/generated/schema").components["schemas"]["VersionRead"][];
|
|
82
|
+
}>, Error, {
|
|
83
|
+
name: string;
|
|
84
|
+
display_name: string | null;
|
|
85
|
+
description: string;
|
|
86
|
+
spec?: Record<string, unknown>;
|
|
87
|
+
}, unknown>;
|
|
88
|
+
save: import("@tanstack/react-query").UseMutationResult<import("@/shared/api/ai-assets").Versioned<{
|
|
89
|
+
id: string;
|
|
90
|
+
kind: import("@/shared/api/generated/schema").components["schemas"]["AssetKind"];
|
|
91
|
+
name: string;
|
|
92
|
+
display_name: string | null;
|
|
93
|
+
description: string;
|
|
94
|
+
pinned_version_id: string | null;
|
|
95
|
+
published_number: number | null;
|
|
96
|
+
version: number;
|
|
97
|
+
updated_at: number;
|
|
98
|
+
linked_tools?: number | null;
|
|
99
|
+
connection?: import("@/shared/api/generated/schema").components["schemas"]["McpConnection"] | null;
|
|
100
|
+
exposes?: import("@/shared/api/generated/schema").components["schemas"]["McpExposure"] | null;
|
|
101
|
+
tool?: import("@/shared/api/generated/schema").components["schemas"]["ToolSummary"] | null;
|
|
102
|
+
contract?: import("@/shared/api/generated/schema").components["schemas"]["AssetContract"] | null;
|
|
103
|
+
spec: {
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
};
|
|
106
|
+
versions: import("@/shared/api/generated/schema").components["schemas"]["VersionRead"][];
|
|
107
|
+
}>, Error, {
|
|
108
|
+
id: string;
|
|
109
|
+
etag: string;
|
|
110
|
+
input: Parameters<typeof saveAssetDraft>[2];
|
|
111
|
+
}, unknown>;
|
|
112
|
+
remove: import("@tanstack/react-query").UseMutationResult<void, Error, {
|
|
113
|
+
id: string;
|
|
114
|
+
etag: string;
|
|
115
|
+
}, unknown>;
|
|
116
|
+
freeze: import("@tanstack/react-query").UseMutationResult<{
|
|
117
|
+
id: string;
|
|
118
|
+
asset_id: string;
|
|
119
|
+
number: number;
|
|
120
|
+
status: import("@/shared/api/generated/schema").components["schemas"]["AssetVersionStatus"];
|
|
121
|
+
spec: {
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
};
|
|
124
|
+
content_hash: string;
|
|
125
|
+
reason: string;
|
|
126
|
+
created_at: number;
|
|
127
|
+
created_by: string;
|
|
128
|
+
published_at: number | null;
|
|
129
|
+
published_by: string | null;
|
|
130
|
+
}, Error, {
|
|
131
|
+
id: string;
|
|
132
|
+
reason: string;
|
|
133
|
+
}, unknown>;
|
|
134
|
+
publish: import("@tanstack/react-query").UseMutationResult<{
|
|
135
|
+
id: string;
|
|
136
|
+
asset_id: string;
|
|
137
|
+
number: number;
|
|
138
|
+
status: import("@/shared/api/generated/schema").components["schemas"]["AssetVersionStatus"];
|
|
139
|
+
spec: {
|
|
140
|
+
[key: string]: unknown;
|
|
141
|
+
};
|
|
142
|
+
content_hash: string;
|
|
143
|
+
reason: string;
|
|
144
|
+
created_at: number;
|
|
145
|
+
created_by: string;
|
|
146
|
+
published_at: number | null;
|
|
147
|
+
published_by: string | null;
|
|
148
|
+
}, Error, {
|
|
149
|
+
id: string;
|
|
150
|
+
versionId: string;
|
|
151
|
+
}, unknown>;
|
|
152
|
+
test: import("@tanstack/react-query").UseMutationResult<{
|
|
153
|
+
output: unknown;
|
|
154
|
+
trace: import("@/shared/api/generated/schema").components["schemas"]["TraceStepRead"][];
|
|
155
|
+
duration_ms: number;
|
|
156
|
+
}, Error, {
|
|
157
|
+
id: string;
|
|
158
|
+
input: unknown;
|
|
159
|
+
version: number | null;
|
|
160
|
+
}, unknown>;
|
|
161
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMutation as e,useQuery as t,useQueryClient as n}from"@tanstack/react-query";import{createAsset as r,deleteAsset as i,freezeAssetVersion as a,getA2aTasks as o,getAgentSpec as s,getAsset as c,getAssets as l,publishAssetVersion as u,saveAssetDraft as d,testAsset as f}from"@/shared/api/ai-assets";import{notify as p}from"@/shared/lib/notify";import{kinds as m}from"../model/kinds";export const assetsKey=e=>[`ai-assets`,e??`own`];export function useAgentSpec(e){return t({queryKey:[`ai-assets`,`agent-spec`],queryFn:({signal:e})=>s(e),enabled:e,staleTime:3e5})}export function useAssets(e,n,r){return t({queryKey:[...assetsKey(n),`list`,e],queryFn:({signal:t})=>l(e,n,t),enabled:r,retry:!1})}export function useAsset(e,n,r,i){return t({queryKey:[...assetsKey(r),`asset`,e,n],queryFn:()=>c(e,n,r),enabled:i&&n!==``,retry:!1,refetchOnWindowFocus:!1})}export function useA2aTasks(e,n,r){return t({queryKey:[...assetsKey(n),`a2a-tasks`,e],queryFn:({signal:t})=>o(e,n,t),enabled:r,refetchInterval:1e4,retry:!1})}export function useAssetActions(t,o){let s=n(),{label:c}=m[t],l=e=>({onSuccess:()=>{p.success(e),s.invalidateQueries({queryKey:assetsKey(o)})}});return{create:e({mutationFn:e=>r(t,e,o),...l(`${c} created.`)}),save:e({mutationFn:e=>d(t,e.id,e.input,e.etag,o),...l(`${c} draft saved.`)}),remove:e({mutationFn:e=>i(t,e.id,e.etag,o),...l(`${c} deleted.`)}),freeze:e({mutationFn:e=>a(t,e.id,e.reason,o),...l(`Version frozen.`)}),publish:e({mutationFn:e=>u(t,e.id,e.versionId,o),...l(`Version published.`)}),test:e({mutationFn:e=>f(t,e.id,e.input,e.version,o)})}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control Tower's tabs with a count on every tab, whichever tab is open. The queries share
|
|
3
|
+
* their keys with the pages, so the open tab's list is fetched once.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useControlTowerTabs(): {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon: import("lucide-react").LucideIcon;
|
|
9
|
+
count: number | undefined;
|
|
10
|
+
}[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useQuery as e}from"@tanstack/react-query";import{controlTowerTabs as t}from"@/app/control-tower";import{getGuardrails as n,guardrailPolicies as r,guardrailPoliciesKey as i,guardrailsKey as a}from"@/shared/api/guardrails";import{llmProviders as o,llmProvidersKey as s}from"@/shared/api/llm-providers";import{useSession as c}from"@/shared/auth/session-context";import{useTenantScope as l}from"@/shared/hooks/useTenantScope";export function useControlTowerTabs(){let{can:u}=c(),d=l(),f=u(`ai.catalog.read`)&&d.ready,p=e({queryKey:s(d.tenantId),queryFn:({signal:e})=>o.list(d.tenantId,e),enabled:f,retry:!1}),m=e({queryKey:i(d.tenantId),queryFn:({signal:e})=>r.list(d.tenantId,e),enabled:f,retry:!1}),h=e({queryKey:a(d.tenantId),queryFn:({signal:e})=>n(d.tenantId,e),enabled:f,retry:!1}),g=m.data&&h.data?m.data.items.length+h.data.length:void 0,_={llms:p.data?.length,guardrails:g};return t.map(e=>({...e,count:_[e.id]}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AgentDesignerPage, AgentsRegistryPage, GuardrailPolicyDesignerPage, GuardrailsRegistryPage, LlmProviderDesignerPage, LlmProvidersRegistryPage, McpClientDesignerPage, McpRegistryPage, McpServerDesignerPage, NewToolDesignerPage, RemoteAgentDesignerPage, SkillDesignerPage, SkillsRegistryPage, ToolDesignerPage, ToolsRegistryPage, } from './components/RegistryPages';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{AgentDesignerPage,AgentsRegistryPage,GuardrailPolicyDesignerPage,GuardrailsRegistryPage,LlmProviderDesignerPage,LlmProvidersRegistryPage,McpClientDesignerPage,McpRegistryPage,McpServerDesignerPage,NewToolDesignerPage,RemoteAgentDesignerPage,SkillDesignerPage,SkillsRegistryPage,ToolDesignerPage,ToolsRegistryPage}from"./components/RegistryPages";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{env as e}from"@/shared/config/env";export function endpoint(t){return`${(e.apiBaseUrl.startsWith(`http`)?e.apiBaseUrl:`${window.location.origin}${e.apiBaseUrl}`).replace(/\/$/,``)}${t}`}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LucideIcon } from 'lucide-react';
|
|
2
|
+
import type { AssetItem, AssetKind } from '@/shared/api/ai-assets';
|
|
3
|
+
/** What each kind is called and what it is for, in the words people use. */
|
|
4
|
+
export type KindInfo = {
|
|
5
|
+
kind: AssetKind;
|
|
6
|
+
label: string;
|
|
7
|
+
plural: string;
|
|
8
|
+
icon: LucideIcon;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const kinds: Record<AssetKind, KindInfo>;
|
|
12
|
+
export declare const assetTitle: (asset: Pick<AssetItem, 'name' | 'display_name'>) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Bot as e,Cable as t,Network as n,Plug as r,Sparkles as i,Wrench as a}from"lucide-react";export const kinds={agent:{kind:`agent`,label:`Agent`,plural:`Agents`,icon:e,description:`Framework-neutral agents with their skills, tools, MCP and A2A deployment.`},remote_agent:{kind:`remote_agent`,label:`Remote agent`,plural:`Remote agents (A2A)`,icon:n,description:`Partner agents reachable over A2A, usable by our agents as tools.`},skill:{kind:`skill`,label:`Skill`,plural:`Skills`,icon:i,description:`Reusable instructions (and tools) an agent applies to a task.`},tool:{kind:`tool`,label:`Tool`,plural:`Tools`,icon:a,description:`One callable capability: an action, MCP tool, agent, function or expression.`},mcp_server:{kind:`mcp_server`,label:`MCP server`,plural:`MCP servers`,icon:t,description:`MCP endpoints we publish, exposing our tools and agents.`},mcp_client:{kind:`mcp_client`,label:`MCP client`,plural:`MCP clients`,icon:r,description:`Outside MCP servers whose tools our agents use.`}};export const assetTitle=e=>e.display_name||e.name;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AssetKind, type TenantScope } from '@/shared/api/ai-assets';
|
|
2
|
+
import type { AuthProfileKind } from '@/shared/api/integrations';
|
|
3
|
+
/** How an MCP client authenticates, as the dialog offers it. */
|
|
4
|
+
export type McpAuth = 'none' | 'bearer' | 'api_key' | 'client_credentials' | 'authorization_code' | 'existing';
|
|
5
|
+
export declare const mcpAuthOptions: {
|
|
6
|
+
value: McpAuth;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
/** The Integration Studio credential kind behind each inline auth choice. */
|
|
10
|
+
export declare const profileKind: Partial<Record<McpAuth, AuthProfileKind>>;
|
|
11
|
+
export declare const authOf: (kind: AuthProfileKind) => McpAuth;
|
|
12
|
+
/** The credential an MCP client keeps its own auth in (managed from the client dialog). */
|
|
13
|
+
export declare const managedCredential: (client: string) => string;
|
|
14
|
+
/** Where OAuth providers send the person back (register it in the provider's app). */
|
|
15
|
+
export declare const oauthCallback: () => string;
|
|
16
|
+
export declare const slug: (text: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Make what is saved live: freeze the draft and publish it. A draft identical to the last
|
|
19
|
+
* version publishes that version (nothing to freeze).
|
|
20
|
+
*/
|
|
21
|
+
export declare function publishDraft(kind: AssetKind, id: string, tenantId: TenantScope): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{freezeAssetVersion as e,getAsset as t,publishAssetVersion as n}from"@/shared/api/ai-assets";import{ApiError as r}from"@/shared/api/http";import{endpoint as i}from"./endpoints";export const mcpAuthOptions=[{value:`none`,label:`None`},{value:`bearer`,label:`Bearer token`},{value:`api_key`,label:`API key`},{value:`client_credentials`,label:`Client credentials (OAuth2)`},{value:`authorization_code`,label:`Authorization code (OAuth2 sign-in)`},{value:`existing`,label:`Existing credential`}];export const profileKind={bearer:`bearer_static`,api_key:`api_key_header`,client_credentials:`oauth2_client_credentials`,authorization_code:`oauth2_authorization_code`};export const authOf=e=>Object.entries(profileKind).find(([,t])=>t===e)?.[0]??`existing`;export const managedCredential=e=>`mcp-${e}`;export const oauthCallback=()=>i(`/api/v1/integration-auth-profiles/oauth/callback`);export const slug=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,63);export async function publishDraft(i,a,o){try{let t=await e(i,a,`Saved`,o);await n(i,a,t.id,o)}catch(e){if(!(e instanceof r)||!/already has exactly/.test(e.message))throw e;let{data:s}=await t(i,a,o),c=s.versions[0];c&&c.id!==s.pinned_version_id&&await n(i,a,c.id,o)}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AssetKind } from '@/shared/api/ai-assets';
|
|
2
|
+
/** Where each kind's designer lives (`/ai-studio/tools/{id}`, …). */
|
|
3
|
+
export declare const designerBase: Record<AssetKind, string>;
|
|
4
|
+
export declare const designerPath: (kind: AssetKind, id: string) => string;
|
|
5
|
+
/** The list page (and tab) each kind lives on. */
|
|
6
|
+
export declare function listPath(kind: AssetKind): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{paths as e}from"@/app/paths";export const designerBase={agent:e.aiAgents,remote_agent:e.remoteAgents,skill:e.aiSkills,tool:e.aiTools,mcp_server:e.mcpServers,mcp_client:e.mcpClients};export const designerPath=(e,t)=>`${designerBase[e]}/${t}`;export function listPath(t){return t===`agent`?e.aiAgents:t===`remote_agent`?`${e.aiAgents}?tab=remote_agent`:t===`skill`?e.aiSkills:t===`tool`?e.aiTools:t===`mcp_server`?`${e.mcp}?tab=mcp_server`:e.mcp}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ToolSpec } from '@/shared/api/ai-assets';
|
|
2
|
+
/** A tool's contract as rows: JSON Schema properties the designer edits without JSON. */
|
|
3
|
+
export type JsonSchema = Record<string, unknown>;
|
|
4
|
+
export type Executor = NonNullable<ToolSpec['executor']>;
|
|
5
|
+
export type ExecutorType = Executor['type'];
|
|
6
|
+
export type Binding = NonNullable<ToolSpec['bindings']>[string];
|
|
7
|
+
export declare const ARGUMENT_TYPES: readonly ['string', 'number', 'integer', 'boolean', 'object', 'array'];
|
|
8
|
+
export type ArgumentType = (typeof ARGUMENT_TYPES)[number] | 'any';
|
|
9
|
+
/** One argument (or output field). `extra` keeps every other JSON Schema keyword (format,
|
|
10
|
+
* items, minimum…) so a schema from an MCP server survives being edited as rows. */
|
|
11
|
+
export type Argument = {
|
|
12
|
+
name: string;
|
|
13
|
+
type: ArgumentType;
|
|
14
|
+
required: boolean;
|
|
15
|
+
description: string;
|
|
16
|
+
default?: unknown;
|
|
17
|
+
options: string[];
|
|
18
|
+
extra: JsonSchema;
|
|
19
|
+
};
|
|
20
|
+
/** The rows of a JSON Schema object; anything that is not one gives no rows. */
|
|
21
|
+
export declare function argumentsOf(schema: unknown): Argument[];
|
|
22
|
+
/** The JSON Schema object of the rows, keeping the base schema's other keywords; no rows
|
|
23
|
+
* is the empty schema (anything is accepted). */
|
|
24
|
+
export declare function schemaOf(rows: readonly Argument[], base?: unknown): JsonSchema;
|
|
25
|
+
export declare const NAME_PATTERN: RegExp;
|
|
26
|
+
/** A free name for a new row (`argument_1`, `argument_2`…). */
|
|
27
|
+
export declare const nextName: (rows: readonly Argument[], prefix: string) => string;
|
|
28
|
+
/** The text a value is edited as: strings as they are, everything else as JSON; no value
|
|
29
|
+
* (undefined, or null for a binding not filled in yet) is empty. */
|
|
30
|
+
export declare const asText: (value: unknown) => string;
|
|
31
|
+
/** A typed value from its text, or why it is not one. Empty text is no value. */
|
|
32
|
+
export declare function parseValue(type: ArgumentType, text: string): {
|
|
33
|
+
value?: unknown;
|
|
34
|
+
problem?: string;
|
|
35
|
+
};
|
|
36
|
+
/** The arguments callers give: every argument the tool does not bind itself. */
|
|
37
|
+
export declare const callerArguments: (rows: readonly Argument[], bindings: ToolSpec['bindings']) => Argument[];
|
|
38
|
+
/** The argument names a prompt template uses, in order, once each. */
|
|
39
|
+
export declare const placeholders: (template: string) => string[];
|
|
40
|
+
/** A tool is the leaf that does the work (ADR 0035). Skills, agents and flows are the
|
|
41
|
+
* wrappers that orchestrate tools, so a tool never wraps one of them. Authors pick one of
|
|
42
|
+
* these categories; `types` are the executors it covers (the first is chosen). */
|
|
43
|
+
export declare const CATEGORIES: readonly {
|
|
44
|
+
key: string;
|
|
45
|
+
types: readonly ExecutorType[];
|
|
46
|
+
label: string;
|
|
47
|
+
detail: string;
|
|
48
|
+
}[];
|
|
49
|
+
/** The Python a new script tool starts from. */
|
|
50
|
+
export declare const SCRIPT_STARTER = "def run(inputs):\n \"\"\"Return the outputs as a JSON value; print() goes to the test trace.\"\"\"\n return {\"echo\": inputs}\n";
|
|
51
|
+
/** Synced from an MCP server: read-only here, a sync replaces it. */
|
|
52
|
+
export declare const isSynced: (type: string) => type is "mcp";
|
|
53
|
+
/** Tools that wrap an agent or a prompt: kept running, never offered for new tools. */
|
|
54
|
+
export declare const isWrapper: (type: string) => type is "agent" | "prompt";
|
|
55
|
+
export declare const sourceLabel: (type: string) => string;
|
|
56
|
+
export declare const EXECUTOR_DEFAULTS: Record<ExecutorType, Executor>;
|
|
57
|
+
/** The spec a new tool starts from: a REST call with no arguments. */
|
|
58
|
+
export declare const NEW_TOOL_SPEC: ToolSpec;
|
|
59
|
+
/** The texts a tool test starts from: each argument's default. */
|
|
60
|
+
export declare const startingTexts: (rows: readonly Argument[]) => {
|
|
61
|
+
[k: string]: string;
|
|
62
|
+
};
|
|
63
|
+
/** The arguments of the texts, or each reason one is wrong (required and empty, not a
|
|
64
|
+
* value of its type). */
|
|
65
|
+
export declare function argumentsFrom(rows: readonly Argument[], texts: Record<string, string>): {
|
|
66
|
+
values: Record<string, unknown>;
|
|
67
|
+
problems: Record<string, string>;
|
|
68
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const ARGUMENT_TYPES=[`string`,`number`,`integer`,`boolean`,`object`,`array`];const e=e=>typeof e==`object`&&!!e&&!Array.isArray(e),t=e=>typeof e==`string`&&ARGUMENT_TYPES.includes(e)?e:`any`;export function argumentsOf(n){if(!e(n)||!e(n.properties))return[];let r=Array.isArray(n.required)?n.required:[];return Object.entries(n.properties).map(([n,i])=>{let{type:a,description:o,default:s,enum:c,...l}=e(i)?i:{};return{name:n,type:t(a),required:r.includes(n),description:typeof o==`string`?o:``,...s===void 0?{}:{default:s},options:Array.isArray(c)?c.map(String):[],extra:a!==void 0&&t(a)===`any`?{type:a,...l}:l}})}export function schemaOf(t,n={}){let r=e(n)?n:{};return t.length===0?{}:{...r,type:`object`,properties:Object.fromEntries(t.map(e=>[e.name,{...e.extra,...e.type===`any`?{}:{type:e.type},...e.description?{description:e.description}:{},...e.default===void 0?{}:{default:e.default},...e.options.length?{enum:e.options}:{}}])),required:t.filter(e=>e.required).map(e=>e.name)}}export const NAME_PATTERN=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/;export const nextName=(e,t)=>{let n=e.length+1;for(;e.some(e=>e.name===`${t}_${n}`);)n+=1;return`${t}_${n}`};export const asText=e=>e==null?``:typeof e==`string`?e:JSON.stringify(e);export function parseValue(t,n){let r=n.trim();if(r===``)return{};if(t===`string`)return{value:n};if(t===`number`||t===`integer`){let e=Number(r);return Number.isFinite(e)?t===`integer`&&!Number.isInteger(e)?{problem:`Enter a whole number.`}:{value:e}:{problem:`Enter a number.`}}if(t===`boolean`)return r===`true`||r===`false`?{value:r===`true`}:{problem:`Enter true or false.`};try{let n=JSON.parse(r);return t===`object`&&!e(n)?{problem:`Enter a JSON object.`}:t===`array`&&!Array.isArray(n)?{problem:`Enter a JSON array.`}:{value:n}}catch{return t===`any`?{value:n}:{problem:`Enter valid JSON.`}}}export const callerArguments=(e,t)=>e.filter(e=>!(t??{})[e.name]);const n=/\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;export const placeholders=e=>[...new Set([...e.matchAll(n)].map(e=>e[1]))];export const CATEGORIES=[{key:`rest`,types:[`action`],label:`REST call`,detail:`A published Integration Studio action`},{key:`database`,types:[`query`],label:`Database call`,detail:`A published query: arguments are its parameters`},{key:`coded`,types:[`platform`],label:`Coded`,detail:`A platform function`},{key:`script`,types:[`script`,`expression`],label:`Script`,detail:`Python run(inputs) in a sandbox, or CEL`}];export const SCRIPT_STARTER=`def run(inputs):
|
|
2
|
+
"""Return the outputs as a JSON value; print() goes to the test trace."""
|
|
3
|
+
return {"echo": inputs}
|
|
4
|
+
`;export const isSynced=e=>e===`mcp`;export const isWrapper=e=>e===`agent`||e===`prompt`;const r={action:`REST call`,platform:`Coded`,expression:`Script · CEL`,query:`Database call`,script:`Script`,mcp:`MCP tool`,agent:`Agent`,prompt:`Prompt`};export const sourceLabel=e=>r[e]??e;export const EXECUTOR_DEFAULTS={action:{type:`action`,action:``},mcp:{type:`mcp`,client:``,tool:``},agent:{type:`agent`,agent:``,remote:!1},platform:{type:`platform`,function:`text.to_upper`},expression:{type:`expression`,expression:`input`},prompt:{type:`prompt`,instructions:``,llm_provider:null},query:{type:`query`,query:``},script:{type:`script`,language:`python`,code:`def run(inputs):
|
|
5
|
+
"""Return the outputs as a JSON value; print() goes to the test trace."""
|
|
6
|
+
return {"echo": inputs}
|
|
7
|
+
`}};export const NEW_TOOL_SPEC={executor:EXECUTOR_DEFAULTS.action,input_schema:{},bindings:{},output_schema:{},output_expression:``,timeout_ms:3e4,requires_approval:!1,tags:[]};export const startingTexts=e=>Object.fromEntries(e.map(e=>[e.name,asText(e.default)]));export function argumentsFrom(e,t){let n={},r={};for(let i of e){let e=parseValue(i.type,t[i.name]??``);e.problem?r[i.name]=e.problem:e.value===void 0?i.required&&(r[i.name]=`Required`):n[i.name]=e.value}return{values:n,problems:r}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AssetKind } from '@/shared/api/ai-assets';
|
|
2
|
+
/** The designer of one asset: its spec (per kind), versions, tests and, for agents, the
|
|
3
|
+
* tasks A2A callers started. A new page, saved with If-Match. */
|
|
4
|
+
export declare function AssetDesignerPage({ kind }: {
|
|
5
|
+
kind: AssetKind;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tabBarClass as e,tabClass as t}from"@/shared/components/workspace/tab-styles";import{useState as n}from"react";import{useNavigate as r,useParams as i,useSearchParams as a}from"react-router-dom";import{Save as o,Trash2 as s}from"lucide-react";import{runSettingsOf as c}from"@/shared/api/run-settings";import{useSession as l}from"@/shared/auth/session-context";import{RunSettingsFields as ee}from"@/shared/components/workspace/RunSettingsFields";import{ConfirmButton as te}from"@/shared/components/workspace/ConfirmButton";import{Button as u}from"@/shared/components/ui/button";import{ChooseTenant as d}from"@/shared/components/workspace/ChooseTenant";import{ControlHeader as f}from"@/shared/components/workspace/ControlHeader";import{useTenantScope as p}from"@/shared/hooks/useTenantScope";import{cn as m}from"@/shared/lib/utils";import{AreaField as ne,Section as h,TextField as re}from"../components/fields";import{A2aTasksPanel as ie,Problems as g,TestPanel as ae,VersionsPanel as oe}from"../components/Panels";import{McpClientToolsPanel as _}from"../components/McpClientToolsPanel";import{AgentEditor as v,McpClientEditor as y,McpServerEditor as b,RemoteAgentEditor as x,SkillEditor as S}from"../components/SpecEditors";import{ToolInputsOutputs as C,ToolSettings as se,ToolSource as w}from"../components/ToolEditor";import{useAgentSpec as T,useAsset as E,useAssetActions as D}from"../hooks/useAssets";import{assetTitle as O,kinds as k}from"../model/kinds";import{listPath as A}from"../model/routes";import{isSynced as ce}from"../model/tool-contract";import{BackLink as le}from"@/shared/components/workspace/BackLink";import{jsx as j,jsxs as M,Fragment as N}from"react/jsx-runtime";const P={agent:v,skill:S,mcp_client:y,mcp_server:b,remote_agent:x},F=[[`details`,`Details`],[`source`,`Source`],[`io`,`Inputs & outputs`],[`settings`,`Settings`]],I=e=>({display_name:e.display_name??``,description:e.description,spec:e.spec});export function AssetDesignerPage({kind:e}){let{id:t=``}=i(),{can:n}=l(),r=p(),a=n(`ai.catalog.read`),o=E(e,t,r.tenantId,a&&r.ready);return a?r.ready?o.error?j(g,{error:o.error}):o.data?j(L,{asset:o.data.data,loadedEtag:o.data.etag},o.data.etag):j(`output`,{className:`block p-6 text-sm`,children:`Loading…`}):j(d,{children:`Agents, skills and tools belong to one customer.`}):j(`p`,{role:`alert`,children:`You do not have access to the AI registry.`})}function L({asset:i,loadedEtag:d}){let{can:v}=l(),y=p(),b=r(),[x,S]=a(),E=v(`ai.asset.write`),L=T(i.kind===`agent`),R=D(i.kind,y.tenantId),[z,B]=n(()=>I(i)),V=d,H=k[i.kind],U=JSON.stringify(z)!==JSON.stringify(I(i)),W=i.kind===`tool`,G=W&&ce(i.spec.executor?.type??``),K=W?`details`:`design`,q=x.get(`tab`)??K,ue=[...W?F:[[`design`,`Design`]],[`versions`,`Versions (${i.versions.length})`],[`test`,`Test`],...i.kind===`mcp_client`?[[`tools`,`Tools`]]:[],...i.kind===`agent`?[[`a2a`,`A2A tasks`]]:[]],J=P[i.kind],Y=e=>B({...z,spec:{...z.spec,...e}}),X=z.spec,Z=i.kind===`agent`||i.kind===`skill`||W,de=c(z.spec.run),Q=Z&&c(i.spec.run).protection===`read_only`,$=Z&&j(`fieldset`,{disabled:!E||G,className:`min-w-0`,children:j(h,{title:`Run settings`,children:j(ee,{id:`${i.kind}-run`,what:H.label.toLowerCase(),value:de,onChange:e=>Y({run:e})})})});return M(`div`,{className:`workspace-admin flex min-h-0 flex-col`,children:[j(le,{to:A(i.kind),children:H.plural}),j(f,{title:O({name:i.name,display_name:z.display_name||null}),description:`${H.label} · ${i.name} · ${i.published_number?`v${i.published_number} is live`:`not published`}`,icon:H.icon,actions:E&&M(N,{children:[U&&j(`span`,{className:`text-xs font-semibold text-warning-foreground`,children:`Unsaved changes`}),!G&&M(u,{disabled:!U||R.save.isPending,onClick:()=>R.save.mutate({id:i.id,etag:V,input:{display_name:z.display_name.trim()||null,description:z.description,spec:z.spec}}),children:[j(o,{}),` `,R.save.isPending?`Saving…`:`Save draft`]}),M(te,{destructive:!0,title:`Delete ${i.name}?`,detail:`Assets that use it stop resolving.`,action:`Delete`,disabled:Q,pending:R.remove.isPending,onConfirm:()=>R.remove.mutate({id:i.id,etag:V},{onSuccess:()=>void b(A(i.kind))}),children:[j(s,{}),` Delete`]})]})}),j(g,{error:R.save.error??R.remove.error}),j(`nav`,{"aria-label":`Designer views`,className:m(e,`mb-3`),children:ue.map(([e,n])=>j(`button`,{type:`button`,"aria-current":q===e?`page`:void 0,onClick:()=>S(t=>{let n=new URLSearchParams(t);return e===K?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0}),className:t(q===e),children:n},e))}),Q&&j(`output`,{className:`mb-3 block rounded-lg border bg-muted/30 px-3 py-2 text-xs`,children:`Protected (read-only): set Run settings › Protection to None and save, on its own, to change it.`}),(q===`design`||q===`details`)&&M(`fieldset`,{disabled:!E||G||Q,className:`min-w-0 space-y-3`,children:[j(h,{title:`Identity`,children:M(`div`,{className:`grid gap-3 md:grid-cols-[1fr_2fr]`,children:[j(re,{label:`Display name`,value:z.display_name,max:120,onChange:e=>B({...z,display_name:e})}),j(ne,{label:`Description`,value:z.description,rows:2,max:2e3,onChange:e=>B({...z,description:e}),hint:`Models read it to decide when to use this asset.`})]})}),J&&j(J,{spec:z.spec,set:Y,name:i.name,tenantId:y.tenantId,runtimes:L.data?.runtimes??[`maf`]})]}),q===`design`&&j(`div`,{className:`mt-3`,children:$}),W&&[`source`,`io`,`settings`].includes(q)&&M(`fieldset`,{disabled:!E||G||Q,className:`min-w-0`,children:[q===`source`&&j(w,{spec:X,set:Y,tenantId:y.tenantId}),q===`io`&&j(C,{spec:X,set:Y}),q===`settings`&&j(se,{spec:X,set:Y})]}),W&&q===`settings`&&j(`div`,{className:`mt-3`,children:$}),q===`versions`&&M(N,{children:[U&&j(`p`,{className:`mb-2 text-xs text-warning-foreground`,children:`Save the draft first: a version freezes what is saved.`}),j(oe,{asset:i,tenantId:y.tenantId,canPublish:v(`ai.asset.publish`)})]}),q===`test`&&j(ae,{asset:i,tenantId:y.tenantId}),q===`a2a`&&j(ie,{asset:i,tenantId:y.tenantId}),q===`tools`&&i.kind===`mcp_client`&&j(_,{client:i,tenantId:y.tenantId})]})}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type LucideIcon } from 'lucide-react';
|
|
2
|
+
import type { AssetKind } from '@/shared/api/ai-assets';
|
|
3
|
+
/** One registry page: tabs for its kinds (e.g. Agents | Remote agents), New opens the
|
|
4
|
+
* designer of a new asset of the shown kind. */
|
|
5
|
+
export declare function AssetsPage({ title, description, icon, tabs, }: {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
icon: LucideIcon;
|
|
9
|
+
tabs: readonly AssetKind[];
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PageTabs as e}from"@/shared/components/workspace/PageTabs";import{useNavigate as t,useSearchParams as n}from"react-router-dom";import{Plus as r}from"lucide-react";import{useSession as i}from"@/shared/auth/session-context";import{Button as a}from"@/shared/components/ui/button";import{ChooseTenant as o}from"@/shared/components/workspace/ChooseTenant";import{ControlHeader as s}from"@/shared/components/workspace/ControlHeader";import{InsightGrid as c}from"@/shared/components/workspace/insight-grid";import{SearchInput as l}from"@/shared/components/workspace/SearchInput";import{useTenantScope as u}from"@/shared/hooks/useTenantScope";import{NewAssetPanel as d}from"../components/Panels";import{useAssets as f}from"../hooks/useAssets";import{assetTitle as p,kinds as m}from"../model/kinds";import{designerPath as h}from"../model/routes";import{isWrapper as g,sourceLabel as _}from"../model/tool-contract";import{matchesSearch as v}from"@/shared/lib/search";import{jsx as y,jsxs as b}from"react/jsx-runtime";function x(e){let t=m[e.kind];return{id:e.id,title:p(e),subtitle:e.description||t.description,icon:t.icon,status:e.published_number?{label:`Published v${e.published_number}`,tone:`good`}:{label:`Draft`,tone:`neutral`}}}const S=e=>[e.name,e.display_name??``,e.description,...e.tool?[_(e.tool.source),e.tool.target,...e.tool.tags]:[]];export function AssetsPage({title:p,description:_,icon:C,tabs:w}){let{can:T}=i(),E=u(),D=t(),[O,k]=n(),A=e=>k(t=>{let n=new URLSearchParams(t);return Object.entries(e).forEach(([e,t])=>t?n.set(e,t):n.delete(e)),n},{replace:!0}),j=O.get(`tab`),M=w.find(e=>e===j)??(j===`a2a`&&w.includes(`remote_agent`)?`remote_agent`:w[0]),N=T(`ai.catalog.read`),P=T(`ai.asset.write`),F=f(M,E.tenantId,N&&E.ready),I={...F,data:F.data?.filter(e=>!(e.tool&&g(e.tool.source)))},L=O.get(`q`)??``,R=(I.data??[]).filter(e=>v(L,S(e)));return b(`div`,{className:`workspace-admin flex min-h-0 flex-col`,children:[y(s,{title:p,description:_,icon:C,actions:P&&E.ready&&b(a,{onClick:()=>M===`tool`?void D(`${h(M,`new`)}`):A({new:M}),children:[y(r,{}),` `,m[M].label]})}),w.length>1&&y(`div`,{className:`mb-3`,children:y(e,{label:`${p} kinds`,current:M,tabs:w.map(e=>({id:e,label:m[e].plural,icon:m[e].icon}))})}),N?E.ready?I.error?b(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`The registry could not be loaded: `,I.error.message]}):y(c,{label:`${m[M].plural} inventory`,rows:R.map(x),densityKey:`sirius-assets-density`,empty:I.isPending?`Loading…`:L?`Nothing matches this search.`:`No ${m[M].plural.toLowerCase()} yet. Choose “New ${m[M].label.toLowerCase()}”.`,onOpen:e=>void D(h(M,e.id)),toolbar:y(l,{className:`w-64 max-w-full`,label:`Search ${m[M].plural.toLowerCase()}`,placeholder:`Search ${m[M].plural.toLowerCase()}…`,value:O.get(`q`)??``,onChange:e=>A({q:e})})}):y(o,{children:`Agents, skills and tools belong to one customer.`}):y(`p`,{role:`alert`,children:`Your account does not have permission to view the AI registry.`}),O.get(`new`)&&P&&E.ready&&y(d,{kind:M,tenantId:E.tenantId,onClose:()=>A({new:``})})]})}
|
|
@@ -0,0 +1,3 @@
|
|
|
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}from"react-router-dom";import{Plus as o,Save as s,Trash2 as c,X as l,Zap as u}from"lucide-react";import{paths as d}from"@/app/paths";import{getAssets as f}from"@/shared/api/ai-assets";import{guardrailPolicies as p,guardrailPoliciesKey as m,harmCategoryLabels as h,policyActionLabels as g,policyCheckHints as _,policyCheckLabels as v,policyStageLabels as y,severityLabels as b,targetKindLabels as x}from"@/shared/api/guardrails";import{getFlows as S}from"@/shared/api/workflow-packs";import{useSession as C}from"@/shared/auth/session-context";import{Button as w}from"@/shared/components/ui/button";import{Input as T}from"@/shared/components/ui/input";import{Switch as E}from"@/shared/components/ui/switch";import{Textarea as D}from"@/shared/components/ui/textarea";import{ChooseTenant as O}from"@/shared/components/workspace/ChooseTenant";import{ConfirmButton as k}from"@/shared/components/workspace/ConfirmButton";import{ModalField as A,modalSelect as j}from"@/shared/components/workspace/Modal";import{useGoBack as M}from"@/shared/hooks/useGoBack";import{useTenantScope as N}from"@/shared/hooks/useTenantScope";import{notify as P}from"@/shared/lib/notify";import{cn as F}from"@/shared/lib/utils";import{FormSection as I,McpEditorLayout as L,StatusBadge as R}from"../components/McpEditorLayout";import{Problems as z}from"../components/Panels";import{jsx as B,jsxs as V,Fragment as H}from"react/jsx-runtime";const U=`${d.controlTower}?tab=guardrails`,W=Object.keys(h),G=[`flow`,`agent`,`skill`,`tool`],K=e=>({name:e?.name??``,description:e?.description??``,check:e?.check??`blocked_terms`,stage:e?.stage??`both`,action:e?.action??`block`,enabled:e?.is_enabled??!0,everywhere:e?.everywhere??!0,targets:e?.targets??[],terms:(e?.terms??[]).join(`
|
|
2
|
+
`),categories:e?.categories.length?e.categories:W,severity:e?.severity??4}),q=e=>e.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean);export function GuardrailPolicyPage(){let{id:e=`new`}=a(),{can:t}=C(),r=N(),i=e===`new`,o=n({queryKey:[...m(r.tenantId),e],queryFn:()=>p.get(e,r.tenantId),enabled:r.ready&&!i,retry:!1});return t(`ai.catalog.read`)?r.ready?o.error?B(z,{error:o.error}):!i&&!o.data?B(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading…`}):B(Y,{saved:o.data??null,tenantId:r.tenantId,writable:t(`ai.asset.publish`)},o.data?.etag??`new`):B(O,{children:`Guardrails belong to one customer.`}):B(`p`,{role:`alert`,children:`You do not have access to guardrails.`})}function J(e,t){return n({queryKey:[`guardrail-targets`,e,t??`own`],queryFn:async({signal:n})=>e===`flow`?(await S(t,n)).map(e=>e.name):(await f(e,t,n)).map(e=>e.name),retry:!1})}function Y({saved:n,tenantId:a,writable:o}){let l=r(),u=i(),[f,x]=e(()=>K(n?.data??null)),{goBack:S}=M(U),C=JSON.stringify(f)!==JSON.stringify(K(n?.data??null)),O=e=>x(t=>({...t,...e})),N=q(f.terms),F=f.name.trim()!==``&&(f.check!==`blocked_terms`||N.length>0)&&(f.check!==`harmful_content`||f.categories.length>0)&&(f.everywhere||f.targets.length>0);function G(){return{name:f.name.trim(),description:f.description.trim(),check:f.check,stage:f.stage,action:f.action,is_enabled:f.enabled,everywhere:f.everywhere,targets:f.everywhere?[]:f.targets,terms:f.check===`blocked_terms`?N:[],categories:f.check===`harmful_content`?f.categories:[],severity:f.severity}}let J=t({mutationFn:()=>n?p.update(n.data.id,G(),n.etag,a):p.create(G(),a),onSuccess:e=>{P.success(n?`Guardrail saved. The next runs use it.`:`Guardrail created.`),l.invalidateQueries({queryKey:m(a)}),n||u(`${d.guardrails}/${e.data.id}`,{replace:!0})}}),Y=t({mutationFn:()=>p.remove(n?.data.id??``,n?.etag??``,a),onSuccess:()=>{P.success(`Guardrail deleted.`),l.invalidateQueries({queryKey:m(a)}),u(U)}}),Q=n?.data;return V(L,{back:U,backLabel:`Guardrails`,title:Q?f.name||Q.name:`New guardrail`,subtitle:_[f.check],badge:Q?B(R,{tone:Q.is_enabled?`good`:`plain`,children:Q.is_enabled?`On`:`Off`}):B(R,{tone:`plain`,children:`New`}),tab:`details`,onTab:()=>void 0,tabs:[{id:`details`,label:`Details`}],actions:o&&V(H,{children:[B(w,{variant:`outline`,onClick:S,children:`Cancel`}),V(w,{type:`submit`,form:`guardrail-form`,disabled:!F||J.isPending||n!==null&&!C,children:[B(s,{}),` `,J.isPending?`Saving…`:n?`Save`:`Create`]}),n&&V(k,{destructive:!0,title:`Delete ${n.data.name}?`,detail:`Runs are no longer checked against it.`,action:`Delete`,pending:Y.isPending,error:Y.error?.message,onConfirm:()=>Y.mutate(),children:[B(c,{}),` Delete`]})]}),children:[V(`form`,{id:`guardrail-form`,"aria-label":`Guardrail details`,className:`max-w-6xl`,onSubmit:e=>{e.preventDefault(),J.mutate()},children:[J.error&&B(`div`,{className:`mb-4`,children:B(z,{error:J.error})}),V(`fieldset`,{disabled:!o,className:`min-w-0`,children:[V(I,{title:`General`,description:`What the guardrail is called and whether it runs.`,children:[B(A,{label:`Name *`,htmlFor:`guardrail-name`,children:B(T,{id:`guardrail-name`,required:!0,maxLength:120,placeholder:`Block jailbreaks`,value:f.name,onChange:e=>O({name:e.target.value})})}),V(`div`,{className:`flex items-end gap-2 pb-2 text-sm`,children:[B(E,{"aria-label":`On`,checked:f.enabled,onCheckedChange:e=>O({enabled:e})}),B(`span`,{"aria-hidden":`true`,children:`On`})]}),B(A,{label:`Description`,htmlFor:`guardrail-description`,wide:!0,children:B(D,{id:`guardrail-description`,rows:2,maxLength:2e3,value:f.description,onChange:e=>O({description:e.target.value})})})]}),V(I,{title:`Check`,description:`What the guardrail looks for, in which text, and what happens when it trips.`,children:[B(A,{label:`Check *`,htmlFor:`guardrail-check`,children:B(`select`,{id:`guardrail-check`,className:j,value:f.check,onChange:e=>O({check:e.target.value}),children:Object.entries(v).map(([e,t])=>B(`option`,{value:e,children:t},e))})}),B(A,{label:`Text checked`,htmlFor:`guardrail-stage`,children:B(`select`,{id:`guardrail-stage`,className:j,value:f.stage,onChange:e=>O({stage:e.target.value}),children:Object.entries(y).map(([e,t])=>B(`option`,{value:e,children:t},e))})}),B(A,{label:`When it trips`,htmlFor:`guardrail-action`,hint:f.action===`block`?`The run stops with the guardrail name; a flow takes the step’s failure route.`:`The run continues; the trip is recorded in the run’s trace.`,children:B(`select`,{id:`guardrail-action`,className:j,value:f.action,onChange:e=>O({action:e.target.value}),children:Object.entries(g).map(([e,t])=>B(`option`,{value:e,children:t},e))})}),f.check===`harmful_content`&&B(A,{label:`Trips from severity`,htmlFor:`guardrail-severity`,children:B(`select`,{id:`guardrail-severity`,className:j,value:f.severity,onChange:e=>O({severity:Number(e.target.value)}),children:Object.entries(b).map(([e,t])=>B(`option`,{value:e,children:t},e))})}),f.check===`blocked_terms`&&B(A,{label:`Blocked terms *`,htmlFor:`guardrail-terms`,wide:!0,hint:`One per line. Whole words or phrases, ignoring case.`,children:B(D,{id:`guardrail-terms`,rows:4,value:f.terms,onChange:e=>O({terms:e.target.value})})}),f.check===`harmful_content`&&V(`fieldset`,{className:`md:col-span-2`,children:[B(`legend`,{className:`mb-2 text-sm font-medium`,children:`Categories *`}),B(`div`,{className:`flex flex-wrap gap-4`,children:W.map(e=>V(`label`,{className:`flex items-center gap-2 text-sm`,children:[B(`input`,{type:`checkbox`,checked:f.categories.includes(e),onChange:t=>O({categories:t.target.checked?[...f.categories,e]:f.categories.filter(t=>t!==e)})}),h[e]]},e))})]})]}),V(I,{title:`Applies to`,description:`Every run, or only the flows, agents, skills and tools you choose. A flow covers everything it runs.`,children:[V(`fieldset`,{className:`md:col-span-2`,children:[B(`legend`,{className:`sr-only`,children:`Applies to`}),V(`div`,{className:`flex gap-6 text-sm`,children:[V(`label`,{className:`flex items-center gap-2`,children:[B(`input`,{type:`radio`,name:`guardrail-scope`,checked:f.everywhere,onChange:()=>O({everywhere:!0})}),`Everywhere`]}),V(`label`,{className:`flex items-center gap-2`,children:[B(`input`,{type:`radio`,name:`guardrail-scope`,checked:!f.everywhere,onChange:()=>O({everywhere:!1})}),`Chosen flows, agents, skills and tools`]})]})]}),!f.everywhere&&B(X,{tenantId:a,targets:f.targets,onChange:e=>O({targets:e})})]})]})]}),Q&&B(Z,{policy:Q,tenantId:a})]})}function X({tenantId:t,targets:n,onChange:r}){let[i,a]=e(`agent`),[s,c]=e(``),u=J(i,t),d=new Set(n.map(e=>`${e.kind}:${e.name}`)),f=(u.data??[]).filter(e=>!d.has(`${i}:${e}`)).sort();return V(`div`,{className:`space-y-3 md:col-span-2`,children:[V(`div`,{className:`flex flex-wrap items-end gap-2`,children:[B(A,{label:`Kind`,htmlFor:`guardrail-target-kind`,children:B(`select`,{id:`guardrail-target-kind`,className:F(j,`w-36`),value:i,onChange:e=>{a(e.target.value),c(``)},children:G.map(e=>B(`option`,{value:e,children:x[e]},e))})}),B(A,{label:`Name`,htmlFor:`guardrail-target-name`,children:V(`select`,{id:`guardrail-target-name`,className:F(j,`w-72`),value:s,onChange:e=>c(e.target.value),children:[B(`option`,{value:``,children:u.isPending?`Loading…`:f.length?`Choose…`:`Nothing to add`}),f.map(e=>B(`option`,{value:e,children:e},e))]})}),V(w,{type:`button`,variant:`outline`,disabled:!s,onClick:()=>{r([...n,{kind:i,name:s}]),c(``)},children:[B(o,{}),` Add`]})]}),n.length===0?B(`p`,{className:`text-xs text-destructive`,children:`Add at least one, or apply it everywhere.`}):B(`ul`,{"aria-label":`Attached to`,className:`flex flex-wrap gap-2`,children:n.map(e=>V(`li`,{className:`flex items-center gap-1.5 rounded-md border bg-muted/40 py-1 pr-1 pl-2 text-xs`,children:[B(`span`,{className:`text-muted-foreground`,children:x[e.kind]}),B(`span`,{className:`font-medium`,children:e.name}),B(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,className:`rounded p-0.5 hover:bg-destructive/10 hover:text-destructive`,onClick:()=>r(n.filter(t=>t!==e)),children:B(l,{className:`size-3.5`})})]},`${e.kind}:${e.name}`))})]})}function Z({policy:n,tenantId:r}){let[i,a]=e(``),[o,s]=e(n.stage===`output`?`output`:`input`),[c,l]=e(!1),[d,f]=e(null),m=t({mutationFn:()=>p.try(n.id,{text:i,stage:o,tool:c},r),onSuccess:f});return B(`section`,{"aria-label":`Try it`,className:`max-w-6xl border-t`,children:V(I,{title:`Try it`,description:`Check a text against the saved guardrail, on or off. The text is not kept.`,children:[B(A,{label:`Text`,htmlFor:`guardrail-try-text`,wide:!0,children:B(D,{id:`guardrail-try-text`,rows:3,maxLength:2e4,value:i,onChange:e=>a(e.target.value)})}),V(`div`,{className:`flex flex-wrap items-center gap-4 md:col-span-2`,children:[V(`select`,{"aria-label":`Checked as`,className:F(j,`w-40`),value:o,onChange:e=>s(e.target.value),children:[B(`option`,{value:`input`,children:`Input`}),B(`option`,{value:`output`,children:`Output`})]}),V(`label`,{className:`flex items-center gap-2 text-sm`,children:[B(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`As a tool call`]}),V(w,{type:`button`,variant:`outline`,disabled:!i.trim()||m.isPending,onClick:()=>m.mutate(),children:[B(u,{}),` `,m.isPending?`Checking…`:`Try`]})]}),(d||m.error)&&V(`div`,{className:`md:col-span-2`,children:[B(z,{error:m.error}),d&&B(`output`,{className:F(`block rounded-md px-3 py-2 text-sm`,d.passed?`bg-success/10 text-success-foreground`:`bg-destructive/10 text-destructive`),children:d.passed?`Passed: nothing tripped.`:d.trips.map(e=>`${g[e.action]}: ${e.reason}`).join(` · `)})]})]})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GridHeader as e,GridHeaderSlot as t}from"@/shared/components/workspace/GridHeader";import{useState as n}from"react";import{mcpHeadings as r}from"../components/mcp-headings";import{DataTable as i,DataTableRow as a}from"@/shared/components/workspace/DataTable";import{useMutation as o,useQuery as s,useQueryClient as c}from"@tanstack/react-query";import{Link as l,useNavigate as u,useSearchParams as d}from"react-router-dom";import{LockKeyhole as f,Plus as p,Search as m,ShieldCheck as h}from"lucide-react";import{paths as g}from"@/app/paths";import{getGuardrails as _,guardrailPolicies as v,guardrailPoliciesKey as y,guardrailStageLabels as b,guardrailsKey as x,policyActionLabels as S,policyCheckLabels as C,policyStageLabels as w,policyWrite as T,switchGuardrail as E,targetKindLabels as D}from"@/shared/api/guardrails";import{useSession as O}from"@/shared/auth/session-context";import{Button as k}from"@/shared/components/ui/button";import{Input as A}from"@/shared/components/ui/input";import{Switch as j}from"@/shared/components/ui/switch";import{ChooseTenant as M}from"@/shared/components/workspace/ChooseTenant";import{ControlHeader as N}from"@/shared/components/workspace/ControlHeader";import{PageTabs as P}from"@/shared/components/workspace/PageTabs";import{RefreshButton as F}from"@/shared/components/workspace/RefreshButton";import{SearchInput as I}from"@/shared/components/workspace/SearchInput";import{useTenantScope as L}from"@/shared/hooks/useTenantScope";import{formatInstant as R}from"@/shared/lib/datetime";import{notify as z}from"@/shared/lib/notify";import{matchesSearch as B}from"@/shared/lib/search";import{cn as V}from"@/shared/lib/utils";import{Badge as H,cell as U}from"../components/McpTables";import{useControlTowerTabs as W}from"../hooks/useControlTowerTabs";import{jsx as G,jsxs as K,Fragment as q}from"react/jsx-runtime";export function GuardrailsPage(){let[a,o]=n(null),[c,l]=n(null),[b,T]=n(``),{can:E}=O(),D=L(),j=u(),[R,z]=d(),V=E(`ai.catalog.read`),H=E(`ai.asset.publish`),U=s({queryKey:y(D.tenantId),queryFn:({signal:e})=>v.list(D.tenantId,e),enabled:V&&D.ready,retry:!1}),Q=s({queryKey:x(D.tenantId),queryFn:({signal:e})=>_(D.tenantId,e),enabled:V&&D.ready,retry:!1}),$=R.get(`q`)??``,ee=e=>z(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0}),te=(U.data?.items??[]).filter(e=>B($,[e.name,e.description,C[e.check]])),ne=(Q.data??[]).filter(e=>B(b,[e.description,...J(e)])),re=W();return K(`div`,{className:`workspace-admin flex min-h-0 flex-col gap-4`,children:[G(N,{title:`Guardrails`,icon:h,description:`What every agent, skill and tool run is checked against, and what happens when a check trips.`,actions:H&&D.ready&&K(k,{"aria-label":`Create guardrail`,onClick:()=>void j(`${g.guardrails}/new`),children:[G(p,{}),` Guardrail`]})}),V?D.ready?K(q,{children:[G(P,{label:`Control Tower sections`,current:`guardrails`,tabs:re}),K(`section`,{"aria-label":`Your guardrails`,className:`overflow-x-auto rounded-xl border bg-card`,children:[K(e,{children:[K(`div`,{className:`relative w-72`,children:[G(m,{className:`absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),G(A,{"aria-label":`Search guardrails`,placeholder:`Search guardrails…`,className:`pl-9`,value:$,onChange:e=>ee(e.target.value)})]}),G(t,{ref:o}),G(F,{fetching:U.isFetching||Q.isFetching,onRefresh:()=>{U.refetch(),Q.refetch()}})]}),U.data&&!U.data.contentSafetyReady&&G(`p`,{className:`border-t bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:`Harmful content and Prompt Shields need Azure AI Content Safety, which this deployment has not configured. Blocked terms work now.`}),U.error?G(`p`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:U.error.message}):U.isPending?G(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Loading…`}):K(i,{empty:$?`Nothing matches this search.`:`No guardrails of your own yet. Add one to check what agents, skills and tools take in and give out.`,externalSearch:!0,columnsToolbar:a,className:`w-full text-sm`,"aria-label":`Your guardrails`,children:[r([`Guardrail`,`Check`,`Text checked`,`Action`,`Applies to`,`On`]),G(`tbody`,{className:`divide-y`,children:te.map(e=>G(X,{gridValues:[e.name,C[e.check],w[e.stage],S[e.action],Y(e),e.is_enabled?`On`:`Off`],item:e,tenantId:D.tenantId,writable:H},e.id))})]})]}),K(`section`,{"aria-label":`Platform guardrails`,className:`overflow-x-auto rounded-xl border bg-card`,children:[K(e,{label:`Platform guardrail controls`,children:[K(`div`,{className:`flex items-center gap-2 px-1`,children:[G(f,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),K(`div`,{children:[G(`h2`,{className:`text-sm font-semibold`,children:`Platform guardrails`}),G(`p`,{className:`text-xs text-muted-foreground`,children:`A red lock means always on.`})]})]}),G(I,{label:`Search platform guardrails`,placeholder:`Search platform guardrails…`,className:`w-64 max-w-full`,value:b,onChange:T}),G(t,{ref:l})]}),Q.error?G(`p`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:Q.error.message}):Q.isPending?G(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Loading…`}):K(i,{className:`w-full text-left text-sm`,"aria-label":`Platform guardrails`,empty:b?`Nothing matches this search.`:`No platform guardrails.`,externalSearch:!0,columnsToolbar:c,children:[r([`Guardrail`,`Stage`,`Settings`,`Status`,`On`]),G(`tbody`,{className:`divide-y`,children:ne.map(e=>G(Z,{gridValues:J(e),item:e,tenantId:D.tenantId,writable:H},e.key))})]})]})]}):G(M,{children:`Guardrails belong to one customer.`}):G(`p`,{role:`alert`,children:`Your account does not have permission to view guardrails.`})]})}function J(e){return[e.name,b[e.stage],e.settings.flatMap(({name:e,value:t})=>[e,t]).join(` `),e.active?`Active`:`Off`,e.switched_off?`Off`:`On`]}function Y(e){if(e.everywhere)return`Everywhere`;let t=e.targets.map(e=>`${e.name} (${D[e.kind].toLowerCase()})`);return t.length>2?`${t.slice(0,2).join(`, `)} and ${t.length-2} more`:t.join(`, `)}function X({item:e,tenantId:t,writable:n}){let r=c(),i=o({mutationFn:n=>v.update(e.id,T(e,{is_enabled:n}),`"${e.version}"`,t),onSuccess:n=>{z.success(n.data.is_enabled?`${e.name} is on. The next runs are checked.`:`${e.name} is off.`),r.invalidateQueries({queryKey:y(t)})},onError:t=>z.error(`${e.name}: ${t.message}`)});return K(a,{children:[K(`td`,{className:U,children:[G(l,{to:`${g.guardrails}/${e.id}`,className:`font-semibold text-primary hover:underline`,children:e.name}),e.description&&G(`div`,{className:`text-xs text-muted-foreground`,children:e.description})]}),G(`td`,{className:V(U,`whitespace-nowrap`),children:C[e.check]}),G(`td`,{className:V(U,`whitespace-nowrap`),children:w[e.stage]}),G(`td`,{className:U,children:G(H,{tone:e.action===`block`?`bad`:`warn`,children:S[e.action]})}),G(`td`,{className:V(U,`text-xs`),children:Y(e)}),G(`td`,{className:U,"data-grid-value":e.is_enabled?`Enabled`:`Disabled`,children:G(j,{"aria-label":`${e.name} on`,checked:e.is_enabled,disabled:!n||i.isPending,onCheckedChange:e=>i.mutate(e)})})]})}function Z({item:e,tenantId:t,writable:n}){let r=c(),i=o({mutationFn:n=>E(e.key,n,t),onSuccess:n=>{z.success(n.active?`${e.name} is on. The next runs are checked.`:`${e.name} is off for this customer.`),r.invalidateQueries({queryKey:x(t)})},onError:t=>z.error(`${e.name}: ${t.message}`)});return K(a,{children:[K(`td`,{className:U,children:[K(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[e.name,e.locked&&G(f,{className:`size-3.5 text-destructive`,"aria-label":`Always on: customers cannot turn it off`})]}),G(`div`,{className:`text-xs text-muted-foreground`,children:e.description})]}),G(`td`,{className:V(U,`whitespace-nowrap`),children:b[e.stage]}),G(`td`,{className:U,children:G(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs`,children:e.settings.map(e=>K(`div`,{className:`contents`,children:[G(`dt`,{className:`text-muted-foreground`,children:e.name}),G(`dd`,{children:e.value})]},e.name))})}),K(`td`,{className:U,children:[G(H,{tone:e.active?`good`:`plain`,children:e.active?`Active`:`Off`}),e.switched_at&&e.switched_by&&G(`div`,{className:`mt-1 text-[11px] whitespace-nowrap text-muted-foreground`,children:`Switched by ${e.switched_by} · ${R(e.switched_at)}`})]}),G(`td`,{className:U,children:e.locked?G(f,{className:`size-4 text-destructive`,"aria-label":`${e.name} is always on`}):G(j,{"aria-label":`${e.name} on`,checked:!e.switched_off,disabled:!n||i.isPending,onCheckedChange:e=>i.mutate(e)})})]})}
|
|
@@ -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}from"react-router-dom";import{Eye as o,EyeOff as s,Save as c,Zap as ee}from"lucide-react";import{paths as l}from"@/app/paths";import{llmProviders as u,llmProvidersKey as d,vendorLabels as f}from"@/shared/api/llm-providers";import{useSession as p}from"@/shared/auth/session-context";import{Button as m}from"@/shared/components/ui/button";import{Input as h}from"@/shared/components/ui/input";import{Textarea as g}from"@/shared/components/ui/textarea";import{ChooseTenant as _}from"@/shared/components/workspace/ChooseTenant";import{ModalField as v,modalSelect as y}from"@/shared/components/workspace/Modal";import{useTenantScope as b}from"@/shared/hooks/useTenantScope";import{cn as te}from"@/shared/lib/utils";import{FormSection as x,McpEditorLayout as S,StatusBadge as C}from"../components/McpEditorLayout";import{Problems as w}from"../components/Panels";import{notify as T}from"@/shared/lib/notify";import{jsx as E,Fragment as D,jsxs as O}from"react/jsx-runtime";const k=[`azure_claude`,`azure_openai`],A={anthropic:{name:`Claude Sonnet 4.6`,model:`claude-sonnet-4-6`,url:`https://api.anthropic.com`},azure_claude:{name:`Azure Claude Opus 4.6`,model:`claude-opus-4-6`,url:`https://<resource>.services.ai.azure.com/anthropic/`},openai:{name:`GPT-5`,model:`gpt-5`,url:`https://api.openai.com/v1`},azure_openai:{name:`Azure OpenAI GPT-5-Chat`,model:`gpt-5-chat`,url:`https://<resource>.cognitiveservices.azure.com/`},custom:{name:`Llama 3.1 70B`,model:`llama-3.1-70b`,url:`https://llm.example.com/v1`}},j=e=>({name:e?.name??``,provider:e?.provider??`anthropic`,modelId:e?.model_id??``,baseUrl:e?.base_url??``,apiVersion:e?.api_version??``,auth:e?.auth??`api_key`,apiKey:``,removeKey:!1,description:e?.description??``,temperature:e?e.temperature?.toString()??``:`0.7`,maxTokens:e?.max_tokens?.toString()??``,extra:e&&Object.keys(e.extra_params).length?JSON.stringify(e.extra_params,null,2):``,tags:(e?.tags??[]).join(`, `),isDefault:e?.is_default??!1,isEnabled:e?.is_enabled??!0});function M(e){if(!e.trim())return{};try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}export function LlmProviderPage(){let{id:e=`new`}=a(),{can:t}=p(),r=b(),i=e===`new`,o=n({queryKey:[...d(r.tenantId),e],queryFn:()=>u.get(e,r.tenantId),enabled:r.ready&&!i,retry:!1});return t(`ai.catalog.read`)?r.ready?o.error?E(w,{error:o.error}):!i&&!o.data?E(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading…`}):E(N,{saved:o.data??null,tenantId:r.tenantId,writable:t(`ai.asset.publish`)},o.data?.etag??`new`):E(_,{children:`LLM providers belong to one customer.`}):E(`p`,{role:`alert`,children:`You do not have access to LLM providers.`})}function N({saved:n,tenantId:a,writable:p}){let _=r(),b=i(),[N,P]=e(()=>j(n?.data??null)),[F,I]=e(!1),[L,R]=e(null),z=e=>P(t=>({...t,...e})),B=k.includes(N.provider),V=A[N.provider],H=M(N.extra),U=N.temperature.trim()===``?null:Number(N.temperature),W=N.maxTokens.trim()===``?null:Number(N.maxTokens),G=N.name.trim()!==``&&N.modelId.trim()!==``&&(!(B||N.provider===`custom`)||N.baseUrl.trim()!==``)&&H!==null&&(U===null||U>=0&&U<=2)&&(W===null||Number.isInteger(W)&&W>=1);function K(){let e=B?N.auth:`api_key`;return{name:N.name.trim(),provider:N.provider,model_id:N.modelId.trim(),base_url:N.baseUrl.trim()||null,api_version:B&&N.apiVersion.trim()||null,auth:e,...e===`api_key`&&N.apiKey?{api_key:N.apiKey}:N.removeKey?{api_key:``}:{},description:N.description.trim(),temperature:U,max_tokens:W,extra_params:H??{},tags:N.tags.split(`,`).map(e=>e.trim()).filter(Boolean),is_default:N.isDefault,is_enabled:N.isEnabled}}async function q(){let e=n?await u.update(n.data.id,K(),n.etag,a):await u.create(K(),a);return _.invalidateQueries({queryKey:d(a)}),e.data}let J=e=>{n||b(`${l.llmProviders}/${e.id}`,{replace:!0})},Y=t({mutationFn:q,onSuccess:e=>{T.success(n?`LLM provider saved.`:`LLM provider created.`),J(e)}}),X=t({mutationFn:async()=>{let e=await q();return{stored:e,result:await u.test(e.id,a)}},onSuccess:({stored:e,result:t})=>{R(t),t.success?T.success(`Connection successful in ${t.response_time_ms} ms.`):T.error(`Connection failed: ${t.error??`no answer from the provider`}.`),J(e)},onError:()=>T.error(`The connection test could not run. See the message above.`)}),Z=Y.isPending||X.isPending,Q=n?.data,$=Q?.has_api_key&&!N.removeKey;return E(S,{back:`${l.controlTower}?tab=llms`,backLabel:`LLM providers`,title:Q?N.name||Q.name:`New LLM provider`,subtitle:Q?`${f[Q.provider]} · ${Q.model_id}`:`Configure a language model provider with API credentials.`,badge:Q?O(D,{children:[E(C,{tone:Q.is_enabled?`good`:`plain`,children:Q.is_enabled?`Enabled`:`Disabled`}),Q.is_default&&E(C,{tone:`good`,children:`Default`})]}):E(C,{tone:`plain`,children:`New`}),tab:`details`,onTab:()=>void 0,tabs:[{id:`details`,label:`Details`}],actions:p&&O(D,{children:[O(m,{variant:`outline`,disabled:!G||Z||!N.isEnabled,onClick:()=>X.mutate(),children:[E(ee,{}),` `,X.isPending?`Testing…`:`Test connection`]}),O(m,{type:`submit`,form:`llm-provider-form`,disabled:!G||Z,children:[E(c,{}),` `,Y.isPending?`Saving…`:n?`Save`:`Create`]})]}),children:O(`form`,{id:`llm-provider-form`,"aria-label":`LLM provider details`,className:`max-w-6xl`,onSubmit:e=>{e.preventDefault(),Y.mutate()},children:[(L||Y.error||X.error)&&O(`div`,{className:`mb-4 space-y-2`,children:[L&&E(`output`,{className:te(`block rounded-md px-3 py-2 text-sm`,L.success?`bg-success/10 text-success-foreground`:`bg-destructive/10 text-destructive`),children:L.success?`Connection successful · ${L.response_time_ms} ms · “${L.response_preview}”`:`Connection failed · ${L.error}`}),E(w,{error:Y.error??X.error})]}),O(`fieldset`,{disabled:!p,className:`min-w-0`,children:[O(x,{title:`General`,description:`How the provider is named and whether agents use it.`,children:[E(v,{label:`Name *`,htmlFor:`llm-name`,children:E(h,{id:`llm-name`,required:!0,maxLength:255,placeholder:V.name,value:N.name,onChange:e=>z({name:e.target.value})})}),O(`div`,{className:`flex items-end gap-6 pb-2`,children:[O(`label`,{className:`flex items-center gap-2 text-sm`,children:[E(`input`,{type:`checkbox`,checked:N.isDefault,onChange:e=>z({isDefault:e.target.checked})}),`Set as default`]}),O(`label`,{className:`flex items-center gap-2 text-sm`,children:[E(`input`,{type:`checkbox`,checked:N.isEnabled,onChange:e=>z({isEnabled:e.target.checked})}),`Enabled`]})]}),E(v,{label:`Description`,htmlFor:`llm-description`,wide:!0,children:E(g,{id:`llm-description`,rows:2,maxLength:2e3,placeholder:`Brief description of this provider`,value:N.description,onChange:e=>z({description:e.target.value})})}),E(v,{label:`Tags (comma-separated)`,htmlFor:`llm-tags`,wide:!0,children:E(h,{id:`llm-tags`,placeholder:`production, vision, fast`,value:N.tags,onChange:e=>z({tags:e.target.value})})})]}),O(x,{title:`Model`,description:`Who serves the model and where it is reached.`,children:[E(v,{label:`Provider *`,htmlFor:`llm-provider`,children:E(`select`,{id:`llm-provider`,className:y,value:N.provider,onChange:e=>z({provider:e.target.value}),children:Object.entries(f).map(([e,t])=>E(`option`,{value:e,children:t},e))})}),E(v,{label:`Model ID *`,htmlFor:`llm-model`,children:E(h,{id:`llm-model`,required:!0,maxLength:200,placeholder:V.model,value:N.modelId,onChange:e=>z({modelId:e.target.value})})}),E(v,{label:B||N.provider===`custom`?`Base URL *`:`Base URL (optional)`,htmlFor:`llm-url`,wide:!B,children:E(h,{id:`llm-url`,maxLength:500,placeholder:V.url,value:N.baseUrl,onChange:e=>z({baseUrl:e.target.value})})}),B&&E(v,{label:`API version (Azure)`,htmlFor:`llm-api-version`,children:E(h,{id:`llm-api-version`,maxLength:50,placeholder:`2024-02-15-preview`,value:N.apiVersion,onChange:e=>z({apiVersion:e.target.value})})})]}),O(x,{title:`Authentication`,description:`The key is encrypted and never shown again; only its last four characters.`,children:[B&&E(v,{label:`Sign in with`,htmlFor:`llm-auth`,children:O(`select`,{id:`llm-auth`,className:y,value:N.auth,onChange:e=>z({auth:e.target.value}),children:[E(`option`,{value:`api_key`,children:`API key`}),E(`option`,{value:`azure_identity`,children:`Platform Azure identity (no key)`})]})}),(!B||N.auth===`api_key`)&&E(v,{label:`API key`,htmlFor:`llm-key`,wide:!B,hint:$?O(D,{children:[`Stored: `,Q?.api_key_masked,`. Type a new key to replace it, or`,` `,E(`button`,{type:`button`,className:`text-destructive underline`,onClick:()=>z({removeKey:!0,apiKey:``}),children:`remove it`}),`.`]}):N.removeKey?`The stored key is removed when you save.`:void 0,children:O(`div`,{className:`flex gap-2`,children:[E(h,{id:`llm-key`,type:F?`text`:`password`,autoComplete:`new-password`,placeholder:$?Q?.api_key_masked??``:`Paste API key here`,value:N.apiKey,onChange:e=>z({apiKey:e.target.value,removeKey:!1})}),E(m,{type:`button`,variant:`outline`,size:`icon`,"aria-label":F?`Hide API key`:`Show API key`,onClick:()=>I(e=>!e),children:E(F?s:o,{})})]})})]}),O(x,{title:`Parameters`,description:`Defaults sent with every call. Leave empty to use the model's own.`,children:[E(v,{label:`Temperature`,htmlFor:`llm-temperature`,hint:`0 to 2.`,children:E(h,{id:`llm-temperature`,type:`number`,min:0,max:2,step:.1,value:N.temperature,onChange:e=>z({temperature:e.target.value})})}),E(v,{label:`Max tokens`,htmlFor:`llm-max-tokens`,children:E(h,{id:`llm-max-tokens`,type:`number`,min:1,value:N.maxTokens,onChange:e=>z({maxTokens:e.target.value})})}),E(v,{label:`Extra parameters (JSON)`,htmlFor:`llm-extra`,wide:!0,hint:H===null?E(`span`,{className:`text-destructive`,children:`Must be a JSON object.`}):`For example {"top_p": 0.9}.`,children:E(g,{id:`llm-extra`,rows:3,className:`font-mono text-xs`,placeholder:`{"top_p": 0.9}`,value:N.extra,onChange:e=>z({extra:e.target.value})})})]})]})]})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mcpHeadings as e}from"../components/mcp-headings";import{DataTable as t,DataTableRow as n}from"@/shared/components/workspace/DataTable";import{useState as r}from"react";import{useMutation as i,useQuery as a,useQueryClient as o}from"@tanstack/react-query";import{Link as s,useNavigate as c,useSearchParams as l}from"react-router-dom";import{KeyRound as u,Plus as d,Trash2 as f,Zap as p}from"lucide-react";import{paths as m}from"@/app/paths";import{llmProviders as h,llmProvidersKey as g,vendorLabels as _}from"@/shared/api/llm-providers";import{useSession as v}from"@/shared/auth/session-context";import{Button as y}from"@/shared/components/ui/button";import{ChooseTenant as b}from"@/shared/components/workspace/ChooseTenant";import{ConfirmButton as x}from"@/shared/components/workspace/ConfirmButton";import{ControlHeader as S}from"@/shared/components/workspace/ControlHeader";import{GridHeader as C,GridHeaderSlot as w}from"@/shared/components/workspace/GridHeader";import{PageTabs as T}from"@/shared/components/workspace/PageTabs";import{RefreshButton as E}from"@/shared/components/workspace/RefreshButton";import{SearchInput as D}from"@/shared/components/workspace/SearchInput";import{useTenantScope as O}from"@/shared/hooks/useTenantScope";import{cn as k}from"@/shared/lib/utils";import{Badge as A,IconAction as j,cell as M}from"../components/McpTables";import{useControlTowerTabs as N}from"../hooks/useControlTowerTabs";import{matchesSearch as P}from"@/shared/lib/search";import{notify as F}from"@/shared/lib/notify";import{jsx as I,jsxs as L,Fragment as R}from"react/jsx-runtime";const z={anthropic:`bg-primary/10 text-primary`,azure_claude:`bg-primary/10 text-primary`,openai:`bg-success/15 text-success-foreground`,azure_openai:`bg-success/15 text-success-foreground`,custom:`bg-muted text-muted-foreground`};export function LlmProvidersPage(){let{can:n}=v(),i=O(),o=c(),[s,f]=l(),[p,x]=r(null),k=n(`ai.catalog.read`),A=n(`ai.asset.publish`),j=a({queryKey:g(i.tenantId),queryFn:({signal:e})=>h.list(i.tenantId,e),enabled:k&&i.ready,retry:!1}),M=N(),F=s.get(`q`)??``,z=e=>f(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0}),V=(j.data??[]).filter(e=>P(F,[e.name,e.model_id,e.description,...e.tags]));return L(`div`,{className:`workspace-admin flex min-h-0 flex-col gap-4`,children:[I(S,{title:`LLM providers`,icon:u,description:`Configure and manage LLM provider connections and API keys.`,actions:A&&i.ready&&L(y,{onClick:()=>void o(`${m.llmProviders}/new`),children:[I(d,{}),` Provider`]})}),k?i.ready?L(R,{children:[I(T,{label:`Control Tower sections`,current:`llms`,tabs:M}),L(`section`,{"aria-label":`LLM providers`,className:`overflow-x-auto rounded-xl border bg-card`,children:[L(C,{children:[I(D,{label:`Search by name, model ID`,placeholder:`Search by name, model ID…`,className:`w-64 max-w-full`,value:F,onChange:z}),I(w,{ref:x}),I(`div`,{className:`ml-auto`,children:I(E,{fetching:j.isFetching,onRefresh:()=>void j.refetch()})})]}),j.error?I(`p`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:j.error.message}):j.isPending?I(`p`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`Loading…`}):L(t,{empty:F?`Nothing matches this search.`:`No LLM providers yet. Agents use the platform model until one is added.`,className:`w-full text-left text-sm`,"aria-label":`LLM providers`,externalSearch:!0,columnsToolbar:p,children:[e([`Name`,`Provider`,`Model ID`,`Default`,`Enabled`,`Actions`]),I(`tbody`,{className:`divide-y`,children:V.map(e=>I(B,{gridValues:[e.name,_[e.provider],e.model_id,e.is_default?`Default`:``,e.is_enabled?`Enabled`:`Disabled`],item:e,tenantId:i.tenantId,writable:A},e.id))})]})]})]}):I(b,{children:`LLM providers belong to one customer.`}):I(`p`,{role:`alert`,children:`Your account does not have permission to view LLM providers.`})]})}function B({item:e,tenantId:t,writable:a}){let c=o(),[l,u]=r(null),d=i({mutationFn:()=>h.test(e.id,t),onSuccess:t=>{u(t.success?{ok:!0,text:`Connected · ${t.response_time_ms} ms`}:{ok:!1,text:t.error}),t.success?F.success(`${e.name}: connection successful in ${t.response_time_ms} ms.`):F.error(`${e.name}: connection failed. ${t.error??``}`.trim())},onError:t=>{u({ok:!1,text:t.message}),F.error(`${e.name}: the connection test could not run. ${t.message}`)}}),v=i({mutationFn:()=>h.remove(e.id,`"${e.version}"`,t),onSuccess:()=>{F.success(`LLM provider deleted.`),c.invalidateQueries({queryKey:g(t)})}}),y=`${m.llmProviders}/${e.id}`;return L(n,{className:`hover:bg-muted/30`,children:[L(`td`,{className:M,children:[I(s,{to:y,className:`font-semibold text-primary hover:underline`,children:e.name}),l&&I(`output`,{className:k(`block text-xs`,l.ok?`text-success-foreground`:`text-destructive`),children:l.text})]}),I(`td`,{className:M,children:I(`span`,{className:k(`inline-flex rounded-badge px-2.5 py-1 text-xs font-medium`,z[e.provider]),children:_[e.provider]})}),I(`td`,{className:M,children:I(`code`,{className:`text-[13px]`,children:e.model_id})}),I(`td`,{className:M,children:e.is_default&&I(A,{tone:`good`,children:`Default`})}),I(`td`,{className:M,children:I(A,{tone:e.is_enabled?`good`:`plain`,children:e.is_enabled?`Enabled`:`Disabled`})}),L(`td`,{className:k(M,`text-right whitespace-nowrap`),children:[a&&I(j,{label:`Test ${e.name}`,busy:d.isPending,disabled:!e.is_enabled,onClick:()=>d.mutate(),children:I(p,{})}),a&&I(x,{destructive:!0,title:`Delete ${e.name}?`,detail:`Its key is forgotten. Agents that chose it fail until they pick another.`,action:`Delete`,pending:v.isPending,error:v.error?.message,onConfirm:()=>v.mutate(),className:`size-7 border-0 bg-transparent p-0 hover:bg-destructive/10`,children:I(f,{"aria-label":`Delete ${e.name}`})})]})]})}
|