@riddledc/riddle-proof 0.8.36 → 0.8.37

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/dist/index.cjs CHANGED
@@ -19066,10 +19066,68 @@ function previewDeployResultFromRecord(input) {
19066
19066
  function canRecoverPreviewPublish(error) {
19067
19067
  return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
19068
19068
  }
19069
+ function summarizePreviewDirectory(directory) {
19070
+ const stack = [directory];
19071
+ let fileCount = 0;
19072
+ let totalBytes = 0;
19073
+ while (stack.length) {
19074
+ const current = stack.pop();
19075
+ for (const entry of (0, import_node_fs5.readdirSync)(current, { withFileTypes: true })) {
19076
+ const fullPath = import_node_path5.default.join(current, entry.name);
19077
+ if (entry.isDirectory()) {
19078
+ stack.push(fullPath);
19079
+ continue;
19080
+ }
19081
+ if (!entry.isFile()) continue;
19082
+ const stat = (0, import_node_fs5.statSync)(fullPath);
19083
+ fileCount += 1;
19084
+ totalBytes += stat.size;
19085
+ }
19086
+ }
19087
+ return { file_count: fileCount, total_bytes: totalBytes };
19088
+ }
19089
+ function previewProgressEmitter(config, base) {
19090
+ return async (snapshot) => {
19091
+ if (!config.onPreviewProgress) return;
19092
+ await config.onPreviewProgress({
19093
+ label: base.label,
19094
+ framework: base.framework,
19095
+ directory: base.directory,
19096
+ elapsed_ms: Math.max(0, Date.now() - base.startedAt),
19097
+ warnings: base.warnings?.length ? base.warnings : void 0,
19098
+ ...snapshot
19099
+ });
19100
+ };
19101
+ }
19069
19102
  async function waitForPublishedPreview(config, input) {
19103
+ await input.emitProgress?.({
19104
+ stage: "publish_recovering",
19105
+ id: input.id,
19106
+ file_count: input.localSummary?.file_count,
19107
+ total_bytes: input.localSummary?.total_bytes,
19108
+ publish_error: input.publishError.message,
19109
+ message: `publish returned ${input.publishError.status}; polling preview status`
19110
+ });
19070
19111
  for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
19071
19112
  const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
19113
+ await input.emitProgress?.({
19114
+ stage: "checking_status",
19115
+ id: input.id,
19116
+ attempt,
19117
+ attempts: PREVIEW_PUBLISH_RECOVERY_ATTEMPTS,
19118
+ status: typeof status.status === "string" ? status.status : null,
19119
+ preview_url: typeof status.preview_url === "string" ? status.preview_url : void 0,
19120
+ file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
19121
+ total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
19122
+ });
19072
19123
  if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
19124
+ await input.emitProgress?.({
19125
+ stage: "ready",
19126
+ id: input.id,
19127
+ preview_url: String(status.preview_url),
19128
+ file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
19129
+ total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
19130
+ });
19073
19131
  return previewDeployResultFromRecord({
19074
19132
  record: status,
19075
19133
  id: input.id,
@@ -19091,7 +19149,17 @@ async function deployRiddlePreview(config, directory, label, framework = "static
19091
19149
  if (!directory?.trim()) throw new Error("directory is required");
19092
19150
  if (!label?.trim()) throw new Error("label is required");
19093
19151
  if (framework !== "spa" && framework !== "static") throw new Error("framework must be spa or static");
19152
+ const startedAt = Date.now();
19094
19153
  const warnings = collectRiddlePreviewDeployWarnings(directory, framework);
19154
+ const emitProgress = previewProgressEmitter(config, { label, framework, directory, startedAt, warnings });
19155
+ await emitProgress({ stage: "validating", message: "checking preview input directory" });
19156
+ const localSummary = summarizePreviewDirectory(directory);
19157
+ await emitProgress({
19158
+ stage: "creating",
19159
+ file_count: localSummary.file_count,
19160
+ total_bytes: localSummary.total_bytes,
19161
+ message: "creating preview upload target"
19162
+ });
19095
19163
  const created = await riddleRequestJson(config, "/v1/preview", {
19096
19164
  method: "POST",
19097
19165
  body: JSON.stringify({ framework, label })
@@ -19099,10 +19167,42 @@ async function deployRiddlePreview(config, directory, label, framework = "static
19099
19167
  const id = String(created.id || "");
19100
19168
  const uploadUrl = String(created.upload_url || "");
19101
19169
  if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
19170
+ await emitProgress({
19171
+ stage: "created",
19172
+ id,
19173
+ file_count: localSummary.file_count,
19174
+ total_bytes: localSummary.total_bytes,
19175
+ message: "preview upload target created"
19176
+ });
19102
19177
  const scratch = (0, import_node_fs5.mkdtempSync)(import_node_path5.default.join((0, import_node_os2.tmpdir)(), "riddle-preview-upload-"));
19103
19178
  const tarball = import_node_path5.default.join(scratch, `${id}.tar.gz`);
19179
+ let tarballBytes = 0;
19104
19180
  try {
19181
+ await emitProgress({
19182
+ stage: "archiving",
19183
+ id,
19184
+ file_count: localSummary.file_count,
19185
+ total_bytes: localSummary.total_bytes,
19186
+ message: "creating preview archive"
19187
+ });
19105
19188
  (0, import_node_child_process4.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
19189
+ tarballBytes = (0, import_node_fs5.statSync)(tarball).size;
19190
+ await emitProgress({
19191
+ stage: "archived",
19192
+ id,
19193
+ file_count: localSummary.file_count,
19194
+ total_bytes: localSummary.total_bytes,
19195
+ tarball_bytes: tarballBytes,
19196
+ message: "preview archive created"
19197
+ });
19198
+ await emitProgress({
19199
+ stage: "uploading",
19200
+ id,
19201
+ file_count: localSummary.file_count,
19202
+ total_bytes: localSummary.total_bytes,
19203
+ tarball_bytes: tarballBytes,
19204
+ message: "uploading preview archive"
19205
+ });
19106
19206
  const upload = await fetchFor(config)(uploadUrl, {
19107
19207
  method: "PUT",
19108
19208
  headers: { "Content-Type": "application/gzip" },
@@ -19111,14 +19211,37 @@ async function deployRiddlePreview(config, directory, label, framework = "static
19111
19211
  if (!upload.ok) {
19112
19212
  throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
19113
19213
  }
19214
+ await emitProgress({
19215
+ stage: "uploaded",
19216
+ id,
19217
+ file_count: localSummary.file_count,
19218
+ total_bytes: localSummary.total_bytes,
19219
+ tarball_bytes: tarballBytes,
19220
+ message: "preview archive uploaded"
19221
+ });
19114
19222
  } finally {
19115
19223
  (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
19116
19224
  }
19117
19225
  const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
19118
19226
  try {
19227
+ await emitProgress({
19228
+ stage: "publishing",
19229
+ id,
19230
+ file_count: localSummary.file_count,
19231
+ total_bytes: localSummary.total_bytes,
19232
+ tarball_bytes: tarballBytes || void 0,
19233
+ message: "publishing preview"
19234
+ });
19119
19235
  const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
19120
19236
  method: "POST"
19121
19237
  });
19238
+ await emitProgress({
19239
+ stage: "ready",
19240
+ id,
19241
+ preview_url: String(published.preview_url || ""),
19242
+ file_count: typeof published.file_count === "number" ? published.file_count : localSummary.file_count,
19243
+ total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : localSummary.total_bytes
19244
+ });
19122
19245
  return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt, warnings });
19123
19246
  } catch (error) {
19124
19247
  if (!canRecoverPreviewPublish(error)) throw error;
@@ -19128,7 +19251,9 @@ async function deployRiddlePreview(config, directory, label, framework = "static
19128
19251
  framework,
19129
19252
  expiresAt,
19130
19253
  publishError: error,
19131
- warnings
19254
+ warnings,
19255
+ localSummary,
19256
+ emitProgress
19132
19257
  });
19133
19258
  }
19134
19259
  }
package/dist/index.d.cts CHANGED
@@ -11,4 +11,4 @@ export { BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_V
11
11
  export { AssessPlayabilityOptions, RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION, RIDDLE_PROOF_PLAYABILITY_VERSION, RiddleProofPlayabilityAssessment, RiddleProofPlayabilityEvidence, assessPlayabilityEvidence, extractPlayabilityEvidence, isRiddleProofPlayabilityMode } from './playability.cjs';
12
12
  export { AssessBasicGameplayOptions, AttachBasicGameplayArtifactOptions, BASIC_GAMEPLAY_ACTION_TYPES, BASIC_GAMEPLAY_PROGRESS_CHECK_TYPES, BasicGameplayActionResult, BasicGameplayActionType, BasicGameplayArtifactResolution, BasicGameplayAssessmentSummary, BasicGameplayBoundsOffender, BasicGameplayCanvasState, BasicGameplayCatchRecord, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayFixReference, BasicGameplayMetric, BasicGameplayMobileEvidence, BasicGameplayProgressCheckType, BasicGameplayProgressionCheck, BasicGameplayProofArtifact, BasicGameplayResponsiveViewportEvidence, BasicGameplayRouteReference, BasicGameplaySnapshot, BasicGameplaySuiteFailure, BasicGameplayWarningCode, CreateBasicGameplayCatchSummaryInput, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayCatchSummary, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayProgressionCheck, assessBasicGameplayProgressionChecks, assessBasicGameplayRoute, attachBasicGameplayArtifactScreenshotHashes, augmentBasicGameplayAssessmentWithProgressionChecks, compactBasicGameplayText, createBasicGameplayCatchRecords, createBasicGameplayCatchSummary, extractBasicGameplayEvidence, resolveBasicGameplayProgressionCheckWithArtifactScreenshots, sanitizeBasicGameplayJsonString } from './basic-gameplay.cjs';
13
13
  export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofProfile, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.cjs';
14
- export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployResult, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.cjs';
14
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployProgressSnapshot, RiddlePreviewDeployResult, RiddlePreviewDeployStage, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.cjs';
package/dist/index.d.ts CHANGED
@@ -11,4 +11,4 @@ export { BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_V
11
11
  export { AssessPlayabilityOptions, RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION, RIDDLE_PROOF_PLAYABILITY_VERSION, RiddleProofPlayabilityAssessment, RiddleProofPlayabilityEvidence, assessPlayabilityEvidence, extractPlayabilityEvidence, isRiddleProofPlayabilityMode } from './playability.js';
12
12
  export { AssessBasicGameplayOptions, AttachBasicGameplayArtifactOptions, BASIC_GAMEPLAY_ACTION_TYPES, BASIC_GAMEPLAY_PROGRESS_CHECK_TYPES, BasicGameplayActionResult, BasicGameplayActionType, BasicGameplayArtifactResolution, BasicGameplayAssessmentSummary, BasicGameplayBoundsOffender, BasicGameplayCanvasState, BasicGameplayCatchRecord, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayFixReference, BasicGameplayMetric, BasicGameplayMobileEvidence, BasicGameplayProgressCheckType, BasicGameplayProgressionCheck, BasicGameplayProofArtifact, BasicGameplayResponsiveViewportEvidence, BasicGameplayRouteReference, BasicGameplaySnapshot, BasicGameplaySuiteFailure, BasicGameplayWarningCode, CreateBasicGameplayCatchSummaryInput, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayCatchSummary, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayProgressionCheck, assessBasicGameplayProgressionChecks, assessBasicGameplayRoute, attachBasicGameplayArtifactScreenshotHashes, augmentBasicGameplayAssessmentWithProgressionChecks, compactBasicGameplayText, createBasicGameplayCatchRecords, createBasicGameplayCatchSummary, extractBasicGameplayEvidence, resolveBasicGameplayProgressionCheckWithArtifactScreenshots, sanitizeBasicGameplayJsonString } from './basic-gameplay.js';
13
13
  export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofProfile, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from './profile.js';
14
- export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployResult, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.js';
14
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployProgressSnapshot, RiddlePreviewDeployResult, RiddlePreviewDeployStage, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.js';
package/dist/index.js CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  riddleRequestJson,
81
81
  runRiddleScript,
82
82
  runRiddleServerPreview
83
- } from "./chunk-TWTEUS7R.js";
83
+ } from "./chunk-DI2XNGEZ.js";
84
84
  import {
85
85
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
86
86
  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";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup";
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";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
@@ -1,2 +1,2 @@
1
1
  import './proof-run-core-B1GeqkR8.cjs';
2
- export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-DYUu2mqY.cjs';
2
+ export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-4dM37pEx.cjs';
@@ -1,2 +1,2 @@
1
1
  import './proof-run-core-B1GeqkR8.js';
2
- export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-BmNYuOJ7.js';
2
+ export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-BqaeqAze.js';
@@ -130,10 +130,68 @@ function previewDeployResultFromRecord(input) {
130
130
  function canRecoverPreviewPublish(error) {
131
131
  return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
132
132
  }
133
+ function summarizePreviewDirectory(directory) {
134
+ const stack = [directory];
135
+ let fileCount = 0;
136
+ let totalBytes = 0;
137
+ while (stack.length) {
138
+ const current = stack.pop();
139
+ for (const entry of (0, import_node_fs.readdirSync)(current, { withFileTypes: true })) {
140
+ const fullPath = import_node_path.default.join(current, entry.name);
141
+ if (entry.isDirectory()) {
142
+ stack.push(fullPath);
143
+ continue;
144
+ }
145
+ if (!entry.isFile()) continue;
146
+ const stat = (0, import_node_fs.statSync)(fullPath);
147
+ fileCount += 1;
148
+ totalBytes += stat.size;
149
+ }
150
+ }
151
+ return { file_count: fileCount, total_bytes: totalBytes };
152
+ }
153
+ function previewProgressEmitter(config, base) {
154
+ return async (snapshot) => {
155
+ if (!config.onPreviewProgress) return;
156
+ await config.onPreviewProgress({
157
+ label: base.label,
158
+ framework: base.framework,
159
+ directory: base.directory,
160
+ elapsed_ms: Math.max(0, Date.now() - base.startedAt),
161
+ warnings: base.warnings?.length ? base.warnings : void 0,
162
+ ...snapshot
163
+ });
164
+ };
165
+ }
133
166
  async function waitForPublishedPreview(config, input) {
167
+ await input.emitProgress?.({
168
+ stage: "publish_recovering",
169
+ id: input.id,
170
+ file_count: input.localSummary?.file_count,
171
+ total_bytes: input.localSummary?.total_bytes,
172
+ publish_error: input.publishError.message,
173
+ message: `publish returned ${input.publishError.status}; polling preview status`
174
+ });
134
175
  for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
135
176
  const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
177
+ await input.emitProgress?.({
178
+ stage: "checking_status",
179
+ id: input.id,
180
+ attempt,
181
+ attempts: PREVIEW_PUBLISH_RECOVERY_ATTEMPTS,
182
+ status: typeof status.status === "string" ? status.status : null,
183
+ preview_url: typeof status.preview_url === "string" ? status.preview_url : void 0,
184
+ file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
185
+ total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
186
+ });
136
187
  if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
188
+ await input.emitProgress?.({
189
+ stage: "ready",
190
+ id: input.id,
191
+ preview_url: String(status.preview_url),
192
+ file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
193
+ total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
194
+ });
137
195
  return previewDeployResultFromRecord({
138
196
  record: status,
139
197
  id: input.id,
@@ -155,7 +213,17 @@ async function deployRiddlePreview(config, directory, label, framework = "static
155
213
  if (!directory?.trim()) throw new Error("directory is required");
156
214
  if (!label?.trim()) throw new Error("label is required");
157
215
  if (framework !== "spa" && framework !== "static") throw new Error("framework must be spa or static");
216
+ const startedAt = Date.now();
158
217
  const warnings = collectRiddlePreviewDeployWarnings(directory, framework);
218
+ const emitProgress = previewProgressEmitter(config, { label, framework, directory, startedAt, warnings });
219
+ await emitProgress({ stage: "validating", message: "checking preview input directory" });
220
+ const localSummary = summarizePreviewDirectory(directory);
221
+ await emitProgress({
222
+ stage: "creating",
223
+ file_count: localSummary.file_count,
224
+ total_bytes: localSummary.total_bytes,
225
+ message: "creating preview upload target"
226
+ });
159
227
  const created = await riddleRequestJson(config, "/v1/preview", {
160
228
  method: "POST",
161
229
  body: JSON.stringify({ framework, label })
@@ -163,10 +231,42 @@ async function deployRiddlePreview(config, directory, label, framework = "static
163
231
  const id = String(created.id || "");
164
232
  const uploadUrl = String(created.upload_url || "");
165
233
  if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
234
+ await emitProgress({
235
+ stage: "created",
236
+ id,
237
+ file_count: localSummary.file_count,
238
+ total_bytes: localSummary.total_bytes,
239
+ message: "preview upload target created"
240
+ });
166
241
  const scratch = (0, import_node_fs.mkdtempSync)(import_node_path.default.join((0, import_node_os.tmpdir)(), "riddle-preview-upload-"));
167
242
  const tarball = import_node_path.default.join(scratch, `${id}.tar.gz`);
243
+ let tarballBytes = 0;
168
244
  try {
245
+ await emitProgress({
246
+ stage: "archiving",
247
+ id,
248
+ file_count: localSummary.file_count,
249
+ total_bytes: localSummary.total_bytes,
250
+ message: "creating preview archive"
251
+ });
169
252
  (0, import_node_child_process.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
253
+ tarballBytes = (0, import_node_fs.statSync)(tarball).size;
254
+ await emitProgress({
255
+ stage: "archived",
256
+ id,
257
+ file_count: localSummary.file_count,
258
+ total_bytes: localSummary.total_bytes,
259
+ tarball_bytes: tarballBytes,
260
+ message: "preview archive created"
261
+ });
262
+ await emitProgress({
263
+ stage: "uploading",
264
+ id,
265
+ file_count: localSummary.file_count,
266
+ total_bytes: localSummary.total_bytes,
267
+ tarball_bytes: tarballBytes,
268
+ message: "uploading preview archive"
269
+ });
170
270
  const upload = await fetchFor(config)(uploadUrl, {
171
271
  method: "PUT",
172
272
  headers: { "Content-Type": "application/gzip" },
@@ -175,14 +275,37 @@ async function deployRiddlePreview(config, directory, label, framework = "static
175
275
  if (!upload.ok) {
176
276
  throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
177
277
  }
278
+ await emitProgress({
279
+ stage: "uploaded",
280
+ id,
281
+ file_count: localSummary.file_count,
282
+ total_bytes: localSummary.total_bytes,
283
+ tarball_bytes: tarballBytes,
284
+ message: "preview archive uploaded"
285
+ });
178
286
  } finally {
179
287
  (0, import_node_fs.rmSync)(scratch, { recursive: true, force: true });
180
288
  }
181
289
  const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
182
290
  try {
291
+ await emitProgress({
292
+ stage: "publishing",
293
+ id,
294
+ file_count: localSummary.file_count,
295
+ total_bytes: localSummary.total_bytes,
296
+ tarball_bytes: tarballBytes || void 0,
297
+ message: "publishing preview"
298
+ });
183
299
  const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
184
300
  method: "POST"
185
301
  });
302
+ await emitProgress({
303
+ stage: "ready",
304
+ id,
305
+ preview_url: String(published.preview_url || ""),
306
+ file_count: typeof published.file_count === "number" ? published.file_count : localSummary.file_count,
307
+ total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : localSummary.total_bytes
308
+ });
186
309
  return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt, warnings });
187
310
  } catch (error) {
188
311
  if (!canRecoverPreviewPublish(error)) throw error;
@@ -192,7 +315,9 @@ async function deployRiddlePreview(config, directory, label, framework = "static
192
315
  framework,
193
316
  expiresAt,
194
317
  publishError: error,
195
- warnings
318
+ warnings,
319
+ localSummary,
320
+ emitProgress
196
321
  });
197
322
  }
198
323
  }
@@ -6,6 +6,7 @@ interface RiddleClientConfig {
6
6
  apiKeyFile?: string;
7
7
  apiBaseUrl?: string;
8
8
  fetchImpl?: RiddleFetch;
9
+ onPreviewProgress?: (snapshot: RiddlePreviewDeployProgressSnapshot) => void | Promise<void>;
9
10
  }
10
11
  interface RiddleApiKeySource {
11
12
  source: "option" | "env" | "file";
@@ -54,6 +55,25 @@ interface RiddlePollJobOptions {
54
55
  onProgress?: (snapshot: RiddlePollProgressSnapshot) => void | Promise<void>;
55
56
  }
56
57
  type RiddlePreviewFramework = "spa" | "static";
58
+ type RiddlePreviewDeployStage = "validating" | "creating" | "created" | "archiving" | "archived" | "uploading" | "uploaded" | "publishing" | "publish_recovering" | "checking_status" | "ready";
59
+ interface RiddlePreviewDeployProgressSnapshot {
60
+ stage: RiddlePreviewDeployStage;
61
+ label: string;
62
+ framework: RiddlePreviewFramework;
63
+ directory: string;
64
+ elapsed_ms: number;
65
+ id?: string;
66
+ preview_url?: string;
67
+ file_count?: number;
68
+ total_bytes?: number;
69
+ tarball_bytes?: number;
70
+ attempt?: number;
71
+ attempts?: number;
72
+ status?: string | null;
73
+ publish_error?: string;
74
+ warnings?: string[];
75
+ message?: string;
76
+ }
57
77
  interface RiddlePreviewDeployResult {
58
78
  ok: true;
59
79
  id: string;
@@ -151,4 +171,4 @@ declare function createRiddleApiClient(config?: RiddleClientConfig): {
151
171
  pollJob: (jobId: string, options?: RiddlePollJobOptions) => Promise<RiddlePollJobResult>;
152
172
  };
153
173
 
154
- export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleApiKeySource, type RiddleBalanceResult, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobOptions, type RiddlePollJobResult, type RiddlePollProgressSnapshot, type RiddlePollSummary, type RiddlePreviewDeployResult, type RiddlePreviewFramework, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
174
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleApiKeySource, type RiddleBalanceResult, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobOptions, type RiddlePollJobResult, type RiddlePollProgressSnapshot, type RiddlePollSummary, type RiddlePreviewDeployProgressSnapshot, type RiddlePreviewDeployResult, type RiddlePreviewDeployStage, type RiddlePreviewFramework, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
@@ -6,6 +6,7 @@ interface RiddleClientConfig {
6
6
  apiKeyFile?: string;
7
7
  apiBaseUrl?: string;
8
8
  fetchImpl?: RiddleFetch;
9
+ onPreviewProgress?: (snapshot: RiddlePreviewDeployProgressSnapshot) => void | Promise<void>;
9
10
  }
10
11
  interface RiddleApiKeySource {
11
12
  source: "option" | "env" | "file";
@@ -54,6 +55,25 @@ interface RiddlePollJobOptions {
54
55
  onProgress?: (snapshot: RiddlePollProgressSnapshot) => void | Promise<void>;
55
56
  }
56
57
  type RiddlePreviewFramework = "spa" | "static";
58
+ type RiddlePreviewDeployStage = "validating" | "creating" | "created" | "archiving" | "archived" | "uploading" | "uploaded" | "publishing" | "publish_recovering" | "checking_status" | "ready";
59
+ interface RiddlePreviewDeployProgressSnapshot {
60
+ stage: RiddlePreviewDeployStage;
61
+ label: string;
62
+ framework: RiddlePreviewFramework;
63
+ directory: string;
64
+ elapsed_ms: number;
65
+ id?: string;
66
+ preview_url?: string;
67
+ file_count?: number;
68
+ total_bytes?: number;
69
+ tarball_bytes?: number;
70
+ attempt?: number;
71
+ attempts?: number;
72
+ status?: string | null;
73
+ publish_error?: string;
74
+ warnings?: string[];
75
+ message?: string;
76
+ }
57
77
  interface RiddlePreviewDeployResult {
58
78
  ok: true;
59
79
  id: string;
@@ -151,4 +171,4 @@ declare function createRiddleApiClient(config?: RiddleClientConfig): {
151
171
  pollJob: (jobId: string, options?: RiddlePollJobOptions) => Promise<RiddlePollJobResult>;
152
172
  };
153
173
 
154
- export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleApiKeySource, type RiddleBalanceResult, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobOptions, type RiddlePollJobResult, type RiddlePollProgressSnapshot, type RiddlePollSummary, type RiddlePreviewDeployResult, type RiddlePreviewFramework, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
174
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleApiKeySource, type RiddleBalanceResult, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobOptions, type RiddlePollJobResult, type RiddlePollProgressSnapshot, type RiddlePollSummary, type RiddlePreviewDeployProgressSnapshot, type RiddlePreviewDeployResult, type RiddlePreviewDeployStage, type RiddlePreviewFramework, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
@@ -15,7 +15,7 @@ import {
15
15
  riddleRequestJson,
16
16
  runRiddleScript,
17
17
  runRiddleServerPreview
18
- } from "./chunk-TWTEUS7R.js";
18
+ } from "./chunk-DI2XNGEZ.js";
19
19
  import "./chunk-MLKGABMK.js";
20
20
  export {
21
21
  DEFAULT_RIDDLE_API_BASE_URL,