@downcity/agent 1.1.43 → 1.1.51
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 +6 -8
- 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 +4 -4
- package/bin/config/AgentInitializer.d.ts.map +1 -1
- package/bin/config/AgentInitializer.js +14 -12
- 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 +3 -111
- package/bin/config/DowncitySchema.js.map +1 -1
- package/bin/config/ExecutionBinding.d.ts +0 -15
- package/bin/config/ExecutionBinding.d.ts.map +1 -1
- package/bin/config/ExecutionBinding.js +1 -21
- 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/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/tools/shell/ShellToolFormatting.js +2 -2
- package/bin/executor/tools/shell/ShellToolFormatting.js.map +1 -1
- package/bin/executor/types/SessionRun.d.ts +1 -1
- package/bin/index.d.ts +4 -6
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +5 -5
- package/bin/index.js.map +1 -1
- 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/server/http/control/OverviewRoutes.js +1 -1
- package/bin/runtime/server/http/control/OverviewRoutes.js.map +1 -1
- package/bin/session/index.d.ts +1 -1
- package/bin/session/index.d.ts.map +1 -1
- package/bin/session/index.js +1 -1
- package/bin/session/index.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/types/agent/AgentTypes.d.ts +23 -52
- package/bin/types/agent/AgentTypes.d.ts.map +1 -1
- package/bin/types/config/AgentProject.d.ts +6 -5
- package/bin/types/config/AgentProject.d.ts.map +1 -1
- package/bin/types/config/DowncityConfig.d.ts +8 -66
- package/bin/types/config/DowncityConfig.d.ts.map +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/host/Store.d.ts +7 -50
- package/bin/types/runtime/host/Store.d.ts.map +1 -1
- package/bin/types/runtime/platform/Platform.d.ts +6 -6
- 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 +4 -6
- package/src/agent/Agent.ts +54 -71
- package/src/agent/RemoteAgent.ts +515 -345
- package/src/config/AgentInitializer.ts +14 -12
- package/src/config/Config.ts +28 -85
- package/src/config/Defaults.ts +1 -9
- package/src/config/DowncitySchema.ts +3 -113
- package/src/config/ExecutionBinding.ts +1 -23
- package/src/config/Paths.ts +10 -43
- package/src/config/PlatformPaths.ts +5 -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/tools/shell/ShellToolFormatting.ts +2 -2
- package/src/executor/types/SessionRun.ts +1 -1
- package/src/index.ts +7 -14
- 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/server/http/control/OverviewRoutes.ts +1 -1
- package/src/session/index.ts +0 -1
- package/src/session/storage/Paths.ts +0 -10
- package/src/types/agent/AgentTypes.ts +23 -57
- package/src/types/config/AgentProject.ts +6 -5
- package/src/types/config/DowncityConfig.ts +8 -67
- package/src/types/config/LlmConfig.ts +1 -1
- package/src/types/config/Start.ts +3 -0
- package/src/types/runtime/host/Store.ts +7 -53
- package/src/types/runtime/platform/Platform.ts +6 -6
- 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.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,9 +149,15 @@ 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
162
|
* Runtime startup configuration used by `downcity agent start`.
|
|
157
163
|
* CLI flags (if provided) take precedence over this config.
|
|
@@ -195,69 +201,4 @@ export interface DowncityConfig {
|
|
|
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
|
}
|
|
@@ -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
|
}
|
|
@@ -190,11 +190,6 @@ export interface UpsertModelInput {
|
|
|
190
190
|
isPaused?: boolean;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
/**
|
|
194
|
-
* Env 条目作用域。
|
|
195
|
-
*/
|
|
196
|
-
export type StoredEnvScope = "global" | "agent";
|
|
197
|
-
|
|
198
193
|
/**
|
|
199
194
|
* 平台环境变量记录。
|
|
200
195
|
*/
|
|
@@ -203,18 +198,10 @@ export interface StoredEnvEntry {
|
|
|
203
198
|
* Env 作用域。
|
|
204
199
|
*
|
|
205
200
|
* 关键点(中文)
|
|
206
|
-
* - `global`
|
|
207
|
-
* -
|
|
208
|
-
*/
|
|
209
|
-
scope: StoredEnvScope;
|
|
210
|
-
/**
|
|
211
|
-
* Agent 唯一标识(使用 projectRoot 绝对路径)。
|
|
212
|
-
*
|
|
213
|
-
* 关键点(中文)
|
|
214
|
-
* - 仅当 `scope=agent` 时有值。
|
|
215
|
-
* - `scope=global` 时为空。
|
|
201
|
+
* - 当前版本只保留 `global` 单一作用域。
|
|
202
|
+
* - 所有平台 Env 都视为宿主级共享变量,由宿主决定是否注入具体运行实例。
|
|
216
203
|
*/
|
|
217
|
-
|
|
204
|
+
scope: "global";
|
|
218
205
|
/**
|
|
219
206
|
* 环境变量 key(例如 `OPENAI_API_KEY`)。
|
|
220
207
|
*/
|
|
@@ -247,16 +234,12 @@ export interface StoredEnvEntry {
|
|
|
247
234
|
export interface UpsertEnvEntryInput {
|
|
248
235
|
/**
|
|
249
236
|
* Env 作用域。
|
|
250
|
-
*/
|
|
251
|
-
scope: StoredEnvScope;
|
|
252
|
-
/**
|
|
253
|
-
* Agent 唯一标识(projectRoot)。
|
|
254
237
|
*
|
|
255
238
|
* 关键点(中文)
|
|
256
|
-
* -
|
|
257
|
-
* -
|
|
239
|
+
* - 当前只允许写入 `global`。
|
|
240
|
+
* - 保留该字段是为了让宿主侧调用点显式表达“这是平台全局 env 写入”。
|
|
258
241
|
*/
|
|
259
|
-
|
|
242
|
+
scope: "global";
|
|
260
243
|
/**
|
|
261
244
|
* 环境变量 key。
|
|
262
245
|
*/
|
|
@@ -276,42 +259,13 @@ export interface UpsertEnvEntryInput {
|
|
|
276
259
|
|
|
277
260
|
/**
|
|
278
261
|
* 全局环境变量记录。
|
|
279
|
-
*
|
|
280
|
-
* 关键点(中文)
|
|
281
|
-
* - 作为统一 `StoredEnvEntry` 的别名保留。
|
|
282
|
-
* - 调用方可继续按全局 env 语义使用。
|
|
283
262
|
*/
|
|
284
263
|
export type StoredGlobalEnvEntry = StoredEnvEntry;
|
|
285
264
|
|
|
286
|
-
/**
|
|
287
|
-
* Agent 私有环境变量记录。
|
|
288
|
-
*
|
|
289
|
-
* 关键点(中文)
|
|
290
|
-
* - 作为统一 `StoredEnvEntry` 的别名保留。
|
|
291
|
-
* - 调用方可继续按 agent env 语义使用。
|
|
292
|
-
*/
|
|
293
|
-
export type StoredAgentEnvEntry = StoredEnvEntry;
|
|
294
|
-
|
|
295
265
|
/**
|
|
296
266
|
* 全局环境变量写入参数。
|
|
297
|
-
*
|
|
298
|
-
* 关键点(中文)
|
|
299
|
-
* - 作为统一 `UpsertEnvEntryInput` 的别名保留。
|
|
300
|
-
*/
|
|
301
|
-
export type UpsertGlobalEnvEntryInput = Omit<UpsertEnvEntryInput, "scope" | "agentId">;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Agent 私有环境变量写入参数。
|
|
305
|
-
*
|
|
306
|
-
* 关键点(中文)
|
|
307
|
-
* - 作为统一 `UpsertEnvEntryInput` 的别名保留。
|
|
308
267
|
*/
|
|
309
|
-
export type
|
|
310
|
-
/**
|
|
311
|
-
* Agent 唯一标识(projectRoot)。
|
|
312
|
-
*/
|
|
313
|
-
agentId: string;
|
|
314
|
-
};
|
|
268
|
+
export type UpsertGlobalEnvEntryInput = Omit<UpsertEnvEntryInput, "scope">;
|
|
315
269
|
|
|
316
270
|
/**
|
|
317
271
|
* 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
|
* 配置文件状态列表。
|
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
|
-
}
|