@seavideo/cli 0.0.0-stage → 0.3.1

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 (111) hide show
  1. package/LICENSE +12 -0
  2. package/README.md +153 -2
  3. package/README.publish.md +154 -0
  4. package/dist/bin/seavideo.js +11 -0
  5. package/dist/src/atomic-write.js +14 -0
  6. package/dist/src/canvas/api.js +172 -0
  7. package/dist/src/canvas/browser.js +40 -0
  8. package/dist/src/canvas/chrome-binary.js +109 -0
  9. package/dist/src/canvas/daemon.js +264 -0
  10. package/dist/src/canvas/engine-install.js +46 -0
  11. package/dist/src/canvas/engine-log.js +9 -0
  12. package/dist/src/canvas/engine.js +99 -0
  13. package/dist/src/canvas/entry.js +16 -0
  14. package/dist/src/canvas/env-lock.js +164 -0
  15. package/dist/src/canvas/launch.js +97 -0
  16. package/dist/src/canvas/lifecycle.js +65 -0
  17. package/dist/src/canvas/names.js +61 -0
  18. package/dist/src/canvas/params.js +38 -0
  19. package/dist/src/canvas/puppeteer.js +153 -0
  20. package/dist/src/canvas/screenshot.js +23 -0
  21. package/dist/src/canvas/session-record.js +77 -0
  22. package/dist/src/canvas/team.js +97 -0
  23. package/dist/src/canvas/tool-args.js +47 -0
  24. package/dist/src/canvas/tool-session.js +165 -0
  25. package/dist/src/canvas/tool-specs.js +54 -0
  26. package/dist/src/canvas/url.js +38 -0
  27. package/dist/src/cli/args.js +16 -0
  28. package/dist/src/cli/commands/auth.js +51 -0
  29. package/dist/src/cli/commands/canvas/common.js +31 -0
  30. package/dist/src/cli/commands/canvas/engine-choice.js +41 -0
  31. package/dist/src/cli/commands/canvas/index.js +5 -0
  32. package/dist/src/cli/commands/canvas/item.js +233 -0
  33. package/dist/src/cli/commands/canvas/list.js +168 -0
  34. package/dist/src/cli/commands/canvas/register.js +106 -0
  35. package/dist/src/cli/commands/canvas/render.js +229 -0
  36. package/dist/src/cli/commands/canvas/screenshot.js +52 -0
  37. package/dist/src/cli/commands/canvas/session.js +249 -0
  38. package/dist/src/cli/commands/canvas/teams.js +142 -0
  39. package/dist/src/cli/commands/config.js +74 -0
  40. package/dist/src/cli/commands/doctor.js +261 -0
  41. package/dist/src/cli/commands/engine.js +96 -0
  42. package/dist/src/cli/commands/env/create.js +160 -0
  43. package/dist/src/cli/commands/env/fields.js +26 -0
  44. package/dist/src/cli/commands/env/index.js +4 -0
  45. package/dist/src/cli/commands/env/list.js +44 -0
  46. package/dist/src/cli/commands/env/mutate.js +118 -0
  47. package/dist/src/cli/commands/login/flow-token.js +41 -0
  48. package/dist/src/cli/commands/login/index.js +12 -0
  49. package/dist/src/cli/commands/login/oauth.js +69 -0
  50. package/dist/src/cli/commands/login/save.js +26 -0
  51. package/dist/src/cli/commands/logout.js +92 -0
  52. package/dist/src/cli/commands/skill.js +185 -0
  53. package/dist/src/cli/commands/tool.js +279 -0
  54. package/dist/src/cli/commands/update.js +117 -0
  55. package/dist/src/cli/commands/wallet.js +69 -0
  56. package/dist/src/cli/commands/whoami.js +147 -0
  57. package/dist/src/cli/context.js +41 -0
  58. package/dist/src/cli/credential.js +93 -0
  59. package/dist/src/cli/elapsed.js +25 -0
  60. package/dist/src/cli/failure-screenshot.js +24 -0
  61. package/dist/src/cli/flags.js +1 -0
  62. package/dist/src/cli/hints.js +7 -0
  63. package/dist/src/cli/main.js +44 -0
  64. package/dist/src/cli/output-error.js +23 -0
  65. package/dist/src/cli/output.js +47 -0
  66. package/dist/src/cli/program.js +261 -0
  67. package/dist/src/cli/run.js +11 -0
  68. package/dist/src/cli/session.js +63 -0
  69. package/dist/src/config/base-url.js +26 -0
  70. package/dist/src/config/credential-vault.js +115 -0
  71. package/dist/src/config/dotenv.js +59 -0
  72. package/dist/src/config/envname.js +41 -0
  73. package/dist/src/config/paths.js +22 -0
  74. package/dist/src/config/preset-schema.js +67 -0
  75. package/dist/src/config/presets.js +132 -0
  76. package/dist/src/config/resolve.js +41 -0
  77. package/dist/src/config/secret-key.js +63 -0
  78. package/dist/src/config/store-schema.js +143 -0
  79. package/dist/src/config/store.js +273 -0
  80. package/dist/src/config/vault-crypto.js +44 -0
  81. package/dist/src/deps.js +191 -0
  82. package/dist/src/deps.types.js +1 -0
  83. package/dist/src/errors.js +24 -0
  84. package/dist/src/fs-retry.js +34 -0
  85. package/dist/src/i18n.js +1214 -0
  86. package/dist/src/loopback.js +134 -0
  87. package/dist/src/sdk/auth.js +20 -0
  88. package/dist/src/sdk/credential-expiry.js +67 -0
  89. package/dist/src/sdk/discovery.js +90 -0
  90. package/dist/src/sdk/http.js +98 -0
  91. package/dist/src/sdk/identity.js +17 -0
  92. package/dist/src/sdk/jwks.js +119 -0
  93. package/dist/src/sdk/oauth-protocol.js +226 -0
  94. package/dist/src/sdk/oauth.js +179 -0
  95. package/dist/src/sdk/provider/cn.js +34 -0
  96. package/dist/src/sdk/provider/index.js +16 -0
  97. package/dist/src/sdk/provider/oversea.js +41 -0
  98. package/dist/src/sdk/provider/types.js +1 -0
  99. package/dist/src/sdk/refresh.js +66 -0
  100. package/dist/src/semver.js +89 -0
  101. package/dist/src/skill/api.js +176 -0
  102. package/dist/src/text.js +3 -0
  103. package/dist/src/types.js +1 -0
  104. package/dist/src/update/check-cache.js +56 -0
  105. package/dist/src/update/install-layout.js +79 -0
  106. package/dist/src/update/notify.js +15 -0
  107. package/dist/src/update/npm-install.js +64 -0
  108. package/dist/src/update/passive.js +53 -0
  109. package/dist/src/update/registry.js +59 -0
  110. package/dist/src/wallet/api.js +107 -0
  111. package/package.json +59 -4
