deepline 0.3.229 → 0.3.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  3. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +19 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +47 -32
  5. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +3 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +38 -2
  7. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +8 -3
  8. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +9 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +293 -4
  11. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +29 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +50 -10
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +1 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +4 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +4 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +187 -14
  17. package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +52 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +5 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +30 -2
  20. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +118 -6
  21. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +135 -21
  22. package/dist/cli/index.js +109 -7
  23. package/dist/cli/index.mjs +109 -7
  24. package/dist/index.js +93 -2
  25. package/dist/index.mjs +93 -2
  26. package/dist/release.d.mts +1 -1
  27. package/dist/release.d.ts +1 -1
  28. package/dist/release.js +1 -1
  29. package/dist/release.mjs +1 -1
  30. package/package.json +1 -1
@@ -3046,7 +3046,7 @@ var SDK_RELEASE = {
3046
3046
  // getters keep their established compatibility behavior.
3047
3047
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3048
3048
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3049
- version: "0.3.229",
3049
+ version: "0.3.231",
3050
3050
  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.",
3051
3051
  packageCapabilities: {
3052
3052
  updatePreferences: 1
@@ -5379,12 +5379,84 @@ function normalizeDatasetBornFrom(value) {
5379
5379
 
5380
5380
  // ../play-runtime/run-ledger.ts
5381
5381
  var LOG_TAIL_LIMIT = 100;
5382
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
5383
+ "completed",
5384
+ "failed",
5385
+ "cancelled",
5386
+ "terminated",
5387
+ "timed_out"
5388
+ ]);
5382
5389
  function isRecord5(value) {
5383
5390
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
5384
5391
  }
5385
5392
  function finiteNumber(value) {
5386
5393
  return typeof value === "number" && Number.isFinite(value) ? value : null;
5387
5394
  }
5395
+ function nonnegativeSafeInteger(value) {
5396
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
5397
+ }
5398
+ function isWorkCounterSegmentId(value) {
5399
+ return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
5400
+ value
5401
+ );
5402
+ }
5403
+ function normalizePlayRunLedgerTerminalWorkCounterSegment(value) {
5404
+ if (!isRecord5(value)) return void 0;
5405
+ if (!nonnegativeSafeInteger(value.attempt) || !nonnegativeSafeInteger(value.invocationSeq) || value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId)) {
5406
+ return void 0;
5407
+ }
5408
+ return {
5409
+ attempt: value.attempt,
5410
+ invocationSeq: value.invocationSeq,
5411
+ segmentId: value.segmentId
5412
+ };
5413
+ }
5414
+ function hasConfirmedPlayRunLedgerWorkCounters(snapshot) {
5415
+ const counters = snapshot.workCounters;
5416
+ const terminal = snapshot.terminalWorkCounterSegment;
5417
+ return Boolean(
5418
+ isTerminalPlayRunLedgerStatus(snapshot.status) && (snapshot.terminalSource === "worker" || snapshot.terminalSource === "system") && counters?.final && counters.completeThroughAttempt && counters.consistent && terminal && counters.attempt === terminal.attempt && counters.invocationSeq === terminal.invocationSeq && counters.segmentId === terminal.segmentId && Number.isSafeInteger(
5419
+ counters.completedLogicalCalls + counters.logicalCalls
5420
+ ) && Number.isSafeInteger(
5421
+ counters.completedProviderRequests + counters.providerRequests
5422
+ ) && Number.isSafeInteger(
5423
+ counters.completedProvider429s + counters.provider429s
5424
+ )
5425
+ );
5426
+ }
5427
+ function normalizeWorkCounters(value) {
5428
+ if (!isRecord5(value)) return void 0;
5429
+ for (const field of [
5430
+ "attempt",
5431
+ "invocationSeq",
5432
+ "logicalCalls",
5433
+ "providerRequests",
5434
+ "provider429s",
5435
+ "completedLogicalCalls",
5436
+ "completedProviderRequests",
5437
+ "completedProvider429s"
5438
+ ]) {
5439
+ if (!nonnegativeSafeInteger(value[field])) return void 0;
5440
+ }
5441
+ if (value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId) || typeof value.final !== "boolean" || typeof value.completeThroughAttempt !== "boolean" || typeof value.consistent !== "boolean") {
5442
+ return void 0;
5443
+ }
5444
+ return {
5445
+ ...value,
5446
+ attempt: value.attempt,
5447
+ invocationSeq: value.invocationSeq,
5448
+ segmentId: value.segmentId,
5449
+ logicalCalls: value.logicalCalls,
5450
+ providerRequests: value.providerRequests,
5451
+ provider429s: value.provider429s,
5452
+ final: value.final,
5453
+ completedLogicalCalls: value.completedLogicalCalls,
5454
+ completedProviderRequests: value.completedProviderRequests,
5455
+ completedProvider429s: value.completedProvider429s,
5456
+ completeThroughAttempt: value.completeThroughAttempt,
5457
+ consistent: value.consistent
5458
+ };
5459
+ }
5388
5460
  function optionalFiniteNumber(value) {
5389
5461
  const normalized = finiteNumber(value);
5390
5462
  return normalized === null ? void 0 : normalized;
@@ -5426,6 +5498,9 @@ function normalizePlayRunLedgerStatus(value) {
5426
5498
  return "unknown";
5427
5499
  }
5428
5500
  }
