@nextclaw/server 0.9.3 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +280 -179
  2. package/dist/index.js +267 -20
  3. package/package.json +5 -4
package/dist/index.d.ts CHANGED
@@ -5,6 +5,284 @@ import { NcpHttpAgentStreamProvider } from '@nextclaw/ncp-http-agent-server';
5
5
  import { Hono } from 'hono';
6
6
  import { IncomingMessage } from 'node:http';
7
7
 
8
+ type MarketplaceItemType = "plugin" | "skill" | "mcp";
9
+ type MarketplaceSort = "relevance" | "updated";
10
+ type MarketplacePluginInstallKind = "npm";
11
+ type MarketplaceSkillInstallKind = "builtin" | "marketplace";
12
+ type MarketplaceMcpInstallKind = "template";
13
+ type MarketplaceInstallKind = MarketplacePluginInstallKind | MarketplaceSkillInstallKind | MarketplaceMcpInstallKind;
14
+ type MarketplaceInstallSpec = {
15
+ kind: MarketplaceInstallKind;
16
+ spec: string;
17
+ command: string;
18
+ };
19
+ type MarketplaceMcpTemplateInput = {
20
+ id: string;
21
+ label: string;
22
+ description?: string;
23
+ required?: boolean;
24
+ secret?: boolean;
25
+ defaultValue?: string;
26
+ };
27
+ type MarketplaceMcpInstallSpec = MarketplaceInstallSpec & {
28
+ kind: "template";
29
+ defaultName: string;
30
+ transportTypes: Array<"stdio" | "http" | "sse">;
31
+ template: Record<string, unknown>;
32
+ inputs: MarketplaceMcpTemplateInput[];
33
+ };
34
+ type MarketplaceLocalizedTextMap = Record<string, string>;
35
+ type MarketplaceItemSummary = {
36
+ id: string;
37
+ slug: string;
38
+ type: MarketplaceItemType;
39
+ name: string;
40
+ summary: string;
41
+ summaryI18n: MarketplaceLocalizedTextMap;
42
+ tags: string[];
43
+ author: string;
44
+ install: MarketplaceInstallSpec;
45
+ updatedAt: string;
46
+ };
47
+ type MarketplaceItemView = MarketplaceItemSummary & {
48
+ description?: string;
49
+ descriptionI18n?: MarketplaceLocalizedTextMap;
50
+ sourceRepo?: string;
51
+ homepage?: string;
52
+ publishedAt: string;
53
+ };
54
+ type MarketplaceSkillContentView = {
55
+ type: "skill";
56
+ slug: string;
57
+ name: string;
58
+ install: MarketplaceInstallSpec;
59
+ source: "builtin" | "marketplace" | "remote";
60
+ raw: string;
61
+ metadataRaw?: string;
62
+ bodyRaw: string;
63
+ sourceUrl?: string;
64
+ };
65
+ type MarketplacePluginContentView = {
66
+ type: "plugin";
67
+ slug: string;
68
+ name: string;
69
+ install: MarketplaceInstallSpec;
70
+ source: "npm" | "repo" | "remote";
71
+ raw?: string;
72
+ bodyRaw?: string;
73
+ metadataRaw?: string;
74
+ sourceUrl?: string;
75
+ };
76
+ type MarketplaceMcpContentView = {
77
+ type: "mcp";
78
+ slug: string;
79
+ name: string;
80
+ install: MarketplaceMcpInstallSpec;
81
+ source: "marketplace" | "remote";
82
+ raw: string;
83
+ metadataRaw?: string;
84
+ bodyRaw: string;
85
+ sourceUrl?: string;
86
+ };
87
+ type MarketplaceListView = {
88
+ total: number;
89
+ page: number;
90
+ pageSize: number;
91
+ totalPages: number;
92
+ sort: MarketplaceSort;
93
+ query?: string;
94
+ items: MarketplaceItemSummary[];
95
+ };
96
+ type MarketplaceRecommendationView = {
97
+ type: MarketplaceItemType;
98
+ sceneId: string;
99
+ title: string;
100
+ description?: string;
101
+ total: number;
102
+ items: MarketplaceItemSummary[];
103
+ };
104
+ type MarketplaceInstalledRecord = {
105
+ type: MarketplaceItemType;
106
+ id?: string;
107
+ spec: string;
108
+ label?: string;
109
+ description?: string;
110
+ descriptionZh?: string;
111
+ source?: string;
112
+ installedAt?: string;
113
+ enabled?: boolean;
114
+ runtimeStatus?: string;
115
+ origin?: string;
116
+ installPath?: string;
117
+ transport?: "stdio" | "http" | "sse";
118
+ scope?: {
119
+ allAgents: boolean;
120
+ agents: string[];
121
+ };
122
+ catalogSlug?: string;
123
+ vendor?: string;
124
+ docsUrl?: string;
125
+ homepage?: string;
126
+ trustLevel?: "official" | "verified" | "community";
127
+ toolCount?: number;
128
+ accessible?: boolean;
129
+ lastReadyAt?: string;
130
+ lastDoctorAt?: string;
131
+ lastError?: string;
132
+ };
133
+ type MarketplaceInstalledView = {
134
+ type: MarketplaceItemType;
135
+ total: number;
136
+ specs: string[];
137
+ records: MarketplaceInstalledRecord[];
138
+ };
139
+ type MarketplaceInstallSkillParams = {
140
+ slug: string;
141
+ kind?: MarketplaceSkillInstallKind;
142
+ skill?: string;
143
+ installPath?: string;
144
+ force?: boolean;
145
+ };
146
+ type MarketplacePluginInstallRequest = {
147
+ type?: "plugin";
148
+ spec: string;
149
+ };
150
+ type MarketplaceSkillInstallRequest = {
151
+ type?: "skill";
152
+ spec: string;
153
+ kind?: MarketplaceSkillInstallKind;
154
+ skill?: string;
155
+ installPath?: string;
156
+ force?: boolean;
157
+ };
158
+ type MarketplaceMcpInstallRequest = {
159
+ type?: "mcp";
160
+ spec: string;
161
+ name?: string;
162
+ enabled?: boolean;
163
+ allAgents?: boolean;
164
+ agents?: string[];
165
+ inputs?: Record<string, string>;
166
+ template?: MarketplaceMcpInstallSpec;
167
+ };
168
+ type MarketplacePluginInstallResult = {
169
+ type: "plugin";
170
+ spec: string;
171
+ message: string;
172
+ output?: string;
173
+ };
174
+ type MarketplaceSkillInstallResult = {
175
+ type: "skill";
176
+ spec: string;
177
+ message: string;
178
+ output?: string;
179
+ };
180
+ type MarketplaceMcpInstallResult = {
181
+ type: "mcp";
182
+ spec: string;
183
+ name: string;
184
+ message: string;
185
+ output?: string;
186
+ };
187
+ type MarketplacePluginManageAction = "enable" | "disable" | "uninstall";
188
+ type MarketplaceSkillManageAction = "uninstall";
189
+ type MarketplaceMcpManageAction = "enable" | "disable" | "remove";
190
+ type MarketplacePluginManageRequest = {
191
+ type?: "plugin";
192
+ action: MarketplacePluginManageAction;
193
+ id?: string;
194
+ spec?: string;
195
+ };
196
+ type MarketplaceSkillManageRequest = {
197
+ type?: "skill";
198
+ action: MarketplaceSkillManageAction;
199
+ id?: string;
200
+ spec?: string;
201
+ };
202
+ type MarketplaceMcpManageRequest = {
203
+ type?: "mcp";
204
+ action: MarketplaceMcpManageAction;
205
+ id?: string;
206
+ spec?: string;
207
+ };
208
+ type MarketplacePluginManageResult = {
209
+ type: "plugin";
210
+ action: MarketplacePluginManageAction;
211
+ id: string;
212
+ message: string;
213
+ output?: string;
214
+ };
215
+ type MarketplaceSkillManageResult = {
216
+ type: "skill";
217
+ action: MarketplaceSkillManageAction;
218
+ id: string;
219
+ message: string;
220
+ output?: string;
221
+ };
222
+ type MarketplaceMcpManageResult = {
223
+ type: "mcp";
224
+ action: MarketplaceMcpManageAction;
225
+ id: string;
226
+ message: string;
227
+ output?: string;
228
+ };
229
+ type MarketplaceMcpDoctorResult = {
230
+ name: string;
231
+ enabled: boolean;
232
+ transport: "stdio" | "http" | "sse";
233
+ accessible: boolean;
234
+ toolCount: number;
235
+ error?: string;
236
+ };
237
+ type MarketplaceInstaller = {
238
+ installPlugin?: (spec: string) => Promise<{
239
+ message: string;
240
+ output?: string;
241
+ }>;
242
+ installSkill?: (params: MarketplaceInstallSkillParams) => Promise<{
243
+ message: string;
244
+ output?: string;
245
+ }>;
246
+ enablePlugin?: (id: string) => Promise<{
247
+ message: string;
248
+ output?: string;
249
+ }>;
250
+ disablePlugin?: (id: string) => Promise<{
251
+ message: string;
252
+ output?: string;
253
+ }>;
254
+ uninstallPlugin?: (id: string) => Promise<{
255
+ message: string;
256
+ output?: string;
257
+ }>;
258
+ uninstallSkill?: (slug: string) => Promise<{
259
+ message: string;
260
+ output?: string;
261
+ }>;
262
+ installMcp?: (params: MarketplaceMcpInstallRequest) => Promise<{
263
+ name: string;
264
+ message: string;
265
+ output?: string;
266
+ }>;
267
+ enableMcp?: (name: string) => Promise<{
268
+ message: string;
269
+ output?: string;
270
+ }>;
271
+ disableMcp?: (name: string) => Promise<{
272
+ message: string;
273
+ output?: string;
274
+ }>;
275
+ removeMcp?: (name: string) => Promise<{
276
+ message: string;
277
+ output?: string;
278
+ }>;
279
+ doctorMcp?: (name: string) => Promise<MarketplaceMcpDoctorResult>;
280
+ };
281
+ type MarketplaceApiConfig = {
282
+ apiBaseUrl?: string;
283
+ installer?: MarketplaceInstaller;
284
+ };
285
+
8
286
  type ApiError = {
9
287
  code: string;
10
288
  message: string;
@@ -190,6 +468,7 @@ type SessionEntryView = {
190
468
  updatedAt: string;
191
469
  label?: string;
192
470
  preferredModel?: string;
471
+ preferredThinking?: ThinkingLevel | null;
193
472
  sessionType: string;
194
473
  sessionTypeMutable: boolean;
195
474
  messageCount: number;
@@ -634,184 +913,6 @@ type ConfigActionExecuteResult = {
634
913
  patch?: Record<string, unknown>;
635
914
  nextActions?: string[];
636
915
  };
637
- type MarketplaceItemType = "plugin" | "skill";
638
- type MarketplaceSort = "relevance" | "updated";
639
- type MarketplacePluginInstallKind = "npm";
640
- type MarketplaceSkillInstallKind = "builtin" | "marketplace";
641
- type MarketplaceInstallKind = MarketplacePluginInstallKind | MarketplaceSkillInstallKind;
642
- type MarketplaceInstallSpec = {
643
- kind: MarketplaceInstallKind;
644
- spec: string;
645
- command: string;
646
- };
647
- type MarketplaceLocalizedTextMap = Record<string, string>;
648
- type MarketplaceItemSummary = {
649
- id: string;
650
- slug: string;
651
- type: MarketplaceItemType;
652
- name: string;
653
- summary: string;
654
- summaryI18n: MarketplaceLocalizedTextMap;
655
- tags: string[];
656
- author: string;
657
- install: MarketplaceInstallSpec;
658
- updatedAt: string;
659
- };
660
- type MarketplaceItemView = MarketplaceItemSummary & {
661
- description?: string;
662
- descriptionI18n?: MarketplaceLocalizedTextMap;
663
- sourceRepo?: string;
664
- homepage?: string;
665
- publishedAt: string;
666
- };
667
- type MarketplaceSkillContentView = {
668
- type: "skill";
669
- slug: string;
670
- name: string;
671
- install: MarketplaceInstallSpec;
672
- source: "builtin" | "marketplace" | "remote";
673
- raw: string;
674
- metadataRaw?: string;
675
- bodyRaw: string;
676
- sourceUrl?: string;
677
- };
678
- type MarketplacePluginContentView = {
679
- type: "plugin";
680
- slug: string;
681
- name: string;
682
- install: MarketplaceInstallSpec;
683
- source: "npm" | "repo" | "remote";
684
- raw?: string;
685
- bodyRaw?: string;
686
- metadataRaw?: string;
687
- sourceUrl?: string;
688
- };
689
- type MarketplaceListView = {
690
- total: number;
691
- page: number;
692
- pageSize: number;
693
- totalPages: number;
694
- sort: MarketplaceSort;
695
- query?: string;
696
- items: MarketplaceItemSummary[];
697
- };
698
- type MarketplaceRecommendationView = {
699
- type: MarketplaceItemType;
700
- sceneId: string;
701
- title: string;
702
- description?: string;
703
- total: number;
704
- items: MarketplaceItemSummary[];
705
- };
706
- type MarketplaceInstalledRecord = {
707
- type: MarketplaceItemType;
708
- id?: string;
709
- spec: string;
710
- label?: string;
711
- description?: string;
712
- descriptionZh?: string;
713
- source?: string;
714
- installedAt?: string;
715
- enabled?: boolean;
716
- runtimeStatus?: string;
717
- origin?: string;
718
- installPath?: string;
719
- };
720
- type MarketplaceInstalledView = {
721
- type: MarketplaceItemType;
722
- total: number;
723
- specs: string[];
724
- records: MarketplaceInstalledRecord[];
725
- };
726
- type MarketplaceInstallSkillParams = {
727
- slug: string;
728
- kind?: MarketplaceSkillInstallKind;
729
- skill?: string;
730
- installPath?: string;
731
- force?: boolean;
732
- };
733
- type MarketplacePluginInstallRequest = {
734
- type?: "plugin";
735
- spec: string;
736
- };
737
- type MarketplaceSkillInstallRequest = {
738
- type?: "skill";
739
- spec: string;
740
- kind?: MarketplaceSkillInstallKind;
741
- skill?: string;
742
- installPath?: string;
743
- force?: boolean;
744
- };
745
- type MarketplacePluginInstallResult = {
746
- type: "plugin";
747
- spec: string;
748
- message: string;
749
- output?: string;
750
- };
751
- type MarketplaceSkillInstallResult = {
752
- type: "skill";
753
- spec: string;
754
- message: string;
755
- output?: string;
756
- };
757
- type MarketplacePluginManageAction = "enable" | "disable" | "uninstall";
758
- type MarketplaceSkillManageAction = "uninstall";
759
- type MarketplacePluginManageRequest = {
760
- type?: "plugin";
761
- action: MarketplacePluginManageAction;
762
- id?: string;
763
- spec?: string;
764
- };
765
- type MarketplaceSkillManageRequest = {
766
- type?: "skill";
767
- action: MarketplaceSkillManageAction;
768
- id?: string;
769
- spec?: string;
770
- };
771
- type MarketplacePluginManageResult = {
772
- type: "plugin";
773
- action: MarketplacePluginManageAction;
774
- id: string;
775
- message: string;
776
- output?: string;
777
- };
778
- type MarketplaceSkillManageResult = {
779
- type: "skill";
780
- action: MarketplaceSkillManageAction;
781
- id: string;
782
- message: string;
783
- output?: string;
784
- };
785
- type MarketplaceInstaller = {
786
- installPlugin?: (spec: string) => Promise<{
787
- message: string;
788
- output?: string;
789
- }>;
790
- installSkill?: (params: MarketplaceInstallSkillParams) => Promise<{
791
- message: string;
792
- output?: string;
793
- }>;
794
- enablePlugin?: (id: string) => Promise<{
795
- message: string;
796
- output?: string;
797
- }>;
798
- disablePlugin?: (id: string) => Promise<{
799
- message: string;
800
- output?: string;
801
- }>;
802
- uninstallPlugin?: (id: string) => Promise<{
803
- message: string;
804
- output?: string;
805
- }>;
806
- uninstallSkill?: (slug: string) => Promise<{
807
- message: string;
808
- output?: string;
809
- }>;
810
- };
811
- type MarketplaceApiConfig = {
812
- apiBaseUrl?: string;
813
- installer?: MarketplaceInstaller;
814
- };
815
916
  type UiServerEvent = {
816
917
  type: "config.updated";
817
918
  payload: {
@@ -956,4 +1057,4 @@ declare function deleteSession(configPath: string, key: string): boolean;
956
1057
  declare function updateRuntime(configPath: string, patch: RuntimeConfigUpdate): Pick<ConfigView, "agents" | "bindings" | "session">;
957
1058
  declare function updateSecrets(configPath: string, patch: SecretsConfigUpdate): SecretsView;
958
1059
 
959
- export { type AgentBindingView, type AgentProfileView, type ApiError, type ApiResponse, type AppMetaView, type AuthEnabledUpdateRequest, type AuthLoginRequest, type AuthPasswordUpdateRequest, type AuthSetupRequest, type AuthStatusView, type BindingPeerView, type BochaFreshnessValue, type ChannelSpecView, type ChatCapabilitiesView, type ChatCommandOptionView, type ChatCommandView, type ChatCommandsView, type ChatRunListView, type ChatRunState, type ChatRunView, type ChatSessionTypeOptionView, type ChatSessionTypesView, type ChatTurnRequest, type ChatTurnResult, type ChatTurnStopRequest, type ChatTurnStopResult, type ChatTurnStreamEvent, type ChatTurnView, type ConfigActionExecuteRequest, type ConfigActionExecuteResult, type ConfigActionManifest, type ConfigActionType, type ConfigMetaView, type ConfigSchemaResponse, type ConfigUiHint, type ConfigUiHints, type ConfigView, type CronActionResult, type CronEnableRequest, type CronJobStateView, type CronJobView, type CronListView, type CronPayloadView, type CronRunRequest, type CronScheduleView, DEFAULT_SESSION_TYPE, type MarketplaceApiConfig, type MarketplaceInstallKind, type MarketplaceInstallSkillParams, type MarketplaceInstallSpec, type MarketplaceInstalledRecord, type MarketplaceInstalledView, type MarketplaceInstaller, type MarketplaceItemSummary, type MarketplaceItemType, type MarketplaceItemView, type MarketplaceListView, type MarketplaceLocalizedTextMap, type MarketplacePluginContentView, type MarketplacePluginInstallKind, type MarketplacePluginInstallRequest, type MarketplacePluginInstallResult, type MarketplacePluginManageAction, type MarketplacePluginManageRequest, type MarketplacePluginManageResult, type MarketplaceRecommendationView, type MarketplaceSkillContentView, type MarketplaceSkillInstallKind, type MarketplaceSkillInstallRequest, type MarketplaceSkillInstallResult, type MarketplaceSkillManageAction, type MarketplaceSkillManageRequest, type MarketplaceSkillManageResult, type MarketplaceSort, type ProviderAuthImportResult, type ProviderAuthPollRequest, type ProviderAuthPollResult, type ProviderAuthStartRequest, type ProviderAuthStartResult, type ProviderConfigUpdate, type ProviderConfigView, type ProviderConnectionTestRequest, type ProviderConnectionTestResult, type ProviderCreateRequest, type ProviderCreateResult, type ProviderDeleteResult, type ProviderSpecView, type RuntimeConfigUpdate, type SearchConfigUpdate, type SearchConfigView, type SearchProviderConfigView, type SearchProviderName, type SearchProviderSpecView, type SecretProviderEnvView, type SecretProviderExecView, type SecretProviderFileView, type SecretProviderView, type SecretRefView, type SecretSourceView, type SecretsConfigUpdate, type SecretsView, type SessionConfigView, type SessionEntryView, type SessionEventView, type SessionHistoryView, type SessionMessageView, type SessionPatchUpdate, SessionPatchValidationError, type SessionsListView, type UiChatRuntime, type UiNcpAgent, type UiNcpSessionListView, type UiNcpSessionMessagesView, type UiServerEvent, type UiServerHandle, type UiServerOptions, buildConfigMeta, buildConfigSchemaView, buildConfigView, createCustomProvider, createUiRouter, deleteCustomProvider, deleteSession, executeConfigAction, getSessionHistory, listSessions, loadConfigOrDefault, patchSession, startUiServer, testProviderConnection, updateChannel, updateModel, updateProvider, updateRuntime, updateSearch, updateSecrets };
1060
+ export { type AgentBindingView, type AgentProfileView, type ApiError, type ApiResponse, type AppMetaView, type AuthEnabledUpdateRequest, type AuthLoginRequest, type AuthPasswordUpdateRequest, type AuthSetupRequest, type AuthStatusView, type BindingPeerView, type BochaFreshnessValue, type ChannelSpecView, type ChatCapabilitiesView, type ChatCommandOptionView, type ChatCommandView, type ChatCommandsView, type ChatRunListView, type ChatRunState, type ChatRunView, type ChatSessionTypeOptionView, type ChatSessionTypesView, type ChatTurnRequest, type ChatTurnResult, type ChatTurnStopRequest, type ChatTurnStopResult, type ChatTurnStreamEvent, type ChatTurnView, type ConfigActionExecuteRequest, type ConfigActionExecuteResult, type ConfigActionManifest, type ConfigActionType, type ConfigMetaView, type ConfigSchemaResponse, type ConfigUiHint, type ConfigUiHints, type ConfigView, type CronActionResult, type CronEnableRequest, type CronJobStateView, type CronJobView, type CronListView, type CronPayloadView, type CronRunRequest, type CronScheduleView, DEFAULT_SESSION_TYPE, type MarketplaceApiConfig, type MarketplaceInstallKind, type MarketplaceInstallSkillParams, type MarketplaceInstallSpec, type MarketplaceInstalledRecord, type MarketplaceInstalledView, type MarketplaceInstaller, type MarketplaceItemSummary, type MarketplaceItemType, type MarketplaceItemView, type MarketplaceListView, type MarketplaceLocalizedTextMap, type MarketplaceMcpContentView, type MarketplaceMcpDoctorResult, type MarketplaceMcpInstallKind, type MarketplaceMcpInstallRequest, type MarketplaceMcpInstallResult, type MarketplaceMcpInstallSpec, type MarketplaceMcpManageAction, type MarketplaceMcpManageRequest, type MarketplaceMcpManageResult, type MarketplaceMcpTemplateInput, type MarketplacePluginContentView, type MarketplacePluginInstallKind, type MarketplacePluginInstallRequest, type MarketplacePluginInstallResult, type MarketplacePluginManageAction, type MarketplacePluginManageRequest, type MarketplacePluginManageResult, type MarketplaceRecommendationView, type MarketplaceSkillContentView, type MarketplaceSkillInstallKind, type MarketplaceSkillInstallRequest, type MarketplaceSkillInstallResult, type MarketplaceSkillManageAction, type MarketplaceSkillManageRequest, type MarketplaceSkillManageResult, type MarketplaceSort, type ProviderAuthImportResult, type ProviderAuthPollRequest, type ProviderAuthPollResult, type ProviderAuthStartRequest, type ProviderAuthStartResult, type ProviderConfigUpdate, type ProviderConfigView, type ProviderConnectionTestRequest, type ProviderConnectionTestResult, type ProviderCreateRequest, type ProviderCreateResult, type ProviderDeleteResult, type ProviderSpecView, type RuntimeConfigUpdate, type SearchConfigUpdate, type SearchConfigView, type SearchProviderConfigView, type SearchProviderName, type SearchProviderSpecView, type SecretProviderEnvView, type SecretProviderExecView, type SecretProviderFileView, type SecretProviderView, type SecretRefView, type SecretSourceView, type SecretsConfigUpdate, type SecretsView, type SessionConfigView, type SessionEntryView, type SessionEventView, type SessionHistoryView, type SessionMessageView, type SessionPatchUpdate, SessionPatchValidationError, type SessionsListView, type UiChatRuntime, type UiNcpAgent, type UiNcpSessionListView, type UiNcpSessionMessagesView, type UiServerEvent, type UiServerHandle, type UiServerOptions, buildConfigMeta, buildConfigSchemaView, buildConfigView, createCustomProvider, createUiRouter, deleteCustomProvider, deleteSession, executeConfigAction, getSessionHistory, listSessions, loadConfigOrDefault, patchSession, startUiServer, testProviderConnection, updateChannel, updateModel, updateProvider, updateRuntime, updateSearch, updateSecrets };
package/dist/index.js CHANGED
@@ -512,7 +512,7 @@ import {
512
512
  SessionManager,
513
513
  getWorkspacePathFromConfig,
514
514
  normalizeThinkingLevels,
515
- parseThinkingLevel as parseThinkingLevel2
515
+ parseThinkingLevel as parseThinkingLevel3
516
516
  } from "@nextclaw/core";
517
517
 
518
518
  // src/ui/provider-overrides.ts
@@ -639,6 +639,18 @@ function applySessionPreferencePatch(params) {
639
639
  return nextMetadata;
640
640
  }
641
641
 
642
+ // src/ui/session-list-metadata.ts
643
+ import { parseThinkingLevel as parseThinkingLevel2 } from "@nextclaw/core";
644
+ function readSessionListMetadata(metadata) {
645
+ const rawLabel = typeof metadata.label === "string" ? metadata.label.trim() : "";
646
+ const rawPreferredModel = typeof metadata.preferred_model === "string" ? metadata.preferred_model.trim() : "";
647
+ return {
648
+ label: rawLabel || void 0,
649
+ preferredModel: rawPreferredModel || void 0,
650
+ preferredThinking: parseThinkingLevel2(metadata.preferred_thinking) ?? null
651
+ };
652
+ }
653
+
642
654
  // src/ui/config.ts
643
655
  var MASK_MIN_LENGTH = 8;
644
656
  var EXTRA_SENSITIVE_PATH_PATTERNS = [/authorization/i, /cookie/i, /session/i, /bearer/i];
@@ -991,7 +1003,7 @@ function normalizeModelThinkingConfig(input) {
991
1003
  if (supported.length === 0) {
992
1004
  continue;
993
1005
  }
994
- const defaultLevel = parseThinkingLevel2(rawValue.default);
1006
+ const defaultLevel = parseThinkingLevel3(rawValue.default);
995
1007
  if (defaultLevel && supported.includes(defaultLevel)) {
996
1008
  normalized[model] = { supported, default: defaultLevel };
997
1009
  } else {
@@ -1578,8 +1590,7 @@ function listSessions(configPath, query) {
1578
1590
  const messages = session?.messages ?? [];
1579
1591
  const lastMessage = messages.length > 0 ? messages[messages.length - 1] : null;
1580
1592
  const metadata = item.metadata && typeof item.metadata === "object" ? item.metadata : {};
1581
- const label = typeof metadata.label === "string" ? metadata.label.trim() : "";
1582
- const preferredModel = typeof metadata.preferred_model === "string" ? metadata.preferred_model.trim() : "";
1593
+ const { label, preferredModel, preferredThinking } = readSessionListMetadata(metadata);
1583
1594
  const createdAt = typeof item.created_at === "string" ? item.created_at : (/* @__PURE__ */ new Date(0)).toISOString();
1584
1595
  const updatedAt = typeof item.updated_at === "string" ? item.updated_at : createdAt;
1585
1596
  const sessionType = readSessionType({
@@ -1594,8 +1605,9 @@ function listSessions(configPath, query) {
1594
1605
  key,
1595
1606
  createdAt,
1596
1607
  updatedAt,
1597
- label: label || void 0,
1598
- preferredModel: preferredModel || void 0,
1608
+ label,
1609
+ preferredModel,
1610
+ preferredThinking,
1599
1611
  sessionType,
1600
1612
  sessionTypeMutable,
1601
1613
  messageCount: messages.length,
@@ -3708,6 +3720,13 @@ async function fetchAllSkillMarketplaceItems(params) {
3708
3720
  query: params.query
3709
3721
  });
3710
3722
  }
3723
+ async function fetchAllMcpMarketplaceItems(params) {
3724
+ return fetchAllMarketplaceItems({
3725
+ baseUrl: params.baseUrl,
3726
+ path: "/api/v1/mcp/items",
3727
+ query: params.query
3728
+ });
3729
+ }
3711
3730
  function sanitizeMarketplaceListItems(items) {
3712
3731
  return items.map((item) => sanitizeMarketplaceItem(item));
3713
3732
  }
@@ -3715,6 +3734,216 @@ function sanitizeMarketplaceItemView(item) {
3715
3734
  return sanitizeMarketplaceItem(item);
3716
3735
  }
3717
3736
 
3737
+ // src/ui/router/marketplace/mcp.controller.ts
3738
+ import { McpInstalledViewService } from "@nextclaw/mcp";
3739
+ var McpMarketplaceController = class {
3740
+ constructor(options, marketplaceBaseUrl) {
3741
+ this.options = options;
3742
+ this.marketplaceBaseUrl = marketplaceBaseUrl;
3743
+ }
3744
+ getInstalled = (c) => {
3745
+ const service = new McpInstalledViewService({
3746
+ getConfig: () => loadConfigOrDefault(this.options.configPath)
3747
+ });
3748
+ const records = service.listInstalled().map((record) => ({
3749
+ type: "mcp",
3750
+ id: record.name,
3751
+ spec: record.catalogSlug ?? record.name,
3752
+ label: record.displayName ?? record.name,
3753
+ enabled: record.enabled,
3754
+ runtimeStatus: record.enabled ? "enabled" : "disabled",
3755
+ transport: record.transport,
3756
+ scope: record.scope,
3757
+ catalogSlug: record.catalogSlug,
3758
+ vendor: record.vendor,
3759
+ docsUrl: record.docsUrl,
3760
+ homepage: record.homepage,
3761
+ trustLevel: record.trustLevel,
3762
+ source: record.source,
3763
+ installedAt: record.installedAt,
3764
+ toolCount: record.toolCount,
3765
+ accessible: record.accessible,
3766
+ lastReadyAt: record.lastReadyAt,
3767
+ lastDoctorAt: record.lastReadyAt,
3768
+ lastError: record.lastError
3769
+ }));
3770
+ return c.json(ok({
3771
+ type: "mcp",
3772
+ total: records.length,
3773
+ specs: records.map((record) => record.spec),
3774
+ records
3775
+ }));
3776
+ };
3777
+ listItems = async (c) => {
3778
+ const query = c.req.query();
3779
+ const result = await fetchAllMcpMarketplaceItems({
3780
+ baseUrl: this.marketplaceBaseUrl,
3781
+ query: {
3782
+ q: query.q,
3783
+ tag: query.tag,
3784
+ sort: query.sort,
3785
+ page: query.page,
3786
+ pageSize: query.pageSize
3787
+ }
3788
+ });
3789
+ if (!result.ok) {
3790
+ return c.json(err("MARKETPLACE_UNAVAILABLE", result.message), result.status);
3791
+ }
3792
+ const items = sanitizeMarketplaceListItems(result.data.items).map((item) => normalizeMarketplaceItemForUi(item));
3793
+ const pageSize = Math.min(100, toPositiveInt(query.pageSize, 20));
3794
+ const requestedPage = toPositiveInt(query.page, 1);
3795
+ const totalPages = items.length === 0 ? 0 : Math.ceil(items.length / pageSize);
3796
+ const currentPage = totalPages === 0 ? 1 : Math.min(requestedPage, totalPages);
3797
+ return c.json(ok({
3798
+ total: items.length,
3799
+ page: currentPage,
3800
+ pageSize,
3801
+ totalPages,
3802
+ sort: result.data.sort,
3803
+ query: result.data.query,
3804
+ items: items.slice((currentPage - 1) * pageSize, currentPage * pageSize)
3805
+ }));
3806
+ };
3807
+ getItem = async (c) => {
3808
+ const slug = encodeURIComponent(c.req.param("slug"));
3809
+ const result = await fetchMarketplaceData({
3810
+ baseUrl: this.marketplaceBaseUrl,
3811
+ path: `/api/v1/mcp/items/${slug}`
3812
+ });
3813
+ if (!result.ok) {
3814
+ return c.json(err("MARKETPLACE_UNAVAILABLE", result.message), result.status);
3815
+ }
3816
+ return c.json(ok(normalizeMarketplaceItemForUi(sanitizeMarketplaceItemView(result.data))));
3817
+ };
3818
+ getItemContent = async (c) => {
3819
+ const slug = encodeURIComponent(c.req.param("slug"));
3820
+ const result = await fetchMarketplaceData({
3821
+ baseUrl: this.marketplaceBaseUrl,
3822
+ path: `/api/v1/mcp/items/${slug}/content`
3823
+ });
3824
+ if (!result.ok) {
3825
+ return c.json(err("MARKETPLACE_UNAVAILABLE", result.message), result.status);
3826
+ }
3827
+ return c.json(ok(result.data));
3828
+ };
3829
+ install = async (c) => {
3830
+ const body = await readJson(c.req.raw);
3831
+ if (!body.ok || !body.data || typeof body.data !== "object") {
3832
+ return c.json(err("INVALID_BODY", "invalid json body"), 400);
3833
+ }
3834
+ if (body.data.type && body.data.type !== "mcp") {
3835
+ return c.json(err("INVALID_BODY", "body.type does not match route type"), 400);
3836
+ }
3837
+ const slug = typeof body.data.spec === "string" ? body.data.spec.trim() : "";
3838
+ if (!slug) {
3839
+ return c.json(err("INVALID_BODY", "non-empty spec is required"), 400);
3840
+ }
3841
+ const installer = this.options.marketplace?.installer;
3842
+ if (!installer?.installMcp) {
3843
+ return c.json(err("NOT_AVAILABLE", "mcp installer is not configured"), 503);
3844
+ }
3845
+ const itemResult = await fetchMarketplaceData({
3846
+ baseUrl: this.marketplaceBaseUrl,
3847
+ path: `/api/v1/mcp/items/${encodeURIComponent(slug)}`
3848
+ });
3849
+ if (!itemResult.ok) {
3850
+ return c.json(err("MARKETPLACE_UNAVAILABLE", itemResult.message), itemResult.status);
3851
+ }
3852
+ const template = itemResult.data.install;
3853
+ if (template.kind !== "template") {
3854
+ return c.json(err("MARKETPLACE_CONTRACT_MISMATCH", `unsupported mcp install kind: ${template.kind}`), 502);
3855
+ }
3856
+ try {
3857
+ const result = await installer.installMcp({
3858
+ ...body.data,
3859
+ template
3860
+ });
3861
+ this.options.publish({ type: "config.updated", payload: { path: "mcp" } });
3862
+ return c.json(ok({
3863
+ type: "mcp",
3864
+ spec: slug,
3865
+ name: result.name,
3866
+ message: result.message,
3867
+ output: result.output
3868
+ }));
3869
+ } catch (error) {
3870
+ return c.json(err("INSTALL_FAILED", error instanceof Error ? error.message : String(error)), 400);
3871
+ }
3872
+ };
3873
+ manage = async (c) => {
3874
+ const body = await readJson(c.req.raw);
3875
+ if (!body.ok || !body.data || typeof body.data !== "object") {
3876
+ return c.json(err("INVALID_BODY", "invalid json body"), 400);
3877
+ }
3878
+ if (body.data.type && body.data.type !== "mcp") {
3879
+ return c.json(err("INVALID_BODY", "body.type does not match route type"), 400);
3880
+ }
3881
+ const target = typeof body.data.id === "string" && body.data.id.trim().length > 0 ? body.data.id.trim() : typeof body.data.spec === "string" && body.data.spec.trim().length > 0 ? body.data.spec.trim() : "";
3882
+ if (!target) {
3883
+ return c.json(err("INVALID_BODY", "non-empty id/spec is required"), 400);
3884
+ }
3885
+ const installer = this.options.marketplace?.installer;
3886
+ if (!installer) {
3887
+ return c.json(err("NOT_AVAILABLE", "marketplace installer is not configured"), 503);
3888
+ }
3889
+ try {
3890
+ const action = body.data.action;
3891
+ const result = action === "enable" ? await installer.enableMcp?.(target) : action === "disable" ? await installer.disableMcp?.(target) : await installer.removeMcp?.(target);
3892
+ if (!result) {
3893
+ return c.json(err("NOT_AVAILABLE", `mcp ${action} is not configured`), 503);
3894
+ }
3895
+ this.options.publish({ type: "config.updated", payload: { path: "mcp" } });
3896
+ return c.json(ok({
3897
+ type: "mcp",
3898
+ action,
3899
+ id: target,
3900
+ message: result.message,
3901
+ output: result.output
3902
+ }));
3903
+ } catch (error) {
3904
+ return c.json(err("MANAGE_FAILED", error instanceof Error ? error.message : String(error)), 400);
3905
+ }
3906
+ };
3907
+ doctor = async (c) => {
3908
+ const body = await readJson(c.req.raw);
3909
+ if (!body.ok || !body.data || typeof body.data !== "object") {
3910
+ return c.json(err("INVALID_BODY", "invalid json body"), 400);
3911
+ }
3912
+ const target = typeof body.data.name === "string" && body.data.name.trim().length > 0 ? body.data.name.trim() : typeof body.data.id === "string" && body.data.id.trim().length > 0 ? body.data.id.trim() : typeof body.data.spec === "string" && body.data.spec.trim().length > 0 ? body.data.spec.trim() : "";
3913
+ if (!target) {
3914
+ return c.json(err("INVALID_BODY", "name/id/spec is required"), 400);
3915
+ }
3916
+ const installer = this.options.marketplace?.installer;
3917
+ if (!installer?.doctorMcp) {
3918
+ return c.json(err("NOT_AVAILABLE", "mcp doctor is not configured"), 503);
3919
+ }
3920
+ try {
3921
+ const result = await installer.doctorMcp(target);
3922
+ return c.json(ok(result));
3923
+ } catch (error) {
3924
+ return c.json(err("DOCTOR_FAILED", error instanceof Error ? error.message : String(error)), 400);
3925
+ }
3926
+ };
3927
+ getRecommendations = async (c) => {
3928
+ const query = c.req.query();
3929
+ const result = await fetchMarketplaceData({
3930
+ baseUrl: this.marketplaceBaseUrl,
3931
+ path: "/api/v1/mcp/recommendations",
3932
+ query: {
3933
+ scene: query.scene,
3934
+ limit: query.limit
3935
+ }
3936
+ });
3937
+ if (!result.ok) {
3938
+ return c.json(err("MARKETPLACE_UNAVAILABLE", result.message), result.status);
3939
+ }
3940
+ return c.json(ok({
3941
+ ...result.data,
3942
+ items: sanitizeMarketplaceListItems(result.data.items).map((item) => normalizeMarketplaceItemForUi(item))
3943
+ }));
3944
+ };
3945
+ };
3946
+
3718
3947
  // src/ui/router/marketplace/installed.ts
3719
3948
  import * as NextclawCore3 from "@nextclaw/core";
3720
3949
  import { buildPluginStatusReport } from "@nextclaw/openclaw-compat";
@@ -4313,6 +4542,32 @@ var PluginMarketplaceController = class {
4313
4542
  };
4314
4543
  };
4315
4544
 
4545
+ // src/ui/router/marketplace/routes.ts
4546
+ function mountMarketplaceRoutes(app, controllers) {
4547
+ app.get("/api/marketplace/plugins/installed", controllers.plugin.getInstalled);
4548
+ app.get("/api/marketplace/plugins/items", controllers.plugin.listItems);
4549
+ app.get("/api/marketplace/plugins/items/:slug", controllers.plugin.getItem);
4550
+ app.get("/api/marketplace/plugins/items/:slug/content", controllers.plugin.getItemContent);
4551
+ app.post("/api/marketplace/plugins/install", controllers.plugin.install);
4552
+ app.post("/api/marketplace/plugins/manage", controllers.plugin.manage);
4553
+ app.get("/api/marketplace/plugins/recommendations", controllers.plugin.getRecommendations);
4554
+ app.get("/api/marketplace/skills/installed", controllers.skill.getInstalled);
4555
+ app.get("/api/marketplace/skills/items", controllers.skill.listItems);
4556
+ app.get("/api/marketplace/skills/items/:slug", controllers.skill.getItem);
4557
+ app.get("/api/marketplace/skills/items/:slug/content", controllers.skill.getItemContent);
4558
+ app.post("/api/marketplace/skills/install", controllers.skill.install);
4559
+ app.post("/api/marketplace/skills/manage", controllers.skill.manage);
4560
+ app.get("/api/marketplace/skills/recommendations", controllers.skill.getRecommendations);
4561
+ app.get("/api/marketplace/mcp/installed", controllers.mcp.getInstalled);
4562
+ app.get("/api/marketplace/mcp/items", controllers.mcp.listItems);
4563
+ app.get("/api/marketplace/mcp/items/:slug", controllers.mcp.getItem);
4564
+ app.get("/api/marketplace/mcp/items/:slug/content", controllers.mcp.getItemContent);
4565
+ app.post("/api/marketplace/mcp/install", controllers.mcp.install);
4566
+ app.post("/api/marketplace/mcp/manage", controllers.mcp.manage);
4567
+ app.post("/api/marketplace/mcp/doctor", controllers.mcp.doctor);
4568
+ app.get("/api/marketplace/mcp/recommendations", controllers.mcp.getRecommendations);
4569
+ }
4570
+
4316
4571
  // src/ui/router/marketplace/skill.controller.ts
4317
4572
  async function installMarketplaceSkill(params) {
4318
4573
  const spec = typeof params.body.spec === "string" ? params.body.spec.trim() : "";
@@ -4620,6 +4875,7 @@ function createUiRouter(options) {
4620
4875
  const ncpSessionController = new NcpSessionRoutesController(options);
4621
4876
  const pluginMarketplaceController = new PluginMarketplaceController(options, marketplaceBaseUrl);
4622
4877
  const skillMarketplaceController = new SkillMarketplaceController(options, marketplaceBaseUrl);
4878
+ const mcpMarketplaceController = new McpMarketplaceController(options, marketplaceBaseUrl);
4623
4879
  app.notFound((c) => c.json(err("NOT_FOUND", "endpoint not found"), 404));
4624
4880
  app.use("/api/*", async (c, next) => {
4625
4881
  const path = c.req.path;
@@ -4688,20 +4944,11 @@ function createUiRouter(options) {
4688
4944
  app.delete("/api/cron/:id", cronController.deleteJob);
4689
4945
  app.put("/api/cron/:id/enable", cronController.enableJob);
4690
4946
  app.post("/api/cron/:id/run", cronController.runJob);
4691
- app.get("/api/marketplace/plugins/installed", pluginMarketplaceController.getInstalled);
4692
- app.get("/api/marketplace/plugins/items", pluginMarketplaceController.listItems);
4693
- app.get("/api/marketplace/plugins/items/:slug", pluginMarketplaceController.getItem);
4694
- app.get("/api/marketplace/plugins/items/:slug/content", pluginMarketplaceController.getItemContent);
4695
- app.post("/api/marketplace/plugins/install", pluginMarketplaceController.install);
4696
- app.post("/api/marketplace/plugins/manage", pluginMarketplaceController.manage);
4697
- app.get("/api/marketplace/plugins/recommendations", pluginMarketplaceController.getRecommendations);
4698
- app.get("/api/marketplace/skills/installed", skillMarketplaceController.getInstalled);
4699
- app.get("/api/marketplace/skills/items", skillMarketplaceController.listItems);
4700
- app.get("/api/marketplace/skills/items/:slug", skillMarketplaceController.getItem);
4701
- app.get("/api/marketplace/skills/items/:slug/content", skillMarketplaceController.getItemContent);
4702
- app.post("/api/marketplace/skills/install", skillMarketplaceController.install);
4703
- app.post("/api/marketplace/skills/manage", skillMarketplaceController.manage);
4704
- app.get("/api/marketplace/skills/recommendations", skillMarketplaceController.getRecommendations);
4947
+ mountMarketplaceRoutes(app, {
4948
+ plugin: pluginMarketplaceController,
4949
+ skill: skillMarketplaceController,
4950
+ mcp: mcpMarketplaceController
4951
+ });
4705
4952
  return app;
4706
4953
  }
4707
4954
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/server",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "private": false,
5
5
  "description": "Nextclaw UI/API server.",
6
6
  "type": "module",
@@ -18,11 +18,12 @@
18
18
  "@hono/node-server": "^1.13.3",
19
19
  "hono": "^4.6.2",
20
20
  "ws": "^8.18.0",
21
+ "@nextclaw/mcp": "0.1.2",
21
22
  "@nextclaw/ncp": "0.3.1",
22
- "@nextclaw/core": "0.9.2",
23
- "@nextclaw/runtime": "0.2.2",
24
23
  "@nextclaw/ncp-http-agent-server": "0.3.1",
25
- "@nextclaw/openclaw-compat": "0.3.4"
24
+ "@nextclaw/openclaw-compat": "0.3.5",
25
+ "@nextclaw/runtime": "0.2.2",
26
+ "@nextclaw/core": "0.9.2"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/node": "^20.17.6",