@@ -0,0 +1,249 @@
1
+ import { CliError, errorMessage } from "../../../errors.js";
2
+ import { appendEngineLog } from "../../../canvas/engine-log.js";
3
+ import { connectPuppeteerBrowser, puppeteerConnect } from "../../../canvas/puppeteer.js";
4
+ import { DEFAULT_IDLE_TIMEOUT_MS, spawnCanvasBrowser } from "../../../canvas/daemon.js";
5
+ import { clearSessionRecord, readSessionRecord, sessionFingerprint, writeSessionRecord, } from "../../../canvas/session-record.js";
6
+ import { closeCanvasSession, daemonDepsOf } from "../../../canvas/lifecycle.js";
7
+ import { withCanvasLock } from "../../../canvas/env-lock.js";
8
+ import { buildLoadUrl, maskUrlCredential, requireFlowCredential } from "../../../canvas/url.js";
9
+ import { requestCanvasLaunch } from "../../../canvas/launch.js";
10
+ import { writeToolSpecs } from "../../../canvas/tool-specs.js";
11
+ import { assertCanvasId } from "../../../canvas/params.js";
12
+ import { isHeadful } from "../../../canvas/browser.js";
13
+ import { resolveEnginePath } from "./engine-choice.js";
14
+ import { resolveFlowCredential } from "../../credential.js";
15
+ import { resolveEnvName } from "../../../config/resolve.js";
16
+ import { withScreenshot } from "../../failure-screenshot.js";
17
+ import { style } from "../../output.js";
18
+ import { cmdPrefix } from "../../hints.js";
19
+ import { loadEnv } from "../../context.js";
20
+ import { t } from "../../../i18n.js";
21
+ export async function canvasUseCommand(ctx, id, options) {
22
+ return useCanvas(ctx, id, options.json === true, options.show === true);
23
+ }
24
+ export function loadHint(ctx, id, envMap) {
25
+ return t('canvas.createdButNotLoadedHint', { entry: ctx.entry, id }, envMap);
26
+ }
27
+ const FAILURE_SCREENSHOT_REASON = 'load-failed';
28
+ export async function useCanvas(ctx, id, json = false, show = false) {
29
+ const { deps } = ctx;
30
+ const canvasId = assertCanvasId(id, deps.env);
31
+ const loaded = await loadEnv(ctx);
32
+ const env = loaded.env;
33
+ const headful = show || isHeadful(deps.env);
34
+ const enginePath = await resolveEnginePath(ctx, headful);
35
+ const engine = { path: enginePath };
36
+ const logEngine = json ? deps.stderr : deps.stdout;
37
+ logEngine(`${style.dim(t('canvas.engineInUse', { path: engine.path }, deps.env))}\n`);
38
+ return withCanvasLock(ctx, env, async () => {
39
+ const { config, token } = await resolveFlowCredential(ctx, loaded);
40
+ const launch = config.platform === 'cn' ? await requestCanvasLaunch(deps, config, canvasId, token) : null;
41
+ const url = launch?.url ?? buildLoadUrl(config, canvasId, deps.env);
42
+ return startCanvas(ctx, {
43
+ id: canvasId,
44
+ url,
45
+ cookie: launch?.cookie,
46
+ config,
47
+ enginePath: engine.path,
48
+ headful,
49
+ json,
50
+ });
51
+ });
52
+ }
53
+ async function startCanvas(ctx, args) {
54
+ const { deps } = ctx;
55
+ const { id, url, cookie, config, enginePath, headful, json } = args;
56
+ const { env } = config;
57
+ const replaced = await closeCanvasSession(ctx, env);
58
+ const sessionFile = ctx.paths.canvasSessionFile(env);
59
+ const logFile = ctx.paths.engineLogFile(env);
60
+ const daemonDeps = daemonDepsOf(ctx);
61
+ const profileDir = ctx.paths.profileDir(env);
62
+ const spawned = await spawnCanvasBrowser(enginePath, profileDir, sessionFile, deps.nodePath(), daemonDeps, { headful });
63
+ await appendEngineLog(deps, logFile, {
64
+ at: deps.clock().toISOString(),
65
+ event: 'spawn',
66
+ env,
67
+ canvasId: id,
68
+ url,
69
+ pid: spawned.pid,
70
+ port: spawned.port,
71
+ engine: enginePath,
72
+ args: spawned.args,
73
+ });
74
+ const browser = connectPuppeteerBrowser({
75
+ connect: puppeteerConnect,
76
+ port: spawned.port,
77
+ envMap: deps.env,
78
+ });
79
+ try {
80
+ return await loadOrScreenshot(ctx, {
81
+ id,
82
+ url,
83
+ cookie,
84
+ config,
85
+ env,
86
+ sessionFile,
87
+ spawned,
88
+ browser,
89
+ json,
90
+ replaced,
91
+ });
92
+ }
93
+ finally {
94
+ await browser.close();
95
+ }
96
+ }
97
+ async function loadOrScreenshot(ctx, args) {
98
+ let result;
99
+ try {
100
+ result = await loadIntoSession(ctx, args);
101
+ }
102
+ catch (err) {
103
+ const noted = await withScreenshot(ctx, {
104
+ browser: args.browser,
105
+ env: args.env,
106
+ canvasId: args.id,
107
+ reason: FAILURE_SCREENSHOT_REASON,
108
+ }, err);
109
+ await appendEngineLog(ctx.deps, ctx.paths.engineLogFile(args.env), {
110
+ at: ctx.deps.clock().toISOString(),
111
+ event: 'error',
112
+ env: args.env,
113
+ canvasId: args.id,
114
+ phase: 'load',
115
+ message: errorMessage(err),
116
+ detail: err instanceof CliError ? err.detail : undefined,
117
+ });
118
+ try {
119
+ ctx.deps.terminate(args.spawned.pid);
120
+ }
121
+ catch {
122
+ }
123
+ await appendEngineLog(ctx.deps, ctx.paths.engineLogFile(args.env), {
124
+ at: ctx.deps.clock().toISOString(),
125
+ event: 'exit',
126
+ env: args.env,
127
+ canvasId: args.id,
128
+ pid: args.spawned.pid,
129
+ reason: 'load-failed',
130
+ });
131
+ await clearSessionRecord(args.sessionFile, ctx.deps).catch(() => undefined);
132
+ throw noted;
133
+ }
134
+ return result;
135
+ }
136
+ async function loadIntoSession(ctx, args) {
137
+ const { deps } = ctx;
138
+ const { id, url, cookie, config, env, sessionFile, spawned, browser, json, replaced } = args;
139
+ const session = await browser.open(url, cookie);
140
+ await appendEngineLog(deps, ctx.paths.engineLogFile(env), {
141
+ at: deps.clock().toISOString(),
142
+ event: 'loaded',
143
+ env,
144
+ canvasId: id,
145
+ url,
146
+ finalUrl: session.url,
147
+ title: session.title,
148
+ toolCount: session.tools.length,
149
+ });
150
+ const now = deps.clock().toISOString();
151
+ await cacheToolSpecs(ctx, env, session.tools);
152
+ const fingerprint = sessionFingerprint({
153
+ env,
154
+ id,
155
+ flowWebBaseUrl: config.flowWebBaseUrl,
156
+ flowCredential: requireFlowCredential(config, deps.env),
157
+ });
158
+ const record = { id, port: spawned.port, pid: spawned.pid, at: now, usedAt: now, fingerprint };
159
+ try {
160
+ await writeSessionRecord(sessionFile, record, deps);
161
+ }
162
+ catch (err) {
163
+ throw new CliError('config', t('canvas.sessionRecordFailed', {}, deps.env), {
164
+ detail: errorMessage(err),
165
+ });
166
+ }
167
+ await ctx.store.writeLastCanvas(env, { id, at: now }).catch(() => {
168
+ deps.stderr(`${style.warn('!')} ${t('canvas.lastUsedWriteFailed', {}, deps.env)}\n`);
169
+ });
170
+ printLoaded(ctx, {
171
+ id,
172
+ url,
173
+ env,
174
+ session,
175
+ pid: spawned.pid,
176
+ port: spawned.port,
177
+ replaced,
178
+ json,
179
+ });
180
+ return 0;
181
+ }
182
+ async function cacheToolSpecs(ctx, env, tools) {
183
+ try {
184
+ await writeToolSpecs(ctx.deps, ctx.paths.toolSpecsDir(env), tools);
185
+ }
186
+ catch (err) {
187
+ ctx.deps.stderr(`${style.warn('!')} ${t('canvas.toolSpecsWriteFailed', { reason: errorMessage(err) }, ctx.deps.env)}\n`);
188
+ }
189
+ }
190
+ function printLoaded(ctx, args) {
191
+ const { deps } = ctx;
192
+ const { id, url, env, session, pid, port, replaced, json } = args;
193
+ const specsLine = `${style.dim(` ${t('canvas.toolSpecsDir', { dir: ctx.paths.toolSpecsDir(env) }, deps.env)}`)}\n`;
194
+ if (json) {
195
+ deps.stdout(`${JSON.stringify({
196
+ id,
197
+ url: maskUrlCredential(url),
198
+ finalUrl: maskUrlCredential(session.url),
199
+ title: session.title,
200
+ tools: session.tools.map((tool) => tool.name),
201
+ pid,
202
+ port,
203
+ replaced,
204
+ }, null, 2)}\n`);
205
+ deps.stderr(specsLine);
206
+ }
207
+ else {
208
+ const replacedLine = replaced === null ? '' : `${style.dim(t('canvas.replaced', { id: replaced }, deps.env))}\n`;
209
+ deps.stdout(`${replacedLine}${style.ok('✓')} ${t('canvas.loaded', { id, title: session.title }, deps.env)}\n`);
210
+ deps.stdout(`${style.dim(` ${t('canvas.loadUrl', { url: maskUrlCredential(url) }, deps.env)}`)}\n`);
211
+ deps.stdout(`${style.dim(` ${t('canvas.finalUrl', { url: maskUrlCredential(session.url) }, deps.env)}`)}\n`);
212
+ deps.stdout(`${style.dim(` ${t('canvas.toolCount', { count: session.tools.length }, deps.env)}`)}\n`);
213
+ deps.stdout(specsLine);
214
+ deps.stdout(`${style.dim(` ${t('canvas.sessionKept', { pid, minutes: IDLE_TIMEOUT_MINUTES }, deps.env)}`)}\n`);
215
+ deps.stdout(`${style.dim(` ${t('canvas.sessionCloseHint', {}, deps.env)}: ${cmdPrefix(ctx)}canvas close`)}\n`);
216
+ deps.stdout(`${style.warn('!')} ${t('canvas.exclusiveWarning', {}, deps.env)}\n`);
217
+ }
218
+ }
219
+ const IDLE_TIMEOUT_MINUTES = Math.round(DEFAULT_IDLE_TIMEOUT_MS / 60_000);
220
+ export async function canvasCloseCommand(ctx, options) {
221
+ const { deps } = ctx;
222
+ const env = await resolveEnvName(ctx.envFlag, deps, ctx.paths);
223
+ return withCanvasLock(ctx, env, () => closeInLock(ctx, env, options.json === true));
224
+ }
225
+ async function closeInLock(ctx, env, json) {
226
+ const { deps } = ctx;
227
+ const record = await readSessionRecord(ctx.paths.canvasSessionFile(env), deps);
228
+ let result;
229
+ if (record === null) {
230
+ if (json) {
231
+ deps.stdout(`${JSON.stringify({ closed: false, reason: 'no-session' }, null, 2)}\n`);
232
+ }
233
+ else {
234
+ deps.stdout(`${style.dim(t('canvas.closeNone', {}, deps.env))}\n`);
235
+ }
236
+ result = 0;
237
+ }
238
+ else {
239
+ await closeCanvasSession(ctx, env);
240
+ if (json) {
241
+ deps.stdout(`${JSON.stringify({ closed: true, id: record.id, pid: record.pid }, null, 2)}\n`);
242
+ }
243
+ else {
244
+ deps.stdout(`${style.ok('✓')} ${t('canvas.closed', { id: record.id }, deps.env)}\n`);
245
+ }
246
+ result = 0;
247
+ }
248
+ return result;
249
+ }
@@ -0,0 +1,142 @@
1
+ import { CliError, errorMessage } from "../../../errors.js";
2
+ import { createTeamApi, } from "../../../canvas/team.js";
3
+ import { requireSpace } from "../../../canvas/entry.js";
4
+ import { PAGE_SIZE_LIMIT } from "../../../canvas/params.js";
5
+ import { formatTimestamp } from "../../elapsed.js";
6
+ import { renderTable, style } from "../../output.js";
7
+ import { hint } from "../../hints.js";
8
+ import { sanitizeText } from "../../../text.js";
9
+ import { t } from "../../../i18n.js";
10
+ import { apiOf, MAX_ALL_PAGES, requireAccountCredential } from "./common.js";
11
+ export async function canvasTeamListCommand(ctx, options) {
12
+ const { deps } = ctx;
13
+ requireSpace(ctx.entry, 'team', deps.env);
14
+ const { config, flowToken } = await apiOf(ctx);
15
+ const credential = requireAccountCredential(config, deps.env);
16
+ const teams = await createTeamApi(deps, config, credential, flowToken).teams();
17
+ let result;
18
+ if (options.json === true) {
19
+ deps.stdout(`${JSON.stringify({ total: teams.length, items: teams }, null, 2)}\n`);
20
+ result = 0;
21
+ }
22
+ else if (teams.length === 0) {
23
+ deps.stdout(`${style.dim(t('canvas.teamEmpty', {}, deps.env))}\n`);
24
+ result = 0;
25
+ }
26
+ else {
27
+ const columns = [
28
+ ['id', 'canvas.col.id'],
29
+ ['name', 'canvas.col.name'],
30
+ ['role', 'canvas.col.role'],
31
+ ['createdAt', 'canvas.col.createdAt'],
32
+ ];
33
+ const cells = teams.map((x) => [
34
+ x.id,
35
+ x.name === '' ? style.dim(t('canvas.unnamed', {}, deps.env)) : sanitizeText(x.name),
36
+ x.role === null ? '' : sanitizeText(x.role),
37
+ x.createdAt === null ? '' : formatTimestamp(x.createdAt),
38
+ ]);
39
+ deps.stdout(`${style.bold(columns.map(([, key]) => t(key, {}, deps.env)).join(' '))}\n`);
40
+ deps.stdout(`${renderTable(cells)}\n`);
41
+ deps.stdout(`${style.dim(` ${t('canvas.teamCount', { count: teams.length }, deps.env)} · ${hint(ctx, 'canvas.teamHint', `canvas project list --team <id>`)}`)}\n`);
42
+ result = 0;
43
+ }
44
+ return result;
45
+ }
46
+ async function fetchTeamProjects(teamApi, teamId) {
47
+ const projects = [];
48
+ for (let p = 1; p <= MAX_ALL_PAGES; p += 1) {
49
+ const chunk = await teamApi.canvases(teamId, p, PAGE_SIZE_LIMIT);
50
+ projects.push(...chunk.projects);
51
+ if (p >= chunk.pages)
52
+ break;
53
+ }
54
+ return projects;
55
+ }
56
+ async function scanTeamProjects(teamApi, teams) {
57
+ const rows = [];
58
+ const failures = [];
59
+ let firstError = null;
60
+ for (const team of teams) {
61
+ try {
62
+ for (const p of await fetchTeamProjects(teamApi, team.id)) {
63
+ rows.push({
64
+ teamId: team.id,
65
+ teamName: team.name,
66
+ projectId: p.id,
67
+ projectName: p.name,
68
+ canvasCount: p.canvasCount,
69
+ });
70
+ }
71
+ }
72
+ catch (err) {
73
+ firstError ??= err;
74
+ failures.push(`${team.name === '' ? team.id : sanitizeText(team.name)}: ${errorMessage(err)}`);
75
+ }
76
+ }
77
+ return { rows, failures, firstError };
78
+ }
79
+ function printProjects(ctx, options, rows, teamCount) {
80
+ const { deps } = ctx;
81
+ if (options.json === true) {
82
+ deps.stdout(`${JSON.stringify({
83
+ total: rows.length,
84
+ teams: teamCount,
85
+ items: rows.map((r) => ({
86
+ teamId: r.teamId,
87
+ teamName: r.teamName,
88
+ projectId: r.projectId,
89
+ projectName: r.projectName,
90
+ canvasCount: r.canvasCount,
91
+ })),
92
+ }, null, 2)}\n`);
93
+ }
94
+ else if (rows.length === 0) {
95
+ deps.stdout(`${style.dim(t('canvas.projectEmpty', {}, deps.env))}\n`);
96
+ }
97
+ else {
98
+ const columns = [
99
+ ['teamId', 'canvas.col.teamId'],
100
+ ['teamName', 'canvas.col.teamName'],
101
+ ['projectId', 'canvas.col.projectId'],
102
+ ['projectName', 'canvas.col.projectName'],
103
+ ['canvasCount', 'canvas.col.canvases'],
104
+ ];
105
+ const cells = rows.map((r) => [
106
+ r.teamId,
107
+ r.teamName === '' ? style.dim(t('canvas.unnamed', {}, deps.env)) : sanitizeText(r.teamName),
108
+ r.projectId,
109
+ r.projectName === ''
110
+ ? style.dim(t('canvas.unnamed', {}, deps.env))
111
+ : sanitizeText(r.projectName),
112
+ r.canvasCount === null ? '' : String(r.canvasCount),
113
+ ]);
114
+ deps.stdout(`${style.bold(columns.map(([, key]) => t(key, {}, deps.env)).join(' '))}\n`);
115
+ deps.stdout(`${renderTable(cells)}\n`);
116
+ deps.stdout(`${style.dim(` ${t('canvas.teamProjectCount', { count: rows.length }, deps.env)} · ` +
117
+ `${t('canvas.teamCount', { count: teamCount }, deps.env)} · ${hint(ctx, 'canvas.projectHint', `canvas create <name> --project <id>`)}`)}\n`);
118
+ }
119
+ }
120
+ export async function canvasProjectListCommand(ctx, options) {
121
+ const { deps } = ctx;
122
+ requireSpace(ctx.entry, 'team', deps.env);
123
+ const { config, flowToken } = await apiOf(ctx);
124
+ const credential = requireAccountCredential(config, deps.env);
125
+ const teamApi = createTeamApi(deps, config, credential, flowToken);
126
+ const teams = await teamApi.teams();
127
+ const selected = options.team === undefined ? teams : teams.filter((x) => x.id === options.team);
128
+ if (options.team !== undefined && selected.length === 0) {
129
+ throw new CliError('usage', t('canvas.teamNotFound', { team: options.team }, deps.env), {
130
+ detail: t('canvas.teamNotFoundDetail', {}, deps.env),
131
+ });
132
+ }
133
+ const { rows, failures, firstError } = await scanTeamProjects(teamApi, selected);
134
+ if (rows.length === 0 && failures.length === selected.length && firstError !== null) {
135
+ throw firstError;
136
+ }
137
+ for (const f of failures) {
138
+ deps.stderr(`${style.warn('!')} ${t('canvas.teamProjectsFailed', { error: f }, deps.env)}\n`);
139
+ }
140
+ printProjects(ctx, options, rows, selected.length);
141
+ return 0;
142
+ }
@@ -0,0 +1,74 @@
1
+ import { resolveEnvName } from "../../config/resolve.js";
2
+ import { maskSecret, renderTable, style } from "../output.js";
3
+ import { loadEnv } from "../context.js";
4
+ import { t } from "../../i18n.js";
5
+ export async function configPathCommand(ctx) {
6
+ const env = await resolveEnvName(ctx.envFlag, ctx.deps, ctx.paths);
7
+ ctx.deps.stdout(`${ctx.paths.root}\n`);
8
+ ctx.deps.stdout(`${ctx.paths.currentFile}\n`);
9
+ ctx.deps.stdout(`${ctx.paths.configFile(env)}\n`);
10
+ ctx.deps.stdout(`${ctx.paths.userFile(env)}\n`);
11
+ return 0;
12
+ }
13
+ export async function configGetCommand(ctx, options) {
14
+ const config = await loadEnv(ctx);
15
+ const credential = config.credential;
16
+ const flowCredential = config.flowCredential;
17
+ if (options.json === true) {
18
+ ctx.deps.stdout(`${JSON.stringify({
19
+ env: config.env,
20
+ platform: config.platform,
21
+ seavideoBaseUrl: config.seavideoBaseUrl,
22
+ flowWebBaseUrl: config.flowWebBaseUrl,
23
+ flowApiBaseUrl: config.flowApiBaseUrl,
24
+ aiVideoApiBaseUrl: config.aiVideoApiBaseUrl,
25
+ authIssuer: config.authIssuer,
26
+ authClientId: config.authClientId,
27
+ credential: credential === null
28
+ ? null
29
+ : { masked: maskSecret(credential.value), source: credential.source },
30
+ flowCredential: flowCredential === null
31
+ ? null
32
+ : { masked: maskSecret(flowCredential.value), source: flowCredential.source },
33
+ }, null, 2)}\n`);
34
+ }
35
+ else {
36
+ ctx.deps.stdout(`${renderTable([
37
+ [t('config.label.env', {}, ctx.deps.env), config.env],
38
+ [t('config.label.platform', {}, ctx.deps.env), config.platform],
39
+ [t('config.label.server', {}, ctx.deps.env), config.seavideoBaseUrl],
40
+ [t('config.label.flowWebBaseUrl', {}, ctx.deps.env), config.flowWebBaseUrl],
41
+ [t('config.label.flowApiBaseUrl', {}, ctx.deps.env), config.flowApiBaseUrl],
42
+ [
43
+ t('config.label.credential', {}, ctx.deps.env),
44
+ credential === null
45
+ ? style.dim(t('config.notConfigured', {}, ctx.deps.env))
46
+ : maskSecret(credential.value),
47
+ ],
48
+ [
49
+ t('config.label.flowCredential', {}, ctx.deps.env),
50
+ flowCredential === null
51
+ ? style.dim(t('config.notConfigured', {}, ctx.deps.env))
52
+ : maskSecret(flowCredential.value),
53
+ ],
54
+ [
55
+ t('config.label.authIssuer', {}, ctx.deps.env),
56
+ config.authIssuer === null
57
+ ? style.dim(t('config.notConfigured', {}, ctx.deps.env))
58
+ : config.authIssuer,
59
+ ],
60
+ [
61
+ t('config.label.authClientId', {}, ctx.deps.env),
62
+ config.authClientId === null
63
+ ? style.dim(t('config.notConfigured', {}, ctx.deps.env))
64
+ : config.authClientId,
65
+ ],
66
+ [
67
+ t('config.label.source', {}, ctx.deps.env),
68
+ credential === null ? style.dim('-') : credential.source,
69
+ ],
70
+ [t('config.label.file', {}, ctx.deps.env), ctx.paths.configFile(config.env)],
71
+ ])}\n`);
72
+ }
73
+ return 0;
74
+ }