5501
+ function isTerminalPlayRunLedgerStatus(status) {
5502
+ return TERMINAL_STATUSES.has(status);
5503
+ }
5429
5504
  function summarizeRunRowOutcomes(snapshot) {
5430
5505
  let completedRows = 0;
5431
5506
  let failedRows = 0;
@@ -5560,6 +5635,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
5560
5635
  const error = Object.prototype.hasOwnProperty.call(value, "error") ? optionalNullableString(value.error) ?? null : fallback.error ?? null;
5561
5636
  const rawTail = Array.isArray(value.logTail) ? value.logTail : value.logs;
5562
5637
  const logTail = Array.isArray(rawTail) ? rawTail.filter((line) => typeof line === "string") : [];
5638
+ const workCounters = normalizeWorkCounters(value.workCounters);
5639
+ const terminalWorkCounterSegment = normalizePlayRunLedgerTerminalWorkCounterSegment(
5640
+ value.terminalWorkCounterSegment
5641
+ );
5563
5642
  return {
5564
5643
  runId: optionalString(value.runId) ?? fallback.runId,
5565
5644
  playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
@@ -5582,6 +5661,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
5582
5661
  (activityId) => typeof activityId === "string" && Boolean(activitiesById[activityId])
5583
5662
  ),
5584
5663
  activitiesById,
5664
+ ...workCounters ? { workCounters } : {},
5665
+ ...terminalWorkCounterSegment ? { terminalWorkCounterSegment } : {},
5585
5666
  logTail: logTail.slice(-LOG_TAIL_LIMIT),
5586
5667
  // Snapshots persisted before totalLogCount existed only know the retained
5587
5668
  // tail, so the best lower bound for the cumulative count is the tail size.
@@ -5889,6 +5970,13 @@ function buildSnapshotFromLedger(snapshot) {
5889
5970
  const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
5890
5971
  const terminalRowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) ? summarizeRunRowOutcomes(snapshot) : null;
5891
5972
  const rowOutcomes = terminalRowOutcomes && (Object.keys(snapshot.stepsById).length > 0 || terminalRowOutcomes.totalRows > 0 || (terminalRowOutcomes.supersededRows ?? 0) > 0) ? terminalRowOutcomes : null;
5973
+ const workCounters = snapshot.workCounters;
5974
+ const calls = workCounters ? {
5975
+ logicalCalls: workCounters.completedLogicalCalls + workCounters.logicalCalls,
5976
+ providerRequests: workCounters.completedProviderRequests + workCounters.providerRequests,
5977
+ provider429s: workCounters.completedProvider429s + workCounters.provider429s,
5978
+ confirmed: isTerminalPlayRunLiveStatus(liveStatus) && hasConfirmedPlayRunLedgerWorkCounters(snapshot)
5979
+ } : null;
5892
5980
  return {
5893
5981
  runId: snapshot.runId,
5894
5982
  status: liveStatus,
@@ -5913,7 +6001,10 @@ function buildSnapshotFromLedger(snapshot) {
5913
6001
  activeActivity: snapshot.activeActivityId ? snapshot.activitiesById[snapshot.activeActivityId] ?? null : null,
5914
6002
  nodeStates,
5915
6003
  activeNodeId: snapshot.activeStepId ?? null,
5916
- ...rowOutcomes ? { rowOutcomes } : {}
6004
+ ...rowOutcomes ? { rowOutcomes } : {},
6005
+ ...calls && Object.values(calls).every(
6006
+ (value) => typeof value === "boolean" || Number.isSafeInteger(value)
6007
+ ) ? { calls } : {}
5917
6008
  };
5918
6009
  }
5919
6010
  function buildPlayRunStatusSnapshot(input2) {
@@ -25117,6 +25208,15 @@ function getProgressLinesFromLiveEvent(event) {
25117
25208
  `progress ${formatProgressLabel(record3.nodeId ?? progress.artifactTableNamespace)}: ${counts}${messageSuffix}`
25118
25209
  );
25119
25210
  }
25211
+ const calls = readRecord(payload.calls);
25212
+ const callCounts = calls ? [calls.logicalCalls, calls.providerRequests, calls.provider429s] : [];
25213
+ if (callCounts.length === 3 && callCounts.every(
25214
+ (count) => typeof count === "number" && Number.isSafeInteger(count) && count >= 0
25215
+ )) {
25216
+ lines.push(
25217
+ `progress calls: ${formatInteger(callCounts[0])} logical, ${formatInteger(callCounts[1])} provider requests, ${formatInteger(callCounts[2])} provider 429s${calls?.confirmed === true ? "" : " (observed)"}`
25218
+ );
25219
+ }
25120
25220
  const rowOutcomes = readRowOutcomeSummary({
25121
25221
  rowOutcomes: payload.rowOutcomes
25122
25222
  });
@@ -50232,7 +50332,7 @@ async function searchTools(queryInput, options = {}) {
50232
50332
  tools: result.tools.slice(0, 8).map(compactTool)
50233
50333
  } : result;
50234
50334
  printCommandEnvelope(payload, {
50235
- json: options.json || shouldEmitJson()
50335
+ json: options.json === true
50236
50336
  });
50237
50337
  return 0;
50238
50338
  }
