@riddledc/riddle-proof 0.7.113 → 0.7.114

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.
@@ -14,6 +14,9 @@ var RiddleApiError = class extends Error {
14
14
  this.path = pathname;
15
15
  }
16
16
  };
17
+ var PREVIEW_PUBLISH_RECOVERY_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
18
+ var PREVIEW_PUBLISH_RECOVERY_ATTEMPTS = 30;
19
+ var PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS = 2e3;
17
20
  function normalizeBaseUrl(value) {
18
21
  return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
19
22
  }
@@ -48,6 +51,45 @@ async function riddleRequestJson(config, pathname, init = {}) {
48
51
  if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
49
52
  return json ?? text;
50
53
  }
54
+ function previewDeployResultFromRecord(input) {
55
+ const { record, id, label, framework, expiresAt, publishRecovered, publishError } = input;
56
+ return {
57
+ ok: true,
58
+ id: String(record.id || record.preview_id || id),
59
+ label,
60
+ framework,
61
+ preview_url: String(record.preview_url || ""),
62
+ file_count: typeof record.file_count === "number" ? record.file_count : void 0,
63
+ total_bytes: typeof record.total_bytes === "number" ? record.total_bytes : void 0,
64
+ expires_at: expiresAt,
65
+ publish_recovered: publishRecovered || void 0,
66
+ publish_error: publishError,
67
+ raw: record
68
+ };
69
+ }
70
+ function canRecoverPreviewPublish(error) {
71
+ return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
72
+ }
73
+ async function waitForPublishedPreview(config, input) {
74
+ for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
75
+ const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
76
+ if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
77
+ return previewDeployResultFromRecord({
78
+ record: status,
79
+ id: input.id,
80
+ label: input.label,
81
+ framework: input.framework,
82
+ expiresAt: input.expiresAt,
83
+ publishRecovered: true,
84
+ publishError: input.publishError.message
85
+ });
86
+ }
87
+ if (attempt < PREVIEW_PUBLISH_RECOVERY_ATTEMPTS) {
88
+ await new Promise((resolve) => setTimeout(resolve, PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS));
89
+ }
90
+ }
91
+ throw input.publishError;
92
+ }
51
93
  async function deployRiddlePreview(config, directory, label, framework = "static") {
52
94
  if (!directory?.trim()) throw new Error("directory is required");
53
95
  if (!label?.trim()) throw new Error("label is required");
@@ -74,20 +116,22 @@ async function deployRiddlePreview(config, directory, label, framework = "static
74
116
  } finally {
75
117
  rmSync(scratch, { recursive: true, force: true });
76
118
  }
77
- const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
78
- method: "POST"
79
- });
80
- return {
81
- ok: true,
82
- id: String(published.id || id),
83
- label,
84
- framework,
85
- preview_url: String(published.preview_url || ""),
86
- file_count: typeof published.file_count === "number" ? published.file_count : void 0,
87
- total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
88
- expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
89
- raw: published
90
- };
119
+ const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
120
+ try {
121
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
122
+ method: "POST"
123
+ });
124
+ return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt });
125
+ } catch (error) {
126
+ if (!canRecoverPreviewPublish(error)) throw error;
127
+ return waitForPublishedPreview(config, {
128
+ id,
129
+ label,
130
+ framework,
131
+ expiresAt,
132
+ publishError: error
133
+ });
134
+ }
91
135
  }
92
136
  async function deployRiddleStaticPreview(config, directory, label) {
93
137
  return deployRiddlePreview(config, directory, label, "static");
package/dist/cli.cjs CHANGED
@@ -6575,6 +6575,9 @@ var RiddleApiError = class extends Error {
6575
6575
  this.path = pathname;
6576
6576
  }
6577
6577
  };
6578
+ var PREVIEW_PUBLISH_RECOVERY_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
6579
+ var PREVIEW_PUBLISH_RECOVERY_ATTEMPTS = 30;
6580
+ var PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS = 2e3;
6578
6581
  function normalizeBaseUrl(value) {
6579
6582
  return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
6580
6583
  }
