deepline 0.1.83 → 0.1.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -179,10 +179,10 @@ import { join as join2 } from "path";
179
179
 
180
180
  // src/release.ts
181
181
  var SDK_RELEASE = {
182
- version: "0.1.83",
182
+ version: "0.1.88",
183
183
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
184
184
  supportPolicy: {
185
- latest: "0.1.83",
185
+ latest: "0.1.88",
186
186
  minimumSupported: "0.1.53",
187
187
  deprecatedBelow: "0.1.53"
188
188
  }
@@ -196,6 +196,7 @@ var SDK_API_CONTRACT = SDK_RELEASE.apiContract;
196
196
  var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
197
197
  var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
198
198
  var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
199
+ var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
199
200
 
200
201
  // src/http.ts
201
202
  var MAX_DIAGNOSTIC_HEADER_LENGTH = 120;
@@ -263,6 +264,10 @@ var HttpClient = class {
263
264
  if (workerCallbackUrl?.trim()) {
264
265
  headers[WORKER_CALLBACK_URL_OVERRIDE_HEADER] = workerCallbackUrl.trim();
265
266
  }
267
+ const syntheticRun = typeof process !== "undefined" ? process.env?.DEEPLINE_SYNTHETIC_RUN : void 0;
268
+ if (syntheticRun && syntheticRun.trim() && syntheticRun.trim() !== "0") {
269
+ headers[SYNTHETIC_RUN_HEADER] = "1";
270
+ }
266
271
  return headers;
267
272
  }
268
273
  /**
@@ -553,6 +558,21 @@ function isTransientCompileManifestError(error) {
553
558
  function isRecord(value) {
554
559
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
555
560
  }
561
+ function isPrebuiltPlayDescription(play) {
562
+ return play.origin === "prebuilt" || play.ownerType === "deepline";
563
+ }
564
+ function preferPrebuiltPlayDescriptions(plays) {
565
+ const prebuilt = [];
566
+ const owned = [];
567
+ for (const play of plays) {
568
+ if (isPrebuiltPlayDescription(play)) {
569
+ prebuilt.push(play);
570
+ } else {
571
+ owned.push(play);
572
+ }
573
+ }
574
+ return [...prebuilt, ...owned];
575
+ }
556
576
  function isPlayRunPackage(value) {
557
577
  return Boolean(
558
578
  value && typeof value === "object" && !Array.isArray(value) && value.kind === "play_run" && value.run && typeof value.run?.id === "string"
@@ -676,8 +696,14 @@ function playRunStatusFromState(state) {
676
696
  var DeeplineClient = class {
677
697
  http;
678
698
  config;
699
+ /** Canonical run lifecycle namespace backed by `/api/v2/runs`. */
679
700
  runs;
680
701
  /**
702
+ * Create a low-level SDK client.
703
+ *
704
+ * Most callers can omit options and let the SDK resolve auth/config from
705
+ * environment variables and CLI-managed credentials.
706
+ *
681
707
  * @param options - Optional overrides for API key, base URL, timeout, and retries.
682
708
  * @throws {@link ConfigError} if no API key can be resolved from any source.
683
709
  */
@@ -779,12 +805,19 @@ var DeeplineClient = class {
779
805
  // ——————————————————————————————————————————————————————————
780
806
  // Secrets
781
807
  // ——————————————————————————————————————————————————————————
808
+ /** List secret metadata visible to the current workspace. */
782
809
  async listSecrets() {
783
810
  const response = await this.http.get(
784
811
  "/api/v2/secrets"
785
812
  );
786
813
  return Array.isArray(response.secrets) ? response.secrets : [];
787
814
  }
815
+ /**
816
+ * Check whether a named secret exists, is active, and has a stored value.
817
+ *
818
+ * @param name - Secret name. It is normalized to uppercase before lookup.
819
+ * @returns Matching active secret metadata, or `null`.
820
+ */
788
821
  async checkSecret(name) {
789
822
  const normalized = name.trim().toUpperCase();
790
823
  const secrets = await this.listSecrets();
@@ -897,9 +930,21 @@ var DeeplineClient = class {
897
930
  headers
898
931
  );
899
932
  }
933
+ /**
934
+ * Back-compatible alias for {@link executeTool}.
935
+ *
936
+ * Retained for callers that still use the older raw naming while the response
937
+ * envelope remains the same.
938
+ */
900
939
  async executeToolRaw(toolId, input, options) {
901
940
  return this.executeTool(toolId, input, options);
902
941
  }
942
+ /**
943
+ * Run a bounded SQL query against the customer data plane.
944
+ *
945
+ * Use this from trusted backend or agent contexts only. The API enforces
946
+ * workspace scoping and row limits.
947
+ */
903
948
  async queryCustomerDb(input) {
904
949
  return this.http.post("/api/v2/db/query", {
905
950
  sql: input.sql,
@@ -971,6 +1016,17 @@ var DeeplineClient = class {
971
1016
  );
972
1017
  return normalizePlayRunStart(response);
973
1018
  }
1019
+ /**
1020
+ * Start a play run and stream live runtime events from the same request.
1021
+ *
1022
+ * Use this when a caller wants low-level event handling instead of submitting
1023
+ * first and then connecting to `streamPlayRunEvents(runId)`.
1024
+ *
1025
+ * @param request - Play run configuration.
1026
+ * @param options - Optional streaming options.
1027
+ * @param options.signal - Optional abort signal for the streaming request.
1028
+ * @returns Async stream of play-scoped live events.
1029
+ */
974
1030
  async *startPlayRunStream(request, options) {
975
1031
  const body = {
976
1032
  ...request.name ? { name: request.name } : {},
@@ -1023,6 +1079,12 @@ var DeeplineClient = class {
1023
1079
  compilerManifest
1024
1080
  });
1025
1081
  }
1082
+ /**
1083
+ * Register multiple bundled play artifacts in one request.
1084
+ *
1085
+ * Used by packaging and prebuilt publication flows. Each artifact is compiled
1086
+ * first when a compiler manifest is not already supplied.
1087
+ */
1026
1088
  async registerPlayArtifacts(artifacts) {
1027
1089
  const compiledArtifacts = await Promise.all(
1028
1090
  artifacts.map(async (artifact) => ({
@@ -1039,6 +1101,13 @@ var DeeplineClient = class {
1039
1101
  artifacts: compiledArtifacts
1040
1102
  });
1041
1103
  }
1104
+ /**
1105
+ * Compile a bundled play artifact into the server-side compiler manifest.
1106
+ *
1107
+ * The manifest records imports, trigger bindings, static pipeline shape, and
1108
+ * runtime metadata needed before a play artifact can be checked, registered,
1109
+ * or run.
1110
+ */
1042
1111
  async compilePlayManifest(input) {
1043
1112
  const retryDelays = COMPILE_MANIFEST_RETRY_DELAYS_MS.slice(
1044
1113
  0,
@@ -1067,9 +1136,21 @@ var DeeplineClient = class {
1067
1136
  async checkPlayArtifact(input) {
1068
1137
  return this.http.post("/api/v2/plays/check", input);
1069
1138
  }
1139
+ /**
1140
+ * Compile legacy enrich command arguments into a runtime plan.
1141
+ *
1142
+ * This is primarily used by CLI compatibility paths that translate older
1143
+ * enrichment commands onto the play runtime.
1144
+ */
1070
1145
  async compileEnrichPlan(input) {
1071
1146
  return this.http.post("/api/v2/enrich/compile", input);
1072
1147
  }
1148
+ /**
1149
+ * Register an already-bundled play artifact and start a run from it.
1150
+ *
1151
+ * This is the low-level file-backed run path used by SDK/CLI packaging
1152
+ * wrappers after local bundling has produced the runtime artifact.
1153
+ */
1073
1154
  async startPlayRunFromBundle(input) {
1074
1155
  const compilerManifest = input.compilerManifest ?? await this.compilePlayManifest({
1075
1156
  name: input.name,
@@ -1227,6 +1308,12 @@ var DeeplineClient = class {
1227
1308
  const response = await this.http.postFormData("/api/v2/plays/files/stage", buildFormData);
1228
1309
  return response.files;
1229
1310
  }
1311
+ /**
1312
+ * Resolve staged play files by content hash without uploading bytes.
1313
+ *
1314
+ * Missing files are returned so callers can upload only the files the server
1315
+ * does not already have.
1316
+ */
1230
1317
  async resolveStagedPlayFiles(files) {
1231
1318
  return this.http.post("/api/v2/plays/files/stage", { files });
1232
1319
  }
@@ -1443,6 +1530,12 @@ var DeeplineClient = class {
1443
1530
  entries
1444
1531
  };
1445
1532
  }
1533
+ /**
1534
+ * Export persisted runtime-sheet rows for a play dataset/table namespace.
1535
+ *
1536
+ * This is the SDK form of exporting `ctx.dataset(...).run()` output for a
1537
+ * specific play and optional run id.
1538
+ */
1446
1539
  async getPlaySheetRows(input) {
1447
1540
  const params = new URLSearchParams({
1448
1541
  tableNamespace: input.tableNamespace,
@@ -1471,6 +1564,12 @@ var DeeplineClient = class {
1471
1564
  options?.reason ? { reason: options.reason } : {}
1472
1565
  );
1473
1566
  }
1567
+ /**
1568
+ * List callable plays visible to the workspace.
1569
+ *
1570
+ * Pass `origin: "prebuilt"` for Deepline-managed prebuilts or
1571
+ * `origin: "owned"` for org-owned plays.
1572
+ */
1474
1573
  async listPlays(options) {
1475
1574
  const params = new URLSearchParams();
1476
1575
  if (options?.origin) params.set("origin", options.origin);
@@ -1485,15 +1584,32 @@ var DeeplineClient = class {
1485
1584
  );
1486
1585
  return response.plays ?? [];
1487
1586
  }
1587
+ /**
1588
+ * Search callable plays and return compact play descriptions.
1589
+ *
1590
+ * Prebuilt plays are preferred by default because they have maintained
1591
+ * contracts and stable run behavior.
1592
+ */
1488
1593
  async searchPlays(options) {
1489
1594
  const params = new URLSearchParams();
1490
1595
  params.set("search", options.query.trim());
1596
+ const scope = options.scope ?? "prebuilt";
1597
+ if (scope !== "all") {
1598
+ params.set("origin", scope);
1599
+ }
1491
1600
  const response = await this.http.get(
1492
1601
  `/api/v2/plays?${params.toString()}`
1493
1602
  );
1494
- return (response.plays ?? []).map(
1603
+ const plays = (response.plays ?? []).map(
1495
1604
  (play) => this.summarizePlayListItem(play, options)
1496
1605
  );
1606
+ if (scope === "prebuilt") {
1607
+ return plays.filter(isPrebuiltPlayDescription);
1608
+ }
1609
+ if (scope === "owned") {
1610
+ return plays.filter((play) => !isPrebuiltPlayDescription(play));
1611
+ }
1612
+ return preferPrebuiltPlayDescriptions(plays);
1497
1613
  }
1498
1614
  /**
1499
1615
  * Get the full definition and state of a named play.
@@ -1516,6 +1632,12 @@ var DeeplineClient = class {
1516
1632
  const encodedName = encodeURIComponent(name);
1517
1633
  return this.http.get(`/api/v2/plays/${encodedName}`);
1518
1634
  }
1635
+ /**
1636
+ * Get a normalized play description suitable for agents and CLIs.
1637
+ *
1638
+ * The description includes runnable examples, input/output summaries, clone
1639
+ * guidance, revision state, and latest run metadata when available.
1640
+ */
1519
1641
  async describePlay(name, options) {
1520
1642
  const detail = await this.getPlay(name);
1521
1643
  return this.summarizePlayDetail(detail, options);
@@ -2002,6 +2124,58 @@ function buildEmailStatus({
2002
2124
  };
2003
2125
  }
2004
2126
 
2127
+ // ../shared_libs/play-runtime/extractor-targets.ts
2128
+ var JOB_CHANGE_STATUS_VALUES = [
2129
+ "moved",
2130
+ "no_change",
2131
+ "left_company",
2132
+ "unknown",
2133
+ "profile_unavailable",
2134
+ "no_new_company"
2135
+ ];
2136
+ var PHONE_STATUS_VALUES = ["valid", "invalid", "unknown"];
2137
+ var DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS = {
2138
+ id: { identity: true, valueKind: "string" },
2139
+ name: { identity: true, valueKind: "string" },
2140
+ email: { identity: true, valueKind: "string" },
2141
+ personal_email: { identity: true, valueKind: "string" },
2142
+ phone: { identity: true, valueKind: "string" },
2143
+ linkedin: { identity: true, valueKind: "string" },
2144
+ linkedin_url: { identity: true, valueKind: "string" },
2145
+ domain: { identity: true, valueKind: "string" },
2146
+ website: { identity: true, valueKind: "string" },
2147
+ first_name: { identity: true, valueKind: "string" },
2148
+ last_name: { identity: true, valueKind: "string" },
2149
+ full_name: { identity: true, valueKind: "string" },
2150
+ company: { identity: true, valueKind: "string" },
2151
+ company_name: { identity: true, valueKind: "string" },
2152
+ organization_name: { identity: true, valueKind: "string" },
2153
+ company_domain: { identity: true, valueKind: "string" },
2154
+ company_website: { identity: true, valueKind: "string" },
2155
+ company_linkedin_url: { identity: true, valueKind: "string" },
2156
+ title: { identity: false, valueKind: "string" },
2157
+ industry: { identity: false, valueKind: "string" },
2158
+ status: { identity: false, valueKind: "string" },
2159
+ job_change: { identity: false, valueKind: "job_change" },
2160
+ job_change_status: {
2161
+ identity: false,
2162
+ valueKind: "job_change_status",
2163
+ enum: JOB_CHANGE_STATUS_VALUES
2164
+ },
2165
+ email_status: { identity: false, valueKind: "email_status" },
2166
+ phone_status: {
2167
+ identity: false,
2168
+ valueKind: "phone_status",
2169
+ enum: PHONE_STATUS_VALUES
2170
+ }
2171
+ };
2172
+ var DEEPLINE_EXTRACTOR_TARGETS = Object.keys(
2173
+ DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS
2174
+ );
2175
+ function isDeeplineExtractorTarget(value) {
2176
+ return value in DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS;
2177
+ }
2178
+
2005
2179
  // ../shared_libs/play-runtime/tool-result.ts
2006
2180
  var TARGET_FALLBACK_KEYS = {
2007
2181
  email: [/^email$/i, /^address$/i, /email/i],
@@ -2275,10 +2449,61 @@ function normalizePhoneStatus(value) {
2275
2449
  }
2276
2450
  return normalized;
2277
2451
  }
2452
+ function normalizeJobChangeStatus(value) {
2453
+ if (typeof value === "boolean") return value ? "moved" : "no_change";
2454
+ const normalized = normalizeString(value)?.toLowerCase().replace(/[\s-]+/g, "_");
2455
+ if (!normalized) return "unknown";
2456
+ if (["true", "yes", "moved", "changed", "new_company"].includes(normalized)) {
2457
+ return "moved";
2458
+ }
2459
+ if (["false", "no", "same", "no_change"].includes(normalized))
2460
+ return "no_change";
2461
+ if (["left", "left_company"].includes(normalized)) return "left_company";
2462
+ if (JOB_CHANGE_STATUS_VALUES.includes(normalized)) {
2463
+ return normalized;
2464
+ }
2465
+ return "unknown";
2466
+ }
2467
+ function firstExperienceDate(value) {
2468
+ if (!Array.isArray(value)) return null;
2469
+ for (const entry of value) {
2470
+ if (!isRecord2(entry)) continue;
2471
+ const date = normalizeString(
2472
+ entry.start_date ?? entry.started_at ?? entry.startDate
2473
+ );
2474
+ if (date) return date;
2475
+ }
2476
+ return null;
2477
+ }
2478
+ function normalizeJobChange(value) {
2479
+ const record = isRecord2(value) ? value : {};
2480
+ const nested = isRecord2(record.job_change) ? record.job_change : record;
2481
+ const output = isRecord2(nested.output) ? nested.output : nested;
2482
+ const person = isRecord2(output.person) ? output.person : {};
2483
+ const status = normalizeJobChangeStatus(
2484
+ output.status ?? output.job_change_status ?? output.job_changed ?? output.changed
2485
+ );
2486
+ const moved = status === "moved";
2487
+ return {
2488
+ status,
2489
+ date: moved ? normalizeString(
2490
+ output.date ?? output.job_change_date ?? output.change_date ?? output.changed_at
2491
+ ) ?? firstExperienceDate(person.experiences) : null,
2492
+ new_company: moved ? normalizeString(
2493
+ output.new_company ?? output.current_company ?? person.company_name ?? person.current_company
2494
+ ) : null,
2495
+ new_title: moved ? normalizeString(
2496
+ output.new_title ?? output.current_title ?? person.title ?? person.headline
2497
+ ) : null
2498
+ };
2499
+ }
2278
2500
  function applyExtractorTransforms(value, descriptor) {
2279
2501
  return (descriptor.transforms ?? []).reduce((current, transform) => {
2280
2502
  if (transform.endsWith("emailStatus")) return normalizeEmailStatus(current);
2281
2503
  if (transform.endsWith("phoneStatus")) return normalizePhoneStatus(current);
2504
+ if (transform === "jobChange") return normalizeJobChange(current);
2505
+ if (transform === "jobChangeStatus")
2506
+ return normalizeJobChangeStatus(current);
2282
2507
  return current;
2283
2508
  }, value);
2284
2509
  }
@@ -2566,7 +2791,10 @@ var DeeplineStepProgram = class _DeeplineStepProgram {
2566
2791
  ...this.steps,
2567
2792
  {
2568
2793
  name,
2569
- resolver: stepResolver
2794
+ resolver: stepResolver,
2795
+ ...options?.staleAfterSeconds !== void 0 ? {
2796
+ staleAfterSeconds: options.staleAfterSeconds
2797
+ } : {}
2570
2798
  }
2571
2799
  ],
2572
2800
  this.returnResolver
@@ -2666,6 +2894,14 @@ function createNamedPlayHandle(clientFactory, name) {
2666
2894
  }
2667
2895
  var DeeplineContext = class {
2668
2896
  client;
2897
+ /**
2898
+ * Create a high-level SDK context.
2899
+ *
2900
+ * Most callers should use {@link Deepline.connect}; direct construction is
2901
+ * equivalent when you already have explicit client options.
2902
+ *
2903
+ * @param options - Optional SDK client configuration.
2904
+ */
2669
2905
  constructor(options) {
2670
2906
  this.client = new DeeplineClient(options);
2671
2907
  }
@@ -2695,12 +2931,25 @@ var DeeplineContext = class {
2695
2931
  }
2696
2932
  };
2697
2933
  }
2934
+ /**
2935
+ * Play discovery and named-play handles.
2936
+ *
2937
+ * Use `plays.list()` for discovery and `plays.get(name)` when you prefer a
2938
+ * namespace spelling over `ctx.play(name)`.
2939
+ */
2698
2940
  get plays() {
2699
2941
  return {
2700
2942
  list: () => this.client.listPlays(),
2701
2943
  get: (name) => this.play(name)
2702
2944
  };
2703
2945
  }
2946
+ /**
2947
+ * Convenience references for Deepline-managed prebuilt plays.
2948
+ *
2949
+ * Known prebuilts are exposed by camel-cased aliases. Any other property is
2950
+ * converted into `prebuilt/<property>` so callers can pass the reference to
2951
+ * `ctx.runPlay(...)`.
2952
+ */
2704
2953
  get prebuilt() {
2705
2954
  const explicit = {
2706
2955
  companyToContact: {
@@ -2755,6 +3004,17 @@ var DeeplineContext = class {
2755
3004
  play(name) {
2756
3005
  return createNamedPlayHandle(() => this.client, name);
2757
3006
  }
3007
+ /**
3008
+ * Run a named or prebuilt play and wait for its output.
3009
+ *
3010
+ * This is the high-level SDK equivalent of `ctx.play(name).runSync(input)`.
3011
+ * Inside a play runtime, prefer the in-play `ctx.runPlay(key, playRef, input,
3012
+ * options)` form so the child run is checkpointed under a stable key.
3013
+ *
3014
+ * @param playOrRef - Play name or prebuilt/reference object.
3015
+ * @param input - JSON input passed to the play.
3016
+ * @returns Completed play output.
3017
+ */
2758
3018
  async runPlay(playOrRef, input) {
2759
3019
  const name = typeof playOrRef === "string" ? playOrRef : playOrRef.playName ?? playOrRef.name ?? "";
2760
3020
  return await this.play(name).runSync(input);
@@ -3128,11 +3388,15 @@ function extractSummaryFields(payload) {
3128
3388
  export {
3129
3389
  AuthError,
3130
3390
  ConfigError,
3391
+ DEEPLINE_EXTRACTOR_TARGETS,
3392
+ DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS,
3131
3393
  DEEPLINE_TOOL_CATEGORIES,
3132
3394
  Deepline,
3133
3395
  DeeplineClient,
3134
3396
  DeeplineContext,
3135
3397
  DeeplineError,
3398
+ JOB_CHANGE_STATUS_VALUES,
3399
+ PHONE_STATUS_VALUES,
3136
3400
  PLAY_BOOTSTRAP_COMPANY_FIELDS,
3137
3401
  PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY,
3138
3402
  PLAY_BOOTSTRAP_CONTACT_FIELDS,
@@ -3155,6 +3419,7 @@ export {
3155
3419
  formatPlayBootstrapFinderKindsForSentence,
3156
3420
  formatPlayBootstrapTemplates,
3157
3421
  getDefinedPlayMetadata,
3422
+ isDeeplineExtractorTarget,
3158
3423
  isPlayBootstrapFinderKind,
3159
3424
  isPlayBootstrapTemplate,
3160
3425
  resolveConfig,
@@ -1302,6 +1302,7 @@ export class PlayDedup implements DurableObject {
1302
1302
  ? body.activeArtifactTableNamespace
1303
1303
  : null,
1304
1304
  updatedAt: typeof body.updatedAt === 'number' ? body.updatedAt : null,
1305
+ liveNodeProgress: body.liveNodeProgress,
1305
1306
  };
1306
1307
  } else if (
1307
1308
  body.type === 'terminal' &&