@@ -50461,11 +50561,13 @@ Notes:
50461
50561
  Use a provider name in the query; --prefix is not a supported option.
50462
50562
  The grep alias is the same ranked retrieval surface with a more literal name
50463
50563
  for agents that are filtering a registry rather than choosing a workflow.
50564
+ Search prints a readable result list by default, piped or not, and that is
50565
+ the recommended form. Pass --json only when a program parses the result.
50464
50566
 
50465
50567
  Examples:
50466
- deepline tools search email --limit 10 --json
50467
- deepline tools search email --limit 10 --offset 10 --json
50468
- deepline tools search linkedin --task "I have 200 LinkedIn profile URLs and need each person's current title and company" --json
50568
+ deepline tools search email --limit 10
50569
+ deepline tools search email --limit 10 --offset 10
50570
+ deepline tools search linkedin --task "I have 200 LinkedIn profile URLs and need each person's current title and company"
50469
50571
  deepline tools search --categories company_search --search_terms "investors,funding"
50470
50572
  deepline tools grep "company enrichment" --categories enrichment --json
50471
50573
  deepline tools search verifier --search-mode v2 --json
@@ -50479,7 +50581,7 @@ Examples:
50479
50581
  ).option("--search-terms <terms>", "Alias for --search_terms").option(
50480
50582
  "--task <sentence>",
50481
50583
  "What you are trying to accomplish: input you have -> result you need"
50482
- ).option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--compact", "Drop verbose fields from JSON output").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (query, options) => {
50584
+ ).option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--compact", "Drop verbose fields from JSON output").option("--json", "Emit JSON output instead of the readable default").action(async (query, options) => {
50483
50585
  process.exitCode = await searchTools(query, {
50484
50586
  json: options.json,
50485
50587
  compact: options.compact,
package/dist/index.js CHANGED
@@ -864,7 +864,7 @@ var SDK_RELEASE = {
864
864
  // getters keep their established compatibility behavior.
865
865
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
866
866
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
867
- version: "0.3.229",
867
+ version: "0.3.231",
868
868
  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.",
869
869
  packageCapabilities: {
870
870
  updatePreferences: 1
@@ -3135,12 +3135,84 @@ function normalizeDatasetBornFrom(value) {
3135
3135
 
3136
3136
  // ../play-runtime/run-ledger.ts
3137
3137
  var LOG_TAIL_LIMIT = 100;
3138
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
3139
+ "completed",
3140
+ "failed",
3141
+ "cancelled",
3142
+ "terminated",
3143
+ "timed_out"
3144
+ ]);
3138
3145
  function isRecord5(value) {
3139
3146
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
3140
3147
  }
3141
3148
  function finiteNumber(value) {
3142
3149
  return typeof value === "number" && Number.isFinite(value) ? value : null;
3143
3150
  }
3151
+ function nonnegativeSafeInteger(value) {
3152
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
3153
+ }
3154
+ function isWorkCounterSegmentId(value) {
3155
+ return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
3156
+ value
3157
+ );
3158
+ }
3159
+ function normalizePlayRunLedgerTerminalWorkCounterSegment(value) {
3160
+ if (!isRecord5(value)) return void 0;
3161
+ if (!nonnegativeSafeInteger(value.attempt) || !nonnegativeSafeInteger(value.invocationSeq) || value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId)) {
3162
+ return void 0;
3163
+ }
3164
+ return {
3165
+ attempt: value.attempt,
3166
+ invocationSeq: value.invocationSeq,
3167
+ segmentId: value.segmentId
3168
+ };
3169
+ }
3170
+ function hasConfirmedPlayRunLedgerWorkCounters(snapshot) {
3171
+ const counters = snapshot.workCounters;
3172
+ const terminal = snapshot.terminalWorkCounterSegment;
3173
+ return Boolean(
3174
+ isTerminalPlayRunLedgerStatus(snapshot.status) && (snapshot.terminalSource === "worker" || snapshot.terminalSource === "system") && counters?.final && counters.completeThroughAttempt && counters.consistent && terminal && counters.attempt === terminal.attempt && counters.invocationSeq === terminal.invocationSeq && counters.segmentId === terminal.segmentId && Number.isSafeInteger(
3175
+ counters.completedLogicalCalls + counters.logicalCalls
3176
+ ) && Number.isSafeInteger(
3177
+ counters.completedProviderRequests + counters.providerRequests
3178
+ ) && Number.isSafeInteger(
3179
+ counters.completedProvider429s + counters.provider429s
3180
+ )
3181
+ );
3182
+ }
3183
+ function normalizeWorkCounters(value) {
3184
+ if (!isRecord5(value)) return void 0;
3185
+ for (const field of [
3186
+ "attempt",
3187
+ "invocationSeq",
3188
+ "logicalCalls",
3189
+ "providerRequests",
3190
+ "provider429s",
3191
+ "completedLogicalCalls",
3192
+ "completedProviderRequests",
3193
+ "completedProvider429s"
3194
+ ]) {
3195
+ if (!nonnegativeSafeInteger(value[field])) return void 0;
3196
+ }
3197
+ if (value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId) || typeof value.final !== "boolean" || typeof value.completeThroughAttempt !== "boolean" || typeof value.consistent !== "boolean") {
3198
+ return void 0;
3199
+ }
3200
+ return {
3201
+ ...value,
3202
+ attempt: value.attempt,
3203
+ invocationSeq: value.invocationSeq,
3204
+ segmentId: value.segmentId,
3205
+ logicalCalls: value.logicalCalls,
3206
+ providerRequests: value.providerRequests,
3207
+ provider429s: value.provider429s,
3208
+ final: value.final,
3209
+ completedLogicalCalls: value.completedLogicalCalls,
3210
+ completedProviderRequests: value.completedProviderRequests,
3211
+ completedProvider429s: value.completedProvider429s,
3212
+ completeThroughAttempt: value.completeThroughAttempt,
3213
+ consistent: value.consistent
3214
+ };
3215
+ }
3144
3216
  function optionalFiniteNumber(value) {
3145
3217
  const normalized = finiteNumber(value);
3146
3218
  return normalized === null ? void 0 : normalized;
@@ -3182,6 +3254,9 @@ function normalizePlayRunLedgerStatus(value) {
3182
3254
  return "unknown";
3183
3255
  }
3184
3256
  }