@@ -6609,6 +6612,45 @@ async function riddleRequestJson(config, pathname, init = {}) {
6609
6612
  if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
6610
6613
  return json ?? text;
6611
6614
  }
6615
+ function previewDeployResultFromRecord(input) {
6616
+ const { record, id, label, framework, expiresAt, publishRecovered, publishError } = input;
6617
+ return {
6618
+ ok: true,
6619
+ id: String(record.id || record.preview_id || id),
6620
+ label,
6621
+ framework,
6622
+ preview_url: String(record.preview_url || ""),
6623
+ file_count: typeof record.file_count === "number" ? record.file_count : void 0,
6624
+ total_bytes: typeof record.total_bytes === "number" ? record.total_bytes : void 0,
6625
+ expires_at: expiresAt,
6626
+ publish_recovered: publishRecovered || void 0,
6627
+ publish_error: publishError,
6628
+ raw: record
6629
+ };
6630
+ }
6631
+ function canRecoverPreviewPublish(error) {
6632
+ return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
6633
+ }
6634
+ async function waitForPublishedPreview(config, input) {
6635
+ for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
6636
+ const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
6637
+ if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
6638
+ return previewDeployResultFromRecord({
6639
+ record: status,
6640
+ id: input.id,
6641
+ label: input.label,
6642
+ framework: input.framework,
6643
+ expiresAt: input.expiresAt,
6644
+ publishRecovered: true,
6645
+ publishError: input.publishError.message
6646
+ });
6647
+ }
6648
+ if (attempt < PREVIEW_PUBLISH_RECOVERY_ATTEMPTS) {
6649
+ await new Promise((resolve) => setTimeout(resolve, PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS));
6650
+ }
6651
+ }
6652
+ throw input.publishError;
6653
+ }
6612
6654
  async function deployRiddlePreview(config, directory, label, framework = "static") {
6613
6655
  if (!directory?.trim()) throw new Error("directory is required");
6614
6656
  if (!label?.trim()) throw new Error("label is required");
@@ -6635,20 +6677,22 @@ async function deployRiddlePreview(config, directory, label, framework = "static
6635
6677
  } finally {
6636
6678
  (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
6637
6679
  }
6638
- const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
6639
- method: "POST"
6640
- });
6641
- return {
6642
- ok: true,
6643
- id: String(published.id || id),
6644
- label,
6645
- framework,
6646
- preview_url: String(published.preview_url || ""),
6647
- file_count: typeof published.file_count === "number" ? published.file_count : void 0,
6648
- total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
6649
- expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
6650
- raw: published
6651
- };
6680
+ const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
6681
+ try {
6682
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
6683
+ method: "POST"
6684
+ });
6685
+ return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt });
6686
+ } catch (error) {
6687
+ if (!canRecoverPreviewPublish(error)) throw error;
6688
+ return waitForPublishedPreview(config, {
6689
+ id,
6690
+ label,
6691
+ framework,
6692
+ expiresAt,
6693
+ publishError: error
6694
+ });
6695
+ }
6652
6696
  }
6653
6697
  async function deployRiddleStaticPreview(config, directory, label) {
6654
6698
  return deployRiddlePreview(config, directory, label, "static");
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  createRiddleApiClient,
16
16
  parseRiddleViewport
17
- } from "./chunk-OI57LO6Y.js";
17
+ } from "./chunk-7GHBRZHQ.js";
18
18
  import {
19
19
  createDisabledRiddleProofAgentAdapter,
20
20
  readRiddleProofRunStatus,
package/dist/index.cjs CHANGED
@@ -14476,6 +14476,9 @@ var RiddleApiError = class extends Error {
14476
14476
  this.path = pathname;
14477
14477
  }
14478
14478
  };
14479
+ var PREVIEW_PUBLISH_RECOVERY_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
14480
+ var PREVIEW_PUBLISH_RECOVERY_ATTEMPTS = 30;
14481
+ var PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS = 2e3;
14479
14482
  function normalizeBaseUrl(value) {
14480
14483
  return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
14481
14484
  }
@@ -14510,6 +14513,45 @@ async function riddleRequestJson(config, pathname, init = {}) {
14510
14513
  if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
14511
14514
  return json ?? text;
14512
14515
  }
