@nextclaw/server 0.6.12 → 0.7.0

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 +62 -1
  2. package/dist/index.js +2734 -2142
  3. package/package.json +4 -4
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as NextclawCore from '@nextclaw/core';
2
2
  import { ThinkingLevel, CronService, Config, ConfigActionExecuteRequest as ConfigActionExecuteRequest$1, ConfigActionExecuteResult as ConfigActionExecuteResult$1 } from '@nextclaw/core';
3
3
  import { Hono } from 'hono';
4
+ import { IncomingMessage } from 'node:http';
4
5
 
5
6
  type ApiError = {
6
7
  code: string;
@@ -133,6 +134,26 @@ type ProviderAuthImportResult = {
133
134
  source: "cli";
134
135
  expiresAt?: string;
135
136
  };
137
+ type AuthStatusView = {
138
+ enabled: boolean;
139
+ configured: boolean;
140
+ authenticated: boolean;
141
+ username?: string;
142
+ };
143
+ type AuthSetupRequest = {
144
+ username: string;
145
+ password: string;
146
+ };
147
+ type AuthLoginRequest = {
148
+ username: string;
149
+ password: string;
150
+ };
151
+ type AuthPasswordUpdateRequest = {
152
+ password: string;
153
+ };
154
+ type AuthEnabledUpdateRequest = {
155
+ enabled: boolean;
156
+ };
136
157
  type AgentProfileView = {
137
158
  id: string;
138
159
  default?: boolean;
@@ -820,6 +841,44 @@ type UiServerHandle = {
820
841
 
821
842
  declare function startUiServer(options: UiServerOptions): UiServerHandle;
822
843
 
844
+ declare class UiAuthService {
845
+ private readonly configPath;
846
+ private readonly sessions;
847
+ constructor(configPath: string);
848
+ private loadCurrentConfig;
849
+ private saveCurrentConfig;
850
+ private readAuthConfig;
851
+ private isConfigured;
852
+ isProtectionEnabled(): boolean;
853
+ private getSessionIdFromCookieHeader;
854
+ private getValidSession;
855
+ isRequestAuthenticated(request: Request): boolean;
856
+ isSocketAuthenticated(request: IncomingMessage): boolean;
857
+ getStatus(request: Request): AuthStatusView;
858
+ private createSession;
859
+ private clearAllSessions;
860
+ private deleteRequestSession;
861
+ private buildLoginCookie;
862
+ buildLogoutCookie(request: Request): string;
863
+ setup(request: Request, payload: AuthSetupRequest): {
864
+ status: AuthStatusView;
865
+ cookie: string;
866
+ };
867
+ login(request: Request, payload: AuthLoginRequest): {
868
+ status: AuthStatusView;
869
+ cookie: string;
870
+ };
871
+ logout(request: Request): void;
872
+ updatePassword(request: Request, payload: AuthPasswordUpdateRequest): {
873
+ status: AuthStatusView;
874
+ cookie?: string;
875
+ };
876
+ updateEnabled(request: Request, payload: AuthEnabledUpdateRequest): {
877
+ status: AuthStatusView;
878
+ cookie?: string;
879
+ };
880
+ }
881
+
823
882
  type UiRouterOptions = {
824
883
  configPath: string;
825
884
  productVersion?: string;
@@ -827,7 +886,9 @@ type UiRouterOptions = {
827
886
  marketplace?: MarketplaceApiConfig;
828
887
  cronService?: InstanceType<typeof NextclawCore.CronService>;
829
888
  chatRuntime?: UiChatRuntime;
889
+ authService?: UiAuthService;
830
890
  };
891
+
831
892
  declare function createUiRouter(options: UiRouterOptions): Hono;
832
893
 
833
894
  type ExecuteActionResult = {
@@ -874,4 +935,4 @@ declare function deleteSession(configPath: string, key: string): boolean;
874
935
  declare function updateRuntime(configPath: string, patch: RuntimeConfigUpdate): Pick<ConfigView, "agents" | "bindings" | "session">;
875
936
  declare function updateSecrets(configPath: string, patch: SecretsConfigUpdate): SecretsView;
876
937
 
877
- export { type AgentBindingView, type AgentProfileView, type ApiError, type ApiResponse, type AppMetaView, 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 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 };
938
+ 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 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 };