@downcity/city 1.1.29 → 1.1.39
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 +5 -11
- package/bin/cli/Index.js +10 -5
- package/bin/cli/Index.js.map +1 -1
- package/bin/cli/agent/AgentChat.js +1 -1
- package/bin/cli/agent/AgentChat.js.map +1 -1
- package/bin/cli/agent/AgentManager.js +3 -3
- package/bin/cli/agent/AgentManager.js.map +1 -1
- package/bin/cli/agent/Init.d.ts.map +1 -1
- package/bin/cli/agent/Init.js +14 -14
- package/bin/cli/agent/Init.js.map +1 -1
- package/bin/cli/agent/Restart.js +1 -1
- package/bin/cli/agent/Restart.js.map +1 -1
- package/bin/cli/agent/Run.d.ts.map +1 -1
- package/bin/cli/agent/Run.js +12 -19
- package/bin/cli/agent/Run.js.map +1 -1
- package/bin/cli/agent/Start.js +1 -1
- package/bin/cli/agent/Start.js.map +1 -1
- package/bin/cli/control-plane/ControlPlaneProcess.d.ts.map +1 -1
- package/bin/cli/control-plane/ControlPlaneProcess.js +2 -3
- package/bin/cli/control-plane/ControlPlaneProcess.js.map +1 -1
- package/bin/cli/model/ModelSupport.d.ts +1 -1
- package/bin/cli/model/ModelSupport.d.ts.map +1 -1
- package/bin/cli/model/ModelSupport.js +1 -1
- package/bin/cli/model/ModelSupport.js.map +1 -1
- package/bin/cli/shared/Chat.d.ts +1 -1
- package/bin/cli/shared/Chat.js +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 +1 -1
- package/bin/cli/shared/ChatManager.d.ts.map +1 -1
- package/bin/cli/shared/ChatManager.js +20 -21
- package/bin/cli/shared/ChatManager.js.map +1 -1
- package/bin/cli/shared/Config.js +1 -1
- package/bin/cli/shared/Config.js.map +1 -1
- package/bin/cli/shared/ManagedPluginActionCommands.d.ts +15 -0
- package/bin/cli/shared/ManagedPluginActionCommands.d.ts.map +1 -0
- package/bin/cli/shared/{PluginRuntimeActionCommands.js → ManagedPluginActionCommands.js} +13 -12
- package/bin/cli/shared/ManagedPluginActionCommands.js.map +1 -0
- package/bin/cli/shared/{PluginRuntimeRemote.d.ts → ManagedPluginRemote.d.ts} +6 -6
- package/bin/cli/shared/{PluginRuntimeRemote.d.ts.map → ManagedPluginRemote.d.ts.map} +1 -1
- package/bin/cli/shared/{PluginRuntimeRemote.js → ManagedPluginRemote.js} +14 -14
- package/bin/cli/shared/ManagedPluginRemote.js.map +1 -0
- 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 +12 -11
- package/bin/cli/shared/PluginScheduleCommand.js.map +1 -1
- package/bin/cli/shared/{PluginRuntimeSupport.d.ts → PluginTargetSupport.d.ts} +7 -7
- package/bin/cli/shared/PluginTargetSupport.d.ts.map +1 -0
- package/bin/cli/shared/{PluginRuntimeSupport.js → PluginTargetSupport.js} +7 -8
- package/bin/cli/shared/{PluginRuntimeSupport.js.map → PluginTargetSupport.js.map} +1 -1
- package/bin/cli/shared/Plugins.d.ts.map +1 -1
- package/bin/cli/shared/Plugins.js +30 -21
- package/bin/cli/shared/Plugins.js.map +1 -1
- package/bin/cli/shared/PortHints.js +1 -1
- package/bin/config/DowncitySchema.d.ts.map +1 -1
- package/bin/config/DowncitySchema.js +2 -8
- package/bin/config/DowncitySchema.js.map +1 -1
- package/bin/config/Paths.d.ts +2 -2
- package/bin/config/Paths.js +2 -2
- package/bin/control/AgentStatusApiRoutes.js +2 -2
- package/bin/control/AgentStatusApiRoutes.js.map +1 -1
- package/bin/control/ChannelAccountApiRoutes.d.ts.map +1 -1
- package/bin/control/ChannelAccountApiRoutes.js +6 -7
- package/bin/control/ChannelAccountApiRoutes.js.map +1 -1
- package/bin/control/ControlGateway.d.ts.map +1 -1
- package/bin/control/ControlGateway.js +3 -2
- package/bin/control/ControlGateway.js.map +1 -1
- package/bin/control/PluginApiRoutes.d.ts.map +1 -1
- package/bin/control/PluginApiRoutes.js +38 -30
- package/bin/control/PluginApiRoutes.js.map +1 -1
- package/bin/control/gateway/AgentActions.d.ts.map +1 -1
- package/bin/control/gateway/AgentActions.js +16 -11
- package/bin/control/gateway/AgentActions.js.map +1 -1
- package/bin/control/gateway/AgentCatalog.js +1 -1
- package/bin/control/gateway/AgentCatalog.js.map +1 -1
- package/bin/control/instant/InstantApiRoutes.d.ts +3 -3
- package/bin/control/instant/InstantApiRoutes.d.ts.map +1 -1
- package/bin/control/instant/InstantApiRoutes.js +5 -5
- package/bin/control/instant/InstantApiRoutes.js.map +1 -1
- package/bin/control/instant/{InstantSessionService.d.ts → InstantSessionRunner.d.ts} +7 -7
- package/bin/control/instant/InstantSessionRunner.d.ts.map +1 -0
- package/bin/control/instant/{InstantSessionService.js → InstantSessionRunner.js} +4 -4
- package/bin/control/instant/InstantSessionRunner.js.map +1 -0
- package/bin/http/auth/RoutePolicy.js +4 -4
- package/bin/http/auth/RoutePolicy.js.map +1 -1
- package/bin/model/runtime/CreateRuntimeModel.d.ts +2 -10
- package/bin/model/runtime/CreateRuntimeModel.d.ts.map +1 -1
- package/bin/model/runtime/CreateRuntimeModel.js +1 -16
- 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/process/daemon/Api.d.ts +2 -2
- package/bin/process/daemon/Api.js +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 +2 -156
- package/bin/process/registry/AgentHostRuntime.js.map +1 -1
- package/package.json +3 -2
- package/src/cli/Index.ts +13 -5
- package/src/cli/agent/AgentChat.ts +1 -1
- package/src/cli/agent/AgentManager.ts +3 -3
- package/src/cli/agent/Init.ts +15 -14
- package/src/cli/agent/Restart.ts +1 -1
- package/src/cli/agent/Run.ts +12 -18
- package/src/cli/agent/Start.ts +1 -1
- package/src/cli/control-plane/ControlPlaneProcess.ts +2 -3
- package/src/cli/model/ModelSupport.ts +1 -1
- package/src/cli/shared/Chat.ts +1 -1
- package/src/cli/shared/ChatAuth.ts +10 -11
- package/src/cli/shared/ChatManager.ts +21 -22
- package/src/cli/shared/Config.ts +1 -1
- package/src/cli/shared/{PluginRuntimeActionCommands.ts → ManagedPluginActionCommands.ts} +18 -15
- package/src/cli/shared/{PluginRuntimeRemote.ts → ManagedPluginRemote.ts} +15 -15
- package/src/cli/shared/PluginScheduleCommand.ts +12 -11
- package/src/cli/shared/{PluginRuntimeSupport.ts → PluginTargetSupport.ts} +8 -9
- package/src/cli/shared/Plugins.ts +38 -28
- package/src/cli/shared/PortHints.ts +1 -1
- package/src/config/DowncitySchema.ts +2 -8
- package/src/config/Paths.ts +2 -2
- package/src/control/AgentStatusApiRoutes.ts +5 -5
- package/src/control/ChannelAccountApiRoutes.ts +6 -7
- package/src/control/ControlGateway.ts +3 -2
- package/src/control/PluginApiRoutes.ts +42 -32
- package/src/control/gateway/AgentActions.ts +16 -11
- package/src/control/gateway/AgentCatalog.ts +1 -1
- package/src/control/instant/InstantApiRoutes.ts +8 -8
- package/src/control/instant/{InstantSessionService.ts → InstantSessionRunner.ts} +7 -7
- package/src/http/auth/RoutePolicy.ts +4 -4
- package/src/model/runtime/CreateRuntimeModel.ts +1 -26
- package/src/model/runtime/ExecutionModelBinding.ts +120 -0
- package/src/process/daemon/Api.ts +2 -2
- package/src/process/registry/AgentHostRuntime.ts +2 -164
- package/tsconfig.json +2 -1
- package/bin/cli/shared/PluginRuntimeActionCommands.d.ts +0 -14
- package/bin/cli/shared/PluginRuntimeActionCommands.d.ts.map +0 -1
- package/bin/cli/shared/PluginRuntimeActionCommands.js.map +0 -1
- package/bin/cli/shared/PluginRuntimeRemote.js.map +0 -1
- package/bin/cli/shared/PluginRuntimeSupport.d.ts.map +0 -1
- package/bin/control/instant/InstantSessionService.d.ts.map +0 -1
- package/bin/control/instant/InstantSessionService.js.map +0 -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/registry/PluginRuntime.d.ts +0 -24
- package/bin/process/registry/PluginRuntime.d.ts.map +0 -1
- package/bin/process/registry/PluginRuntime.js +0 -31
- package/bin/process/registry/PluginRuntime.js.map +0 -1
- package/src/platform/chatAuthorization/Store.ts +0 -181
- package/src/process/registry/PluginRuntime.ts +0 -42
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* City 级 chat authorization 配置存储。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 静态 chat 授权配置属于 city 维护的项目侧状态。
|
|
6
|
-
* - 这里把配置落在项目 `.downcity/chat/authorization/config.json`。
|
|
7
|
-
* - agent 只消费注入进来的读写能力,不再自己管理这份配置。
|
|
8
|
-
*/
|
|
9
|
-
import fs from "fs-extra";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import { CHAT_AUTHORIZATION_CHANNELS, createDefaultChatAuthorizationRoles, } from "@downcity/agent";
|
|
12
|
-
function normalizeText(value) {
|
|
13
|
-
const text = String(value || "").trim();
|
|
14
|
-
return text || undefined;
|
|
15
|
-
}
|
|
16
|
-
function normalizeRoleMap(input) {
|
|
17
|
-
const defaultRoles = createDefaultChatAuthorizationRoles();
|
|
18
|
-
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
19
|
-
return defaultRoles;
|
|
20
|
-
const roles = {};
|
|
21
|
-
for (const [rawRoleId, rawRole] of Object.entries(input)) {
|
|
22
|
-
const roleId = normalizeText(rawRoleId);
|
|
23
|
-
if (!roleId)
|
|
24
|
-
continue;
|
|
25
|
-
const roleObj = rawRole && typeof rawRole === "object" && !Array.isArray(rawRole)
|
|
26
|
-
? rawRole
|
|
27
|
-
: null;
|
|
28
|
-
if (!roleObj)
|
|
29
|
-
continue;
|
|
30
|
-
const builtinRole = defaultRoles[roleId];
|
|
31
|
-
const permissions = Array.isArray(roleObj.permissions)
|
|
32
|
-
? [...new Set(roleObj.permissions.map((item) => normalizeText(item)).filter(Boolean))]
|
|
33
|
-
: [];
|
|
34
|
-
roles[roleId] = {
|
|
35
|
-
roleId,
|
|
36
|
-
name: normalizeText(roleObj.name) || builtinRole?.name || roleId,
|
|
37
|
-
...(normalizeText(roleObj.description) || builtinRole?.description
|
|
38
|
-
? {
|
|
39
|
-
description: normalizeText(roleObj.description) || builtinRole?.description || undefined,
|
|
40
|
-
}
|
|
41
|
-
: {}),
|
|
42
|
-
permissions: permissions,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (Object.keys(roles).length === 0)
|
|
46
|
-
return defaultRoles;
|
|
47
|
-
if (!roles.default)
|
|
48
|
-
roles.default = defaultRoles.default;
|
|
49
|
-
return roles;
|
|
50
|
-
}
|
|
51
|
-
function normalizeBindingMap(input, roles) {
|
|
52
|
-
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
53
|
-
return {};
|
|
54
|
-
const out = {};
|
|
55
|
-
for (const [rawId, rawRoleId] of Object.entries(input)) {
|
|
56
|
-
const entityId = normalizeText(rawId);
|
|
57
|
-
const roleId = normalizeText(rawRoleId);
|
|
58
|
-
if (!entityId || !roleId || !roles[roleId])
|
|
59
|
-
continue;
|
|
60
|
-
out[entityId] = roleId;
|
|
61
|
-
}
|
|
62
|
-
return out;
|
|
63
|
-
}
|
|
64
|
-
function normalizeChannelConfig(input, roles) {
|
|
65
|
-
const raw = input && typeof input === "object" && !Array.isArray(input)
|
|
66
|
-
? input
|
|
67
|
-
: {};
|
|
68
|
-
const defaultUserRoleId = normalizeText(raw.defaultUserRoleId) || "default";
|
|
69
|
-
return {
|
|
70
|
-
defaultUserRoleId: roles[defaultUserRoleId] ? defaultUserRoleId : "default",
|
|
71
|
-
userRoles: normalizeBindingMap(raw.userRoles, roles),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function normalizeAuthorizationConfig(input) {
|
|
75
|
-
const raw = input && typeof input === "object" && !Array.isArray(input)
|
|
76
|
-
? input
|
|
77
|
-
: {};
|
|
78
|
-
const roles = normalizeRoleMap(raw.roles);
|
|
79
|
-
const channels = {};
|
|
80
|
-
for (const channel of CHAT_AUTHORIZATION_CHANNELS) {
|
|
81
|
-
channels[channel] = normalizeChannelConfig(raw.channels?.[channel], roles);
|
|
82
|
-
}
|
|
83
|
-
return { roles, channels };
|
|
84
|
-
}
|
|
85
|
-
function getChatAuthorizationConfigPath(projectRoot) {
|
|
86
|
-
return path.join(projectRoot, ".downcity", "chat", "authorization", "config.json");
|
|
87
|
-
}
|
|
88
|
-
function readConfigFile(projectRoot) {
|
|
89
|
-
const file = getChatAuthorizationConfigPath(projectRoot);
|
|
90
|
-
if (!fs.existsSync(file))
|
|
91
|
-
return normalizeAuthorizationConfig({});
|
|
92
|
-
try {
|
|
93
|
-
return normalizeAuthorizationConfig(fs.readJsonSync(file));
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return normalizeAuthorizationConfig({});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function writeConfigFile(projectRoot, config) {
|
|
100
|
-
const file = getChatAuthorizationConfigPath(projectRoot);
|
|
101
|
-
fs.ensureDirSync(path.dirname(file));
|
|
102
|
-
fs.writeJsonSync(file, normalizeAuthorizationConfig(config), { spaces: 2 });
|
|
103
|
-
return normalizeAuthorizationConfig(config);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* 同步读取 chat authorization 配置。
|
|
107
|
-
*/
|
|
108
|
-
export function readChatAuthorizationConfigSync(projectRoot) {
|
|
109
|
-
return readConfigFile(String(projectRoot || "").trim());
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* 读取 chat authorization 配置。
|
|
113
|
-
*/
|
|
114
|
-
export async function readChatAuthorizationConfig(projectRoot) {
|
|
115
|
-
return readChatAuthorizationConfigSync(projectRoot);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* 覆盖写入 chat authorization 配置。
|
|
119
|
-
*/
|
|
120
|
-
export async function writeChatAuthorizationConfig(projectRoot, nextConfig) {
|
|
121
|
-
return writeConfigFile(String(projectRoot || "").trim(), nextConfig);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* 设置单个用户角色。
|
|
125
|
-
*/
|
|
126
|
-
export async function setChatAuthorizationUserRole(params) {
|
|
127
|
-
const projectRoot = String(params.projectRoot || "").trim();
|
|
128
|
-
const userId = normalizeText(params.userId);
|
|
129
|
-
const roleId = normalizeText(params.roleId);
|
|
130
|
-
if (!projectRoot)
|
|
131
|
-
throw new Error("projectRoot is required");
|
|
132
|
-
if (!userId || !roleId)
|
|
133
|
-
throw new Error("userId and roleId are required");
|
|
134
|
-
const next = readConfigFile(projectRoot);
|
|
135
|
-
next.roles = normalizeRoleMap(next.roles);
|
|
136
|
-
if (!next.roles[roleId])
|
|
137
|
-
throw new Error(`Unknown roleId: ${roleId}`);
|
|
138
|
-
next.channels ??= {};
|
|
139
|
-
const channelConfig = normalizeChannelConfig(next.channels[params.channel], next.roles);
|
|
140
|
-
channelConfig.userRoles ??= {};
|
|
141
|
-
channelConfig.userRoles[userId] = roleId;
|
|
142
|
-
next.channels[params.channel] = channelConfig;
|
|
143
|
-
return writeConfigFile(projectRoot, next);
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=Store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/platform/chatAuthorization/Store.ts"],"names":[],"mappings":"AAAA;;;;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
|
-
* - PluginRegistry / PluginManager 属于 city runtime,不应直接反向 import agent AgentContext 单例。
|
|
6
|
-
* - 当前模块只负责保存“当前执行上下文 resolver”的注入入口。
|
|
7
|
-
* - agent runtime 仅作为 context provider 注册方,不再成为 plugin manager 的宿主。
|
|
8
|
-
*/
|
|
9
|
-
import type { AgentContext } from "@downcity/agent";
|
|
10
|
-
type AgentContextResolver = () => AgentContext;
|
|
11
|
-
/**
|
|
12
|
-
* 设置当前 city plugin runtime 的执行上下文 resolver。
|
|
13
|
-
*/
|
|
14
|
-
export declare function setPluginRuntimeContextResolver(resolver: AgentContextResolver): void;
|
|
15
|
-
/**
|
|
16
|
-
* 清理当前 city plugin runtime 的执行上下文 resolver。
|
|
17
|
-
*/
|
|
18
|
-
export declare function clearPluginRuntimeContextResolver(): void;
|
|
19
|
-
/**
|
|
20
|
-
* 读取当前 city plugin runtime 的执行上下文 resolver。
|
|
21
|
-
*/
|
|
22
|
-
export declare function getPluginRuntimeContextResolver(): AgentContextResolver;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=PluginRuntime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRuntime.d.ts","sourceRoot":"","sources":["../../../src/process/registry/PluginRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,KAAK,oBAAoB,GAAG,MAAM,YAAY,CAAC;AAI/C;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,oBAAoB,GAC7B,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,oBAAoB,CAOtE"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PluginRuntime:city 级 plugin 运行时注入模块。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - PluginRegistry / PluginManager 属于 city runtime,不应直接反向 import agent AgentContext 单例。
|
|
6
|
-
* - 当前模块只负责保存“当前执行上下文 resolver”的注入入口。
|
|
7
|
-
* - agent runtime 仅作为 context provider 注册方,不再成为 plugin manager 的宿主。
|
|
8
|
-
*/
|
|
9
|
-
let executionContextResolver = null;
|
|
10
|
-
/**
|
|
11
|
-
* 设置当前 city plugin runtime 的执行上下文 resolver。
|
|
12
|
-
*/
|
|
13
|
-
export function setPluginRuntimeContextResolver(resolver) {
|
|
14
|
-
executionContextResolver = resolver;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 清理当前 city plugin runtime 的执行上下文 resolver。
|
|
18
|
-
*/
|
|
19
|
-
export function clearPluginRuntimeContextResolver() {
|
|
20
|
-
executionContextResolver = null;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 读取当前 city plugin runtime 的执行上下文 resolver。
|
|
24
|
-
*/
|
|
25
|
-
export function getPluginRuntimeContextResolver() {
|
|
26
|
-
if (!executionContextResolver) {
|
|
27
|
-
throw new Error("Plugin runtime context resolver is not configured. Configure city plugin runtime before using PluginManager.");
|
|
28
|
-
}
|
|
29
|
-
return executionContextResolver;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=PluginRuntime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRuntime.js","sourceRoot":"","sources":["../../../src/process/registry/PluginRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,IAAI,wBAAwB,GAAgC,IAAI,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAC7C,QAA8B;IAE9B,wBAAwB,GAAG,QAAQ,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC;IAC/C,wBAAwB,GAAG,IAAI,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B;IAC7C,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,8GAA8G,CAC/G,CAAC;IACJ,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* City 级 chat authorization 配置存储。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 静态 chat 授权配置属于 city 维护的项目侧状态。
|
|
6
|
-
* - 这里把配置落在项目 `.downcity/chat/authorization/config.json`。
|
|
7
|
-
* - agent 只消费注入进来的读写能力,不再自己管理这份配置。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import fs from "fs-extra";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import type {
|
|
13
|
-
ChatAuthorizationChannel,
|
|
14
|
-
ChatAuthorizationConfig,
|
|
15
|
-
ChatAuthorizationRole,
|
|
16
|
-
ChatChannelAuthorizationConfig,
|
|
17
|
-
} from "@downcity/agent";
|
|
18
|
-
import {
|
|
19
|
-
CHAT_AUTHORIZATION_CHANNELS,
|
|
20
|
-
createDefaultChatAuthorizationRoles,
|
|
21
|
-
} from "@downcity/agent";
|
|
22
|
-
|
|
23
|
-
function normalizeText(value: unknown): string | undefined {
|
|
24
|
-
const text = String(value || "").trim();
|
|
25
|
-
return text || undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function normalizeRoleMap(input: unknown): Record<string, ChatAuthorizationRole> {
|
|
29
|
-
const defaultRoles = createDefaultChatAuthorizationRoles();
|
|
30
|
-
if (!input || typeof input !== "object" || Array.isArray(input)) return defaultRoles;
|
|
31
|
-
const roles: Record<string, ChatAuthorizationRole> = {};
|
|
32
|
-
for (const [rawRoleId, rawRole] of Object.entries(input as Record<string, unknown>)) {
|
|
33
|
-
const roleId = normalizeText(rawRoleId);
|
|
34
|
-
if (!roleId) continue;
|
|
35
|
-
const roleObj =
|
|
36
|
-
rawRole && typeof rawRole === "object" && !Array.isArray(rawRole)
|
|
37
|
-
? (rawRole as {
|
|
38
|
-
name?: unknown;
|
|
39
|
-
description?: unknown;
|
|
40
|
-
permissions?: unknown[];
|
|
41
|
-
})
|
|
42
|
-
: null;
|
|
43
|
-
if (!roleObj) continue;
|
|
44
|
-
const builtinRole = defaultRoles[roleId];
|
|
45
|
-
const permissions = Array.isArray(roleObj.permissions)
|
|
46
|
-
? [...new Set(roleObj.permissions.map((item) => normalizeText(item)).filter(Boolean))]
|
|
47
|
-
: [];
|
|
48
|
-
roles[roleId] = {
|
|
49
|
-
roleId,
|
|
50
|
-
name: normalizeText(roleObj.name) || builtinRole?.name || roleId,
|
|
51
|
-
...(normalizeText(roleObj.description) || builtinRole?.description
|
|
52
|
-
? {
|
|
53
|
-
description:
|
|
54
|
-
normalizeText(roleObj.description) || builtinRole?.description || undefined,
|
|
55
|
-
}
|
|
56
|
-
: {}),
|
|
57
|
-
permissions: permissions as ChatAuthorizationRole["permissions"],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (Object.keys(roles).length === 0) return defaultRoles;
|
|
61
|
-
if (!roles.default) roles.default = defaultRoles.default;
|
|
62
|
-
return roles;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function normalizeBindingMap(
|
|
66
|
-
input: unknown,
|
|
67
|
-
roles: Record<string, ChatAuthorizationRole>,
|
|
68
|
-
): Record<string, string> {
|
|
69
|
-
if (!input || typeof input !== "object" || Array.isArray(input)) return {};
|
|
70
|
-
const out: Record<string, string> = {};
|
|
71
|
-
for (const [rawId, rawRoleId] of Object.entries(input as Record<string, unknown>)) {
|
|
72
|
-
const entityId = normalizeText(rawId);
|
|
73
|
-
const roleId = normalizeText(rawRoleId);
|
|
74
|
-
if (!entityId || !roleId || !roles[roleId]) continue;
|
|
75
|
-
out[entityId] = roleId;
|
|
76
|
-
}
|
|
77
|
-
return out;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function normalizeChannelConfig(
|
|
81
|
-
input: unknown,
|
|
82
|
-
roles: Record<string, ChatAuthorizationRole>,
|
|
83
|
-
): ChatChannelAuthorizationConfig {
|
|
84
|
-
const raw =
|
|
85
|
-
input && typeof input === "object" && !Array.isArray(input)
|
|
86
|
-
? (input as {
|
|
87
|
-
defaultUserRoleId?: unknown;
|
|
88
|
-
userRoles?: unknown;
|
|
89
|
-
})
|
|
90
|
-
: {};
|
|
91
|
-
const defaultUserRoleId = normalizeText(raw.defaultUserRoleId) || "default";
|
|
92
|
-
return {
|
|
93
|
-
defaultUserRoleId: roles[defaultUserRoleId] ? defaultUserRoleId : "default",
|
|
94
|
-
userRoles: normalizeBindingMap(raw.userRoles, roles),
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function normalizeAuthorizationConfig(input: unknown): ChatAuthorizationConfig {
|
|
99
|
-
const raw =
|
|
100
|
-
input && typeof input === "object" && !Array.isArray(input)
|
|
101
|
-
? (input as { roles?: unknown; channels?: Record<string, unknown> })
|
|
102
|
-
: {};
|
|
103
|
-
const roles = normalizeRoleMap(raw.roles);
|
|
104
|
-
const channels: Partial<Record<ChatAuthorizationChannel, ChatChannelAuthorizationConfig>> = {};
|
|
105
|
-
for (const channel of CHAT_AUTHORIZATION_CHANNELS) {
|
|
106
|
-
channels[channel] = normalizeChannelConfig(raw.channels?.[channel], roles);
|
|
107
|
-
}
|
|
108
|
-
return { roles, channels };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function getChatAuthorizationConfigPath(projectRoot: string): string {
|
|
112
|
-
return path.join(projectRoot, ".downcity", "chat", "authorization", "config.json");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function readConfigFile(projectRoot: string): ChatAuthorizationConfig {
|
|
116
|
-
const file = getChatAuthorizationConfigPath(projectRoot);
|
|
117
|
-
if (!fs.existsSync(file)) return normalizeAuthorizationConfig({});
|
|
118
|
-
try {
|
|
119
|
-
return normalizeAuthorizationConfig(fs.readJsonSync(file));
|
|
120
|
-
} catch {
|
|
121
|
-
return normalizeAuthorizationConfig({});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function writeConfigFile(projectRoot: string, config: ChatAuthorizationConfig): ChatAuthorizationConfig {
|
|
126
|
-
const file = getChatAuthorizationConfigPath(projectRoot);
|
|
127
|
-
fs.ensureDirSync(path.dirname(file));
|
|
128
|
-
fs.writeJsonSync(file, normalizeAuthorizationConfig(config), { spaces: 2 });
|
|
129
|
-
return normalizeAuthorizationConfig(config);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 同步读取 chat authorization 配置。
|
|
134
|
-
*/
|
|
135
|
-
export function readChatAuthorizationConfigSync(projectRoot: string): ChatAuthorizationConfig {
|
|
136
|
-
return readConfigFile(String(projectRoot || "").trim());
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 读取 chat authorization 配置。
|
|
141
|
-
*/
|
|
142
|
-
export async function readChatAuthorizationConfig(
|
|
143
|
-
projectRoot: string,
|
|
144
|
-
): Promise<ChatAuthorizationConfig> {
|
|
145
|
-
return readChatAuthorizationConfigSync(projectRoot);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 覆盖写入 chat authorization 配置。
|
|
150
|
-
*/
|
|
151
|
-
export async function writeChatAuthorizationConfig(
|
|
152
|
-
projectRoot: string,
|
|
153
|
-
nextConfig: ChatAuthorizationConfig,
|
|
154
|
-
): Promise<ChatAuthorizationConfig> {
|
|
155
|
-
return writeConfigFile(String(projectRoot || "").trim(), nextConfig);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* 设置单个用户角色。
|
|
160
|
-
*/
|
|
161
|
-
export async function setChatAuthorizationUserRole(params: {
|
|
162
|
-
projectRoot: string;
|
|
163
|
-
channel: ChatAuthorizationChannel;
|
|
164
|
-
userId: string;
|
|
165
|
-
roleId: string;
|
|
166
|
-
}): Promise<ChatAuthorizationConfig> {
|
|
167
|
-
const projectRoot = String(params.projectRoot || "").trim();
|
|
168
|
-
const userId = normalizeText(params.userId);
|
|
169
|
-
const roleId = normalizeText(params.roleId);
|
|
170
|
-
if (!projectRoot) throw new Error("projectRoot is required");
|
|
171
|
-
if (!userId || !roleId) throw new Error("userId and roleId are required");
|
|
172
|
-
const next = readConfigFile(projectRoot);
|
|
173
|
-
next.roles = normalizeRoleMap(next.roles);
|
|
174
|
-
if (!next.roles[roleId]) throw new Error(`Unknown roleId: ${roleId}`);
|
|
175
|
-
next.channels ??= {};
|
|
176
|
-
const channelConfig = normalizeChannelConfig(next.channels[params.channel], next.roles);
|
|
177
|
-
channelConfig.userRoles ??= {};
|
|
178
|
-
channelConfig.userRoles[userId] = roleId;
|
|
179
|
-
next.channels[params.channel] = channelConfig;
|
|
180
|
-
return writeConfigFile(projectRoot, next);
|
|
181
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PluginRuntime:city 级 plugin 运行时注入模块。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - PluginRegistry / PluginManager 属于 city runtime,不应直接反向 import agent AgentContext 单例。
|
|
6
|
-
* - 当前模块只负责保存“当前执行上下文 resolver”的注入入口。
|
|
7
|
-
* - agent runtime 仅作为 context provider 注册方,不再成为 plugin manager 的宿主。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { AgentContext } from "@downcity/agent";
|
|
11
|
-
|
|
12
|
-
type AgentContextResolver = () => AgentContext;
|
|
13
|
-
|
|
14
|
-
let executionContextResolver: AgentContextResolver | null = null;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 设置当前 city plugin runtime 的执行上下文 resolver。
|
|
18
|
-
*/
|
|
19
|
-
export function setPluginRuntimeContextResolver(
|
|
20
|
-
resolver: AgentContextResolver,
|
|
21
|
-
): void {
|
|
22
|
-
executionContextResolver = resolver;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 清理当前 city plugin runtime 的执行上下文 resolver。
|
|
27
|
-
*/
|
|
28
|
-
export function clearPluginRuntimeContextResolver(): void {
|
|
29
|
-
executionContextResolver = null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 读取当前 city plugin runtime 的执行上下文 resolver。
|
|
34
|
-
*/
|
|
35
|
-
export function getPluginRuntimeContextResolver(): AgentContextResolver {
|
|
36
|
-
if (!executionContextResolver) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
"Plugin runtime context resolver is not configured. Configure city plugin runtime before using PluginManager.",
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return executionContextResolver;
|
|
42
|
-
}
|