@nextclaw/server 0.10.54 → 0.10.56
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/dist/index.d.ts +34 -1
- package/dist/index.js +89 -4
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,29 @@ import { NcpHttpAgentStreamProvider } from '@nextclaw/ncp-http-agent-server';
|
|
|
6
6
|
import { IncomingMessage } from 'node:http';
|
|
7
7
|
import { Hono } from 'hono';
|
|
8
8
|
|
|
9
|
+
type UiNcpStoredAttachmentRecord = {
|
|
10
|
+
id: string;
|
|
11
|
+
uri: string;
|
|
12
|
+
storageKey: string;
|
|
13
|
+
originalName: string;
|
|
14
|
+
storedName: string;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
sizeBytes: number;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
sha256: string;
|
|
19
|
+
};
|
|
20
|
+
type UiNcpAttachmentView = {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
mimeType: string;
|
|
24
|
+
sizeBytes: number;
|
|
25
|
+
attachmentUri: string;
|
|
26
|
+
url: string;
|
|
27
|
+
};
|
|
28
|
+
type UiNcpAttachmentUploadView = {
|
|
29
|
+
attachments: UiNcpAttachmentView[];
|
|
30
|
+
};
|
|
31
|
+
|
|
9
32
|
type MarketplaceItemType = "plugin" | "skill" | "mcp";
|
|
10
33
|
type MarketplaceSort = "relevance" | "updated";
|
|
11
34
|
type MarketplacePluginInstallKind = "npm";
|
|
@@ -942,6 +965,16 @@ type UiNcpAgent = {
|
|
|
942
965
|
streamProvider?: NcpHttpAgentStreamProvider;
|
|
943
966
|
sessionApi?: NcpSessionApi;
|
|
944
967
|
listSessionTypes?: (params?: SessionTypeDescribeParams) => Promise<ChatSessionTypesView> | ChatSessionTypesView;
|
|
968
|
+
attachmentApi?: {
|
|
969
|
+
saveAttachment: (input: {
|
|
970
|
+
fileName: string;
|
|
971
|
+
mimeType?: string | null;
|
|
972
|
+
bytes: Uint8Array;
|
|
973
|
+
createdAt?: Date;
|
|
974
|
+
}) => Promise<UiNcpStoredAttachmentRecord>;
|
|
975
|
+
statAttachment: (uri: string) => Promise<UiNcpStoredAttachmentRecord | null> | UiNcpStoredAttachmentRecord | null;
|
|
976
|
+
resolveContentPath: (uri: string) => string | null;
|
|
977
|
+
};
|
|
945
978
|
basePath?: string;
|
|
946
979
|
};
|
|
947
980
|
type ConfigView = {
|
|
@@ -1217,4 +1250,4 @@ declare function getUiBridgeSecretPath(): string;
|
|
|
1217
1250
|
declare function readUiBridgeSecret(): string | null;
|
|
1218
1251
|
declare function ensureUiBridgeSecret(): string;
|
|
1219
1252
|
|
|
1220
|
-
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 ChannelAuthPollRequest, type ChannelAuthPollResult, type ChannelAuthStartRequest, type ChannelAuthStartResult, type ChannelSpecView, type ChatCapabilitiesView, type ChatCommandOptionView, type ChatCommandView, type ChatCommandsView, type ChatRunListView, type ChatRunState, type ChatRunView, type ChatSessionTypeCtaView, 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 RemoteAccessView, type RemoteAccountView, type RemoteBrowserAuthPollRequest, type RemoteBrowserAuthPollResult, type RemoteBrowserAuthStartRequest, type RemoteBrowserAuthStartResult, type RemoteDoctorCheckView, type RemoteDoctorView, type RemoteLoginRequest, type RemoteRuntimeView, type RemoteServiceAction, type RemoteServiceActionResult, type RemoteServiceView, type RemoteSettingsUpdateRequest, type RemoteSettingsView, 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 SessionTypeDescribeParams, type SessionsListView, type UiChatRuntime, type UiNcpAgent, type UiNcpSessionListView, type UiNcpSessionMessagesView, type UiRemoteAccessHost, type UiServerEvent, type UiServerHandle, type UiServerOptions, buildConfigMeta, buildConfigSchemaView, buildConfigView, createCustomProvider, createUiRouter, deleteCustomProvider, deleteSession, ensureUiBridgeSecret, executeConfigAction, getSessionHistory, getUiBridgeSecretPath, listSessions, loadConfigOrDefault, patchSession, readUiBridgeSecret, startUiServer, testProviderConnection, updateChannel, updateModel, updateProvider, updateRuntime, updateSearch, updateSecrets };
|
|
1253
|
+
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 ChannelAuthPollRequest, type ChannelAuthPollResult, type ChannelAuthStartRequest, type ChannelAuthStartResult, type ChannelSpecView, type ChatCapabilitiesView, type ChatCommandOptionView, type ChatCommandView, type ChatCommandsView, type ChatRunListView, type ChatRunState, type ChatRunView, type ChatSessionTypeCtaView, 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 RemoteAccessView, type RemoteAccountView, type RemoteBrowserAuthPollRequest, type RemoteBrowserAuthPollResult, type RemoteBrowserAuthStartRequest, type RemoteBrowserAuthStartResult, type RemoteDoctorCheckView, type RemoteDoctorView, type RemoteLoginRequest, type RemoteRuntimeView, type RemoteServiceAction, type RemoteServiceActionResult, type RemoteServiceView, type RemoteSettingsUpdateRequest, type RemoteSettingsView, 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 SessionTypeDescribeParams, type SessionsListView, type UiChatRuntime, type UiNcpAgent, type UiNcpAttachmentUploadView, type UiNcpAttachmentView, type UiNcpSessionListView, type UiNcpSessionMessagesView, type UiNcpStoredAttachmentRecord, type UiRemoteAccessHost, type UiServerEvent, type UiServerHandle, type UiServerOptions, buildConfigMeta, buildConfigSchemaView, buildConfigView, createCustomProvider, createUiRouter, deleteCustomProvider, deleteSession, ensureUiBridgeSecret, executeConfigAction, getSessionHistory, getUiBridgeSecretPath, listSessions, loadConfigOrDefault, patchSession, readUiBridgeSecret, startUiServer, testProviderConnection, updateChannel, updateModel, updateProvider, updateRuntime, updateSearch, updateSecrets };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { compress } from "hono/compress";
|
|
|
4
4
|
import { serve } from "@hono/node-server";
|
|
5
5
|
import { WebSocketServer, WebSocket } from "ws";
|
|
6
6
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
7
|
-
import { readFile as
|
|
7
|
+
import { readFile as readFile3, stat } from "fs/promises";
|
|
8
8
|
import { join as join2 } from "path";
|
|
9
9
|
|
|
10
10
|
// src/ui/auth.service.ts
|
|
@@ -836,6 +836,7 @@ var PREFERRED_PROVIDER_ORDER = [
|
|
|
836
836
|
"anthropic",
|
|
837
837
|
"gemini",
|
|
838
838
|
"openrouter",
|
|
839
|
+
"dashscope-coding-plan",
|
|
839
840
|
"dashscope",
|
|
840
841
|
"deepseek",
|
|
841
842
|
"minimax",
|
|
@@ -3612,6 +3613,87 @@ var CronRoutesController = class {
|
|
|
3612
3613
|
};
|
|
3613
3614
|
};
|
|
3614
3615
|
|
|
3616
|
+
// src/ui/router/ncp-attachment.controller.ts
|
|
3617
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
3618
|
+
var ATTACHMENT_CONTENT_BASE_PATH = "/api/ncp/attachments/content";
|
|
3619
|
+
function buildAttachmentContentUrl(attachmentUri) {
|
|
3620
|
+
const query = new URLSearchParams({ uri: attachmentUri });
|
|
3621
|
+
return `${ATTACHMENT_CONTENT_BASE_PATH}?${query.toString()}`;
|
|
3622
|
+
}
|
|
3623
|
+
function encodeContentDispositionFileName(fileName) {
|
|
3624
|
+
return encodeURIComponent(fileName).replace(/\*/g, "%2A");
|
|
3625
|
+
}
|
|
3626
|
+
function toAttachmentView(record) {
|
|
3627
|
+
return {
|
|
3628
|
+
id: record.id,
|
|
3629
|
+
name: record.originalName,
|
|
3630
|
+
mimeType: record.mimeType,
|
|
3631
|
+
sizeBytes: record.sizeBytes,
|
|
3632
|
+
attachmentUri: record.uri,
|
|
3633
|
+
url: buildAttachmentContentUrl(record.uri)
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
var NcpAttachmentRoutesController = class {
|
|
3637
|
+
constructor(options) {
|
|
3638
|
+
this.options = options;
|
|
3639
|
+
}
|
|
3640
|
+
uploadAttachments = async (c) => {
|
|
3641
|
+
const attachmentApi = this.options.ncpAgent?.attachmentApi;
|
|
3642
|
+
if (!attachmentApi) {
|
|
3643
|
+
return c.json(err("NOT_AVAILABLE", "ncp attachment api unavailable"), 503);
|
|
3644
|
+
}
|
|
3645
|
+
let formData;
|
|
3646
|
+
try {
|
|
3647
|
+
formData = await c.req.raw.formData();
|
|
3648
|
+
} catch {
|
|
3649
|
+
return c.json(err("INVALID_BODY", "invalid multipart body"), 400);
|
|
3650
|
+
}
|
|
3651
|
+
const files = Array.from(formData.values()).reduce((result, value) => {
|
|
3652
|
+
if (typeof value !== "string") {
|
|
3653
|
+
result.push(value);
|
|
3654
|
+
}
|
|
3655
|
+
return result;
|
|
3656
|
+
}, []);
|
|
3657
|
+
if (files.length === 0) {
|
|
3658
|
+
return c.json(err("INVALID_BODY", "no files provided"), 400);
|
|
3659
|
+
}
|
|
3660
|
+
const attachments = [];
|
|
3661
|
+
for (const file of files) {
|
|
3662
|
+
const record = await attachmentApi.saveAttachment({
|
|
3663
|
+
fileName: file.name,
|
|
3664
|
+
mimeType: file.type || null,
|
|
3665
|
+
bytes: new Uint8Array(await file.arrayBuffer())
|
|
3666
|
+
});
|
|
3667
|
+
attachments.push(toAttachmentView(record));
|
|
3668
|
+
}
|
|
3669
|
+
const payload = { attachments };
|
|
3670
|
+
return c.json(ok(payload));
|
|
3671
|
+
};
|
|
3672
|
+
getAttachmentContent = async (c) => {
|
|
3673
|
+
const attachmentApi = this.options.ncpAgent?.attachmentApi;
|
|
3674
|
+
if (!attachmentApi) {
|
|
3675
|
+
return c.json(err("NOT_AVAILABLE", "ncp attachment api unavailable"), 503);
|
|
3676
|
+
}
|
|
3677
|
+
const uri = c.req.query("uri")?.trim();
|
|
3678
|
+
if (!uri) {
|
|
3679
|
+
return c.json(err("INVALID_URI", "attachment uri is required"), 400);
|
|
3680
|
+
}
|
|
3681
|
+
const record = await attachmentApi.statAttachment(uri);
|
|
3682
|
+
const contentPath = attachmentApi.resolveContentPath(uri);
|
|
3683
|
+
if (!record || !contentPath) {
|
|
3684
|
+
return c.json(err("NOT_FOUND", `attachment not found: ${uri}`), 404);
|
|
3685
|
+
}
|
|
3686
|
+
const body = await readFile2(contentPath);
|
|
3687
|
+
return new Response(body, {
|
|
3688
|
+
headers: {
|
|
3689
|
+
"content-length": String(body.byteLength),
|
|
3690
|
+
"content-type": record.mimeType || "application/octet-stream",
|
|
3691
|
+
"content-disposition": `inline; filename*=UTF-8''${encodeContentDispositionFileName(record.originalName)}`
|
|
3692
|
+
}
|
|
3693
|
+
});
|
|
3694
|
+
};
|
|
3695
|
+
};
|
|
3696
|
+
|
|
3615
3697
|
// src/ui/router/ncp-session.controller.ts
|
|
3616
3698
|
function readPositiveInt(value) {
|
|
3617
3699
|
if (typeof value !== "string") {
|
|
@@ -5388,7 +5470,7 @@ function registerSessionRoutes(app, sessionController) {
|
|
|
5388
5470
|
app.put("/api/sessions/:key", sessionController.patchSession);
|
|
5389
5471
|
app.delete("/api/sessions/:key", sessionController.deleteSession);
|
|
5390
5472
|
}
|
|
5391
|
-
function registerNcpRoutes(app, options, ncpSessionController) {
|
|
5473
|
+
function registerNcpRoutes(app, options, ncpSessionController, ncpAttachmentController) {
|
|
5392
5474
|
if (!options.ncpAgent) {
|
|
5393
5475
|
return;
|
|
5394
5476
|
}
|
|
@@ -5403,6 +5485,8 @@ function registerNcpRoutes(app, options, ncpSessionController) {
|
|
|
5403
5485
|
app.put("/api/ncp/sessions/:sessionId", ncpSessionController.patchSession);
|
|
5404
5486
|
app.get("/api/ncp/sessions/:sessionId/messages", ncpSessionController.listSessionMessages);
|
|
5405
5487
|
app.delete("/api/ncp/sessions/:sessionId", ncpSessionController.deleteSession);
|
|
5488
|
+
app.post("/api/ncp/attachments", ncpAttachmentController.uploadAttachments);
|
|
5489
|
+
app.get("/api/ncp/attachments/content", ncpAttachmentController.getAttachmentContent);
|
|
5406
5490
|
}
|
|
5407
5491
|
function registerCronRoutes(app, cronController) {
|
|
5408
5492
|
app.get("/api/cron", cronController.listJobs);
|
|
@@ -5434,6 +5518,7 @@ function createUiRouter(options) {
|
|
|
5434
5518
|
const sessionController = new SessionRoutesController(options);
|
|
5435
5519
|
const cronController = new CronRoutesController(options);
|
|
5436
5520
|
const ncpSessionController = new NcpSessionRoutesController(options);
|
|
5521
|
+
const ncpAttachmentController = new NcpAttachmentRoutesController(options);
|
|
5437
5522
|
const remoteController = options.remoteAccess ? new RemoteRoutesController(options.remoteAccess) : null;
|
|
5438
5523
|
const pluginMarketplaceController = new PluginMarketplaceController(options, marketplaceBaseUrl);
|
|
5439
5524
|
const skillMarketplaceController = new SkillMarketplaceController(options, marketplaceBaseUrl);
|
|
@@ -5458,7 +5543,7 @@ function createUiRouter(options) {
|
|
|
5458
5543
|
registerConfigRoutes(app, configController);
|
|
5459
5544
|
registerChatRoutes(app, chatController);
|
|
5460
5545
|
registerSessionRoutes(app, sessionController);
|
|
5461
|
-
registerNcpRoutes(app, options, ncpSessionController);
|
|
5546
|
+
registerNcpRoutes(app, options, ncpSessionController, ncpAttachmentController);
|
|
5462
5547
|
registerCronRoutes(app, cronController);
|
|
5463
5548
|
registerRemoteRoutes(app, remoteController);
|
|
5464
5549
|
mountMarketplaceRoutes(app, {
|
|
@@ -5584,7 +5669,7 @@ function startUiServer(options) {
|
|
|
5584
5669
|
join: join2,
|
|
5585
5670
|
getContent: async (path) => {
|
|
5586
5671
|
try {
|
|
5587
|
-
return await
|
|
5672
|
+
return await readFile3(path);
|
|
5588
5673
|
} catch {
|
|
5589
5674
|
return null;
|
|
5590
5675
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.56",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"hono": "^4.6.2",
|
|
20
20
|
"ws": "^8.18.0",
|
|
21
21
|
"@nextclaw/mcp": "0.1.50",
|
|
22
|
-
"@nextclaw/openclaw-compat": "0.3.30",
|
|
23
|
-
"@nextclaw/ncp": "0.3.2",
|
|
24
|
-
"@nextclaw/runtime": "0.2.15",
|
|
25
22
|
"@nextclaw/ncp-http-agent-server": "0.3.2",
|
|
26
|
-
"@nextclaw/
|
|
23
|
+
"@nextclaw/ncp": "0.3.2",
|
|
24
|
+
"@nextclaw/openclaw-compat": "0.3.32",
|
|
25
|
+
"@nextclaw/core": "0.11.1",
|
|
26
|
+
"@nextclaw/runtime": "0.2.15"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^20.17.6",
|