deepline 0.3.245 → 0.3.247

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/cli/index.js CHANGED
@@ -3473,7 +3473,7 @@ var SDK_RELEASE = {
3473
3473
  // getters keep their established compatibility behavior.
3474
3474
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3475
3475
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3476
- version: "0.3.245",
3476
+ version: "0.3.247",
3477
3477
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3478
3478
  packageCapabilities: {
3479
3479
  updatePreferences: 1
@@ -3816,6 +3816,7 @@ var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
3816
3816
  var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
3817
3817
  var RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER = "x-deepline-runtime-scheduler-schema";
3818
3818
  var RUNTIME_ENVIRONMENT_TOKEN_HEADER = "x-deepline-runtime-environment-token";
3819
+ var RETAINED_PIPELINE_RECEIVERS_HEADER = "x-deepline-retained-pipeline-receivers";
3819
3820
  var ABSURD_RELEASE_OVERRIDE_HEADER = "x-deepline-absurd-release";
3820
3821
  var PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER = "x-deepline-preferred-receipt-gateway-machine-id";
3821
3822
  var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
@@ -4235,6 +4236,11 @@ var HttpClient = class {
4235
4236
  if (runtimeTestFault?.trim()) {
4236
4237
  headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
4237
4238
  }
4239
+ const retainedReceivers = typeof process !== "undefined" ? process.env?.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim() : void 0;
4240
+ if (retainedReceivers && coordinatorInternalToken?.trim()) {
4241
+ headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
4242
+ headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
4243
+ }
4238
4244
  if (absurdReleaseOverride?.trim() && coordinatorInternalToken?.trim()) {
4239
4245
  headers[ABSURD_RELEASE_OVERRIDE_HEADER] = absurdReleaseOverride.trim();
4240
4246
  }
@@ -5589,7 +5595,7 @@ function diffPlayRunStreamEvents(input2) {
5589
5595
  return { events, next };
5590
5596
  }
5591
5597
 
5592
- // src/stream-reconnect.ts
5598
+ // src/runs/read-errors.ts
5593
5599
  function isTransientPlayRunReadError(error) {
5594
5600
  if (error instanceof DeeplineError && error.code === "PLAY_STREAM_NETWORK_ABORTED") {
5595
5601
  return true;
@@ -5857,7 +5863,6 @@ function parseNotificationGroupTarget(value) {
5857
5863
  function notificationObjectKey(kind) {
5858
5864
  return `${kind}.${globalThis.crypto.randomUUID()}`;
5859
5865
  }
5860
- var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
5861
5866
  var MONITOR_NON_RETRYABLE_MUTATION_OPTIONS = {
5862
5867
  maxRetries: 0,
5863
5868
  exactUrlOnly: true
@@ -5964,7 +5969,11 @@ function runtimeSelectionHeaders(runtime) {
5964
5969
  "RUNTIME_ENVIRONMENT_TOKEN_REQUIRED"
5965
5970
  );
5966
5971
  }
5967
- return { [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token };
5972
+ const receivers = process.env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
5973
+ return {
5974
+ [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
5975
+ ...receivers ? { [RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}
5976
+ };
5968
5977
  }
5969
5978
  function normalizeTestPolicyOverrides(value, source) {
5970
5979
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -6127,7 +6136,7 @@ function normalizePlayRunStart(raw) {
6127
6136
  name: runPackage.run.playName,
6128
6137
  status,
6129
6138
  ...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
6130
- ...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
6139
+ ...isTerminalPlayRunLifecycleStatus(status) ? { finalStatus: runPackage } : {},
6131
6140
  package: runPackage
6132
6141
  };
6133
6142
  }
@@ -6205,11 +6214,12 @@ function readStringArray(value) {
6205
6214
  function getPlayLiveEventPayload(event) {
6206
6215
  return event.payload && typeof event.payload === "object" ? event.payload : {};
6207
6216
  }
6208
- function normalizeLiveStatus(value) {
6209
- if (value === "queued" || value === "running" || value === "waiting" || value === "completed" || value === "failed" || value === "cancelled") {
6210
- return value;
6217
+ function playLiveRunStatus(event) {
6218
+ if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
6219
+ return null;
6211
6220
  }
6212
- return null;
6221
+ const payload = getPlayLiveEventPayload(event);
6222
+ return decodePlayRunPublicStatus(payload.status) ?? (isPlayRunPackage(payload) ? decodePlayRunPublicStatus(payload.run.status) : null);
6213
6223
  }
6214
6224
  function appendPlayLiveLogLines(state, payload) {
6215
6225
  const lines = readStringArray(payload.lines);
@@ -6242,7 +6252,7 @@ function updatePlayLiveStatusState(state, event) {
6242
6252
  return null;
6243
6253
  }
6244
6254
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
6245
- const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
6255
+ const status = playLiveRunStatus(event) ?? state.status;
6246
6256
  const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
6247
6257
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
6248
6258
  const payloadLogs = readStringArray(payload.logs);
@@ -7400,13 +7410,6 @@ var DeeplineClient = class _DeeplineClient {
7400
7410
  }
7401
7411
  /** Poll snapshots to terminal status and return the durable package. */
7402
7412
  async watchRunToTerminal(runId, options) {
7403
- const state = {
7404
- runId,
7405
- status: "running",
7406
- logs: [],
7407
- lastLogSeq: 0,
7408
- latest: null
7409
- };
7410
7413
  let terminalObserved = false;
7411
7414
  for await (const event of this.watchRunEvents(runId, {
7412
7415
  signal: options?.signal,
@@ -7414,19 +7417,17 @@ var DeeplineClient = class _DeeplineClient {
7414
7417
  onRetry: options?.onRetry ?? options?.onReconnect
7415
7418
  })) {
7416
7419
  options?.onEvent?.(event);
7417
- const status = updatePlayLiveStatusState(state, event);
7418
- if (status && TERMINAL_PLAY_STATUSES.has(status.status)) {
7420
+ if (isTerminalPlayRunLifecycleStatus(playLiveRunStatus(event))) {
7419
7421
  terminalObserved = true;
7420
7422
  }
7421
7423
  }
7422
7424
  if (options?.signal?.aborted) {
7423
7425
  throw new DeeplineError("Run watch aborted.", void 0, "ABORTED");
7424
7426
  }
7425
- if (terminalObserved) {
7426
- return await this.getRunStatus(runId);
7427
- }
7428
7427
  const refreshed = await this.getRunStatus(runId);
7429
- if (TERMINAL_PLAY_STATUSES.has(refreshed.status)) return refreshed;
7428
+ if (terminalObserved || isTerminalPlayRunLifecycleStatus(refreshed.status)) {
7429
+ return refreshed;
7430
+ }
7430
7431
  throw new DeeplineError(
7431
7432
  `Run watch for ${runId} ended before a terminal status.`,
7432
7433
  void 0,
@@ -7607,15 +7608,7 @@ var DeeplineClient = class _DeeplineClient {
7607
7608
  `/api/v2/runs/${encodeURIComponent(runId)}${query}`,
7608
7609
  { headers: { "x-deepline-run-status": "1" } }
7609
7610
  );
7610
- const responseRunStatus = isPlayRunPackage(response) ? response.runStatus : isPlayRunPackage(response.package) ? response.package.runStatus : response.runStatus;
7611
- const responseOverview = isPlayRunPackage(response) ? response.overview : isPlayRunPackage(response.package) ? response.package.overview : response.overview;
7612
7611
  const status = normalizePlayStatus(response);
7613
- if (isRecord4(responseRunStatus)) {
7614
- status.runStatus = responseRunStatus;
7615
- }
7616
- if (isRecord4(responseOverview)) {
7617
- status.overview = responseOverview;
7618
- }
7619
7612
  if (options?.failedLogs !== true || status.status !== "failed") {
7620
7613
  return status;
7621
7614
  }
@@ -8593,7 +8586,7 @@ var DeeplineClient = class _DeeplineClient {
8593
8586
  if (event.type !== "play.run.status" || status.status !== previousStatus) {
8594
8587
  options?.onProgress?.(status);
8595
8588
  }
8596
- if (TERMINAL_PLAY_STATUSES.has(status.status)) {
8589
+ if (isTerminalPlayRunLifecycleStatus(status.status)) {
8597
8590
  terminalObserved = status;
8598
8591
  }
8599
8592
  }
@@ -23419,7 +23412,7 @@ function pendingStartFailureStatus(input2) {
23419
23412
  }
23420
23413
  };
23421
23414
  }
23422
- var TERMINAL_PLAY_STATUSES2 = /* @__PURE__ */ new Set([
23415
+ var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set([
23423
23416
  "completed",
23424
23417
  "failed",
23425
23418
  "cancelled"
@@ -23919,18 +23912,12 @@ function openPlayDashboard(dashboardUrl, open2) {
23919
23912
  }
23920
23913
  }
23921
23914
  function printPlayLogLines(input2) {
23915
+ if (!input2.emitLogs) return;
23922
23916
  for (const line of input2.lines) {
23923
- if (input2.emitLogs) {
23924
- const formatted = formatPlayLogLine(
23925
- line,
23926
- input2.status ?? void 0,
23927
- input2.state
23928
- );
23929
- if (formatted) {
23930
- input2.progress.writeLogLine(formatted);
23931
- }
23917
+ const formatted = formatPlayLogLine(line, input2.state);
23918
+ if (formatted) {
23919
+ input2.progress.writeLogLine(formatted);
23932
23920
  }
23933
- input2.state.lastLogIndex += 1;
23934
23921
  }
23935
23922
  }
23936
23923
  function assertPlayWaitNotTimedOut(input2) {
@@ -23991,7 +23978,7 @@ async function waitForPlayCompletionByWatch(input2) {
23991
23978
  if (refreshed.runId === input2.workflowId && statusProvesPlayRunExecution(refreshed.status)) {
23992
23979
  await confirmAdmission();
23993
23980
  }
23994
- return TERMINAL_PLAY_STATUSES2.has(refreshed.status) ? withDashboardUrl(refreshed) : null;
23981
+ return TERMINAL_PLAY_STATUSES.has(refreshed.status) ? withDashboardUrl(refreshed) : null;
23995
23982
  };
23996
23983
  const handleLiveEvent = async (event) => {
23997
23984
  assertPlayWaitNotTimedOut({ ...input2, lastPhase });
@@ -24018,8 +24005,6 @@ async function waitForPlayCompletionByWatch(input2) {
24018
24005
  });
24019
24006
  printPlayLogLines({
24020
24007
  lines: getLogLinesFromLiveEvent(event),
24021
- status: null,
24022
- jsonOutput: input2.jsonOutput,
24023
24008
  emitLogs: input2.emitLogs,
24024
24009
  state: input2.state,
24025
24010
  progress: input2.progress
@@ -24052,7 +24037,7 @@ async function waitForPlayCompletionByWatch(input2) {
24052
24037
  return withDashboardUrl(finalStatus);
24053
24038
  }
24054
24039
  const status = getStatusFromLiveEvent(event);
24055
- if (status && TERMINAL_PLAY_STATUSES2.has(status)) {
24040
+ if (status && TERMINAL_PLAY_STATUSES.has(status)) {
24056
24041
  terminalStatusRead ??= fetchTerminalStatus();
24057
24042
  return await terminalStatusRead;
24058
24043
  }
@@ -24136,7 +24121,6 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
24136
24121
  input2.playName
24137
24122
  );
24138
24123
  const state = {
24139
- lastLogIndex: 0,
24140
24124
  emittedRunnerStarted: false,
24141
24125
  verbose: input2.verboseLogs === true,
24142
24126
  logLevel: input2.logLevel ?? "info",
@@ -24183,7 +24167,7 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
24183
24167
  if (refreshed.runId === lastKnownWorkflowId && statusProvesPlayRunExecution(refreshed.status)) {
24184
24168
  await confirmAdmission(lastKnownWorkflowId);
24185
24169
  }
24186
- return TERMINAL_PLAY_STATUSES2.has(refreshed.status) ? {
24170
+ return TERMINAL_PLAY_STATUSES.has(refreshed.status) ? {
24187
24171
  ...refreshed,
24188
24172
  dashboardUrl,
24189
24173
  ...launchedRevisionId ? { revisionId: launchedRevisionId } : {}
@@ -24247,8 +24231,6 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
24247
24231
  });
24248
24232
  printPlayLogLines({
24249
24233
  lines: getLogLinesFromLiveEvent(event),
24250
- status: null,
24251
- jsonOutput: input2.jsonOutput,
24252
24234
  emitLogs: input2.emitLogs,
24253
24235
  state,
24254
24236
  progress: input2.progress
@@ -24519,7 +24501,7 @@ var BULKY_RETURN_KEYS = /* @__PURE__ */ new Set([
24519
24501
  "sequenceTrace",
24520
24502
  "logs"
24521
24503
  ]);
24522
- function formatPlayLogLine(rawLine, status, state) {
24504
+ function formatPlayLogLine(rawLine, state) {
24523
24505
  const classified = classifyLogLine(rawLine);
24524
24506
  const line = classified.line;
24525
24507
  const timestampMatch = line.match(/^\[([^\]]+)\]\s*(.*)$/);
@@ -24551,12 +24533,6 @@ function formatPlayLogLine(rawLine, status, state) {
24551
24533
  state.emittedRunnerStarted = true;
24552
24534
  return `${prefix}runner started`;
24553
24535
  }
24554
- const stages = (status?.contract?.staticPipeline?.stages ?? []).filter((stage) => stage.tableNamespace);
24555
- const sourceLabelForNamespace = (namespace) => {
24556
- const stage = stages.find((entry) => entry.tableNamespace === namespace);
24557
- const range = stage?.sourceRange;
24558
- return range?.startLine && range?.endLine ? `${namespace} lines ${range.startLine}-${range.endLine}` : namespace;
24559
- };
24560
24536
  const mapStart = message.match(
24561
24537
  /^Starting map over (\d+) items with (\d+) fields \(key: ([^;]+); (\d+) already satisfied; (\d+) pending\)$/
24562
24538
  );
@@ -24565,7 +24541,7 @@ function formatPlayLogLine(rawLine, status, state) {
24565
24541
  return null;
24566
24542
  }
24567
24543
  const [, rows, fields2, namespace, cached, pending] = mapStart;
24568
- return `${prefix}map ${sourceLabelForNamespace(namespace)}: ${formatInteger(Number(rows))} rows, ${fields2} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
24544
+ return `${prefix}map ${namespace}: ${formatInteger(Number(rows))} rows, ${fields2} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
24569
24545
  }
24570
24546
  const mapDone = message.match(
24571
24547
  /^Map completed: (\d+) results \((\d+) executed, (\d+) already satisfied\)$/
@@ -28643,7 +28619,6 @@ async function handleRunTail(args) {
28643
28619
  const compact = args.includes("--compact");
28644
28620
  const showLiveLogs = debug || hasExplicitLogLevel || !jsonOutput && !compact;
28645
28621
  const compactState = {
28646
- lastLogIndex: 0,
28647
28622
  emittedRunnerStarted: false,
28648
28623
  lastProgressSignature: null,
28649
28624
  lastProgressHeartbeatAt: 0,
@@ -28664,14 +28639,9 @@ async function handleRunTail(args) {
28664
28639
  } : compact || showLiveLogs ? (event) => {
28665
28640
  if (showLiveLogs) {
28666
28641
  for (const line of getLogLinesFromLiveEvent(event)) {
28667
- const formatted = formatPlayLogLine(
28668
- line,
28669
- void 0,
28670
- compactState
28671
- );
28642
+ const formatted = formatPlayLogLine(line, compactState);
28672
28643
  if (formatted) process.stderr.write(`${formatted}
28673
28644
  `);
28674
- compactState.lastLogIndex += 1;
28675
28645
  }
28676
28646
  }
28677
28647
  if (!compact || jsonOutput) return;
@@ -3468,7 +3468,7 @@ var SDK_RELEASE = {
3468
3468
  // getters keep their established compatibility behavior.
3469
3469
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3470
3470
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3471
- version: "0.3.245",
3471
+ version: "0.3.247",
3472
3472
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3473
3473
  packageCapabilities: {
3474
3474
  updatePreferences: 1
@@ -3811,6 +3811,7 @@ var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
3811
3811
  var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
3812
3812
  var RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER = "x-deepline-runtime-scheduler-schema";
3813
3813
  var RUNTIME_ENVIRONMENT_TOKEN_HEADER = "x-deepline-runtime-environment-token";
3814
+ var RETAINED_PIPELINE_RECEIVERS_HEADER = "x-deepline-retained-pipeline-receivers";
3814
3815
  var ABSURD_RELEASE_OVERRIDE_HEADER = "x-deepline-absurd-release";
3815
3816
  var PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER = "x-deepline-preferred-receipt-gateway-machine-id";
3816
3817
  var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
@@ -4230,6 +4231,11 @@ var HttpClient = class {
4230
4231
  if (runtimeTestFault?.trim()) {
4231
4232
  headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
4232
4233
  }
4234
+ const retainedReceivers = typeof process !== "undefined" ? process.env?.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim() : void 0;
4235
+ if (retainedReceivers && coordinatorInternalToken?.trim()) {
4236
+ headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
4237
+ headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
4238
+ }
4233
4239
  if (absurdReleaseOverride?.trim() && coordinatorInternalToken?.trim()) {
4234
4240
  headers[ABSURD_RELEASE_OVERRIDE_HEADER] = absurdReleaseOverride.trim();
4235
4241
  }
@@ -5584,7 +5590,7 @@ function diffPlayRunStreamEvents(input2) {
5584
5590
  return { events, next };
5585
5591
  }
5586
5592
 
5587
- // src/stream-reconnect.ts
5593
+ // src/runs/read-errors.ts
5588
5594
  function isTransientPlayRunReadError(error) {
5589
5595
  if (error instanceof DeeplineError && error.code === "PLAY_STREAM_NETWORK_ABORTED") {
5590
5596
  return true;
@@ -5852,7 +5858,6 @@ function parseNotificationGroupTarget(value) {
5852
5858
  function notificationObjectKey(kind) {
5853
5859
  return `${kind}.${globalThis.crypto.randomUUID()}`;
5854
5860
  }
5855
- var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
5856
5861
  var MONITOR_NON_RETRYABLE_MUTATION_OPTIONS = {
5857
5862
  maxRetries: 0,
5858
5863
  exactUrlOnly: true
@@ -5959,7 +5964,11 @@ function runtimeSelectionHeaders(runtime) {
5959
5964
  "RUNTIME_ENVIRONMENT_TOKEN_REQUIRED"
5960
5965
  );
5961
5966
  }
5962
- return { [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token };
5967
+ const receivers = process.env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
5968
+ return {
5969
+ [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
5970
+ ...receivers ? { [RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}
5971
+ };
5963
5972
  }
5964
5973
  function normalizeTestPolicyOverrides(value, source) {
5965
5974
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -6122,7 +6131,7 @@ function normalizePlayRunStart(raw) {
6122
6131
  name: runPackage.run.playName,
6123
6132
  status,
6124
6133
  ...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
6125
- ...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
6134
+ ...isTerminalPlayRunLifecycleStatus(status) ? { finalStatus: runPackage } : {},
6126
6135
  package: runPackage
6127
6136
  };
6128
6137
  }
@@ -6200,11 +6209,12 @@ function readStringArray(value) {
6200
6209
  function getPlayLiveEventPayload(event) {
6201
6210
  return event.payload && typeof event.payload === "object" ? event.payload : {};
6202
6211
  }
6203
- function normalizeLiveStatus(value) {
6204
- if (value === "queued" || value === "running" || value === "waiting" || value === "completed" || value === "failed" || value === "cancelled") {
6205
- return value;
6212
+ function playLiveRunStatus(event) {
6213
+ if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
6214
+ return null;
6206
6215
  }
6207
- return null;
6216
+ const payload = getPlayLiveEventPayload(event);
6217
+ return decodePlayRunPublicStatus(payload.status) ?? (isPlayRunPackage(payload) ? decodePlayRunPublicStatus(payload.run.status) : null);
6208
6218
  }
6209
6219
  function appendPlayLiveLogLines(state, payload) {
6210
6220
  const lines = readStringArray(payload.lines);
@@ -6237,7 +6247,7 @@ function updatePlayLiveStatusState(state, event) {
6237
6247
  return null;
6238
6248
  }
6239
6249
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
6240
- const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
6250
+ const status = playLiveRunStatus(event) ?? state.status;
6241
6251
  const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
6242
6252
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
6243
6253
  const payloadLogs = readStringArray(payload.logs);
@@ -7395,13 +7405,6 @@ var DeeplineClient = class _DeeplineClient {
7395
7405
  }
7396
7406
  /** Poll snapshots to terminal status and return the durable package. */
7397
7407
  async watchRunToTerminal(runId, options) {
7398
- const state = {
7399
- runId,
7400
- status: "running",
7401
- logs: [],
7402
- lastLogSeq: 0,
7403
- latest: null
7404
- };
7405
7408
  let terminalObserved = false;
7406
7409
  for await (const event of this.watchRunEvents(runId, {
7407
7410
  signal: options?.signal,
@@ -7409,19 +7412,17 @@ var DeeplineClient = class _DeeplineClient {
7409
7412
  onRetry: options?.onRetry ?? options?.onReconnect
7410
7413
  })) {
7411
7414
  options?.onEvent?.(event);
7412
- const status = updatePlayLiveStatusState(state, event);
7413
- if (status && TERMINAL_PLAY_STATUSES.has(status.status)) {
7415
+ if (isTerminalPlayRunLifecycleStatus(playLiveRunStatus(event))) {
7414
7416
  terminalObserved = true;
7415
7417
  }
7416
7418
  }
7417
7419
  if (options?.signal?.aborted) {
7418
7420
  throw new DeeplineError("Run watch aborted.", void 0, "ABORTED");
7419
7421
  }
7420
- if (terminalObserved) {
7421
- return await this.getRunStatus(runId);
7422
- }
7423
7422
  const refreshed = await this.getRunStatus(runId);
7424
- if (TERMINAL_PLAY_STATUSES.has(refreshed.status)) return refreshed;
7423
+ if (terminalObserved || isTerminalPlayRunLifecycleStatus(refreshed.status)) {
7424
+ return refreshed;
7425
+ }
7425
7426
  throw new DeeplineError(
7426
7427
  `Run watch for ${runId} ended before a terminal status.`,
7427
7428
  void 0,
@@ -7602,15 +7603,7 @@ var DeeplineClient = class _DeeplineClient {
7602
7603
  `/api/v2/runs/${encodeURIComponent(runId)}${query}`,
7603
7604
  { headers: { "x-deepline-run-status": "1" } }
7604
7605
  );
7605
- const responseRunStatus = isPlayRunPackage(response) ? response.runStatus : isPlayRunPackage(response.package) ? response.package.runStatus : response.runStatus;
7606
- const responseOverview = isPlayRunPackage(response) ? response.overview : isPlayRunPackage(response.package) ? response.package.overview : response.overview;
7607
7606
  const status = normalizePlayStatus(response);
7608
- if (isRecord4(responseRunStatus)) {
7609
- status.runStatus = responseRunStatus;
7610
- }
7611
- if (isRecord4(responseOverview)) {
7612
- status.overview = responseOverview;
7613
- }
7614
7607
  if (options?.failedLogs !== true || status.status !== "failed") {
7615
7608
  return status;
7616
7609
  }
@@ -8588,7 +8581,7 @@ var DeeplineClient = class _DeeplineClient {
8588
8581
  if (event.type !== "play.run.status" || status.status !== previousStatus) {
8589
8582
  options?.onProgress?.(status);
8590
8583
  }
8591
- if (TERMINAL_PLAY_STATUSES.has(status.status)) {
8584
+ if (isTerminalPlayRunLifecycleStatus(status.status)) {
8592
8585
  terminalObserved = status;
8593
8586
  }
8594
8587
  }
@@ -23492,7 +23485,7 @@ function pendingStartFailureStatus(input2) {
23492
23485
  }
23493
23486
  };
23494
23487
  }
23495
- var TERMINAL_PLAY_STATUSES2 = /* @__PURE__ */ new Set([
23488
+ var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set([
23496
23489
  "completed",
23497
23490
  "failed",
23498
23491
  "cancelled"
@@ -23992,18 +23985,12 @@ function openPlayDashboard(dashboardUrl, open2) {
23992
23985
  }
23993
23986
  }
23994
23987
  function printPlayLogLines(input2) {
23988
+ if (!input2.emitLogs) return;
23995
23989
  for (const line of input2.lines) {
23996
- if (input2.emitLogs) {
23997
- const formatted = formatPlayLogLine(
23998
- line,
23999
- input2.status ?? void 0,
24000
- input2.state
24001
- );
24002
- if (formatted) {
24003
- input2.progress.writeLogLine(formatted);
24004
- }
23990
+ const formatted = formatPlayLogLine(line, input2.state);
23991
+ if (formatted) {
23992
+ input2.progress.writeLogLine(formatted);
24005
23993
  }
24006
- input2.state.lastLogIndex += 1;
24007
23994
  }
24008
23995
  }
24009
23996
  function assertPlayWaitNotTimedOut(input2) {
@@ -24064,7 +24051,7 @@ async function waitForPlayCompletionByWatch(input2) {
24064
24051
  if (refreshed.runId === input2.workflowId && statusProvesPlayRunExecution(refreshed.status)) {
24065
24052
  await confirmAdmission();
24066
24053
  }
24067
- return TERMINAL_PLAY_STATUSES2.has(refreshed.status) ? withDashboardUrl(refreshed) : null;
24054
+ return TERMINAL_PLAY_STATUSES.has(refreshed.status) ? withDashboardUrl(refreshed) : null;
24068
24055
  };
24069
24056
  const handleLiveEvent = async (event) => {
24070
24057
  assertPlayWaitNotTimedOut({ ...input2, lastPhase });
@@ -24091,8 +24078,6 @@ async function waitForPlayCompletionByWatch(input2) {
24091
24078
  });
24092
24079
  printPlayLogLines({
24093
24080
  lines: getLogLinesFromLiveEvent(event),
24094
- status: null,
24095
- jsonOutput: input2.jsonOutput,
24096
24081
  emitLogs: input2.emitLogs,
24097
24082
  state: input2.state,
24098
24083
  progress: input2.progress
@@ -24125,7 +24110,7 @@ async function waitForPlayCompletionByWatch(input2) {
24125
24110
  return withDashboardUrl(finalStatus);
24126
24111
  }
24127
24112
  const status = getStatusFromLiveEvent(event);
24128
- if (status && TERMINAL_PLAY_STATUSES2.has(status)) {
24113
+ if (status && TERMINAL_PLAY_STATUSES.has(status)) {
24129
24114
  terminalStatusRead ??= fetchTerminalStatus();
24130
24115
  return await terminalStatusRead;
24131
24116
  }
@@ -24209,7 +24194,6 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
24209
24194
  input2.playName
24210
24195
  );
24211
24196
  const state = {
24212
- lastLogIndex: 0,
24213
24197
  emittedRunnerStarted: false,
24214
24198
  verbose: input2.verboseLogs === true,
24215
24199
  logLevel: input2.logLevel ?? "info",
@@ -24256,7 +24240,7 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
24256
24240
  if (refreshed.runId === lastKnownWorkflowId && statusProvesPlayRunExecution(refreshed.status)) {
24257
24241
  await confirmAdmission(lastKnownWorkflowId);
24258
24242
  }
24259
- return TERMINAL_PLAY_STATUSES2.has(refreshed.status) ? {
24243
+ return TERMINAL_PLAY_STATUSES.has(refreshed.status) ? {
24260
24244
  ...refreshed,
24261
24245
  dashboardUrl,
24262
24246
  ...launchedRevisionId ? { revisionId: launchedRevisionId } : {}
@@ -24320,8 +24304,6 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
24320
24304
  });
24321
24305
  printPlayLogLines({
24322
24306
  lines: getLogLinesFromLiveEvent(event),
24323
- status: null,
24324
- jsonOutput: input2.jsonOutput,
24325
24307
  emitLogs: input2.emitLogs,
24326
24308
  state,
24327
24309
  progress: input2.progress
@@ -24592,7 +24574,7 @@ var BULKY_RETURN_KEYS = /* @__PURE__ */ new Set([
24592
24574
  "sequenceTrace",
24593
24575
  "logs"
24594
24576
  ]);
24595
- function formatPlayLogLine(rawLine, status, state) {
24577
+ function formatPlayLogLine(rawLine, state) {
24596
24578
  const classified = classifyLogLine(rawLine);
24597
24579
  const line = classified.line;
24598
24580
  const timestampMatch = line.match(/^\[([^\]]+)\]\s*(.*)$/);
@@ -24624,12 +24606,6 @@ function formatPlayLogLine(rawLine, status, state) {
24624
24606
  state.emittedRunnerStarted = true;
24625
24607
  return `${prefix}runner started`;
24626
24608
  }
24627
- const stages = (status?.contract?.staticPipeline?.stages ?? []).filter((stage) => stage.tableNamespace);
24628
- const sourceLabelForNamespace = (namespace) => {
24629
- const stage = stages.find((entry) => entry.tableNamespace === namespace);
24630
- const range = stage?.sourceRange;
24631
- return range?.startLine && range?.endLine ? `${namespace} lines ${range.startLine}-${range.endLine}` : namespace;
24632
- };
24633
24609
  const mapStart = message.match(
24634
24610
  /^Starting map over (\d+) items with (\d+) fields \(key: ([^;]+); (\d+) already satisfied; (\d+) pending\)$/
24635
24611
  );
@@ -24638,7 +24614,7 @@ function formatPlayLogLine(rawLine, status, state) {
24638
24614
  return null;
24639
24615
  }
24640
24616
  const [, rows, fields2, namespace, cached, pending] = mapStart;
24641
- return `${prefix}map ${sourceLabelForNamespace(namespace)}: ${formatInteger(Number(rows))} rows, ${fields2} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
24617
+ return `${prefix}map ${namespace}: ${formatInteger(Number(rows))} rows, ${fields2} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
24642
24618
  }
24643
24619
  const mapDone = message.match(
24644
24620
  /^Map completed: (\d+) results \((\d+) executed, (\d+) already satisfied\)$/
@@ -28716,7 +28692,6 @@ async function handleRunTail(args) {
28716
28692
  const compact = args.includes("--compact");
28717
28693
  const showLiveLogs = debug || hasExplicitLogLevel || !jsonOutput && !compact;
28718
28694
  const compactState = {
28719
- lastLogIndex: 0,
28720
28695
  emittedRunnerStarted: false,
28721
28696
  lastProgressSignature: null,
28722
28697
  lastProgressHeartbeatAt: 0,
@@ -28737,14 +28712,9 @@ async function handleRunTail(args) {
28737
28712
  } : compact || showLiveLogs ? (event) => {
28738
28713
  if (showLiveLogs) {
28739
28714
  for (const line of getLogLinesFromLiveEvent(event)) {
28740
- const formatted = formatPlayLogLine(
28741
- line,
28742
- void 0,
28743
- compactState
28744
- );
28715
+ const formatted = formatPlayLogLine(line, compactState);
28745
28716
  if (formatted) process.stderr.write(`${formatted}
28746
28717
  `);
28747
- compactState.lastLogIndex += 1;
28748
28718
  }
28749
28719
  }
28750
28720
  if (!compact || jsonOutput) return;