@lingjingai/lj-awb-cli-pre 0.3.15

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 (49) hide show
  1. package/README.md +335 -0
  2. package/build/_shared.mjs +130 -0
  3. package/build/build.mjs +50 -0
  4. package/build/pre-publish.mjs +57 -0
  5. package/build/pre.mjs +42 -0
  6. package/build/prod.mjs +52 -0
  7. package/install.mjs +53 -0
  8. package/package.json +44 -0
  9. package/packages/awb-cli/README.md +19 -0
  10. package/packages/awb-cli/bin/lj-awb +19 -0
  11. package/packages/awb-cli/bin/lj-awb.js +11 -0
  12. package/packages/awb-cli/package.json +18 -0
  13. package/packages/awb-core/README.md +12 -0
  14. package/packages/awb-core/package.json +21 -0
  15. package/packages/awb-core/src/api.js +349 -0
  16. package/packages/awb-core/src/artifact.js +936 -0
  17. package/packages/awb-core/src/auth.js +80 -0
  18. package/packages/awb-core/src/commands.js +1321 -0
  19. package/packages/awb-core/src/common.js +508 -0
  20. package/packages/awb-core/src/output.js +1189 -0
  21. package/packages/awb-core/src/services.js +3811 -0
  22. package/packages/awb-core/src/standalone.js +1213 -0
  23. package/skills/lj-awb/SKILL.md +160 -0
  24. package/skills/lj-awb/VERSION +1 -0
  25. package/skills/lj-awb/compat.json +6 -0
  26. package/skills/lj-awb/modules/account.md +30 -0
  27. package/skills/lj-awb/modules/artifact/asset.md +64 -0
  28. package/skills/lj-awb/modules/artifact/clip.md +65 -0
  29. package/skills/lj-awb/modules/artifact/script.md +37 -0
  30. package/skills/lj-awb/modules/artifact/video.md +65 -0
  31. package/skills/lj-awb/modules/artifact.md +65 -0
  32. package/skills/lj-awb/modules/asset.md +53 -0
  33. package/skills/lj-awb/modules/auth.md +30 -0
  34. package/skills/lj-awb/modules/create-contract.md +118 -0
  35. package/skills/lj-awb/modules/credits.md +28 -0
  36. package/skills/lj-awb/modules/evals.md +186 -0
  37. package/skills/lj-awb/modules/image.md +75 -0
  38. package/skills/lj-awb/modules/model.md +110 -0
  39. package/skills/lj-awb/modules/project.md +30 -0
  40. package/skills/lj-awb/modules/subject.md +32 -0
  41. package/skills/lj-awb/modules/task-manual.md +185 -0
  42. package/skills/lj-awb/modules/task.md +62 -0
  43. package/skills/lj-awb/modules/upload.md +33 -0
  44. package/skills/lj-awb/modules/video.md +102 -0
  45. package/skills/lj-awb/modules/workflows.md +482 -0
  46. package/skills/lj-awb/references/error-codes.md +102 -0
  47. package/skills/lj-awb/references/model-options-read.md +49 -0
  48. package/skills/lj-awb/references/output-fields.md +113 -0
  49. package/skills/lj-awb/scripts/resolve-lj-awb-cmd.sh +10 -0
@@ -0,0 +1,80 @@
1
+ import {
2
+ LingjingAwbCliError,
3
+ AUTH_PATH,
4
+ maskSecret,
5
+ nowIso,
6
+ readJson,
7
+ resolveRuntimeAccessKey,
8
+ trimSecret,
9
+ writeJson,
10
+ } from './common.js';
11
+
12
+ export async function loadAuth() {
13
+ return await readJson(AUTH_PATH, {});
14
+ }
15
+
16
+ export async function saveAuth(auth) {
17
+ const stored = {
18
+ ...auth,
19
+ updatedAt: Date.now(),
20
+ updatedAtText: nowIso(),
21
+ };
22
+ await writeJson(AUTH_PATH, stored, { secure: true });
23
+ return stored;
24
+ }
25
+
26
+ export async function clearAuth() {
27
+ await writeJson(AUTH_PATH, {}, { secure: true });
28
+ }
29
+
30
+ export async function resolveAuthContext({ required = true } = {}) {
31
+ const savedAuth = await loadAuth();
32
+ const accessKeyInfo = resolveRuntimeAccessKey(savedAuth);
33
+ if (!accessKeyInfo) {
34
+ if (!required) {
35
+ return { authenticated: false, auth: savedAuth, accessKeyInfo: null };
36
+ }
37
+ throw new LingjingAwbCliError('缺少 access key', {
38
+ type: 'auth_required',
39
+ exitCode: 3,
40
+ hint: '请设置 LINGJING_AWB_ACCESS_KEY / AWB_ACCESS_KEY,或运行 lj-awb auth login。',
41
+ });
42
+ }
43
+ return {
44
+ authenticated: true,
45
+ auth: savedAuth,
46
+ accessKeyInfo,
47
+ accessKey: accessKeyInfo.accessKey,
48
+ };
49
+ }
50
+
51
+ export function summarizeAuth(auth, accessKeyInfo = null) {
52
+ const info = accessKeyInfo || resolveRuntimeAccessKey(auth);
53
+ return {
54
+ loginState: info ? '已配置' : '未配置',
55
+ authType: info ? 'access_key' : null,
56
+ accessKey: info ? maskSecret(info.accessKey) : null,
57
+ accessKeySource: info?.source ?? null,
58
+ accessKeySourceName: info?.sourceName ?? null,
59
+ authPath: AUTH_PATH,
60
+ updatedAt: auth?.updatedAt ?? null,
61
+ updatedAtText: auth?.updatedAtText ?? null,
62
+ };
63
+ }
64
+
65
+ export async function saveAccessKey(rawAccessKey, options = {}) {
66
+ const accessKey = trimSecret(rawAccessKey);
67
+ if (!accessKey) {
68
+ throw new LingjingAwbCliError('access key 不能为空', {
69
+ type: 'argument_error',
70
+ exitCode: 2,
71
+ });
72
+ }
73
+ const auth = await saveAuth({
74
+ accessKey,
75
+ awbCode: accessKey,
76
+ authType: 'access_key',
77
+ verified: Boolean(options.verified),
78
+ });
79
+ return { auth, accessKey };
80
+ }