@downcity/agent 1.1.43 → 1.1.62
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 +11 -12
- package/bin/agent/Agent.d.ts +31 -16
- package/bin/agent/Agent.d.ts.map +1 -1
- package/bin/agent/Agent.js +47 -63
- package/bin/agent/Agent.js.map +1 -1
- package/bin/agent/RemoteAgent.d.ts +6 -6
- package/bin/agent/RemoteAgent.d.ts.map +1 -1
- package/bin/agent/RemoteAgent.js +377 -267
- package/bin/agent/RemoteAgent.js.map +1 -1
- package/bin/config/AgentInitializer.d.ts +5 -5
- package/bin/config/AgentInitializer.d.ts.map +1 -1
- package/bin/config/AgentInitializer.js +15 -13
- package/bin/config/AgentInitializer.js.map +1 -1
- package/bin/config/Config.d.ts +9 -30
- package/bin/config/Config.d.ts.map +1 -1
- package/bin/config/Config.js +23 -70
- package/bin/config/Config.js.map +1 -1
- package/bin/config/Defaults.d.ts.map +1 -1
- package/bin/config/Defaults.js +1 -9
- package/bin/config/Defaults.js.map +1 -1
- package/bin/config/DowncitySchema.d.ts.map +1 -1
- package/bin/config/DowncitySchema.js +4 -112
- package/bin/config/DowncitySchema.js.map +1 -1
- package/bin/config/ExecutionBinding.d.ts +1 -16
- package/bin/config/ExecutionBinding.d.ts.map +1 -1
- package/bin/config/ExecutionBinding.js +2 -22
- package/bin/config/ExecutionBinding.js.map +1 -1
- package/bin/config/Paths.d.ts +4 -43
- package/bin/config/Paths.d.ts.map +1 -1
- package/bin/config/Paths.js +10 -30
- package/bin/config/Paths.js.map +1 -1
- package/bin/config/PlatformPaths.d.ts +0 -4
- package/bin/config/PlatformPaths.d.ts.map +1 -1
- package/bin/config/PlatformPaths.js +5 -1
- package/bin/config/PlatformPaths.js.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +0 -4
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
- package/bin/executor/composer/system/default/InitPrompts.d.ts +1 -1
- package/bin/executor/composer/system/default/InitPrompts.js +1 -1
- package/bin/executor/composer/system/default/SystemDomain.js +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/init/PROFILE.md.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/init/PROFILE.md.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/init/PROFILE.md.js +1 -1
- package/bin/executor/composer/system/default/assets/init/PROFILE.md.js.map +1 -1
- package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/plugin.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/task.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/task.prompt.js +1 -1
- package/bin/executor/messages/ChatMessageMarkupTypes.d.ts +1 -1
- package/bin/executor/messages/ChatMessageMarkupTypes.js +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +1 -2
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +17 -56
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
- package/bin/executor/tools/shell/ShellToolBridge.js +1 -1
- package/bin/executor/tools/shell/ShellToolBridge.js.map +1 -1
- package/bin/executor/tools/shell/ShellToolDefinition.d.ts +2 -2
- package/bin/executor/tools/shell/ShellToolFormatting.d.ts +1 -1
- package/bin/executor/tools/shell/ShellToolFormatting.js +9 -9
- package/bin/executor/tools/shell/ShellToolFormatting.js.map +1 -1
- package/bin/executor/tools/shell/ShellToolSchemas.d.ts +7 -75
- package/bin/executor/tools/shell/ShellToolSchemas.d.ts.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts +5 -24
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.js +1 -1
- package/bin/executor/types/SessionRun.d.ts +1 -1
- package/bin/index.d.ts +5 -6
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +6 -5
- package/bin/index.js.map +1 -1
- package/bin/model/CityModelAdapter.d.ts +23 -0
- package/bin/model/CityModelAdapter.d.ts.map +1 -0
- package/bin/model/CityModelAdapter.js +338 -0
- package/bin/model/CityModelAdapter.js.map +1 -0
- package/bin/plugin/core/PluginCommandRequest.d.ts +1 -1
- package/bin/plugin/core/PluginCommandRequest.js +1 -1
- package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
- package/bin/plugin/core/PluginLocalExecution.js +4 -8
- package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
- package/bin/plugin/types/PluginApi.d.ts +1 -1
- package/bin/rpc/Client.d.ts +104 -0
- package/bin/rpc/Client.d.ts.map +1 -0
- package/bin/rpc/Client.js +300 -0
- package/bin/rpc/Client.js.map +1 -0
- package/bin/rpc/Server.d.ts +41 -0
- package/bin/rpc/Server.d.ts.map +1 -0
- package/bin/rpc/Server.js +164 -0
- package/bin/rpc/Server.js.map +1 -0
- package/bin/runtime/host/daemon/Api.d.ts +1 -1
- package/bin/runtime/host/daemon/Client.d.ts +1 -1
- package/bin/runtime/host/daemon/Client.d.ts.map +1 -1
- package/bin/runtime/host/daemon/Client.js +30 -20
- package/bin/runtime/host/daemon/Client.js.map +1 -1
- package/bin/runtime/host/daemon/Paths.d.ts +1 -1
- package/bin/runtime/host/daemon/Paths.js +1 -1
- package/bin/runtime/host/daemon/ProjectSetup.js +2 -2
- package/bin/runtime/server/http/control/OverviewRoutes.js +1 -1
- package/bin/runtime/server/http/control/OverviewRoutes.js.map +1 -1
- package/bin/session/Session.d.ts +1 -0
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +32 -6
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionTitle.d.ts +49 -0
- package/bin/session/SessionTitle.d.ts.map +1 -0
- package/bin/session/SessionTitle.js +130 -0
- package/bin/session/SessionTitle.js.map +1 -0
- package/bin/session/browse/Browse.d.ts +2 -1
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +18 -15
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/index.d.ts +3 -2
- package/bin/session/index.d.ts.map +1 -1
- package/bin/session/index.js +3 -2
- package/bin/session/index.js.map +1 -1
- package/bin/session/storage/Metadata.d.ts +4 -0
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +12 -25
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/session/storage/Paths.d.ts +0 -4
- package/bin/session/storage/Paths.d.ts.map +1 -1
- package/bin/session/storage/Paths.js +0 -6
- package/bin/session/storage/Paths.js.map +1 -1
- package/bin/session/storage/Persistence.d.ts.map +1 -1
- package/bin/session/storage/Persistence.js +1 -4
- package/bin/session/storage/Persistence.js.map +1 -1
- package/bin/types/agent/AgentTypes.d.ts +32 -57
- package/bin/types/agent/AgentTypes.d.ts.map +1 -1
- package/bin/types/config/AgentProject.d.ts +7 -6
- package/bin/types/config/AgentProject.d.ts.map +1 -1
- package/bin/types/config/DowncityConfig.d.ts +11 -69
- package/bin/types/config/DowncityConfig.d.ts.map +1 -1
- package/bin/types/config/ExecutionBinding.d.ts +4 -4
- package/bin/types/config/ExecutionBinding.js +1 -1
- package/bin/types/config/LlmConfig.d.ts +1 -1
- package/bin/types/config/Start.d.ts +3 -0
- package/bin/types/config/Start.d.ts.map +1 -1
- package/bin/types/config/Start.js +2 -0
- package/bin/types/config/Start.js.map +1 -1
- package/bin/types/runtime/auth/AuthPermission.js +2 -2
- package/bin/types/runtime/auth/AuthPermission.js.map +1 -1
- package/bin/types/runtime/host/Store.d.ts +10 -227
- package/bin/types/runtime/host/Store.d.ts.map +1 -1
- package/bin/types/runtime/host/Store.js +7 -0
- package/bin/types/runtime/host/Store.js.map +1 -1
- package/bin/types/runtime/http/InlineInstant.d.ts +1 -1
- package/bin/types/runtime/platform/Platform.d.ts +7 -7
- package/bin/types/runtime/platform/Platform.d.ts.map +1 -1
- package/bin/types/runtime/platform/PlatformGateway.d.ts +2 -2
- package/bin/types/runtime/platform/PlatformGateway.d.ts.map +1 -1
- package/bin/utils/Time.d.ts +0 -1
- package/bin/utils/Time.d.ts.map +1 -1
- package/bin/utils/Time.js +0 -7
- package/bin/utils/Time.js.map +1 -1
- package/bin/utils/storage/index.d.ts +0 -1
- package/bin/utils/storage/index.d.ts.map +1 -1
- package/bin/utils/storage/index.js +0 -6
- package/bin/utils/storage/index.js.map +1 -1
- package/package.json +22 -23
- package/src/agent/Agent.ts +57 -73
- package/src/agent/RemoteAgent.ts +515 -345
- package/src/config/AgentInitializer.ts +15 -13
- package/src/config/Config.ts +28 -85
- package/src/config/Defaults.ts +1 -9
- package/src/config/DowncitySchema.ts +4 -114
- package/src/config/ExecutionBinding.ts +2 -24
- package/src/config/Paths.ts +10 -43
- package/src/config/PlatformPaths.ts +5 -1
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +0 -4
- package/src/executor/composer/system/default/InitPrompts.ts +1 -1
- package/src/executor/composer/system/default/SystemDomain.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts.txt +1 -1
- package/src/executor/composer/system/default/assets/init/PROFILE.md.ts +1 -1
- package/src/executor/composer/system/default/assets/init/PROFILE.md.ts.txt +1 -2
- package/src/executor/composer/system/default/assets/plugin.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/plugin.prompt.ts.txt +18 -18
- package/src/executor/composer/system/default/assets/task.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/task.prompt.ts.txt +1 -1
- package/src/executor/messages/ChatMessageMarkupTypes.ts +1 -1
- package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +17 -57
- package/src/executor/tools/shell/ShellToolBridge.ts +1 -1
- package/src/executor/tools/shell/ShellToolFormatting.ts +9 -9
- package/src/executor/types/SessionHistoryMeta.ts +5 -25
- package/src/executor/types/SessionRun.ts +1 -1
- package/src/index.ts +12 -19
- package/src/model/CityModelAdapter.ts +384 -0
- package/src/plugin/core/PluginCommandRequest.ts +1 -1
- package/src/plugin/core/PluginLocalExecution.ts +4 -8
- package/src/plugin/types/PluginApi.ts +1 -1
- package/src/rpc/Client.ts +467 -0
- package/src/rpc/Server.ts +302 -0
- package/src/runtime/host/daemon/Api.ts +1 -1
- package/src/runtime/host/daemon/Client.ts +44 -22
- package/src/runtime/host/daemon/Paths.ts +1 -1
- package/src/runtime/host/daemon/ProjectSetup.ts +2 -2
- package/src/runtime/server/http/control/OverviewRoutes.ts +1 -1
- package/src/session/Session.ts +40 -6
- package/src/session/SessionTitle.ts +192 -0
- package/src/session/browse/Browse.ts +22 -13
- package/src/session/index.ts +5 -1
- package/src/session/storage/Metadata.ts +14 -29
- package/src/session/storage/Paths.ts +0 -10
- package/src/session/storage/Persistence.ts +1 -4
- package/src/types/agent/AgentTypes.ts +33 -62
- package/src/types/config/AgentProject.ts +7 -6
- package/src/types/config/DowncityConfig.ts +11 -70
- package/src/types/config/ExecutionBinding.ts +4 -4
- package/src/types/config/LlmConfig.ts +1 -1
- package/src/types/config/Start.ts +3 -0
- package/src/types/runtime/auth/AuthPermission.ts +2 -2
- package/src/types/runtime/host/Store.ts +10 -235
- package/src/types/runtime/http/InlineInstant.ts +1 -1
- package/src/types/runtime/platform/Platform.ts +7 -7
- package/src/types/runtime/platform/PlatformGateway.ts +2 -2
- package/src/utils/Time.ts +0 -6
- package/src/utils/storage/index.ts +0 -7
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/config/ConfigEnvResolver.d.ts +0 -22
- package/bin/config/ConfigEnvResolver.d.ts.map +0 -1
- package/bin/config/ConfigEnvResolver.js +0 -41
- package/bin/config/ConfigEnvResolver.js.map +0 -1
- package/bin/runtime/server/rpc/Server.d.ts +0 -18
- package/bin/runtime/server/rpc/Server.d.ts.map +0 -1
- package/bin/runtime/server/rpc/Server.js +0 -315
- package/bin/runtime/server/rpc/Server.js.map +0 -1
- package/bin/runtime/transport/rpc/Client.d.ts +0 -13
- package/bin/runtime/transport/rpc/Client.d.ts.map +0 -1
- package/bin/runtime/transport/rpc/Client.js +0 -98
- package/bin/runtime/transport/rpc/Client.js.map +0 -1
- package/bin/runtime/transport/rpc/Paths.d.ts +0 -14
- package/bin/runtime/transport/rpc/Paths.d.ts.map +0 -1
- package/bin/runtime/transport/rpc/Paths.js +0 -42
- package/bin/runtime/transport/rpc/Paths.js.map +0 -1
- package/bin/runtime/transport/rpc/Transport.d.ts +0 -21
- package/bin/runtime/transport/rpc/Transport.d.ts.map +0 -1
- package/bin/runtime/transport/rpc/Transport.js +0 -30
- package/bin/runtime/transport/rpc/Transport.js.map +0 -1
- package/bin/types/common/ResolvedConfigValue.d.ts +0 -12
- package/bin/types/common/ResolvedConfigValue.d.ts.map +0 -1
- package/bin/types/common/ResolvedConfigValue.js +0 -2
- package/bin/types/common/ResolvedConfigValue.js.map +0 -1
- package/bin/types/runtime/rpc/LocalRpc.d.ts +0 -69
- package/bin/types/runtime/rpc/LocalRpc.d.ts.map +0 -1
- package/bin/types/runtime/rpc/LocalRpc.js +0 -9
- package/bin/types/runtime/rpc/LocalRpc.js.map +0 -1
- package/src/config/ConfigEnvResolver.ts +0 -52
- package/src/runtime/server/rpc/Server.ts +0 -408
- package/src/runtime/transport/rpc/Client.ts +0 -113
- package/src/runtime/transport/rpc/Paths.ts +0 -50
- package/src/runtime/transport/rpc/Transport.ts +0 -43
- package/src/types/common/ResolvedConfigValue.ts +0 -16
- package/src/types/runtime/rpc/LocalRpc.ts +0 -72
|
@@ -149,11 +149,17 @@ export interface DowncityPluginConfigMap {
|
|
|
149
149
|
|
|
150
150
|
export interface DowncityConfig {
|
|
151
151
|
$schema?: string;
|
|
152
|
-
|
|
152
|
+
/**
|
|
153
|
+
* agent 唯一标识。
|
|
154
|
+
*
|
|
155
|
+
* 关键点(中文)
|
|
156
|
+
* - `@downcity/agent` 只关心稳定标识,不承担展示名语义。
|
|
157
|
+
* - 该字段同时用于 session/runtime/storage 目录归属。
|
|
158
|
+
*/
|
|
159
|
+
id: string;
|
|
153
160
|
version: string;
|
|
154
|
-
description?: string;
|
|
155
161
|
/**
|
|
156
|
-
* Runtime startup configuration used by `
|
|
162
|
+
* Runtime startup configuration used by `town agent start`.
|
|
157
163
|
* CLI flags (if provided) take precedence over this config.
|
|
158
164
|
*/
|
|
159
165
|
start?: {
|
|
@@ -175,7 +181,7 @@ export interface DowncityConfig {
|
|
|
175
181
|
*
|
|
176
182
|
* 关键点(中文)
|
|
177
183
|
* - 项目只有一种执行模式:`api`。
|
|
178
|
-
* -
|
|
184
|
+
* - 绑定 City AIService 暴露的模型 ID。
|
|
179
185
|
*/
|
|
180
186
|
execution?: ExecutionBindingConfig;
|
|
181
187
|
/**
|
|
@@ -191,73 +197,8 @@ export interface DowncityConfig {
|
|
|
191
197
|
*
|
|
192
198
|
* 关键点(中文)
|
|
193
199
|
* - `@downcity/agent` 本地 SDK 不直接消费该字段。
|
|
194
|
-
* - 宿主侧(例如
|
|
200
|
+
* - 宿主侧(例如 `downcity`)可读取该字段控制模型工厂行为,例如 `llm.logMessages`。
|
|
195
201
|
* - 对于项目内 `downcity.json`,通常不需要显式写 provider/model 明细。
|
|
196
202
|
*/
|
|
197
203
|
llm?: LlmConfig;
|
|
198
|
-
/**
|
|
199
|
-
* 上下文管理(工程向配置)。
|
|
200
|
-
*
|
|
201
|
-
* 说明
|
|
202
|
-
* - 对话消息以 UIMessage[] 为唯一事实源(`.downcity/agents/<agentId>/sessions/<sessionId>/messages/messages.jsonl`)。
|
|
203
|
-
* - Agent 每次执行直接把 UIMessage[] 转成 ModelMessage[] 作为 messages 输入。
|
|
204
|
-
* - 超出上下文窗口时会自动 compact(更早段压缩为摘要 + 保留最近窗口)。
|
|
205
|
-
*/
|
|
206
|
-
context?: {
|
|
207
|
-
/**
|
|
208
|
-
* messages(唯一上下文消息来源)的 compact 策略。
|
|
209
|
-
*/
|
|
210
|
-
messages?: {
|
|
211
|
-
/**
|
|
212
|
-
* 历史兼容字段(保留)。
|
|
213
|
-
*
|
|
214
|
-
* 说明(中文)
|
|
215
|
-
* - 当前默认策略按 `compactRatio` 压缩前段消息。
|
|
216
|
-
* - 该字段仍会写入 compact 元信息,便于观测与旧配置兼容。
|
|
217
|
-
*
|
|
218
|
-
* 默认:30
|
|
219
|
-
*/
|
|
220
|
-
keepLastMessages?: number;
|
|
221
|
-
/**
|
|
222
|
-
* 输入预算(近似 token 数)。
|
|
223
|
-
*
|
|
224
|
-
* 说明(中文)
|
|
225
|
-
* - 这里是近似值,用于在调用 provider 前提前触发 compact
|
|
226
|
-
* - 实际超窗仍会被 provider 拒绝并进入 retry(更激进 compact)
|
|
227
|
-
*
|
|
228
|
-
* 默认:128000
|
|
229
|
-
*/
|
|
230
|
-
maxInputTokensApprox?: number;
|
|
231
|
-
/**
|
|
232
|
-
* compact 时是否归档被折叠的原始消息段(写入 messages/archive/)。
|
|
233
|
-
* 默认:true
|
|
234
|
-
*/
|
|
235
|
-
archiveOnCompact?: boolean;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* 前段压缩比例(0-1)。
|
|
239
|
-
*
|
|
240
|
-
* 说明(中文)
|
|
241
|
-
* - 触发 compact 后,优先压缩最早一段消息。
|
|
242
|
-
* - `0.5` 代表优先压缩“最早 50% 的 UIMessage”。
|
|
243
|
-
* - 实际切分会做边界保护(至少保留 1 条最近消息)。
|
|
244
|
-
*
|
|
245
|
-
* 默认:0.5
|
|
246
|
-
*/
|
|
247
|
-
compactRatio?: number;
|
|
248
|
-
};
|
|
249
|
-
/**
|
|
250
|
-
* 记忆管理配置。
|
|
251
|
-
*
|
|
252
|
-
* 设计目标
|
|
253
|
-
* - 默认开启,开箱即用(零配置)
|
|
254
|
-
* - 仅保留总开关,避免复杂配置负担
|
|
255
|
-
*/
|
|
256
|
-
memory?: {
|
|
257
|
-
/**
|
|
258
|
-
* 是否启用 memory plugin。
|
|
259
|
-
*/
|
|
260
|
-
enabled?: boolean;
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
204
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 项目运行入口只有一种执行模式:`api`。
|
|
6
|
-
* -
|
|
6
|
+
* - 绑定 City AIService 暴露的模型 ID。
|
|
7
7
|
* - 该类型是项目 `downcity.json` 中唯一的执行配置。
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -17,11 +17,11 @@ export interface ExecutionBindingConfig {
|
|
|
17
17
|
type: "api";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* City AIService 中的模型 ID。
|
|
21
21
|
*
|
|
22
22
|
* 说明(中文)
|
|
23
|
-
* -
|
|
24
|
-
* - 例如:`
|
|
23
|
+
* - 必须能通过 City 的 `/v1/ai/models` 目录查询到。
|
|
24
|
+
* - 例如:`deepseek-v4-flash`、`fast`、`quality`。
|
|
25
25
|
*/
|
|
26
26
|
modelId: string;
|
|
27
27
|
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* 字段说明(中文)
|
|
5
5
|
* - `port`/`host`:主 API 服务监听地址。
|
|
6
6
|
* - `agent start/restart` 中的 `port` 由 console 自动分配(CLI 不再暴露 `--port`)。
|
|
7
|
+
* - `rpcPort`:Agent 本机 RPC 监听端口。
|
|
8
|
+
* - 属于内部启动参数,通常由 city 自动分配,不面向普通用户。
|
|
7
9
|
* - `daemon`:兼容旧参数(显式声明后台/前台)。
|
|
8
10
|
* - `foreground`:显式前台启动。
|
|
9
11
|
*/
|
|
@@ -11,6 +13,7 @@
|
|
|
11
13
|
export interface StartOptions {
|
|
12
14
|
port?: number | string;
|
|
13
15
|
host?: string;
|
|
16
|
+
rpcPort?: number | string;
|
|
14
17
|
daemon?: boolean | string;
|
|
15
18
|
foreground?: boolean | string;
|
|
16
19
|
}
|
|
@@ -44,8 +44,8 @@ export const AUTH_PERMISSION_DESCRIPTIONS: Record<AuthPermissionKey, string> = {
|
|
|
44
44
|
"agent.execute": "触发 agent 执行与会话运行。",
|
|
45
45
|
"task.read": "查看 task 定义与运行结果。",
|
|
46
46
|
"task.run": "创建或手动执行 task。",
|
|
47
|
-
"model.read": "
|
|
48
|
-
"model.write": "
|
|
47
|
+
"model.read": "查看 City AIService 模型与模型绑定。",
|
|
48
|
+
"model.write": "修改模型绑定。",
|
|
49
49
|
"env.read": "查看环境变量配置。",
|
|
50
50
|
"env.write": "修改环境变量配置。",
|
|
51
51
|
"channel.read": "查看渠道账号与渠道状态。",
|
|
@@ -1,200 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 平台宿主存储类型定义。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - Town 只保存平台级 env、channel account 与安全配置。
|
|
6
|
+
* - 模型能力由 City AIService 暴露,Town 不再声明 provider/model 存储类型。
|
|
7
7
|
*/
|
|
8
|
-
import type { LlmProviderType } from "@/types/config/LlmConfig.js";
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Channel Account 支持的渠道类型。
|
|
12
11
|
*/
|
|
13
12
|
export type StoredChannelAccountChannel = "telegram" | "feishu" | "qq";
|
|
14
13
|
|
|
15
|
-
/**
|
|
16
|
-
* 模型 provider 记录。
|
|
17
|
-
*/
|
|
18
|
-
export interface StoredModelProvider {
|
|
19
|
-
/**
|
|
20
|
-
* provider 主键 ID(例如:`openai_main`、`default`)。
|
|
21
|
-
*/
|
|
22
|
-
id: string;
|
|
23
|
-
/**
|
|
24
|
-
* provider 类型(决定 SDK 分支与默认网关行为)。
|
|
25
|
-
*/
|
|
26
|
-
type: LlmProviderType;
|
|
27
|
-
/**
|
|
28
|
-
* provider 基础地址(可选)。
|
|
29
|
-
*/
|
|
30
|
-
baseUrl?: string;
|
|
31
|
-
/**
|
|
32
|
-
* provider API Key(解密后的明文;仅在运行时内存中使用)。
|
|
33
|
-
*/
|
|
34
|
-
apiKey?: string;
|
|
35
|
-
/**
|
|
36
|
-
* 创建时间(ISO 字符串)。
|
|
37
|
-
*/
|
|
38
|
-
createdAt: string;
|
|
39
|
-
/**
|
|
40
|
-
* 更新时间(ISO 字符串)。
|
|
41
|
-
*/
|
|
42
|
-
updatedAt: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* provider 元信息。
|
|
47
|
-
*
|
|
48
|
-
* 关键点(中文)
|
|
49
|
-
* - 仅保留同步读取所需的轻量字段。
|
|
50
|
-
* - 不包含解密后的 API Key,避免在只读展示链路中泄露敏感信息。
|
|
51
|
-
*/
|
|
52
|
-
export interface StoredProviderMeta {
|
|
53
|
-
/**
|
|
54
|
-
* provider 主键 ID。
|
|
55
|
-
*/
|
|
56
|
-
id: string;
|
|
57
|
-
/**
|
|
58
|
-
* provider 类型。
|
|
59
|
-
*/
|
|
60
|
-
type: LlmProviderType;
|
|
61
|
-
/**
|
|
62
|
-
* provider 基础地址(可选)。
|
|
63
|
-
*/
|
|
64
|
-
baseUrl?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 模型记录。
|
|
69
|
-
*/
|
|
70
|
-
export interface StoredModel {
|
|
71
|
-
/**
|
|
72
|
-
* 模型主键 ID(例如:`default`、`fast`、`quality`)。
|
|
73
|
-
*/
|
|
74
|
-
id: string;
|
|
75
|
-
/**
|
|
76
|
-
* 关联 provider ID。
|
|
77
|
-
*/
|
|
78
|
-
providerId: string;
|
|
79
|
-
/**
|
|
80
|
-
* 上游模型名称(例如 `gpt-4o-mini`)。
|
|
81
|
-
*/
|
|
82
|
-
name: string;
|
|
83
|
-
/**
|
|
84
|
-
* 采样温度(可选)。
|
|
85
|
-
*/
|
|
86
|
-
temperature?: number;
|
|
87
|
-
/**
|
|
88
|
-
* 最大输出 token(可选)。
|
|
89
|
-
*/
|
|
90
|
-
maxTokens?: number;
|
|
91
|
-
/**
|
|
92
|
-
* topP(可选)。
|
|
93
|
-
*/
|
|
94
|
-
topP?: number;
|
|
95
|
-
/**
|
|
96
|
-
* frequencyPenalty(可选)。
|
|
97
|
-
*/
|
|
98
|
-
frequencyPenalty?: number;
|
|
99
|
-
/**
|
|
100
|
-
* presencePenalty(可选)。
|
|
101
|
-
*/
|
|
102
|
-
presencePenalty?: number;
|
|
103
|
-
/**
|
|
104
|
-
* Anthropic 版本字段(可选)。
|
|
105
|
-
*/
|
|
106
|
-
anthropicVersion?: string;
|
|
107
|
-
/**
|
|
108
|
-
* 是否暂停该模型。
|
|
109
|
-
*
|
|
110
|
-
* 关键点(中文)
|
|
111
|
-
* - 暂停后禁止作为 `execution.modelId` 被运行时加载。
|
|
112
|
-
* - 用于模型维护窗口、成本管控或临时故障隔离。
|
|
113
|
-
*/
|
|
114
|
-
isPaused: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* 创建时间(ISO 字符串)。
|
|
117
|
-
*/
|
|
118
|
-
createdAt: string;
|
|
119
|
-
/**
|
|
120
|
-
* 更新时间(ISO 字符串)。
|
|
121
|
-
*/
|
|
122
|
-
updatedAt: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* provider 写入参数。
|
|
127
|
-
*/
|
|
128
|
-
export interface UpsertModelProviderInput {
|
|
129
|
-
/**
|
|
130
|
-
* provider ID。
|
|
131
|
-
*/
|
|
132
|
-
id: string;
|
|
133
|
-
/**
|
|
134
|
-
* provider 类型。
|
|
135
|
-
*/
|
|
136
|
-
type: LlmProviderType;
|
|
137
|
-
/**
|
|
138
|
-
* provider baseUrl(可选)。
|
|
139
|
-
*/
|
|
140
|
-
baseUrl?: string;
|
|
141
|
-
/**
|
|
142
|
-
* provider apiKey(可选)。
|
|
143
|
-
*/
|
|
144
|
-
apiKey?: string;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* model 写入参数。
|
|
149
|
-
*/
|
|
150
|
-
export interface UpsertModelInput {
|
|
151
|
-
/**
|
|
152
|
-
* 模型 ID。
|
|
153
|
-
*/
|
|
154
|
-
id: string;
|
|
155
|
-
/**
|
|
156
|
-
* provider ID。
|
|
157
|
-
*/
|
|
158
|
-
providerId: string;
|
|
159
|
-
/**
|
|
160
|
-
* 上游模型名称。
|
|
161
|
-
*/
|
|
162
|
-
name: string;
|
|
163
|
-
/**
|
|
164
|
-
* 采样温度(可选)。
|
|
165
|
-
*/
|
|
166
|
-
temperature?: number;
|
|
167
|
-
/**
|
|
168
|
-
* 最大输出 token(可选)。
|
|
169
|
-
*/
|
|
170
|
-
maxTokens?: number;
|
|
171
|
-
/**
|
|
172
|
-
* topP(可选)。
|
|
173
|
-
*/
|
|
174
|
-
topP?: number;
|
|
175
|
-
/**
|
|
176
|
-
* frequencyPenalty(可选)。
|
|
177
|
-
*/
|
|
178
|
-
frequencyPenalty?: number;
|
|
179
|
-
/**
|
|
180
|
-
* presencePenalty(可选)。
|
|
181
|
-
*/
|
|
182
|
-
presencePenalty?: number;
|
|
183
|
-
/**
|
|
184
|
-
* Anthropic 版本字段(可选)。
|
|
185
|
-
*/
|
|
186
|
-
anthropicVersion?: string;
|
|
187
|
-
/**
|
|
188
|
-
* 是否暂停该模型(可选)。
|
|
189
|
-
*/
|
|
190
|
-
isPaused?: boolean;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Env 条目作用域。
|
|
195
|
-
*/
|
|
196
|
-
export type StoredEnvScope = "global" | "agent";
|
|
197
|
-
|
|
198
14
|
/**
|
|
199
15
|
* 平台环境变量记录。
|
|
200
16
|
*/
|
|
@@ -203,18 +19,10 @@ export interface StoredEnvEntry {
|
|
|
203
19
|
* Env 作用域。
|
|
204
20
|
*
|
|
205
21
|
* 关键点(中文)
|
|
206
|
-
* - `global`
|
|
207
|
-
* -
|
|
208
|
-
*/
|
|
209
|
-
scope: StoredEnvScope;
|
|
210
|
-
/**
|
|
211
|
-
* Agent 唯一标识(使用 projectRoot 绝对路径)。
|
|
212
|
-
*
|
|
213
|
-
* 关键点(中文)
|
|
214
|
-
* - 仅当 `scope=agent` 时有值。
|
|
215
|
-
* - `scope=global` 时为空。
|
|
22
|
+
* - 当前版本只保留 `global` 单一作用域。
|
|
23
|
+
* - 所有平台 Env 都视为宿主级共享变量,由宿主决定是否注入具体运行实例。
|
|
216
24
|
*/
|
|
217
|
-
|
|
25
|
+
scope: "global";
|
|
218
26
|
/**
|
|
219
27
|
* 环境变量 key(例如 `OPENAI_API_KEY`)。
|
|
220
28
|
*/
|
|
@@ -247,16 +55,12 @@ export interface StoredEnvEntry {
|
|
|
247
55
|
export interface UpsertEnvEntryInput {
|
|
248
56
|
/**
|
|
249
57
|
* Env 作用域。
|
|
250
|
-
*/
|
|
251
|
-
scope: StoredEnvScope;
|
|
252
|
-
/**
|
|
253
|
-
* Agent 唯一标识(projectRoot)。
|
|
254
58
|
*
|
|
255
59
|
* 关键点(中文)
|
|
256
|
-
* -
|
|
257
|
-
* -
|
|
60
|
+
* - 当前只允许写入 `global`。
|
|
61
|
+
* - 保留该字段是为了让宿主侧调用点显式表达“这是平台全局 env 写入”。
|
|
258
62
|
*/
|
|
259
|
-
|
|
63
|
+
scope: "global";
|
|
260
64
|
/**
|
|
261
65
|
* 环境变量 key。
|
|
262
66
|
*/
|
|
@@ -276,42 +80,13 @@ export interface UpsertEnvEntryInput {
|
|
|
276
80
|
|
|
277
81
|
/**
|
|
278
82
|
* 全局环境变量记录。
|
|
279
|
-
*
|
|
280
|
-
* 关键点(中文)
|
|
281
|
-
* - 作为统一 `StoredEnvEntry` 的别名保留。
|
|
282
|
-
* - 调用方可继续按全局 env 语义使用。
|
|
283
83
|
*/
|
|
284
84
|
export type StoredGlobalEnvEntry = StoredEnvEntry;
|
|
285
85
|
|
|
286
|
-
/**
|
|
287
|
-
* Agent 私有环境变量记录。
|
|
288
|
-
*
|
|
289
|
-
* 关键点(中文)
|
|
290
|
-
* - 作为统一 `StoredEnvEntry` 的别名保留。
|
|
291
|
-
* - 调用方可继续按 agent env 语义使用。
|
|
292
|
-
*/
|
|
293
|
-
export type StoredAgentEnvEntry = StoredEnvEntry;
|
|
294
|
-
|
|
295
86
|
/**
|
|
296
87
|
* 全局环境变量写入参数。
|
|
297
|
-
*
|
|
298
|
-
* 关键点(中文)
|
|
299
|
-
* - 作为统一 `UpsertEnvEntryInput` 的别名保留。
|
|
300
|
-
*/
|
|
301
|
-
export type UpsertGlobalEnvEntryInput = Omit<UpsertEnvEntryInput, "scope" | "agentId">;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Agent 私有环境变量写入参数。
|
|
305
|
-
*
|
|
306
|
-
* 关键点(中文)
|
|
307
|
-
* - 作为统一 `UpsertEnvEntryInput` 的别名保留。
|
|
308
88
|
*/
|
|
309
|
-
export type
|
|
310
|
-
/**
|
|
311
|
-
* Agent 唯一标识(projectRoot)。
|
|
312
|
-
*/
|
|
313
|
-
agentId: string;
|
|
314
|
-
};
|
|
89
|
+
export type UpsertGlobalEnvEntryInput = Omit<UpsertEnvEntryInput, "scope">;
|
|
315
90
|
|
|
316
91
|
/**
|
|
317
92
|
* Channel Account 记录。
|
|
@@ -17,9 +17,9 @@ export interface PlatformAgentOption {
|
|
|
17
17
|
id: string;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* agent
|
|
20
|
+
* agent 项目自身的稳定标识(优先 downcity.json.id,回退目录名推导)。
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
agentId: string;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* agent 项目根目录(绝对路径)。
|
|
@@ -173,9 +173,9 @@ export interface PlatformAgentDirectoryInspection {
|
|
|
173
173
|
running: boolean;
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
176
|
+
* 当前目录解析出的 agent id(若存在)。
|
|
177
177
|
*/
|
|
178
|
-
|
|
178
|
+
agentId?: string;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* 当前读取到的主模型 ID(若存在)。
|
|
@@ -336,9 +336,9 @@ export interface PlatformConfigStatusResponse {
|
|
|
336
336
|
selectedAgentId: string;
|
|
337
337
|
|
|
338
338
|
/**
|
|
339
|
-
* 当前选中的 agent
|
|
339
|
+
* 当前选中的 agent 项目 id(即 `downcity.json.id`,可能为空)。
|
|
340
340
|
*/
|
|
341
|
-
|
|
341
|
+
selectedAgentProjectId: string;
|
|
342
342
|
|
|
343
343
|
/**
|
|
344
344
|
* 配置文件状态列表。
|
|
@@ -402,7 +402,7 @@ export interface ManagedAgentRegistryV1 {
|
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
|
-
* `
|
|
405
|
+
* `town agent list --running` 输出可复用的受管 agent 运行态视图。
|
|
406
406
|
*/
|
|
407
407
|
export interface ManagedAgentProcessView {
|
|
408
408
|
/**
|
package/src/utils/Time.ts
CHANGED
|
@@ -10,12 +10,6 @@ export function getTimestamp(): string {
|
|
|
10
10
|
return new Date().toISOString();
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function formatDuration(ms: number): string {
|
|
14
|
-
if (ms < 1000) return `${ms}ms`;
|
|
15
|
-
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
|
16
|
-
return `${(ms / 60000).toFixed(1)}m`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
export function resolveRuntimeTimezone(): string {
|
|
20
14
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
21
15
|
return String(timezone || "").trim() || "UTC";
|
|
@@ -17,10 +17,3 @@ export async function ensureDir(dir: string): Promise<void> {
|
|
|
17
17
|
export async function saveJson(filePath: string, data: JsonValue | object): Promise<void> {
|
|
18
18
|
await fs.writeJson(filePath, data, { spaces: 2 });
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
export async function loadJson<T>(filePath: string): Promise<T | null> {
|
|
22
|
-
if (!fs.existsSync(filePath)) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return fs.readJson(filePath) as Promise<T>;
|
|
26
|
-
}
|