14516
+ function previewDeployResultFromRecord(input) {
14517
+ const { record, id, label, framework, expiresAt, publishRecovered, publishError } = input;
14518
+ return {
14519
+ ok: true,
14520
+ id: String(record.id || record.preview_id || id),
14521
+ label,
14522
+ framework,
14523
+ preview_url: String(record.preview_url || ""),
14524
+ file_count: typeof record.file_count === "number" ? record.file_count : void 0,
14525
+ total_bytes: typeof record.total_bytes === "number" ? record.total_bytes : void 0,
14526
+ expires_at: expiresAt,
14527
+ publish_recovered: publishRecovered || void 0,
14528
+ publish_error: publishError,
14529
+ raw: record
14530
+ };
14531
+ }
14532
+ function canRecoverPreviewPublish(error) {
14533
+ return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
14534
+ }
14535
+ async function waitForPublishedPreview(config, input) {
14536
+ for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
14537
+ const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
14538
+ if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
14539
+ return previewDeployResultFromRecord({
14540
+ record: status,
14541
+ id: input.id,
14542
+ label: input.label,
14543
+ framework: input.framework,
14544
+ expiresAt: input.expiresAt,
14545
+ publishRecovered: true,
14546
+ publishError: input.publishError.message
14547
+ });
14548
+ }
14549
+ if (attempt < PREVIEW_PUBLISH_RECOVERY_ATTEMPTS) {
14550
+ await new Promise((resolve) => setTimeout(resolve, PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS));
14551
+ }
14552
+ }
14553
+ throw input.publishError;
14554
+ }
14513
14555
  async function deployRiddlePreview(config, directory, label, framework = "static") {
14514
14556
  if (!directory?.trim()) throw new Error("directory is required");
14515
14557
  if (!label?.trim()) throw new Error("label is required");
@@ -14536,20 +14578,22 @@ async function deployRiddlePreview(config, directory, label, framework = "static
14536
14578
  } finally {
14537
14579
  (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
14538
14580
  }
14539
- const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
14540
- method: "POST"
14541
- });
14542
- return {
14543
- ok: true,
14544
- id: String(published.id || id),
14545
- label,
14546
- framework,
14547
- preview_url: String(published.preview_url || ""),
14548
- file_count: typeof published.file_count === "number" ? published.file_count : void 0,
14549
- total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
14550
- expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
14551
- raw: published
14552
- };
14581
+ const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
14582
+ try {
14583
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
14584
+ method: "POST"
14585
+ });
14586
+ return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt });
14587
+ } catch (error) {
14588
+ if (!canRecoverPreviewPublish(error)) throw error;
14589
+ return waitForPublishedPreview(config, {
14590
+ id,
14591
+ label,
14592
+ framework,
14593
+ expiresAt,
14594
+ publishError: error
14595
+ });
14596
+ }
14553
14597
  }
14554
14598
  async function deployRiddleStaticPreview(config, directory, label) {
14555
14599
  return deployRiddlePreview(config, directory, label, "static");
package/dist/index.js CHANGED
@@ -74,7 +74,7 @@ import {
74
74
  riddleRequestJson,
75
75
  runRiddleScript,
76
76
  runRiddleServerPreview
77
- } from "./chunk-OI57LO6Y.js";
77
+ } from "./chunk-7GHBRZHQ.js";
78
78
  import {
79
79
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
80
80
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
@@ -60,6 +60,9 @@ var RiddleApiError = class extends Error {
60
60
  this.path = pathname;
61
61
  }
62
62
  };
63
+ var PREVIEW_PUBLISH_RECOVERY_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
64
+ var PREVIEW_PUBLISH_RECOVERY_ATTEMPTS = 30;
65
+ var PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS = 2e3;
63
66
  function normalizeBaseUrl(value) {
64
67
  return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
65
68
  }
@@ -94,6 +97,45 @@ async function riddleRequestJson(config, pathname, init = {}) {
94
97
  if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
95
98
  return json ?? text;
96
99
  }
