deepline 0.2.40 → 0.2.41

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.
@@ -86,10 +86,7 @@ import type { PlayStagedFileRef } from './plays/local-file-discovery.js';
86
86
  import type { PlayCompilerManifest } from '../../shared_libs/plays/compiler-manifest.js';
87
87
  import type { EnrichCompiledConfig } from './cli/enrich-play-compiler.js';
88
88
  import { RUNTIME_ENVIRONMENT_TOKEN_HEADER } from '../../shared_libs/play-runtime/coordinator-headers.js';
89
- import {
90
- THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS,
91
- usesExtendedTheirstackJobSearchBudget,
92
- } from '../../shared_libs/integrations/theirstack-execution-policy.js';
89
+ import { resolveTheirstackClientTimeoutMs } from '../../shared_libs/integrations/theirstack-execution-policy.js';
93
90
  import {
94
91
  normalizePlayRuntimeEnvironment,
95
92
  normalizePlayRuntimeNamespace,
@@ -424,9 +421,11 @@ function resolveToolExecuteTimeoutMs(
424
421
  // Provider-specific slow-request policies live in shared modules so the SDK
425
422
  // and server classify the same payloads. If more providers need this, replace
426
423
  // these individual checks with a shared policy registry, not a wider default.
427
- if (usesExtendedTheirstackJobSearchBudget(normalized, input)) {
428
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
429
- }
424
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
425
+ normalized,
426
+ input,
427
+ );
428
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
430
429
  return normalized === 'deeplineagent' ||
431
430
  normalized === 'deeplineagent_deeplineagent' ||
432
431
  normalized === 'ai_inference' ||
@@ -160,7 +160,7 @@ export const SDK_RELEASE = {
160
160
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
161
161
  // exposed storage-dependent synchronous access. This deliberate minor
162
162
  // release keeps lazy paging semantics independent of row residency.
163
- version: '0.2.40',
163
+ version: '0.2.41',
164
164
  contracts: {
165
165
  api: {
166
166
  name: 'sdk-http-api',
@@ -23,6 +23,14 @@ export const THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135_000;
23
23
  export const THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS =
24
24
  60_000 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15_000;
25
25
 
26
+ /**
27
+ * TheirStack company search is synchronous but can spend the full upstream
28
+ * request window before returning a large result set. The SDK default is only
29
+ * 60 seconds, so keep it alive through the server's 120-second provider
30
+ * deadline plus the same permit and response grace used for slow job search.
31
+ */
32
+ export const THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 210_000;
33
+
26
34
  const LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1_000;
27
35
  const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
28
36
 
@@ -95,3 +103,16 @@ export function usesExtendedTheirstackJobSearchBudget(
95
103
  ? true
96
104
  : usesLongExplicitDateWindow(payload);
97
105
  }
106
+
107
+ /** SDK-only timeout selection. Provider request timeouts remain action-local. */
108
+ export function resolveTheirstackClientTimeoutMs(
109
+ endpointId: string,
110
+ payload: Record<string, unknown>,
111
+ ): number | null {
112
+ if (endpointId === 'theirstack_company_search') {
113
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
114
+ }
115
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload)
116
+ ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS
117
+ : null;
118
+ }
@@ -77,7 +77,16 @@ export function workReceiptClaimConflictPredicateSql(input: {
77
77
  const forceFailedRefreshSql = input.forceFailedRefreshSql ?? 'false';
78
78
  return `${table}.status = ANY(${input.claimableStatusesSql}::smallint[])
79
79
  AND (
80
- ${input.forceRefreshSql}::boolean
80
+ (
81
+ ${input.forceRefreshSql}::boolean
82
+ AND (
83
+ ${table}.status NOT IN (
84
+ ${RECEIPT_STATUS_CODE.completed}::smallint,
85
+ ${RECEIPT_STATUS_CODE.skipped}::smallint
86
+ )
87
+ OR ${table}.run_id IS DISTINCT FROM ${input.claimantRunIdSql}
88
+ )
89
+ )
81
90
  OR (
82
91
  ${forceFailedRefreshSql}::boolean
83
92
  AND ${table}.status = ${RECEIPT_STATUS_CODE.failed}::smallint
@@ -111,6 +120,7 @@ export function workReceiptClaimConflictPredicateSql(input: {
111
120
  ${RECEIPT_STATUS_CODE.completed}::smallint,
112
121
  ${RECEIPT_STATUS_CODE.skipped}::smallint
113
122
  )
123
+ AND ${table}.run_id IS DISTINCT FROM ${input.claimantRunIdSql}
114
124
  AND (
115
125
  (
116
126
  ${table}.lease_id IS NULL
@@ -4402,8 +4402,8 @@ export async function claimRuntimeWorkReceipt(
4402
4402
  }
4403
4403
  if (
4404
4404
  latest &&
4405
- input.forceRefresh !== true &&
4406
- isReusableWorkReceipt(latest)
4405
+ isReusableWorkReceipt(latest) &&
4406
+ (input.forceRefresh !== true || latest.runId === input.runId)
4407
4407
  ) {
4408
4408
  return { disposition: 'reused', receipt: latest };
4409
4409
  }
@@ -4697,7 +4697,10 @@ export async function claimRuntimeWorkReceipts(
4697
4697
  });
4698
4698
  continue;
4699
4699
  }
4700
- if (input.forceRefresh !== true && isReusableWorkReceipt(receipt)) {
4700
+ if (
4701
+ isReusableWorkReceipt(receipt) &&
4702
+ (input.forceRefresh !== true || receipt.runId === input.runId)
4703
+ ) {
4701
4704
  claimsByKey.set(receipt.key, {
4702
4705
  disposition: 'reused',
4703
4706
  receipt,
@@ -277,6 +277,22 @@ export function decideWorkReceiptClaim(input: {
277
277
  }): WorkReceiptClaimDecision {
278
278
  if (!input.receipt) return { kind: 'claim' };
279
279
  const state = classifyWorkReceiptState(input.receipt, input.nowMs);
280
+ const sameLogicalRun =
281
+ normalize(input.claimantRunId) !== null &&
282
+ normalize(input.claimantRunId) === normalize(input.receipt.runId);
283
+ const sameRunNewerLeaseAttempt =
284
+ state.reusable &&
285
+ state.lease.kind === 'active' &&
286
+ state.lease.ownerRunId === normalize(input.claimantRunId) &&
287
+ state.lease.ownerAttempt < normalizeAttempt(input.claimantRunAttempt);
288
+ // Force refresh means new intent across runs. Within one run it is a replay,
289
+ // so reuse terminal output instead of creating a second terminal payload
290
+ // under the run's existing Runtime Sheet write version. A newer lease
291
+ // generation is the exception: it is a new attempt and retains the existing
292
+ // stale-owner fence semantics.
293
+ if (state.reusable && sameLogicalRun && !sameRunNewerLeaseAttempt) {
294
+ return { kind: 'reuse_terminal' };
295
+ }
280
296
  if (state.reusable && input.forceRefresh !== true) {
281
297
  return { kind: 'reuse_terminal' };
282
298
  }
package/dist/cli/index.js CHANGED
@@ -1044,7 +1044,7 @@ var SDK_RELEASE = {
1044
1044
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1045
1045
  // exposed storage-dependent synchronous access. This deliberate minor
1046
1046
  // release keeps lazy paging semantics independent of row residency.
1047
- version: "0.2.40",
1047
+ version: "0.2.41",
1048
1048
  contracts: {
1049
1049
  api: {
1050
1050
  name: "sdk-http-api",
@@ -3272,6 +3272,7 @@ async function* observeRunEvents(options) {
3272
3272
  // ../shared_libs/integrations/theirstack-execution-policy.ts
3273
3273
  var THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135e3;
3274
3274
  var THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS = 6e4 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15e3;
3275
+ var THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 21e4;
3275
3276
  var LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1e3;
3276
3277
  var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
3277
3278
  function parseDateOnly(value) {
@@ -3315,6 +3316,12 @@ function usesExtendedTheirstackJobSearchBudget(endpointId, payload) {
3315
3316
  const maxAgeDays = parseMaxAgeDays(payload.posted_at_max_age_days);
3316
3317
  return maxAgeDays !== null && maxAgeDays >= 365 ? true : usesLongExplicitDateWindow(payload);
3317
3318
  }
3319
+ function resolveTheirstackClientTimeoutMs(endpointId, payload) {
3320
+ if (endpointId === "theirstack_company_search") {
3321
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
3322
+ }
3323
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload) ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS : null;
3324
+ }
3318
3325
 
3319
3326
  // ../shared_libs/play-runtime/backend.ts
3320
3327
  var PLAY_RUNTIME_BACKENDS = {
@@ -3561,9 +3568,11 @@ function resolveToolExecuteTimeoutMs(toolId, input2) {
3561
3568
  return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
3562
3569
  }
3563
3570
  }
3564
- if (usesExtendedTheirstackJobSearchBudget(normalized, input2)) {
3565
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
3566
- }
3571
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
3572
+ normalized,
3573
+ input2
3574
+ );
3575
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
3567
3576
  return normalized === "deeplineagent" || normalized === "deeplineagent_deeplineagent" || normalized === "ai_inference" || normalized === "deeplineagent_ai_inference" || normalized === "aiinference" ? DEEPLINEAGENT_EXECUTE_TIMEOUT_MS : void 0;
3568
3577
  }
3569
3578
  var RUNS_FAILED_LOG_LIMIT = 20;
@@ -1030,7 +1030,7 @@ var SDK_RELEASE = {
1030
1030
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1031
1031
  // exposed storage-dependent synchronous access. This deliberate minor
1032
1032
  // release keeps lazy paging semantics independent of row residency.
1033
- version: "0.2.40",
1033
+ version: "0.2.41",
1034
1034
  contracts: {
1035
1035
  api: {
1036
1036
  name: "sdk-http-api",
@@ -3258,6 +3258,7 @@ async function* observeRunEvents(options) {
3258
3258
  // ../shared_libs/integrations/theirstack-execution-policy.ts
3259
3259
  var THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135e3;
3260
3260
  var THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS = 6e4 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15e3;
3261
+ var THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 21e4;
3261
3262
  var LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1e3;
3262
3263
  var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
3263
3264
  function parseDateOnly(value) {
@@ -3301,6 +3302,12 @@ function usesExtendedTheirstackJobSearchBudget(endpointId, payload) {
3301
3302
  const maxAgeDays = parseMaxAgeDays(payload.posted_at_max_age_days);
3302
3303
  return maxAgeDays !== null && maxAgeDays >= 365 ? true : usesLongExplicitDateWindow(payload);
3303
3304
  }
3305
+ function resolveTheirstackClientTimeoutMs(endpointId, payload) {
3306
+ if (endpointId === "theirstack_company_search") {
3307
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
3308
+ }
3309
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload) ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS : null;
3310
+ }
3304
3311
 
3305
3312
  // ../shared_libs/play-runtime/backend.ts
3306
3313
  var PLAY_RUNTIME_BACKENDS = {
@@ -3547,9 +3554,11 @@ function resolveToolExecuteTimeoutMs(toolId, input2) {
3547
3554
  return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
3548
3555
  }
3549
3556
  }
3550
- if (usesExtendedTheirstackJobSearchBudget(normalized, input2)) {
3551
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
3552
- }
3557
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
3558
+ normalized,
3559
+ input2
3560
+ );
3561
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
3553
3562
  return normalized === "deeplineagent" || normalized === "deeplineagent_deeplineagent" || normalized === "ai_inference" || normalized === "deeplineagent_ai_inference" || normalized === "aiinference" ? DEEPLINEAGENT_EXECUTE_TIMEOUT_MS : void 0;
3554
3563
  }
3555
3564
  var RUNS_FAILED_LOG_LIMIT = 20;
package/dist/index.js CHANGED
@@ -763,7 +763,7 @@ var SDK_RELEASE = {
763
763
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
764
764
  // exposed storage-dependent synchronous access. This deliberate minor
765
765
  // release keeps lazy paging semantics independent of row residency.
766
- version: "0.2.40",
766
+ version: "0.2.41",
767
767
  contracts: {
768
768
  api: {
769
769
  name: "sdk-http-api",
@@ -2991,6 +2991,7 @@ async function* observeRunEvents(options) {
2991
2991
  // ../shared_libs/integrations/theirstack-execution-policy.ts
2992
2992
  var THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135e3;
2993
2993
  var THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS = 6e4 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15e3;
2994
+ var THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 21e4;
2994
2995
  var LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1e3;
2995
2996
  var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
2996
2997
  function parseDateOnly(value) {
@@ -3034,6 +3035,12 @@ function usesExtendedTheirstackJobSearchBudget(endpointId, payload) {
3034
3035
  const maxAgeDays = parseMaxAgeDays(payload.posted_at_max_age_days);
3035
3036
  return maxAgeDays !== null && maxAgeDays >= 365 ? true : usesLongExplicitDateWindow(payload);
3036
3037
  }
3038
+ function resolveTheirstackClientTimeoutMs(endpointId, payload) {
3039
+ if (endpointId === "theirstack_company_search") {
3040
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
3041
+ }
3042
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload) ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS : null;
3043
+ }
3037
3044
 
3038
3045
  // ../shared_libs/play-runtime/backend.ts
3039
3046
  var PLAY_RUNTIME_BACKENDS = {
@@ -3280,9 +3287,11 @@ function resolveToolExecuteTimeoutMs(toolId, input) {
3280
3287
  return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
3281
3288
  }
3282
3289
  }
3283
- if (usesExtendedTheirstackJobSearchBudget(normalized, input)) {
3284
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
3285
- }
3290
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
3291
+ normalized,
3292
+ input
3293
+ );
3294
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
3286
3295
  return normalized === "deeplineagent" || normalized === "deeplineagent_deeplineagent" || normalized === "ai_inference" || normalized === "deeplineagent_ai_inference" || normalized === "aiinference" ? DEEPLINEAGENT_EXECUTE_TIMEOUT_MS : void 0;
3287
3296
  }
3288
3297
  var RUNS_FAILED_LOG_LIMIT = 20;
package/dist/index.mjs CHANGED
@@ -689,7 +689,7 @@ var SDK_RELEASE = {
689
689
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
690
690
  // exposed storage-dependent synchronous access. This deliberate minor
691
691
  // release keeps lazy paging semantics independent of row residency.
692
- version: "0.2.40",
692
+ version: "0.2.41",
693
693
  contracts: {
694
694
  api: {
695
695
  name: "sdk-http-api",
@@ -2917,6 +2917,7 @@ async function* observeRunEvents(options) {
2917
2917
  // ../shared_libs/integrations/theirstack-execution-policy.ts
2918
2918
  var THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135e3;
2919
2919
  var THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS = 6e4 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15e3;
2920
+ var THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 21e4;
2920
2921
  var LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1e3;
2921
2922
  var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
2922
2923
  function parseDateOnly(value) {
@@ -2960,6 +2961,12 @@ function usesExtendedTheirstackJobSearchBudget(endpointId, payload) {
2960
2961
  const maxAgeDays = parseMaxAgeDays(payload.posted_at_max_age_days);
2961
2962
  return maxAgeDays !== null && maxAgeDays >= 365 ? true : usesLongExplicitDateWindow(payload);
2962
2963
  }
2964
+ function resolveTheirstackClientTimeoutMs(endpointId, payload) {
2965
+ if (endpointId === "theirstack_company_search") {
2966
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
2967
+ }
2968
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload) ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS : null;
2969
+ }
2963
2970
 
2964
2971
  // ../shared_libs/play-runtime/backend.ts
2965
2972
  var PLAY_RUNTIME_BACKENDS = {
@@ -3206,9 +3213,11 @@ function resolveToolExecuteTimeoutMs(toolId, input) {
3206
3213
  return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
3207
3214
  }
3208
3215
  }
3209
- if (usesExtendedTheirstackJobSearchBudget(normalized, input)) {
3210
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
3211
- }
3216
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
3217
+ normalized,
3218
+ input
3219
+ );
3220
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
3212
3221
  return normalized === "deeplineagent" || normalized === "deeplineagent_deeplineagent" || normalized === "ai_inference" || normalized === "deeplineagent_ai_inference" || normalized === "aiinference" ? DEEPLINEAGENT_EXECUTE_TIMEOUT_MS : void 0;
3213
3222
  }
3214
3223
  var RUNS_FAILED_LOG_LIMIT = 20;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {