@actiondock/core 2.10.0 → 2.12.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.
- package/README.md +1 -2
- package/dist/catalog/action-catalog.js +3 -33
- package/dist/catalog/discovery.d.ts +0 -3
- package/dist/catalog/discovery.js +4 -4
- package/dist/catalog/graph.d.ts +0 -4
- package/dist/catalog/graph.js +8 -14
- package/dist/{profile/client-actions.d.ts → client/actions.d.ts} +1 -1
- package/dist/{profile/client-actions.js → client/actions.js} +2 -8
- package/dist/{profile/client-config.d.ts → client/config.d.ts} +1 -1
- package/dist/{profile/client-config.js → client/config.js} +1 -1
- package/dist/client/dispatcher.d.ts +4 -0
- package/dist/client/dispatcher.js +21 -0
- package/dist/client/health.d.ts +38 -0
- package/dist/{profile/client-health.js → client/health.js} +9 -6
- package/dist/client/index.d.ts +16 -0
- package/dist/client/index.js +20 -0
- package/dist/{profile/client-playbooks.d.ts → client/playbooks.d.ts} +1 -1
- package/dist/{profile/client-playbooks.js → client/playbooks.js} +1 -1
- package/dist/{profile/client-runs.d.ts → client/runs.d.ts} +4 -2
- package/dist/{profile/client-runs.js → client/runs.js} +7 -1
- package/dist/{profile/client-state.d.ts → client/state.d.ts} +1 -1
- package/dist/{profile/client-state.js → client/state.js} +1 -1
- package/dist/{profile/client-transport.d.ts → client/transport.d.ts} +29 -10
- package/dist/{profile/client-transport.js → client/transport.js} +125 -35
- package/dist/doctor/checks/index.d.ts +1 -1
- package/dist/doctor/checks/index.js +1 -1
- package/dist/doctor/checks/project.js +20 -88
- package/dist/doctor/checks/runtime.d.ts +0 -4
- package/dist/doctor/checks/runtime.js +0 -28
- package/dist/doctor/doctor.js +1 -2
- package/dist/errors.d.ts +53 -3
- package/dist/errors.js +53 -3
- package/dist/execution/service.d.ts +55 -37
- package/dist/execution/service.js +601 -212
- package/dist/execution/types.d.ts +24 -5
- package/dist/host/host.d.ts +42 -22
- package/dist/host/host.js +562 -149
- package/dist/host/routing.js +6 -6
- package/dist/host/types.d.ts +25 -13
- package/dist/index.d.ts +9 -4
- package/dist/index.js +5 -2
- package/dist/input/advice.d.ts +0 -44
- package/dist/input/advice.js +7 -141
- package/dist/input/flat-materializer.js +1 -1
- package/dist/input/flat-parser.js +1 -1
- package/dist/input/index.d.ts +0 -1
- package/dist/input/index.js +0 -1
- package/dist/input/input-resolver.js +1 -1
- package/dist/input/validation-mapper.d.ts +1 -1
- package/dist/ipc/diagnostic.d.ts +8 -21
- package/dist/ipc/diagnostic.js +24 -57
- package/dist/ipc/host.js +21 -7
- package/dist/ipc/service.d.ts +14 -0
- package/dist/ipc/service.js +132 -26
- package/dist/ipc/types.d.ts +0 -4
- package/dist/package/index.d.ts +4 -5
- package/dist/package/index.js +1 -2
- package/dist/package/runtime.d.ts +94 -23
- package/dist/package/runtime.js +628 -274
- package/dist/package/static-index.d.ts +3 -6
- package/dist/package/static-index.js +11 -40
- package/dist/package/types.d.ts +19 -4
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +2 -1
- package/dist/platform/loader-hook.d.ts +32 -0
- package/dist/platform/loader-hook.js +90 -0
- package/dist/{node → platform}/module-loader.d.ts +13 -0
- package/dist/{node → platform}/module-loader.js +51 -4
- package/dist/platform/node.d.ts +19 -8
- package/dist/platform/node.js +50 -20
- package/dist/platform/types.d.ts +7 -47
- package/dist/process/context-process.d.ts +3 -18
- package/dist/process/context-process.js +3 -44
- package/dist/process/control.d.ts +21 -0
- package/dist/process/control.js +34 -0
- package/dist/process/converters.d.ts +23 -0
- package/dist/process/converters.js +92 -0
- package/dist/process/cursor.js +2 -22
- package/dist/process/{diagnostics-sink.d.ts → diagnostics.d.ts} +0 -7
- package/dist/process/{diagnostics-sink.js → diagnostics.js} +6 -8
- package/dist/process/index.d.ts +1 -3
- package/dist/process/index.js +1 -3
- package/dist/process/input-dispatcher.d.ts +4 -13
- package/dist/process/input-dispatcher.js +48 -69
- package/dist/process/managed-record.d.ts +3 -31
- package/dist/process/metadata-store.d.ts +0 -41
- package/dist/process/metadata-store.js +2 -341
- package/dist/process/process-driver.js +2 -2
- package/dist/process/process-manager.d.ts +8 -50
- package/dist/process/process-manager.js +28 -417
- package/dist/process/quotas.d.ts +14 -0
- package/dist/process/quotas.js +29 -0
- package/dist/process/run-executor.js +0 -1
- package/dist/process/terminal-output-cache.d.ts +20 -34
- package/dist/process/terminal-output-cache.js +43 -64
- package/dist/profile/index.d.ts +1 -2
- package/dist/profile/index.js +1 -2
- package/dist/profile/manager.d.ts +2 -4
- package/dist/profile/manager.js +10 -40
- package/dist/profile/types.d.ts +1 -17
- package/dist/project/digest.d.ts +5 -1
- package/dist/project/digest.js +81 -219
- package/dist/project/index.d.ts +4 -5
- package/dist/project/index.js +4 -5
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +3 -3
- package/dist/project/loader.js +72 -50
- package/dist/project/lockfile.js +6 -5
- package/dist/project/manifest.js +5 -4
- package/dist/project/transactions.d.ts +4 -42
- package/dist/project/transactions.js +83 -138
- package/dist/project/types-generator.js +2 -1
- package/dist/project/types.d.ts +2 -0
- package/dist/registry/index.d.ts +0 -1
- package/dist/registry/index.js +0 -1
- package/dist/registry/lock.d.ts +2 -11
- package/dist/registry/lock.js +14 -183
- package/dist/registry/registry.d.ts +1 -6
- package/dist/registry/registry.js +5 -17
- package/dist/runtime/action-registry.d.ts +1 -5
- package/dist/runtime/action-registry.js +0 -12
- package/dist/runtime/context.js +2 -2
- package/dist/runtime/events.d.ts +11 -50
- package/dist/runtime/events.js +88 -368
- package/dist/runtime/index.d.ts +0 -4
- package/dist/runtime/index.js +0 -4
- package/dist/runtime/run-persistence.d.ts +2 -0
- package/dist/runtime/run-persistence.js +2 -1
- package/dist/runtime/standalone-commands.d.ts +18 -0
- package/dist/runtime/standalone-commands.js +466 -0
- package/dist/runtime/standalone-help.d.ts +20 -0
- package/dist/runtime/standalone-help.js +72 -0
- package/dist/runtime/standalone.d.ts +1 -44
- package/dist/runtime/standalone.js +32 -573
- package/dist/schema/validator.d.ts +2 -2
- package/dist/schema/validator.js +2 -9
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.js +0 -2
- package/dist/server/routes/actions.js +1 -1
- package/dist/server/routes/info.js +1 -1
- package/dist/server/routes/playbooks.js +1 -1
- package/dist/server/routes/runs.js +123 -16
- package/dist/server/routes/state.js +43 -18
- package/dist/server/security.d.ts +1 -1
- package/dist/server/security.js +2 -2
- package/dist/server/server.js +3 -7
- package/dist/service/factory.js +4 -3
- package/dist/service/index.d.ts +1 -1
- package/dist/service/index.js +1 -1
- package/dist/service/remote-errors.d.ts +1 -1
- package/dist/service/remote-errors.js +6 -6
- package/dist/service/remote-polling.d.ts +3 -0
- package/dist/service/remote-polling.js +10 -5
- package/dist/service/remote.d.ts +5 -1
- package/dist/service/remote.js +108 -17
- package/dist/service/sse-stream.js +2 -2
- package/dist/service/types.d.ts +22 -19
- package/dist/service/types.js +1 -24
- package/dist/storage/clock.d.ts +1 -1
- package/dist/storage/clock.js +1 -1
- package/dist/storage/data-dir-lock.d.ts +10 -22
- package/dist/storage/data-dir-lock.js +28 -56
- package/dist/storage/file-lock.d.ts +64 -0
- package/dist/storage/file-lock.js +447 -0
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +5 -4
- package/dist/storage/run-liveness.d.ts +48 -0
- package/dist/storage/run-liveness.js +44 -0
- package/dist/storage/sqlite-config.d.ts +16 -0
- package/dist/storage/sqlite-config.js +59 -0
- package/dist/storage/sqlite-driver.d.ts +3 -1
- package/dist/storage/sqlite-driver.js +14 -4
- package/dist/storage/sqlite-events.d.ts +13 -0
- package/dist/storage/sqlite-events.js +48 -0
- package/dist/storage/sqlite-runs.d.ts +107 -0
- package/dist/storage/sqlite-runs.js +622 -0
- package/dist/storage/sqlite-schema.d.ts +5 -0
- package/dist/storage/sqlite-schema.js +143 -0
- package/dist/storage/sqlite-state.d.ts +33 -0
- package/dist/storage/sqlite-state.js +270 -0
- package/dist/storage/sqlite.d.ts +30 -57
- package/dist/storage/sqlite.js +84 -741
- package/dist/storage/types.d.ts +35 -2
- package/dist/utils/index.d.ts +18 -14
- package/dist/utils/index.js +37 -29
- package/dist/utils/semver.d.ts +18 -0
- package/dist/utils/semver.js +19 -0
- package/dist/utils/warning.d.ts +1 -0
- package/dist/utils/warning.js +52 -0
- package/dist/{json/value-validator.d.ts → value-validator.d.ts} +9 -0
- package/dist/value-validator.js +330 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -12
- package/dist/execution/index.d.ts +0 -2
- package/dist/execution/index.js +0 -2
- package/dist/filter/index.d.ts +0 -1
- package/dist/filter/index.js +0 -1
- package/dist/graph/index.d.ts +0 -4
- package/dist/graph/index.js +0 -4
- package/dist/input/metadata.d.ts +0 -99
- package/dist/input/metadata.js +0 -99
- package/dist/invocation/index.d.ts +0 -2
- package/dist/invocation/index.js +0 -2
- package/dist/ipc/index.d.ts +0 -4
- package/dist/ipc/index.js +0 -4
- package/dist/json/index.d.ts +0 -1
- package/dist/json/index.js +0 -1
- package/dist/json/value-validator.js +0 -330
- package/dist/node/index.d.ts +0 -1
- package/dist/node/index.js +0 -1
- package/dist/platform/node-fs.d.ts +0 -37
- package/dist/platform/node-fs.js +0 -81
- package/dist/process/control-arbiter.d.ts +0 -108
- package/dist/process/control-arbiter.js +0 -250
- package/dist/process/process-executor.d.ts +0 -47
- package/dist/process/process-executor.js +0 -296
- package/dist/profile/client-health.d.ts +0 -14
- package/dist/profile/client-query.d.ts +0 -30
- package/dist/profile/client-query.js +0 -69
- package/dist/profile/client.d.ts +0 -26
- package/dist/profile/client.js +0 -31
- package/dist/project/closure.d.ts +0 -25
- package/dist/project/closure.js +0 -74
- package/dist/registry/store.d.ts +0 -42
- package/dist/registry/store.js +0 -43
- package/dist/runtime/clock.d.ts +0 -7
- package/dist/runtime/clock.js +0 -7
- package/dist/runtime/module-loader.d.ts +0 -2
- package/dist/runtime/module-loader.js +0 -1
- package/dist/runtime/process.d.ts +0 -8
- package/dist/runtime/process.js +0 -1
- package/dist/runtime/runner.d.ts +0 -234
- package/dist/runtime/runner.js +0 -609
- package/dist/schema/index.d.ts +0 -1
- package/dist/schema/index.js +0 -1
- package/dist/server/dispatcher.d.ts +0 -25
- package/dist/server/dispatcher.js +0 -54
- package/dist/service/local.d.ts +0 -27
- package/dist/service/local.js +0 -141
- package/dist/storage/driver.d.ts +0 -10
- package/dist/storage/driver.js +0 -10
- package/dist/storage/lazy.d.ts +0 -8
- package/dist/storage/lazy.js +0 -45
- package/dist/storage/lock-core.d.ts +0 -158
- package/dist/storage/lock-core.js +0 -872
- package/dist/utils/net.d.ts +0 -10
- package/dist/utils/net.js +0 -16
- package/dist/utils/process.d.ts +0 -10
- package/dist/utils/process.js +0 -21
- /package/dist/{filter → utils}/intent.d.ts +0 -0
- /package/dist/{filter → utils}/intent.js +0 -0
|
@@ -3,7 +3,7 @@ import { ActionDockError, RUN_PERSISTENCE_FAILED, RUN_REPOSITORY_UNAVAILABLE } f
|
|
|
3
3
|
* 构建运行初始记录(RunRecord 组装单一事实源)。
|
|
4
4
|
*/
|
|
5
5
|
export function buildInitialRunRecord(params, status, error) {
|
|
6
|
-
const { runId, rootRunId, parentRunId, ownerId, hostSessionId, packageInstanceId, generationId, targetPackageId, targetActionId, startedAt, input, runnerPackageId, runnerPackageInstanceId, runnerGenerationId, runnerHostSessionId, } = params;
|
|
6
|
+
const { runId, rootRunId, parentRunId, ownerId, hostSessionId, hostPid, packageInstanceId, generationId, targetPackageId, targetActionId, startedAt, input, runnerPackageId, runnerPackageInstanceId, runnerGenerationId, runnerHostSessionId, } = params;
|
|
7
7
|
const record = {
|
|
8
8
|
id: runId,
|
|
9
9
|
rootRunId,
|
|
@@ -14,6 +14,7 @@ export function buildInitialRunRecord(params, status, error) {
|
|
|
14
14
|
generationId: generationId || (runnerPackageId === targetPackageId ? runnerGenerationId : "1"),
|
|
15
15
|
ownerId: ownerId || "local",
|
|
16
16
|
hostSessionId: hostSessionId || runnerHostSessionId,
|
|
17
|
+
hostPid,
|
|
17
18
|
status,
|
|
18
19
|
error,
|
|
19
20
|
startedAt,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionDockService } from "../service/types.js";
|
|
2
|
+
import { type StandaloneDispatcherOptions } from "./standalone.js";
|
|
3
|
+
export interface CommandContext {
|
|
4
|
+
service: ActionDockService;
|
|
5
|
+
options: StandaloneDispatcherOptions;
|
|
6
|
+
writeOut: (msg: string) => void;
|
|
7
|
+
writeErr: (msg: string) => void;
|
|
8
|
+
emitError: (isJson: boolean, code: string, message: string, exitCode: number, options?: {
|
|
9
|
+
textMessage?: string;
|
|
10
|
+
details?: unknown;
|
|
11
|
+
hint?: string;
|
|
12
|
+
}) => number;
|
|
13
|
+
}
|
|
14
|
+
export declare function handleList(ctx: CommandContext, subArgs: string[]): Promise<number>;
|
|
15
|
+
export declare function handleDescribe(ctx: CommandContext, subArgs: string[]): Promise<number>;
|
|
16
|
+
export declare function handleRun(ctx: CommandContext, subArgs: string[], actionArgs: string[], signal?: AbortSignal): Promise<number>;
|
|
17
|
+
export declare function handleConfig(ctx: CommandContext, subArgs: string[]): Promise<number>;
|
|
18
|
+
export declare function handleState(ctx: CommandContext, subArgs: string[]): Promise<number>;
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { decodeStateKey } from "@actiondock/sdk";
|
|
2
|
+
import { filterWithFallbackInfo } from "../utils/intent.js";
|
|
3
|
+
import { resolveExecutionHint } from "../errors.js";
|
|
4
|
+
import { resolveActionInput, formatActionDetail, buildActionDescribePayload, mapInputValidationFailure, } from "../input/index.js";
|
|
5
|
+
import { validateActionInputValue } from "../value-validator.js";
|
|
6
|
+
import { parseDuration } from "../utils/index.js";
|
|
7
|
+
import { ExitCode } from "./standalone.js";
|
|
8
|
+
export async function handleList(ctx, subArgs) {
|
|
9
|
+
const isJson = subArgs.includes("--json");
|
|
10
|
+
const noFallback = subArgs.includes("--no-fallback");
|
|
11
|
+
let intent;
|
|
12
|
+
const positionalPatterns = [];
|
|
13
|
+
for (let i = 0; i < subArgs.length; i++) {
|
|
14
|
+
const arg = subArgs[i];
|
|
15
|
+
if (arg === "--intent" || arg === "-i") {
|
|
16
|
+
if (i + 1 < subArgs.length)
|
|
17
|
+
intent = subArgs[++i];
|
|
18
|
+
}
|
|
19
|
+
else if (arg.startsWith("--intent=")) {
|
|
20
|
+
intent = arg.slice(9);
|
|
21
|
+
}
|
|
22
|
+
else if (arg.startsWith("-i=")) {
|
|
23
|
+
intent = arg.slice(3);
|
|
24
|
+
}
|
|
25
|
+
else if (!arg.startsWith("-")) {
|
|
26
|
+
positionalPatterns.push(arg);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const effectiveIntent = intent || (positionalPatterns.length > 0 ? positionalPatterns.join("|") : undefined);
|
|
30
|
+
const actions = await ctx.service.discovery.listActions();
|
|
31
|
+
const list = actions.map((a) => ({
|
|
32
|
+
id: a.id,
|
|
33
|
+
description: a.description || "",
|
|
34
|
+
}));
|
|
35
|
+
const filterRes = filterWithFallbackInfo(list, effectiveIntent, [(a) => a.id, (a) => a.description], !noFallback);
|
|
36
|
+
const hints = [
|
|
37
|
+
"Tip: For composite or multi-step tasks, check 'ad playbook list' for standard operating procedures.",
|
|
38
|
+
];
|
|
39
|
+
if (isJson) {
|
|
40
|
+
ctx.writeOut(JSON.stringify({ items: filterRes.items, hints }, null, 2));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
let text = `Actions in ${ctx.options.packageId} (v${ctx.options.version}):\n\n`;
|
|
44
|
+
for (const a of filterRes.items) {
|
|
45
|
+
text += ` ${a.id.padEnd(28)} ${a.description}\n`;
|
|
46
|
+
}
|
|
47
|
+
ctx.writeOut(text.trimEnd());
|
|
48
|
+
}
|
|
49
|
+
return ExitCode.SUCCESS;
|
|
50
|
+
}
|
|
51
|
+
export async function handleDescribe(ctx, subArgs) {
|
|
52
|
+
const id = subArgs.find((a) => !a.startsWith("-"));
|
|
53
|
+
const isJson = subArgs.includes("--json");
|
|
54
|
+
if (!id) {
|
|
55
|
+
return ctx.emitError(isJson, "INVALID_ARGUMENT", "Action ID is required for describe", ExitCode.INVALID_ARGUMENT);
|
|
56
|
+
}
|
|
57
|
+
let action;
|
|
58
|
+
try {
|
|
59
|
+
action = await ctx.service.discovery.describeAction(id);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
const hint = "Tip: Run 'ad list' to discover available actions.";
|
|
63
|
+
return ctx.emitError(isJson, "INVALID_ARGUMENT", `Action '${id}' not found`, ExitCode.INVALID_ARGUMENT, {
|
|
64
|
+
textMessage: `Error: Action '${id}' not found\n${hint}`,
|
|
65
|
+
hint,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const payload = buildActionDescribePayload(action, {
|
|
69
|
+
packageId: ctx.options.packageId,
|
|
70
|
+
});
|
|
71
|
+
if (isJson) {
|
|
72
|
+
ctx.writeOut(JSON.stringify(payload, null, 2));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
ctx.writeOut(formatActionDetail(payload));
|
|
76
|
+
}
|
|
77
|
+
return ExitCode.SUCCESS;
|
|
78
|
+
}
|
|
79
|
+
export async function handleRun(ctx, subArgs, actionArgs, signal) {
|
|
80
|
+
const isJson = subArgs.includes("--json");
|
|
81
|
+
const id = subArgs.find((a) => !a.startsWith("-"));
|
|
82
|
+
if (!id) {
|
|
83
|
+
return ctx.emitError(isJson, "INVALID_ARGUMENT", "Error: Action ID is required for run", ExitCode.INVALID_ARGUMENT, { textMessage: "Error: Action ID is required for run" });
|
|
84
|
+
}
|
|
85
|
+
let inputStr;
|
|
86
|
+
let inputFile;
|
|
87
|
+
let timeoutMs;
|
|
88
|
+
const recognizedFlags = new Set(["--json", "--async"]);
|
|
89
|
+
for (let i = 0; i < subArgs.length; i++) {
|
|
90
|
+
const arg = subArgs[i];
|
|
91
|
+
if (arg === id || recognizedFlags.has(arg)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (arg === "--timeout" && i + 1 < subArgs.length) {
|
|
95
|
+
try {
|
|
96
|
+
timeoutMs = parseDuration(subArgs[++i]);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
return ctx.emitError(isJson, "INVALID_ARGUMENT", `Invalid timeout format: ${err?.message || err}`, ExitCode.INVALID_ARGUMENT);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (arg.startsWith("--timeout=")) {
|
|
103
|
+
try {
|
|
104
|
+
timeoutMs = parseDuration(arg.slice(10));
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
return ctx.emitError(isJson, "INVALID_ARGUMENT", `Invalid timeout format: ${err?.message || err}`, ExitCode.INVALID_ARGUMENT);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (arg === "--input" && i + 1 < subArgs.length) {
|
|
111
|
+
inputStr = subArgs[++i];
|
|
112
|
+
}
|
|
113
|
+
else if (arg.startsWith("--input=")) {
|
|
114
|
+
inputStr = arg.slice(8);
|
|
115
|
+
}
|
|
116
|
+
else if (arg === "-i" && i + 1 < subArgs.length) {
|
|
117
|
+
inputStr = subArgs[++i];
|
|
118
|
+
}
|
|
119
|
+
else if (arg.startsWith("-i=")) {
|
|
120
|
+
inputStr = arg.slice(3);
|
|
121
|
+
}
|
|
122
|
+
else if (arg === "--input-file" && i + 1 < subArgs.length) {
|
|
123
|
+
inputFile = subArgs[++i];
|
|
124
|
+
}
|
|
125
|
+
else if (arg.startsWith("--input-file=")) {
|
|
126
|
+
inputFile = arg.slice(13);
|
|
127
|
+
}
|
|
128
|
+
else if (arg === "-f" && i + 1 < subArgs.length) {
|
|
129
|
+
inputFile = subArgs[++i];
|
|
130
|
+
}
|
|
131
|
+
else if (arg.startsWith("-f=")) {
|
|
132
|
+
inputFile = arg.slice(3);
|
|
133
|
+
}
|
|
134
|
+
else if (arg.startsWith("-")) {
|
|
135
|
+
const hint = "Hint: Separate action inputs from CLI options using '--', e.g.: ad run <id> [options] -- <param>=<val> or <param>:=<json>.";
|
|
136
|
+
return ctx.emitError(isJson, "INVALID_ARGUMENT", `error: unknown option '${arg}'`, ExitCode.INVALID_ARGUMENT, {
|
|
137
|
+
textMessage: `error: unknown option '${arg}'\n${hint}`,
|
|
138
|
+
hint,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
let input;
|
|
143
|
+
try {
|
|
144
|
+
input = await resolveActionInput({
|
|
145
|
+
input: inputStr,
|
|
146
|
+
inputFile,
|
|
147
|
+
flatArgs: actionArgs.length > 0 ? actionArgs : undefined,
|
|
148
|
+
stdin: process.stdin,
|
|
149
|
+
});
|
|
150
|
+
const check = validateActionInputValue(input);
|
|
151
|
+
if (!check.valid) {
|
|
152
|
+
throw mapInputValidationFailure("cli-pre-target", check);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
return ctx.emitError(isJson, err?.code || "INVALID_ARGUMENT", err?.message || String(err), ExitCode.INVALID_ARGUMENT, {
|
|
157
|
+
details: err?.details,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const result = await ctx.service.execution.run(id, input, {
|
|
161
|
+
signal,
|
|
162
|
+
timeoutMs,
|
|
163
|
+
});
|
|
164
|
+
if (isJson) {
|
|
165
|
+
if (!result.ok) {
|
|
166
|
+
const errorObj = result.error;
|
|
167
|
+
const hint = resolveExecutionHint(id, errorObj);
|
|
168
|
+
const machineOutput = hint !== undefined ? { ...result, hint } : result;
|
|
169
|
+
ctx.writeOut(JSON.stringify(machineOutput, null, 2));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
ctx.writeOut(JSON.stringify(result, null, 2));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
if (result.ok) {
|
|
177
|
+
const data = result.data;
|
|
178
|
+
let rawText;
|
|
179
|
+
let metaInfo;
|
|
180
|
+
if (typeof data === "string") {
|
|
181
|
+
rawText = data;
|
|
182
|
+
}
|
|
183
|
+
else if (data !== null && typeof data === "object") {
|
|
184
|
+
if ("content" in data && data.content !== undefined) {
|
|
185
|
+
rawText =
|
|
186
|
+
typeof data.content === "object" && data.content !== null
|
|
187
|
+
? JSON.stringify(data.content, null, 2)
|
|
188
|
+
: String(data.content);
|
|
189
|
+
const { content, ...rest } = data;
|
|
190
|
+
if (Object.keys(rest).length > 0) {
|
|
191
|
+
metaInfo = rest;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if ("text" in data && typeof data.text === "string") {
|
|
195
|
+
rawText = data.text;
|
|
196
|
+
const { text, ...rest } = data;
|
|
197
|
+
if (Object.keys(rest).length > 0) {
|
|
198
|
+
metaInfo = rest;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if ("message" in data && typeof data.message === "string") {
|
|
202
|
+
rawText = data.message;
|
|
203
|
+
const { message, ...rest } = data;
|
|
204
|
+
if (Object.keys(rest).length > 0) {
|
|
205
|
+
metaInfo = rest;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
rawText = JSON.stringify(data, null, 2);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else if (data !== undefined) {
|
|
213
|
+
rawText = String(data);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
rawText = "";
|
|
217
|
+
}
|
|
218
|
+
if (metaInfo) {
|
|
219
|
+
const parts = [];
|
|
220
|
+
const title = metaInfo.path ? String(metaInfo.path) : id;
|
|
221
|
+
parts.push(title);
|
|
222
|
+
if (metaInfo.startLine !== undefined && metaInfo.endLine !== undefined) {
|
|
223
|
+
parts.push(`lines ${metaInfo.startLine}-${metaInfo.endLine}`);
|
|
224
|
+
}
|
|
225
|
+
else if (metaInfo.line !== undefined) {
|
|
226
|
+
parts.push(`line ${metaInfo.line}`);
|
|
227
|
+
}
|
|
228
|
+
if (metaInfo.hasMore !== undefined) {
|
|
229
|
+
parts.push(`hasMore: ${metaInfo.hasMore}`);
|
|
230
|
+
}
|
|
231
|
+
if (metaInfo.truncated) {
|
|
232
|
+
parts.push("truncated: true");
|
|
233
|
+
}
|
|
234
|
+
const handled = new Set(["path", "startLine", "endLine", "line", "hasMore", "truncated"]);
|
|
235
|
+
for (const [k, v] of Object.entries(metaInfo)) {
|
|
236
|
+
if (!handled.has(k) && v !== undefined) {
|
|
237
|
+
parts.push(`${k}: ${typeof v === "object" ? JSON.stringify(v) : v}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (parts.length > 0) {
|
|
241
|
+
ctx.writeErr(`[${parts.join(" | ")}]`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
ctx.writeOut(rawText);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
const errorObj = result.error;
|
|
248
|
+
ctx.writeErr(`Error [${errorObj.code}]: ${errorObj.message}`);
|
|
249
|
+
if (errorObj.details) {
|
|
250
|
+
ctx.writeErr(typeof errorObj.details === "string"
|
|
251
|
+
? errorObj.details
|
|
252
|
+
: JSON.stringify(errorObj.details, null, 2));
|
|
253
|
+
}
|
|
254
|
+
const hint = resolveExecutionHint(id, errorObj);
|
|
255
|
+
if (hint) {
|
|
256
|
+
ctx.writeErr(hint);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return result.ok ? ExitCode.SUCCESS : ExitCode.FAILURE;
|
|
261
|
+
}
|
|
262
|
+
function isServiceCapabilityError(err) {
|
|
263
|
+
const code = String(err?.code || "");
|
|
264
|
+
return (code === "CAPABILITY_UNAVAILABLE" ||
|
|
265
|
+
code === "TARGET_CAPABILITY_UNAVAILABLE");
|
|
266
|
+
}
|
|
267
|
+
export async function handleConfig(ctx, subArgs) {
|
|
268
|
+
const sub = subArgs[0] || "list";
|
|
269
|
+
if (!ctx.service.management) {
|
|
270
|
+
ctx.writeErr("Error: management port is not enabled on this service");
|
|
271
|
+
return ExitCode.FAILURE;
|
|
272
|
+
}
|
|
273
|
+
if (sub === "list") {
|
|
274
|
+
const views = await ctx.service.management.config.list(ctx.options.packageId);
|
|
275
|
+
const dict = {};
|
|
276
|
+
for (const v of views) {
|
|
277
|
+
if (v.configured && v.value !== undefined) {
|
|
278
|
+
dict[v.key] = v.value;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
ctx.writeOut(JSON.stringify(dict, null, 2));
|
|
282
|
+
return ExitCode.SUCCESS;
|
|
283
|
+
}
|
|
284
|
+
if (sub === "get") {
|
|
285
|
+
const key = subArgs[1];
|
|
286
|
+
if (!key) {
|
|
287
|
+
ctx.writeErr("Error: config key required");
|
|
288
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
const item = await ctx.service.management.config.get(ctx.options.packageId, key);
|
|
292
|
+
ctx.writeOut(item.configured ? JSON.stringify(item.value) : "undefined");
|
|
293
|
+
return ExitCode.SUCCESS;
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
if (isServiceCapabilityError(err)) {
|
|
297
|
+
ctx.writeOut("undefined");
|
|
298
|
+
return ExitCode.SUCCESS;
|
|
299
|
+
}
|
|
300
|
+
ctx.writeErr(`Error reading config '${key}': ${err?.message || String(err)}`);
|
|
301
|
+
return ExitCode.FAILURE;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (sub === "set") {
|
|
305
|
+
const key = subArgs[1];
|
|
306
|
+
const rawVal = subArgs[2];
|
|
307
|
+
if (!key || rawVal === undefined) {
|
|
308
|
+
ctx.writeErr("Error: key and value required");
|
|
309
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
310
|
+
}
|
|
311
|
+
let parsed = rawVal;
|
|
312
|
+
try {
|
|
313
|
+
parsed = JSON.parse(rawVal);
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
parsed = rawVal;
|
|
317
|
+
}
|
|
318
|
+
await ctx.service.management.config.set(ctx.options.packageId, key, parsed);
|
|
319
|
+
ctx.writeOut(`Config '${key}' updated`);
|
|
320
|
+
return ExitCode.SUCCESS;
|
|
321
|
+
}
|
|
322
|
+
if (sub === "delete") {
|
|
323
|
+
const key = subArgs[1];
|
|
324
|
+
if (!key) {
|
|
325
|
+
ctx.writeErr("Error: config key required");
|
|
326
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
327
|
+
}
|
|
328
|
+
await ctx.service.management.config.delete(ctx.options.packageId, key);
|
|
329
|
+
ctx.writeOut(`Config '${key}' deleted`);
|
|
330
|
+
return ExitCode.SUCCESS;
|
|
331
|
+
}
|
|
332
|
+
ctx.writeErr(`Unknown config subcommand: '${sub}'`);
|
|
333
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
334
|
+
}
|
|
335
|
+
function decodeStateKeyArg(key) {
|
|
336
|
+
try {
|
|
337
|
+
return decodeStateKey(key);
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return { namespace: "", key };
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
export async function handleState(ctx, subArgs) {
|
|
344
|
+
const sub = subArgs[0] || "list";
|
|
345
|
+
let namespace;
|
|
346
|
+
let isAll = false;
|
|
347
|
+
let isJson = false;
|
|
348
|
+
if (!ctx.service.management) {
|
|
349
|
+
ctx.writeErr("Error: management port is not enabled on this service");
|
|
350
|
+
return ExitCode.FAILURE;
|
|
351
|
+
}
|
|
352
|
+
for (let i = 1; i < subArgs.length; i++) {
|
|
353
|
+
if ((subArgs[i] === "-n" || subArgs[i] === "--namespace") && i + 1 < subArgs.length) {
|
|
354
|
+
namespace = subArgs[++i];
|
|
355
|
+
}
|
|
356
|
+
else if (subArgs[i].startsWith("--namespace=")) {
|
|
357
|
+
namespace = subArgs[i].slice(12);
|
|
358
|
+
}
|
|
359
|
+
else if (subArgs[i] === "-a" || subArgs[i] === "--all") {
|
|
360
|
+
isAll = true;
|
|
361
|
+
}
|
|
362
|
+
else if (subArgs[i] === "--json") {
|
|
363
|
+
isJson = true;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (sub === "list") {
|
|
367
|
+
const prefix = subArgs[1] && !subArgs[1].startsWith("-") ? subArgs[1] : "";
|
|
368
|
+
const keys = await ctx.service.management.state.list(ctx.options.packageId, "", {
|
|
369
|
+
namespace: (namespace !== undefined ? namespace : null),
|
|
370
|
+
prefix: prefix || undefined,
|
|
371
|
+
all: isAll,
|
|
372
|
+
});
|
|
373
|
+
ctx.writeOut(JSON.stringify(keys, null, 2));
|
|
374
|
+
return ExitCode.SUCCESS;
|
|
375
|
+
}
|
|
376
|
+
if (sub === "get") {
|
|
377
|
+
const key = subArgs[1] && !subArgs[1].startsWith("-") ? subArgs[1] : subArgs[2];
|
|
378
|
+
if (!key) {
|
|
379
|
+
ctx.writeErr("Error: state key required");
|
|
380
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
381
|
+
}
|
|
382
|
+
let ns = namespace;
|
|
383
|
+
let actualKey = key;
|
|
384
|
+
if (ns === undefined) {
|
|
385
|
+
const decoded = decodeStateKeyArg(key);
|
|
386
|
+
ns = decoded.namespace || undefined;
|
|
387
|
+
actualKey = decoded.key;
|
|
388
|
+
}
|
|
389
|
+
const val = await ctx.service.management.state.get(ctx.options.packageId, "", actualKey, { namespace: ns });
|
|
390
|
+
if (isJson) {
|
|
391
|
+
ctx.writeOut(JSON.stringify({ key, value: val }, null, 2));
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
ctx.writeOut(val !== undefined ? JSON.stringify(val) : "undefined");
|
|
395
|
+
}
|
|
396
|
+
return ExitCode.SUCCESS;
|
|
397
|
+
}
|
|
398
|
+
if (sub === "set") {
|
|
399
|
+
const key = subArgs[1];
|
|
400
|
+
const rawVal = subArgs[2];
|
|
401
|
+
if (!key || rawVal === undefined) {
|
|
402
|
+
ctx.writeErr("Error: key and value required");
|
|
403
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
404
|
+
}
|
|
405
|
+
let ns = namespace || "";
|
|
406
|
+
let actualKey = key;
|
|
407
|
+
if (namespace === undefined) {
|
|
408
|
+
const decoded = decodeStateKeyArg(key);
|
|
409
|
+
ns = decoded.namespace;
|
|
410
|
+
actualKey = decoded.key;
|
|
411
|
+
}
|
|
412
|
+
let parsed = rawVal;
|
|
413
|
+
try {
|
|
414
|
+
parsed = JSON.parse(rawVal);
|
|
415
|
+
}
|
|
416
|
+
catch {
|
|
417
|
+
parsed = rawVal;
|
|
418
|
+
}
|
|
419
|
+
let ttl;
|
|
420
|
+
for (let i = 3; i < subArgs.length; i++) {
|
|
421
|
+
if (subArgs[i] === "--ttl" && i + 1 < subArgs.length) {
|
|
422
|
+
ttl = parseInt(subArgs[++i], 10);
|
|
423
|
+
}
|
|
424
|
+
else if (subArgs[i].startsWith("--ttl=")) {
|
|
425
|
+
ttl = parseInt(subArgs[i].slice(6), 10);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
await ctx.service.management.state.set(ctx.options.packageId, "", actualKey, parsed, { namespace: ns, ttl });
|
|
429
|
+
const displayKey = ns ? `${ns}:${actualKey}` : actualKey;
|
|
430
|
+
ctx.writeOut(`State '${displayKey}' updated`);
|
|
431
|
+
return ExitCode.SUCCESS;
|
|
432
|
+
}
|
|
433
|
+
if (sub === "delete" || sub === "rm") {
|
|
434
|
+
const key = subArgs[1] && !subArgs[1].startsWith("-") ? subArgs[1] : subArgs[2];
|
|
435
|
+
if (!key) {
|
|
436
|
+
ctx.writeErr("Error: state key required");
|
|
437
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
438
|
+
}
|
|
439
|
+
let ns = namespace;
|
|
440
|
+
let actualKey = key;
|
|
441
|
+
if (ns === undefined) {
|
|
442
|
+
const decoded = decodeStateKeyArg(key);
|
|
443
|
+
ns = decoded.namespace || undefined;
|
|
444
|
+
actualKey = decoded.key;
|
|
445
|
+
}
|
|
446
|
+
const deleted = await ctx.service.management.state.delete(ctx.options.packageId, "", actualKey, { namespace: ns });
|
|
447
|
+
if (deleted) {
|
|
448
|
+
ctx.writeOut(`State '${key}' deleted`);
|
|
449
|
+
return ExitCode.SUCCESS;
|
|
450
|
+
}
|
|
451
|
+
ctx.writeErr(`Error: State key '${key}' not found`);
|
|
452
|
+
return ExitCode.FAILURE;
|
|
453
|
+
}
|
|
454
|
+
if (sub === "clear" || sub === "clean") {
|
|
455
|
+
const prefix = subArgs[1] && !subArgs[1].startsWith("-") ? subArgs[1] : "";
|
|
456
|
+
const count = await ctx.service.management.state.clear(ctx.options.packageId, "", {
|
|
457
|
+
namespace,
|
|
458
|
+
all: isAll,
|
|
459
|
+
prefix: prefix || undefined,
|
|
460
|
+
});
|
|
461
|
+
ctx.writeOut(`Cleared ${count} state entry(s)`);
|
|
462
|
+
return ExitCode.SUCCESS;
|
|
463
|
+
}
|
|
464
|
+
ctx.writeErr(`Unknown state subcommand: '${sub}'`);
|
|
465
|
+
return ExitCode.INVALID_ARGUMENT;
|
|
466
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ParsedArgs {
|
|
2
|
+
controlArgs: string[];
|
|
3
|
+
actionArgs: string[];
|
|
4
|
+
filteredArgs: string[];
|
|
5
|
+
dataDir?: string;
|
|
6
|
+
configOverrides: Record<string, unknown>;
|
|
7
|
+
command: string;
|
|
8
|
+
subArgs: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function parseStandaloneArgs(argv: string[]): ParsedArgs;
|
|
11
|
+
export declare function printHelp(writeOut: (msg: string) => void, options: {
|
|
12
|
+
packageId: string;
|
|
13
|
+
version: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}): void;
|
|
16
|
+
export declare function emitError(writeOut: (msg: string) => void, writeErr: (msg: string) => void, isJson: boolean, code: string, message: string, exitCode: number, options?: {
|
|
17
|
+
textMessage?: string;
|
|
18
|
+
details?: unknown;
|
|
19
|
+
hint?: string;
|
|
20
|
+
}): number;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export function parseStandaloneArgs(argv) {
|
|
2
|
+
const separator = argv.indexOf("--");
|
|
3
|
+
const controlArgs = separator >= 0 ? argv.slice(0, separator) : argv;
|
|
4
|
+
const actionArgs = separator >= 0 ? argv.slice(separator + 1) : [];
|
|
5
|
+
let dataDir;
|
|
6
|
+
const configOverrides = {};
|
|
7
|
+
const filteredArgs = [];
|
|
8
|
+
for (let i = 0; i < controlArgs.length; i++) {
|
|
9
|
+
const arg = controlArgs[i];
|
|
10
|
+
if (arg === "--data-dir" && i + 1 < controlArgs.length) {
|
|
11
|
+
dataDir = controlArgs[++i];
|
|
12
|
+
}
|
|
13
|
+
else if (arg.startsWith("--data-dir=")) {
|
|
14
|
+
dataDir = arg.slice(11);
|
|
15
|
+
}
|
|
16
|
+
else if (arg === "--config" && i + 1 < controlArgs.length) {
|
|
17
|
+
const pair = controlArgs[++i];
|
|
18
|
+
const [k, ...v] = pair.split("=");
|
|
19
|
+
if (k)
|
|
20
|
+
configOverrides[k] = v.join("=");
|
|
21
|
+
}
|
|
22
|
+
else if (arg.startsWith("--config=")) {
|
|
23
|
+
const pair = arg.slice(9);
|
|
24
|
+
const [k, ...v] = pair.split("=");
|
|
25
|
+
if (k)
|
|
26
|
+
configOverrides[k] = v.join("=");
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
filteredArgs.push(arg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const command = filteredArgs[0] || "help";
|
|
33
|
+
const subArgs = filteredArgs.slice(1);
|
|
34
|
+
return { controlArgs, actionArgs, filteredArgs, dataDir, configOverrides, command, subArgs };
|
|
35
|
+
}
|
|
36
|
+
export function printHelp(writeOut, options) {
|
|
37
|
+
writeOut(`${options.packageId} (v${options.version})`);
|
|
38
|
+
if (options.description)
|
|
39
|
+
writeOut(`${options.description}\n`);
|
|
40
|
+
writeOut("Usage:");
|
|
41
|
+
writeOut(" <cmd> list [--json] List available actions");
|
|
42
|
+
writeOut(" <cmd> describe <id> [--json] Show action details and schemas");
|
|
43
|
+
writeOut(" <cmd> run <id> [--input '<json>'] Execute action (raw text output by default)");
|
|
44
|
+
writeOut(" <cmd> run <id> [--json] Output standard execution result in JSON format");
|
|
45
|
+
writeOut(" <cmd> config list/get/set/delete Manage package configuration");
|
|
46
|
+
writeOut(" <cmd> state list/get/set/delete Manage shared state store");
|
|
47
|
+
writeOut("\nGlobal options:");
|
|
48
|
+
writeOut(" --data-dir <path> Custom runtime database directory");
|
|
49
|
+
writeOut(" --config <KEY=val> Temporary config override");
|
|
50
|
+
}
|
|
51
|
+
export function emitError(writeOut, writeErr, isJson, code, message, exitCode, options) {
|
|
52
|
+
if (isJson) {
|
|
53
|
+
const details = options?.details;
|
|
54
|
+
const hint = options?.hint ??
|
|
55
|
+
(details && typeof details === "object" && typeof details.hint === "string"
|
|
56
|
+
? details.hint
|
|
57
|
+
: undefined);
|
|
58
|
+
writeOut(JSON.stringify({
|
|
59
|
+
ok: false,
|
|
60
|
+
error: {
|
|
61
|
+
code,
|
|
62
|
+
message,
|
|
63
|
+
...(details !== undefined ? { details } : {}),
|
|
64
|
+
},
|
|
65
|
+
...(hint !== undefined ? { hint } : {}),
|
|
66
|
+
}, null, 2));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
writeErr(options?.textMessage ?? `Error: ${message}`);
|
|
70
|
+
}
|
|
71
|
+
return exitCode;
|
|
72
|
+
}
|
|
@@ -65,22 +65,9 @@ export declare class StandaloneDispatcher {
|
|
|
65
65
|
constructor(options: StandaloneDispatcherOptions);
|
|
66
66
|
private writeOut;
|
|
67
67
|
private writeErr;
|
|
68
|
-
/**
|
|
69
|
-
* 统一错误输出辅助方法。
|
|
70
|
-
*
|
|
71
|
-
* JSON 模式向 stdout 输出两空格缩进的标准错误结构;
|
|
72
|
-
* 纯文本模式向 stderr 输出单行错误消息(默认携带 Error: 前缀)。
|
|
73
|
-
* 消息文本与退出码由调用方逐字给定,输出字节严格保持不变。
|
|
74
|
-
*
|
|
75
|
-
* @param isJson 是否处于 JSON 输出模式
|
|
76
|
-
* @param code 错误码
|
|
77
|
-
* @param message JSON 模式错误消息(兼作纯文本默认消息主体)
|
|
78
|
-
* @param exitCode 调用方应返回的退出状态码
|
|
79
|
-
* @param options 可选项:textMessage 覆盖纯文本消息全文;details 为 JSON 模式可选结构化详情
|
|
80
|
-
* @returns 透传 exitCode 供调用方直接返回
|
|
81
|
-
*/
|
|
82
68
|
private emitError;
|
|
83
69
|
private createLocalService;
|
|
70
|
+
private printHelp;
|
|
84
71
|
/**
|
|
85
72
|
* 解析命令行参数并分发执行对应子命令。
|
|
86
73
|
*
|
|
@@ -89,37 +76,7 @@ export declare class StandaloneDispatcher {
|
|
|
89
76
|
* @returns 退出状态码(0: 成功, 1: 失败, 2: 参数错误, 130: 中断)
|
|
90
77
|
*/
|
|
91
78
|
dispatch(argv: string[], control?: InvocationControl): Promise<number>;
|
|
92
|
-
private handleList;
|
|
93
|
-
private handleDescribe;
|
|
94
|
-
private handleRun;
|
|
95
|
-
private handleConfig;
|
|
96
|
-
private handleState;
|
|
97
|
-
/**
|
|
98
|
-
* 判定配置读取异常是否为服务能力缺失(键未配置语义)而非内部故障。
|
|
99
|
-
*/
|
|
100
|
-
private isServiceCapabilityError;
|
|
101
|
-
/**
|
|
102
|
-
* 解析携带命名空间前缀的状态键参数:委托 sdk 单一事实源 decodeStateKey。
|
|
103
|
-
*
|
|
104
|
-
* 解析失败(如存在多个未转义冒号的歧义键)时按纯键处理,交由存储层兜底。
|
|
105
|
-
*/
|
|
106
|
-
private decodeStateKeyArg;
|
|
107
|
-
private printHelp;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* 独立二进制可执行文件运行时(兼容门面包装)。
|
|
111
|
-
*/
|
|
112
|
-
export interface StandaloneRuntimeOptions extends StandaloneDispatcherOptions {
|
|
113
|
-
}
|
|
114
|
-
export declare class StandaloneRuntime {
|
|
115
|
-
private dispatcher;
|
|
116
|
-
constructor(options: StandaloneRuntimeOptions);
|
|
117
|
-
run(argv: string[]): Promise<void>;
|
|
118
79
|
}
|
|
119
|
-
/**
|
|
120
|
-
* 工厂函数:创建独立运行时实例。
|
|
121
|
-
*/
|
|
122
|
-
export declare function createStandaloneRuntime(options: StandaloneRuntimeOptions): StandaloneRuntime;
|
|
123
80
|
/**
|
|
124
81
|
* 独立二进制进程入口适配器。
|
|
125
82
|
* 仅在命令行可执行入口调用,负责全局 SIGINT 监听与退出状态码写入。
|