@nextclaw/ui 0.12.19 → 0.12.20-beta.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/CHANGELOG.md +39 -0
- package/dist/assets/api-BcqDx0tm.js +15 -0
- package/dist/assets/app-manager-provider-DVYBjif-.js +1 -0
- package/dist/assets/app-navigation.config-CMoWvFEI.js +1 -0
- package/dist/assets/{book-open-CVEuA0y5.js → book-open-DgLqYpNY.js} +1 -1
- package/dist/assets/{channels-list-page-BqhqaBf1.js → channels-list-page-CsoI4OJm.js} +2 -2
- package/dist/assets/{chat-D4KecKjB.js → chat-CA3aRmhx.js} +13 -12
- package/dist/assets/chat-page-gdSN6Pr6.js +1 -0
- package/dist/assets/chunk-JZWAC4HX-u4uYphxM.js +3 -0
- package/dist/assets/{config-split-page-BGjVACdO.js → config-split-page-BMRGuCJQ.js} +1 -1
- package/dist/assets/{createLucideIcon-PPrXCGK8.js → createLucideIcon-BZkY6emz.js} +1 -1
- package/dist/assets/desktop-update-config-CD6-2PfI.js +1 -0
- package/dist/assets/{dialog-CTCX7oLf.js → dialog-csshWetU.js} +1 -1
- package/dist/assets/{dist-FL5e8mMi.js → dist-Bl94Ahwx.js} +1 -1
- package/dist/assets/{doc-browser-C02neCIE.js → doc-browser-BUlCkZo2.js} +1 -1
- package/dist/assets/doc-browser-CzCV73NJ.js +1 -0
- package/dist/assets/doc-browser-Doh2541x.js +1 -0
- package/dist/assets/{doc-browser-context-C-WPOji4.js → doc-browser-context-DfLHAWbG.js} +1 -1
- package/dist/assets/{es2015-BNy4R8AC.js → es2015-JCM5-KtW.js} +1 -1
- package/dist/assets/{external-link-BNtqJE01.js → external-link-Sw3ah_JD.js} +1 -1
- package/dist/assets/{folder-QyJHVUNz.js → folder-D7-VTnkz.js} +1 -1
- package/dist/assets/{hash-BGYUE-zr.js → hash-zajSTDXZ.js} +1 -1
- package/dist/assets/i18n-C5Mibli1.js +1 -0
- package/dist/assets/index-BTDFuKka.js +2 -0
- package/dist/assets/index-CUmk8xFK.css +1 -0
- package/dist/assets/{key-round-DenCfA2w.js → key-round-CnI1mc9F.js} +1 -1
- package/dist/assets/loader-circle-B5i8oMMY.js +1 -0
- package/dist/assets/{logo-badge-CKAxvQFc.js → logo-badge-BQgKnVtz.js} +1 -1
- package/dist/assets/{logos-CqXnaJIm.js → logos-CqVm0q0W.js} +1 -1
- package/dist/assets/marketplace-page-DJGDpTAo.js +1 -0
- package/dist/assets/{marketplace-page-XnDa2ulT.js → marketplace-page-DxlxHCFm.js} +2 -2
- package/dist/assets/mcp-marketplace-page-5UjYRWOR.js +40 -0
- package/dist/assets/mcp-marketplace-page-C1XaHZZO.js +1 -0
- package/dist/assets/message-square-D6Z4NwpG.js +1 -0
- package/dist/assets/{model-config-ByeL6Toe.js → model-config-PccJ9XyH.js} +1 -1
- package/dist/assets/{notice-card-D00-02yg.js → notice-card-CCgk6FvF.js} +1 -1
- package/dist/assets/play-D8WJLnJe.js +1 -0
- package/dist/assets/plus-Di0KAkiO.js +1 -0
- package/dist/assets/{popover-AmJkxio3.js → popover-YAsxDBhY.js} +1 -1
- package/dist/assets/{provider-scoped-model-input-CfFJsJp-.js → provider-scoped-model-input-CzpF7cug.js} +1 -1
- package/dist/assets/{providers-list-HMQzW2WV.js → providers-list-8qDMER8o.js} +1 -1
- package/dist/assets/{refresh-ccw-B-dhb3yS.js → refresh-ccw-Bii4w8aB.js} +1 -1
- package/dist/assets/refresh-cw-BxojR62w.js +1 -0
- package/dist/assets/remote-D4TtLPAp.js +1 -0
- package/dist/assets/{rotate-cw-BWqAG3Fv.js → rotate-cw-1Xqa7LZ8.js} +1 -1
- package/dist/assets/runtime-config-page-D-4c5H5z.js +1 -0
- package/dist/assets/{save-DpdkGieJ.js → save--BVI5wZX.js} +1 -1
- package/dist/assets/search-config-D3a65l3r.js +1 -0
- package/dist/assets/{search-CQUdr7j_.js → search-vChioOoe.js} +1 -1
- package/dist/assets/{secrets-config-YCsGd1am.js → secrets-config-CoMlR_7i.js} +2 -2
- package/dist/assets/{select-DVUtSFHZ.js → select-DIZrwsKU.js} +1 -1
- package/dist/assets/{sessions-config-page-BKN-XdKr.js → sessions-config-page-Cc0TJStn.js} +2 -2
- package/dist/assets/{setting-row-Cb5-lFs-.js → setting-row-DiQyrE81.js} +1 -1
- package/dist/assets/{settings-DgtZZlnF.js → settings-CiRChctQ.js} +1 -1
- package/dist/assets/skeleton-CFQRIUzt.js +1 -0
- package/dist/assets/{sparkles-DNSCyDhL.js → sparkles-D1ZKWdm4.js} +1 -1
- package/dist/assets/{status-dot-X_j51OfA.js → status-dot-Dv_hiUVa.js} +1 -1
- package/dist/assets/{tabs-custom-CcWmekaF.js → tabs-custom-CsACkVji.js} +1 -1
- package/dist/assets/{tag-chip-fdbK2wE6.js → tag-chip-C3wDBe_-.js} +1 -1
- package/dist/assets/theme-provider-aOmrJ9J6.js +1 -0
- package/dist/assets/{tooltip-BkZCQcKw.js → tooltip-Dq5Xehpk.js} +1 -1
- package/dist/assets/{trash-2-CqciSCsg.js → trash-2-rY9ZteZX.js} +1 -1
- package/dist/assets/use-config-BQJjq1mP.js +1 -0
- package/dist/assets/{use-confirm-dialog-DSrb9205.js → use-confirm-dialog-DBoV5n5P.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-DmowtyTI.js → use-infinite-scroll-loader-JAicqVC5.js} +1 -1
- package/dist/assets/{use-viewport-layout-CaALCA51.js → use-viewport-layout-BX3XqzJ4.js} +1 -1
- package/dist/assets/x-DpTzXQcX.js +1 -0
- package/dist/index.html +40 -39
- package/package.json +9 -6
- package/src/app/hooks/use-realtime-query-bridge.ts +5 -5
- package/src/app/index.tsx +7 -1
- package/src/features/channels/components/config/channel-form.tsx +3 -3
- package/src/features/channels/components/config/weixin-channel-auth-section.tsx +1 -1
- package/src/features/chat/components/conversation/chat-conversation-panel.tsx +1 -0
- package/src/features/chat/components/conversation/chat-input-bar.container.tsx +9 -4
- package/src/features/chat/components/conversation/chat-message-list.container.test.tsx +64 -6
- package/src/features/chat/components/conversation/chat-message-list.container.tsx +185 -17
- package/src/features/chat/components/session/session-context-icon.tsx +1 -4
- package/src/features/chat/hooks/use-ncp-chat-derived-state.ts +3 -1
- package/src/features/chat/hooks/use-ncp-chat-page-data.ts +7 -6
- package/src/features/chat/hooks/use-ncp-session-conversation.test.tsx +74 -2
- package/src/features/chat/hooks/use-ncp-session-conversation.ts +32 -10
- package/src/features/chat/hooks/use-selected-session-context-window-indicator.ts +20 -0
- package/src/features/chat/managers/ncp-chat-input.manager.test.ts +25 -0
- package/src/features/chat/managers/ncp-chat-input.manager.ts +5 -1
- package/src/features/chat/pages/ncp-chat-page.test.ts +22 -8
- package/src/features/chat/pages/ncp-chat-page.tsx +15 -11
- package/src/features/chat/stores/chat-thread.store.ts +8 -2
- package/src/features/chat/utils/chat-context-window-indicator.utils.ts +50 -0
- package/src/features/chat/utils/chat-runtime.utils.ts +1 -1
- package/src/features/chat/utils/chat-session-preference-governance.utils.test.tsx +114 -0
- package/src/features/chat/utils/chat-session-preference-governance.utils.ts +30 -36
- package/src/features/chat/utils/ncp-chat-runtime-availability.utils.test.ts +165 -0
- package/src/features/chat/utils/ncp-chat-runtime-availability.utils.ts +50 -0
- package/src/features/chat/utils/ncp-session-adapter.utils.test.ts +27 -0
- package/src/features/chat/utils/ncp-session-adapter.utils.ts +6 -4
- package/src/features/chat/utils/ncp-session-context-metadata.utils.ts +121 -0
- package/src/features/chat/utils/session-context.utils.ts +1 -2
- package/src/features/system-status/components/config/runtime-config-editor.tsx +6 -0
- package/src/features/system-status/components/config/runtime-settings-card.tsx +12 -0
- package/src/features/system-status/components/desktop-update-config.test.tsx +17 -7
- package/src/features/system-status/components/desktop-update-config.tsx +75 -30
- package/src/features/system-status/hooks/use-system-status.ts +0 -11
- package/src/features/system-status/index.ts +4 -1
- package/src/features/system-status/managers/runtime-update.manager.ts +330 -0
- package/src/features/system-status/managers/system-status.manager.test.ts +0 -25
- package/src/features/system-status/managers/system-status.manager.ts +1 -30
- package/src/features/system-status/stores/runtime-update.store.ts +24 -0
- package/src/features/system-status/types/system-status.types.ts +0 -2
- package/src/features/system-status/utils/runtime-config-agent.utils.ts +6 -1
- package/src/features/system-status/utils/system-status.utils.test.ts +1 -85
- package/src/features/system-status/utils/system-status.utils.ts +1 -23
- package/src/platforms/desktop/managers/desktop-update.manager.ts +6 -0
- package/src/platforms/desktop/types/desktop-update.types.ts +21 -19
- package/src/shared/components/common/brand-header.test.tsx +142 -0
- package/src/shared/components/common/brand-header.tsx +93 -0
- package/src/shared/components/cron-config.tsx +1 -1
- package/src/shared/components/doc-browser/doc-browser-context.test.tsx +1 -1
- package/src/shared/components/doc-browser/doc-browser.tsx +1 -1
- package/src/shared/components/search-config.tsx +3 -3
- package/src/shared/lib/api/README.md +3 -0
- package/src/shared/lib/api/index.ts +13 -11
- package/src/shared/lib/api/ncp-session.test.ts +17 -18
- package/src/shared/lib/api/ncp-session.types.ts +92 -0
- package/src/shared/lib/api/raw-client.utils.ts +3 -126
- package/src/shared/lib/api/services/agents.service.ts +18 -0
- package/src/shared/lib/api/services/channel-auth.service.ts +21 -0
- package/src/shared/lib/api/{client.ts → services/client.service.ts} +45 -1
- package/src/shared/lib/api/services/config.service.ts +171 -0
- package/src/shared/lib/api/services/marketplace.service.ts +66 -0
- package/src/shared/lib/api/services/mcp-marketplace.service.ts +70 -0
- package/src/shared/lib/api/services/ncp-attachments.service.ts +14 -0
- package/src/shared/lib/api/services/ncp-session.service.ts +39 -0
- package/src/shared/lib/api/services/remote.service.ts +50 -0
- package/src/shared/lib/api/services/runtime-control.service.ts +18 -0
- package/src/shared/lib/api/services/runtime-update.service.ts +26 -0
- package/src/shared/lib/api/services/server-path.service.ts +16 -0
- package/src/shared/lib/api/types.ts +9 -74
- package/src/shared/lib/i18n/{chat.ts → chat-labels.utils.ts} +13 -1
- package/src/shared/lib/i18n/desktop-update-labels.utils.ts +65 -0
- package/src/shared/lib/i18n/index.ts +4 -5
- package/src/shared/lib/i18n/runtime/i18n-language-owner.ts +5 -5
- package/src/shared/lib/transport/index.ts +1 -0
- package/src/shared/lib/transport/local-transport.service.ts +24 -4
- package/src/shared/lib/transport/remote-transport.service.ts +2 -2
- package/src/shared/lib/transport/request-raw-api-response.utils.ts +133 -0
- package/src/shared/lib/transport/transport.types.ts +8 -2
- package/src/shared/lib/ui-document-title/index.ts +1 -1
- package/tsconfig.json +1 -0
- package/dist/assets/api-BurjmW4A.js +0 -15
- package/dist/assets/app-manager-provider-DhxUmyTv.js +0 -1
- package/dist/assets/app-navigation.config-Bpd16Pem.js +0 -1
- package/dist/assets/chat-page-Cc7n80lW.js +0 -1
- package/dist/assets/chunk-JZWAC4HX-24FLdHl7.js +0 -3
- package/dist/assets/desktop-update-config-fMLlSStv.js +0 -1
- package/dist/assets/doc-browser-COj7x090.js +0 -1
- package/dist/assets/doc-browser-fyn7eDTp.js +0 -1
- package/dist/assets/i18n-CM4y8Mw9.js +0 -1
- package/dist/assets/index-CtVSzMPM.js +0 -2
- package/dist/assets/index-N3hjuljD.css +0 -1
- package/dist/assets/loader-circle-R23uEPkM.js +0 -1
- package/dist/assets/marketplace-page-mF-M5mku.js +0 -1
- package/dist/assets/mcp-marketplace-page-BArKWcRZ.js +0 -40
- package/dist/assets/mcp-marketplace-page-DBUcIIHJ.js +0 -1
- package/dist/assets/message-square-Dm34zD6k.js +0 -1
- package/dist/assets/play-ul4L6MWm.js +0 -1
- package/dist/assets/plus-D14303DH.js +0 -1
- package/dist/assets/remote-B4ELSd3u.js +0 -1
- package/dist/assets/runtime-config-page-N4FP6H0M.js +0 -1
- package/dist/assets/search-config-B62TY-z2.js +0 -1
- package/dist/assets/skeleton-BCPi52jT.js +0 -1
- package/dist/assets/theme-provider-WTWq_jYq.js +0 -1
- package/dist/assets/use-config-CyvhbRhf.js +0 -1
- package/dist/assets/x-tYcSDsrY.js +0 -1
- package/src/shared/lib/api/agents.ts +0 -34
- package/src/shared/lib/api/channel-auth.ts +0 -35
- package/src/shared/lib/api/config.ts +0 -362
- package/src/shared/lib/api/marketplace.ts +0 -156
- package/src/shared/lib/api/mcp-marketplace.ts +0 -138
- package/src/shared/lib/api/ncp-attachments.ts +0 -41
- package/src/shared/lib/api/ncp-session.ts +0 -78
- package/src/shared/lib/api/remote.ts +0 -86
- package/src/shared/lib/api/runtime-control.ts +0 -34
- package/src/shared/lib/api/server-path.ts +0 -46
- /package/dist/assets/{config-hints-CPNzbMEp.js → config-hints-MogHYQ8G.js} +0 -0
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import { api } from './client';
|
|
2
|
-
import type {
|
|
3
|
-
AuthEnabledUpdateRequest,
|
|
4
|
-
AuthLoginRequest,
|
|
5
|
-
AuthPasswordUpdateRequest,
|
|
6
|
-
AuthSetupRequest,
|
|
7
|
-
AuthStatusView,
|
|
8
|
-
AppMetaView,
|
|
9
|
-
BootstrapStatusView,
|
|
10
|
-
ConfigView,
|
|
11
|
-
ConfigMetaView,
|
|
12
|
-
ConfigSchemaResponse,
|
|
13
|
-
ProviderConfigView,
|
|
14
|
-
ChannelConfigUpdate,
|
|
15
|
-
ProviderConfigUpdate,
|
|
16
|
-
ProviderConnectionTestRequest,
|
|
17
|
-
ProviderConnectionTestResult,
|
|
18
|
-
ProviderAuthStartRequest,
|
|
19
|
-
ProviderAuthStartResult,
|
|
20
|
-
ProviderAuthPollRequest,
|
|
21
|
-
ProviderAuthPollResult,
|
|
22
|
-
ProviderAuthImportResult,
|
|
23
|
-
SearchConfigUpdate,
|
|
24
|
-
SearchConfigView,
|
|
25
|
-
ProviderCreateRequest,
|
|
26
|
-
ProviderCreateResult,
|
|
27
|
-
ProviderDeleteResult,
|
|
28
|
-
RuntimeConfigUpdate,
|
|
29
|
-
SecretsConfigUpdate,
|
|
30
|
-
SecretsView,
|
|
31
|
-
ConfigActionExecuteRequest,
|
|
32
|
-
ConfigActionExecuteResult,
|
|
33
|
-
ChatSessionTypesView,
|
|
34
|
-
CronListView,
|
|
35
|
-
CronEnableRequest,
|
|
36
|
-
CronRunRequest,
|
|
37
|
-
CronActionResult
|
|
38
|
-
} from './types';
|
|
39
|
-
|
|
40
|
-
// GET /api/auth/status
|
|
41
|
-
export async function fetchAuthStatus(options: { timeoutMs?: number } = {}): Promise<AuthStatusView> {
|
|
42
|
-
const response = await api.get<AuthStatusView>('/api/auth/status', { timeoutMs: options.timeoutMs ?? 5_000 });
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
throw new Error(response.error.message);
|
|
45
|
-
}
|
|
46
|
-
return response.data;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// POST /api/auth/setup
|
|
50
|
-
export async function setupAuth(data: AuthSetupRequest): Promise<AuthStatusView> {
|
|
51
|
-
const response = await api.post<AuthStatusView>('/api/auth/setup', data);
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw new Error(response.error.message);
|
|
54
|
-
}
|
|
55
|
-
return response.data;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// POST /api/auth/login
|
|
59
|
-
export async function loginAuth(data: AuthLoginRequest): Promise<AuthStatusView> {
|
|
60
|
-
const response = await api.post<AuthStatusView>('/api/auth/login', data);
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
throw new Error(response.error.message);
|
|
63
|
-
}
|
|
64
|
-
return response.data;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// POST /api/auth/logout
|
|
68
|
-
export async function logoutAuth(): Promise<{ success: boolean }> {
|
|
69
|
-
const response = await api.post<{ success: boolean }>('/api/auth/logout', {});
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
throw new Error(response.error.message);
|
|
72
|
-
}
|
|
73
|
-
return response.data;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// PUT /api/auth/password
|
|
77
|
-
export async function updateAuthPassword(data: AuthPasswordUpdateRequest): Promise<AuthStatusView> {
|
|
78
|
-
const response = await api.put<AuthStatusView>('/api/auth/password', data);
|
|
79
|
-
if (!response.ok) {
|
|
80
|
-
throw new Error(response.error.message);
|
|
81
|
-
}
|
|
82
|
-
return response.data;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// PUT /api/auth/enabled
|
|
86
|
-
export async function updateAuthEnabled(data: AuthEnabledUpdateRequest): Promise<AuthStatusView> {
|
|
87
|
-
const response = await api.put<AuthStatusView>('/api/auth/enabled', data);
|
|
88
|
-
if (!response.ok) {
|
|
89
|
-
throw new Error(response.error.message);
|
|
90
|
-
}
|
|
91
|
-
return response.data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// GET /api/app/meta
|
|
95
|
-
export async function fetchAppMeta(): Promise<AppMetaView> {
|
|
96
|
-
const response = await api.get<AppMetaView>('/api/app/meta');
|
|
97
|
-
if (!response.ok) {
|
|
98
|
-
throw new Error(response.error.message);
|
|
99
|
-
}
|
|
100
|
-
return response.data;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// GET /api/runtime/bootstrap-status
|
|
104
|
-
export async function fetchBootstrapStatus(): Promise<BootstrapStatusView> {
|
|
105
|
-
const response = await api.get<BootstrapStatusView>('/api/runtime/bootstrap-status');
|
|
106
|
-
if (!response.ok) {
|
|
107
|
-
throw new Error(response.error.message);
|
|
108
|
-
}
|
|
109
|
-
return response.data;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// GET /api/config
|
|
113
|
-
export async function fetchConfig(): Promise<ConfigView> {
|
|
114
|
-
const response = await api.get<ConfigView>('/api/config');
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
throw new Error(response.error.message);
|
|
117
|
-
}
|
|
118
|
-
return response.data;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// GET /api/config/meta
|
|
122
|
-
export async function fetchConfigMeta(): Promise<ConfigMetaView> {
|
|
123
|
-
const response = await api.get<ConfigMetaView>('/api/config/meta');
|
|
124
|
-
if (!response.ok) {
|
|
125
|
-
throw new Error(response.error.message);
|
|
126
|
-
}
|
|
127
|
-
return response.data;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// GET /api/config/schema
|
|
131
|
-
export async function fetchConfigSchema(): Promise<ConfigSchemaResponse> {
|
|
132
|
-
const response = await api.get<ConfigSchemaResponse>('/api/config/schema');
|
|
133
|
-
if (!response.ok) {
|
|
134
|
-
throw new Error(response.error.message);
|
|
135
|
-
}
|
|
136
|
-
return response.data;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// PUT /api/config/model
|
|
140
|
-
export async function updateModel(data: { model: string; workspace?: string }): Promise<{ model: string; workspace?: string }> {
|
|
141
|
-
const response = await api.put<{ model: string; workspace?: string }>('/api/config/model', data);
|
|
142
|
-
if (!response.ok) {
|
|
143
|
-
throw new Error(response.error.message);
|
|
144
|
-
}
|
|
145
|
-
return response.data;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// PUT /api/config/search
|
|
149
|
-
export async function updateSearch(
|
|
150
|
-
data: SearchConfigUpdate
|
|
151
|
-
): Promise<SearchConfigView> {
|
|
152
|
-
const response = await api.put<SearchConfigView>('/api/config/search', data);
|
|
153
|
-
if (!response.ok) {
|
|
154
|
-
throw new Error(response.error.message);
|
|
155
|
-
}
|
|
156
|
-
return response.data;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// PUT /api/config/providers/:provider
|
|
160
|
-
export async function updateProvider(
|
|
161
|
-
provider: string,
|
|
162
|
-
data: ProviderConfigUpdate
|
|
163
|
-
): Promise<ProviderConfigView> {
|
|
164
|
-
const response = await api.put<ProviderConfigView>(
|
|
165
|
-
`/api/config/providers/${provider}`,
|
|
166
|
-
data
|
|
167
|
-
);
|
|
168
|
-
if (!response.ok) {
|
|
169
|
-
throw new Error(response.error.message);
|
|
170
|
-
}
|
|
171
|
-
return response.data;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// POST /api/config/providers
|
|
175
|
-
export async function createProvider(
|
|
176
|
-
data: ProviderCreateRequest = {}
|
|
177
|
-
): Promise<ProviderCreateResult> {
|
|
178
|
-
const response = await api.post<ProviderCreateResult>(
|
|
179
|
-
'/api/config/providers',
|
|
180
|
-
data
|
|
181
|
-
);
|
|
182
|
-
if (!response.ok) {
|
|
183
|
-
throw new Error(response.error.message);
|
|
184
|
-
}
|
|
185
|
-
return response.data;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// DELETE /api/config/providers/:provider
|
|
189
|
-
export async function deleteProvider(provider: string): Promise<ProviderDeleteResult> {
|
|
190
|
-
const response = await api.delete<ProviderDeleteResult>(
|
|
191
|
-
`/api/config/providers/${provider}`
|
|
192
|
-
);
|
|
193
|
-
if (!response.ok) {
|
|
194
|
-
throw new Error(response.error.message);
|
|
195
|
-
}
|
|
196
|
-
return response.data;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// POST /api/config/providers/:provider/test
|
|
200
|
-
export async function testProviderConnection(
|
|
201
|
-
provider: string,
|
|
202
|
-
data: ProviderConnectionTestRequest
|
|
203
|
-
): Promise<ProviderConnectionTestResult> {
|
|
204
|
-
const response = await api.post<ProviderConnectionTestResult>(
|
|
205
|
-
`/api/config/providers/${provider}/test`,
|
|
206
|
-
data
|
|
207
|
-
);
|
|
208
|
-
if (!response.ok) {
|
|
209
|
-
throw new Error(response.error.message);
|
|
210
|
-
}
|
|
211
|
-
return response.data;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// POST /api/config/providers/:provider/auth/start
|
|
215
|
-
export async function startProviderAuth(
|
|
216
|
-
provider: string,
|
|
217
|
-
data: ProviderAuthStartRequest = {}
|
|
218
|
-
): Promise<ProviderAuthStartResult> {
|
|
219
|
-
const response = await api.post<ProviderAuthStartResult>(
|
|
220
|
-
`/api/config/providers/${provider}/auth/start`,
|
|
221
|
-
data
|
|
222
|
-
);
|
|
223
|
-
if (!response.ok) {
|
|
224
|
-
throw new Error(response.error.message);
|
|
225
|
-
}
|
|
226
|
-
return response.data;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// POST /api/config/providers/:provider/auth/poll
|
|
230
|
-
export async function pollProviderAuth(
|
|
231
|
-
provider: string,
|
|
232
|
-
data: ProviderAuthPollRequest
|
|
233
|
-
): Promise<ProviderAuthPollResult> {
|
|
234
|
-
const response = await api.post<ProviderAuthPollResult>(
|
|
235
|
-
`/api/config/providers/${provider}/auth/poll`,
|
|
236
|
-
data
|
|
237
|
-
);
|
|
238
|
-
if (!response.ok) {
|
|
239
|
-
throw new Error(response.error.message);
|
|
240
|
-
}
|
|
241
|
-
return response.data;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// POST /api/config/providers/:provider/auth/import-cli
|
|
245
|
-
export async function importProviderAuthFromCli(provider: string): Promise<ProviderAuthImportResult> {
|
|
246
|
-
const response = await api.post<ProviderAuthImportResult>(
|
|
247
|
-
`/api/config/providers/${provider}/auth/import-cli`,
|
|
248
|
-
{}
|
|
249
|
-
);
|
|
250
|
-
if (!response.ok) {
|
|
251
|
-
throw new Error(response.error.message);
|
|
252
|
-
}
|
|
253
|
-
return response.data;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// PUT /api/config/channels/:channel
|
|
257
|
-
export async function updateChannel(
|
|
258
|
-
channel: string,
|
|
259
|
-
data: ChannelConfigUpdate
|
|
260
|
-
): Promise<Record<string, unknown>> {
|
|
261
|
-
const response = await api.put<Record<string, unknown>>(
|
|
262
|
-
`/api/config/channels/${channel}`,
|
|
263
|
-
data
|
|
264
|
-
);
|
|
265
|
-
if (!response.ok) {
|
|
266
|
-
throw new Error(response.error.message);
|
|
267
|
-
}
|
|
268
|
-
return response.data;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// PUT /api/config/runtime
|
|
272
|
-
export async function updateRuntime(
|
|
273
|
-
data: RuntimeConfigUpdate
|
|
274
|
-
): Promise<Pick<ConfigView, 'agents' | 'bindings' | 'session'>> {
|
|
275
|
-
const response = await api.put<Pick<ConfigView, 'agents' | 'bindings' | 'session'>>(
|
|
276
|
-
'/api/config/runtime',
|
|
277
|
-
data
|
|
278
|
-
);
|
|
279
|
-
if (!response.ok) {
|
|
280
|
-
throw new Error(response.error.message);
|
|
281
|
-
}
|
|
282
|
-
return response.data;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// PUT /api/config/secrets
|
|
286
|
-
export async function updateSecrets(
|
|
287
|
-
data: SecretsConfigUpdate
|
|
288
|
-
): Promise<SecretsView> {
|
|
289
|
-
const response = await api.put<SecretsView>(
|
|
290
|
-
'/api/config/secrets',
|
|
291
|
-
data
|
|
292
|
-
);
|
|
293
|
-
if (!response.ok) {
|
|
294
|
-
throw new Error(response.error.message);
|
|
295
|
-
}
|
|
296
|
-
return response.data;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// POST /api/config/actions/:id/execute
|
|
300
|
-
export async function executeConfigAction(
|
|
301
|
-
actionId: string,
|
|
302
|
-
data: ConfigActionExecuteRequest
|
|
303
|
-
): Promise<ConfigActionExecuteResult> {
|
|
304
|
-
const response = await api.post<ConfigActionExecuteResult>(
|
|
305
|
-
`/api/config/actions/${actionId}/execute`,
|
|
306
|
-
data
|
|
307
|
-
);
|
|
308
|
-
if (!response.ok) {
|
|
309
|
-
throw new Error(response.error.message);
|
|
310
|
-
}
|
|
311
|
-
return response.data;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// GET /api/ncp/session-types
|
|
315
|
-
export async function fetchNcpChatSessionTypes(): Promise<ChatSessionTypesView> {
|
|
316
|
-
const response = await api.get<ChatSessionTypesView>('/api/ncp/session-types');
|
|
317
|
-
if (!response.ok) {
|
|
318
|
-
throw new Error(response.error.message);
|
|
319
|
-
}
|
|
320
|
-
return response.data;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// GET /api/cron
|
|
324
|
-
export async function fetchCronJobs(params?: { all?: boolean }): Promise<CronListView> {
|
|
325
|
-
const query = new URLSearchParams();
|
|
326
|
-
if (params?.all) {
|
|
327
|
-
query.set('all', '1');
|
|
328
|
-
}
|
|
329
|
-
const suffix = query.toString();
|
|
330
|
-
const response = await api.get<CronListView>(suffix ? '/api/cron?' + suffix : '/api/cron');
|
|
331
|
-
if (!response.ok) {
|
|
332
|
-
throw new Error(response.error.message);
|
|
333
|
-
}
|
|
334
|
-
return response.data;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// DELETE /api/cron/:id
|
|
338
|
-
export async function deleteCronJob(id: string): Promise<{ deleted: boolean }> {
|
|
339
|
-
const response = await api.delete<{ deleted: boolean }>(`/api/cron/${encodeURIComponent(id)}`);
|
|
340
|
-
if (!response.ok) {
|
|
341
|
-
throw new Error(response.error.message);
|
|
342
|
-
}
|
|
343
|
-
return response.data;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// PUT /api/cron/:id/enable
|
|
347
|
-
export async function setCronJobEnabled(id: string, data: CronEnableRequest): Promise<CronActionResult> {
|
|
348
|
-
const response = await api.put<CronActionResult>(`/api/cron/${encodeURIComponent(id)}/enable`, data);
|
|
349
|
-
if (!response.ok) {
|
|
350
|
-
throw new Error(response.error.message);
|
|
351
|
-
}
|
|
352
|
-
return response.data;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// POST /api/cron/:id/run
|
|
356
|
-
export async function runCronJob(id: string, data: CronRunRequest): Promise<CronActionResult> {
|
|
357
|
-
const response = await api.post<CronActionResult>(`/api/cron/${encodeURIComponent(id)}/run`, data);
|
|
358
|
-
if (!response.ok) {
|
|
359
|
-
throw new Error(response.error.message);
|
|
360
|
-
}
|
|
361
|
-
return response.data;
|
|
362
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { api } from './client';
|
|
2
|
-
import type {
|
|
3
|
-
MarketplaceInstallRequest,
|
|
4
|
-
MarketplaceInstallResult,
|
|
5
|
-
MarketplaceManageRequest,
|
|
6
|
-
MarketplaceManageResult,
|
|
7
|
-
MarketplaceInstalledView,
|
|
8
|
-
MarketplacePluginContentView,
|
|
9
|
-
MarketplaceItemType,
|
|
10
|
-
MarketplaceSkillContentView,
|
|
11
|
-
MarketplaceItemView,
|
|
12
|
-
MarketplaceListView,
|
|
13
|
-
MarketplaceRecommendationView,
|
|
14
|
-
MarketplaceSort
|
|
15
|
-
} from './types';
|
|
16
|
-
|
|
17
|
-
export type MarketplaceListParams = {
|
|
18
|
-
type: MarketplaceItemType;
|
|
19
|
-
q?: string;
|
|
20
|
-
tag?: string;
|
|
21
|
-
sort?: MarketplaceSort;
|
|
22
|
-
page?: number;
|
|
23
|
-
pageSize?: number;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function toMarketplaceTypeSegment(type: MarketplaceItemType): 'plugins' | 'skills' | 'mcp' {
|
|
27
|
-
if (type === 'plugin') {
|
|
28
|
-
return 'plugins';
|
|
29
|
-
}
|
|
30
|
-
if (type === 'skill') {
|
|
31
|
-
return 'skills';
|
|
32
|
-
}
|
|
33
|
-
return 'mcp';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function fetchMarketplaceItems(params: MarketplaceListParams): Promise<MarketplaceListView> {
|
|
37
|
-
const query = new URLSearchParams();
|
|
38
|
-
const segment = toMarketplaceTypeSegment(params.type);
|
|
39
|
-
|
|
40
|
-
if (params.q?.trim()) {
|
|
41
|
-
query.set('q', params.q.trim());
|
|
42
|
-
}
|
|
43
|
-
if (params.tag?.trim()) {
|
|
44
|
-
query.set('tag', params.tag.trim());
|
|
45
|
-
}
|
|
46
|
-
if (params.sort) {
|
|
47
|
-
query.set('sort', params.sort);
|
|
48
|
-
}
|
|
49
|
-
if (typeof params.page === 'number' && Number.isFinite(params.page)) {
|
|
50
|
-
query.set('page', String(Math.max(1, Math.trunc(params.page))));
|
|
51
|
-
}
|
|
52
|
-
if (typeof params.pageSize === 'number' && Number.isFinite(params.pageSize)) {
|
|
53
|
-
query.set('pageSize', String(Math.max(1, Math.trunc(params.pageSize))));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const suffix = query.toString();
|
|
57
|
-
const response = await api.get<MarketplaceListView>(
|
|
58
|
-
suffix ? `/api/marketplace/${segment}/items?${suffix}` : `/api/marketplace/${segment}/items`
|
|
59
|
-
);
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
throw new Error(response.error.message);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return response.data;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function fetchMarketplaceItem(slug: string, type: MarketplaceItemType): Promise<MarketplaceItemView> {
|
|
68
|
-
const segment = toMarketplaceTypeSegment(type);
|
|
69
|
-
const response = await api.get<MarketplaceItemView>(
|
|
70
|
-
`/api/marketplace/${segment}/items/${encodeURIComponent(slug)}`
|
|
71
|
-
);
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
throw new Error(response.error.message);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return response.data;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function fetchMarketplaceSkillContent(slug: string): Promise<MarketplaceSkillContentView> {
|
|
80
|
-
const response = await api.get<MarketplaceSkillContentView>(
|
|
81
|
-
`/api/marketplace/skills/items/${encodeURIComponent(slug)}/content`
|
|
82
|
-
);
|
|
83
|
-
if (!response.ok) {
|
|
84
|
-
throw new Error(response.error.message);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return response.data;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export async function fetchMarketplacePluginContent(slug: string): Promise<MarketplacePluginContentView> {
|
|
91
|
-
const response = await api.get<MarketplacePluginContentView>(
|
|
92
|
-
`/api/marketplace/plugins/items/${encodeURIComponent(slug)}/content`
|
|
93
|
-
);
|
|
94
|
-
if (!response.ok) {
|
|
95
|
-
throw new Error(response.error.message);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return response.data;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export async function fetchMarketplaceRecommendations(
|
|
102
|
-
type: MarketplaceItemType,
|
|
103
|
-
params: {
|
|
104
|
-
scene?: string;
|
|
105
|
-
limit?: number;
|
|
106
|
-
} = {}
|
|
107
|
-
): Promise<MarketplaceRecommendationView> {
|
|
108
|
-
const query = new URLSearchParams();
|
|
109
|
-
const segment = toMarketplaceTypeSegment(type);
|
|
110
|
-
if (params.scene?.trim()) {
|
|
111
|
-
query.set('scene', params.scene.trim());
|
|
112
|
-
}
|
|
113
|
-
if (typeof params.limit === 'number' && Number.isFinite(params.limit)) {
|
|
114
|
-
query.set('limit', String(Math.max(1, Math.trunc(params.limit))));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const suffix = query.toString();
|
|
118
|
-
const response = await api.get<MarketplaceRecommendationView>(
|
|
119
|
-
suffix
|
|
120
|
-
? `/api/marketplace/${segment}/recommendations?${suffix}`
|
|
121
|
-
: `/api/marketplace/${segment}/recommendations`
|
|
122
|
-
);
|
|
123
|
-
if (!response.ok) {
|
|
124
|
-
throw new Error(response.error.message);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return response.data;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export async function installMarketplaceItem(request: MarketplaceInstallRequest): Promise<MarketplaceInstallResult> {
|
|
131
|
-
const segment = toMarketplaceTypeSegment(request.type);
|
|
132
|
-
const response = await api.post<MarketplaceInstallResult>(`/api/marketplace/${segment}/install`, request);
|
|
133
|
-
if (!response.ok) {
|
|
134
|
-
throw new Error(response.error.message);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return response.data;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export async function fetchMarketplaceInstalled(type: MarketplaceItemType): Promise<MarketplaceInstalledView> {
|
|
141
|
-
const segment = toMarketplaceTypeSegment(type);
|
|
142
|
-
const response = await api.get<MarketplaceInstalledView>(`/api/marketplace/${segment}/installed`);
|
|
143
|
-
if (!response.ok) {
|
|
144
|
-
throw new Error(response.error.message);
|
|
145
|
-
}
|
|
146
|
-
return response.data;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export async function manageMarketplaceItem(request: MarketplaceManageRequest): Promise<MarketplaceManageResult> {
|
|
150
|
-
const segment = toMarketplaceTypeSegment(request.type);
|
|
151
|
-
const response = await api.post<MarketplaceManageResult>(`/api/marketplace/${segment}/manage`, request);
|
|
152
|
-
if (!response.ok) {
|
|
153
|
-
throw new Error(response.error.message);
|
|
154
|
-
}
|
|
155
|
-
return response.data;
|
|
156
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { api } from './client';
|
|
2
|
-
import type {
|
|
3
|
-
MarketplaceInstalledView,
|
|
4
|
-
MarketplaceItemView,
|
|
5
|
-
MarketplaceListView,
|
|
6
|
-
MarketplaceMcpContentView,
|
|
7
|
-
MarketplaceMcpDoctorResult,
|
|
8
|
-
MarketplaceRecommendationView,
|
|
9
|
-
MarketplaceSort
|
|
10
|
-
} from './types';
|
|
11
|
-
|
|
12
|
-
export type McpMarketplaceListParams = {
|
|
13
|
-
q?: string;
|
|
14
|
-
tag?: string;
|
|
15
|
-
sort?: MarketplaceSort;
|
|
16
|
-
page?: number;
|
|
17
|
-
pageSize?: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export async function fetchMcpMarketplaceItems(params: McpMarketplaceListParams): Promise<MarketplaceListView> {
|
|
21
|
-
const query = new URLSearchParams();
|
|
22
|
-
if (params.q?.trim()) {
|
|
23
|
-
query.set('q', params.q.trim());
|
|
24
|
-
}
|
|
25
|
-
if (params.tag?.trim()) {
|
|
26
|
-
query.set('tag', params.tag.trim());
|
|
27
|
-
}
|
|
28
|
-
if (params.sort) {
|
|
29
|
-
query.set('sort', params.sort);
|
|
30
|
-
}
|
|
31
|
-
if (typeof params.page === 'number' && Number.isFinite(params.page)) {
|
|
32
|
-
query.set('page', String(Math.max(1, Math.trunc(params.page))));
|
|
33
|
-
}
|
|
34
|
-
if (typeof params.pageSize === 'number' && Number.isFinite(params.pageSize)) {
|
|
35
|
-
query.set('pageSize', String(Math.max(1, Math.trunc(params.pageSize))));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const suffix = query.toString();
|
|
39
|
-
const response = await api.get<MarketplaceListView>(
|
|
40
|
-
suffix ? `/api/marketplace/mcp/items?${suffix}` : '/api/marketplace/mcp/items'
|
|
41
|
-
);
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
throw new Error(response.error.message);
|
|
44
|
-
}
|
|
45
|
-
return response.data;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export async function fetchMcpMarketplaceInstalled(): Promise<MarketplaceInstalledView> {
|
|
49
|
-
const response = await api.get<MarketplaceInstalledView>('/api/marketplace/mcp/installed');
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(response.error.message);
|
|
52
|
-
}
|
|
53
|
-
return response.data;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function fetchMcpMarketplaceItem(slug: string): Promise<MarketplaceItemView> {
|
|
57
|
-
const response = await api.get<MarketplaceItemView>(`/api/marketplace/mcp/items/${encodeURIComponent(slug)}`);
|
|
58
|
-
if (!response.ok) {
|
|
59
|
-
throw new Error(response.error.message);
|
|
60
|
-
}
|
|
61
|
-
return response.data;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export async function fetchMcpMarketplaceContent(slug: string): Promise<MarketplaceMcpContentView> {
|
|
65
|
-
const response = await api.get<MarketplaceMcpContentView>(`/api/marketplace/mcp/items/${encodeURIComponent(slug)}/content`);
|
|
66
|
-
if (!response.ok) {
|
|
67
|
-
throw new Error(response.error.message);
|
|
68
|
-
}
|
|
69
|
-
return response.data;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export async function fetchMcpMarketplaceRecommendations(params: {
|
|
73
|
-
scene?: string;
|
|
74
|
-
limit?: number;
|
|
75
|
-
} = {}): Promise<MarketplaceRecommendationView> {
|
|
76
|
-
const query = new URLSearchParams();
|
|
77
|
-
if (params.scene?.trim()) {
|
|
78
|
-
query.set('scene', params.scene.trim());
|
|
79
|
-
}
|
|
80
|
-
if (typeof params.limit === 'number' && Number.isFinite(params.limit)) {
|
|
81
|
-
query.set('limit', String(Math.max(1, Math.trunc(params.limit))));
|
|
82
|
-
}
|
|
83
|
-
const suffix = query.toString();
|
|
84
|
-
const response = await api.get<MarketplaceRecommendationView>(
|
|
85
|
-
suffix ? `/api/marketplace/mcp/recommendations?${suffix}` : '/api/marketplace/mcp/recommendations'
|
|
86
|
-
);
|
|
87
|
-
if (!response.ok) {
|
|
88
|
-
throw new Error(response.error.message);
|
|
89
|
-
}
|
|
90
|
-
return response.data;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export async function installMcpMarketplaceItem(request: {
|
|
94
|
-
spec: string;
|
|
95
|
-
name?: string;
|
|
96
|
-
enabled?: boolean;
|
|
97
|
-
allAgents?: boolean;
|
|
98
|
-
agents?: string[];
|
|
99
|
-
inputs?: Record<string, string>;
|
|
100
|
-
}): Promise<{ type: 'mcp'; spec: string; name?: string; message: string; output?: string }> {
|
|
101
|
-
const response = await api.post<{ type: 'mcp'; spec: string; name?: string; message: string; output?: string }>(
|
|
102
|
-
'/api/marketplace/mcp/install',
|
|
103
|
-
{
|
|
104
|
-
type: 'mcp',
|
|
105
|
-
...request
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
if (!response.ok) {
|
|
109
|
-
throw new Error(response.error.message);
|
|
110
|
-
}
|
|
111
|
-
return response.data;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export async function manageMcpMarketplaceItem(request: {
|
|
115
|
-
action: 'enable' | 'disable' | 'remove';
|
|
116
|
-
id?: string;
|
|
117
|
-
spec?: string;
|
|
118
|
-
}): Promise<{ type: 'mcp'; action: 'enable' | 'disable' | 'remove'; id: string; message: string; output?: string }> {
|
|
119
|
-
const response = await api.post<{ type: 'mcp'; action: 'enable' | 'disable' | 'remove'; id: string; message: string; output?: string }>(
|
|
120
|
-
'/api/marketplace/mcp/manage',
|
|
121
|
-
{
|
|
122
|
-
type: 'mcp',
|
|
123
|
-
...request
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
if (!response.ok) {
|
|
127
|
-
throw new Error(response.error.message);
|
|
128
|
-
}
|
|
129
|
-
return response.data;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export async function doctorMcpMarketplaceItem(name: string): Promise<MarketplaceMcpDoctorResult> {
|
|
133
|
-
const response = await api.post<MarketplaceMcpDoctorResult>('/api/marketplace/mcp/doctor', { name });
|
|
134
|
-
if (!response.ok) {
|
|
135
|
-
throw new Error(response.error.message);
|
|
136
|
-
}
|
|
137
|
-
return response.data;
|
|
138
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { NcpDraftAttachment } from "@nextclaw/ncp-react";
|
|
2
|
-
import { API_BASE } from "./api-base";
|
|
3
|
-
import type { ApiResponse, NcpAssetPutView } from "./types";
|
|
4
|
-
|
|
5
|
-
function readErrorMessage(payload: unknown, fallback: string): string {
|
|
6
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
7
|
-
return fallback;
|
|
8
|
-
}
|
|
9
|
-
const error = (payload as { error?: unknown }).error;
|
|
10
|
-
if (!error || typeof error !== "object" || Array.isArray(error)) {
|
|
11
|
-
return fallback;
|
|
12
|
-
}
|
|
13
|
-
const message = (error as { message?: unknown }).message;
|
|
14
|
-
return typeof message === "string" && message.trim().length > 0 ? message : fallback;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function uploadNcpAssets(files: File[]): Promise<NcpDraftAttachment[]> {
|
|
18
|
-
const formData = new FormData();
|
|
19
|
-
for (const file of files) {
|
|
20
|
-
formData.append("files", file);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const response = await fetch(`${API_BASE}/api/ncp/assets`, {
|
|
24
|
-
method: "POST",
|
|
25
|
-
body: formData,
|
|
26
|
-
credentials: "include",
|
|
27
|
-
});
|
|
28
|
-
const payload = (await response.json()) as ApiResponse<NcpAssetPutView>;
|
|
29
|
-
if (!response.ok || !payload.ok) {
|
|
30
|
-
throw new Error(readErrorMessage(payload, "Failed to put assets."));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return payload.data.assets.map((asset) => ({
|
|
34
|
-
id: asset.id,
|
|
35
|
-
name: asset.name,
|
|
36
|
-
mimeType: asset.mimeType,
|
|
37
|
-
sizeBytes: asset.sizeBytes,
|
|
38
|
-
assetUri: asset.assetUri,
|
|
39
|
-
url: asset.url,
|
|
40
|
-
}));
|
|
41
|
-
}
|