@toothfairyai/tfdesign 0.4.5 → 0.4.7

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 (2) hide show
  1. package/dist/cli.js +18 -11
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1076,6 +1076,7 @@ async function runDesignRun(rawArgs) {
1076
1076
  process.exit(130);
1077
1077
  });
1078
1078
  let outcome;
1079
+ let result;
1079
1080
  try {
1080
1081
  outcome = await driveRounds({
1081
1082
  base,
@@ -1095,6 +1096,13 @@ async function runDesignRun(rawArgs) {
1095
1096
  },
1096
1097
  isCanceled: () => canceled
1097
1098
  });
1099
+ if (outcome.status === "succeeded") {
1100
+ result = await buildResult(base, project, conversationId, {
1101
+ rounds: outcome.rounds,
1102
+ finalText: outcome.finalText,
1103
+ mirrorRoot
1104
+ });
1105
+ }
1098
1106
  } finally {
1099
1107
  if (daemon.booted && daemon.server) {
1100
1108
  daemon.server.close?.();
@@ -1104,11 +1112,6 @@ async function runDesignRun(rawArgs) {
1104
1112
  if (outcome.status === "canceled") process.exit(130);
1105
1113
  if (outcome.status === "failed") process.exit(4);
1106
1114
  if (outcome.status === "unanswered") process.exit(5);
1107
- const result = await buildResult(base, project, conversationId, {
1108
- rounds: outcome.rounds,
1109
- finalText: outcome.finalText,
1110
- mirrorRoot
1111
- });
1112
1115
  emit({ type: "result", ...result });
1113
1116
  if (!json) printResultSummary(result);
1114
1117
  if (flags.open === true && result.previewUrl) {
@@ -1634,16 +1637,20 @@ function resolveOption(input, options) {
1634
1637
  }
1635
1638
  async function buildResult(base, project, conversationId, { rounds, finalText, mirrorRoot }) {
1636
1639
  const projectId = project.id;
1637
- const [projectData, filesData] = await Promise.all([
1640
+ const filesUrl = `${base}/api/projects/${encodeURIComponent(projectId)}/files`;
1641
+ const fetchFiles = async () => (await getJson(filesUrl).catch(() => null))?.files ?? [];
1642
+ let filesRaw = await fetchFiles();
1643
+ for (let wait = 0; filesRaw.length === 0 && wait < 10; wait++) {
1644
+ await new Promise((r) => setTimeout(r, 500));
1645
+ filesRaw = await fetchFiles();
1646
+ }
1647
+ const [projectData] = await Promise.all([
1638
1648
  getJson(`${base}/api/projects/${encodeURIComponent(projectId)}`).catch(
1639
1649
  () => null
1640
- ),
1641
- getJson(
1642
- `${base}/api/projects/${encodeURIComponent(projectId)}/files`
1643
- ).catch(() => null)
1650
+ )
1644
1651
  ]);
1645
1652
  const record = projectData?.project ?? projectData ?? project;
1646
- const files = (filesData?.files ?? []).filter(
1653
+ const files = filesRaw.filter(
1647
1654
  (f) => typeof f?.name === "string" && f.name.length > 0 && !f.name.split("/").some((s) => s.startsWith("."))
1648
1655
  );
1649
1656
  let entryFile = record?.metadata?.entryFile ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toothfairyai/tfdesign",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "TF Design — the local design workspace CLI: headless design runs (decks, posters, sites) through the tfdesign daemon, delegable from tfcode.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",