mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-26 02:07:28 +08:00
57a505f837
* chore: Rename service & container names for consistency in Docker configs (#6710) * chore: Rename container names for consistency in Docker configs * chore: Rename service names for consistency in Docker configs chore: Update OpenSandbox versions and image repositories (#6709) * chore: Update OpenSandbox versions and image repositories * yml version * images * init yml * port --------- Co-authored-by: archer <545436317@qq.com> refactor(chat): optimize sandbox status logic and decouple UI/Status hooks (#6713) * refactor(chat): optimize sandbox status logic and decouple UI/Status hooks * fix: useRef, rename onClose to afterClose Update .env.template (#6720) aiproxy默认的请求地址改成http协议 feat: comprehensive agent skill management and sandbox infrastructure optimization - Skill System: Implemented a full skill management module including CRUD operations, folder organization, AI-driven skill generation, and versioning (switch/update). - Sandbox Infrastructure: Introduced 'volume-manager' for PVC and Docker volume lifecycle management, replacing the MinIO sync-agent for better data persistence. - Workflow Integration: Enhanced the Agent node to support skill selection and configuration, including new UI components and data normalization. - Permission Management: Added granular permission controls for skills, supporting collaborators, owner transfers, and permission inheritance. - UI/UX: Added a dedicated Skill dashboard, sandbox debug interface (terminal, logs, and iframe proxy), and comprehensive i18n support. - Maintenance: Migrated Docker services to named volumes, optimized sandbox instance limits, and improved error handling for sandbox providers. Co-authored-by: chanzhi82020 <chenzhi@sangfor.com.cn> Co-authored-by: lavine77 Signed-off-by: Jon <ljp@sangfor.com.cn> feat: hide skill prettier * perf: hide skill code * fix: ts * lock * perf: tool code * fix: ts * lock * fix: test * fix: openapi * lock * fix: test * null model --------- Co-authored-by: archer <545436317@qq.com>
88 lines
3.1 KiB
TypeScript
88 lines
3.1 KiB
TypeScript
import { type Monaco } from '@monaco-editor/react';
|
|
import { useCallback } from 'react';
|
|
import { type CompletionModel, type CompletionPosition } from './type';
|
|
|
|
let monacoInstance: Monaco | null = null;
|
|
|
|
const useSystemHelperCompletion = () => {
|
|
return useCallback((monaco: Monaco) => {
|
|
if (monacoInstance === monaco) return;
|
|
monacoInstance = monaco;
|
|
|
|
const buildSuggestions = (
|
|
monaco: Monaco,
|
|
model: CompletionModel,
|
|
position: CompletionPosition,
|
|
memberSnippet: string
|
|
) => {
|
|
const lineContent = model.getLineContent(position.lineNumber);
|
|
const textBeforeCursor = lineContent.slice(0, position.column - 1);
|
|
|
|
// After "SystemHelper." — suggest members
|
|
if (textBeforeCursor.endsWith('SystemHelper.')) {
|
|
return {
|
|
suggestions: [
|
|
{
|
|
label: 'httpRequest',
|
|
kind: monaco.languages.CompletionItemKind.Method,
|
|
insertText: memberSnippet,
|
|
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
documentation: 'Send an HTTP request. Returns { status, data }.',
|
|
range: {
|
|
startLineNumber: position.lineNumber,
|
|
endLineNumber: position.lineNumber,
|
|
startColumn: position.column,
|
|
endColumn: position.column
|
|
}
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
// Suggest "SystemHelper" as a global identifier
|
|
const wordInfo = model.getWordUntilPosition(position);
|
|
if (wordInfo.word.length > 0 && 'SystemHelper'.startsWith(wordInfo.word)) {
|
|
return {
|
|
suggestions: [
|
|
{
|
|
label: 'SystemHelper',
|
|
kind: monaco.languages.CompletionItemKind.Module,
|
|
insertText: 'SystemHelper',
|
|
documentation: 'Built-in helper utilities provided by FastGPT sandbox.',
|
|
range: {
|
|
startLineNumber: position.lineNumber,
|
|
endLineNumber: position.lineNumber,
|
|
startColumn: wordInfo.startColumn,
|
|
endColumn: wordInfo.endColumn
|
|
}
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
return { suggestions: [] };
|
|
};
|
|
|
|
// JS/TS completion provider
|
|
const jsSnippet =
|
|
"httpRequest(${1:url}, {\n\tmethod: '${2:GET}',\n\theaders: {},\n\tbody: null,\n\ttimeout: 60\n})";
|
|
for (const lang of ['javascript', 'typescript'] as const) {
|
|
monaco.languages.registerCompletionItemProvider(lang, {
|
|
triggerCharacters: ['.'],
|
|
provideCompletionItems: (model: CompletionModel, position: CompletionPosition) =>
|
|
buildSuggestions(monaco, model, position, jsSnippet)
|
|
});
|
|
}
|
|
|
|
// Python completion provider
|
|
const pySnippet = 'httpRequest(${1:url}, method="${2:GET}", headers={}, timeout=${3:60})';
|
|
monaco.languages.registerCompletionItemProvider('python', {
|
|
triggerCharacters: ['.'],
|
|
provideCompletionItems: (model: CompletionModel, position: CompletionPosition) =>
|
|
buildSuggestions(monaco, model, position, pySnippet)
|
|
});
|
|
}, []);
|
|
};
|
|
|
|
export default useSystemHelperCompletion;
|