@downcity/agent 1.1.7 → 1.1.8
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/bin/agent/AgentContext.d.ts.map +1 -1
- package/bin/agent/AgentContext.js +1 -0
- package/bin/agent/AgentContext.js.map +1 -1
- package/bin/agent/AgentContextTypes.d.ts +5 -1
- package/bin/agent/AgentContextTypes.d.ts.map +1 -1
- package/bin/agent/AgentRuntime.d.ts +6 -1
- package/bin/agent/AgentRuntime.d.ts.map +1 -1
- package/bin/agent/AgentRuntime.js +22 -3
- package/bin/agent/AgentRuntime.js.map +1 -1
- package/bin/agent/AgentRuntimeState.d.ts.map +1 -1
- package/bin/agent/AgentRuntimeState.js +58 -2
- package/bin/agent/AgentRuntimeState.js.map +1 -1
- package/bin/agent/AgentRuntimeTypes.d.ts +5 -1
- package/bin/agent/AgentRuntimeTypes.d.ts.map +1 -1
- package/bin/agent/project/AgentInitializer.d.ts +3 -2
- package/bin/agent/project/AgentInitializer.d.ts.map +1 -1
- package/bin/agent/project/AgentInitializer.js +34 -44
- package/bin/agent/project/AgentInitializer.js.map +1 -1
- package/bin/config/Config.d.ts.map +1 -1
- package/bin/config/Config.js +2 -21
- package/bin/config/Config.js.map +1 -1
- package/bin/config/Paths.d.ts +1 -5
- package/bin/config/Paths.d.ts.map +1 -1
- package/bin/config/Paths.js +2 -8
- package/bin/config/Paths.js.map +1 -1
- package/bin/host/daemon/ProjectSetup.d.ts +2 -1
- package/bin/host/daemon/ProjectSetup.d.ts.map +1 -1
- package/bin/host/daemon/ProjectSetup.js +14 -21
- package/bin/host/daemon/ProjectSetup.js.map +1 -1
- package/bin/host/runtime/AgentHostRuntime.d.ts.map +1 -1
- package/bin/host/runtime/AgentHostRuntime.js +1 -2
- package/bin/host/runtime/AgentHostRuntime.js.map +1 -1
- package/bin/host/runtime/CityPaths.d.ts +0 -3
- package/bin/host/runtime/CityPaths.d.ts.map +1 -1
- package/bin/host/runtime/CityPaths.js +0 -3
- package/bin/host/runtime/CityPaths.js.map +1 -1
- package/bin/host/sdk/Agent.d.ts +1 -0
- package/bin/host/sdk/Agent.d.ts.map +1 -1
- package/bin/host/sdk/Agent.js +24 -2
- package/bin/host/sdk/Agent.js.map +1 -1
- package/bin/host/sdk/AgentSdkTypes.d.ts +9 -0
- package/bin/host/sdk/AgentSdkTypes.d.ts.map +1 -1
- package/bin/http/Server.d.ts.map +1 -1
- package/bin/http/Server.js +1 -11
- package/bin/http/Server.js.map +1 -1
- package/bin/http/auth/AuthEnv.d.ts +0 -9
- package/bin/http/auth/AuthEnv.d.ts.map +1 -1
- package/bin/http/auth/AuthEnv.js +0 -9
- package/bin/http/auth/AuthEnv.js.map +1 -1
- package/bin/http/auth/CliAuthStateStore.d.ts +0 -4
- package/bin/http/auth/CliAuthStateStore.d.ts.map +1 -1
- package/bin/http/auth/CliAuthStateStore.js +0 -4
- package/bin/http/auth/CliAuthStateStore.js.map +1 -1
- package/bin/http/control/ModelRoutes.d.ts.map +1 -1
- package/bin/http/control/ModelRoutes.js +3 -8
- package/bin/http/control/ModelRoutes.js.map +1 -1
- package/bin/index.d.ts +2 -6
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +2 -6
- package/bin/index.js.map +1 -1
- package/bin/model/CreateModel.d.ts +2 -2
- package/bin/model/CreateModel.d.ts.map +1 -1
- package/bin/model/CreateModel.js +13 -12
- package/bin/model/CreateModel.js.map +1 -1
- package/bin/plugin/Activation.d.ts +4 -0
- package/bin/plugin/Activation.d.ts.map +1 -1
- package/bin/plugin/Activation.js +2 -2
- package/bin/plugin/Activation.js.map +1 -1
- package/bin/plugin/LocalExecution.d.ts.map +1 -1
- package/bin/plugin/LocalExecution.js +23 -2
- package/bin/plugin/LocalExecution.js.map +1 -1
- package/bin/plugin/PluginRegistry.js +2 -2
- package/bin/plugin/PluginRegistry.js.map +1 -1
- package/bin/plugins/asr/Plugin.d.ts.map +1 -1
- package/bin/plugins/asr/Plugin.js +4 -5
- package/bin/plugins/asr/Plugin.js.map +1 -1
- package/bin/plugins/auth/Plugin.d.ts.map +1 -1
- package/bin/plugins/auth/Plugin.js +1 -0
- package/bin/plugins/auth/Plugin.js.map +1 -1
- package/bin/plugins/auth/runtime/AuthorizationConfig.d.ts +4 -4
- package/bin/plugins/auth/runtime/AuthorizationConfig.d.ts.map +1 -1
- package/bin/plugins/auth/runtime/AuthorizationConfig.js +28 -26
- package/bin/plugins/auth/runtime/AuthorizationConfig.js.map +1 -1
- package/bin/plugins/auth/runtime/AuthorizationPolicy.d.ts +2 -0
- package/bin/plugins/auth/runtime/AuthorizationPolicy.d.ts.map +1 -1
- package/bin/plugins/auth/runtime/AuthorizationPolicy.js +3 -2
- package/bin/plugins/auth/runtime/AuthorizationPolicy.js.map +1 -1
- package/bin/plugins/auth/runtime/AuthorizationStore.d.ts +1 -1
- package/bin/plugins/auth/runtime/AuthorizationStore.d.ts.map +1 -1
- package/bin/plugins/auth/runtime/AuthorizationStore.js +3 -4
- package/bin/plugins/auth/runtime/AuthorizationStore.js.map +1 -1
- package/bin/plugins/skill/Plugin.js +2 -2
- package/bin/plugins/skill/Plugin.js.map +1 -1
- package/bin/plugins/tts/Plugin.d.ts.map +1 -1
- package/bin/plugins/tts/Plugin.js +4 -5
- package/bin/plugins/tts/Plugin.js.map +1 -1
- package/bin/plugins/web/Plugin.d.ts.map +1 -1
- package/bin/plugins/web/Plugin.js +4 -5
- package/bin/plugins/web/Plugin.js.map +1 -1
- package/bin/plugins/workboard/Plugin.js +2 -2
- package/bin/plugins/workboard/Plugin.js.map +1 -1
- package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts +4 -1
- package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts.map +1 -1
- package/bin/service/builtins/chat/accounts/ChannelAccountService.js +64 -91
- package/bin/service/builtins/chat/accounts/ChannelAccountService.js.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelActions.js +11 -18
- package/bin/service/builtins/chat/runtime/ChatChannelActions.js.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.js +9 -17
- package/bin/service/builtins/chat/runtime/ChatChannelCore.js.map +1 -1
- package/bin/service/builtins/memory/Action.d.ts +1 -5
- package/bin/service/builtins/memory/Action.d.ts.map +1 -1
- package/bin/service/builtins/memory/Action.js +4 -42
- package/bin/service/builtins/memory/Action.js.map +1 -1
- package/bin/service/builtins/memory/MemoryService.d.ts.map +1 -1
- package/bin/service/builtins/memory/MemoryService.js +2 -32
- package/bin/service/builtins/memory/MemoryService.js.map +1 -1
- package/bin/service/builtins/memory/runtime/Search.d.ts +7 -3
- package/bin/service/builtins/memory/runtime/Search.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Search.js +220 -16
- package/bin/service/builtins/memory/runtime/Search.js.map +1 -1
- package/bin/service/builtins/memory/runtime/Store.d.ts +9 -50
- package/bin/service/builtins/memory/runtime/Store.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Store.js +10 -130
- package/bin/service/builtins/memory/runtime/Store.js.map +1 -1
- package/bin/service/builtins/memory/runtime/Writer.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Writer.js +1 -2
- package/bin/service/builtins/memory/runtime/Writer.js.map +1 -1
- package/bin/service/builtins/memory/types/Memory.d.ts +3 -57
- package/bin/service/builtins/memory/types/Memory.d.ts.map +1 -1
- package/bin/service/schedule/Store.d.ts +22 -25
- package/bin/service/schedule/Store.d.ts.map +1 -1
- package/bin/service/schedule/Store.js +172 -154
- package/bin/service/schedule/Store.js.map +1 -1
- package/bin/session/composer/system/default/SystemDomain.d.ts.map +1 -1
- package/bin/session/composer/system/default/SystemDomain.js +1 -0
- package/bin/session/composer/system/default/SystemDomain.js.map +1 -1
- package/bin/shared/types/AgentHost.d.ts +120 -4
- package/bin/shared/types/AgentHost.d.ts.map +1 -1
- package/bin/shared/types/Plugin.d.ts +5 -1
- package/bin/shared/types/Plugin.d.ts.map +1 -1
- package/package.json +1 -4
- package/src/agent/AgentContext.ts +1 -0
- package/src/agent/AgentContextTypes.ts +5 -0
- package/src/agent/AgentRuntime.ts +32 -3
- package/src/agent/AgentRuntimeState.ts +66 -2
- package/src/agent/AgentRuntimeTypes.ts +5 -0
- package/src/agent/project/AgentInitializer.ts +40 -42
- package/src/config/Config.ts +2 -17
- package/src/config/Paths.ts +2 -9
- package/src/host/daemon/ProjectSetup.ts +19 -21
- package/src/host/runtime/AgentHostRuntime.ts +0 -2
- package/src/host/runtime/CityPaths.ts +0 -3
- package/src/host/sdk/Agent.ts +26 -2
- package/src/host/sdk/AgentSdkTypes.ts +10 -0
- package/src/http/Server.ts +0 -13
- package/src/http/auth/AuthEnv.ts +0 -9
- package/src/http/auth/CliAuthStateStore.ts +0 -4
- package/src/http/control/ModelRoutes.ts +3 -9
- package/src/index.ts +2 -12
- package/src/model/CreateModel.ts +15 -13
- package/src/plugin/Activation.ts +6 -2
- package/src/plugin/LocalExecution.ts +24 -2
- package/src/plugin/PluginRegistry.ts +2 -2
- package/src/plugins/asr/Plugin.ts +4 -5
- package/src/plugins/auth/Plugin.ts +1 -0
- package/src/plugins/auth/runtime/AuthorizationConfig.ts +47 -37
- package/src/plugins/auth/runtime/AuthorizationPolicy.ts +5 -2
- package/src/plugins/auth/runtime/AuthorizationStore.ts +6 -5
- package/src/plugins/skill/Plugin.ts +2 -2
- package/src/plugins/tts/Plugin.ts +4 -5
- package/src/plugins/web/Plugin.ts +4 -5
- package/src/plugins/workboard/Plugin.ts +2 -2
- package/src/service/builtins/chat/accounts/ChannelAccountService.ts +42 -62
- package/src/service/builtins/chat/runtime/ChatChannelActions.ts +12 -18
- package/src/service/builtins/chat/runtime/ChatChannelCore.ts +9 -14
- package/src/service/builtins/memory/Action.ts +6 -47
- package/src/service/builtins/memory/MemoryService.ts +1 -33
- package/src/service/builtins/memory/runtime/Search.ts +256 -16
- package/src/service/builtins/memory/runtime/Store.ts +13 -185
- package/src/service/builtins/memory/runtime/Writer.ts +1 -2
- package/src/service/builtins/memory/types/Memory.ts +2 -59
- package/src/service/schedule/Store.ts +215 -175
- package/src/session/composer/system/default/SystemDomain.ts +1 -0
- package/src/shared/types/AgentHost.ts +138 -4
- package/src/shared/types/Plugin.ts +5 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/http/auth/AuthMiddleware.d.ts +0 -36
- package/bin/http/auth/AuthMiddleware.d.ts.map +0 -1
- package/bin/http/auth/AuthMiddleware.js +0 -37
- package/bin/http/auth/AuthMiddleware.js.map +0 -1
- package/bin/http/auth/AuthRoutes.d.ts +0 -17
- package/bin/http/auth/AuthRoutes.d.ts.map +0 -1
- package/bin/http/auth/AuthRoutes.js +0 -78
- package/bin/http/auth/AuthRoutes.js.map +0 -1
- package/bin/http/auth/AuthService.d.ts +0 -119
- package/bin/http/auth/AuthService.d.ts.map +0 -1
- package/bin/http/auth/AuthService.js +0 -307
- package/bin/http/auth/AuthService.js.map +0 -1
- package/bin/http/auth/AuthStore.d.ts +0 -165
- package/bin/http/auth/AuthStore.d.ts.map +0 -1
- package/bin/http/auth/AuthStore.js +0 -442
- package/bin/http/auth/AuthStore.js.map +0 -1
- package/bin/http/auth/RoutePolicy.d.ts +0 -30
- package/bin/http/auth/RoutePolicy.d.ts.map +0 -1
- package/bin/http/auth/RoutePolicy.js +0 -229
- package/bin/http/auth/RoutePolicy.js.map +0 -1
- package/bin/plugin/Lifecycle.d.ts +0 -33
- package/bin/plugin/Lifecycle.d.ts.map +0 -1
- package/bin/plugin/Lifecycle.js +0 -102
- package/bin/plugin/Lifecycle.js.map +0 -1
- package/bin/service/builtins/memory/runtime/Indexer.d.ts +0 -71
- package/bin/service/builtins/memory/runtime/Indexer.d.ts.map +0 -1
- package/bin/service/builtins/memory/runtime/Indexer.js +0 -345
- package/bin/service/builtins/memory/runtime/Indexer.js.map +0 -1
- package/bin/service/schedule/Schema.d.ts +0 -171
- package/bin/service/schedule/Schema.d.ts.map +0 -1
- package/bin/service/schedule/Schema.js +0 -26
- package/bin/service/schedule/Schema.js.map +0 -1
- package/bin/shared/utils/store/StoreChannelAccountRepository.d.ts +0 -34
- package/bin/shared/utils/store/StoreChannelAccountRepository.d.ts.map +0 -1
- package/bin/shared/utils/store/StoreChannelAccountRepository.js +0 -198
- package/bin/shared/utils/store/StoreChannelAccountRepository.js.map +0 -1
- package/bin/shared/utils/store/StoreEnvRepository.d.ts +0 -98
- package/bin/shared/utils/store/StoreEnvRepository.d.ts.map +0 -1
- package/bin/shared/utils/store/StoreEnvRepository.js +0 -334
- package/bin/shared/utils/store/StoreEnvRepository.js.map +0 -1
- package/bin/shared/utils/store/StoreModelRepository.d.ts +0 -61
- package/bin/shared/utils/store/StoreModelRepository.d.ts.map +0 -1
- package/bin/shared/utils/store/StoreModelRepository.js +0 -278
- package/bin/shared/utils/store/StoreModelRepository.js.map +0 -1
- package/bin/shared/utils/store/StoreSchema.d.ts +0 -13
- package/bin/shared/utils/store/StoreSchema.d.ts.map +0 -1
- package/bin/shared/utils/store/StoreSchema.js +0 -319
- package/bin/shared/utils/store/StoreSchema.js.map +0 -1
- package/bin/shared/utils/store/StoreSecureSettings.d.ts +0 -33
- package/bin/shared/utils/store/StoreSecureSettings.d.ts.map +0 -1
- package/bin/shared/utils/store/StoreSecureSettings.js +0 -91
- package/bin/shared/utils/store/StoreSecureSettings.js.map +0 -1
- package/bin/shared/utils/store/StoreShared.d.ts +0 -44
- package/bin/shared/utils/store/StoreShared.d.ts.map +0 -1
- package/bin/shared/utils/store/StoreShared.js +0 -40
- package/bin/shared/utils/store/StoreShared.js.map +0 -1
- package/bin/shared/utils/store/crypto.d.ts +0 -24
- package/bin/shared/utils/store/crypto.d.ts.map +0 -1
- package/bin/shared/utils/store/crypto.js +0 -101
- package/bin/shared/utils/store/crypto.js.map +0 -1
- package/bin/shared/utils/store/index.d.ts +0 -230
- package/bin/shared/utils/store/index.d.ts.map +0 -1
- package/bin/shared/utils/store/index.js +0 -360
- package/bin/shared/utils/store/index.js.map +0 -1
- package/bin/shared/utils/store/schema.d.ts +0 -690
- package/bin/shared/utils/store/schema.d.ts.map +0 -1
- package/bin/shared/utils/store/schema.js +0 -81
- package/bin/shared/utils/store/schema.js.map +0 -1
- package/src/http/auth/AuthMiddleware.ts +0 -61
- package/src/http/auth/AuthRoutes.ts +0 -100
- package/src/http/auth/AuthService.ts +0 -367
- package/src/http/auth/AuthStore.ts +0 -572
- package/src/http/auth/RoutePolicy.ts +0 -255
- package/src/plugin/Lifecycle.ts +0 -116
- package/src/service/builtins/memory/runtime/Indexer.ts +0 -466
- package/src/service/schedule/Schema.ts +0 -34
- package/src/shared/utils/store/StoreChannelAccountRepository.ts +0 -269
- package/src/shared/utils/store/StoreEnvRepository.ts +0 -452
- package/src/shared/utils/store/StoreModelRepository.ts +0 -324
- package/src/shared/utils/store/StoreSchema.ts +0 -344
- package/src/shared/utils/store/StoreSecureSettings.ts +0 -126
- package/src/shared/utils/store/StoreShared.ts +0 -67
- package/src/shared/utils/store/crypto.ts +0 -112
- package/src/shared/utils/store/index.ts +0 -497
- package/src/shared/utils/store/schema.ts +0 -103
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
} from "@/shared/types/AuthPlugin.js";
|
|
17
17
|
import type { AgentContext } from "@/agent/AgentContextTypes.js";
|
|
18
18
|
import type { ChatDispatchChannel } from "@/service/builtins/chat/types/ChatDispatcher.js";
|
|
19
|
-
import { readChatAuthorizationConfigSync } from "@/plugins/auth/runtime/AuthorizationConfig.js";
|
|
20
19
|
|
|
21
20
|
function getAuthorizationStatePath(rootPath: string): string {
|
|
22
21
|
return path.join(rootPath, ".downcity", "chat", "authorization", "state.json");
|
|
@@ -145,8 +144,10 @@ async function writeState(rootPath: string, state: ChatAuthorizationStateFile):
|
|
|
145
144
|
await fs.writeJson(file, state, { spaces: 2 });
|
|
146
145
|
}
|
|
147
146
|
|
|
148
|
-
function readAuthorizationConfig(
|
|
149
|
-
|
|
147
|
+
function readAuthorizationConfig(
|
|
148
|
+
context: Pick<AgentContext, "rootPath" | "platform">,
|
|
149
|
+
): ChatAuthorizationSnapshot["config"] {
|
|
150
|
+
return context.platform.readChatAuthorizationConfig(context.rootPath);
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
/**
|
|
@@ -207,11 +208,11 @@ export async function recordObservedAuthorizationPrincipal(params: {
|
|
|
207
208
|
* 读取授权快照(配置 + 动态状态)。
|
|
208
209
|
*/
|
|
209
210
|
export async function readAuthorizationSnapshot(params: {
|
|
210
|
-
context: Pick<AgentContext, "rootPath">;
|
|
211
|
+
context: Pick<AgentContext, "rootPath" | "platform">;
|
|
211
212
|
}): Promise<ChatAuthorizationSnapshot> {
|
|
212
213
|
const state = await readState(params.context.rootPath);
|
|
213
214
|
return {
|
|
214
|
-
config: readAuthorizationConfig(params.context
|
|
215
|
+
config: readAuthorizationConfig(params.context),
|
|
215
216
|
users: Object.values(state.usersByKey).sort((a, b) => b.lastSeenAt - a.lastSeenAt),
|
|
216
217
|
chats: Object.values(state.chatsByKey).sort((a, b) => b.lastSeenAt - a.lastSeenAt),
|
|
217
218
|
};
|
|
@@ -126,8 +126,8 @@ export const skillPlugin: Plugin = {
|
|
|
126
126
|
...DEFAULT_SKILL_PLUGIN_CONFIG,
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
|
-
availability() {
|
|
130
|
-
if (!isPluginEnabled({ plugin: skillPlugin })) {
|
|
129
|
+
availability(context) {
|
|
130
|
+
if (!isPluginEnabled({ plugin: skillPlugin, context })) {
|
|
131
131
|
return {
|
|
132
132
|
enabled: false,
|
|
133
133
|
available: false,
|
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
TtsSynthesizeInput,
|
|
15
15
|
} from "@/shared/types/TtsPlugin.js";
|
|
16
16
|
import { isPluginEnabled } from "@/plugin/Activation.js";
|
|
17
|
-
import { setCityPluginEnabled } from "@/plugin/Lifecycle.js";
|
|
18
17
|
import {
|
|
19
18
|
checkTtsSynthesizer,
|
|
20
19
|
installTtsSynthesizer,
|
|
@@ -176,7 +175,7 @@ export const ttsPlugin: Plugin = {
|
|
|
176
175
|
statusAction: "status",
|
|
177
176
|
},
|
|
178
177
|
async availability(context) {
|
|
179
|
-
if (!isPluginEnabled({ plugin: ttsPlugin })) {
|
|
178
|
+
if (!isPluginEnabled({ plugin: ttsPlugin, context })) {
|
|
180
179
|
return {
|
|
181
180
|
enabled: false,
|
|
182
181
|
available: false,
|
|
@@ -378,7 +377,7 @@ export const ttsPlugin: Plugin = {
|
|
|
378
377
|
},
|
|
379
378
|
},
|
|
380
379
|
execute: async ({ context, payload }) => {
|
|
381
|
-
|
|
380
|
+
context.platform.setPluginEnabled?.("tts", true);
|
|
382
381
|
if ((payload as { install?: unknown }).install !== false) {
|
|
383
382
|
const installResult = await installTtsSynthesizer({
|
|
384
383
|
context,
|
|
@@ -411,7 +410,7 @@ export const ttsPlugin: Plugin = {
|
|
|
411
410
|
},
|
|
412
411
|
},
|
|
413
412
|
execute: async ({ context }) => {
|
|
414
|
-
|
|
413
|
+
context.platform.setPluginEnabled?.("tts", false);
|
|
415
414
|
return {
|
|
416
415
|
success: true,
|
|
417
416
|
data: {
|
|
@@ -535,7 +534,7 @@ export const ttsPlugin: Plugin = {
|
|
|
535
534
|
},
|
|
536
535
|
},
|
|
537
536
|
system(context) {
|
|
538
|
-
if (!isPluginEnabled({ plugin: ttsPlugin })) {
|
|
537
|
+
if (!isPluginEnabled({ plugin: ttsPlugin, context })) {
|
|
539
538
|
return "";
|
|
540
539
|
}
|
|
541
540
|
return [
|
|
@@ -12,7 +12,6 @@ import type { JsonObject, JsonValue } from "@/shared/types/Json.js";
|
|
|
12
12
|
import type { WebPluginConfig, WebPluginInstallInput } from "@/shared/types/WebPlugin.js";
|
|
13
13
|
import { WEB_PLUGIN_DEFAULT_REPOSITORY_URL } from "@/shared/types/WebPlugin.js";
|
|
14
14
|
import { isPluginEnabled } from "@/plugin/Activation.js";
|
|
15
|
-
import { setCityPluginEnabled } from "@/plugin/Lifecycle.js";
|
|
16
15
|
import {
|
|
17
16
|
doctorWebPluginDependency,
|
|
18
17
|
inspectWebPluginDependency,
|
|
@@ -179,7 +178,7 @@ export const webPlugin: Plugin = {
|
|
|
179
178
|
statusAction: "status",
|
|
180
179
|
},
|
|
181
180
|
async availability(context) {
|
|
182
|
-
if (!isPluginEnabled({ plugin: webPlugin })) {
|
|
181
|
+
if (!isPluginEnabled({ plugin: webPlugin, context })) {
|
|
183
182
|
return {
|
|
184
183
|
enabled: false,
|
|
185
184
|
available: false,
|
|
@@ -361,7 +360,7 @@ export const webPlugin: Plugin = {
|
|
|
361
360
|
},
|
|
362
361
|
},
|
|
363
362
|
execute: async ({ context, payload }) => {
|
|
364
|
-
|
|
363
|
+
context.platform.setPluginEnabled?.("web", true);
|
|
365
364
|
const providerRaw = String((payload as { provider?: unknown }).provider || "").trim();
|
|
366
365
|
const provider =
|
|
367
366
|
providerRaw === "web-access" || providerRaw === "agent-browser"
|
|
@@ -403,7 +402,7 @@ export const webPlugin: Plugin = {
|
|
|
403
402
|
},
|
|
404
403
|
},
|
|
405
404
|
execute: async ({ context }) => {
|
|
406
|
-
|
|
405
|
+
context.platform.setPluginEnabled?.("web", false);
|
|
407
406
|
return {
|
|
408
407
|
success: true,
|
|
409
408
|
data: {
|
|
@@ -497,7 +496,7 @@ export const webPlugin: Plugin = {
|
|
|
497
496
|
},
|
|
498
497
|
system(context) {
|
|
499
498
|
const config = readWebPluginConfig(context);
|
|
500
|
-
if (!isPluginEnabled({ plugin: webPlugin }) || !config.injectPrompt) {
|
|
499
|
+
if (!isPluginEnabled({ plugin: webPlugin, context }) || !config.injectPrompt) {
|
|
501
500
|
return "";
|
|
502
501
|
}
|
|
503
502
|
const providerPrompt =
|
|
@@ -19,8 +19,8 @@ export const workboardPlugin: Plugin = {
|
|
|
19
19
|
title: "Workboard Snapshot",
|
|
20
20
|
description:
|
|
21
21
|
"Collects structured runtime activity snapshots so console surfaces can show what the current agent is doing now and what it recently worked on.",
|
|
22
|
-
availability() {
|
|
23
|
-
if (!isPluginEnabled({ plugin: workboardPlugin })) {
|
|
22
|
+
availability(context) {
|
|
23
|
+
if (!isPluginEnabled({ plugin: workboardPlugin, context })) {
|
|
24
24
|
return {
|
|
25
25
|
enabled: false,
|
|
26
26
|
available: false,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import crypto from "node:crypto";
|
|
11
|
-
import {
|
|
11
|
+
import type { AgentPlatformRuntime } from "@/shared/types/AgentHost.js";
|
|
12
12
|
import type { StoredChannelAccountChannel } from "@/shared/types/Store.js";
|
|
13
13
|
import { resolveChatChannelBotInfo } from "@/service/builtins/chat/channels/BotInfoProvider.js";
|
|
14
14
|
import type {
|
|
@@ -69,6 +69,12 @@ function pickFirstNonEmpty(inputs: unknown[]): string {
|
|
|
69
69
|
* ChatChannelAccountService。
|
|
70
70
|
*/
|
|
71
71
|
export class ChatChannelAccountService {
|
|
72
|
+
private readonly platform: AgentPlatformRuntime;
|
|
73
|
+
|
|
74
|
+
constructor(platform: AgentPlatformRuntime) {
|
|
75
|
+
this.platform = platform;
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
/**
|
|
73
79
|
* 生成唯一 channel account id。
|
|
74
80
|
*
|
|
@@ -82,18 +88,13 @@ export class ChatChannelAccountService {
|
|
|
82
88
|
}): Promise<string> {
|
|
83
89
|
const seed = normalizeChannelAccountIdToken(params.seed || "");
|
|
84
90
|
const prefix = `${params.channel}-${seed}`.slice(0, 36);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const existing = await store.getChannelAccount(candidate);
|
|
91
|
-
if (!existing) return candidate;
|
|
92
|
-
}
|
|
93
|
-
return `${params.channel}-${Date.now().toString(36)}`;
|
|
94
|
-
} finally {
|
|
95
|
-
store.close();
|
|
91
|
+
for (let index = 0; index < 8; index += 1) {
|
|
92
|
+
const suffix = crypto.randomBytes(3).toString("hex");
|
|
93
|
+
const candidate = `${prefix}-${suffix}`.slice(0, 64);
|
|
94
|
+
const existing = this.platform.getChannelAccount(candidate);
|
|
95
|
+
if (!existing) return candidate;
|
|
96
96
|
}
|
|
97
|
+
return `${params.channel}-${Date.now().toString(36)}`;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
/**
|
|
@@ -205,32 +206,13 @@ export class ChatChannelAccountService {
|
|
|
205
206
|
* 列出账户池(脱敏)。
|
|
206
207
|
*/
|
|
207
208
|
async list(): Promise<ChatChannelAccountListResult> {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return {
|
|
212
|
-
items: rows.map((item) => ({
|
|
213
|
-
id: item.id,
|
|
214
|
-
channel: item.channel,
|
|
215
|
-
name: item.name,
|
|
216
|
-
identity: item.identity,
|
|
217
|
-
owner: item.owner,
|
|
218
|
-
creator: item.creator,
|
|
219
|
-
domain: item.domain,
|
|
220
|
-
sandbox: item.sandbox === true,
|
|
221
|
-
hasBotToken: !!String(item.botToken || "").trim(),
|
|
222
|
-
hasAppId: !!String(item.appId || "").trim(),
|
|
223
|
-
hasAppSecret: !!String(item.appSecret || "").trim(),
|
|
224
|
-
botTokenMasked: item.botToken ? maskSecret(item.botToken) : undefined,
|
|
225
|
-
appIdMasked: item.appId ? maskSecret(item.appId) : undefined,
|
|
226
|
-
appSecretMasked: item.appSecret ? maskSecret(item.appSecret) : undefined,
|
|
227
|
-
createdAt: item.createdAt,
|
|
228
|
-
updatedAt: item.updatedAt,
|
|
229
|
-
})),
|
|
230
|
-
};
|
|
231
|
-
} finally {
|
|
232
|
-
store.close();
|
|
209
|
+
const list = this.platform.listChannelAccounts;
|
|
210
|
+
if (!list) {
|
|
211
|
+
throw new Error("Channel account listing is not available in this runtime");
|
|
233
212
|
}
|
|
213
|
+
return {
|
|
214
|
+
items: await list(),
|
|
215
|
+
};
|
|
234
216
|
}
|
|
235
217
|
|
|
236
218
|
/**
|
|
@@ -254,9 +236,7 @@ export class ChatChannelAccountService {
|
|
|
254
236
|
throw new Error("appSecret and clearAppSecret cannot be used together");
|
|
255
237
|
}
|
|
256
238
|
|
|
257
|
-
const
|
|
258
|
-
try {
|
|
259
|
-
const current = await store.getChannelAccount(id);
|
|
239
|
+
const current = this.platform.getChannelAccount(id);
|
|
260
240
|
const nextBotToken = input.clearBotToken
|
|
261
241
|
? undefined
|
|
262
242
|
: input.botToken !== undefined
|
|
@@ -282,36 +262,36 @@ export class ChatChannelAccountService {
|
|
|
282
262
|
? normalizeOptionalText(input.creator)
|
|
283
263
|
: current?.creator;
|
|
284
264
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
name,
|
|
289
|
-
identity: nextIdentity,
|
|
290
|
-
owner: nextOwner,
|
|
291
|
-
creator: nextCreator,
|
|
292
|
-
botToken: nextBotToken,
|
|
293
|
-
appId: nextAppId,
|
|
294
|
-
appSecret: nextAppSecret,
|
|
295
|
-
domain: normalizeOptionalText(input.domain),
|
|
296
|
-
sandbox: input.sandbox === true,
|
|
297
|
-
});
|
|
298
|
-
return { id };
|
|
299
|
-
} finally {
|
|
300
|
-
store.close();
|
|
265
|
+
const updateChannelAccount = this.platform.updateChannelAccount;
|
|
266
|
+
if (!updateChannelAccount) {
|
|
267
|
+
throw new Error("Channel account update is not available in this runtime");
|
|
301
268
|
}
|
|
269
|
+
await updateChannelAccount({
|
|
270
|
+
id,
|
|
271
|
+
channel,
|
|
272
|
+
name,
|
|
273
|
+
identity: nextIdentity,
|
|
274
|
+
owner: nextOwner,
|
|
275
|
+
creator: nextCreator,
|
|
276
|
+
botToken: nextBotToken,
|
|
277
|
+
appId: nextAppId,
|
|
278
|
+
appSecret: nextAppSecret,
|
|
279
|
+
domain: normalizeOptionalText(input.domain),
|
|
280
|
+
sandbox: input.sandbox === true,
|
|
281
|
+
});
|
|
282
|
+
return { id };
|
|
302
283
|
}
|
|
303
284
|
|
|
304
285
|
/**
|
|
305
286
|
* 删除账号。
|
|
306
287
|
*/
|
|
307
|
-
remove(idInput: string): void {
|
|
288
|
+
async remove(idInput: string): Promise<void> {
|
|
308
289
|
const id = String(idInput || "").trim();
|
|
309
290
|
if (!id) throw new Error("channel account id cannot be empty");
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
} finally {
|
|
314
|
-
store.close();
|
|
291
|
+
const removeChannelAccount = this.platform.removeChannelAccount;
|
|
292
|
+
if (!removeChannelAccount) {
|
|
293
|
+
throw new Error("Channel account removal is not available in this runtime");
|
|
315
294
|
}
|
|
295
|
+
await removeChannelAccount(id);
|
|
316
296
|
}
|
|
317
297
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* - 对外只暴露 action 级入口,供 ChatServiceActions 装配使用。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { PlatformStore } from "@/shared/utils/store/index.js";
|
|
11
10
|
import type { AgentContext } from "@/agent/AgentContextTypes.js";
|
|
12
11
|
import type { ChatChannelState } from "@/shared/types/ChatRuntime.js";
|
|
13
12
|
import type {
|
|
@@ -264,23 +263,18 @@ export async function executeChatConfigureAction(params: {
|
|
|
264
263
|
if (Object.prototype.hasOwnProperty.call(patch, "channelAccountId")) {
|
|
265
264
|
const channelAccountId = String(patch.channelAccountId || "").trim();
|
|
266
265
|
if (channelAccountId) {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
error: `Bot account channel mismatch: expected ${channel}, got ${account.channel}`,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
} finally {
|
|
283
|
-
store.close();
|
|
266
|
+
const account = params.context.platform.getChannelAccount(channelAccountId);
|
|
267
|
+
if (!account) {
|
|
268
|
+
return {
|
|
269
|
+
success: false,
|
|
270
|
+
error: `Bot account not found: ${channelAccountId}`,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (account.channel !== channel) {
|
|
274
|
+
return {
|
|
275
|
+
success: false,
|
|
276
|
+
error: `Bot account channel mismatch: expected ${channel}, got ${account.channel}`,
|
|
277
|
+
};
|
|
284
278
|
}
|
|
285
279
|
}
|
|
286
280
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* - 目标是让 chat channel 子模块共享同一套最小公共基元。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { PlatformStore } from "@/shared/utils/store/index.js";
|
|
11
10
|
import type { AgentContext } from "@/agent/AgentContextTypes.js";
|
|
12
11
|
import type { StoredChannelAccount } from "@/shared/types/Store.js";
|
|
13
12
|
import type { ChatChannelName } from "@/service/builtins/chat/types/ChannelStatus.js";
|
|
@@ -85,7 +84,7 @@ export function resolveChannelAccountId(
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
/**
|
|
88
|
-
*
|
|
87
|
+
* 从宿主平台能力中解析渠道 account。
|
|
89
88
|
*/
|
|
90
89
|
export function resolveChannelAccount(
|
|
91
90
|
context: AgentContext,
|
|
@@ -95,18 +94,14 @@ export function resolveChannelAccount(
|
|
|
95
94
|
const explicit = service?.resolveChannelAccount?.(context, channel);
|
|
96
95
|
if (explicit) return explicit;
|
|
97
96
|
const channelAccountId = resolveChannelAccountId(context, channel);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return null;
|
|
107
|
-
} finally {
|
|
108
|
-
store.close();
|
|
109
|
-
}
|
|
97
|
+
const account = context.platform.resolveChannelAccount?.({
|
|
98
|
+
projectRoot: context.rootPath,
|
|
99
|
+
channel,
|
|
100
|
+
...(channelAccountId ? { channelAccountId } : {}),
|
|
101
|
+
}) || (channelAccountId ? context.platform.getChannelAccount(channelAccountId) : null);
|
|
102
|
+
if (!account) return null;
|
|
103
|
+
if (account.channel !== channel) return null;
|
|
104
|
+
return account;
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
/**
|
|
@@ -12,15 +12,16 @@ import type { JsonValue } from "@/shared/types/Json.js";
|
|
|
12
12
|
import type {
|
|
13
13
|
MemoryFlushPayload,
|
|
14
14
|
MemoryGetPayload,
|
|
15
|
-
MemoryIndexPayload,
|
|
16
15
|
MemorySearchPayload,
|
|
17
16
|
MemoryStorePayload,
|
|
18
17
|
} from "@/service/builtins/memory/types/Memory.js";
|
|
19
18
|
import { flushMemory } from "./runtime/Flush.js";
|
|
20
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
collectMemoryStatus,
|
|
21
|
+
searchMemory,
|
|
22
|
+
} from "./runtime/Search.js";
|
|
21
23
|
import {
|
|
22
24
|
MEMORY_DEFAULTS,
|
|
23
|
-
ensureMemoryIndexed,
|
|
24
25
|
type MemoryRuntimeState,
|
|
25
26
|
} from "./runtime/Store.js";
|
|
26
27
|
import { getMemory, storeMemory } from "./runtime/Writer.js";
|
|
@@ -33,23 +34,10 @@ export async function statusMemoryAction(
|
|
|
33
34
|
state: MemoryRuntimeState,
|
|
34
35
|
): Promise<ServiceActionResult<JsonValue>> {
|
|
35
36
|
try {
|
|
36
|
-
const stats = state
|
|
37
|
+
const stats = await collectMemoryStatus(context, state);
|
|
37
38
|
return {
|
|
38
39
|
success: true,
|
|
39
|
-
data:
|
|
40
|
-
enabled: state.enabled,
|
|
41
|
-
backend: "builtin",
|
|
42
|
-
mode: "fts",
|
|
43
|
-
dbPath: state.indexer.getRelativeDbPath(),
|
|
44
|
-
dirty: state.dirty,
|
|
45
|
-
files: stats.files,
|
|
46
|
-
chunks: stats.chunks,
|
|
47
|
-
sourceCounts: stats.sourceCounts,
|
|
48
|
-
...(typeof state.lastSyncAt === "number"
|
|
49
|
-
? { lastSyncAt: state.lastSyncAt }
|
|
50
|
-
: {}),
|
|
51
|
-
...(state.lastError ? { lastError: state.lastError } : {}),
|
|
52
|
-
} as unknown as JsonValue,
|
|
40
|
+
data: stats as unknown as JsonValue,
|
|
53
41
|
};
|
|
54
42
|
} catch (error) {
|
|
55
43
|
return {
|
|
@@ -59,35 +47,6 @@ export async function statusMemoryAction(
|
|
|
59
47
|
}
|
|
60
48
|
}
|
|
61
49
|
|
|
62
|
-
/**
|
|
63
|
-
* index action。
|
|
64
|
-
*/
|
|
65
|
-
export async function indexMemoryAction(
|
|
66
|
-
context: AgentContext,
|
|
67
|
-
state: MemoryRuntimeState,
|
|
68
|
-
payload: MemoryIndexPayload,
|
|
69
|
-
): Promise<ServiceActionResult<JsonValue>> {
|
|
70
|
-
try {
|
|
71
|
-
const result = await ensureMemoryIndexed(context, state, {
|
|
72
|
-
force: payload.force === true,
|
|
73
|
-
reason: payload.force ? "manual-force" : "manual",
|
|
74
|
-
});
|
|
75
|
-
const status = state.indexer.status();
|
|
76
|
-
const data = {
|
|
77
|
-
totalFiles: result?.totalFiles ?? status.files,
|
|
78
|
-
reindexedFiles: result?.reindexedFiles ?? 0,
|
|
79
|
-
removedFiles: result?.removedFiles ?? 0,
|
|
80
|
-
totalChunks: result?.totalChunks ?? 0,
|
|
81
|
-
};
|
|
82
|
-
return { success: true, data: data as unknown as JsonValue };
|
|
83
|
-
} catch (error) {
|
|
84
|
-
return {
|
|
85
|
-
success: false,
|
|
86
|
-
error: String(error),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
50
|
/**
|
|
92
51
|
* search action。
|
|
93
52
|
*/
|
|
@@ -15,7 +15,6 @@ import { BaseService } from "@/service/builtins/BaseService.js";
|
|
|
15
15
|
import {
|
|
16
16
|
flushMemoryAction,
|
|
17
17
|
getMemoryAction,
|
|
18
|
-
indexMemoryAction,
|
|
19
18
|
searchMemoryAction,
|
|
20
19
|
statusMemoryAction,
|
|
21
20
|
storeMemoryAction,
|
|
@@ -76,11 +75,6 @@ function readOptionalNumber(body: JsonObject, key: string): number | undefined {
|
|
|
76
75
|
return typeof value === "number" ? value : undefined;
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
function readOptionalBoolean(body: JsonObject, key: string): boolean | undefined {
|
|
80
|
-
const value = body[key];
|
|
81
|
-
return typeof value === "boolean" ? value : undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
78
|
/**
|
|
85
79
|
* Memory service 类实现。
|
|
86
80
|
*/
|
|
@@ -124,7 +118,7 @@ export class MemoryService extends BaseService {
|
|
|
124
118
|
readonly actions: ServiceActions = {
|
|
125
119
|
status: {
|
|
126
120
|
command: {
|
|
127
|
-
description: "查看 memory 状态(backend/files/chunks
|
|
121
|
+
description: "查看 memory 状态(backend/files/chunks)",
|
|
128
122
|
mapInput() {
|
|
129
123
|
return {};
|
|
130
124
|
},
|
|
@@ -137,32 +131,6 @@ export class MemoryService extends BaseService {
|
|
|
137
131
|
return await statusMemoryAction(params.context, state);
|
|
138
132
|
},
|
|
139
133
|
},
|
|
140
|
-
index: {
|
|
141
|
-
command: {
|
|
142
|
-
description: "重建 memory 索引",
|
|
143
|
-
configure(command: Command) {
|
|
144
|
-
command.option("--force", "强制全量重建", false);
|
|
145
|
-
},
|
|
146
|
-
mapInput({ opts }) {
|
|
147
|
-
return {
|
|
148
|
-
force: opts.force === true,
|
|
149
|
-
};
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
api: {
|
|
153
|
-
method: "POST",
|
|
154
|
-
mapInput(ctx) {
|
|
155
|
-
return ctx.req.json();
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
execute: async (params) => {
|
|
159
|
-
const body = readBodyObject(params.payload);
|
|
160
|
-
const state = this.getOrCreateRuntimeState(params.context);
|
|
161
|
-
return await indexMemoryAction(params.context, state, {
|
|
162
|
-
force: readOptionalBoolean(body, "force"),
|
|
163
|
-
});
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
134
|
search: {
|
|
167
135
|
command: {
|
|
168
136
|
description: "检索记忆片段",
|