@downcity/agent 1.1.71 → 1.1.73
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/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
- package/bin/executor/tools/shell/ShellToolFormatting.js +1 -1
- package/bin/executor/tools/shell/ShellToolFormatting.js.map +1 -1
- package/bin/index.d.ts +2 -6
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +1 -5
- package/bin/index.js.map +1 -1
- package/bin/plugin/core/PluginCatalog.js +2 -2
- package/bin/plugin/core/PluginCatalog.js.map +1 -1
- package/bin/rpc/Client.d.ts +2 -2
- package/bin/rpc/Client.d.ts.map +1 -1
- package/bin/rpc/Server.js +2 -2
- package/bin/rpc/Server.js.map +1 -1
- package/bin/runtime/auth/AuthEnv.d.ts.map +1 -0
- package/bin/runtime/auth/AuthEnv.js.map +1 -0
- package/bin/runtime/auth/CliAuthStateStore.d.ts.map +1 -0
- package/bin/runtime/auth/CliAuthStateStore.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/AuthControlService.d.ts +3 -3
- package/bin/runtime/control/AuthControlService.d.ts.map +1 -0
- package/bin/runtime/control/AuthControlService.js.map +1 -0
- package/bin/runtime/control/CommonHelpers.d.ts.map +1 -0
- package/bin/runtime/control/CommonHelpers.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/ExecuteBySession.d.ts +4 -4
- package/bin/runtime/control/ExecuteBySession.d.ts.map +1 -0
- package/bin/runtime/control/ExecuteBySession.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/ExecuteInput.d.ts +1 -1
- package/bin/runtime/control/ExecuteInput.d.ts.map +1 -0
- package/bin/runtime/{server/http/control → control}/ExecuteInput.js +2 -2
- package/bin/runtime/control/ExecuteInput.js.map +1 -0
- package/bin/runtime/control/Helpers.d.ts.map +1 -0
- package/bin/runtime/control/Helpers.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/MessageTimeline.d.ts +2 -2
- package/bin/runtime/control/MessageTimeline.d.ts.map +1 -0
- package/bin/runtime/{server/http/control → control}/MessageTimeline.js +2 -2
- package/bin/runtime/control/MessageTimeline.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/SessionSummaryStore.d.ts +2 -2
- package/bin/runtime/control/SessionSummaryStore.d.ts.map +1 -0
- package/bin/runtime/{server/http/control → control}/SessionSummaryStore.js +1 -1
- package/bin/runtime/control/SessionSummaryStore.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/TaskStore.d.ts +1 -1
- package/bin/runtime/control/TaskStore.d.ts.map +1 -0
- package/bin/runtime/{server/http/control → control}/TaskStore.js +1 -1
- package/bin/runtime/control/TaskStore.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/types/AuthControl.d.ts +1 -1
- package/bin/runtime/control/types/AuthControl.d.ts.map +1 -0
- package/bin/runtime/control/types/AuthControl.js.map +1 -0
- package/bin/runtime/control/types/ControlSessionExecute.d.ts.map +1 -0
- package/bin/runtime/control/types/ControlSessionExecute.js.map +1 -0
- package/bin/runtime/{server/http/control → control}/types/ControlViewData.d.ts +1 -1
- package/bin/runtime/control/types/ControlViewData.d.ts.map +1 -0
- package/bin/runtime/control/types/ControlViewData.js.map +1 -0
- package/bin/runtime/host/ProjectSetup.d.ts.map +1 -0
- package/bin/runtime/host/{daemon/ProjectSetup.js → ProjectSetup.js} +1 -1
- package/bin/runtime/host/ProjectSetup.js.map +1 -0
- package/bin/types/runtime/platform/PlatformGateway.d.ts +3 -16
- package/bin/types/runtime/platform/PlatformGateway.d.ts.map +1 -1
- package/package.json +3 -3
- 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/tools/shell/ShellToolFormatting.ts +1 -1
- package/src/index.ts +1 -17
- package/src/plugin/core/PluginCatalog.ts +2 -2
- package/src/rpc/Client.ts +2 -2
- package/src/rpc/Server.ts +3 -3
- package/src/runtime/{server/http/control → control}/AuthControlService.ts +1 -1
- package/src/runtime/{server/http/control → control}/ExecuteBySession.ts +1 -1
- package/src/runtime/{server/http/control → control}/ExecuteInput.ts +1 -1
- package/src/runtime/{server/http/control → control}/MessageTimeline.ts +1 -1
- package/src/runtime/{server/http/control → control}/SessionSummaryStore.ts +1 -1
- package/src/runtime/{server/http/control → control}/TaskStore.ts +1 -1
- package/src/types/runtime/platform/PlatformGateway.ts +3 -17
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/runtime/host/daemon/Api.d.ts +0 -60
- package/bin/runtime/host/daemon/Api.d.ts.map +0 -1
- package/bin/runtime/host/daemon/Api.js +0 -10
- package/bin/runtime/host/daemon/Api.js.map +0 -1
- package/bin/runtime/host/daemon/Client.d.ts +0 -17
- package/bin/runtime/host/daemon/Client.d.ts.map +0 -1
- package/bin/runtime/host/daemon/Client.js +0 -168
- package/bin/runtime/host/daemon/Client.js.map +0 -1
- package/bin/runtime/host/daemon/Paths.d.ts +0 -20
- package/bin/runtime/host/daemon/Paths.d.ts.map +0 -1
- package/bin/runtime/host/daemon/Paths.js +0 -23
- package/bin/runtime/host/daemon/Paths.js.map +0 -1
- package/bin/runtime/host/daemon/ProjectSetup.d.ts.map +0 -1
- package/bin/runtime/host/daemon/ProjectSetup.js.map +0 -1
- package/bin/runtime/server/http/Server.d.ts +0 -48
- package/bin/runtime/server/http/Server.d.ts.map +0 -1
- package/bin/runtime/server/http/Server.js +0 -129
- package/bin/runtime/server/http/Server.js.map +0 -1
- package/bin/runtime/server/http/auth/AuthEnv.d.ts.map +0 -1
- package/bin/runtime/server/http/auth/AuthEnv.js.map +0 -1
- package/bin/runtime/server/http/auth/CliAuthStateStore.d.ts.map +0 -1
- package/bin/runtime/server/http/auth/CliAuthStateStore.js.map +0 -1
- package/bin/runtime/server/http/control/AuthControlService.d.ts.map +0 -1
- package/bin/runtime/server/http/control/AuthControlService.js.map +0 -1
- package/bin/runtime/server/http/control/CommonHelpers.d.ts.map +0 -1
- package/bin/runtime/server/http/control/CommonHelpers.js.map +0 -1
- package/bin/runtime/server/http/control/ControlApiRoutes.d.ts +0 -14
- package/bin/runtime/server/http/control/ControlApiRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/control/ControlApiRoutes.js +0 -25
- package/bin/runtime/server/http/control/ControlApiRoutes.js.map +0 -1
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.d.ts +0 -17
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.js +0 -84
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.js.map +0 -1
- package/bin/runtime/server/http/control/ControlRouter.d.ts +0 -35
- package/bin/runtime/server/http/control/ControlRouter.d.ts.map +0 -1
- package/bin/runtime/server/http/control/ControlRouter.js +0 -28
- package/bin/runtime/server/http/control/ControlRouter.js.map +0 -1
- package/bin/runtime/server/http/control/ExecuteBySession.d.ts.map +0 -1
- package/bin/runtime/server/http/control/ExecuteBySession.js.map +0 -1
- package/bin/runtime/server/http/control/ExecuteInput.d.ts.map +0 -1
- package/bin/runtime/server/http/control/ExecuteInput.js.map +0 -1
- package/bin/runtime/server/http/control/Helpers.d.ts.map +0 -1
- package/bin/runtime/server/http/control/Helpers.js.map +0 -1
- package/bin/runtime/server/http/control/MessageTimeline.d.ts.map +0 -1
- package/bin/runtime/server/http/control/MessageTimeline.js.map +0 -1
- package/bin/runtime/server/http/control/OverviewRoutes.d.ts +0 -13
- package/bin/runtime/server/http/control/OverviewRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/control/OverviewRoutes.js +0 -101
- package/bin/runtime/server/http/control/OverviewRoutes.js.map +0 -1
- package/bin/runtime/server/http/control/SessionRoutes.d.ts +0 -14
- package/bin/runtime/server/http/control/SessionRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/control/SessionRoutes.js +0 -334
- package/bin/runtime/server/http/control/SessionRoutes.js.map +0 -1
- package/bin/runtime/server/http/control/SessionSummaryStore.d.ts.map +0 -1
- package/bin/runtime/server/http/control/SessionSummaryStore.js.map +0 -1
- package/bin/runtime/server/http/control/TaskRoutes.d.ts +0 -13
- package/bin/runtime/server/http/control/TaskRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/control/TaskRoutes.js +0 -364
- package/bin/runtime/server/http/control/TaskRoutes.js.map +0 -1
- package/bin/runtime/server/http/control/TaskStore.d.ts.map +0 -1
- package/bin/runtime/server/http/control/TaskStore.js.map +0 -1
- package/bin/runtime/server/http/control/types/AuthControl.d.ts.map +0 -1
- package/bin/runtime/server/http/control/types/AuthControl.js.map +0 -1
- package/bin/runtime/server/http/control/types/ControlRoutes.d.ts +0 -28
- package/bin/runtime/server/http/control/types/ControlRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/control/types/ControlRoutes.js +0 -9
- package/bin/runtime/server/http/control/types/ControlRoutes.js.map +0 -1
- package/bin/runtime/server/http/control/types/ControlSessionExecute.d.ts.map +0 -1
- package/bin/runtime/server/http/control/types/ControlSessionExecute.js.map +0 -1
- package/bin/runtime/server/http/control/types/ControlViewData.d.ts.map +0 -1
- package/bin/runtime/server/http/control/types/ControlViewData.js.map +0 -1
- package/bin/runtime/server/http/execute/execute.d.ts +0 -25
- package/bin/runtime/server/http/execute/execute.d.ts.map +0 -1
- package/bin/runtime/server/http/execute/execute.js +0 -63
- package/bin/runtime/server/http/execute/execute.js.map +0 -1
- package/bin/runtime/server/http/health/health.d.ts +0 -14
- package/bin/runtime/server/http/health/health.d.ts.map +0 -1
- package/bin/runtime/server/http/health/health.js +0 -24
- package/bin/runtime/server/http/health/health.js.map +0 -1
- package/bin/runtime/server/http/plugins/plugins.d.ts +0 -25
- package/bin/runtime/server/http/plugins/plugins.d.ts.map +0 -1
- package/bin/runtime/server/http/plugins/plugins.js +0 -114
- package/bin/runtime/server/http/plugins/plugins.js.map +0 -1
- package/bin/runtime/server/http/sdk/Router.d.ts +0 -14
- package/bin/runtime/server/http/sdk/Router.d.ts.map +0 -1
- package/bin/runtime/server/http/sdk/Router.js +0 -18
- package/bin/runtime/server/http/sdk/Router.js.map +0 -1
- package/bin/runtime/server/http/sdk/SessionRoutes.d.ts +0 -15
- package/bin/runtime/server/http/sdk/SessionRoutes.d.ts.map +0 -1
- package/bin/runtime/server/http/sdk/SessionRoutes.js +0 -249
- package/bin/runtime/server/http/sdk/SessionRoutes.js.map +0 -1
- package/bin/runtime/server/http/static/static.d.ts +0 -25
- package/bin/runtime/server/http/static/static.d.ts.map +0 -1
- package/bin/runtime/server/http/static/static.js +0 -99
- package/bin/runtime/server/http/static/static.js.map +0 -1
- package/bin/types/config/Start.d.ts +0 -19
- package/bin/types/config/Start.d.ts.map +0 -1
- package/bin/types/config/Start.js +0 -13
- package/bin/types/config/Start.js.map +0 -1
- package/bin/types/runtime/daemon/Daemon.d.ts +0 -46
- package/bin/types/runtime/daemon/Daemon.d.ts.map +0 -1
- package/bin/types/runtime/daemon/Daemon.js +0 -14
- package/bin/types/runtime/daemon/Daemon.js.map +0 -1
- package/src/runtime/host/daemon/Api.ts +0 -64
- package/src/runtime/host/daemon/Client.ts +0 -204
- package/src/runtime/host/daemon/Paths.ts +0 -33
- package/src/runtime/server/http/Server.ts +0 -183
- package/src/runtime/server/http/control/ControlApiRoutes.ts +0 -29
- package/src/runtime/server/http/control/ControlAuthorizationRoutes.ts +0 -103
- package/src/runtime/server/http/control/ControlRouter.ts +0 -47
- package/src/runtime/server/http/control/OverviewRoutes.ts +0 -115
- package/src/runtime/server/http/control/SessionRoutes.ts +0 -427
- package/src/runtime/server/http/control/TaskRoutes.ts +0 -436
- package/src/runtime/server/http/control/types/ControlRoutes.ts +0 -31
- package/src/runtime/server/http/execute/execute.ts +0 -97
- package/src/runtime/server/http/health/health.ts +0 -27
- package/src/runtime/server/http/plugins/plugins.ts +0 -150
- package/src/runtime/server/http/sdk/Router.ts +0 -22
- package/src/runtime/server/http/sdk/SessionRoutes.ts +0 -300
- package/src/runtime/server/http/static/static.ts +0 -120
- package/src/types/config/Start.ts +0 -19
- package/src/types/runtime/daemon/Daemon.ts +0 -53
- /package/bin/runtime/{server/http/auth → auth}/AuthEnv.d.ts +0 -0
- /package/bin/runtime/{server/http/auth → auth}/AuthEnv.js +0 -0
- /package/bin/runtime/{server/http/auth → auth}/CliAuthStateStore.d.ts +0 -0
- /package/bin/runtime/{server/http/auth → auth}/CliAuthStateStore.js +0 -0
- /package/bin/runtime/{server/http/control → control}/AuthControlService.js +0 -0
- /package/bin/runtime/{server/http/control → control}/CommonHelpers.d.ts +0 -0
- /package/bin/runtime/{server/http/control → control}/CommonHelpers.js +0 -0
- /package/bin/runtime/{server/http/control → control}/ExecuteBySession.js +0 -0
- /package/bin/runtime/{server/http/control → control}/Helpers.d.ts +0 -0
- /package/bin/runtime/{server/http/control → control}/Helpers.js +0 -0
- /package/bin/runtime/{server/http/control → control}/types/AuthControl.js +0 -0
- /package/bin/runtime/{server/http/control → control}/types/ControlSessionExecute.d.ts +0 -0
- /package/bin/runtime/{server/http/control → control}/types/ControlSessionExecute.js +0 -0
- /package/bin/runtime/{server/http/control → control}/types/ControlViewData.js +0 -0
- /package/bin/runtime/host/{daemon/ProjectSetup.d.ts → ProjectSetup.d.ts} +0 -0
- /package/src/runtime/{server/http/auth → auth}/AuthEnv.ts +0 -0
- /package/src/runtime/{server/http/auth → auth}/CliAuthStateStore.ts +0 -0
- /package/src/runtime/{server/http/control → control}/CommonHelpers.ts +0 -0
- /package/src/runtime/{server/http/control → control}/Helpers.ts +0 -0
- /package/src/runtime/{server/http/control → control}/types/AuthControl.ts +0 -0
- /package/src/runtime/{server/http/control → control}/types/ControlSessionExecute.ts +0 -0
- /package/src/runtime/{server/http/control → control}/types/ControlViewData.ts +0 -0
- /package/src/runtime/host/{daemon/ProjectSetup.ts → ProjectSetup.ts} +0 -0
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* run/start/restart 命令参数类型。
|
|
3
|
-
*
|
|
4
|
-
* 字段说明(中文)
|
|
5
|
-
* - `port`/`host`:主 API 服务监听地址。
|
|
6
|
-
* - `agent start/restart` 中的 `port` 由 console 自动分配(CLI 不再暴露 `--port`)。
|
|
7
|
-
* - `rpcPort`:Agent 本机 RPC 监听端口。
|
|
8
|
-
* - 属于内部启动参数,通常由 city 自动分配,不面向普通用户。
|
|
9
|
-
* - `daemon`:兼容旧参数(显式声明后台/前台)。
|
|
10
|
-
* - `foreground`:显式前台启动。
|
|
11
|
-
*/
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=Start.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Start.js","sourceRoot":"","sources":["../../../src/types/config/Start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 后台常驻(daemon)相关类型与常量。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里统一描述 agent daemon 的 pid/log/meta 文件命名与元信息结构。
|
|
6
|
-
* - city 全局后台的运行时文件命名不放在这里,而是放到 city 包的 process/registry 路径模块。
|
|
7
|
-
*/
|
|
8
|
-
/** daemon pid 文件名。 */
|
|
9
|
-
export declare const DAEMON_PID_FILENAME = "downcity.pid";
|
|
10
|
-
/** daemon 日志文件名。 */
|
|
11
|
-
export declare const DAEMON_LOG_FILENAME = "downcity.daemon.log";
|
|
12
|
-
/** daemon 元数据文件名。 */
|
|
13
|
-
export declare const DAEMON_META_FILENAME = "downcity.daemon.json";
|
|
14
|
-
/**
|
|
15
|
-
* daemon 元数据文件结构。
|
|
16
|
-
*/
|
|
17
|
-
export interface DaemonMeta {
|
|
18
|
-
/** 当前 daemon 进程的操作系统 pid。 */
|
|
19
|
-
pid: number;
|
|
20
|
-
/** daemon 所属 agent 项目的绝对路径。 */
|
|
21
|
-
projectRoot: string;
|
|
22
|
-
/** daemon 启动时间(ISO 时间字符串)。 */
|
|
23
|
-
startedAt: string;
|
|
24
|
-
/** 启动 daemon 时使用的命令。 */
|
|
25
|
-
command: string;
|
|
26
|
-
/** 启动 daemon 时使用的参数列表。 */
|
|
27
|
-
args: string[];
|
|
28
|
-
/** 当前 node 可执行文件路径。 */
|
|
29
|
-
node: string;
|
|
30
|
-
/** 当前运行平台。 */
|
|
31
|
-
platform: NodeJS.Platform;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* daemon 进入 stale 状态的诊断项。
|
|
35
|
-
*/
|
|
36
|
-
export interface DaemonStaleReason {
|
|
37
|
-
/**
|
|
38
|
-
* 机器可读的原因编码。
|
|
39
|
-
*/
|
|
40
|
-
code: "process_not_alive" | "meta_missing" | "meta_invalid" | "meta_pid_mismatch" | "meta_project_mismatch";
|
|
41
|
-
/**
|
|
42
|
-
* 面向用户展示的原因说明。
|
|
43
|
-
*/
|
|
44
|
-
message: string;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=Daemon.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Daemon.d.ts","sourceRoot":"","sources":["../../../../src/types/runtime/daemon/Daemon.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,sBAAsB;AACtB,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,oBAAoB;AACpB,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,qBAAqB;AACrB,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EACA,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,mBAAmB,GACnB,uBAAuB,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 后台常驻(daemon)相关类型与常量。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里统一描述 agent daemon 的 pid/log/meta 文件命名与元信息结构。
|
|
6
|
-
* - city 全局后台的运行时文件命名不放在这里,而是放到 city 包的 process/registry 路径模块。
|
|
7
|
-
*/
|
|
8
|
-
/** daemon pid 文件名。 */
|
|
9
|
-
export const DAEMON_PID_FILENAME = "downcity.pid";
|
|
10
|
-
/** daemon 日志文件名。 */
|
|
11
|
-
export const DAEMON_LOG_FILENAME = "downcity.daemon.log";
|
|
12
|
-
/** daemon 元数据文件名。 */
|
|
13
|
-
export const DAEMON_META_FILENAME = "downcity.daemon.json";
|
|
14
|
-
//# sourceMappingURL=Daemon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Daemon.js","sourceRoot":"","sources":["../../../../src/types/runtime/daemon/Daemon.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,sBAAsB;AACtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAClD,oBAAoB;AACpB,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,qBAAqB;AACrB,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Daemon API 协议类型模块。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里描述的是 CLI 与 agent daemon 之间的远程访问契约,不包含具体 HTTP 实现。
|
|
6
|
-
* - plugin runtime 等上层模块只依赖这些协议类型,不需要感知 city/daemon 的内部实现细节。
|
|
7
|
-
* - 该文件属于 agent daemon 访问协议边界,而不是通用 HTTP 类型目录。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { JsonValue } from "@/types/common/Json.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Daemon 服务端点。
|
|
14
|
-
*/
|
|
15
|
-
export type DaemonEndpoint = {
|
|
16
|
-
host: string;
|
|
17
|
-
port: number;
|
|
18
|
-
baseUrl: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Daemon HTTP 方法白名单。
|
|
23
|
-
*/
|
|
24
|
-
export type DaemonHttpMethod = "GET" | "POST" | "PUT" | "DELETE";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* JSON API 调用参数。
|
|
28
|
-
*
|
|
29
|
-
* 关键点(中文)
|
|
30
|
-
* - `projectRoot` 用于解析 downcity.json 与默认 endpoint。
|
|
31
|
-
* - `host/port` 可显式覆盖自动解析结果。
|
|
32
|
-
*/
|
|
33
|
-
export type DaemonJsonApiCallParams = {
|
|
34
|
-
projectRoot: string;
|
|
35
|
-
path: string;
|
|
36
|
-
method?: DaemonHttpMethod;
|
|
37
|
-
body?: JsonValue;
|
|
38
|
-
/**
|
|
39
|
-
* 单次调用超时(毫秒)。
|
|
40
|
-
*
|
|
41
|
-
* 说明(中文)
|
|
42
|
-
* - HTTP daemon client 可消费该参数。
|
|
43
|
-
* - 用于 `session execute`、`plugin command` 这类可能持续几十秒的请求,
|
|
44
|
-
* 避免被默认短超时误判成“Agent server 未启动”。
|
|
45
|
-
*/
|
|
46
|
-
timeoutMs?: number;
|
|
47
|
-
host?: string;
|
|
48
|
-
port?: number;
|
|
49
|
-
authToken?: string;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* JSON API 通用返回结构。
|
|
54
|
-
*
|
|
55
|
-
* 语义(中文)
|
|
56
|
-
* - `success=true` 时读取 `data`。
|
|
57
|
-
* - `success=false` 时读取 `error`(可选 `status`)。
|
|
58
|
-
*/
|
|
59
|
-
export type DaemonJsonApiCallResult<T> = {
|
|
60
|
-
success: boolean;
|
|
61
|
-
status?: number;
|
|
62
|
-
data?: T;
|
|
63
|
-
error?: string;
|
|
64
|
-
};
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Daemon API 客户端(process 子模块)。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 业务模块统一通过 daemon API 与运行时通信。
|
|
6
|
-
* - HTTP gateway 与本机 RPC 的地址解析分开,避免端口语义混淆。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import fs from "fs-extra";
|
|
10
|
-
import {
|
|
11
|
-
type DaemonEndpoint,
|
|
12
|
-
type DaemonJsonApiCallParams,
|
|
13
|
-
type DaemonJsonApiCallResult,
|
|
14
|
-
} from "./Api.js";
|
|
15
|
-
import {
|
|
16
|
-
formatCliBearerHeaderValue,
|
|
17
|
-
resolveCliAuthToken,
|
|
18
|
-
} from "@/runtime/server/http/auth/CliAuthStateStore.js";
|
|
19
|
-
import { getDaemonMetaPath } from "@/runtime/host/daemon/Paths.js";
|
|
20
|
-
import type { JsonObject, JsonValue } from "@/types/common/Json.js";
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 解析端口值。
|
|
24
|
-
*
|
|
25
|
-
* 关键点(中文)
|
|
26
|
-
* - 仅接受 1~65535 的整数;非法值返回 undefined。
|
|
27
|
-
*/
|
|
28
|
-
function parsePortLike(input: string | number | undefined): number | undefined {
|
|
29
|
-
if (input === undefined || input === null || input === "") return undefined;
|
|
30
|
-
const raw =
|
|
31
|
-
typeof input === "number" ? input : Number.parseInt(String(input), 10);
|
|
32
|
-
if (!Number.isFinite(raw) || Number.isNaN(raw)) return undefined;
|
|
33
|
-
if (!Number.isInteger(raw) || raw <= 0 || raw > 65535) return undefined;
|
|
34
|
-
return raw;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 归一化 host。
|
|
39
|
-
*
|
|
40
|
-
* 关键点(中文)
|
|
41
|
-
* - `0.0.0.0`/`::` 会转换为 `127.0.0.1`,避免客户端直连通配地址失败。
|
|
42
|
-
*/
|
|
43
|
-
function normalizeHost(input: string | undefined): string | undefined {
|
|
44
|
-
const host = typeof input === "string" ? input.trim() : "";
|
|
45
|
-
if (!host) return undefined;
|
|
46
|
-
if (host === "0.0.0.0" || host === "::") return "127.0.0.1";
|
|
47
|
-
return host;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function parseErrorMessageFromPayload(data: JsonValue | null): string | null {
|
|
51
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) return null;
|
|
52
|
-
const payload = data as JsonObject;
|
|
53
|
-
if (typeof payload.error === "string") return payload.error;
|
|
54
|
-
if (typeof payload.message === "string") return payload.message;
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function pickArgValue(args: string[], key: string): string | undefined {
|
|
59
|
-
const idx = args.findIndex((item) => String(item).trim() === key);
|
|
60
|
-
if (idx < 0) return undefined;
|
|
61
|
-
const next = String(args[idx + 1] || "").trim();
|
|
62
|
-
return next || undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
type ResolveDaemonEndpointParams = {
|
|
66
|
-
projectRoot: string;
|
|
67
|
-
host?: string;
|
|
68
|
-
port?: number;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
function resolveDaemonEndpointFromSources(params: {
|
|
72
|
-
projectRoot: string;
|
|
73
|
-
explicit_host?: string;
|
|
74
|
-
explicit_port?: number;
|
|
75
|
-
env_host_name: string;
|
|
76
|
-
env_port_name: string;
|
|
77
|
-
arg_port_name: string;
|
|
78
|
-
default_host: string;
|
|
79
|
-
default_port: number;
|
|
80
|
-
}): DaemonEndpoint {
|
|
81
|
-
const explicitHost = normalizeHost(params.explicit_host);
|
|
82
|
-
const explicitPort = parsePortLike(params.explicit_port);
|
|
83
|
-
|
|
84
|
-
const envHost = normalizeHost(process.env[params.env_host_name]);
|
|
85
|
-
const envPort = parsePortLike(process.env[params.env_port_name]);
|
|
86
|
-
|
|
87
|
-
let daemonArgHost: string | undefined;
|
|
88
|
-
let daemonArgPort: number | undefined;
|
|
89
|
-
try {
|
|
90
|
-
const metaPath = getDaemonMetaPath(params.projectRoot);
|
|
91
|
-
if (fs.existsSync(metaPath)) {
|
|
92
|
-
const raw = fs.readJsonSync(metaPath) as { args?: unknown };
|
|
93
|
-
const args = Array.isArray(raw?.args)
|
|
94
|
-
? raw.args.map((item) => String(item))
|
|
95
|
-
: [];
|
|
96
|
-
daemonArgHost = normalizeHost(pickArgValue(args, "--host"));
|
|
97
|
-
daemonArgPort = parsePortLike(pickArgValue(args, params.arg_port_name));
|
|
98
|
-
}
|
|
99
|
-
} catch {
|
|
100
|
-
// ignore daemon meta errors, fallback to other sources
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const host = explicitHost || envHost || daemonArgHost || params.default_host;
|
|
104
|
-
const port = explicitPort || envPort || daemonArgPort || params.default_port;
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
host,
|
|
108
|
-
port,
|
|
109
|
-
baseUrl: `http://${host}:${port}`,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 解析 daemon endpoint。
|
|
115
|
-
*
|
|
116
|
-
* 优先级(中文)
|
|
117
|
-
* 1) 显式入参 `host/port`
|
|
118
|
-
* 2) 环境变量 `DC_CITY_HOST/DC_CITY_PORT`
|
|
119
|
-
* 3) daemon meta args(`downcity.daemon.json`)
|
|
120
|
-
* 4) 默认 `127.0.0.1:5314`
|
|
121
|
-
*/
|
|
122
|
-
function resolveDaemonEndpoint(
|
|
123
|
-
params: ResolveDaemonEndpointParams,
|
|
124
|
-
): DaemonEndpoint {
|
|
125
|
-
return resolveDaemonEndpointFromSources({
|
|
126
|
-
projectRoot: params.projectRoot,
|
|
127
|
-
explicit_host: params.host,
|
|
128
|
-
explicit_port: params.port,
|
|
129
|
-
env_host_name: "DC_CITY_HOST",
|
|
130
|
-
env_port_name: "DC_CITY_PORT",
|
|
131
|
-
arg_port_name: "--port",
|
|
132
|
-
default_host: "127.0.0.1",
|
|
133
|
-
default_port: 5314,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 调用 daemon JSON API。
|
|
139
|
-
*
|
|
140
|
-
* 错误语义(中文)
|
|
141
|
-
* - 网络异常:`success=false` + `error`(无 status)。
|
|
142
|
-
* - HTTP 非 2xx:`success=false` + `status` + `error`。
|
|
143
|
-
*/
|
|
144
|
-
export async function callServer<T>(
|
|
145
|
-
params: DaemonJsonApiCallParams,
|
|
146
|
-
): Promise<DaemonJsonApiCallResult<T>> {
|
|
147
|
-
const endpoint = resolveDaemonEndpoint({
|
|
148
|
-
projectRoot: params.projectRoot,
|
|
149
|
-
host: params.host,
|
|
150
|
-
port: params.port,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const url = new URL(params.path, endpoint.baseUrl).toString();
|
|
154
|
-
const method = params.method || "GET";
|
|
155
|
-
const hasBody = params.body !== undefined && method !== "GET";
|
|
156
|
-
const headers: Record<string, string> = {};
|
|
157
|
-
const authHeaderValue = formatCliBearerHeaderValue(
|
|
158
|
-
resolveCliAuthToken({
|
|
159
|
-
explicitToken: params.authToken,
|
|
160
|
-
}),
|
|
161
|
-
);
|
|
162
|
-
if (hasBody) {
|
|
163
|
-
headers["Content-Type"] = "application/json";
|
|
164
|
-
}
|
|
165
|
-
if (authHeaderValue) {
|
|
166
|
-
headers.Authorization = authHeaderValue;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
try {
|
|
170
|
-
const response = await fetch(url, {
|
|
171
|
-
method,
|
|
172
|
-
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
173
|
-
body: hasBody ? JSON.stringify(params.body) : undefined,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
let data: JsonValue | null = null;
|
|
177
|
-
try {
|
|
178
|
-
data = (await response.json()) as JsonValue;
|
|
179
|
-
} catch {
|
|
180
|
-
data = null;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!response.ok) {
|
|
184
|
-
const messageFromData =
|
|
185
|
-
parseErrorMessageFromPayload(data) || `HTTP ${response.status}`;
|
|
186
|
-
return {
|
|
187
|
-
success: false,
|
|
188
|
-
status: response.status,
|
|
189
|
-
error: messageFromData,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
success: true,
|
|
195
|
-
status: response.status,
|
|
196
|
-
data: data as T,
|
|
197
|
-
};
|
|
198
|
-
} catch (error) {
|
|
199
|
-
return {
|
|
200
|
-
success: false,
|
|
201
|
-
error: `Failed to call ${url}: ${String(error)}`,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent daemon 路径模块。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里只保留 agent 侧访问 daemon meta 所需的项目级路径。
|
|
6
|
-
* - daemon 进程启停、pid 清理、registry 同步属于 `downcity`,不放在 agent 包内。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import path from "node:path";
|
|
10
|
-
import { getDowncityDebugDirPath } from "@/config/Paths.js";
|
|
11
|
-
import {
|
|
12
|
-
DAEMON_LOG_FILENAME,
|
|
13
|
-
DAEMON_META_FILENAME,
|
|
14
|
-
DAEMON_PID_FILENAME,
|
|
15
|
-
} from "@/types/runtime/daemon/Daemon.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 计算 daemon pid 文件路径。
|
|
19
|
-
*/
|
|
20
|
-
export const getDaemonPidPath = (projectRoot: string): string =>
|
|
21
|
-
path.join(getDowncityDebugDirPath(projectRoot), DAEMON_PID_FILENAME);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 计算 daemon 日志文件路径。
|
|
25
|
-
*/
|
|
26
|
-
export const getDaemonLogPath = (projectRoot: string): string =>
|
|
27
|
-
path.join(getDowncityDebugDirPath(projectRoot), DAEMON_LOG_FILENAME);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 计算 daemon 元数据文件路径。
|
|
31
|
-
*/
|
|
32
|
-
export const getDaemonMetaPath = (projectRoot: string): string =>
|
|
33
|
-
path.join(getDowncityDebugDirPath(projectRoot), DAEMON_META_FILENAME);
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent HTTP Server 装配模块。
|
|
3
|
-
*
|
|
4
|
-
* 职责说明:
|
|
5
|
-
* 1. 创建主 Hono 应用并挂载各路由模块。
|
|
6
|
-
* 2. 管理 Node HTTP Server 的启动与停止。
|
|
7
|
-
* 3. 保持 server 层只做协议装配,不混入具体路由实现。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Hono } from "hono";
|
|
11
|
-
import { cors } from "hono/cors";
|
|
12
|
-
import { logger } from "hono/logger";
|
|
13
|
-
import http from "node:http";
|
|
14
|
-
import { Readable } from "node:stream";
|
|
15
|
-
import { finished } from "node:stream/promises";
|
|
16
|
-
import { logger as serverLogger } from "@/utils/logger/Logger.js";
|
|
17
|
-
import { createExecuteRouter } from "@/runtime/server/http/execute/execute.js";
|
|
18
|
-
import { healthRouter } from "@/runtime/server/http/health/health.js";
|
|
19
|
-
import { createPluginsRouter } from "@/runtime/server/http/plugins/plugins.js";
|
|
20
|
-
import { createStaticRouter } from "@/runtime/server/http/static/static.js";
|
|
21
|
-
import { createControlRouter } from "@/runtime/server/http/control/ControlRouter.js";
|
|
22
|
-
import { createSdkRouter } from "@/runtime/server/http/sdk/Router.js";
|
|
23
|
-
import type { AgentRuntime } from "@/types/runtime/agent/AgentRuntime.js";
|
|
24
|
-
import type { AgentContext } from "@/types/runtime/agent/AgentContext.js";
|
|
25
|
-
import type { AgentSessionCollection } from "@/types/agent/AgentTypes.js";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Server 启动参数。
|
|
29
|
-
*/
|
|
30
|
-
export interface ServerStartOptions {
|
|
31
|
-
/** HTTP 服务监听端口。 */
|
|
32
|
-
port: number;
|
|
33
|
-
/** HTTP 服务监听主机。 */
|
|
34
|
-
host: string;
|
|
35
|
-
/** 当前 agent runtime 读取函数。 */
|
|
36
|
-
getAgentRuntime: () => AgentRuntime;
|
|
37
|
-
/** 当前 agent context 读取函数。 */
|
|
38
|
-
getAgentContext: () => AgentContext;
|
|
39
|
-
/** 可选 SDK Session 集合绑定。 */
|
|
40
|
-
sessionCollection?: AgentSessionCollection;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Server 运行实例。
|
|
45
|
-
*/
|
|
46
|
-
export interface ServerInstance {
|
|
47
|
-
/** Hono 应用实例。 */
|
|
48
|
-
app: Hono;
|
|
49
|
-
/** 原生 HTTP Server 实例。 */
|
|
50
|
-
server: http.Server;
|
|
51
|
-
/** 停止当前服务。 */
|
|
52
|
-
stop(): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 创建主 Hono 应用。
|
|
57
|
-
*/
|
|
58
|
-
export function createServerApp(
|
|
59
|
-
options: Pick<
|
|
60
|
-
ServerStartOptions,
|
|
61
|
-
"getAgentRuntime" | "getAgentContext" | "sessionCollection"
|
|
62
|
-
>,
|
|
63
|
-
): Hono {
|
|
64
|
-
const app = new Hono();
|
|
65
|
-
|
|
66
|
-
app.use("*", logger());
|
|
67
|
-
app.use(
|
|
68
|
-
"*",
|
|
69
|
-
cors({
|
|
70
|
-
origin: "*",
|
|
71
|
-
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
72
|
-
allowHeaders: ["Content-Type", "Authorization"],
|
|
73
|
-
}),
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// 关键点(中文):按路由域挂载,server 模块只保留装配职责。
|
|
77
|
-
app.route("/", createStaticRouter({
|
|
78
|
-
getAgentRuntime: options.getAgentRuntime,
|
|
79
|
-
}));
|
|
80
|
-
app.route("/", healthRouter);
|
|
81
|
-
app.route("/", createPluginsRouter({
|
|
82
|
-
getAgentContext: options.getAgentContext,
|
|
83
|
-
}));
|
|
84
|
-
app.route("/", createExecuteRouter({
|
|
85
|
-
getAgentRuntime: options.getAgentRuntime,
|
|
86
|
-
}));
|
|
87
|
-
app.route("/", createControlRouter({
|
|
88
|
-
getAgentRuntime: options.getAgentRuntime,
|
|
89
|
-
getAgentContext: options.getAgentContext,
|
|
90
|
-
}));
|
|
91
|
-
if (options.sessionCollection) {
|
|
92
|
-
app.route("/", createSdkRouter(options.sessionCollection));
|
|
93
|
-
}
|
|
94
|
-
for (const plugin of options.getAgentContext().agent.pluginInstances.values()) {
|
|
95
|
-
plugin.http?.server?.register({
|
|
96
|
-
app,
|
|
97
|
-
getContext: options.getAgentContext,
|
|
98
|
-
pluginName: plugin.name,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return app;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 启动主 HTTP 服务。
|
|
107
|
-
*/
|
|
108
|
-
export async function startServer(
|
|
109
|
-
options: ServerStartOptions,
|
|
110
|
-
): Promise<ServerInstance> {
|
|
111
|
-
const app = createServerApp(options);
|
|
112
|
-
const server = createNodeServer(app, options);
|
|
113
|
-
|
|
114
|
-
await new Promise<void>((resolve) => {
|
|
115
|
-
server.listen(options.port, options.host, () => {
|
|
116
|
-
serverLogger.info(
|
|
117
|
-
`🚀 Agent Server started: http://${options.host}:${options.port}`,
|
|
118
|
-
);
|
|
119
|
-
serverLogger.info("Available APIs:");
|
|
120
|
-
resolve();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
app,
|
|
126
|
-
server,
|
|
127
|
-
async stop(): Promise<void> {
|
|
128
|
-
await serverLogger.saveAllLogs();
|
|
129
|
-
await new Promise<void>((resolve) => {
|
|
130
|
-
server.close(() => resolve());
|
|
131
|
-
});
|
|
132
|
-
serverLogger.info("Agent Server stopped");
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 创建 Node HTTP Server 适配层。
|
|
139
|
-
*/
|
|
140
|
-
function createNodeServer(app: Hono, options: ServerStartOptions): http.Server {
|
|
141
|
-
return http.createServer(async (req, res) => {
|
|
142
|
-
try {
|
|
143
|
-
const url = new URL(req.url || "/", `http://${options.host}:${options.port}`);
|
|
144
|
-
const method = req.method || "GET";
|
|
145
|
-
const bodyBuffer = await readRequestBody(req);
|
|
146
|
-
const request = new Request(url.toString(), {
|
|
147
|
-
method,
|
|
148
|
-
headers: new Headers(req.headers as Record<string, string>),
|
|
149
|
-
body: bodyBuffer.length > 0 ? bodyBuffer : undefined,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const response = await app.fetch(request);
|
|
153
|
-
res.statusCode = response.status;
|
|
154
|
-
for (const [key, value] of response.headers.entries()) {
|
|
155
|
-
res.setHeader(key, value);
|
|
156
|
-
}
|
|
157
|
-
if (!response.body) {
|
|
158
|
-
res.end();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const bodyStream = Readable.fromWeb(
|
|
162
|
-
response.body as unknown as globalThis.ReadableStream<Uint8Array>,
|
|
163
|
-
);
|
|
164
|
-
bodyStream.pipe(res);
|
|
165
|
-
await finished(bodyStream).catch(() => undefined);
|
|
166
|
-
} catch {
|
|
167
|
-
res.statusCode = 500;
|
|
168
|
-
res.end("Internal Server Error");
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* 读取原生请求体。
|
|
175
|
-
*/
|
|
176
|
-
async function readRequestBody(req: http.IncomingMessage): Promise<Buffer> {
|
|
177
|
-
return new Promise<Buffer>((resolve, reject) => {
|
|
178
|
-
const chunks: Buffer[] = [];
|
|
179
|
-
req.on("data", (chunk) => chunks.push(chunk));
|
|
180
|
-
req.on("end", () => resolve(Buffer.concat(chunks)));
|
|
181
|
-
req.on("error", reject);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Control API 路由聚合入口。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 本文件只做模块装配,不再承载具体业务逻辑。
|
|
6
|
-
* - 单 agent control API 子路由按 overview/session/task/auth 四类拆分,便于继续维护。
|
|
7
|
-
* - 单 agent control API 统一暴露在 `/api/control/*` 下。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { ControlRouteRegistrationParams } from "@/runtime/server/http/control/types/ControlRoutes.js";
|
|
11
|
-
import { registerControlAuthorizationRoutes } from "@/runtime/server/http/control/ControlAuthorizationRoutes.js";
|
|
12
|
-
import { registerControlSessionRoutes } from "@/runtime/server/http/control/SessionRoutes.js";
|
|
13
|
-
import { registerControlOverviewRoutes } from "@/runtime/server/http/control/OverviewRoutes.js";
|
|
14
|
-
import { registerControlTaskRoutes } from "@/runtime/server/http/control/TaskRoutes.js";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 注册单 agent control API 路由。
|
|
18
|
-
*/
|
|
19
|
-
export function registerControlApiRoutes(
|
|
20
|
-
params: ControlRouteRegistrationParams,
|
|
21
|
-
): void {
|
|
22
|
-
registerControlAuthorizationRoutes({
|
|
23
|
-
app: params.app,
|
|
24
|
-
getAgentContext: params.getAgentContext,
|
|
25
|
-
});
|
|
26
|
-
registerControlOverviewRoutes(params);
|
|
27
|
-
registerControlSessionRoutes(params);
|
|
28
|
-
registerControlTaskRoutes(params);
|
|
29
|
-
}
|