3257
+ function isTerminalPlayRunLedgerStatus(status) {
3258
+ return TERMINAL_STATUSES.has(status);
3259
+ }
3185
3260
  function summarizeRunRowOutcomes(snapshot) {
3186
3261
  let completedRows = 0;
3187
3262
  let failedRows = 0;
@@ -3316,6 +3391,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
3316
3391
  const error = Object.prototype.hasOwnProperty.call(value, "error") ? optionalNullableString(value.error) ?? null : fallback.error ?? null;
3317
3392
  const rawTail = Array.isArray(value.logTail) ? value.logTail : value.logs;
3318
3393
  const logTail = Array.isArray(rawTail) ? rawTail.filter((line) => typeof line === "string") : [];
3394
+ const workCounters = normalizeWorkCounters(value.workCounters);
3395
+ const terminalWorkCounterSegment = normalizePlayRunLedgerTerminalWorkCounterSegment(
3396
+ value.terminalWorkCounterSegment
3397
+ );
3319
3398
  return {
3320
3399
  runId: optionalString(value.runId) ?? fallback.runId,
3321
3400
  playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
@@ -3338,6 +3417,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
3338
3417
  (activityId) => typeof activityId === "string" && Boolean(activitiesById[activityId])
3339
3418
  ),
3340
3419
  activitiesById,
3420
+ ...workCounters ? { workCounters } : {},
3421
+ ...terminalWorkCounterSegment ? { terminalWorkCounterSegment } : {},
3341
3422
  logTail: logTail.slice(-LOG_TAIL_LIMIT),
3342
3423
  // Snapshots persisted before totalLogCount existed only know the retained
3343
3424
  // tail, so the best lower bound for the cumulative count is the tail size.
@@ -3545,6 +3626,13 @@ function buildSnapshotFromLedger(snapshot) {
3545
3626
  const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
3546
3627
  const terminalRowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) ? summarizeRunRowOutcomes(snapshot) : null;
3547
3628
  const rowOutcomes = terminalRowOutcomes && (Object.keys(snapshot.stepsById).length > 0 || terminalRowOutcomes.totalRows > 0 || (terminalRowOutcomes.supersededRows ?? 0) > 0) ? terminalRowOutcomes : null;
3629
+ const workCounters = snapshot.workCounters;
3630
+ const calls = workCounters ? {
3631
+ logicalCalls: workCounters.completedLogicalCalls + workCounters.logicalCalls,
3632
+ providerRequests: workCounters.completedProviderRequests + workCounters.providerRequests,
3633
+ provider429s: workCounters.completedProvider429s + workCounters.provider429s,
3634
+ confirmed: isTerminalPlayRunLiveStatus(liveStatus) && hasConfirmedPlayRunLedgerWorkCounters(snapshot)
3635
+ } : null;
3548
3636
  return {
3549
3637
  runId: snapshot.runId,
3550
3638
  status: liveStatus,
@@ -3569,7 +3657,10 @@ function buildSnapshotFromLedger(snapshot) {
3569
3657
  activeActivity: snapshot.activeActivityId ? snapshot.activitiesById[snapshot.activeActivityId] ?? null : null,
3570
3658
  nodeStates,
3571
3659
  activeNodeId: snapshot.activeStepId ?? null,
3572
- ...rowOutcomes ? { rowOutcomes } : {}
3660
+ ...rowOutcomes ? { rowOutcomes } : {},
3661
+ ...calls && Object.values(calls).every(
3662
+ (value) => typeof value === "boolean" || Number.isSafeInteger(value)
3663
+ ) ? { calls } : {}
3573
3664
  };
3574
3665
  }
3575
3666
  function buildPlayRunStatusSnapshot(input) {
package/dist/index.mjs CHANGED
@@ -768,7 +768,7 @@ var SDK_RELEASE = {
768
768
  // getters keep their established compatibility behavior.
769
769
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
770
770
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
771
- version: "0.3.229",
771
+ version: "0.3.231",
772
772
  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.",
773
773
  packageCapabilities: {
774
774
  updatePreferences: 1
@@ -3039,12 +3039,84 @@ function normalizeDatasetBornFrom(value) {
3039
3039
 
3040
3040
  // ../play-runtime/run-ledger.ts
3041
3041
  var LOG_TAIL_LIMIT = 100;
3042
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
3043
+ "completed",
3044
+ "failed",
3045
+ "cancelled",
3046
+ "terminated",
3047
+ "timed_out"
3048
+ ]);
3042
3049
  function isRecord5(value) {
3043
3050
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
3044
3051
  }
3045
3052
  function finiteNumber(value) {
3046
3053
  return typeof value === "number" && Number.isFinite(value) ? value : null;
3047
3054
  }
3055
+ function nonnegativeSafeInteger(value) {
3056
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
3057
+ }
3058
+ function isWorkCounterSegmentId(value) {
3059
+ return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
3060
+ value
3061
+ );
3062
+ }
3063
+ function normalizePlayRunLedgerTerminalWorkCounterSegment(value) {
3064
+ if (!isRecord5(value)) return void 0;
3065
+ if (!nonnegativeSafeInteger(value.attempt) || !nonnegativeSafeInteger(value.invocationSeq) || value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId)) {
3066
+ return void 0;
3067
+ }
3068
+ return {
3069
+ attempt: value.attempt,
3070
+ invocationSeq: value.invocationSeq,
3071
+ segmentId: value.segmentId
3072
+ };
3073
+ }
3074
+ function hasConfirmedPlayRunLedgerWorkCounters(snapshot) {
3075
+ const counters = snapshot.workCounters;
3076
+ const terminal = snapshot.terminalWorkCounterSegment;
3077
+ return Boolean(
3078
+ isTerminalPlayRunLedgerStatus(snapshot.status) && (snapshot.terminalSource === "worker" || snapshot.terminalSource === "system") && counters?.final && counters.completeThroughAttempt && counters.consistent && terminal && counters.attempt === terminal.attempt && counters.invocationSeq === terminal.invocationSeq && counters.segmentId === terminal.segmentId && Number.isSafeInteger(
3079
+ counters.completedLogicalCalls + counters.logicalCalls
3080
+ ) && Number.isSafeInteger(
3081
+ counters.completedProviderRequests + counters.providerRequests
3082
+ ) && Number.isSafeInteger(
3083
+ counters.completedProvider429s + counters.provider429s
3084
+ )
3085
+ );
3086
+ }
3087
+ function normalizeWorkCounters(value) {
3088
+ if (!isRecord5(value)) return void 0;
3089
+ for (const field of [
3090
+ "attempt",
3091
+ "invocationSeq",
3092
+ "logicalCalls",
3093
+ "providerRequests",
3094
+ "provider429s",
3095
+ "completedLogicalCalls",
3096
+ "completedProviderRequests",
3097
+ "completedProvider429s"
3098
+ ]) {
3099
+ if (!nonnegativeSafeInteger(value[field])) return void 0;
3100
+ }
3101
+ if (value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId) || typeof value.final !== "boolean" || typeof value.completeThroughAttempt !== "boolean" || typeof value.consistent !== "boolean") {
3102
+ return void 0;
3103
+ }
3104
+ return {
3105
+ ...value,
3106
+ attempt: value.attempt,
3107
+ invocationSeq: value.invocationSeq,
3108
+ segmentId: value.segmentId,
3109
+ logicalCalls: value.logicalCalls,
3110
+ providerRequests: value.providerRequests,
3111
+ provider429s: value.provider429s,
3112
+ final: value.final,
3113
+ completedLogicalCalls: value.completedLogicalCalls,
3114
+ completedProviderRequests: value.completedProviderRequests,
3115
+ completedProvider429s: value.completedProvider429s,
3116
+ completeThroughAttempt: value.completeThroughAttempt,
3117
+ consistent: value.consistent
3118
+ };
3119
+ }
3048
3120
  function optionalFiniteNumber(value) {
3049
3121
  const normalized = finiteNumber(value);
3050
3122
  return normalized === null ? void 0 : normalized;
@@ -3086,6 +3158,9 @@ function normalizePlayRunLedgerStatus(value) {
3086
3158
  return "unknown";
3087
3159
  }
3088
3160
  }
