@meshy-ai/cli 0.4.6 → 0.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.
- package/README.md +7 -6
- package/dist/client/endpoints/balance.d.ts +4 -3
- package/dist/client/endpoints/balance.d.ts.map +1 -1
- package/dist/client/endpoints/balance.js +10 -12
- package/dist/client/endpoints/balance.js.map +1 -1
- package/dist/client/endpoints/base.d.ts +0 -2
- package/dist/client/endpoints/base.d.ts.map +1 -1
- package/dist/client/endpoints/base.js.map +1 -1
- package/dist/client/index.d.ts +0 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -22
- package/dist/client/index.js.map +1 -1
- package/dist/client/resource-registry.d.ts +2 -9
- package/dist/client/resource-registry.d.ts.map +1 -1
- package/dist/client/resource-registry.js +5 -14
- package/dist/client/resource-registry.js.map +1 -1
- package/dist/client/transport.d.ts +1 -1
- package/dist/client/transport.d.ts.map +1 -1
- package/dist/client/types.d.ts +4 -26
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js +4 -31
- package/dist/client/types.js.map +1 -1
- package/dist/cmd/animation-catalog.js +4 -4
- package/dist/cmd/animation-catalog.js.map +1 -1
- package/dist/cmd/api.d.ts.map +1 -1
- package/dist/cmd/api.js +5 -5
- package/dist/cmd/api.js.map +1 -1
- package/dist/cmd/auth.d.ts.map +1 -1
- package/dist/cmd/auth.js +41 -25
- package/dist/cmd/auth.js.map +1 -1
- package/dist/cmd/auto-split.d.ts.map +1 -1
- package/dist/cmd/auto-split.js +0 -1
- package/dist/cmd/auto-split.js.map +1 -1
- package/dist/cmd/balance.d.ts.map +1 -1
- package/dist/cmd/balance.js +6 -6
- package/dist/cmd/balance.js.map +1 -1
- package/dist/cmd/creative-lab.d.ts +0 -2
- package/dist/cmd/creative-lab.d.ts.map +1 -1
- package/dist/cmd/creative-lab.js +0 -7
- package/dist/cmd/creative-lab.js.map +1 -1
- package/dist/cmd/delete.d.ts.map +1 -1
- package/dist/cmd/delete.js +4 -4
- package/dist/cmd/delete.js.map +1 -1
- package/dist/cmd/doctor.js +4 -4
- package/dist/cmd/doctor.js.map +1 -1
- package/dist/cmd/download.d.ts +1 -1
- package/dist/cmd/download.js +9 -9
- package/dist/cmd/download.js.map +1 -1
- package/dist/cmd/image-to-3d.d.ts +3 -3
- package/dist/cmd/image-to-3d.d.ts.map +1 -1
- package/dist/cmd/image-to-3d.js +16 -45
- package/dist/cmd/image-to-3d.js.map +1 -1
- package/dist/cmd/image-to-image.d.ts.map +1 -1
- package/dist/cmd/image-to-image.js +2 -1
- package/dist/cmd/image-to-image.js.map +1 -1
- package/dist/cmd/inspect.d.ts +12 -4
- package/dist/cmd/inspect.d.ts.map +1 -1
- package/dist/cmd/inspect.js +63 -39
- package/dist/cmd/inspect.js.map +1 -1
- package/dist/cmd/make.d.ts.map +1 -1
- package/dist/cmd/make.js +51 -112
- package/dist/cmd/make.js.map +1 -1
- package/dist/cmd/mesh.d.ts +3 -3
- package/dist/cmd/mesh.js +5 -5
- package/dist/cmd/mesh.js.map +1 -1
- package/dist/cmd/multi-image-to-3d.d.ts +2 -3
- package/dist/cmd/multi-image-to-3d.d.ts.map +1 -1
- package/dist/cmd/multi-image-to-3d.js +10 -28
- package/dist/cmd/multi-image-to-3d.js.map +1 -1
- package/dist/cmd/operations.js +6 -6
- package/dist/cmd/operations.js.map +1 -1
- package/dist/cmd/project.d.ts.map +1 -1
- package/dist/cmd/project.js +11 -13
- package/dist/cmd/project.js.map +1 -1
- package/dist/cmd/resources.d.ts +4 -4
- package/dist/cmd/resources.d.ts.map +1 -1
- package/dist/cmd/resources.js +6 -15
- package/dist/cmd/resources.js.map +1 -1
- package/dist/cmd/retexture.d.ts +2 -2
- package/dist/cmd/retexture.js +2 -2
- package/dist/cmd/showcases.d.ts.map +1 -1
- package/dist/cmd/showcases.js +4 -4
- package/dist/cmd/showcases.js.map +1 -1
- package/dist/cmd/slicer.js +4 -4
- package/dist/cmd/slicer.js.map +1 -1
- package/dist/cmd/text-to-3d.d.ts +1 -1
- package/dist/cmd/text-to-3d.js +1 -1
- package/dist/cmd/text-to-image.d.ts.map +1 -1
- package/dist/cmd/text-to-image.js +3 -2
- package/dist/cmd/text-to-image.js.map +1 -1
- package/dist/cmd/usage.js +4 -4
- package/dist/cmd/usage.js.map +1 -1
- package/dist/cmd/uv-unwrap.d.ts +0 -1
- package/dist/cmd/uv-unwrap.d.ts.map +1 -1
- package/dist/cmd/uv-unwrap.js +0 -2
- package/dist/cmd/uv-unwrap.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -53
- package/dist/index.js.map +1 -1
- package/dist/internal/artifacts.d.ts +18 -9
- package/dist/internal/artifacts.d.ts.map +1 -1
- package/dist/internal/artifacts.js +56 -30
- package/dist/internal/artifacts.js.map +1 -1
- package/dist/internal/command-helpers.d.ts +9 -16
- package/dist/internal/command-helpers.d.ts.map +1 -1
- package/dist/internal/command-helpers.js +14 -31
- package/dist/internal/command-helpers.js.map +1 -1
- package/dist/internal/config.d.ts +3 -3
- package/dist/internal/config.js +3 -3
- package/dist/internal/context.d.ts +3 -5
- package/dist/internal/context.d.ts.map +1 -1
- package/dist/internal/context.js +3 -3
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/doctor.d.ts +0 -2
- package/dist/internal/doctor.d.ts.map +1 -1
- package/dist/internal/doctor.js +0 -4
- package/dist/internal/doctor.js.map +1 -1
- package/dist/internal/download.d.ts +34 -50
- package/dist/internal/download.d.ts.map +1 -1
- package/dist/internal/download.js +83 -331
- package/dist/internal/download.js.map +1 -1
- package/dist/internal/errors.d.ts +2 -20
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +9 -88
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/file-input.d.ts +0 -12
- package/dist/internal/file-input.d.ts.map +1 -1
- package/dist/internal/file-input.js +2 -49
- package/dist/internal/file-input.js.map +1 -1
- package/dist/internal/global-options.d.ts +4 -1
- package/dist/internal/global-options.d.ts.map +1 -1
- package/dist/internal/global-options.js +9 -2
- package/dist/internal/global-options.js.map +1 -1
- package/dist/internal/image-models.d.ts +7 -0
- package/dist/internal/image-models.d.ts.map +1 -1
- package/dist/internal/image-models.js +14 -0
- package/dist/internal/image-models.js.map +1 -1
- package/dist/internal/inspect.d.ts +31 -6
- package/dist/internal/inspect.d.ts.map +1 -1
- package/dist/internal/inspect.js +125 -12
- package/dist/internal/inspect.js.map +1 -1
- package/dist/internal/logger.d.ts +0 -1
- package/dist/internal/logger.d.ts.map +1 -1
- package/dist/internal/logger.js +0 -3
- package/dist/internal/logger.js.map +1 -1
- package/dist/internal/material-links.d.ts +0 -2
- package/dist/internal/material-links.d.ts.map +1 -1
- package/dist/internal/material-links.js +0 -4
- package/dist/internal/material-links.js.map +1 -1
- package/dist/internal/obj-transform.d.ts +1 -1
- package/dist/internal/obj-transform.js +1 -1
- package/dist/internal/output.d.ts +4 -13
- package/dist/internal/output.d.ts.map +1 -1
- package/dist/internal/output.js +5 -26
- package/dist/internal/output.js.map +1 -1
- package/dist/internal/paths.d.ts +2 -0
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +4 -0
- package/dist/internal/paths.js.map +1 -1
- package/dist/internal/pricing.d.ts +1 -1
- package/dist/internal/pricing.d.ts.map +1 -1
- package/dist/internal/pricing.js +1 -1
- package/dist/internal/pricing.js.map +1 -1
- package/dist/internal/project-store.d.ts +6 -13
- package/dist/internal/project-store.d.ts.map +1 -1
- package/dist/internal/project-store.js +23 -27
- package/dist/internal/project-store.js.map +1 -1
- package/dist/internal/result.d.ts +1 -2
- package/dist/internal/result.d.ts.map +1 -1
- package/dist/internal/result.js +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/runtime.d.ts +3 -19
- package/dist/internal/runtime.d.ts.map +1 -1
- package/dist/internal/runtime.js +12 -35
- package/dist/internal/runtime.js.map +1 -1
- package/dist/internal/slicers.d.ts +7 -8
- package/dist/internal/slicers.d.ts.map +1 -1
- package/dist/internal/slicers.js +7 -8
- package/dist/internal/slicers.js.map +1 -1
- package/dist/internal/task-command.d.ts +18 -14
- package/dist/internal/task-command.d.ts.map +1 -1
- package/dist/internal/task-command.js +53 -201
- package/dist/internal/task-command.js.map +1 -1
- package/dist/internal/task-view.js +1 -1
- package/dist/internal/task-view.js.map +1 -1
- package/dist/internal/texturing.d.ts +17 -0
- package/dist/internal/texturing.d.ts.map +1 -0
- package/dist/internal/texturing.js +30 -0
- package/dist/internal/texturing.js.map +1 -0
- package/dist/internal/update-notifier.d.ts +5 -25
- package/dist/internal/update-notifier.d.ts.map +1 -1
- package/dist/internal/update-notifier.js +5 -58
- package/dist/internal/update-notifier.js.map +1 -1
- package/dist/internal/views.d.ts +8 -10
- package/dist/internal/views.d.ts.map +1 -1
- package/dist/internal/views.js +61 -29
- package/dist/internal/views.js.map +1 -1
- package/dist/root.d.ts +0 -5
- package/dist/root.d.ts.map +1 -1
- package/dist/root.js +6 -24
- package/dist/root.js.map +1 -1
- package/package.json +1 -1
- package/skills/meshy-cli/SKILL.md +53 -49
- package/dist/internal/report.d.ts +0 -40
- package/dist/internal/report.d.ts.map +0 -1
- package/dist/internal/report.js +0 -48
- package/dist/internal/report.js.map +0 -1
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
* subcommands for any registered task resource. Per-resource modules only
|
|
4
4
|
* contribute their unique `create` flag shape and payload validation.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* never polls.
|
|
10
|
-
* v1 — one `meshy.cli/v1` envelope whose result carries the TaskView,
|
|
11
|
-
* the submission record and the download manifest.
|
|
6
|
+
* Every verb prints one `meshy.cli/v1` envelope whose result carries the
|
|
7
|
+
* TaskView, the submission record and the download manifest. `get` of a task
|
|
8
|
+
* in any status is a successful query (exit 0); async create never polls.
|
|
12
9
|
*
|
|
13
|
-
* Money rules enforced here
|
|
10
|
+
* Money rules enforced here:
|
|
14
11
|
* - every create is exactly one POST, journaled before it is sent;
|
|
15
12
|
* - a lost or malformed response is `submission_unknown` (exit 10), never a
|
|
16
13
|
* retry and never a "please run it again" hint;
|
|
@@ -26,34 +23,32 @@ import { Command, Option } from "commander";
|
|
|
26
23
|
import { MeshyApiError } from "../client/errors.js";
|
|
27
24
|
import { requireTaskResource } from "../client/resource-registry.js";
|
|
28
25
|
import { TransportError } from "../client/transport.js";
|
|
29
|
-
import {
|
|
30
|
-
import { emitResult, openCommand, rejectOutputFlagForV1, saveRawJson } from "./command-helpers.js";
|
|
26
|
+
import { emitResult, openCommand, rejectOutputFlag, saveRawJson } from "./command-helpers.js";
|
|
31
27
|
import { abortSignal, wasInterrupted } from "./context.js";
|
|
32
|
-
import {
|
|
28
|
+
import { downloadTaskAssets } from "./download.js";
|
|
33
29
|
import { classifyError, CliError, UsageError } from "./errors.js";
|
|
34
30
|
import { normalizeMediaPayload } from "./file-input.js";
|
|
31
|
+
import { allAssetsOption, outputOption } from "./global-options.js";
|
|
35
32
|
import { logger } from "./logger.js";
|
|
36
33
|
import { mergeNestedObjects, mergePayload, parseJsonFlag } from "./payload.js";
|
|
37
|
-
import {
|
|
38
|
-
import { taskCard } from "./views.js";
|
|
39
|
-
import { emitEnvelope, emitStreamEvent, emit } from "./output.js";
|
|
34
|
+
import { emitEnvelope, emitStreamEvent } from "./output.js";
|
|
40
35
|
import { parseTimeoutSeconds, pollUntilTerminal } from "./poll.js";
|
|
41
36
|
import { createProgress, withSpinner } from "./progress.js";
|
|
42
|
-
import { printReport } from "./report.js";
|
|
43
37
|
import { errorEnvelope, okEnvelope, warning } from "./result.js";
|
|
44
38
|
import { buildRuntime } from "./runtime.js";
|
|
45
|
-
import { getUpdateNotice, printHumanUpdateHint } from "./update-notifier.js";
|
|
46
39
|
import { streamTask } from "./stream.js";
|
|
47
40
|
import { toTaskView } from "./task-view.js";
|
|
48
41
|
import { beginOperation, credentialBinding, credentialFingerprint, newOperationId, operationsRoot, payloadFingerprint, updateOperation, } from "./operation-store.js";
|
|
49
42
|
import { originOf } from "./config.js";
|
|
50
|
-
import {
|
|
43
|
+
import { freezeRoot, looksLikeFile, resolveWithinRoot } from "./paths.js";
|
|
51
44
|
import { assertProjectMetadataPresent, indexRootFor, projectRecordCommand, recordTask, saveTaskSnapshot, stageFromTaskType } from "./project-store.js";
|
|
52
45
|
import { existsSync } from "node:fs";
|
|
53
46
|
import { dirname, join, resolve as resolvePath } from "node:path";
|
|
54
47
|
const TASK_JSON_OPTIONS = (cmd) => cmd
|
|
48
|
+
.addOption(outputOption())
|
|
49
|
+
.addOption(allAssetsOption())
|
|
55
50
|
.option("--save-json <file>", "save the full task JSON as received (never overwrites)")
|
|
56
|
-
.option("--include-raw", "
|
|
51
|
+
.option("--include-raw", "include the untouched task response under result.task.raw")
|
|
57
52
|
.option("--project <dir>", "initialised meshy_output project: save task_<id>.json there and record the task in metadata.json")
|
|
58
53
|
.option("--stage <name>", "stage label for the project record (default: derived from the task type, e.g. preview | refine | build)");
|
|
59
54
|
const NOT_REQUESTED = () => ({ state: "not_requested", files: [], metadata_path: null });
|
|
@@ -69,9 +64,9 @@ function taskResult(o) {
|
|
|
69
64
|
function nextCommands(descriptor, taskId) {
|
|
70
65
|
const base = `meshy ${descriptor.commandPath.join(" ")}`;
|
|
71
66
|
return {
|
|
72
|
-
get: `${base} get ${taskId}
|
|
73
|
-
wait: `${base} wait ${taskId}
|
|
74
|
-
stream: `${base} stream ${taskId} --format ndjson
|
|
67
|
+
get: `${base} get ${taskId}`,
|
|
68
|
+
wait: `${base} wait ${taskId}`,
|
|
69
|
+
stream: `${base} stream ${taskId} --format ndjson`,
|
|
75
70
|
};
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
@@ -196,7 +191,7 @@ function attachToProject(opts, opened, descriptor, taskId, task, raw, extra, war
|
|
|
196
191
|
stage,
|
|
197
192
|
resource: descriptor.id,
|
|
198
193
|
taskType: task?.type ?? null,
|
|
199
|
-
endpoint: descriptor.
|
|
194
|
+
endpoint: descriptor.endpoint,
|
|
200
195
|
parentTaskId: parentTaskIdFromPayload(extra.payload ?? null),
|
|
201
196
|
status: task?.status ?? null,
|
|
202
197
|
taskJson: null,
|
|
@@ -228,8 +223,6 @@ function attachToProject(opts, opened, descriptor, taskId, task, raw, extra, war
|
|
|
228
223
|
const rec = recordTask(located, input, { root: indexRoot.root, skipIndex: indexRoot.skipIndex });
|
|
229
224
|
if (!rec.index.updated)
|
|
230
225
|
warnings.push(warning("index_dirty", `metadata.json committed but history.json was not updated: ${rec.index.error}; run \`meshy project rebuild-index\``));
|
|
231
|
-
if (rec.migrated_from_legacy)
|
|
232
|
-
warnings.push(warning("metadata_migrated", "legacy metadata.json migrated to schema_version 2 (backup kept beside it)"));
|
|
233
226
|
return { project_dir: projectDir, snapshot: snapshot?.path ?? null, stage, action: rec.action, index: rec.index };
|
|
234
227
|
}
|
|
235
228
|
catch (err) {
|
|
@@ -349,7 +342,6 @@ export function buildResourceCommand(spec) {
|
|
|
349
342
|
const descriptor = requireTaskResource(spec.name);
|
|
350
343
|
const endpointOf = spec.endpointOf ?? ((client) => client.endpointFor(descriptor));
|
|
351
344
|
const prefix = spec.commandPrefix ?? spec.name;
|
|
352
|
-
const defaultSchema = spec.defaultSchema ?? "legacy";
|
|
353
345
|
const cmd = new Command(spec.commandName ?? spec.name).description(spec.description);
|
|
354
346
|
// create
|
|
355
347
|
const createCmd = new Command("create").description(spec.create.description);
|
|
@@ -360,7 +352,7 @@ export function buildResourceCommand(spec) {
|
|
|
360
352
|
.addOption(new Option("--timeout <seconds>", "max seconds to poll in sync mode; the task keeps running after it (resume with `wait`; the API advises allowing up to 60 min)").default("600"))
|
|
361
353
|
.addOption(new Option("--operation-id <id>", "local journal id for this submission; repeating it returns the recorded outcome instead of submitting again (local record only, not a server idempotency key)"))
|
|
362
354
|
.action(async (opts, thisCmd) => {
|
|
363
|
-
const opened = openCommand(thisCmd, `${prefix}.create
|
|
355
|
+
const opened = openCommand(thisCmd, `${prefix}.create`);
|
|
364
356
|
const timeoutSeconds = parseTimeoutSeconds(opts.timeout ?? "600");
|
|
365
357
|
const runAsync = Boolean(opts.async);
|
|
366
358
|
const includeRaw = Boolean(opts.includeRaw);
|
|
@@ -369,45 +361,36 @@ export function buildResourceCommand(spec) {
|
|
|
369
361
|
// 1. Build and validate the payload — every local failure happens here, before the journal and the POST.
|
|
370
362
|
const data = parseJsonFlag(opts.data, "--data");
|
|
371
363
|
const flagPayload = spec.create.toPayload(opts);
|
|
372
|
-
const defaults = spec.create.toDefaults?.(opts) ?? {};
|
|
364
|
+
const defaults = spec.create.toDefaults?.(opts, data) ?? {};
|
|
373
365
|
const layers = [defaults, data, flagPayload];
|
|
374
366
|
let merged = mergePayload(...layers);
|
|
375
367
|
if (spec.create.nestedObjectKeys && spec.create.nestedObjectKeys.length > 0) {
|
|
376
368
|
merged = mergeNestedObjects(merged, layers, spec.create.nestedObjectKeys);
|
|
377
369
|
}
|
|
378
370
|
spec.create.validatePayload?.(merged, opts);
|
|
371
|
+
const payloadWarnings = spec.create.warnPayload?.(merged) ?? [];
|
|
379
372
|
const { payload } = await normalizeMediaPayload(merged, descriptor.mediaFields, { signal: abortSignal() });
|
|
380
373
|
logger.debug("create payload", redactForLog(payload));
|
|
381
374
|
// 2. Local targets that would fail after the POST are refused before it.
|
|
382
375
|
preflightLocalTargets(opts, opened);
|
|
383
376
|
// 3. Journal, then exactly one POST.
|
|
384
377
|
const submitted = await submitCreate(runtime, descriptor, endpoint, payload, opts.operationId ?? null);
|
|
385
|
-
const { taskId, raw: createRaw, operationId
|
|
378
|
+
const { taskId, raw: createRaw, operationId } = submitted;
|
|
379
|
+
const warnings = [...payloadWarnings, ...submitted.warnings];
|
|
386
380
|
const submission = { state: "accepted", operation_id: operationId, task_id: taskId, request_id: submitted.requestId };
|
|
387
381
|
if (runAsync) {
|
|
388
382
|
const ctx = { descriptor, taskId, task: null, raw: null, submission, includeRaw };
|
|
389
383
|
const savedJson = saveJsonInContext(opts, opened, createRaw, ctx);
|
|
390
384
|
const project = attachInContext(opts, opened, descriptor, taskId, null, null, { operationId, payload }, warnings, { ...ctx, savedJson });
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}), warnings), opened.format);
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
emit({
|
|
404
|
-
resource: spec.name,
|
|
405
|
-
task_id: taskId,
|
|
406
|
-
status: "PENDING",
|
|
407
|
-
hint: `meshy-cli ${descriptor.commandPath.join(" ")} wait ${taskId}`,
|
|
408
|
-
operation_id: operationId,
|
|
409
|
-
...(project ? { project_dir: project.project_dir } : {}),
|
|
410
|
-
}, { format: opened.format, file: undefined });
|
|
385
|
+
await emitEnvelope(okEnvelope(opened.command, taskResult({
|
|
386
|
+
task: null,
|
|
387
|
+
raw: null,
|
|
388
|
+
descriptor,
|
|
389
|
+
includeRaw: false,
|
|
390
|
+
submission,
|
|
391
|
+
savedJson,
|
|
392
|
+
extra: { task_id: taskId, next: nextCommands(descriptor, taskId), project },
|
|
393
|
+
}), warnings), opened.format);
|
|
411
394
|
return;
|
|
412
395
|
}
|
|
413
396
|
// 4. Sync: poll the id we just recorded.
|
|
@@ -416,7 +399,7 @@ export function buildResourceCommand(spec) {
|
|
|
416
399
|
cmd.addCommand(createCmd);
|
|
417
400
|
// get
|
|
418
401
|
TASK_JSON_OPTIONS(cmd.command("get <task-id>").description("Retrieve a single task by id (any status is a successful query)")).action(async (taskId, opts, thisCmd) => {
|
|
419
|
-
const opened = openCommand(thisCmd, `${prefix}.get
|
|
402
|
+
const opened = openCommand(thisCmd, `${prefix}.get`);
|
|
420
403
|
beginProjectContext(opts, opened);
|
|
421
404
|
const runtime = await buildRuntime(opened.flags);
|
|
422
405
|
const { task, raw } = await endpointOf(runtime.client).retrieveDetailed(taskId, { signal: abortSignal() });
|
|
@@ -426,25 +409,16 @@ export function buildResourceCommand(spec) {
|
|
|
426
409
|
const ctx = { descriptor, taskId, task, raw, submission, includeRaw };
|
|
427
410
|
const savedJson = saveJsonInContext(opts, opened, raw, ctx);
|
|
428
411
|
const project = attachInContext(opts, opened, descriptor, taskId, task, raw, {}, warnings, { ...ctx, savedJson });
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
// Legacy shape, same rule: a download failure still names the task.
|
|
435
|
-
try {
|
|
436
|
-
await emitLegacyOutcome(task, false, undefined, spec.name, runtime, { query: true });
|
|
437
|
-
}
|
|
438
|
-
catch (err) {
|
|
439
|
-
throw withTaskContext(err, { ...ctx, savedJson, extra: project ? { project } : {} });
|
|
440
|
-
}
|
|
412
|
+
const downloads = await maybeDownloadV1(opened, descriptor, task, raw, submission, warnings, { savedJson, includeRaw, project });
|
|
413
|
+
await emitEnvelope(okEnvelope(opened.command, taskResult({ task, raw, descriptor, includeRaw, submission, downloads, savedJson, extra: project ? { project } : {} }), warnings), opened.format);
|
|
414
|
+
return;
|
|
441
415
|
});
|
|
442
416
|
// wait
|
|
443
417
|
TASK_JSON_OPTIONS(cmd
|
|
444
418
|
.command("wait <task-id>")
|
|
445
419
|
.description("Poll until the task reaches a terminal status")
|
|
446
420
|
.option("--timeout <seconds>", "max seconds to wait (0 = a single query); the task keeps running after it — the API advises allowing up to 60 min", "600")).action(async (taskId, opts, thisCmd) => {
|
|
447
|
-
const opened = openCommand(thisCmd, `${prefix}.wait
|
|
421
|
+
const opened = openCommand(thisCmd, `${prefix}.wait`);
|
|
448
422
|
beginProjectContext(opts, opened);
|
|
449
423
|
const timeoutSeconds = parseTimeoutSeconds(opts.timeout ?? "600");
|
|
450
424
|
const runtime = await buildRuntime(opened.flags);
|
|
@@ -457,7 +431,7 @@ export function buildResourceCommand(spec) {
|
|
|
457
431
|
.description("Follow the task over Server-Sent Events until it is terminal")
|
|
458
432
|
.option("--timeout <seconds>", "total deadline for the stream", "600")
|
|
459
433
|
.option("--idle-timeout <seconds>", "abort when no bytes arrive for this long (keep-alives count)", "60")).action(async (taskId, opts, thisCmd) => {
|
|
460
|
-
const opened = openCommand(thisCmd, `${prefix}.stream
|
|
434
|
+
const opened = openCommand(thisCmd, `${prefix}.stream`);
|
|
461
435
|
beginProjectContext(opts, opened);
|
|
462
436
|
if (!descriptor.supports.stream)
|
|
463
437
|
throw new UsageError(`${spec.name} does not support stream`);
|
|
@@ -478,8 +452,8 @@ export function buildResourceCommand(spec) {
|
|
|
478
452
|
? "Cancel a task: PENDING is refunded, IN_PROGRESS is not; a finished task cannot be canceled (the task is kept as CANCELED, not deleted)"
|
|
479
453
|
: "Permanently delete a task (a PENDING task is refunded; an IN_PROGRESS one cannot be stopped and is refused with exit 14; a finished one is deleted without a refund)")
|
|
480
454
|
.action(async (taskId, _opts, thisCmd) => {
|
|
481
|
-
const opened = openCommand(thisCmd, `${prefix}.delete
|
|
482
|
-
|
|
455
|
+
const opened = openCommand(thisCmd, `${prefix}.delete`);
|
|
456
|
+
rejectOutputFlag(opened, undefined);
|
|
483
457
|
const runtime = await buildRuntime(opened.flags);
|
|
484
458
|
let raw;
|
|
485
459
|
try {
|
|
@@ -489,7 +463,7 @@ export function buildResourceCommand(spec) {
|
|
|
489
463
|
throw deleteFailure(err, taskId, nextCommands(descriptor, taskId).wait);
|
|
490
464
|
}
|
|
491
465
|
const outcome = cancels ? { deleted: false, canceled: true } : { deleted: true };
|
|
492
|
-
await emitResult(opened, { resource: spec.name,
|
|
466
|
+
await emitResult(opened, { resource: spec.name, endpoint: descriptor.endpoint, task_id: taskId, ...outcome, response: raw ?? null });
|
|
493
467
|
});
|
|
494
468
|
// list
|
|
495
469
|
if (spec.supportsList !== false && descriptor.supports.list) {
|
|
@@ -500,10 +474,10 @@ export function buildResourceCommand(spec) {
|
|
|
500
474
|
.option("--page-size <n>", "page size", "10")
|
|
501
475
|
.option("--sort-by <field>", "sort order (e.g. -created_at)", "-created_at")
|
|
502
476
|
.option("--save-json <file>", "save the raw list response (never overwrites)")
|
|
503
|
-
.option("--include-raw", "
|
|
477
|
+
.option("--include-raw", "include each raw task under items[].raw")
|
|
504
478
|
.action(async (opts, thisCmd) => {
|
|
505
|
-
const opened = openCommand(thisCmd, `${prefix}.list
|
|
506
|
-
|
|
479
|
+
const opened = openCommand(thisCmd, `${prefix}.list`);
|
|
480
|
+
rejectOutputFlag(opened, opts.saveJson);
|
|
507
481
|
const runtime = await buildRuntime(opened.flags);
|
|
508
482
|
const page = { page_num: Number(opts.page ?? 1), page_size: Number(opts.pageSize ?? 10), sort_by: String(opts.sortBy ?? "-created_at") };
|
|
509
483
|
if (!Number.isInteger(page.page_num) || page.page_num < 1)
|
|
@@ -513,12 +487,12 @@ export function buildResourceCommand(spec) {
|
|
|
513
487
|
const { tasks, raw } = await endpointOf(runtime.client).listDetailed(page, { signal: abortSignal() });
|
|
514
488
|
const savedJson = opts.saveJson ? saveRawJson(opts.saveJson, raw, { workspace: opened.flags.workspaceRoot }) : null;
|
|
515
489
|
const rawItems = Array.isArray(raw) ? raw : [];
|
|
516
|
-
await emitResult(opened,
|
|
490
|
+
await emitResult(opened, {
|
|
517
491
|
items: tasks.map((t, i) => toTaskView(rawItems[i] ?? t, { descriptor, includeRaw: Boolean(opts.includeRaw) })),
|
|
518
492
|
count: tasks.length,
|
|
519
493
|
page,
|
|
520
494
|
saved_json: savedJson,
|
|
521
|
-
}
|
|
495
|
+
});
|
|
522
496
|
});
|
|
523
497
|
}
|
|
524
498
|
else {
|
|
@@ -598,7 +572,7 @@ export async function submitCreate(runtime, descriptor, endpoint, payload, reque
|
|
|
598
572
|
const credential = credentialIdentityFor(runtime, apiOrigin);
|
|
599
573
|
const identity = {
|
|
600
574
|
resource: descriptor.id,
|
|
601
|
-
endpoint: descriptor.
|
|
575
|
+
endpoint: descriptor.endpoint,
|
|
602
576
|
apiOrigin,
|
|
603
577
|
credentialFingerprint: credential.fingerprint,
|
|
604
578
|
credentialVerified: credential.verified,
|
|
@@ -656,7 +630,7 @@ export async function submitCreate(runtime, descriptor, endpoint, payload, reque
|
|
|
656
630
|
recovery: {
|
|
657
631
|
action: "reconcile",
|
|
658
632
|
automatic: false,
|
|
659
|
-
command: `meshy ${descriptor.commandPath.join(" ")} list
|
|
633
|
+
command: `meshy ${descriptor.commandPath.join(" ")} list # then match operation ${operationId} by time/prompt before creating again`,
|
|
660
634
|
},
|
|
661
635
|
hint: resolveHint(operationId),
|
|
662
636
|
result: { submission: { state: "unknown", operation_id: operationId, task_id: null }, task: null, downloads: NOT_REQUESTED(), ...extra },
|
|
@@ -700,7 +674,7 @@ function replayExisting(record, descriptor, operationId, extra) {
|
|
|
700
674
|
throw new CliError({
|
|
701
675
|
code: "submission_unknown",
|
|
702
676
|
message: `operation ${operationId} is recorded as '${record.state}' since ${record.updated_at}; reconcile it before submitting again (nothing was sent now)`,
|
|
703
|
-
recovery: { action: "reconcile", automatic: false, command: `meshy ${descriptor.commandPath.join(" ")} list
|
|
677
|
+
recovery: { action: "reconcile", automatic: false, command: `meshy ${descriptor.commandPath.join(" ")} list` },
|
|
704
678
|
hint: resolveHint(operationId),
|
|
705
679
|
result: { submission: { state: "unknown", operation_id: operationId, task_id: record.task_id }, task: null, ...extra },
|
|
706
680
|
});
|
|
@@ -732,8 +706,8 @@ function attachSubmission(err, submission, warnings) {
|
|
|
732
706
|
return err;
|
|
733
707
|
}
|
|
734
708
|
/**
|
|
735
|
-
*
|
|
736
|
-
* confined to the workspace when one is set. A failure keeps the task in the
|
|
709
|
+
* `-o`: save a SUCCEEDED task's default selection (every asset with
|
|
710
|
+
* --all-assets), confined to the workspace when one is set. A failure keeps the task in the
|
|
737
711
|
* result — the assets are still on the server, the task still exists.
|
|
738
712
|
*/
|
|
739
713
|
async function maybeDownloadV1(opened, descriptor, task, raw, submission, warnings, ctx) {
|
|
@@ -743,14 +717,14 @@ async function maybeDownloadV1(opened, descriptor, task, raw, submission, warnin
|
|
|
743
717
|
if (task.status !== "SUCCEEDED")
|
|
744
718
|
return { state: "not_ready", files: [], metadata_path: null };
|
|
745
719
|
try {
|
|
746
|
-
const { files, metadataPath, materialLinks } = await withSpinner(opened.format, "Downloading assets", () =>
|
|
747
|
-
|
|
748
|
-
warnings.push(...materialLinks.warnings);
|
|
720
|
+
const { files, metadataPath, materialLinks, skipped, warnings: transferWarnings } = await withSpinner(opened.format, "Downloading assets", () => downloadTaskAssets(task, output, descriptor, { root: opened.flags.workspaceRoot, signal: abortSignal(), allAssets: opened.flags.allAssets }));
|
|
721
|
+
warnings.push(...transferWarnings.map((w) => warning(w.code, w.message)));
|
|
749
722
|
return {
|
|
750
723
|
state: "completed",
|
|
751
724
|
files: files.map((f) => ({ key: f.key, path: f.path, status: f.status, bytes: f.bytes, sha256: f.sha256, error: f.error })),
|
|
752
725
|
metadata_path: metadataPath,
|
|
753
726
|
material_links: materialLinks,
|
|
727
|
+
skipped,
|
|
754
728
|
};
|
|
755
729
|
}
|
|
756
730
|
catch (err) {
|
|
@@ -835,10 +809,6 @@ async function waitAndReport(opened, runtime, descriptor, endpoint, taskId, time
|
|
|
835
809
|
throw interruptedError(descriptor, taskId, task ? { task, raw } : seen.last, submission, opts, opened);
|
|
836
810
|
if (task === null) {
|
|
837
811
|
// The deadline passed before the first response arrived; the task id is all we know — and it is enough.
|
|
838
|
-
if (opened.schema !== "v1") {
|
|
839
|
-
emitLegacyTimeoutWithoutTask(taskId, descriptor.id, runtime);
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
812
|
throw new CliError({
|
|
843
813
|
code: "timed_out",
|
|
844
814
|
message: `task ${taskId} did not answer within ${timeoutSeconds}s (no status was received in time${poll.lastError ? `; ${poll.failedPolls} status request(s) failed, last: ${poll.lastError.message}` : ""}); the server keeps running it`,
|
|
@@ -851,18 +821,6 @@ async function waitAndReport(opened, runtime, descriptor, endpoint, taskId, time
|
|
|
851
821
|
const savedJson = saveJsonInContext(opts, opened, raw, ctx);
|
|
852
822
|
const project = attachInContext(opts, opened, descriptor, taskId, task, raw, { operationId: opts.__operationId ?? submission.operation_id ?? null, payload: opts.__payload ?? null }, warnings, { ...ctx, savedJson });
|
|
853
823
|
const projectExtra = project ? { project } : {};
|
|
854
|
-
if (opened.schema !== "v1") {
|
|
855
|
-
// The legacy reporter downloads too; whatever fails there — an asset host
|
|
856
|
-
// 503, a sidecar that cannot be published, Ctrl-C — the error still
|
|
857
|
-
// carries the accepted task id, the real submission and the resume command.
|
|
858
|
-
try {
|
|
859
|
-
await emitLegacyOutcome(task, timedOut, elapsed, descriptor.id, runtime, { query: false });
|
|
860
|
-
}
|
|
861
|
-
catch (err) {
|
|
862
|
-
throw withTaskContext(err, { ...ctx, savedJson, extra: { wait: waitInfo, ...projectExtra } });
|
|
863
|
-
}
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
824
|
if (timedOut) {
|
|
867
825
|
throw new CliError({
|
|
868
826
|
code: "timed_out",
|
|
@@ -892,20 +850,6 @@ export function retriedPolls(poll) {
|
|
|
892
850
|
export function retriedWarning(poll) {
|
|
893
851
|
return warning("poll_retried", `${poll.failedPolls} status request(s) failed transiently and were retried at the next poll (last: ${poll.lastError?.message ?? "unknown"})`);
|
|
894
852
|
}
|
|
895
|
-
/** Legacy shape for a wait that timed out before any status arrived: still the task id, still exit 8. */
|
|
896
|
-
function emitLegacyTimeoutWithoutTask(taskId, resourceName, runtime) {
|
|
897
|
-
if (runtime.flags.output) {
|
|
898
|
-
const report = { status: "FAIL", taskId, type: resourceName, timedOut: true };
|
|
899
|
-
const notice = getUpdateNotice();
|
|
900
|
-
if (notice)
|
|
901
|
-
report._notice = notice;
|
|
902
|
-
printReport(report);
|
|
903
|
-
}
|
|
904
|
-
else {
|
|
905
|
-
emit({ resource: resourceName, id: taskId, status: null, timed_out: true }, { format: runtime.flags.format });
|
|
906
|
-
}
|
|
907
|
-
process.exitCode = 8;
|
|
908
|
-
}
|
|
909
853
|
function interruptedError(descriptor, taskId, last, submission, opts, opened, savedJson = null) {
|
|
910
854
|
let saved = savedJson;
|
|
911
855
|
if (!saved && opts.saveJson && last) {
|
|
@@ -940,7 +884,7 @@ async function streamAndReport(opened, runtime, descriptor, endpoint, taskId, ti
|
|
|
940
884
|
},
|
|
941
885
|
onTask: async (task, raw) => {
|
|
942
886
|
progress.tick(task.status, task.progress);
|
|
943
|
-
if (
|
|
887
|
+
if (ndjson) {
|
|
944
888
|
sequence += 1;
|
|
945
889
|
const event = {
|
|
946
890
|
...okEnvelope(opened.command, taskResult({ task, raw, descriptor, includeRaw, submission })),
|
|
@@ -1008,20 +952,6 @@ async function streamAndReport(opened, runtime, descriptor, endpoint, taskId, ti
|
|
|
1008
952
|
finalError = bookkeepingError;
|
|
1009
953
|
}
|
|
1010
954
|
}
|
|
1011
|
-
if (opened.schema !== "v1") {
|
|
1012
|
-
// Legacy has no stream shape to preserve: reuse the terminal summary path (which honours -o itself).
|
|
1013
|
-
if (finalError)
|
|
1014
|
-
throw finalError;
|
|
1015
|
-
if (outcome.task) {
|
|
1016
|
-
try {
|
|
1017
|
-
await emitLegacyOutcome(outcome.task, false, outcome.elapsedMs / 1000, descriptor.id, runtime, { query: false });
|
|
1018
|
-
}
|
|
1019
|
-
catch (err) {
|
|
1020
|
-
throw withTaskContext(err, { ...ctx, savedJson, extra: { stream: streamInfo, ...projectExtra } });
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
1025
955
|
// The terminal outcome includes the requested download whatever the output
|
|
1026
956
|
// format: `-o` means "put the assets on disk", not "only when printing JSON".
|
|
1027
957
|
if (!finalError && outcome.task && outcome.task.status === "SUCCEEDED") {
|
|
@@ -1057,81 +987,6 @@ function wrapStreamError(err, result, warnings) {
|
|
|
1057
987
|
}
|
|
1058
988
|
return new CliError({ code: "protocol", message: "stream ended abnormally", result, warnings });
|
|
1059
989
|
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Legacy reporter. `query: true` is `get`: a valid task is a successful query
|
|
1062
|
-
* whatever its status (0.2.0 exited 1 for PENDING/IN_PROGRESS — fixed); a
|
|
1063
|
-
* terminal FAILED/CANCELED still exits 1 for compatibility.
|
|
1064
|
-
*/
|
|
1065
|
-
async function emitLegacyOutcome(task, timedOut, elapsedSeconds, resourceName, runtime, mode) {
|
|
1066
|
-
const output = runtime.flags.output;
|
|
1067
|
-
const succeeded = !timedOut && task.status === "SUCCEEDED";
|
|
1068
|
-
const pretty = runtime.flags.format === "pretty";
|
|
1069
|
-
if (output) {
|
|
1070
|
-
if (succeeded) {
|
|
1071
|
-
const { savedFiles, metadataPath } = await withSpinner(runtime.flags.format, "Downloading assets", () => downloadArtifacts(task, output, resourceName, { root: runtime.flags.workspaceRoot, signal: abortSignal() }));
|
|
1072
|
-
if (pretty) {
|
|
1073
|
-
printTaskCard(task, savedFiles);
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
const successReport = {
|
|
1077
|
-
status: "SUCCESS",
|
|
1078
|
-
taskId: task.id,
|
|
1079
|
-
type: task.type || resourceName,
|
|
1080
|
-
savedFiles,
|
|
1081
|
-
metadataPath,
|
|
1082
|
-
};
|
|
1083
|
-
const successNotice = getUpdateNotice();
|
|
1084
|
-
if (successNotice)
|
|
1085
|
-
successReport._notice = successNotice;
|
|
1086
|
-
printReport(successReport);
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
const report = {
|
|
1090
|
-
status: "FAIL",
|
|
1091
|
-
taskId: task.id,
|
|
1092
|
-
type: task.type || resourceName,
|
|
1093
|
-
};
|
|
1094
|
-
if (timedOut)
|
|
1095
|
-
report.timedOut = true;
|
|
1096
|
-
else if (task.task_error?.message)
|
|
1097
|
-
report.error = task.task_error.message;
|
|
1098
|
-
else if (task.status)
|
|
1099
|
-
report.error = `task status: ${task.status}`;
|
|
1100
|
-
const failNotice = getUpdateNotice();
|
|
1101
|
-
if (failNotice)
|
|
1102
|
-
report._notice = failNotice;
|
|
1103
|
-
if (pretty)
|
|
1104
|
-
printTaskCard(task, []);
|
|
1105
|
-
else
|
|
1106
|
-
printReport(report);
|
|
1107
|
-
if (timedOut)
|
|
1108
|
-
process.exitCode = 8;
|
|
1109
|
-
else if (mode.query && !isTerminalStatus(task.status))
|
|
1110
|
-
process.exitCode = 0;
|
|
1111
|
-
else
|
|
1112
|
-
process.exitCode = 1;
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
emit({
|
|
1116
|
-
resource: resourceName,
|
|
1117
|
-
...summarizeTask(task, elapsedSeconds),
|
|
1118
|
-
...(timedOut ? { timed_out: true } : {}),
|
|
1119
|
-
}, { format: runtime.flags.format });
|
|
1120
|
-
if (timedOut)
|
|
1121
|
-
process.exitCode = 8;
|
|
1122
|
-
else if (task.status === "SUCCEEDED")
|
|
1123
|
-
process.exitCode = 0;
|
|
1124
|
-
else if (!isTerminalStatus(task.status))
|
|
1125
|
-
process.exitCode = mode.query ? 0 : 1;
|
|
1126
|
-
else
|
|
1127
|
-
process.exitCode = 1;
|
|
1128
|
-
}
|
|
1129
|
-
/** Kept for make.ts (legacy path). */
|
|
1130
|
-
/** The `-o` report for a person: the task card with the files it saved, the update hint on stderr. */
|
|
1131
|
-
function printTaskCard(task, saved) {
|
|
1132
|
-
process.stdout.write(`${taskCard(toTaskView(task), painterFor(process.stdout), { saved }).join("\n")}\n`);
|
|
1133
|
-
printHumanUpdateHint(getUpdateNotice(), process);
|
|
1134
|
-
}
|
|
1135
990
|
/** Freeze the progress line with how the wait or stream ended. */
|
|
1136
991
|
function endProgress(progress, task, timedOut, abandoned) {
|
|
1137
992
|
if (abandoned)
|
|
@@ -1143,8 +998,5 @@ function endProgress(progress, task, timedOut, abandoned) {
|
|
|
1143
998
|
else
|
|
1144
999
|
progress.finish("failed", task?.status ?? "no status received");
|
|
1145
1000
|
}
|
|
1146
|
-
export async function emitTerminalOutcome(task, timedOut, elapsedSeconds, resourceName, runtime) {
|
|
1147
|
-
await emitLegacyOutcome(task, timedOut, elapsedSeconds, resourceName, runtime, { query: false });
|
|
1148
|
-
}
|
|
1149
1001
|
export { taskResult as buildTaskResult, nextCommands as taskNextCommands };
|
|
1150
1002
|
//# sourceMappingURL=task-command.js.map
|