@actiondock/core 2.5.0 → 2.6.0

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.
Files changed (134) hide show
  1. package/dist/app/app.d.ts +14 -1
  2. package/dist/app/app.js +88 -215
  3. package/dist/app/static-index.d.ts +39 -0
  4. package/dist/app/static-index.js +164 -0
  5. package/dist/app/types.d.ts +5 -0
  6. package/dist/catalog/action-index.js +6 -4
  7. package/dist/catalog/package-catalog.js +2 -1
  8. package/dist/doctor/checks/index.d.ts +5 -0
  9. package/dist/doctor/checks/index.js +5 -0
  10. package/dist/doctor/checks/project-locate.d.ts +6 -0
  11. package/dist/doctor/checks/project-locate.js +36 -0
  12. package/dist/doctor/checks/project.d.ts +6 -0
  13. package/dist/doctor/checks/project.js +383 -0
  14. package/dist/doctor/checks/registry.d.ts +13 -0
  15. package/dist/doctor/checks/registry.js +207 -0
  16. package/dist/doctor/checks/runtime.d.ts +13 -0
  17. package/dist/doctor/checks/runtime.js +90 -0
  18. package/dist/doctor/checks/storage.d.ts +5 -0
  19. package/dist/doctor/checks/storage.js +34 -0
  20. package/dist/doctor/context.d.ts +35 -0
  21. package/dist/doctor/context.js +11 -0
  22. package/dist/doctor/doctor.d.ts +5 -0
  23. package/dist/doctor/doctor.js +33 -602
  24. package/dist/errors.d.ts +2 -0
  25. package/dist/errors.js +2 -0
  26. package/dist/execution/service.js +14 -9
  27. package/dist/host/host.d.ts +33 -0
  28. package/dist/host/host.js +222 -362
  29. package/dist/host/routing.d.ts +92 -0
  30. package/dist/host/routing.js +238 -0
  31. package/dist/host/types.d.ts +8 -0
  32. package/dist/ipc/host.js +38 -0
  33. package/dist/platform/types.d.ts +7 -0
  34. package/dist/process/control-arbiter.d.ts +107 -0
  35. package/dist/process/control-arbiter.js +251 -0
  36. package/dist/process/diagnostics-sink.d.ts +26 -0
  37. package/dist/process/diagnostics-sink.js +35 -0
  38. package/dist/process/index.d.ts +7 -0
  39. package/dist/process/index.js +7 -0
  40. package/dist/process/input-dispatcher.d.ts +88 -0
  41. package/dist/process/input-dispatcher.js +240 -0
  42. package/dist/process/managed-record.d.ts +78 -0
  43. package/dist/process/managed-record.js +1 -0
  44. package/dist/process/process-manager.d.ts +15 -56
  45. package/dist/process/process-manager.js +119 -707
  46. package/dist/process/reservation-table.d.ts +39 -0
  47. package/dist/process/reservation-table.js +80 -0
  48. package/dist/process/run-executor.d.ts +16 -0
  49. package/dist/process/run-executor.js +155 -0
  50. package/dist/process/terminal-output-cache.d.ts +66 -0
  51. package/dist/process/terminal-output-cache.js +132 -0
  52. package/dist/profile/client-actions.d.ts +56 -0
  53. package/dist/profile/client-actions.js +215 -0
  54. package/dist/profile/client-config.d.ts +20 -0
  55. package/dist/profile/client-config.js +51 -0
  56. package/dist/profile/client-health.d.ts +14 -0
  57. package/dist/profile/client-health.js +68 -0
  58. package/dist/profile/client-playbooks.d.ts +19 -0
  59. package/dist/profile/client-playbooks.js +36 -0
  60. package/dist/profile/client-query.d.ts +30 -0
  61. package/dist/profile/client-query.js +70 -0
  62. package/dist/profile/client-runs.d.ts +42 -0
  63. package/dist/profile/client-runs.js +58 -0
  64. package/dist/profile/client-state.d.ts +56 -0
  65. package/dist/profile/client-state.js +83 -0
  66. package/dist/profile/client-transport.d.ts +61 -0
  67. package/dist/profile/client-transport.js +155 -0
  68. package/dist/profile/client.d.ts +23 -142
  69. package/dist/profile/client.js +28 -588
  70. package/dist/profile/manager.js +1 -1
  71. package/dist/project/closure.d.ts +4 -4
  72. package/dist/project/closure.js +11 -5
  73. package/dist/project/init.js +2 -2
  74. package/dist/project/loader.d.ts +0 -25
  75. package/dist/project/loader.js +1 -154
  76. package/dist/project/transactions.d.ts +12 -14
  77. package/dist/project/transactions.js +60 -836
  78. package/dist/registry/registry.js +6 -4
  79. package/dist/registry/resolve.js +1 -1
  80. package/dist/runtime/action-registry.d.ts +45 -0
  81. package/dist/runtime/action-registry.js +108 -0
  82. package/dist/runtime/clock.d.ts +5 -17
  83. package/dist/runtime/clock.js +5 -15
  84. package/dist/runtime/context.d.ts +3 -0
  85. package/dist/runtime/context.js +17 -56
  86. package/dist/runtime/index.d.ts +3 -0
  87. package/dist/runtime/index.js +3 -0
  88. package/dist/runtime/package-runner-factory.d.ts +82 -0
  89. package/dist/runtime/package-runner-factory.js +186 -0
  90. package/dist/runtime/run-persistence.d.ts +85 -0
  91. package/dist/runtime/run-persistence.js +111 -0
  92. package/dist/runtime/runner.d.ts +23 -33
  93. package/dist/runtime/runner.js +92 -286
  94. package/dist/runtime/standalone.d.ts +11 -1
  95. package/dist/runtime/standalone.js +137 -25
  96. package/dist/server/dispatcher.d.ts +8 -3
  97. package/dist/server/dispatcher.js +16 -40
  98. package/dist/server/routes/runs.js +6 -4
  99. package/dist/server/security.d.ts +1 -7
  100. package/dist/server/security.js +2 -13
  101. package/dist/storage/clock.d.ts +25 -0
  102. package/dist/storage/clock.js +23 -0
  103. package/dist/storage/data-dir-lock.d.ts +3 -36
  104. package/dist/storage/data-dir-lock.js +48 -881
  105. package/dist/storage/index.d.ts +8 -1
  106. package/dist/storage/index.js +8 -2
  107. package/dist/storage/lazy.js +1 -0
  108. package/dist/storage/lock-core.d.ts +162 -0
  109. package/dist/storage/lock-core.js +885 -0
  110. package/dist/storage/sqlite.d.ts +19 -6
  111. package/dist/storage/sqlite.js +81 -89
  112. package/dist/storage/types.d.ts +27 -5
  113. package/dist/storage/types.js +21 -0
  114. package/dist/storage/utils.d.ts +22 -0
  115. package/dist/storage/utils.js +34 -0
  116. package/dist/target/local.d.ts +1 -0
  117. package/dist/target/local.js +23 -17
  118. package/dist/target/remote-errors.d.ts +21 -0
  119. package/dist/target/remote-errors.js +51 -0
  120. package/dist/target/remote-polling.d.ts +35 -0
  121. package/dist/target/remote-polling.js +104 -0
  122. package/dist/target/remote.d.ts +4 -0
  123. package/dist/target/remote.js +108 -301
  124. package/dist/target/sse-parser.d.ts +35 -0
  125. package/dist/target/sse-parser.js +163 -0
  126. package/dist/target/target.js +2 -0
  127. package/dist/target/types.d.ts +6 -0
  128. package/dist/utils/index.d.ts +1 -0
  129. package/dist/utils/index.js +1 -0
  130. package/dist/utils/net.d.ts +10 -0
  131. package/dist/utils/net.js +16 -0
  132. package/dist/version.d.ts +1 -1
  133. package/dist/version.js +1 -1
  134. package/package.json +2 -2
