yuanflow-cli 0.1.0 → 0.1.2
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/LICENSE +1 -1
- package/README.md +34 -50
- package/bin/yuanflow-cli.js +26 -0
- package/bin/yuanflow-skill.cjs +334 -0
- package/generated/registry.json +24641 -0
- package/lib/skill-installer/agents.cjs +203 -0
- package/lib/skill-installer/discover-skills.cjs +79 -0
- package/lib/skill-installer/installer.cjs +300 -0
- package/lib/skill-installer/publish.cjs +53 -0
- package/lib/skill-installer/repo-source.cjs +162 -0
- package/package.json +57 -6
- package/scripts/generate-registry.js +174 -0
- package/skills/yuanflow-skill/SKILL.md +60 -0
- package/skills/yuanflow-skill/yuanflow-cli/SKILL.md +207 -0
- package/src/agent-protocol.js +169 -0
- package/src/cli.js +382 -0
- package/src/config.js +31 -0
- package/src/registry.js +45 -0
- package/src/request.js +97 -0
- package/src/shortcuts.js +346 -0
- package/cli.js +0 -3
- package/src/ycloud/cli.js +0 -29
- package/src/ycloud/commands/analysis.js +0 -82
- package/src/ycloud/commands/auth.js +0 -191
- package/src/ycloud/commands/commands.js +0 -262
- package/src/ycloud/commands/compliance.js +0 -146
- package/src/ycloud/commands/config.js +0 -103
- package/src/ycloud/commands/health.js +0 -35
- package/src/ycloud/commands/index.js +0 -381
- package/src/ycloud/commands/kb.js +0 -82
- package/src/ycloud/commands/schema.js +0 -229
- package/src/ycloud/commands/shared.js +0 -30
- package/src/ycloud/commands/tool-registry.js +0 -209
- package/src/ycloud/commands/tool-runner.js +0 -226
- package/src/ycloud/commands/tool.js +0 -178
- package/src/ycloud/commands/version.js +0 -84
- package/src/ycloud/core/config.js +0 -78
- package/src/ycloud/core/http.js +0 -133
- package/src/ycloud/core/token.js +0 -30
- package/src/ycloud/resources/.gitkeep +0 -1
- package/src/ycloud/resources/tool_catalog_full.json +0 -1
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { apiGet, apiPost } from "../core/http.js";
|
|
2
|
-
import { getToken } from "../core/token.js";
|
|
3
|
-
import { getGlobalFlagsHelp, parseJsonString } from "./shared.js";
|
|
4
|
-
|
|
5
|
-
export function getToolHelp(subcommand) {
|
|
6
|
-
if (subcommand === "catalog") {
|
|
7
|
-
return `List available tool catalog
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
ycloud tool catalog [flags]
|
|
11
|
-
|
|
12
|
-
Optional Flags:
|
|
13
|
-
none
|
|
14
|
-
|
|
15
|
-
${getGlobalFlagsHelp()}
|
|
16
|
-
|
|
17
|
-
Examples:
|
|
18
|
-
ycloud tool catalog --output json
|
|
19
|
-
|
|
20
|
-
Read on success:
|
|
21
|
-
data.tools
|
|
22
|
-
|
|
23
|
-
Read on error:
|
|
24
|
-
error.code
|
|
25
|
-
error.message
|
|
26
|
-
error.retryable`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (subcommand === "execute") {
|
|
30
|
-
return `Execute a server-side tool
|
|
31
|
-
|
|
32
|
-
Usage:
|
|
33
|
-
ycloud tool execute [flags]
|
|
34
|
-
|
|
35
|
-
Required Flags:
|
|
36
|
-
--tool-id string tool id to execute
|
|
37
|
-
|
|
38
|
-
Optional Flags:
|
|
39
|
-
--params string JSON object string
|
|
40
|
-
--params-file string local JSON file path
|
|
41
|
-
--session-id string optional session id
|
|
42
|
-
--idempotency-key string request idempotency key
|
|
43
|
-
|
|
44
|
-
${getGlobalFlagsHelp()}
|
|
45
|
-
|
|
46
|
-
Examples:
|
|
47
|
-
ycloud tool execute --tool-id copywriting_generate --params "{\"topic\":\"短视频文案\"}" --output json
|
|
48
|
-
|
|
49
|
-
Read on success:
|
|
50
|
-
data
|
|
51
|
-
meta.tool_id
|
|
52
|
-
|
|
53
|
-
Read on error:
|
|
54
|
-
error.code
|
|
55
|
-
error.message
|
|
56
|
-
error.retryable`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return `Tool commands
|
|
60
|
-
|
|
61
|
-
Usage:
|
|
62
|
-
ycloud tool <catalog|execute> [flags]`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function requireToken(context) {
|
|
66
|
-
return getToken().then((token) => {
|
|
67
|
-
if (!token) {
|
|
68
|
-
return context.fail(
|
|
69
|
-
context.commandName,
|
|
70
|
-
"TOKEN_MISSING",
|
|
71
|
-
"缺少 YUANCHUANG_API_TOKEN",
|
|
72
|
-
3,
|
|
73
|
-
false,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
return token;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function executeToolCatalog(context) {
|
|
81
|
-
const token = await requireToken(context);
|
|
82
|
-
if (typeof token !== "string") {
|
|
83
|
-
return token;
|
|
84
|
-
}
|
|
85
|
-
const data = await apiGet("/v1/tools/catalog", {
|
|
86
|
-
token,
|
|
87
|
-
traceId: context.globalOptions.traceId,
|
|
88
|
-
timeout: context.globalOptions.timeout,
|
|
89
|
-
baseUrl: context.globalOptions.baseUrl,
|
|
90
|
-
});
|
|
91
|
-
return context.ok("tool catalog", data);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export async function executeToolExecute(context, tokens, allowedToolIds = new Set()) {
|
|
95
|
-
const options = context.parseCommandFlags(tokens);
|
|
96
|
-
if (!options["tool-id"]) {
|
|
97
|
-
return context.fail(
|
|
98
|
-
"tool execute",
|
|
99
|
-
"BAD_ARGUMENT",
|
|
100
|
-
"缺少必填参数 --tool-id",
|
|
101
|
-
2,
|
|
102
|
-
false,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
if (options.params && options["params-file"]) {
|
|
106
|
-
return context.fail(
|
|
107
|
-
"tool execute",
|
|
108
|
-
"BAD_ARGUMENT",
|
|
109
|
-
"--params 和 --params-file 只能二选一",
|
|
110
|
-
2,
|
|
111
|
-
false,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
if (allowedToolIds.size > 0 && !allowedToolIds.has(options["tool-id"])) {
|
|
115
|
-
return context.fail(
|
|
116
|
-
"tool execute",
|
|
117
|
-
"BAD_ARGUMENT",
|
|
118
|
-
`tool_id 未注册到当前 CLI 暴露面: ${options["tool-id"]}`,
|
|
119
|
-
2,
|
|
120
|
-
false,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const token = await requireToken(context);
|
|
125
|
-
if (typeof token !== "string") {
|
|
126
|
-
return token;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
let params = undefined;
|
|
130
|
-
if (options.params) {
|
|
131
|
-
try {
|
|
132
|
-
params = parseJsonString(options.params);
|
|
133
|
-
} catch {
|
|
134
|
-
return context.fail(
|
|
135
|
-
"tool execute",
|
|
136
|
-
"BAD_ARGUMENT",
|
|
137
|
-
"--params 必须是合法 JSON",
|
|
138
|
-
2,
|
|
139
|
-
false,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (options["params-file"]) {
|
|
145
|
-
const { readFile } = await import("node:fs/promises");
|
|
146
|
-
try {
|
|
147
|
-
params = JSON.parse(
|
|
148
|
-
await readFile(options["params-file"], { encoding: "utf-8" }),
|
|
149
|
-
);
|
|
150
|
-
} catch {
|
|
151
|
-
return context.fail(
|
|
152
|
-
"tool execute",
|
|
153
|
-
"BAD_ARGUMENT",
|
|
154
|
-
"--params-file 必须是合法 JSON 文件",
|
|
155
|
-
2,
|
|
156
|
-
false,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const data = await apiPost("/v1/tools/execute", {
|
|
162
|
-
token,
|
|
163
|
-
traceId: context.globalOptions.traceId,
|
|
164
|
-
timeout: context.globalOptions.timeout,
|
|
165
|
-
baseUrl: context.globalOptions.baseUrl,
|
|
166
|
-
body: {
|
|
167
|
-
tool_id: options["tool-id"],
|
|
168
|
-
params,
|
|
169
|
-
session_id: options["session-id"],
|
|
170
|
-
trace_id: context.globalOptions.traceId,
|
|
171
|
-
idempotency_key: options["idempotency-key"],
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
return context.ok("tool execute", data, {
|
|
176
|
-
tool_id: options["tool-id"],
|
|
177
|
-
});
|
|
178
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import pkg from "../../../package.json" with { type: "json" };
|
|
2
|
-
import { apiGet } from "../core/http.js";
|
|
3
|
-
import { getToken } from "../core/token.js";
|
|
4
|
-
import { getGlobalFlagsHelp } from "./shared.js";
|
|
5
|
-
|
|
6
|
-
export function getVersionHelp() {
|
|
7
|
-
return `Check remote version update information
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
ycloud version check [flags]
|
|
11
|
-
|
|
12
|
-
Optional Flags:
|
|
13
|
-
--app-id string application id, default ai-solovision
|
|
14
|
-
--platform string target platform, default desktop
|
|
15
|
-
--channel string release channel, default stable
|
|
16
|
-
--current-version string current CLI version, default local package version
|
|
17
|
-
--current-build int optional current build number
|
|
18
|
-
|
|
19
|
-
${getGlobalFlagsHelp()}
|
|
20
|
-
|
|
21
|
-
Examples:
|
|
22
|
-
ycloud version check --output json
|
|
23
|
-
|
|
24
|
-
Read on success:
|
|
25
|
-
data.latest_version
|
|
26
|
-
data.update_available
|
|
27
|
-
data.update_type
|
|
28
|
-
|
|
29
|
-
Read on error:
|
|
30
|
-
error.code
|
|
31
|
-
error.message`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function executeVersionCheck(context, tokens) {
|
|
35
|
-
const token = await getToken();
|
|
36
|
-
if (!token) {
|
|
37
|
-
return context.fail(
|
|
38
|
-
"version check",
|
|
39
|
-
"TOKEN_MISSING",
|
|
40
|
-
"缺少 YUANCHUANG_API_TOKEN",
|
|
41
|
-
3,
|
|
42
|
-
false,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const options = context.parseCommandFlags(tokens);
|
|
47
|
-
const appId = options["app-id"] || "ai-solovision";
|
|
48
|
-
const platform = options.platform || "desktop";
|
|
49
|
-
const channel = options.channel || "stable";
|
|
50
|
-
const currentVersion = options["current-version"] || pkg.version;
|
|
51
|
-
const query = new URLSearchParams({
|
|
52
|
-
app_id: appId,
|
|
53
|
-
platform,
|
|
54
|
-
channel,
|
|
55
|
-
current_version: currentVersion,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (options["current-build"] !== undefined) {
|
|
59
|
-
query.set("current_build", String(options["current-build"]));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const data = await apiGet(`/v1/version/check?${query.toString()}`, {
|
|
63
|
-
token,
|
|
64
|
-
traceId: context.globalOptions.traceId,
|
|
65
|
-
timeout: context.globalOptions.timeout,
|
|
66
|
-
baseUrl: context.globalOptions.baseUrl,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const remoteData = data?.data || data || {};
|
|
70
|
-
return context.ok("version check", {
|
|
71
|
-
app_id: appId,
|
|
72
|
-
platform,
|
|
73
|
-
channel,
|
|
74
|
-
current_version: currentVersion,
|
|
75
|
-
current_build: remoteData.current_build ?? null,
|
|
76
|
-
latest_version: remoteData.latest_version ?? null,
|
|
77
|
-
latest_build: remoteData.latest_build ?? null,
|
|
78
|
-
update_available: Boolean(remoteData.update_available),
|
|
79
|
-
update_type: remoteData.update_type || "none",
|
|
80
|
-
checked_at: remoteData.checked_at || null,
|
|
81
|
-
release: remoteData.release || null,
|
|
82
|
-
raw: data,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
const CONFIG_DIR_NAME = ".yuanflow";
|
|
6
|
-
const CONFIG_FILE_NAME = "config.json";
|
|
7
|
-
|
|
8
|
-
function getUserHomeDir() {
|
|
9
|
-
return process.env.USERPROFILE || process.env.HOME || homedir();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function getConfigDir() {
|
|
13
|
-
return join(getUserHomeDir(), CONFIG_DIR_NAME);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getConfigPath() {
|
|
17
|
-
return join(getConfigDir(), CONFIG_FILE_NAME);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function readConfig() {
|
|
21
|
-
try {
|
|
22
|
-
const content = await readFile(getConfigPath(), "utf8");
|
|
23
|
-
return JSON.parse(content);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error?.code === "ENOENT") {
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function writeConfig(config) {
|
|
33
|
-
await mkdir(getConfigDir(), { recursive: true });
|
|
34
|
-
await writeFile(
|
|
35
|
-
getConfigPath(),
|
|
36
|
-
`${JSON.stringify(config, null, 2)}\n`,
|
|
37
|
-
"utf8",
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function updateConfig(partial) {
|
|
42
|
-
const current = await readConfig();
|
|
43
|
-
const next = {
|
|
44
|
-
...current,
|
|
45
|
-
...partial,
|
|
46
|
-
};
|
|
47
|
-
await writeConfig(next);
|
|
48
|
-
return next;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function clearConfigKey(key) {
|
|
52
|
-
const current = await readConfig();
|
|
53
|
-
if (!(key in current)) {
|
|
54
|
-
return current;
|
|
55
|
-
}
|
|
56
|
-
const next = { ...current };
|
|
57
|
-
delete next[key];
|
|
58
|
-
if (Object.keys(next).length === 0) {
|
|
59
|
-
try {
|
|
60
|
-
await rm(getConfigPath(), { force: true });
|
|
61
|
-
} catch {
|
|
62
|
-
return {};
|
|
63
|
-
}
|
|
64
|
-
return {};
|
|
65
|
-
}
|
|
66
|
-
await writeConfig(next);
|
|
67
|
-
return next;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function maskToken(token) {
|
|
71
|
-
if (!token) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
if (token.length <= 8) {
|
|
75
|
-
return `${token.slice(0, 2)}****`;
|
|
76
|
-
}
|
|
77
|
-
return `${token.slice(0, 7)}****${token.slice(-4)}`;
|
|
78
|
-
}
|
package/src/ycloud/core/http.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const DEFAULT_BASE_URL = "https://api.yuanchuangai.com";
|
|
2
|
-
const DEFAULT_OPENAPI_URL = "https://api.yuanchuangai.com/openapi.json";
|
|
3
|
-
|
|
4
|
-
function normalizeBaseUrl(baseUrl) {
|
|
5
|
-
return (baseUrl || process.env.YUANCHUANG_API_BASE_URL || DEFAULT_BASE_URL)
|
|
6
|
-
.trim()
|
|
7
|
-
.replace(/\/+$/, "");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function buildHeaders(token, traceId) {
|
|
11
|
-
const headers = {
|
|
12
|
-
Accept: "application/json",
|
|
13
|
-
};
|
|
14
|
-
if (token) {
|
|
15
|
-
headers.Authorization = `Bearer ${token}`;
|
|
16
|
-
}
|
|
17
|
-
if (traceId) {
|
|
18
|
-
headers["X-Trace-Id"] = traceId;
|
|
19
|
-
}
|
|
20
|
-
return headers;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function createTimeoutSignal(timeout) {
|
|
24
|
-
const timeoutMs = timeout ? Number.parseInt(String(timeout), 10) : undefined;
|
|
25
|
-
if (!timeoutMs || Number.isNaN(timeoutMs) || timeoutMs <= 0) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
return AbortSignal.timeout(timeoutMs);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function parseResponseBody(text) {
|
|
32
|
-
if (!text) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(text);
|
|
37
|
-
} catch {
|
|
38
|
-
return text;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function mapStatusToCode(status) {
|
|
43
|
-
if (status === 401 || status === 403) {
|
|
44
|
-
return { code: "AUTH_INVALID", exitCode: 3, retryable: false };
|
|
45
|
-
}
|
|
46
|
-
if (status === 400 || status === 404 || status === 422) {
|
|
47
|
-
return { code: "BAD_ARGUMENT", exitCode: 2, retryable: false };
|
|
48
|
-
}
|
|
49
|
-
if (status >= 500) {
|
|
50
|
-
return { code: "UPSTREAM_ERROR", exitCode: 4, retryable: true };
|
|
51
|
-
}
|
|
52
|
-
return { code: "UPSTREAM_ERROR", exitCode: 4, retryable: false };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function request(method, path, options = {}) {
|
|
56
|
-
const headers = buildHeaders(options.token, options.traceId);
|
|
57
|
-
const init = {
|
|
58
|
-
method,
|
|
59
|
-
headers,
|
|
60
|
-
signal: createTimeoutSignal(options.timeout),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (options.body !== undefined) {
|
|
64
|
-
headers["Content-Type"] = "application/json";
|
|
65
|
-
init.body = JSON.stringify(options.body);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const response = await fetch(`${normalizeBaseUrl(options.baseUrl)}${path}`, init);
|
|
70
|
-
const text = await response.text();
|
|
71
|
-
const payload = parseResponseBody(text);
|
|
72
|
-
|
|
73
|
-
if (!response.ok) {
|
|
74
|
-
const mapped = mapStatusToCode(response.status);
|
|
75
|
-
const message =
|
|
76
|
-
payload?.detail ||
|
|
77
|
-
payload?.message ||
|
|
78
|
-
payload?.error?.message ||
|
|
79
|
-
`HTTP ${response.status}`;
|
|
80
|
-
const error = new Error(message);
|
|
81
|
-
error.code = mapped.code;
|
|
82
|
-
error.exitCode = mapped.exitCode;
|
|
83
|
-
error.retryable = mapped.retryable;
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return payload;
|
|
88
|
-
} catch (error) {
|
|
89
|
-
if (error.name === "AbortError") {
|
|
90
|
-
const timeoutError = new Error("请求超时");
|
|
91
|
-
timeoutError.code = "UPSTREAM_TIMEOUT";
|
|
92
|
-
timeoutError.exitCode = 5;
|
|
93
|
-
timeoutError.retryable = true;
|
|
94
|
-
throw timeoutError;
|
|
95
|
-
}
|
|
96
|
-
if (error.code) {
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
const networkError = new Error(error.message || "网络请求失败");
|
|
100
|
-
networkError.code = "NETWORK_ERROR";
|
|
101
|
-
networkError.exitCode = 5;
|
|
102
|
-
networkError.retryable = true;
|
|
103
|
-
throw networkError;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export async function apiGet(path, options = {}) {
|
|
108
|
-
return request("GET", path, options);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export async function apiPost(path, options = {}) {
|
|
112
|
-
return request("POST", path, options);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export async function fetchOpenApiSpec(options = {}) {
|
|
116
|
-
const response = await fetch(DEFAULT_OPENAPI_URL, {
|
|
117
|
-
method: "GET",
|
|
118
|
-
headers: {
|
|
119
|
-
Accept: "application/json",
|
|
120
|
-
},
|
|
121
|
-
signal: createTimeoutSignal(options.timeout),
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
if (!response.ok) {
|
|
125
|
-
const error = new Error(`HTTP ${response.status}`);
|
|
126
|
-
error.code = "UPSTREAM_ERROR";
|
|
127
|
-
error.exitCode = 4;
|
|
128
|
-
error.retryable = true;
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return response.json();
|
|
133
|
-
}
|
package/src/ycloud/core/token.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { readConfig } from "./config.js";
|
|
2
|
-
|
|
3
|
-
export async function getTokenWithSource() {
|
|
4
|
-
const envToken = (process.env.YUANCHUANG_API_TOKEN || "").trim();
|
|
5
|
-
if (envToken) {
|
|
6
|
-
return {
|
|
7
|
-
token: envToken,
|
|
8
|
-
source: "env",
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const config = await readConfig();
|
|
13
|
-
const configToken = (config.token || "").trim();
|
|
14
|
-
if (configToken) {
|
|
15
|
-
return {
|
|
16
|
-
token: configToken,
|
|
17
|
-
source: "config",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
token: "",
|
|
23
|
-
source: null,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function getToken() {
|
|
28
|
-
const { token } = await getTokenWithSource();
|
|
29
|
-
return token;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|