100
+ function previewDeployResultFromRecord(input) {
101
+ const { record, id, label, framework, expiresAt, publishRecovered, publishError } = input;
102
+ return {
103
+ ok: true,
104
+ id: String(record.id || record.preview_id || id),
105
+ label,
106
+ framework,
107
+ preview_url: String(record.preview_url || ""),
108
+ file_count: typeof record.file_count === "number" ? record.file_count : void 0,
109
+ total_bytes: typeof record.total_bytes === "number" ? record.total_bytes : void 0,
110
+ expires_at: expiresAt,
111
+ publish_recovered: publishRecovered || void 0,
112
+ publish_error: publishError,
113
+ raw: record
114
+ };
115
+ }
116
+ function canRecoverPreviewPublish(error) {
117
+ return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
118
+ }
119
+ async function waitForPublishedPreview(config, input) {
120
+ for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
121
+ const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
122
+ if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
123
+ return previewDeployResultFromRecord({
124
+ record: status,
125
+ id: input.id,
126
+ label: input.label,
127
+ framework: input.framework,
128
+ expiresAt: input.expiresAt,
129
+ publishRecovered: true,
130
+ publishError: input.publishError.message
131
+ });
132
+ }
133
+ if (attempt < PREVIEW_PUBLISH_RECOVERY_ATTEMPTS) {
134
+ await new Promise((resolve) => setTimeout(resolve, PREVIEW_PUBLISH_RECOVERY_INTERVAL_MS));
135
+ }
136
+ }
137
+ throw input.publishError;
138
+ }
97
139
  async function deployRiddlePreview(config, directory, label, framework = "static") {
98
140
  if (!directory?.trim()) throw new Error("directory is required");
99
141
  if (!label?.trim()) throw new Error("label is required");
@@ -120,20 +162,22 @@ async function deployRiddlePreview(config, directory, label, framework = "static
120
162
  } finally {
121
163
  (0, import_node_fs.rmSync)(scratch, { recursive: true, force: true });
122
164
  }
123
- const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
124
- method: "POST"
125
- });
126
- return {
127
- ok: true,
128
- id: String(published.id || id),
129
- label,
130
- framework,
131
- preview_url: String(published.preview_url || ""),
132
- file_count: typeof published.file_count === "number" ? published.file_count : void 0,
133
- total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
134
- expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
135
- raw: published
136
- };
165
+ const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
166
+ try {
167
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
168
+ method: "POST"
169
+ });
170
+ return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt });
171
+ } catch (error) {
172
+ if (!canRecoverPreviewPublish(error)) throw error;
173
+ return waitForPublishedPreview(config, {
174
+ id,
175
+ label,
176
+ framework,
177
+ expiresAt,
178
+ publishError: error
179
+ });
180
+ }
137
181
  }
138
182
  async function deployRiddleStaticPreview(config, directory, label) {
139
183
  return deployRiddlePreview(config, directory, label, "static");
@@ -42,6 +42,8 @@ interface RiddlePreviewDeployResult {
42
42
  file_count?: number;
43
43
  total_bytes?: number;
44
44
  expires_at?: string;
45
+ publish_recovered?: boolean;
46
+ publish_error?: string;
45
47
  raw?: Record<string, unknown>;
46
48
  }
47
49
  interface RiddleRunScriptInput {
@@ -42,6 +42,8 @@ interface RiddlePreviewDeployResult {
42
42
  file_count?: number;
43
43
  total_bytes?: number;
44
44
  expires_at?: string;
45
+ publish_recovered?: boolean;
46
+ publish_error?: string;
45
47
  raw?: Record<string, unknown>;
46
48
  }
47
49
  interface RiddleRunScriptInput {
@@ -12,7 +12,7 @@ import {
12
12
  riddleRequestJson,
13
13
  runRiddleScript,
14
14
  runRiddleServerPreview
15
- } from "./chunk-OI57LO6Y.js";
15
+ } from "./chunk-7GHBRZHQ.js";
16
16
  export {
17
17
  DEFAULT_RIDDLE_API_BASE_URL,
18
18
  DEFAULT_RIDDLE_API_KEY_FILE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.113",
3
+ "version": "0.7.114",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",