@@ -0,0 +1,56 @@
1
+ import type { RemoteClientRequestOptions } from "./client-transport.js";
2
+ /**
3
+ * 远端状态存储域端点。
4
+ */
5
+ /**
6
+ * 列出远端状态键(可按包、Action、命名空间与前缀过滤)。
7
+ */
8
+ export declare function fetchRemoteStateList(serverUrl: string, token?: string, options?: {
9
+ package?: string;
10
+ action?: string;
11
+ namespace?: string;
12
+ prefix?: string;
13
+ } & RemoteClientRequestOptions): Promise<{
14
+ ok: boolean;
15
+ packageId: string;
16
+ keys: string[];
17
+ }>;
18
+ /**
19
+ * 读取单个远端状态键的值。
20
+ */
21
+ export declare function getRemoteStateKey(serverUrl: string, key: string, token?: string, options?: {
22
+ package?: string;
23
+ action?: string;
24
+ namespace?: string;
25
+ } & RemoteClientRequestOptions): Promise<any>;
26
+ /**
27
+ * 写入单个远端状态键(可携带 TTL 过期时间)。
28
+ */
29
+ export declare function setRemoteStateKey(serverUrl: string, key: string, value: unknown, token?: string, options?: {
30
+ package?: string;
31
+ action?: string;
32
+ namespace?: string;
33
+ ttl?: number;
34
+ } & RemoteClientRequestOptions): Promise<any>;
35
+ /**
36
+ * 删除单个远端状态键。
37
+ */
38
+ export declare function deleteRemoteStateKey(serverUrl: string, key: string, token?: string, options?: {
39
+ package?: string;
40
+ action?: string;
41
+ namespace?: string;
42
+ } & RemoteClientRequestOptions): Promise<any>;
43
+ /**
44
+ * 批量清除远端状态键(可按包、Action、命名空间、前缀与全量标志过滤)。
45
+ */
46
+ export declare function clearRemoteState(serverUrl: string, token?: string, options?: {
47
+ package?: string;
48
+ action?: string;
49
+ namespace?: string;
50
+ prefix?: string;
51
+ all?: boolean;
52
+ } & RemoteClientRequestOptions): Promise<{
53
+ ok: boolean;
54
+ packageId: string;
55
+ clearedCount: number;
56
+ }>;
@@ -0,0 +1,83 @@
1
+ import { buildQueryStringPreservingEmpty, fetchRemoteJson } from "./client-query.js";
2
+ /**
3
+ * 远端状态存储域端点。
4
+ */
5
+ /**
6
+ * 列出远端状态键(可按包、Action、命名空间与前缀过滤)。
7
+ */
8
+ export async function fetchRemoteStateList(serverUrl, token, options) {
9
+ return fetchRemoteJson(serverUrl, `/api/v2/state${buildQueryStringPreservingEmpty({
10
+ package: options?.package,
11
+ action: options?.action,
12
+ namespace: options?.namespace,
13
+ prefix: options?.prefix,
14
+ })}`, token, {
15
+ errorPrefix: "Failed to list remote state keys",
16
+ allowInsecureHttp: options?.allowInsecureHttp,
17
+ insecure: options?.insecure,
18
+ dispatcher: options?.dispatcher,
19
+ });
20
+ }
21
+ /**
22
+ * 读取单个远端状态键的值。
23
+ */
24
+ export async function getRemoteStateKey(serverUrl, key, token, options) {
25
+ return fetchRemoteJson(serverUrl, `/api/v2/state/${encodeURIComponent(key)}${buildQueryStringPreservingEmpty({
26
+ package: options?.package,
27
+ action: options?.action,
28
+ namespace: options?.namespace,
29
+ })}`, token, {
30
+ errorPrefix: `Failed to fetch remote state key '${key}'`,
31
+ allowInsecureHttp: options?.allowInsecureHttp,
32
+ insecure: options?.insecure,
33
+ dispatcher: options?.dispatcher,
34
+ });
35
+ }
36
+ /**
37
+ * 写入单个远端状态键(可携带 TTL 过期时间)。
38
+ */
39
+ export async function setRemoteStateKey(serverUrl, key, value, token, options) {
40
+ return fetchRemoteJson(serverUrl, `/api/v2/state/${encodeURIComponent(key)}`, token, {
41
+ method: "PUT",
42
+ body: {
43
+ value,
44
+ package: options?.package,
45
+ action: options?.action,
46
+ namespace: options?.namespace,
47
+ ttl: options?.ttl,
48
+ },
49
+ errorPrefix: `Failed to set remote state key '${key}'`,
50
+ allowInsecureHttp: options?.allowInsecureHttp,
51
+ insecure: options?.insecure,
52
+ dispatcher: options?.dispatcher,
53
+ });
54
+ }
55
+ /**
56
+ * 删除单个远端状态键。
57
+ */
58
+ export async function deleteRemoteStateKey(serverUrl, key, token, options) {
59
+ return fetchRemoteJson(serverUrl, `/api/v2/state/${encodeURIComponent(key)}${buildQueryStringPreservingEmpty({
60
+ package: options?.package,
61
+ action: options?.action,
62
+ namespace: options?.namespace,
63
+ })}`, token, {
64
+ method: "DELETE",
65
+ errorPrefix: `Failed to delete remote state key '${key}'`,
66
+ allowInsecureHttp: options?.allowInsecureHttp,
67
+ insecure: options?.insecure,
68
+ dispatcher: options?.dispatcher,
69
+ });
70
+ }
71
+ /**
72
+ * 批量清除远端状态键(可按包、Action、命名空间、前缀与全量标志过滤)。
73
+ */
74
+ export async function clearRemoteState(serverUrl, token, options) {
75
+ return fetchRemoteJson(serverUrl, "/api/v2/state/clear", token, {
76
+ method: "POST",
77
+ body: options || {},
78
+ errorPrefix: "Failed to clear remote state",
79
+ allowInsecureHttp: options?.allowInsecureHttp,
80
+ insecure: options?.insecure,
81
+ dispatcher: options?.dispatcher,
82
+ });
83
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * 远端客户端传输层。
3
+ *
4
+ * 职责单一聚焦:鉴权头拼装、明文传输安全校验、insecure dispatcher 注入
5
+ * 与 v2 -> v1 协议回退,作为全部远端端点函数的传输样板单一事实源。
6
+ */
7
+ /**
8
+ * 校验在携带认证 Token 时传输层协议是否安全。
9
+ * 若请求携带认证 Token 且目标为非本地回环的明文 http://,默认报错拒绝。
10
+ * 可通过 allowInsecureHttp 选项、insecure 选项、环境变量或命令行参数豁免。
11
+ */
12
+ export declare function assertSecureTransport(serverUrl: string, token?: string, allowInsecureHttpOrOptions?: boolean | {
13
+ allowInsecureHttp?: boolean;
14
+ insecure?: boolean;
15
+ }, insecureArg?: boolean): void;
16
+ /**
17
+ * 构造携带鉴权信息的标准请求头。
18
+ */
19
+ export declare function buildHeaders(token?: string): Record<string, string>;
20
+ /**
21
+ * 远端请求通用控制选项。
22
+ */
23
+ export interface RemoteClientRequestOptions {
24
+ /** 是否允许通过非回环明文 HTTP 发送认证 Token */
25
+ allowInsecureHttp?: boolean;
26
+ /** 是否跳过服务端 TLS 证书合法性校验 */
27
+ insecure?: boolean;
28
+ /** 自定义底层 HTTP 调度器(平台中立) */
29
+ dispatcher?: unknown;
30
+ }
31
+ /** 远端请求描述选项。 */
32
+ export interface RemoteFetchInit {
33
+ /** HTTP 方法(默认 GET) */
34
+ method?: string;
35
+ /** JSON 序列化请求体 */
36
+ body?: unknown;
37
+ /** 额外合并的请求头 */
38
+ headers?: Record<string, string>;
39
+ /** 中断信号 */
40
+ signal?: AbortSignal;
41
+ }
42
+ /**
43
+ * 构建绑定传输上下文(Token、安全选项与调度器)的远端请求函数。
44
+ *
45
+ * 单一事实源收敛所有 fetchRemoteXxx 端点的传输样板:
46
+ * 调用方仅需声明 path 与查询参数,鉴权头拼装、明文传输校验、
47
+ * insecure dispatcher 注入与 v2 -> v1 协议回退均在此统一处理。
48
+ */
49
+ export declare function createRemoteFetch(serverUrl: string, token?: string, options?: RemoteClientRequestOptions): (path: string, init?: RemoteFetchInit) => Promise<Response>;
50
+ /**
51
+ * 携带协议回退的远端请求单一入口:先打 /api/v2/ 路由,404 时改打 /api/v1/ 路由。
52
+ *
53
+ * v1 回退请求若网络失败则沿用 v2 响应,保留原始状态与错误体供上层透传。
54
+ */
55
+ export declare function fetchWithProtocolFallback(base: string, path: string, init: RequestInit & {
56
+ dispatcher?: any;
57
+ }): Promise<Response>;
58
+ /**
59
+ * 列出指定路由的全部协议版本候选 URL(按优先级排序,含原始路由自身)。
60
+ */
61
+ export declare function listProtocolRouteCandidates(base: string, path: string): string[];
@@ -0,0 +1,155 @@
1
+ import { isLoopbackHost } from "../utils/net.js";
2
+ import { normalizeServerUrl } from "./manager.js";
3
+ import { getInsecureDispatcher } from "../server/dispatcher.js";
4
+ /**
5
+ * 远端客户端传输层。
6
+ *
7
+ * 职责单一聚焦:鉴权头拼装、明文传输安全校验、insecure dispatcher 注入
8
+ * 与 v2 -> v1 协议回退,作为全部远端端点函数的传输样板单一事实源。
9
+ */
10
+ /**
11
+ * 校验在携带认证 Token 时传输层协议是否安全。
12
+ * 若请求携带认证 Token 且目标为非本地回环的明文 http://,默认报错拒绝。
13
+ * 可通过 allowInsecureHttp 选项、insecure 选项、环境变量或命令行参数豁免。
14
+ */
15
+ export function assertSecureTransport(serverUrl, token, allowInsecureHttpOrOptions, insecureArg) {
16
+ if (!token || !token.trim()) {
17
+ return;
18
+ }
19
+ let allowInsecureHttp = false;
20
+ let insecure = false;
21
+ if (typeof allowInsecureHttpOrOptions === "object" && allowInsecureHttpOrOptions !== null) {
22
+ allowInsecureHttp = Boolean(allowInsecureHttpOrOptions.allowInsecureHttp);
23
+ insecure = Boolean(allowInsecureHttpOrOptions.insecure);
24
+ }
25
+ else {
26
+ allowInsecureHttp = Boolean(allowInsecureHttpOrOptions);
27
+ insecure = Boolean(insecureArg);
28
+ }
29
+ const allow = allowInsecureHttp ||
30
+ insecure ||
31
+ (typeof process !== "undefined" &&
32
+ (process.env?.ACTIONDOCK_ALLOW_INSECURE_HTTP === "true" ||
33
+ process.env?.ACTIONDOCK_ALLOW_INSECURE_HTTP === "1" ||
34
+ process.env?.ACTIONDOCK_INSECURE === "true" ||
35
+ process.env?.ACTIONDOCK_INSECURE === "1"));
36
+ if (allow) {
37
+ return;
38
+ }
39
+ const base = normalizeServerUrl(serverUrl);
40
+ if (base.startsWith("http://")) {
41
+ try {
42
+ const parsed = new URL(base);
43
+ if (!isLoopbackHost(parsed.hostname)) {
44
+ const err = new Error(`Insecure HTTP connection with authentication token to non-loopback host '${parsed.hostname}' is prohibited. Use HTTPS or pass --allow-insecure-http to override.`);
45
+ err.code = "INSECURE_TRANSPORT";
46
+ throw err;
47
+ }
48
+ }
49
+ catch (e) {
50
+ if (e.code === "INSECURE_TRANSPORT") {
51
+ throw e;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ /**
57
+ * 构造携带鉴权信息的标准请求头。
58
+ */
59
+ export function buildHeaders(token) {
60
+ const headers = {
61
+ Accept: "application/json",
62
+ };
63
+ if (token && token.trim()) {
64
+ headers.Authorization = `Bearer ${token.trim()}`;
65
+ }
66
+ return headers;
67
+ }
68
+ /**
69
+ * 构建绑定传输上下文(Token、安全选项与调度器)的远端请求函数。
70
+ *
71
+ * 单一事实源收敛所有 fetchRemoteXxx 端点的传输样板:
72
+ * 调用方仅需声明 path 与查询参数,鉴权头拼装、明文传输校验、
73
+ * insecure dispatcher 注入与 v2 -> v1 协议回退均在此统一处理。
74
+ */
75
+ export function createRemoteFetch(serverUrl, token, options) {
76
+ assertSecureTransport(serverUrl, token, {
77
+ allowInsecureHttp: options?.allowInsecureHttp,
78
+ insecure: options?.insecure,
79
+ });
80
+ const base = normalizeServerUrl(serverUrl);
81
+ const headers = buildHeaders(token);
82
+ return async (path, init = {}) => {
83
+ const method = init.method || "GET";
84
+ const mergedHeaders = { ...headers };
85
+ if (init.body !== undefined || init.headers) {
86
+ for (const [k, v] of Object.entries(init.headers || {})) {
87
+ mergedHeaders[k] = v;
88
+ }
89
+ if (init.body !== undefined) {
90
+ mergedHeaders["Content-Type"] = mergedHeaders["Content-Type"] || "application/json";
91
+ }
92
+ }
93
+ const fetchInit = {
94
+ method,
95
+ headers: mergedHeaders,
96
+ body: init.body !== undefined ? JSON.stringify(init.body) : undefined,
97
+ signal: init.signal,
98
+ };
99
+ if (options?.dispatcher) {
100
+ fetchInit.dispatcher = options.dispatcher;
101
+ }
102
+ else if (options?.insecure) {
103
+ fetchInit.dispatcher = getInsecureDispatcher();
104
+ }
105
+ return fetchWithProtocolFallback(base, path, fetchInit);
106
+ };
107
+ }
108
+ /** v2 优先、v1 兼容回退的协议版本优先级列表。 */
109
+ const PROTOCOL_PREFERENCE = ["v2", "v1"];
110
+ /**
111
+ * 判定响应是否应当触发下一优先级协议重试。
112
+ * 仅 404(路由不存在)回退;其余状态(如 401、403、500)原样透传。
113
+ */
114
+ function shouldFallbackToNextProtocol(res) {
115
+ return res.status === 404;
116
+ }
117
+ /**
118
+ * 携带协议回退的远端请求单一入口:先打 /api/v2/ 路由,404 时改打 /api/v1/ 路由。
119
+ *
120
+ * v1 回退请求若网络失败则沿用 v2 响应,保留原始状态与错误体供上层透传。
121
+ */
122
+ export async function fetchWithProtocolFallback(base, path, init) {
123
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
124
+ const isVersioned = /^\/api\/v\d+\//.test(normalizedPath);
125
+ let res = await fetch(`${base}${normalizedPath}`, init);
126
+ if (!isVersioned || !shouldFallbackToNextProtocol(res)) {
127
+ return res;
128
+ }
129
+ const candidates = listProtocolRouteCandidates(base, normalizedPath);
130
+ // 首个候选即当前已返回 404 的路由,从次优先级继续尝试
131
+ for (let i = 1; i < candidates.length; i++) {
132
+ try {
133
+ const fallbackRes = await fetch(candidates[i], init);
134
+ if (!shouldFallbackToNextProtocol(fallbackRes)) {
135
+ return fallbackRes;
136
+ }
137
+ }
138
+ catch {
139
+ // 回退请求网络异常时保持既有 v2 响应,由上层统一处理
140
+ }
141
+ }
142
+ return res;
143
+ }
144
+ /**
145
+ * 列出指定路由的全部协议版本候选 URL(按优先级排序,含原始路由自身)。
146
+ */
147
+ export function listProtocolRouteCandidates(base, path) {
148
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
149
+ const versionMatch = normalizedPath.match(/^\/api\/(v\d+)\/(.*)$/);
150
+ if (!versionMatch) {
151
+ return [`${base}${normalizedPath}`];
152
+ }
153
+ const rest = versionMatch[2];
154
+ return PROTOCOL_PREFERENCE.map((version) => `${base}/api/${version}/${rest}`);
155
+ }
@@ -1,145 +1,26 @@
1
- import type { ExecutionResult, RunRecord } from "@actiondock/sdk";
2
- import type { RemoteHealthResult } from "./types.js";
3
1
  /**
4
- * 校验在携带认证 Token 时传输层协议是否安全。
5
- * 若请求携带认证 Token 且目标为非本地回环的明文 http://,默认报错拒绝。
6
- * 可通过 allowInsecureHttp 选项、insecure 选项、环境变量或命令行参数豁免。
7
- */
8
- export declare function assertSecureTransport(serverUrl: string, token?: string, allowInsecureHttpOrOptions?: boolean | {
9
- allowInsecureHttp?: boolean;
10
- insecure?: boolean;
11
- }, insecureArg?: boolean): void;
12
- /**
13
- * 远端请求通用控制选项。
14
- */
15
- export interface RemoteClientRequestOptions {
16
- /** 是否允许通过非回环明文 HTTP 发送认证 Token */
17
- allowInsecureHttp?: boolean;
18
- /** 是否跳过服务端 TLS 证书合法性校验 */
19
- insecure?: boolean;
20
- /** 自定义底层 HTTP 调度器(平台中立) */
21
- dispatcher?: unknown;
22
- }
23
- /**
24
- * 调用远端 ActionDock 服务端执行 Action 时的选项参数。
25
- */
26
- export interface RemoteExecuteOptions extends RemoteClientRequestOptions {
27
- /** 动态配置覆盖 */
28
- configOverrides?: Record<string, unknown>;
29
- /** 鉴权 Bearer Token */
30
- token?: string;
31
- /** 超时毫秒数 */
32
- timeoutMs?: number;
33
- /** 中断信号 */
34
- signal?: AbortSignal;
35
- /** 幂等请求去重标识 */
36
- requestId?: string;
37
- /** 是否异步触发(202 Accepted 立即返回 runId) */
38
- async?: boolean;
39
- }
40
- /**
41
- * 远端 Action 执行结果信封对象。
42
- */
43
- export type RemoteExecutionResult<T = unknown> = ExecutionResult<T> & {
44
- status?: string;
45
- };
46
- /**
47
- * 探测指定远端 ActionDock 服务的健康状态与网络延迟。
2
+ * 远端 Profile 客户端聚合入口。
3
+ *
4
+ * 历史上全部端点函数集中于单一 client.ts(约 950 行),现按域拆分为
5
+ * 单一职责模块,此处仅保留聚合 re-export,导入路径 ./client 与
6
+ * @actiondock/core 的公共导出面保持完全兼容。
48
7
  *
49
- * @param serverUrl 目标服务端地址
50
- * @param token 鉴权 Token(可选)
51
- * @param timeoutMs 探测超时时间(默认 5000ms)
52
- * @param options 传输与安全控制选项
8
+ * 模块划分:
9
+ * - client-transport:传输层(鉴权头、明文校验、协议回退)
10
+ * - client-query:共享请求与查询构造层
11
+ * - client-health:健康检查
12
+ * - client-actions:执行与 Action 查询
13
+ * - client-playbooks:Playbook 规程查询
14
+ * - client-runs:运行记录管理
15
+ * - client-state:状态存储管理
16
+ * - client-config:配置管理
53
17
  */
54
- export declare function checkRemoteHealth(serverUrl: string, token?: string, timeoutMs?: number, options?: RemoteClientRequestOptions): Promise<RemoteHealthResult>;
55
- export declare function executeRemoteAction<T = unknown>(serverUrl: string, actionId: string, input?: unknown, configOverridesOrOptions?: Record<string, unknown> | RemoteExecuteOptions, tokenArg?: string): Promise<RemoteExecutionResult<T>>;
56
- export declare function fetchRemoteRun(serverUrl: string, runId: string, token?: string, options?: RemoteClientRequestOptions): Promise<RunRecord>;
57
- export declare function cancelRemoteRun(serverUrl: string, runId: string, token?: string, reason?: string, options?: RemoteClientRequestOptions): Promise<{
58
- ok: boolean;
59
- runId: string;
60
- status: string;
61
- }>;
62
- export declare function fetchRemoteActions(serverUrl: string, token?: string, intent?: string, options?: RemoteClientRequestOptions): Promise<Array<{
63
- id: string;
64
- description: string;
65
- packageId?: string;
66
- }>>;
67
- export declare function fetchRemoteActionShow(serverUrl: string, actionId: string, token?: string, options?: RemoteClientRequestOptions): Promise<any>;
68
- export declare function fetchRemoteInfo(serverUrl: string, token?: string, options?: {
69
- intent?: string;
70
- package?: string;
71
- tree?: boolean;
72
- } & RemoteClientRequestOptions): Promise<any>;
73
- export declare function fetchRemoteDoctor(serverUrl: string, token?: string, targetPackage?: string, options?: RemoteClientRequestOptions): Promise<any>;
74
- export declare function fetchRemotePlaybooks(serverUrl: string, token?: string, options?: {
75
- intent?: string;
76
- package?: string;
77
- } & RemoteClientRequestOptions): Promise<Array<{
78
- id: string;
79
- description: string;
80
- actions: string[];
81
- packageId: string;
82
- filePath: string;
83
- }>>;
84
- export declare function fetchRemotePlaybookShow(playbookId: string, token?: string, options?: RemoteClientRequestOptions): Promise<any>;
85
- export declare function fetchRemotePlaybookShow(serverUrl: string, playbookId: string, token?: string, options?: RemoteClientRequestOptions): Promise<any>;
86
- export declare function fetchRemoteRuns(serverUrl: string, token?: string, options?: {
87
- status?: string;
88
- actionId?: string;
89
- packageId?: string;
90
- intent?: string;
91
- limit?: number;
92
- } & RemoteClientRequestOptions): Promise<{
93
- ok: boolean;
94
- total: number;
95
- items: RunRecord[];
96
- }>;
97
- export declare function clearRemoteRuns(serverUrl: string, token?: string, options?: {
98
- packageId?: string;
99
- actionId?: string;
100
- status?: string;
101
- } & RemoteClientRequestOptions): Promise<{
102
- ok: boolean;
103
- clearedCount: number;
104
- }>;
105
- export declare function fetchRemoteStateList(serverUrl: string, token?: string, options?: {
106
- package?: string;
107
- action?: string;
108
- namespace?: string;
109
- prefix?: string;
110
- } & RemoteClientRequestOptions): Promise<{
111
- ok: boolean;
112
- packageId: string;
113
- keys: string[];
114
- }>;
115
- export declare function getRemoteStateKey(serverUrl: string, key: string, token?: string, options?: {
116
- package?: string;
117
- action?: string;
118
- namespace?: string;
119
- } & RemoteClientRequestOptions): Promise<any>;
120
- export declare function setRemoteStateKey(serverUrl: string, key: string, value: unknown, token?: string, options?: {
121
- package?: string;
122
- action?: string;
123
- namespace?: string;
124
- ttl?: number;
125
- } & RemoteClientRequestOptions): Promise<any>;
126
- export declare function deleteRemoteStateKey(serverUrl: string, key: string, token?: string, options?: {
127
- package?: string;
128
- action?: string;
129
- namespace?: string;
130
- } & RemoteClientRequestOptions): Promise<any>;
131
- export declare function clearRemoteState(serverUrl: string, token?: string, options?: {
132
- package?: string;
133
- action?: string;
134
- namespace?: string;
135
- prefix?: string;
136
- all?: boolean;
137
- } & RemoteClientRequestOptions): Promise<{
138
- ok: boolean;
139
- packageId: string;
140
- clearedCount: number;
141
- }>;
142
- export declare function fetchRemoteConfig(serverUrl: string, token?: string, packageId?: string, options?: RemoteClientRequestOptions): Promise<any>;
143
- export declare function setRemoteConfig(serverUrl: string, key: string, value: unknown, token?: string, packageId?: string, options?: RemoteClientRequestOptions): Promise<any>;
144
- export declare function deleteRemoteConfig(serverUrl: string, key: string, token?: string, packageId?: string, options?: RemoteClientRequestOptions): Promise<any>;
145
- export declare function fetchRemoteConfigEnv(serverUrl: string, token?: string, packageId?: string, options?: RemoteClientRequestOptions): Promise<any>;
18
+ export { assertSecureTransport, createRemoteFetch, fetchWithProtocolFallback, listProtocolRouteCandidates, } from "./client-transport.js";
19
+ export type { RemoteClientRequestOptions, RemoteFetchInit, } from "./client-transport.js";
20
+ export { checkRemoteHealth } from "./client-health.js";
21
+ export { executeRemoteAction, fetchRemoteActionShow, fetchRemoteActions, fetchRemoteDoctor, fetchRemoteInfo, } from "./client-actions.js";
22
+ export type { RemoteExecuteOptions, RemoteExecutionResult } from "./client-actions.js";
23
+ export { fetchRemotePlaybookShow, fetchRemotePlaybooks } from "./client-playbooks.js";
24
+ export { cancelRemoteRun, clearRemoteRuns, fetchRemoteRun, fetchRemoteRuns, } from "./client-runs.js";
25
+ export { clearRemoteState, deleteRemoteStateKey, fetchRemoteStateList, getRemoteStateKey, setRemoteStateKey, } from "./client-state.js";
26
+ export { deleteRemoteConfig, fetchRemoteConfig, fetchRemoteConfigEnv, setRemoteConfig, } from "./client-config.js";