3161
+ function isTerminalPlayRunLedgerStatus(status) {
3162
+ return TERMINAL_STATUSES.has(status);
3163
+ }
3089
3164
  function summarizeRunRowOutcomes(snapshot) {
3090
3165
  let completedRows = 0;
3091
3166
  let failedRows = 0;
@@ -3220,6 +3295,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
3220
3295
  const error = Object.prototype.hasOwnProperty.call(value, "error") ? optionalNullableString(value.error) ?? null : fallback.error ?? null;
3221
3296
  const rawTail = Array.isArray(value.logTail) ? value.logTail : value.logs;
3222
3297
  const logTail = Array.isArray(rawTail) ? rawTail.filter((line) => typeof line === "string") : [];
3298
+ const workCounters = normalizeWorkCounters(value.workCounters);
3299
+ const terminalWorkCounterSegment = normalizePlayRunLedgerTerminalWorkCounterSegment(
3300
+ value.terminalWorkCounterSegment
3301
+ );
3223
3302
  return {
3224
3303
  runId: optionalString(value.runId) ?? fallback.runId,
3225
3304
  playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
@@ -3242,6 +3321,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
3242
3321
  (activityId) => typeof activityId === "string" && Boolean(activitiesById[activityId])
3243
3322
  ),
3244
3323
  activitiesById,
3324
+ ...workCounters ? { workCounters } : {},
3325
+ ...terminalWorkCounterSegment ? { terminalWorkCounterSegment } : {},
3245
3326
  logTail: logTail.slice(-LOG_TAIL_LIMIT),
3246
3327
  // Snapshots persisted before totalLogCount existed only know the retained
3247
3328
  // tail, so the best lower bound for the cumulative count is the tail size.
@@ -3449,6 +3530,13 @@ function buildSnapshotFromLedger(snapshot) {
3449
3530
  const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
3450
3531
  const terminalRowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) ? summarizeRunRowOutcomes(snapshot) : null;
3451
3532
  const rowOutcomes = terminalRowOutcomes && (Object.keys(snapshot.stepsById).length > 0 || terminalRowOutcomes.totalRows > 0 || (terminalRowOutcomes.supersededRows ?? 0) > 0) ? terminalRowOutcomes : null;
3533
+ const workCounters = snapshot.workCounters;
3534
+ const calls = workCounters ? {
3535
+ logicalCalls: workCounters.completedLogicalCalls + workCounters.logicalCalls,
3536
+ providerRequests: workCounters.completedProviderRequests + workCounters.providerRequests,
3537
+ provider429s: workCounters.completedProvider429s + workCounters.provider429s,
3538
+ confirmed: isTerminalPlayRunLiveStatus(liveStatus) && hasConfirmedPlayRunLedgerWorkCounters(snapshot)
3539
+ } : null;
3452
3540
  return {
3453
3541
  runId: snapshot.runId,
3454
3542
  status: liveStatus,
@@ -3473,7 +3561,10 @@ function buildSnapshotFromLedger(snapshot) {
3473
3561
  activeActivity: snapshot.activeActivityId ? snapshot.activitiesById[snapshot.activeActivityId] ?? null : null,
3474
3562
  nodeStates,
3475
3563
  activeNodeId: snapshot.activeStepId ?? null,
3476
- ...rowOutcomes ? { rowOutcomes } : {}
3564
+ ...rowOutcomes ? { rowOutcomes } : {},
3565
+ ...calls && Object.values(calls).every(
3566
+ (value) => typeof value === "boolean" || Number.isSafeInteger(value)
3567
+ ) ? { calls } : {}
3477
3568
  };
3478
3569
  }
3479
3570
  function buildPlayRunStatusSnapshot(input) {
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.229";
152
+ readonly version: "0.3.231";
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.229";
152
+ readonly version: "0.3.231";
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.229",
77
+ version: "0.3.231",
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.229",
51
+ version: "0.3.231",
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.229",
3
+ "version": "0.3.231",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",