@meshy-ai/cli 0.4.6 → 0.5.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 +5 -3
- package/dist/client/types.d.ts +0 -18
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js +0 -28
- 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.map +1 -1
- package/dist/cmd/creative-lab.js +0 -3
- 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.js +7 -7
- package/dist/cmd/download.js.map +1 -1
- package/dist/cmd/inspect.d.ts.map +1 -1
- package/dist/cmd/inspect.js +4 -4
- package/dist/cmd/inspect.js.map +1 -1
- package/dist/cmd/make.d.ts.map +1 -1
- package/dist/cmd/make.js +31 -99
- package/dist/cmd/make.js.map +1 -1
- package/dist/cmd/mesh.js +2 -2
- package/dist/cmd/mesh.js.map +1 -1
- package/dist/cmd/operations.js +6 -6
- package/dist/cmd/operations.js.map +1 -1
- package/dist/cmd/project.js +10 -10
- 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 -14
- package/dist/cmd/resources.js.map +1 -1
- 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/usage.js +4 -4
- package/dist/cmd/usage.js.map +1 -1
- package/dist/cmd/uv-unwrap.d.ts.map +1 -1
- package/dist/cmd/uv-unwrap.js +0 -1
- package/dist/cmd/uv-unwrap.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -47
- package/dist/index.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/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/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/global-options.d.ts.map +1 -1
- package/dist/internal/global-options.js +4 -1
- package/dist/internal/global-options.js.map +1 -1
- package/dist/internal/inspect.js +1 -1
- package/dist/internal/inspect.js.map +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/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 +2 -10
- package/dist/internal/runtime.d.ts.map +1 -1
- package/dist/internal/runtime.js +9 -16
- package/dist/internal/runtime.js.map +1 -1
- package/dist/internal/slicers.js +2 -2
- package/dist/internal/slicers.js.map +1 -1
- package/dist/internal/task-command.d.ts +5 -11
- package/dist/internal/task-command.d.ts.map +1 -1
- package/dist/internal/task-command.js +38 -189
- package/dist/internal/task-command.js.map +1 -1
- 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 +7 -8
- package/dist/internal/views.d.ts.map +1 -1
- package/dist/internal/views.js +24 -9
- 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 +0 -20
- package/dist/root.js.map +1 -1
- package/package.json +1 -1
- package/skills/meshy-cli/SKILL.md +39 -42
- 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,23 +23,18 @@ 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
28
|
import { downloadArtifacts, looksLikeFile } from "./download.js";
|
|
33
29
|
import { classifyError, CliError, UsageError } from "./errors.js";
|
|
34
30
|
import { normalizeMediaPayload } from "./file-input.js";
|
|
35
31
|
import { logger } from "./logger.js";
|
|
36
32
|
import { mergeNestedObjects, mergePayload, parseJsonFlag } from "./payload.js";
|
|
37
|
-
import {
|
|
38
|
-
import { taskCard } from "./views.js";
|
|
39
|
-
import { emitEnvelope, emitStreamEvent, emit } from "./output.js";
|
|
33
|
+
import { emitEnvelope, emitStreamEvent } from "./output.js";
|
|
40
34
|
import { parseTimeoutSeconds, pollUntilTerminal } from "./poll.js";
|
|
41
35
|
import { createProgress, withSpinner } from "./progress.js";
|
|
42
|
-
import { printReport } from "./report.js";
|
|
43
36
|
import { errorEnvelope, okEnvelope, warning } from "./result.js";
|
|
44
37
|
import { buildRuntime } from "./runtime.js";
|
|
45
|
-
import { getUpdateNotice, printHumanUpdateHint } from "./update-notifier.js";
|
|
46
38
|
import { streamTask } from "./stream.js";
|
|
47
39
|
import { toTaskView } from "./task-view.js";
|
|
48
40
|
import { beginOperation, credentialBinding, credentialFingerprint, newOperationId, operationsRoot, payloadFingerprint, updateOperation, } from "./operation-store.js";
|
|
@@ -53,7 +45,7 @@ import { existsSync } from "node:fs";
|
|
|
53
45
|
import { dirname, join, resolve as resolvePath } from "node:path";
|
|
54
46
|
const TASK_JSON_OPTIONS = (cmd) => cmd
|
|
55
47
|
.option("--save-json <file>", "save the full task JSON as received (never overwrites)")
|
|
56
|
-
.option("--include-raw", "
|
|
48
|
+
.option("--include-raw", "include the untouched task response under result.task.raw")
|
|
57
49
|
.option("--project <dir>", "initialised meshy_output project: save task_<id>.json there and record the task in metadata.json")
|
|
58
50
|
.option("--stage <name>", "stage label for the project record (default: derived from the task type, e.g. preview | refine | build)");
|
|
59
51
|
const NOT_REQUESTED = () => ({ state: "not_requested", files: [], metadata_path: null });
|
|
@@ -69,9 +61,9 @@ function taskResult(o) {
|
|
|
69
61
|
function nextCommands(descriptor, taskId) {
|
|
70
62
|
const base = `meshy ${descriptor.commandPath.join(" ")}`;
|
|
71
63
|
return {
|
|
72
|
-
get: `${base} get ${taskId}
|
|
73
|
-
wait: `${base} wait ${taskId}
|
|
74
|
-
stream: `${base} stream ${taskId} --format ndjson
|
|
64
|
+
get: `${base} get ${taskId}`,
|
|
65
|
+
wait: `${base} wait ${taskId}`,
|
|
66
|
+
stream: `${base} stream ${taskId} --format ndjson`,
|
|
75
67
|
};
|
|
76
68
|
}
|
|
77
69
|
/**
|
|
@@ -349,7 +341,6 @@ export function buildResourceCommand(spec) {
|
|
|
349
341
|
const descriptor = requireTaskResource(spec.name);
|
|
350
342
|
const endpointOf = spec.endpointOf ?? ((client) => client.endpointFor(descriptor));
|
|
351
343
|
const prefix = spec.commandPrefix ?? spec.name;
|
|
352
|
-
const defaultSchema = spec.defaultSchema ?? "legacy";
|
|
353
344
|
const cmd = new Command(spec.commandName ?? spec.name).description(spec.description);
|
|
354
345
|
// create
|
|
355
346
|
const createCmd = new Command("create").description(spec.create.description);
|
|
@@ -360,7 +351,7 @@ export function buildResourceCommand(spec) {
|
|
|
360
351
|
.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
352
|
.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
353
|
.action(async (opts, thisCmd) => {
|
|
363
|
-
const opened = openCommand(thisCmd, `${prefix}.create
|
|
354
|
+
const opened = openCommand(thisCmd, `${prefix}.create`);
|
|
364
355
|
const timeoutSeconds = parseTimeoutSeconds(opts.timeout ?? "600");
|
|
365
356
|
const runAsync = Boolean(opts.async);
|
|
366
357
|
const includeRaw = Boolean(opts.includeRaw);
|
|
@@ -388,26 +379,15 @@ export function buildResourceCommand(spec) {
|
|
|
388
379
|
const ctx = { descriptor, taskId, task: null, raw: null, submission, includeRaw };
|
|
389
380
|
const savedJson = saveJsonInContext(opts, opened, createRaw, ctx);
|
|
390
381
|
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 });
|
|
382
|
+
await emitEnvelope(okEnvelope(opened.command, taskResult({
|
|
383
|
+
task: null,
|
|
384
|
+
raw: null,
|
|
385
|
+
descriptor,
|
|
386
|
+
includeRaw: false,
|
|
387
|
+
submission,
|
|
388
|
+
savedJson,
|
|
389
|
+
extra: { task_id: taskId, next: nextCommands(descriptor, taskId), project },
|
|
390
|
+
}), warnings), opened.format);
|
|
411
391
|
return;
|
|
412
392
|
}
|
|
413
393
|
// 4. Sync: poll the id we just recorded.
|
|
@@ -416,7 +396,7 @@ export function buildResourceCommand(spec) {
|
|
|
416
396
|
cmd.addCommand(createCmd);
|
|
417
397
|
// get
|
|
418
398
|
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
|
|
399
|
+
const opened = openCommand(thisCmd, `${prefix}.get`);
|
|
420
400
|
beginProjectContext(opts, opened);
|
|
421
401
|
const runtime = await buildRuntime(opened.flags);
|
|
422
402
|
const { task, raw } = await endpointOf(runtime.client).retrieveDetailed(taskId, { signal: abortSignal() });
|
|
@@ -426,25 +406,16 @@ export function buildResourceCommand(spec) {
|
|
|
426
406
|
const ctx = { descriptor, taskId, task, raw, submission, includeRaw };
|
|
427
407
|
const savedJson = saveJsonInContext(opts, opened, raw, ctx);
|
|
428
408
|
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
|
-
}
|
|
409
|
+
const downloads = await maybeDownloadV1(opened, descriptor, task, raw, submission, warnings, { savedJson, includeRaw, project });
|
|
410
|
+
await emitEnvelope(okEnvelope(opened.command, taskResult({ task, raw, descriptor, includeRaw, submission, downloads, savedJson, extra: project ? { project } : {} }), warnings), opened.format);
|
|
411
|
+
return;
|
|
441
412
|
});
|
|
442
413
|
// wait
|
|
443
414
|
TASK_JSON_OPTIONS(cmd
|
|
444
415
|
.command("wait <task-id>")
|
|
445
416
|
.description("Poll until the task reaches a terminal status")
|
|
446
417
|
.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
|
|
418
|
+
const opened = openCommand(thisCmd, `${prefix}.wait`);
|
|
448
419
|
beginProjectContext(opts, opened);
|
|
449
420
|
const timeoutSeconds = parseTimeoutSeconds(opts.timeout ?? "600");
|
|
450
421
|
const runtime = await buildRuntime(opened.flags);
|
|
@@ -457,7 +428,7 @@ export function buildResourceCommand(spec) {
|
|
|
457
428
|
.description("Follow the task over Server-Sent Events until it is terminal")
|
|
458
429
|
.option("--timeout <seconds>", "total deadline for the stream", "600")
|
|
459
430
|
.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
|
|
431
|
+
const opened = openCommand(thisCmd, `${prefix}.stream`);
|
|
461
432
|
beginProjectContext(opts, opened);
|
|
462
433
|
if (!descriptor.supports.stream)
|
|
463
434
|
throw new UsageError(`${spec.name} does not support stream`);
|
|
@@ -478,8 +449,8 @@ export function buildResourceCommand(spec) {
|
|
|
478
449
|
? "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
450
|
: "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
451
|
.action(async (taskId, _opts, thisCmd) => {
|
|
481
|
-
const opened = openCommand(thisCmd, `${prefix}.delete
|
|
482
|
-
|
|
452
|
+
const opened = openCommand(thisCmd, `${prefix}.delete`);
|
|
453
|
+
rejectOutputFlag(opened, undefined);
|
|
483
454
|
const runtime = await buildRuntime(opened.flags);
|
|
484
455
|
let raw;
|
|
485
456
|
try {
|
|
@@ -489,7 +460,7 @@ export function buildResourceCommand(spec) {
|
|
|
489
460
|
throw deleteFailure(err, taskId, nextCommands(descriptor, taskId).wait);
|
|
490
461
|
}
|
|
491
462
|
const outcome = cancels ? { deleted: false, canceled: true } : { deleted: true };
|
|
492
|
-
await emitResult(opened, { resource: spec.name,
|
|
463
|
+
await emitResult(opened, { resource: spec.name, endpoint: descriptor.legacyEndpoint, task_id: taskId, ...outcome, response: raw ?? null });
|
|
493
464
|
});
|
|
494
465
|
// list
|
|
495
466
|
if (spec.supportsList !== false && descriptor.supports.list) {
|
|
@@ -500,10 +471,10 @@ export function buildResourceCommand(spec) {
|
|
|
500
471
|
.option("--page-size <n>", "page size", "10")
|
|
501
472
|
.option("--sort-by <field>", "sort order (e.g. -created_at)", "-created_at")
|
|
502
473
|
.option("--save-json <file>", "save the raw list response (never overwrites)")
|
|
503
|
-
.option("--include-raw", "
|
|
474
|
+
.option("--include-raw", "include each raw task under items[].raw")
|
|
504
475
|
.action(async (opts, thisCmd) => {
|
|
505
|
-
const opened = openCommand(thisCmd, `${prefix}.list
|
|
506
|
-
|
|
476
|
+
const opened = openCommand(thisCmd, `${prefix}.list`);
|
|
477
|
+
rejectOutputFlag(opened, opts.saveJson);
|
|
507
478
|
const runtime = await buildRuntime(opened.flags);
|
|
508
479
|
const page = { page_num: Number(opts.page ?? 1), page_size: Number(opts.pageSize ?? 10), sort_by: String(opts.sortBy ?? "-created_at") };
|
|
509
480
|
if (!Number.isInteger(page.page_num) || page.page_num < 1)
|
|
@@ -513,12 +484,12 @@ export function buildResourceCommand(spec) {
|
|
|
513
484
|
const { tasks, raw } = await endpointOf(runtime.client).listDetailed(page, { signal: abortSignal() });
|
|
514
485
|
const savedJson = opts.saveJson ? saveRawJson(opts.saveJson, raw, { workspace: opened.flags.workspaceRoot }) : null;
|
|
515
486
|
const rawItems = Array.isArray(raw) ? raw : [];
|
|
516
|
-
await emitResult(opened,
|
|
487
|
+
await emitResult(opened, {
|
|
517
488
|
items: tasks.map((t, i) => toTaskView(rawItems[i] ?? t, { descriptor, includeRaw: Boolean(opts.includeRaw) })),
|
|
518
489
|
count: tasks.length,
|
|
519
490
|
page,
|
|
520
491
|
saved_json: savedJson,
|
|
521
|
-
}
|
|
492
|
+
});
|
|
522
493
|
});
|
|
523
494
|
}
|
|
524
495
|
else {
|
|
@@ -656,7 +627,7 @@ export async function submitCreate(runtime, descriptor, endpoint, payload, reque
|
|
|
656
627
|
recovery: {
|
|
657
628
|
action: "reconcile",
|
|
658
629
|
automatic: false,
|
|
659
|
-
command: `meshy ${descriptor.commandPath.join(" ")} list
|
|
630
|
+
command: `meshy ${descriptor.commandPath.join(" ")} list # then match operation ${operationId} by time/prompt before creating again`,
|
|
660
631
|
},
|
|
661
632
|
hint: resolveHint(operationId),
|
|
662
633
|
result: { submission: { state: "unknown", operation_id: operationId, task_id: null }, task: null, downloads: NOT_REQUESTED(), ...extra },
|
|
@@ -700,7 +671,7 @@ function replayExisting(record, descriptor, operationId, extra) {
|
|
|
700
671
|
throw new CliError({
|
|
701
672
|
code: "submission_unknown",
|
|
702
673
|
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
|
|
674
|
+
recovery: { action: "reconcile", automatic: false, command: `meshy ${descriptor.commandPath.join(" ")} list` },
|
|
704
675
|
hint: resolveHint(operationId),
|
|
705
676
|
result: { submission: { state: "unknown", operation_id: operationId, task_id: record.task_id }, task: null, ...extra },
|
|
706
677
|
});
|
|
@@ -732,7 +703,7 @@ function attachSubmission(err, submission, warnings) {
|
|
|
732
703
|
return err;
|
|
733
704
|
}
|
|
734
705
|
/**
|
|
735
|
-
*
|
|
706
|
+
* `-o`: download a SUCCEEDED task's assets through the 0.2.0 file layout,
|
|
736
707
|
* confined to the workspace when one is set. A failure keeps the task in the
|
|
737
708
|
* result — the assets are still on the server, the task still exists.
|
|
738
709
|
*/
|
|
@@ -835,10 +806,6 @@ async function waitAndReport(opened, runtime, descriptor, endpoint, taskId, time
|
|
|
835
806
|
throw interruptedError(descriptor, taskId, task ? { task, raw } : seen.last, submission, opts, opened);
|
|
836
807
|
if (task === null) {
|
|
837
808
|
// 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
809
|
throw new CliError({
|
|
843
810
|
code: "timed_out",
|
|
844
811
|
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 +818,6 @@ async function waitAndReport(opened, runtime, descriptor, endpoint, taskId, time
|
|
|
851
818
|
const savedJson = saveJsonInContext(opts, opened, raw, ctx);
|
|
852
819
|
const project = attachInContext(opts, opened, descriptor, taskId, task, raw, { operationId: opts.__operationId ?? submission.operation_id ?? null, payload: opts.__payload ?? null }, warnings, { ...ctx, savedJson });
|
|
853
820
|
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
821
|
if (timedOut) {
|
|
867
822
|
throw new CliError({
|
|
868
823
|
code: "timed_out",
|
|
@@ -892,20 +847,6 @@ export function retriedPolls(poll) {
|
|
|
892
847
|
export function retriedWarning(poll) {
|
|
893
848
|
return warning("poll_retried", `${poll.failedPolls} status request(s) failed transiently and were retried at the next poll (last: ${poll.lastError?.message ?? "unknown"})`);
|
|
894
849
|
}
|
|
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
850
|
function interruptedError(descriptor, taskId, last, submission, opts, opened, savedJson = null) {
|
|
910
851
|
let saved = savedJson;
|
|
911
852
|
if (!saved && opts.saveJson && last) {
|
|
@@ -940,7 +881,7 @@ async function streamAndReport(opened, runtime, descriptor, endpoint, taskId, ti
|
|
|
940
881
|
},
|
|
941
882
|
onTask: async (task, raw) => {
|
|
942
883
|
progress.tick(task.status, task.progress);
|
|
943
|
-
if (
|
|
884
|
+
if (ndjson) {
|
|
944
885
|
sequence += 1;
|
|
945
886
|
const event = {
|
|
946
887
|
...okEnvelope(opened.command, taskResult({ task, raw, descriptor, includeRaw, submission })),
|
|
@@ -1008,20 +949,6 @@ async function streamAndReport(opened, runtime, descriptor, endpoint, taskId, ti
|
|
|
1008
949
|
finalError = bookkeepingError;
|
|
1009
950
|
}
|
|
1010
951
|
}
|
|
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
952
|
// The terminal outcome includes the requested download whatever the output
|
|
1026
953
|
// format: `-o` means "put the assets on disk", not "only when printing JSON".
|
|
1027
954
|
if (!finalError && outcome.task && outcome.task.status === "SUCCEEDED") {
|
|
@@ -1057,81 +984,6 @@ function wrapStreamError(err, result, warnings) {
|
|
|
1057
984
|
}
|
|
1058
985
|
return new CliError({ code: "protocol", message: "stream ended abnormally", result, warnings });
|
|
1059
986
|
}
|
|
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
987
|
/** Freeze the progress line with how the wait or stream ended. */
|
|
1136
988
|
function endProgress(progress, task, timedOut, abandoned) {
|
|
1137
989
|
if (abandoned)
|
|
@@ -1143,8 +995,5 @@ function endProgress(progress, task, timedOut, abandoned) {
|
|
|
1143
995
|
else
|
|
1144
996
|
progress.finish("failed", task?.status ?? "no status received");
|
|
1145
997
|
}
|
|
1146
|
-
export async function emitTerminalOutcome(task, timedOut, elapsedSeconds, resourceName, runtime) {
|
|
1147
|
-
await emitLegacyOutcome(task, timedOut, elapsedSeconds, resourceName, runtime, { query: false });
|
|
1148
|
-
}
|
|
1149
998
|
export { taskResult as buildTaskResult, nextCommands as taskNextCommands };
|
|
1150
999
|
//# sourceMappingURL=task-command.js.map
|