deepline 0.3.245 → 0.3.246

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.
@@ -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.246",
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;
package/dist/index.js CHANGED
@@ -1286,7 +1286,7 @@ var SDK_RELEASE = {
1286
1286
  // getters keep their established compatibility behavior.
1287
1287
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1288
1288
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
1289
- version: "0.3.245",
1289
+ version: "0.3.246",
1290
1290
  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.",
1291
1291
  packageCapabilities: {
1292
1292
  updatePreferences: 1
@@ -1592,6 +1592,7 @@ var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
1592
1592
  var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
1593
1593
  var RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER = "x-deepline-runtime-scheduler-schema";
1594
1594
  var RUNTIME_ENVIRONMENT_TOKEN_HEADER = "x-deepline-runtime-environment-token";
1595
+ var RETAINED_PIPELINE_RECEIVERS_HEADER = "x-deepline-retained-pipeline-receivers";
1595
1596
  var ABSURD_RELEASE_OVERRIDE_HEADER = "x-deepline-absurd-release";
1596
1597
  var PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER = "x-deepline-preferred-receipt-gateway-machine-id";
1597
1598
  var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
@@ -2011,6 +2012,11 @@ var HttpClient = class {
2011
2012
  if (runtimeTestFault?.trim()) {
2012
2013
  headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
2013
2014
  }
2015
+ const retainedReceivers = typeof process !== "undefined" ? process.env?.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim() : void 0;
2016
+ if (retainedReceivers && coordinatorInternalToken?.trim()) {
2017
+ headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
2018
+ headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
2019
+ }
2014
2020
  if (absurdReleaseOverride?.trim() && coordinatorInternalToken?.trim()) {
2015
2021
  headers[ABSURD_RELEASE_OVERRIDE_HEADER] = absurdReleaseOverride.trim();
2016
2022
  }
@@ -3220,7 +3226,7 @@ function diffPlayRunStreamEvents(input) {
3220
3226
  return { events, next };
3221
3227
  }
3222
3228
 
3223
- // src/stream-reconnect.ts
3229
+ // src/runs/read-errors.ts
3224
3230
  function isTransientPlayRunReadError(error) {
3225
3231
  if (error instanceof DeeplineError && error.code === "PLAY_STREAM_NETWORK_ABORTED") {
3226
3232
  return true;
@@ -3488,7 +3494,6 @@ function parseNotificationGroupTarget(value) {
3488
3494
  function notificationObjectKey(kind) {
3489
3495
  return `${kind}.${globalThis.crypto.randomUUID()}`;
3490
3496
  }
3491
- var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
3492
3497
  var MONITOR_NON_RETRYABLE_MUTATION_OPTIONS = {
3493
3498
  maxRetries: 0,
3494
3499
  exactUrlOnly: true
@@ -3595,7 +3600,11 @@ function runtimeSelectionHeaders(runtime) {
3595
3600
  "RUNTIME_ENVIRONMENT_TOKEN_REQUIRED"
3596
3601
  );
3597
3602
  }
3598
- return { [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token };
3603
+ const receivers = process.env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
3604
+ return {
3605
+ [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
3606
+ ...receivers ? { [RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}
3607
+ };
3599
3608
  }
3600
3609
  function normalizeTestPolicyOverrides(value, source) {
3601
3610
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -3779,7 +3788,7 @@ function normalizePlayRunStart(raw) {
3779
3788
  name: runPackage.run.playName,
3780
3789
  status,
3781
3790
  ...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
3782
- ...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
3791
+ ...isTerminalPlayRunLifecycleStatus(status) ? { finalStatus: runPackage } : {},
3783
3792
  package: runPackage
3784
3793
  };
3785
3794
  }
@@ -3857,11 +3866,12 @@ function readStringArray(value) {
3857
3866
  function getPlayLiveEventPayload(event) {
3858
3867
  return event.payload && typeof event.payload === "object" ? event.payload : {};
3859
3868
  }
3860
- function normalizeLiveStatus(value) {
3861
- if (value === "queued" || value === "running" || value === "waiting" || value === "completed" || value === "failed" || value === "cancelled") {
3862
- return value;
3869
+ function playLiveRunStatus(event) {
3870
+ if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
3871
+ return null;
3863
3872
  }
3864
- return null;
3873
+ const payload = getPlayLiveEventPayload(event);
3874
+ return decodePlayRunPublicStatus(payload.status) ?? (isPlayRunPackage(payload) ? decodePlayRunPublicStatus(payload.run.status) : null);
3865
3875
  }
3866
3876
  function appendPlayLiveLogLines(state, payload) {
3867
3877
  const lines = readStringArray(payload.lines);
@@ -3894,7 +3904,7 @@ function updatePlayLiveStatusState(state, event) {
3894
3904
  return null;
3895
3905
  }
3896
3906
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
3897
- const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
3907
+ const status = playLiveRunStatus(event) ?? state.status;
3898
3908
  const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
3899
3909
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
3900
3910
  const payloadLogs = readStringArray(payload.logs);
@@ -5052,13 +5062,6 @@ var DeeplineClient = class _DeeplineClient {
5052
5062
  }
5053
5063
  /** Poll snapshots to terminal status and return the durable package. */
5054
5064
  async watchRunToTerminal(runId, options) {
5055
- const state = {
5056
- runId,
5057
- status: "running",
5058
- logs: [],
5059
- lastLogSeq: 0,
5060
- latest: null
5061
- };
5062
5065
  let terminalObserved = false;
5063
5066
  for await (const event of this.watchRunEvents(runId, {
5064
5067
  signal: options?.signal,
@@ -5066,19 +5069,17 @@ var DeeplineClient = class _DeeplineClient {
5066
5069
  onRetry: options?.onRetry ?? options?.onReconnect
5067
5070
  })) {
5068
5071
  options?.onEvent?.(event);
5069
- const status = updatePlayLiveStatusState(state, event);
5070
- if (status && TERMINAL_PLAY_STATUSES.has(status.status)) {
5072
+ if (isTerminalPlayRunLifecycleStatus(playLiveRunStatus(event))) {
5071
5073
  terminalObserved = true;
5072
5074
  }
5073
5075
  }
5074
5076
  if (options?.signal?.aborted) {
5075
5077
  throw new DeeplineError("Run watch aborted.", void 0, "ABORTED");
5076
5078
  }
5077
- if (terminalObserved) {
5078
- return await this.getRunStatus(runId);
5079
- }
5080
5079
  const refreshed = await this.getRunStatus(runId);
5081
- if (TERMINAL_PLAY_STATUSES.has(refreshed.status)) return refreshed;
5080
+ if (terminalObserved || isTerminalPlayRunLifecycleStatus(refreshed.status)) {
5081
+ return refreshed;
5082
+ }
5082
5083
  throw new DeeplineError(
5083
5084
  `Run watch for ${runId} ended before a terminal status.`,
5084
5085
  void 0,
@@ -5259,15 +5260,7 @@ var DeeplineClient = class _DeeplineClient {
5259
5260
  `/api/v2/runs/${encodeURIComponent(runId)}${query}`,
5260
5261
  { headers: { "x-deepline-run-status": "1" } }
5261
5262
  );
5262
- const responseRunStatus = isPlayRunPackage(response) ? response.runStatus : isPlayRunPackage(response.package) ? response.package.runStatus : response.runStatus;
5263
- const responseOverview = isPlayRunPackage(response) ? response.overview : isPlayRunPackage(response.package) ? response.package.overview : response.overview;
5264
5263
  const status = normalizePlayStatus(response);
5265
- if (isRecord4(responseRunStatus)) {
5266
- status.runStatus = responseRunStatus;
5267
- }
5268
- if (isRecord4(responseOverview)) {
5269
- status.overview = responseOverview;
5270
- }
5271
5264
  if (options?.failedLogs !== true || status.status !== "failed") {
5272
5265
  return status;
5273
5266
  }
@@ -6245,7 +6238,7 @@ var DeeplineClient = class _DeeplineClient {
6245
6238
  if (event.type !== "play.run.status" || status.status !== previousStatus) {
6246
6239
  options?.onProgress?.(status);
6247
6240
  }
6248
- if (TERMINAL_PLAY_STATUSES.has(status.status)) {
6241
+ if (isTerminalPlayRunLifecycleStatus(status.status)) {
6249
6242
  terminalObserved = status;
6250
6243
  }
6251
6244
  }
package/dist/index.mjs CHANGED
@@ -1190,7 +1190,7 @@ var SDK_RELEASE = {
1190
1190
  // getters keep their established compatibility behavior.
1191
1191
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1192
1192
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
1193
- version: "0.3.245",
1193
+ version: "0.3.246",
1194
1194
  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.",
1195
1195
  packageCapabilities: {
1196
1196
  updatePreferences: 1
@@ -1496,6 +1496,7 @@ var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
1496
1496
  var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
1497
1497
  var RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER = "x-deepline-runtime-scheduler-schema";
1498
1498
  var RUNTIME_ENVIRONMENT_TOKEN_HEADER = "x-deepline-runtime-environment-token";
1499
+ var RETAINED_PIPELINE_RECEIVERS_HEADER = "x-deepline-retained-pipeline-receivers";
1499
1500
  var ABSURD_RELEASE_OVERRIDE_HEADER = "x-deepline-absurd-release";
1500
1501
  var PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER = "x-deepline-preferred-receipt-gateway-machine-id";
1501
1502
  var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
@@ -1915,6 +1916,11 @@ var HttpClient = class {
1915
1916
  if (runtimeTestFault?.trim()) {
1916
1917
  headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
1917
1918
  }
1919
+ const retainedReceivers = typeof process !== "undefined" ? process.env?.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim() : void 0;
1920
+ if (retainedReceivers && coordinatorInternalToken?.trim()) {
1921
+ headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
1922
+ headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
1923
+ }
1918
1924
  if (absurdReleaseOverride?.trim() && coordinatorInternalToken?.trim()) {
1919
1925
  headers[ABSURD_RELEASE_OVERRIDE_HEADER] = absurdReleaseOverride.trim();
1920
1926
  }
@@ -3124,7 +3130,7 @@ function diffPlayRunStreamEvents(input) {
3124
3130
  return { events, next };
3125
3131
  }
3126
3132
 
3127
- // src/stream-reconnect.ts
3133
+ // src/runs/read-errors.ts
3128
3134
  function isTransientPlayRunReadError(error) {
3129
3135
  if (error instanceof DeeplineError && error.code === "PLAY_STREAM_NETWORK_ABORTED") {
3130
3136
  return true;
@@ -3392,7 +3398,6 @@ function parseNotificationGroupTarget(value) {
3392
3398
  function notificationObjectKey(kind) {
3393
3399
  return `${kind}.${globalThis.crypto.randomUUID()}`;
3394
3400
  }
3395
- var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
3396
3401
  var MONITOR_NON_RETRYABLE_MUTATION_OPTIONS = {
3397
3402
  maxRetries: 0,
3398
3403
  exactUrlOnly: true
@@ -3499,7 +3504,11 @@ function runtimeSelectionHeaders(runtime) {
3499
3504
  "RUNTIME_ENVIRONMENT_TOKEN_REQUIRED"
3500
3505
  );
3501
3506
  }
3502
- return { [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token };
3507
+ const receivers = process.env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
3508
+ return {
3509
+ [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
3510
+ ...receivers ? { [RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}
3511
+ };
3503
3512
  }
3504
3513
  function normalizeTestPolicyOverrides(value, source) {
3505
3514
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -3683,7 +3692,7 @@ function normalizePlayRunStart(raw) {
3683
3692
  name: runPackage.run.playName,
3684
3693
  status,
3685
3694
  ...runPackage.run.dashboardUrl ? { dashboardUrl: runPackage.run.dashboardUrl } : {},
3686
- ...TERMINAL_PLAY_STATUSES.has(status) ? { finalStatus: runPackage } : {},
3695
+ ...isTerminalPlayRunLifecycleStatus(status) ? { finalStatus: runPackage } : {},
3687
3696
  package: runPackage
3688
3697
  };
3689
3698
  }
@@ -3761,11 +3770,12 @@ function readStringArray(value) {
3761
3770
  function getPlayLiveEventPayload(event) {
3762
3771
  return event.payload && typeof event.payload === "object" ? event.payload : {};
3763
3772
  }
3764
- function normalizeLiveStatus(value) {
3765
- if (value === "queued" || value === "running" || value === "waiting" || value === "completed" || value === "failed" || value === "cancelled") {
3766
- return value;
3773
+ function playLiveRunStatus(event) {
3774
+ if (event.type !== "play.run.snapshot" && event.type !== "play.run.status" && event.type !== "play.run.final_status") {
3775
+ return null;
3767
3776
  }
3768
- return null;
3777
+ const payload = getPlayLiveEventPayload(event);
3778
+ return decodePlayRunPublicStatus(payload.status) ?? (isPlayRunPackage(payload) ? decodePlayRunPublicStatus(payload.run.status) : null);
3769
3779
  }
3770
3780
  function appendPlayLiveLogLines(state, payload) {
3771
3781
  const lines = readStringArray(payload.lines);
@@ -3798,7 +3808,7 @@ function updatePlayLiveStatusState(state, event) {
3798
3808
  return null;
3799
3809
  }
3800
3810
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
3801
- const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
3811
+ const status = playLiveRunStatus(event) ?? state.status;
3802
3812
  const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
3803
3813
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
3804
3814
  const payloadLogs = readStringArray(payload.logs);
@@ -4956,13 +4966,6 @@ var DeeplineClient = class _DeeplineClient {
4956
4966
  }
4957
4967
  /** Poll snapshots to terminal status and return the durable package. */
4958
4968
  async watchRunToTerminal(runId, options) {
4959
- const state = {
4960
- runId,
4961
- status: "running",
4962
- logs: [],
4963
- lastLogSeq: 0,
4964
- latest: null
4965
- };
4966
4969
  let terminalObserved = false;
4967
4970
  for await (const event of this.watchRunEvents(runId, {
4968
4971
  signal: options?.signal,
@@ -4970,19 +4973,17 @@ var DeeplineClient = class _DeeplineClient {
4970
4973
  onRetry: options?.onRetry ?? options?.onReconnect
4971
4974
  })) {
4972
4975
  options?.onEvent?.(event);
4973
- const status = updatePlayLiveStatusState(state, event);
4974
- if (status && TERMINAL_PLAY_STATUSES.has(status.status)) {
4976
+ if (isTerminalPlayRunLifecycleStatus(playLiveRunStatus(event))) {
4975
4977
  terminalObserved = true;
4976
4978
  }
4977
4979
  }
4978
4980
  if (options?.signal?.aborted) {
4979
4981
  throw new DeeplineError("Run watch aborted.", void 0, "ABORTED");
4980
4982
  }
4981
- if (terminalObserved) {
4982
- return await this.getRunStatus(runId);
4983
- }
4984
4983
  const refreshed = await this.getRunStatus(runId);
4985
- if (TERMINAL_PLAY_STATUSES.has(refreshed.status)) return refreshed;
4984
+ if (terminalObserved || isTerminalPlayRunLifecycleStatus(refreshed.status)) {
4985
+ return refreshed;
4986
+ }
4986
4987
  throw new DeeplineError(
4987
4988
  `Run watch for ${runId} ended before a terminal status.`,
4988
4989
  void 0,
@@ -5163,15 +5164,7 @@ var DeeplineClient = class _DeeplineClient {
5163
5164
  `/api/v2/runs/${encodeURIComponent(runId)}${query}`,
5164
5165
  { headers: { "x-deepline-run-status": "1" } }
5165
5166
  );
5166
- const responseRunStatus = isPlayRunPackage(response) ? response.runStatus : isPlayRunPackage(response.package) ? response.package.runStatus : response.runStatus;
5167
- const responseOverview = isPlayRunPackage(response) ? response.overview : isPlayRunPackage(response.package) ? response.package.overview : response.overview;
5168
5167
  const status = normalizePlayStatus(response);
5169
- if (isRecord4(responseRunStatus)) {
5170
- status.runStatus = responseRunStatus;
5171
- }
5172
- if (isRecord4(responseOverview)) {
5173
- status.overview = responseOverview;
5174
- }
5175
5168
  if (options?.failedLogs !== true || status.status !== "failed") {
5176
5169
  return status;
5177
5170
  }
@@ -6149,7 +6142,7 @@ var DeeplineClient = class _DeeplineClient {
6149
6142
  if (event.type !== "play.run.status" || status.status !== previousStatus) {
6150
6143
  options?.onProgress?.(status);
6151
6144
  }
6152
- if (TERMINAL_PLAY_STATUSES.has(status.status)) {
6145
+ if (isTerminalPlayRunLifecycleStatus(status.status)) {
6153
6146
  terminalObserved = status;
6154
6147
  }
6155
6148
  }
@@ -21,9 +21,9 @@
21
21
  "dist/bundling-sources/sdk/src/plays/local-file-discovery.ts",
22
22
  "dist/bundling-sources/sdk/src/release.ts",
23
23
  "dist/bundling-sources/sdk/src/runs/observe-transport.ts",
24
+ "dist/bundling-sources/sdk/src/runs/read-errors.ts",
24
25
  "dist/bundling-sources/sdk/src/runs/watch-polling.ts",
25
26
  "dist/bundling-sources/sdk/src/skills-version.ts",
26
- "dist/bundling-sources/sdk/src/stream-reconnect.ts",
27
27
  "dist/bundling-sources/sdk/src/tool-calls.ts",
28
28
  "dist/bundling-sources/sdk/src/tool-output.ts",
29
29
  "dist/bundling-sources/sdk/src/types.ts",
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.245";
152
+ readonly version: "0.3.246";
153
153
  readonly 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.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.d.ts CHANGED
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.245";
152
+ readonly version: "0.3.246";
153
153
  readonly 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.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.js CHANGED
@@ -74,7 +74,7 @@ var SDK_RELEASE = {
74
74
  // getters keep their established compatibility behavior.
75
75
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
76
76
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
77
- version: "0.3.245",
77
+ version: "0.3.246",
78
78
  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.",
79
79
  packageCapabilities: {
80
80
  updatePreferences: 1
package/dist/release.mjs CHANGED
@@ -48,7 +48,7 @@ var SDK_RELEASE = {
48
48
  // getters keep their established compatibility behavior.
49
49
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
50
50
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
51
- version: "0.3.245",
51
+ version: "0.3.246",
52
52
  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.",
53
53
  packageCapabilities: {
54
54
  updatePreferences: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.245",
3
+ "version": "0.3.246",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",