@downcity/city 1.1.32 → 1.1.47
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/README.md +4 -9
- package/bin/cli/Index.js +10 -3
- package/bin/cli/Index.js.map +1 -1
- package/bin/cli/agent/AgentChat.d.ts +2 -1
- package/bin/cli/agent/AgentChat.d.ts.map +1 -1
- package/bin/cli/agent/AgentChat.js +93 -214
- package/bin/cli/agent/AgentChat.js.map +1 -1
- package/bin/cli/agent/AgentChatTypes.d.ts +8 -12
- package/bin/cli/agent/AgentChatTypes.d.ts.map +1 -1
- package/bin/cli/agent/AgentHistory.js +2 -2
- package/bin/cli/agent/AgentHistory.js.map +1 -1
- package/bin/cli/agent/AgentManager.d.ts.map +1 -1
- package/bin/cli/agent/AgentManager.js +26 -27
- package/bin/cli/agent/AgentManager.js.map +1 -1
- package/bin/cli/agent/AgentManagerTypes.d.ts +2 -2
- package/bin/cli/agent/AgentManagerTypes.d.ts.map +1 -1
- package/bin/cli/agent/AgentReset.js +4 -4
- package/bin/cli/agent/AgentReset.js.map +1 -1
- package/bin/cli/agent/AgentSelection.js +6 -6
- package/bin/cli/agent/AgentSelection.js.map +1 -1
- package/bin/cli/agent/AgentSelectionTypes.d.ts +1 -1
- package/bin/cli/agent/AgentSelectionTypes.d.ts.map +1 -1
- package/bin/cli/agent/Init.d.ts.map +1 -1
- package/bin/cli/agent/Init.js +17 -17
- package/bin/cli/agent/Init.js.map +1 -1
- package/bin/cli/agent/Restart.js +2 -2
- package/bin/cli/agent/Restart.js.map +1 -1
- package/bin/cli/agent/Run.d.ts +1 -1
- package/bin/cli/agent/Run.d.ts.map +1 -1
- package/bin/cli/agent/Run.js +44 -30
- package/bin/cli/agent/Run.js.map +1 -1
- package/bin/cli/agent/Start.js +2 -2
- package/bin/cli/agent/Start.js.map +1 -1
- package/bin/cli/agent/Stop.js +2 -2
- package/bin/cli/agent/Stop.js.map +1 -1
- package/bin/cli/control-plane/ControlPlaneProcess.d.ts.map +1 -1
- package/bin/cli/control-plane/ControlPlaneProcess.js +7 -8
- package/bin/cli/control-plane/ControlPlaneProcess.js.map +1 -1
- package/bin/cli/model/ModelCreateCommand.js +1 -1
- package/bin/cli/model/ModelCreateCommand.js.map +1 -1
- package/bin/cli/model/ModelManageCommand.d.ts.map +1 -1
- package/bin/cli/model/ModelManageCommand.js +5 -3
- package/bin/cli/model/ModelManageCommand.js.map +1 -1
- package/bin/cli/model/ModelManager.js +3 -3
- package/bin/cli/model/ModelManager.js.map +1 -1
- package/bin/cli/model/ModelSupport.d.ts +0 -1
- package/bin/cli/model/ModelSupport.d.ts.map +1 -1
- package/bin/cli/model/ModelSupport.js +2 -11
- package/bin/cli/model/ModelSupport.js.map +1 -1
- package/bin/cli/shared/ChatAuth.d.ts.map +1 -1
- package/bin/cli/shared/ChatAuth.js +5 -7
- package/bin/cli/shared/ChatAuth.js.map +1 -1
- package/bin/cli/shared/ChatManager.d.ts.map +1 -1
- package/bin/cli/shared/ChatManager.js +2 -3
- package/bin/cli/shared/ChatManager.js.map +1 -1
- package/bin/cli/shared/CliReporterTypes.d.ts +1 -1
- package/bin/cli/shared/Config.js +2 -2
- package/bin/cli/shared/Config.js.map +1 -1
- package/bin/cli/shared/Env.d.ts +1 -1
- package/bin/cli/shared/Env.d.ts.map +1 -1
- package/bin/cli/shared/Env.js +18 -149
- package/bin/cli/shared/Env.js.map +1 -1
- package/bin/cli/shared/IndexAgentCommand.d.ts.map +1 -1
- package/bin/cli/shared/IndexAgentCommand.js +3 -3
- package/bin/cli/shared/IndexAgentCommand.js.map +1 -1
- package/bin/cli/shared/IndexSupport.d.ts +3 -3
- package/bin/cli/shared/IndexSupport.d.ts.map +1 -1
- package/bin/cli/shared/IndexSupport.js +14 -8
- package/bin/cli/shared/IndexSupport.js.map +1 -1
- package/bin/cli/shared/ManagedPluginActionCommands.d.ts +2 -1
- package/bin/cli/shared/ManagedPluginActionCommands.d.ts.map +1 -1
- package/bin/cli/shared/ManagedPluginActionCommands.js +9 -7
- package/bin/cli/shared/ManagedPluginActionCommands.js.map +1 -1
- package/bin/cli/shared/ManagedPluginRemote.d.ts.map +1 -1
- package/bin/cli/shared/ManagedPluginRemote.js +4 -4
- package/bin/cli/shared/ManagedPluginRemote.js.map +1 -1
- package/bin/cli/shared/PluginScheduleCommand.d.ts +3 -2
- package/bin/cli/shared/PluginScheduleCommand.d.ts.map +1 -1
- package/bin/cli/shared/PluginScheduleCommand.js +11 -10
- package/bin/cli/shared/PluginScheduleCommand.js.map +1 -1
- package/bin/cli/shared/PluginTargetSupport.d.ts +6 -6
- package/bin/cli/shared/PluginTargetSupport.d.ts.map +1 -1
- package/bin/cli/shared/PluginTargetSupport.js +23 -24
- package/bin/cli/shared/PluginTargetSupport.js.map +1 -1
- package/bin/cli/shared/Plugins.d.ts.map +1 -1
- package/bin/cli/shared/Plugins.js +22 -16
- package/bin/cli/shared/Plugins.js.map +1 -1
- package/bin/cli/shared/PublicHostEnv.d.ts +1 -1
- package/bin/cli/shared/PublicHostEnv.js +2 -2
- package/bin/cli/shared/PublicHostEnv.js.map +1 -1
- package/bin/cli/shared/Terminal.d.ts +13 -0
- package/bin/cli/shared/Terminal.d.ts.map +1 -0
- package/bin/cli/shared/Terminal.js +22 -0
- package/bin/cli/shared/Terminal.js.map +1 -0
- package/bin/config/DowncitySchema.d.ts.map +1 -1
- package/bin/config/DowncitySchema.js +3 -111
- package/bin/config/DowncitySchema.js.map +1 -1
- package/bin/config/Paths.d.ts +0 -56
- package/bin/config/Paths.d.ts.map +1 -1
- package/bin/config/Paths.js +9 -51
- package/bin/config/Paths.js.map +1 -1
- package/bin/control/ChannelAccountApiRoutes.d.ts.map +1 -1
- package/bin/control/ChannelAccountApiRoutes.js +2 -3
- package/bin/control/ChannelAccountApiRoutes.js.map +1 -1
- package/bin/control/ControlGateway.d.ts.map +1 -1
- package/bin/control/ControlGateway.js +4 -3
- package/bin/control/ControlGateway.js.map +1 -1
- package/bin/control/EnvApiRoutes.d.ts +1 -1
- package/bin/control/EnvApiRoutes.d.ts.map +1 -1
- package/bin/control/EnvApiRoutes.js +7 -79
- package/bin/control/EnvApiRoutes.js.map +1 -1
- package/bin/control/PlatformApiRoutes.d.ts +2 -2
- package/bin/control/PlatformApiRoutes.d.ts.map +1 -1
- package/bin/control/PlatformApiRoutes.js +2 -2
- package/bin/control/PlatformApiRoutes.js.map +1 -1
- package/bin/control/PluginApiRoutes.d.ts.map +1 -1
- package/bin/control/PluginApiRoutes.js +33 -25
- package/bin/control/PluginApiRoutes.js.map +1 -1
- package/bin/control/gateway/AgentActions.d.ts +2 -2
- package/bin/control/gateway/AgentActions.d.ts.map +1 -1
- package/bin/control/gateway/AgentActions.js +23 -18
- package/bin/control/gateway/AgentActions.js.map +1 -1
- package/bin/control/gateway/AgentCatalog.d.ts +3 -6
- package/bin/control/gateway/AgentCatalog.d.ts.map +1 -1
- package/bin/control/gateway/AgentCatalog.js +16 -18
- package/bin/control/gateway/AgentCatalog.js.map +1 -1
- package/bin/control/instant/InstantSessionRunner.d.ts.map +1 -1
- package/bin/control/instant/InstantSessionRunner.js +3 -1
- package/bin/control/instant/InstantSessionRunner.js.map +1 -1
- package/bin/env/ProcessEnv.d.ts +24 -0
- package/bin/env/ProcessEnv.d.ts.map +1 -0
- package/bin/env/ProcessEnv.js +41 -0
- package/bin/env/ProcessEnv.js.map +1 -0
- package/bin/http/auth/AuthEnv.d.ts +1 -1
- package/bin/http/auth/AuthEnv.js +1 -1
- package/bin/model/runtime/CreateRuntimeModel.d.ts +6 -6
- package/bin/model/runtime/CreateRuntimeModel.d.ts.map +1 -1
- package/bin/model/runtime/CreateRuntimeModel.js +44 -53
- package/bin/model/runtime/CreateRuntimeModel.js.map +1 -1
- package/bin/model/runtime/ExecutionModelBinding.d.ts +46 -0
- package/bin/model/runtime/ExecutionModelBinding.d.ts.map +1 -0
- package/bin/model/runtime/ExecutionModelBinding.js +96 -0
- package/bin/model/runtime/ExecutionModelBinding.js.map +1 -0
- package/bin/model/service/ModelPoolService.d.ts +1 -1
- package/bin/model/service/ModelPoolService.d.ts.map +1 -1
- package/bin/model/service/ModelPoolService.js +8 -6
- package/bin/model/service/ModelPoolService.js.map +1 -1
- package/bin/platform/store/StoreEnvRepository.d.ts +5 -49
- package/bin/platform/store/StoreEnvRepository.d.ts.map +1 -1
- package/bin/platform/store/StoreEnvRepository.js +31 -178
- package/bin/platform/store/StoreEnvRepository.js.map +1 -1
- package/bin/platform/store/StoreSchema.js +3 -44
- package/bin/platform/store/StoreSchema.js.map +1 -1
- package/bin/platform/store/index.d.ts +9 -45
- package/bin/platform/store/index.d.ts.map +1 -1
- package/bin/platform/store/index.js +12 -62
- package/bin/platform/store/index.js.map +1 -1
- package/bin/platform/store/schema.d.ts +2 -2
- package/bin/platform/store/schema.js +2 -2
- package/bin/process/daemon/Api.d.ts +1 -1
- package/bin/process/daemon/CliArgs.d.ts +1 -0
- package/bin/process/daemon/CliArgs.d.ts.map +1 -1
- package/bin/process/daemon/CliArgs.js +20 -1
- package/bin/process/daemon/CliArgs.js.map +1 -1
- package/bin/process/daemon/Client.d.ts +18 -2
- package/bin/process/daemon/Client.d.ts.map +1 -1
- package/bin/process/daemon/Client.js +70 -20
- package/bin/process/daemon/Client.js.map +1 -1
- package/bin/process/daemon/Manager.d.ts.map +1 -1
- package/bin/process/daemon/Manager.js +2 -1
- package/bin/process/daemon/Manager.js.map +1 -1
- package/bin/process/registry/AgentHostRuntime.d.ts +1 -9
- package/bin/process/registry/AgentHostRuntime.d.ts.map +1 -1
- package/bin/process/registry/AgentHostRuntime.js +1 -155
- package/bin/process/registry/AgentHostRuntime.js.map +1 -1
- package/bin/terminal/admin/auth-error.d.ts +34 -0
- package/bin/terminal/admin/auth-error.d.ts.map +1 -0
- package/bin/terminal/admin/auth-error.js +51 -0
- package/bin/terminal/admin/auth-error.js.map +1 -0
- package/bin/terminal/admin/commands/accounts.d.ts +6 -0
- package/bin/terminal/admin/commands/accounts.d.ts.map +1 -0
- package/bin/terminal/admin/commands/accounts.js +44 -0
- package/bin/terminal/admin/commands/accounts.js.map +1 -0
- package/bin/terminal/admin/commands/balance.d.ts +6 -0
- package/bin/terminal/admin/commands/balance.d.ts.map +1 -0
- package/bin/terminal/admin/commands/balance.js +153 -0
- package/bin/terminal/admin/commands/balance.js.map +1 -0
- package/bin/terminal/admin/commands/config.d.ts +10 -0
- package/bin/terminal/admin/commands/config.d.ts.map +1 -0
- package/bin/terminal/admin/commands/config.js +11 -0
- package/bin/terminal/admin/commands/config.js.map +1 -0
- package/bin/terminal/admin/commands/custom.d.ts +6 -0
- package/bin/terminal/admin/commands/custom.d.ts.map +1 -0
- package/bin/terminal/admin/commands/custom.js +47 -0
- package/bin/terminal/admin/commands/custom.js.map +1 -0
- package/bin/terminal/admin/commands/instruction.d.ts +9 -0
- package/bin/terminal/admin/commands/instruction.d.ts.map +1 -0
- package/bin/terminal/admin/commands/instruction.js +10 -0
- package/bin/terminal/admin/commands/instruction.js.map +1 -0
- package/bin/terminal/admin/commands/models.d.ts +14 -0
- package/bin/terminal/admin/commands/models.d.ts.map +1 -0
- package/bin/terminal/admin/commands/models.js +61 -0
- package/bin/terminal/admin/commands/models.js.map +1 -0
- package/bin/terminal/admin/commands/payment.d.ts +6 -0
- package/bin/terminal/admin/commands/payment.d.ts.map +1 -0
- package/bin/terminal/admin/commands/payment.js +59 -0
- package/bin/terminal/admin/commands/payment.js.map +1 -0
- package/bin/terminal/admin/commands/products.d.ts +6 -0
- package/bin/terminal/admin/commands/products.d.ts.map +1 -0
- package/bin/terminal/admin/commands/products.js +80 -0
- package/bin/terminal/admin/commands/products.js.map +1 -0
- package/bin/terminal/admin/commands/service-env.d.ts +11 -0
- package/bin/terminal/admin/commands/service-env.d.ts.map +1 -0
- package/bin/terminal/admin/commands/service-env.js +248 -0
- package/bin/terminal/admin/commands/service-env.js.map +1 -0
- package/bin/terminal/admin/commands/usage.d.ts +6 -0
- package/bin/terminal/admin/commands/usage.d.ts.map +1 -0
- package/bin/terminal/admin/commands/usage.js +44 -0
- package/bin/terminal/admin/commands/usage.js.map +1 -0
- package/bin/terminal/admin/loop.d.ts +6 -0
- package/bin/terminal/admin/loop.d.ts.map +1 -0
- package/bin/terminal/admin/loop.js +70 -0
- package/bin/terminal/admin/loop.js.map +1 -0
- package/bin/terminal/agent/pi-agent.d.ts +15 -0
- package/bin/terminal/agent/pi-agent.d.ts.map +1 -0
- package/bin/terminal/agent/pi-agent.js +136 -0
- package/bin/terminal/agent/pi-agent.js.map +1 -0
- package/bin/terminal/app.d.ts +13 -0
- package/bin/terminal/app.d.ts.map +1 -0
- package/bin/terminal/app.js +123 -0
- package/bin/terminal/app.js.map +1 -0
- package/bin/terminal/auth/admin.d.ts +8 -0
- package/bin/terminal/auth/admin.d.ts.map +1 -0
- package/bin/terminal/auth/admin.js +18 -0
- package/bin/terminal/auth/admin.js.map +1 -0
- package/bin/terminal/auth/mode-select.d.ts +11 -0
- package/bin/terminal/auth/mode-select.d.ts.map +1 -0
- package/bin/terminal/auth/mode-select.js +33 -0
- package/bin/terminal/auth/mode-select.js.map +1 -0
- package/bin/terminal/auth/server-switch.d.ts +22 -0
- package/bin/terminal/auth/server-switch.d.ts.map +1 -0
- package/bin/terminal/auth/server-switch.js +241 -0
- package/bin/terminal/auth/server-switch.js.map +1 -0
- package/bin/terminal/auth/user.d.ts +19 -0
- package/bin/terminal/auth/user.d.ts.map +1 -0
- package/bin/terminal/auth/user.js +261 -0
- package/bin/terminal/auth/user.js.map +1 -0
- package/bin/terminal/core/browser.d.ts +12 -0
- package/bin/terminal/core/browser.d.ts.map +1 -0
- package/bin/terminal/core/browser.js +29 -0
- package/bin/terminal/core/browser.js.map +1 -0
- package/bin/terminal/core/env.d.ts +15 -0
- package/bin/terminal/core/env.d.ts.map +1 -0
- package/bin/terminal/core/env.js +67 -0
- package/bin/terminal/core/env.js.map +1 -0
- package/bin/terminal/core/session.d.ts +97 -0
- package/bin/terminal/core/session.d.ts.map +1 -0
- package/bin/terminal/core/session.js +342 -0
- package/bin/terminal/core/session.js.map +1 -0
- package/bin/terminal/core/stripe.d.ts +26 -0
- package/bin/terminal/core/stripe.d.ts.map +1 -0
- package/bin/terminal/core/stripe.js +22 -0
- package/bin/terminal/core/stripe.js.map +1 -0
- package/bin/terminal/core/ui.d.ts +29 -0
- package/bin/terminal/core/ui.d.ts.map +1 -0
- package/bin/terminal/core/ui.js +60 -0
- package/bin/terminal/core/ui.js.map +1 -0
- package/bin/terminal/core/update.d.ts +20 -0
- package/bin/terminal/core/update.d.ts.map +1 -0
- package/bin/terminal/core/update.js +193 -0
- package/bin/terminal/core/update.js.map +1 -0
- package/bin/terminal/user/balance.d.ts +31 -0
- package/bin/terminal/user/balance.d.ts.map +1 -0
- package/bin/terminal/user/balance.js +131 -0
- package/bin/terminal/user/balance.js.map +1 -0
- package/bin/terminal/user/chat.d.ts +12 -0
- package/bin/terminal/user/chat.d.ts.map +1 -0
- package/bin/terminal/user/chat.js +70 -0
- package/bin/terminal/user/chat.js.map +1 -0
- package/bin/terminal/user/loop.d.ts +13 -0
- package/bin/terminal/user/loop.d.ts.map +1 -0
- package/bin/terminal/user/loop.js +93 -0
- package/bin/terminal/user/loop.js.map +1 -0
- package/bin/terminal/user/models.d.ts +10 -0
- package/bin/terminal/user/models.d.ts.map +1 -0
- package/bin/terminal/user/models.js +39 -0
- package/bin/terminal/user/models.js.map +1 -0
- package/bin/utils/storage.d.ts +0 -1
- package/bin/utils/storage.d.ts.map +1 -1
- package/bin/utils/storage.js +0 -6
- package/bin/utils/storage.js.map +1 -1
- package/package.json +7 -2
- package/public/app.js +3 -3
- package/src/cli/Index.ts +13 -3
- package/src/cli/agent/AgentChat.ts +113 -289
- package/src/cli/agent/AgentChatTypes.ts +8 -12
- package/src/cli/agent/AgentHistory.ts +2 -2
- package/src/cli/agent/AgentManager.ts +27 -28
- package/src/cli/agent/AgentManagerTypes.ts +2 -2
- package/src/cli/agent/AgentReset.ts +4 -4
- package/src/cli/agent/AgentSelection.ts +6 -6
- package/src/cli/agent/AgentSelectionTypes.ts +1 -1
- package/src/cli/agent/Init.ts +22 -21
- package/src/cli/agent/Restart.ts +2 -2
- package/src/cli/agent/Run.ts +46 -30
- package/src/cli/agent/Start.ts +2 -2
- package/src/cli/agent/Stop.ts +2 -2
- package/src/cli/control-plane/ControlPlaneProcess.ts +7 -8
- package/src/cli/model/ModelCreateCommand.ts +1 -1
- package/src/cli/model/ModelManageCommand.ts +5 -3
- package/src/cli/model/ModelManager.ts +3 -3
- package/src/cli/model/ModelSupport.ts +2 -10
- package/src/cli/shared/ChatAuth.ts +10 -11
- package/src/cli/shared/ChatManager.ts +2 -3
- package/src/cli/shared/CliReporterTypes.ts +1 -1
- package/src/cli/shared/Config.ts +2 -2
- package/src/cli/shared/Env.ts +22 -230
- package/src/cli/shared/IndexAgentCommand.ts +3 -4
- package/src/cli/shared/IndexSupport.ts +16 -10
- package/src/cli/shared/ManagedPluginActionCommands.ts +15 -12
- package/src/cli/shared/ManagedPluginRemote.ts +4 -4
- package/src/cli/shared/PluginScheduleCommand.ts +11 -10
- package/src/cli/shared/PluginTargetSupport.ts +25 -26
- package/src/cli/shared/Plugins.ts +26 -20
- package/src/cli/shared/PublicHostEnv.ts +2 -2
- package/src/cli/shared/Terminal.ts +24 -0
- package/src/config/DowncitySchema.ts +3 -113
- package/src/config/Paths.ts +9 -90
- package/src/control/ChannelAccountApiRoutes.ts +2 -3
- package/src/control/ControlGateway.ts +6 -5
- package/src/control/EnvApiRoutes.ts +7 -91
- package/src/control/PlatformApiRoutes.ts +6 -6
- package/src/control/PluginApiRoutes.ts +37 -27
- package/src/control/gateway/AgentActions.ts +26 -21
- package/src/control/gateway/AgentCatalog.ts +17 -21
- package/src/control/instant/InstantSessionRunner.ts +3 -1
- package/src/env/ProcessEnv.ts +43 -0
- package/src/http/auth/AuthEnv.ts +1 -1
- package/src/model/runtime/CreateRuntimeModel.ts +51 -59
- package/src/model/runtime/ExecutionModelBinding.ts +120 -0
- package/src/model/service/ModelPoolService.ts +13 -11
- package/src/platform/store/StoreEnvRepository.ts +31 -234
- package/src/platform/store/StoreSchema.ts +3 -49
- package/src/platform/store/index.ts +11 -80
- package/src/platform/store/schema.ts +2 -2
- package/src/process/daemon/Api.ts +1 -1
- package/src/process/daemon/CliArgs.ts +24 -1
- package/src/process/daemon/Client.ts +90 -22
- package/src/process/daemon/Manager.ts +2 -1
- package/src/process/registry/AgentHostRuntime.ts +1 -163
- package/src/terminal/admin/auth-error.ts +62 -0
- package/src/terminal/admin/commands/accounts.ts +44 -0
- package/src/terminal/admin/commands/balance.ts +160 -0
- package/src/terminal/admin/commands/config.ts +13 -0
- package/src/terminal/admin/commands/custom.ts +46 -0
- package/src/terminal/admin/commands/instruction.ts +12 -0
- package/src/terminal/admin/commands/models.ts +64 -0
- package/src/terminal/admin/commands/payment.ts +94 -0
- package/src/terminal/admin/commands/products.ts +72 -0
- package/src/terminal/admin/commands/service-env.ts +256 -0
- package/src/terminal/admin/commands/usage.ts +44 -0
- package/src/terminal/admin/loop.ts +69 -0
- package/src/terminal/agent/pi-agent.ts +180 -0
- package/src/terminal/app.ts +120 -0
- package/src/terminal/auth/admin.ts +21 -0
- package/src/terminal/auth/mode-select.ts +38 -0
- package/src/terminal/auth/server-switch.ts +275 -0
- package/src/terminal/auth/user.ts +351 -0
- package/src/terminal/core/browser.ts +31 -0
- package/src/terminal/core/env.ts +71 -0
- package/src/terminal/core/session.ts +450 -0
- package/src/terminal/core/stripe.ts +37 -0
- package/src/terminal/core/ui.ts +84 -0
- package/src/terminal/core/update.ts +230 -0
- package/src/terminal/user/balance.ts +215 -0
- package/src/terminal/user/chat.ts +80 -0
- package/src/terminal/user/loop.ts +112 -0
- package/src/terminal/user/models.ts +43 -0
- package/src/utils/storage.ts +0 -7
- package/tsconfig.json +2 -1
- package/bin/platform/chatAuthorization/Store.d.ts +0 -31
- package/bin/platform/chatAuthorization/Store.d.ts.map +0 -1
- package/bin/platform/chatAuthorization/Store.js +0 -145
- package/bin/platform/chatAuthorization/Store.js.map +0 -1
- package/bin/process/rpc/Client.d.ts +0 -13
- package/bin/process/rpc/Client.d.ts.map +0 -1
- package/bin/process/rpc/Client.js +0 -98
- package/bin/process/rpc/Client.js.map +0 -1
- package/bin/process/rpc/Paths.d.ts +0 -14
- package/bin/process/rpc/Paths.d.ts.map +0 -1
- package/bin/process/rpc/Paths.js +0 -36
- package/bin/process/rpc/Paths.js.map +0 -1
- package/src/platform/chatAuthorization/Store.ts +0 -181
- package/src/process/rpc/Client.ts +0 -113
- package/src/process/rpc/Paths.ts +0 -43
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Accounts 管理命令。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdminClient } from "@downcity/conduit";
|
|
6
|
+
import { select, isCancel } from "@clack/prompts";
|
|
7
|
+
import { showError } from "../../core/ui.js";
|
|
8
|
+
import { adminErrorMessage, rethrowAdminAuthError } from "../auth-error.js";
|
|
9
|
+
|
|
10
|
+
export async function manageAccounts(a: AdminClient): Promise<void> {
|
|
11
|
+
const svc = a.service("accounts");
|
|
12
|
+
while (true) {
|
|
13
|
+
const act = await select({
|
|
14
|
+
message: "Accounts",
|
|
15
|
+
options: [
|
|
16
|
+
{ label: "List users", value: "users" },
|
|
17
|
+
{ label: "List sessions", value: "sessions" },
|
|
18
|
+
{ label: "Back", value: "back" },
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
if (!act || isCancel(act) || act === "back") return;
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
if (act === "users") {
|
|
25
|
+
const b = await svc.get<{ items: { user_id: string; email: string; created_at: string }[] }>("users");
|
|
26
|
+
console.log(`\n${b.items.length} users:\n`);
|
|
27
|
+
for (const u of b.items) {
|
|
28
|
+
console.log(` ${u.user_id.padEnd(30)} ${u.email.padEnd(30)} ${u.created_at.slice(0, 10)}`);
|
|
29
|
+
}
|
|
30
|
+
console.log("");
|
|
31
|
+
} else {
|
|
32
|
+
const b = await svc.get<{ items: { session_id: string; user_id: string; status: string }[] }>("sessions");
|
|
33
|
+
console.log(`\n${b.items.length} sessions:\n`);
|
|
34
|
+
for (const s of b.items) {
|
|
35
|
+
console.log(` ${s.session_id.padEnd(36)} ${s.user_id.padEnd(30)} [${s.status}]`);
|
|
36
|
+
}
|
|
37
|
+
console.log("");
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
rethrowAdminAuthError(e);
|
|
41
|
+
showError(adminErrorMessage(e));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Balance 管理命令。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdminClient } from "@downcity/conduit";
|
|
6
|
+
import { isCancel, select } from "@clack/prompts";
|
|
7
|
+
import { askText, showError, showSuccess } from "../../core/ui.js";
|
|
8
|
+
import { adminErrorMessage, rethrowAdminAuthError } from "../auth-error.js";
|
|
9
|
+
|
|
10
|
+
export async function manageBalance(a: AdminClient): Promise<void> {
|
|
11
|
+
while (true) {
|
|
12
|
+
const act = await select({
|
|
13
|
+
message: "Balance",
|
|
14
|
+
options: [
|
|
15
|
+
{ label: "List users", value: "users" },
|
|
16
|
+
{ label: "History", value: "history" },
|
|
17
|
+
{ label: "Topups", value: "topups" },
|
|
18
|
+
{ label: "Redeem codes", value: "redeem_codes" },
|
|
19
|
+
{ label: "Add balance", value: "add" },
|
|
20
|
+
{ label: "Subtract balance", value: "sub" },
|
|
21
|
+
{ label: "Finish topup", value: "finish" },
|
|
22
|
+
{ label: "Cancel topup", value: "cancel" },
|
|
23
|
+
{ label: "Create redeem code", value: "create_redeem_code" },
|
|
24
|
+
{ label: "Disable redeem code", value: "disable_redeem_code" },
|
|
25
|
+
{ label: "Back", value: "back" },
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
if (!act || isCancel(act) || act === "back") return;
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
if (act === "users") {
|
|
32
|
+
const items = await a.balance.listUsers(30);
|
|
33
|
+
console.log(`\n${items.length} balance accounts:\n`);
|
|
34
|
+
for (const item of items) {
|
|
35
|
+
console.log(` ${item.user_id.padEnd(28)} ${String(item.balance).padStart(8)} ${item.unit.padEnd(10)} ${item.updated_at.slice(0, 19)}`);
|
|
36
|
+
}
|
|
37
|
+
console.log("");
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (act === "history") {
|
|
42
|
+
const userId = await askText("user_id (optional)");
|
|
43
|
+
const items = await a.balance.listHistory({
|
|
44
|
+
limit: 30,
|
|
45
|
+
user_id: userId ?? "",
|
|
46
|
+
});
|
|
47
|
+
console.log(`\n${items.length} balance history entries:\n`);
|
|
48
|
+
for (const item of items) {
|
|
49
|
+
console.log(` ${item.created_at.slice(0, 19)} ${item.user_id.padEnd(20)} ${item.kind.padEnd(8)} ${String(item.amount).padStart(6)} -> ${String(item.balance_after).padStart(6)} ${item.note}`);
|
|
50
|
+
}
|
|
51
|
+
console.log("");
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (act === "topups") {
|
|
56
|
+
const userId = await askText("user_id (optional)");
|
|
57
|
+
const items = await a.balance.listTopups({
|
|
58
|
+
limit: 30,
|
|
59
|
+
user_id: userId ?? "",
|
|
60
|
+
});
|
|
61
|
+
console.log(`\n${items.length} topup orders:\n`);
|
|
62
|
+
for (const item of items) {
|
|
63
|
+
console.log(` ${item.topup_id.padEnd(24)} ${item.user_id.padEnd(20)} ${String(item.amount).padStart(6)} ${item.unit.padEnd(10)} [${item.status}] ${item.note}`);
|
|
64
|
+
}
|
|
65
|
+
console.log("");
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (act === "redeem_codes") {
|
|
70
|
+
const status = await askText("status (optional: active/redeemed/disabled)");
|
|
71
|
+
const userId = await askText("redeemed_by_user_id (optional)");
|
|
72
|
+
const items = await a.balance.redeemCodes.list({
|
|
73
|
+
limit: 30,
|
|
74
|
+
status: normalizeRedeemCodeStatus(status),
|
|
75
|
+
user_id: userId ?? "",
|
|
76
|
+
});
|
|
77
|
+
console.log(`\n${items.length} redeem codes:\n`);
|
|
78
|
+
for (const item of items) {
|
|
79
|
+
const owner = item.redeemed_by_user_id || "-";
|
|
80
|
+
console.log(` ${item.redeem_code_id.padEnd(24)} ${item.code_mask.padEnd(22)} ${String(item.amount).padStart(6)} ${item.unit.padEnd(10)} [${item.status.padEnd(8)}] ${owner.padEnd(20)} ${item.note}`);
|
|
81
|
+
}
|
|
82
|
+
console.log("");
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (act === "add" || act === "sub") {
|
|
87
|
+
const userId = await askText("user_id");
|
|
88
|
+
if (!userId) continue;
|
|
89
|
+
const rawAmount = await askText("amount");
|
|
90
|
+
if (!rawAmount) continue;
|
|
91
|
+
|
|
92
|
+
const amount = Number(rawAmount);
|
|
93
|
+
if (!Number.isInteger(amount) || amount <= 0) {
|
|
94
|
+
showError("amount must be a positive integer");
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const note = await askText("note (optional)");
|
|
99
|
+
const account = act === "add"
|
|
100
|
+
? await a.balance.add({ user_id: userId, amount, note: note ?? "" })
|
|
101
|
+
: await a.balance.sub({ user_id: userId, amount, note: note ?? "" });
|
|
102
|
+
showSuccess(`balance updated: ${account.user_id} -> ${account.balance} ${account.unit}`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (act === "create_redeem_code") {
|
|
107
|
+
const rawAmount = await askText("amount");
|
|
108
|
+
if (!rawAmount) continue;
|
|
109
|
+
|
|
110
|
+
const amount = Number(rawAmount);
|
|
111
|
+
if (!Number.isInteger(amount) || amount <= 0) {
|
|
112
|
+
showError("amount must be a positive integer");
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const code = await askText("custom redeem_code (optional)");
|
|
117
|
+
const note = await askText("note (optional)");
|
|
118
|
+
const issued = await a.balance.redeemCodes.create({
|
|
119
|
+
amount,
|
|
120
|
+
code: code ?? "",
|
|
121
|
+
note: note ?? "",
|
|
122
|
+
});
|
|
123
|
+
showSuccess(`redeem_code created: ${issued.redeem_code_id} -> ${issued.code} (+${issued.amount} ${issued.unit})`);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (act === "disable_redeem_code") {
|
|
128
|
+
const redeemCodeId = await askText("redeem_code_id");
|
|
129
|
+
if (!redeemCodeId) continue;
|
|
130
|
+
const note = await askText("note (optional)");
|
|
131
|
+
const item = await a.balance.redeemCodes.disable({
|
|
132
|
+
redeem_code_id: redeemCodeId,
|
|
133
|
+
note: note ?? "",
|
|
134
|
+
});
|
|
135
|
+
showSuccess(`redeem_code updated: ${item.redeem_code_id} -> ${item.status}`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const topupId = await askText("topup_id");
|
|
140
|
+
if (!topupId) continue;
|
|
141
|
+
const note = await askText("note (optional)");
|
|
142
|
+
const topup = act === "finish"
|
|
143
|
+
? await a.balance.finishTopup({ topup_id: topupId, note: note ?? "" })
|
|
144
|
+
: await a.balance.cancelTopup({ topup_id: topupId, note: note ?? "" });
|
|
145
|
+
showSuccess(`topup updated: ${topup.topup_id} -> ${topup.status}`);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
rethrowAdminAuthError(e);
|
|
148
|
+
showError(adminErrorMessage(e));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function normalizeRedeemCodeStatus(value: string | undefined): "active" | "redeemed" | "disabled" | undefined {
|
|
154
|
+
const normalized = String(value ?? "").trim();
|
|
155
|
+
if (!normalized) return undefined;
|
|
156
|
+
if (normalized === "active" || normalized === "redeemed" || normalized === "disabled") {
|
|
157
|
+
return normalized;
|
|
158
|
+
}
|
|
159
|
+
throw new TypeError("status must be active, redeemed, or disabled");
|
|
160
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 旧的 Admin Server URL 命令兼容壳。
|
|
3
|
+
*
|
|
4
|
+
* 关键说明(中文)
|
|
5
|
+
* - 新交互下,server 管理已经提升到顶层 Manage Servers
|
|
6
|
+
* - 这里保留空壳是为了避免历史导入直接报错
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { type AdminSession } from "../../core/session.js";
|
|
10
|
+
|
|
11
|
+
export async function changeServerUrl(_session: AdminSession): Promise<boolean> {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Custom Service 命令。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdminClient } from "@downcity/conduit";
|
|
6
|
+
import { select, isCancel } from "@clack/prompts";
|
|
7
|
+
import { askText, showError } from "../../core/ui.js";
|
|
8
|
+
import { adminErrorMessage, rethrowAdminAuthError } from "../auth-error.js";
|
|
9
|
+
|
|
10
|
+
export async function manageCustom(a: AdminClient): Promise<void> {
|
|
11
|
+
while (true) {
|
|
12
|
+
const name = await askText("service name (empty to go back)");
|
|
13
|
+
if (!name) return;
|
|
14
|
+
|
|
15
|
+
const act = await select({
|
|
16
|
+
message: name,
|
|
17
|
+
options: [
|
|
18
|
+
{ label: "GET", value: "get" },
|
|
19
|
+
{ label: "POST", value: "post" },
|
|
20
|
+
{ label: "Back", value: "back" },
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
if (!act || isCancel(act) || act === "back") return;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const svc = a.service(name);
|
|
27
|
+
if (act === "get") {
|
|
28
|
+
const path = await askText("path") ?? "";
|
|
29
|
+
console.log(JSON.stringify(await svc.get(path), null, 2));
|
|
30
|
+
} else {
|
|
31
|
+
const raw = await askText("body (JSON)") ?? "{}";
|
|
32
|
+
let body: Record<string, unknown>;
|
|
33
|
+
try {
|
|
34
|
+
body = JSON.parse(raw);
|
|
35
|
+
} catch {
|
|
36
|
+
showError("Invalid JSON body");
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
console.log(JSON.stringify(await svc.action("").invoke(body), null, 2));
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
rethrowAdminAuthError(e);
|
|
43
|
+
showError(adminErrorMessage(e));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Infra 说明文档查看命令。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdminClient } from "@downcity/conduit";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 展示当前 InfraRuntime 聚合后的说明文档。
|
|
9
|
+
*/
|
|
10
|
+
export async function manageInstruction(a: AdminClient): Promise<void> {
|
|
11
|
+
console.log(`\n${await a.instruction()}\n`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Models 只读视图。
|
|
3
|
+
*
|
|
4
|
+
* 关键说明(中文)
|
|
5
|
+
* - 这里不提供模型新增、删除、启停。
|
|
6
|
+
* - 模型定义仍然来自代码注册;admin 只负责查看当前可用状态。
|
|
7
|
+
* - 如果模型缺少 provider key,会在这里直接显示缺失项。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { AdminClient } from "@downcity/conduit";
|
|
11
|
+
import { show, showError } from "../../core/ui.js";
|
|
12
|
+
import { adminErrorMessage, isAdminNotFoundError, rethrowAdminAuthError } from "../auth-error.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 展示全部代码注册模型及其运行状态。
|
|
16
|
+
*/
|
|
17
|
+
export async function manageModels(a: AdminClient): Promise<void> {
|
|
18
|
+
try {
|
|
19
|
+
const [modelResp, envCatalog] = await Promise.all([
|
|
20
|
+
a.listModels(),
|
|
21
|
+
a.env.catalog(),
|
|
22
|
+
]);
|
|
23
|
+
const items = modelResp ?? [];
|
|
24
|
+
const aiScope = envCatalog.find((item) => item.id === "ai-models");
|
|
25
|
+
const envMap = new Map(aiScope?.env.map((item) => [item.key, item.configured]) ?? []);
|
|
26
|
+
|
|
27
|
+
if (items.length === 0) {
|
|
28
|
+
show("No models registered on server.");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(`\n${items.length} models:\n`);
|
|
33
|
+
for (const model of items) {
|
|
34
|
+
const requirements = model.env_requirements ?? [];
|
|
35
|
+
const missingEnv = requirements
|
|
36
|
+
.filter((item) => item.required && !envMap.get(item.key))
|
|
37
|
+
.map((item) => item.key);
|
|
38
|
+
const status = missingEnv.length === 0 ? "READY" : `MISSING ${missingEnv.join(", ")}`;
|
|
39
|
+
const defaults = (model.default_modes ?? []).length > 0
|
|
40
|
+
? `default: ${(model.default_modes ?? []).join(", ")}`
|
|
41
|
+
: "default: none";
|
|
42
|
+
const envText = requirements.length > 0
|
|
43
|
+
? requirements
|
|
44
|
+
.map((item) => `${item.key}${envMap.get(item.key) ? "✓" : "✗"}`)
|
|
45
|
+
.join(", ")
|
|
46
|
+
: "none";
|
|
47
|
+
|
|
48
|
+
console.log(` ${model.name} (${model.id})`);
|
|
49
|
+
console.log(` status: ${status}`);
|
|
50
|
+
console.log(` modalities: ${model.modalities.join(", ") || "none"}`);
|
|
51
|
+
console.log(` ${defaults}`);
|
|
52
|
+
console.log(` env: ${envText}`);
|
|
53
|
+
if (model.description) console.log(` desc: ${model.description}`);
|
|
54
|
+
console.log("");
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
rethrowAdminAuthError(e);
|
|
58
|
+
if (isAdminNotFoundError(e)) {
|
|
59
|
+
showError("Connected InfraRuntime is too old and does not expose /v1/env/catalog yet. Deploy the latest worker/server first.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
showError(adminErrorMessage(e));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Payment 管理命令。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdminClient } from "@downcity/conduit";
|
|
6
|
+
import { select, isCancel } from "@clack/prompts";
|
|
7
|
+
import { buildStripeEndpoints } from "../../core/stripe.js";
|
|
8
|
+
import { show, showError } from "../../core/ui.js";
|
|
9
|
+
import { adminErrorMessage, rethrowAdminAuthError } from "../auth-error.js";
|
|
10
|
+
|
|
11
|
+
interface StripePaymentListItem {
|
|
12
|
+
/** 支付记录 ID */
|
|
13
|
+
payment_id: string;
|
|
14
|
+
/** 充值单 ID */
|
|
15
|
+
topup_id: string;
|
|
16
|
+
/** 用户 ID */
|
|
17
|
+
user_id: string;
|
|
18
|
+
/** 充值金额 */
|
|
19
|
+
amount: number;
|
|
20
|
+
/** 结算币种 */
|
|
21
|
+
currency: string;
|
|
22
|
+
/** 当前状态 */
|
|
23
|
+
status: string;
|
|
24
|
+
/** 更新时间 */
|
|
25
|
+
updated_at: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface StripeEventListItem {
|
|
29
|
+
/** 事件 ID */
|
|
30
|
+
event_id: string;
|
|
31
|
+
/** 事件类型 */
|
|
32
|
+
type: string;
|
|
33
|
+
/** 同步状态 */
|
|
34
|
+
sync_status: string;
|
|
35
|
+
/** 同步错误 */
|
|
36
|
+
sync_error: string;
|
|
37
|
+
/** 创建时间 */
|
|
38
|
+
created_at: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function managePayment(a: AdminClient, baseUrl: string): Promise<void> {
|
|
42
|
+
const svc = a.service("payment.stripe");
|
|
43
|
+
const endpoints = buildStripeEndpoints(baseUrl);
|
|
44
|
+
while (true) {
|
|
45
|
+
const act = await select({
|
|
46
|
+
message: "Payment",
|
|
47
|
+
options: [
|
|
48
|
+
{ label: "Show webhook setup", value: "webhook", hint: endpoints.webhook_url },
|
|
49
|
+
{ label: "List payments", value: "payments" },
|
|
50
|
+
{ label: "List webhook events", value: "events" },
|
|
51
|
+
{ label: "Back", value: "back" },
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
if (!act || isCancel(act) || act === "back") return;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
if (act === "webhook") {
|
|
58
|
+
show([
|
|
59
|
+
`Server URL: ${endpoints.base_url}`,
|
|
60
|
+
`Stripe webhook endpoint: ${endpoints.webhook_url}`,
|
|
61
|
+
"Recommended Stripe events:",
|
|
62
|
+
"- checkout.session.completed",
|
|
63
|
+
"- checkout.session.expired",
|
|
64
|
+
"- payment_intent.payment_failed",
|
|
65
|
+
"After creating the endpoint in Stripe Dashboard, copy its Signing secret into STRIPE_WEBHOOK_SECRET.",
|
|
66
|
+
].join("\n"));
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (act === "payments") {
|
|
71
|
+
const result = await svc.get<{ items: StripePaymentListItem[] }>("payments");
|
|
72
|
+
console.log(`\n${result.items.length} payments:\n`);
|
|
73
|
+
for (const item of result.items) {
|
|
74
|
+
console.log(
|
|
75
|
+
` ${item.updated_at.slice(0, 19)} ${item.user_id.padEnd(20)} ${String(item.amount).padStart(6)} ${item.currency.padEnd(6)} [${item.status}] ${item.payment_id}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
console.log("");
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const result = await svc.get<{ items: StripeEventListItem[] }>("events");
|
|
83
|
+
console.log(`\n${result.items.length} webhook events:\n`);
|
|
84
|
+
for (const item of result.items) {
|
|
85
|
+
const error = item.sync_error ? ` ${item.sync_error}` : "";
|
|
86
|
+
console.log(` ${item.created_at.slice(0, 19)} ${item.type.padEnd(32)} [${item.sync_status}] ${item.event_id}${error}`);
|
|
87
|
+
}
|
|
88
|
+
console.log("");
|
|
89
|
+
} catch (e) {
|
|
90
|
+
rethrowAdminAuthError(e);
|
|
91
|
+
showError(adminErrorMessage(e));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin Products 管理命令。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdminClient } from "@downcity/conduit";
|
|
6
|
+
import { select, isCancel } from "@clack/prompts";
|
|
7
|
+
import { askText, showError, showSuccess } from "../../core/ui.js";
|
|
8
|
+
import { adminErrorMessage, rethrowAdminAuthError } from "../auth-error.js";
|
|
9
|
+
|
|
10
|
+
export async function manageProducts(a: AdminClient): Promise<void> {
|
|
11
|
+
while (true) {
|
|
12
|
+
const act = await select({
|
|
13
|
+
message: "Products",
|
|
14
|
+
options: [
|
|
15
|
+
{ label: "List all", value: "list" },
|
|
16
|
+
{ label: "Create", value: "create" },
|
|
17
|
+
{ label: "Pause", value: "pause" },
|
|
18
|
+
{ label: "Activate", value: "activate" },
|
|
19
|
+
{ label: "Remove", value: "remove" },
|
|
20
|
+
{ label: "Issue token", value: "token" },
|
|
21
|
+
{ label: "Back", value: "back" },
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
if (!act || isCancel(act) || act === "back") return;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
if (act === "list") {
|
|
28
|
+
const items = await a.products.list();
|
|
29
|
+
console.log(`\n${items.length} products:\n`);
|
|
30
|
+
for (const p of items) {
|
|
31
|
+
console.log(` ${p.product_id.padEnd(24)} ${p.name.padEnd(20)} [${p.status}]`);
|
|
32
|
+
}
|
|
33
|
+
console.log("");
|
|
34
|
+
} else if (act === "create") {
|
|
35
|
+
const n = await askText("product name");
|
|
36
|
+
if (!n) continue;
|
|
37
|
+
const productId = await askText("product_id (optional)");
|
|
38
|
+
const p = await a.products.create(
|
|
39
|
+
productId
|
|
40
|
+
? { name: n, product_id: productId }
|
|
41
|
+
: { name: n },
|
|
42
|
+
);
|
|
43
|
+
showSuccess(`created: ${p.product_id}`);
|
|
44
|
+
} else if (act === "pause") {
|
|
45
|
+
const id = await askText("product_id");
|
|
46
|
+
if (!id) continue;
|
|
47
|
+
await a.products.pause(id);
|
|
48
|
+
showSuccess(`paused: ${id}`);
|
|
49
|
+
} else if (act === "activate") {
|
|
50
|
+
const id = await askText("product_id");
|
|
51
|
+
if (!id) continue;
|
|
52
|
+
await a.products.activate(id);
|
|
53
|
+
showSuccess(`activated: ${id}`);
|
|
54
|
+
} else if (act === "remove") {
|
|
55
|
+
const id = await askText("product_id");
|
|
56
|
+
if (!id) continue;
|
|
57
|
+
await a.products.remove(id);
|
|
58
|
+
showSuccess(`removed: ${id}`);
|
|
59
|
+
} else if (act === "token") {
|
|
60
|
+
const pid = await askText("product_id");
|
|
61
|
+
if (!pid) continue;
|
|
62
|
+
const uid = await askText("user_id");
|
|
63
|
+
if (!uid) continue;
|
|
64
|
+
const t = await a.products.tokens.apply({ product_id: pid, user_id: uid });
|
|
65
|
+
showSuccess(`token: ${t.user_token.slice(0, 20)}...`);
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
rethrowAdminAuthError(e);
|
|
69
|
+
showError(adminErrorMessage(e));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|