@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
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local RPC 客户端。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 只用于本机受信任 IPC,不附加 HTTP Bearer 鉴权。
|
|
6
|
-
* - 返回结构与 HTTP `callServer()` 对齐,便于上层透明切换 transport。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import net from "node:net";
|
|
10
|
-
import { nanoid } from "nanoid";
|
|
11
|
-
import type {
|
|
12
|
-
DaemonJsonApiCallParams,
|
|
13
|
-
DaemonJsonApiCallResult,
|
|
14
|
-
} from "@/runtime/host/daemon/Api.js";
|
|
15
|
-
import type { LocalRpcRequest, LocalRpcResponse } from "@/types/runtime/rpc/LocalRpc.js";
|
|
16
|
-
import { getLocalRpcEndpoint } from "./Paths.js";
|
|
17
|
-
|
|
18
|
-
const LOCAL_RPC_TIMEOUT_MS = 5_000;
|
|
19
|
-
|
|
20
|
-
function toLocalRpcRequest(params: DaemonJsonApiCallParams): LocalRpcRequest {
|
|
21
|
-
return {
|
|
22
|
-
requestId: nanoid(),
|
|
23
|
-
path: String(params.path || "").trim(),
|
|
24
|
-
method: params.method || "GET",
|
|
25
|
-
...(params.body !== undefined ? { body: params.body } : {}),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 通过本地 IPC 调用 agent runtime。
|
|
31
|
-
*/
|
|
32
|
-
export async function callLocalServer<T>(
|
|
33
|
-
params: DaemonJsonApiCallParams,
|
|
34
|
-
): Promise<DaemonJsonApiCallResult<T>> {
|
|
35
|
-
const endpoint = getLocalRpcEndpoint(params.projectRoot);
|
|
36
|
-
const request = toLocalRpcRequest(params);
|
|
37
|
-
const timeoutMs =
|
|
38
|
-
typeof params.timeoutMs === "number" &&
|
|
39
|
-
Number.isFinite(params.timeoutMs) &&
|
|
40
|
-
params.timeoutMs > 0
|
|
41
|
-
? Math.floor(params.timeoutMs)
|
|
42
|
-
: LOCAL_RPC_TIMEOUT_MS;
|
|
43
|
-
|
|
44
|
-
return await new Promise<DaemonJsonApiCallResult<T>>((resolve) => {
|
|
45
|
-
const socket = net.createConnection(endpoint);
|
|
46
|
-
let settled = false;
|
|
47
|
-
let buffered = "";
|
|
48
|
-
|
|
49
|
-
const finish = (result: DaemonJsonApiCallResult<T>): void => {
|
|
50
|
-
if (settled) return;
|
|
51
|
-
settled = true;
|
|
52
|
-
socket.destroy();
|
|
53
|
-
resolve(result);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
socket.setEncoding("utf8");
|
|
57
|
-
socket.setTimeout(timeoutMs);
|
|
58
|
-
|
|
59
|
-
socket.on("connect", () => {
|
|
60
|
-
socket.write(`${JSON.stringify(request)}\n`);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
socket.on("data", (chunk) => {
|
|
64
|
-
buffered += String(chunk || "");
|
|
65
|
-
const newlineIndex = buffered.indexOf("\n");
|
|
66
|
-
if (newlineIndex < 0) return;
|
|
67
|
-
const raw = buffered.slice(0, newlineIndex).trim();
|
|
68
|
-
if (!raw) {
|
|
69
|
-
finish({
|
|
70
|
-
success: false,
|
|
71
|
-
error: `Local RPC returned empty payload from ${endpoint}`,
|
|
72
|
-
});
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const response = JSON.parse(raw) as LocalRpcResponse;
|
|
77
|
-
finish({
|
|
78
|
-
success: response.success,
|
|
79
|
-
status: response.status,
|
|
80
|
-
...(response.data !== undefined ? { data: response.data as T } : {}),
|
|
81
|
-
...(response.error ? { error: response.error } : {}),
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
finish({
|
|
85
|
-
success: false,
|
|
86
|
-
error: `Local RPC returned invalid JSON from ${endpoint}: ${String(error)}`,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
socket.on("timeout", () => {
|
|
92
|
-
finish({
|
|
93
|
-
success: false,
|
|
94
|
-
error: `Local RPC timed out after ${timeoutMs}ms (${endpoint})`,
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
socket.on("error", (error) => {
|
|
99
|
-
finish({
|
|
100
|
-
success: false,
|
|
101
|
-
error: `Local RPC unavailable at ${endpoint}: ${String(error)}`,
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
socket.on("end", () => {
|
|
106
|
-
if (settled) return;
|
|
107
|
-
finish({
|
|
108
|
-
success: false,
|
|
109
|
-
error: `Local RPC closed without response (${endpoint})`,
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local RPC 路径工具。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 本地受信任进程之间统一通过 IPC socket/pipe 通信。
|
|
6
|
-
* - Unix 平台使用 city 全局 runtime 目录下的稳定 socket 文件,避免不同启动上下文
|
|
7
|
-
* 的 `TMPDIR` 不一致,导致同一个 agent 被解析到两个不同 socket 路径。
|
|
8
|
-
* - Windows 平台使用命名 pipe,并基于项目路径 hash 保证稳定唯一。
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import crypto from "node:crypto";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import { getPlatformRootDirPath } from "@/config/PlatformPaths.js";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 读取平台级运行目录。
|
|
17
|
-
*/
|
|
18
|
-
function getPlatformRuntimeDirPath(): string {
|
|
19
|
-
return path.join(getPlatformRootDirPath(), "main");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function buildProjectDigest(projectRoot: string): string {
|
|
23
|
-
return crypto
|
|
24
|
-
.createHash("sha1")
|
|
25
|
-
.update(path.resolve(projectRoot))
|
|
26
|
-
.digest("hex")
|
|
27
|
-
.slice(0, 16);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function buildWindowsPipeName(projectRoot: string): string {
|
|
31
|
-
const digest = buildProjectDigest(projectRoot);
|
|
32
|
-
return `\\\\.\\pipe\\downcity-local-${digest}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getLocalRpcUnixDirPath(): string {
|
|
36
|
-
return path.join(getPlatformRuntimeDirPath(), "local-rpc");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 返回本地 RPC endpoint。
|
|
41
|
-
*/
|
|
42
|
-
export function getLocalRpcEndpoint(projectRoot: string): string {
|
|
43
|
-
if (process.platform === "win32") {
|
|
44
|
-
return buildWindowsPipeName(projectRoot);
|
|
45
|
-
}
|
|
46
|
-
return path.join(
|
|
47
|
-
getLocalRpcUnixDirPath(),
|
|
48
|
-
`downcity-local-${buildProjectDigest(projectRoot)}.sock`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 本地/远程 transport 选择器。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 本地受信任调用默认优先使用 IPC。
|
|
6
|
-
* - 只有显式传入 `host/port` 时,才视为外部 HTTP 调用。
|
|
7
|
-
* - 当前返回结构与 `callServer()` 保持一致,方便命令层复用。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type {
|
|
11
|
-
DaemonJsonApiCallParams,
|
|
12
|
-
DaemonJsonApiCallResult,
|
|
13
|
-
} from "@/runtime/host/daemon/Api.js";
|
|
14
|
-
import { callServer } from "@/runtime/host/daemon/Client.js";
|
|
15
|
-
import { callLocalServer } from "./Client.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 判断是否应强制使用 HTTP transport。
|
|
19
|
-
*/
|
|
20
|
-
export function shouldUseHttpTransport(params: {
|
|
21
|
-
host?: string;
|
|
22
|
-
port?: number;
|
|
23
|
-
}): boolean {
|
|
24
|
-
return Boolean(
|
|
25
|
-
(typeof params.host === "string" && params.host.trim()) ||
|
|
26
|
-
typeof params.port === "number",
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 统一调用 agent transport。
|
|
32
|
-
*/
|
|
33
|
-
export async function callAgentTransport<T>(
|
|
34
|
-
params: DaemonJsonApiCallParams,
|
|
35
|
-
): Promise<DaemonJsonApiCallResult<T>> {
|
|
36
|
-
if (shouldUseHttpTransport({
|
|
37
|
-
host: params.host,
|
|
38
|
-
port: params.port,
|
|
39
|
-
})) {
|
|
40
|
-
return await callServer<T>(params);
|
|
41
|
-
}
|
|
42
|
-
return await callLocalServer<T>(params);
|
|
43
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 配置值递归结构类型。
|
|
3
|
-
*
|
|
4
|
-
* 职责说明(中文)
|
|
5
|
-
* - 描述 `downcity.json` 在“读取原始 JSON -> 解析环境变量占位符”阶段可接受的值结构。
|
|
6
|
-
* - 允许对象、数组、JSON 标量与 `undefined` 递归嵌套,供配置解析工具复用。
|
|
7
|
-
* - 该类型只服务配置装配阶段,不承诺运行时最终配置的严格业务语义。
|
|
8
|
-
*/
|
|
9
|
-
export type ResolvedConfigValue =
|
|
10
|
-
| string
|
|
11
|
-
| number
|
|
12
|
-
| boolean
|
|
13
|
-
| null
|
|
14
|
-
| undefined
|
|
15
|
-
| { [key: string]: ResolvedConfigValue }
|
|
16
|
-
| ResolvedConfigValue[];
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LocalRpc:本地 IPC 调用协议类型。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 仅用于本机受信任进程之间的调用,不承担外部 HTTP 鉴权职责。
|
|
6
|
-
* - 当前协议采用“一连接一请求一响应”的 JSON 行格式,便于调试与逐步演进。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { JsonValue } from "@/types/common/Json.js";
|
|
10
|
-
import type { DaemonHttpMethod } from "@/runtime/host/daemon/Api.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 单次本地 RPC 请求。
|
|
14
|
-
*/
|
|
15
|
-
export interface LocalRpcRequest {
|
|
16
|
-
/**
|
|
17
|
-
* 请求唯一标识。
|
|
18
|
-
*/
|
|
19
|
-
requestId: string;
|
|
20
|
-
/**
|
|
21
|
-
* 目标 API 路径。
|
|
22
|
-
*/
|
|
23
|
-
path: string;
|
|
24
|
-
/**
|
|
25
|
-
* 调用方法。
|
|
26
|
-
*/
|
|
27
|
-
method: DaemonHttpMethod;
|
|
28
|
-
/**
|
|
29
|
-
* 可选结构化请求体。
|
|
30
|
-
*/
|
|
31
|
-
body?: JsonValue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 单次本地 RPC 响应。
|
|
36
|
-
*/
|
|
37
|
-
export interface LocalRpcResponse {
|
|
38
|
-
/**
|
|
39
|
-
* 对应请求标识。
|
|
40
|
-
*/
|
|
41
|
-
requestId: string;
|
|
42
|
-
/**
|
|
43
|
-
* HTTP 风格状态码。
|
|
44
|
-
*/
|
|
45
|
-
status: number;
|
|
46
|
-
/**
|
|
47
|
-
* 调用是否成功。
|
|
48
|
-
*/
|
|
49
|
-
success: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* 成功时的数据。
|
|
52
|
-
*/
|
|
53
|
-
data?: JsonValue;
|
|
54
|
-
/**
|
|
55
|
-
* 失败时的错误信息。
|
|
56
|
-
*/
|
|
57
|
-
error?: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 本地 RPC server 句柄。
|
|
62
|
-
*/
|
|
63
|
-
export interface LocalRpcServerHandle {
|
|
64
|
-
/**
|
|
65
|
-
* 当前绑定的 socket/pipe 地址。
|
|
66
|
-
*/
|
|
67
|
-
endpoint: string;
|
|
68
|
-
/**
|
|
69
|
-
* 停止本地 RPC server。
|
|
70
|
-
*/
|
|
71
|
-
stop(): Promise<void>;
|
|
72
|
-
}
|