@nextclaw/server 0.10.0 → 0.10.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/dist/index.d.ts +1 -17
- package/dist/index.js +8 -67
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -658,20 +658,9 @@ type ChatCapabilitiesView = {
|
|
|
658
658
|
stopSupported: boolean;
|
|
659
659
|
stopReason?: string;
|
|
660
660
|
};
|
|
661
|
-
type ChatSessionTypeCtaView = {
|
|
662
|
-
kind: string;
|
|
663
|
-
label?: string;
|
|
664
|
-
href?: string;
|
|
665
|
-
};
|
|
666
661
|
type ChatSessionTypeOptionView = {
|
|
667
662
|
value: string;
|
|
668
663
|
label: string;
|
|
669
|
-
ready?: boolean;
|
|
670
|
-
reason?: string | null;
|
|
671
|
-
reasonMessage?: string | null;
|
|
672
|
-
supportedModels?: string[];
|
|
673
|
-
recommendedModel?: string | null;
|
|
674
|
-
cta?: ChatSessionTypeCtaView | null;
|
|
675
664
|
};
|
|
676
665
|
type ChatSessionTypesView = {
|
|
677
666
|
defaultType: string;
|
|
@@ -991,7 +980,6 @@ declare class UiAuthService {
|
|
|
991
980
|
private clearAllSessions;
|
|
992
981
|
private deleteRequestSession;
|
|
993
982
|
private buildLoginCookie;
|
|
994
|
-
buildTrustedRequestCookieHeader(): string | null;
|
|
995
983
|
buildLogoutCookie(request: Request): string;
|
|
996
984
|
setup(request: Request, payload: AuthSetupRequest): {
|
|
997
985
|
status: AuthStatusView;
|
|
@@ -1069,8 +1057,4 @@ declare function deleteSession(configPath: string, key: string): boolean;
|
|
|
1069
1057
|
declare function updateRuntime(configPath: string, patch: RuntimeConfigUpdate): Pick<ConfigView, "agents" | "bindings" | "session">;
|
|
1070
1058
|
declare function updateSecrets(configPath: string, patch: SecretsConfigUpdate): SecretsView;
|
|
1071
1059
|
|
|
1072
|
-
|
|
1073
|
-
declare function readUiBridgeSecret(): string | null;
|
|
1074
|
-
declare function ensureUiBridgeSecret(): string;
|
|
1075
|
-
|
|
1076
|
-
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 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 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, ensureUiBridgeSecret, executeConfigAction, getSessionHistory, getUiBridgeSecretPath, listSessions, loadConfigOrDefault, patchSession, readUiBridgeSecret, 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
|
@@ -4,9 +4,9 @@ import { compress } from "hono/compress";
|
|
|
4
4
|
import { cors } from "hono/cors";
|
|
5
5
|
import { serve } from "@hono/node-server";
|
|
6
6
|
import { WebSocketServer, WebSocket } from "ws";
|
|
7
|
-
import { existsSync
|
|
7
|
+
import { existsSync, readFileSync } from "fs";
|
|
8
8
|
import { readFile as readFile2, stat } from "fs/promises";
|
|
9
|
-
import { join
|
|
9
|
+
import { join } from "path";
|
|
10
10
|
|
|
11
11
|
// src/ui/auth.service.ts
|
|
12
12
|
import { ConfigSchema, loadConfig, saveConfig } from "@nextclaw/core";
|
|
@@ -179,18 +179,6 @@ var UiAuthService = class {
|
|
|
179
179
|
secure: resolveSecureRequest(request.url, request.headers.get("x-forwarded-proto"))
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
buildTrustedRequestCookieHeader() {
|
|
183
|
-
const auth = this.readAuthConfig();
|
|
184
|
-
if (!auth.enabled || !this.isConfigured(auth)) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
const username = normalizeUsername(auth.username);
|
|
188
|
-
if (!username) {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
const sessionId = this.createSession(username);
|
|
192
|
-
return `${SESSION_COOKIE_NAME}=${encodeURIComponent(sessionId)}`;
|
|
193
|
-
}
|
|
194
182
|
buildLogoutCookie(request) {
|
|
195
183
|
return buildSetCookie({
|
|
196
184
|
value: "",
|
|
@@ -405,39 +393,6 @@ var AppRoutesController = class {
|
|
|
405
393
|
appMeta = (c) => c.json(ok(buildAppMetaView(this.options)));
|
|
406
394
|
};
|
|
407
395
|
|
|
408
|
-
// src/ui/auth-bridge.ts
|
|
409
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
410
|
-
import { join } from "path";
|
|
411
|
-
import { randomBytes as randomBytes2 } from "crypto";
|
|
412
|
-
import { getDataDir } from "@nextclaw/core";
|
|
413
|
-
var REMOTE_BRIDGE_DIR = join(getDataDir(), "remote");
|
|
414
|
-
var REMOTE_BRIDGE_SECRET_PATH = join(REMOTE_BRIDGE_DIR, "ui-bridge-secret");
|
|
415
|
-
function getUiBridgeSecretPath() {
|
|
416
|
-
return REMOTE_BRIDGE_SECRET_PATH;
|
|
417
|
-
}
|
|
418
|
-
function readUiBridgeSecret() {
|
|
419
|
-
if (!existsSync(REMOTE_BRIDGE_SECRET_PATH)) {
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
try {
|
|
423
|
-
const raw = readFileSync(REMOTE_BRIDGE_SECRET_PATH, "utf-8").trim();
|
|
424
|
-
return raw.length > 0 ? raw : null;
|
|
425
|
-
} catch {
|
|
426
|
-
return null;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
function ensureUiBridgeSecret() {
|
|
430
|
-
const existing = readUiBridgeSecret();
|
|
431
|
-
if (existing) {
|
|
432
|
-
return existing;
|
|
433
|
-
}
|
|
434
|
-
mkdirSync(REMOTE_BRIDGE_DIR, { recursive: true });
|
|
435
|
-
const secret = randomBytes2(24).toString("hex");
|
|
436
|
-
writeFileSync(REMOTE_BRIDGE_SECRET_PATH, `${secret}
|
|
437
|
-
`, "utf-8");
|
|
438
|
-
return secret;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
396
|
// src/ui/router/auth.controller.ts
|
|
442
397
|
function isAuthenticationRequiredError(message) {
|
|
443
398
|
return message === "Authentication required.";
|
|
@@ -537,16 +492,6 @@ var AuthRoutesController = class {
|
|
|
537
492
|
return c.json(err(code, message), status);
|
|
538
493
|
}
|
|
539
494
|
};
|
|
540
|
-
issueBridgeSession = (c) => {
|
|
541
|
-
const providedSecret = c.req.header("x-nextclaw-ui-bridge-secret")?.trim();
|
|
542
|
-
const expectedSecret = ensureUiBridgeSecret();
|
|
543
|
-
if (!providedSecret || providedSecret !== expectedSecret) {
|
|
544
|
-
return c.json(err("FORBIDDEN", "Invalid bridge secret."), 403);
|
|
545
|
-
}
|
|
546
|
-
return c.json(ok({
|
|
547
|
-
cookie: this.authService.buildTrustedRequestCookieHeader()
|
|
548
|
-
}));
|
|
549
|
-
};
|
|
550
495
|
};
|
|
551
496
|
|
|
552
497
|
// src/ui/router/chat.controller.ts
|
|
@@ -2496,7 +2441,7 @@ var ChatRoutesController = class {
|
|
|
2496
2441
|
};
|
|
2497
2442
|
|
|
2498
2443
|
// src/ui/provider-auth.ts
|
|
2499
|
-
import { createHash, randomBytes as
|
|
2444
|
+
import { createHash, randomBytes as randomBytes2, randomUUID as randomUUID2 } from "crypto";
|
|
2500
2445
|
import { readFile } from "fs/promises";
|
|
2501
2446
|
import { homedir } from "os";
|
|
2502
2447
|
import { isAbsolute, resolve } from "path";
|
|
@@ -2524,7 +2469,7 @@ function toBase64Url(buffer) {
|
|
|
2524
2469
|
return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
2525
2470
|
}
|
|
2526
2471
|
function buildPkce() {
|
|
2527
|
-
const verifier = toBase64Url(
|
|
2472
|
+
const verifier = toBase64Url(randomBytes2(48));
|
|
2528
2473
|
const challenge = toBase64Url(createHash("sha256").update(verifier).digest());
|
|
2529
2474
|
return { verifier, challenge };
|
|
2530
2475
|
}
|
|
@@ -2741,7 +2686,7 @@ async function startProviderAuth(configPath, providerName, options) {
|
|
|
2741
2686
|
if (!pkce) {
|
|
2742
2687
|
throw new Error("MiniMax OAuth requires PKCE");
|
|
2743
2688
|
}
|
|
2744
|
-
const state = toBase64Url(
|
|
2689
|
+
const state = toBase64Url(randomBytes2(16));
|
|
2745
2690
|
const body = new URLSearchParams({
|
|
2746
2691
|
response_type: "code",
|
|
2747
2692
|
client_id: resolvedMethod.clientId,
|
|
@@ -4953,7 +4898,6 @@ function createUiRouter(options) {
|
|
|
4953
4898
|
app.post("/api/auth/logout", authController.logout);
|
|
4954
4899
|
app.put("/api/auth/password", authController.updatePassword);
|
|
4955
4900
|
app.put("/api/auth/enabled", authController.updateEnabled);
|
|
4956
|
-
app.post("/api/auth/bridge", authController.issueBridgeSession);
|
|
4957
4901
|
app.get("/api/config", configController.getConfig);
|
|
4958
4902
|
app.get("/api/config/meta", configController.getConfigMeta);
|
|
4959
4903
|
app.get("/api/config/schema", configController.getConfigSchema);
|
|
@@ -5048,13 +4992,13 @@ function startUiServer(options) {
|
|
|
5048
4992
|
})
|
|
5049
4993
|
);
|
|
5050
4994
|
const staticDir = options.staticDir;
|
|
5051
|
-
if (staticDir &&
|
|
5052
|
-
const indexHtml =
|
|
4995
|
+
if (staticDir && existsSync(join(staticDir, "index.html"))) {
|
|
4996
|
+
const indexHtml = readFileSync(join(staticDir, "index.html"), "utf-8");
|
|
5053
4997
|
app.use(
|
|
5054
4998
|
"/*",
|
|
5055
4999
|
serveStatic({
|
|
5056
5000
|
root: staticDir,
|
|
5057
|
-
join
|
|
5001
|
+
join,
|
|
5058
5002
|
getContent: async (path) => {
|
|
5059
5003
|
try {
|
|
5060
5004
|
return await readFile2(path);
|
|
@@ -5129,14 +5073,11 @@ export {
|
|
|
5129
5073
|
createUiRouter,
|
|
5130
5074
|
deleteCustomProvider,
|
|
5131
5075
|
deleteSession,
|
|
5132
|
-
ensureUiBridgeSecret,
|
|
5133
5076
|
executeConfigAction,
|
|
5134
5077
|
getSessionHistory,
|
|
5135
|
-
getUiBridgeSecretPath,
|
|
5136
5078
|
listSessions,
|
|
5137
5079
|
loadConfigOrDefault,
|
|
5138
5080
|
patchSession,
|
|
5139
|
-
readUiBridgeSecret,
|
|
5140
5081
|
startUiServer,
|
|
5141
5082
|
testProviderConnection,
|
|
5142
5083
|
updateChannel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"@hono/node-server": "^1.13.3",
|
|
19
19
|
"hono": "^4.6.2",
|
|
20
20
|
"ws": "^8.18.0",
|
|
21
|
-
"@nextclaw/core": "0.9.2",
|
|
22
|
-
"@nextclaw/ncp-http-agent-server": "0.3.1",
|
|
23
|
-
"@nextclaw/mcp": "0.1.1",
|
|
24
|
-
"@nextclaw/ncp": "0.3.1",
|
|
25
21
|
"@nextclaw/openclaw-compat": "0.3.5",
|
|
26
|
-
"@nextclaw/
|
|
22
|
+
"@nextclaw/ncp": "0.3.1",
|
|
23
|
+
"@nextclaw/ncp-http-agent-server": "0.3.1",
|
|
24
|
+
"@nextclaw/runtime": "0.2.2",
|
|
25
|
+
"@nextclaw/core": "0.9.2",
|
|
26
|
+
"@nextclaw/mcp": "0.1.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^20.17.6",
|