deepline 0.1.112 → 0.1.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -183,7 +183,7 @@ configureProxyFromEnv();
183
183
  // src/cli/index.ts
184
184
  var import_promises7 = require("fs/promises");
185
185
  var import_node_path22 = require("path");
186
- var import_node_os15 = require("os");
186
+ var import_node_os16 = require("os");
187
187
  var import_commander3 = require("commander");
188
188
 
189
189
  // src/config.ts
@@ -403,10 +403,10 @@ var SDK_RELEASE = {
403
403
  // skill on the sdk sync surface, and the people-search-to-email prebuilt.
404
404
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
405
405
  // the SDK enrich generator's one-second stale policy.
406
- version: "0.1.112",
406
+ version: "0.1.114",
407
407
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
408
408
  supportPolicy: {
409
- latest: "0.1.112",
409
+ latest: "0.1.114",
410
410
  minimumSupported: "0.1.53",
411
411
  deprecatedBelow: "0.1.53",
412
412
  commandMinimumSupported: [
@@ -16031,6 +16031,8 @@ ${indent(renderJavascriptBody(command.run_if_js), 6)}
16031
16031
  force: true` : "";
16032
16032
  const legacyEnvelope = options.legacyEnvelope ? `,
16033
16033
  legacyEnvelope: true` : "";
16034
+ const waterfallSoftFail = options.waterfallSoftFail ? `,
16035
+ waterfallSoftFail: true` : "";
16034
16036
  return [
16035
16037
  `async (row, stepCtx) => {`,
16036
16038
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
@@ -16042,7 +16044,7 @@ ${indent(renderJavascriptBody(command.run_if_js), 6)}
16042
16044
  ` extract: ${extractJs},`,
16043
16045
  ` runIf: ${runIfJs},`,
16044
16046
  ` row,`,
16045
- ` stepCtx${description}${force}${legacyEnvelope}`,
16047
+ ` stepCtx${description}${force}${legacyEnvelope}${waterfallSoftFail}`,
16046
16048
  ` });`,
16047
16049
  `}`
16048
16050
  ].join("\n");
@@ -16066,34 +16068,22 @@ function renderIdiomaticExecuteStep(command, options) {
16066
16068
  `async (row, ctx) => {`,
16067
16069
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
16068
16070
  ...runIfLines,
16069
- ` const result: any = await ctx.tools.execute({`,
16070
- ` id: ${callId},`,
16071
- ` tool: ${tool},`,
16072
- ` input: ${input2} as any,`,
16073
- ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
16074
- ...options.force ? [` force: true,`] : [],
16075
- ` });`,
16071
+ ` let result: any;`,
16072
+ ` try {`,
16073
+ ` result = await ctx.tools.execute({`,
16074
+ ` id: ${callId},`,
16075
+ ` tool: ${tool},`,
16076
+ ` input: ${input2} as any,`,
16077
+ ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
16078
+ ...options.force ? [` force: true,`] : [],
16079
+ ` });`,
16080
+ ` } catch (error) {`,
16081
+ ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
16082
+ ` }`,
16076
16083
  ` return ${extraction};`,
16077
16084
  `}`
16078
16085
  ].join("\n");
16079
16086
  }
16080
- function renderInlineJavascriptStep(command, options) {
16081
- const code = typeof command.payload?.code === "string" ? command.payload.code : "return null;";
16082
- const runIfLines = command.run_if_js ? [
16083
- ` if (!((row: Record<string, any>) => { const input = row; const context = row;`,
16084
- indent(renderJavascriptBody(command.run_if_js), 4),
16085
- ` })(row as Record<string, any>)) return null;`
16086
- ] : [];
16087
- return [
16088
- `async (row) => {`,
16089
- ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
16090
- ...runIfLines,
16091
- ` return ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
16092
- indent(renderJavascriptBody(code), 4),
16093
- ` })(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
16094
- `}`
16095
- ].join("\n");
16096
- }
16097
16087
  function renderPlayStep(command, options) {
16098
16088
  const alias = stringLiteral(command.alias);
16099
16089
  const callId = stringLiteral(commandCallId(command));
@@ -16112,13 +16102,35 @@ ${indent(renderJavascriptBody(command.run_if_js), 6)}
16112
16102
  ` const templateRow = __dlPrepareEnrichRow(row, [${alias}]);`,
16113
16103
  ...runIfLines,
16114
16104
  ` const payload = __dlTemplate(${payload}, templateRow) as Record<string, unknown>;`,
16115
- ` const result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
16116
- ` description: ${stringLiteral(command.description ?? command.alias)}`,
16117
- ` });`,
16105
+ ` let result: unknown;`,
16106
+ ` try {`,
16107
+ ` result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
16108
+ ` description: ${stringLiteral(command.description ?? command.alias)}`,
16109
+ ` });`,
16110
+ ` } catch (error) {`,
16111
+ ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
16112
+ ` }`,
16118
16113
  ` return __dlPlayResultValue(${alias}, result);`,
16119
16114
  `}`
16120
16115
  ].join("\n");
16121
16116
  }
16117
+ function renderInlineJavascriptStep(command, options) {
16118
+ const code = typeof command.payload?.code === "string" ? command.payload.code : "return null;";
16119
+ const runIfLines = command.run_if_js ? [
16120
+ ` if (!((row: Record<string, any>) => { const input = row; const context = row;`,
16121
+ indent(renderJavascriptBody(command.run_if_js), 4),
16122
+ ` })(row as Record<string, any>)) return null;`
16123
+ ] : [];
16124
+ return [
16125
+ `async (row) => {`,
16126
+ ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
16127
+ ...runIfLines,
16128
+ ` return ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
16129
+ indent(renderJavascriptBody(code), 4),
16130
+ ` })(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
16131
+ `}`
16132
+ ].join("\n");
16133
+ }
16122
16134
  function renderJavascriptBody(source) {
16123
16135
  assertUserCodeIsSafe(source, "play step code");
16124
16136
  const trimmed = source.trim();
@@ -16245,7 +16257,8 @@ function renderWaterfallColumns(command, forceAliases, inlineRunJavascript, idio
16245
16257
  precheck: priorAliases.length > 0 ? `__dlWaterfallSatisfied(row, ${stableJson(priorAliases)}, ${minResults})` : void 0,
16246
16258
  legacyEnvelope: Boolean(nested.extract_js),
16247
16259
  inlineRunJavascript,
16248
- idiomaticGetters
16260
+ idiomaticGetters,
16261
+ waterfallSoftFail: true
16249
16262
  }),
16250
16263
  { recompute: force, recomputeOnError: true }
16251
16264
  );
@@ -16900,6 +16913,26 @@ function helperSource() {
16900
16913
  ` return 'Extractor failed';`,
16901
16914
  `}`,
16902
16915
  ``,
16916
+ `function __dlErrorDetail(error: unknown): string {`,
16917
+ ` const message = __dlErrorMessage(error);`,
16918
+ ` if (!__dlRecord(error)) return message;`,
16919
+ ` try {`,
16920
+ ` return message + ' ' + JSON.stringify(error);`,
16921
+ ` } catch {`,
16922
+ ` return message;`,
16923
+ ` }`,
16924
+ `}`,
16925
+ ``,
16926
+ `function __dlRecoverableWaterfallToolError(error: unknown): boolean {`,
16927
+ ` const detail = __dlErrorDetail(error).toLowerCase();`,
16928
+ ` return /\\b5\\d\\d\\b/.test(detail) || detail.includes('upstream_failure') || detail.includes('"error_category":"upstream"') || (detail.includes('"failure_origin":"provider"') && detail.includes('"status":5')) || detail.includes('bad gateway') || detail.includes('gateway time-out') || detail.includes('gateway timeout') || detail.includes('service unavailable');`,
16929
+ `}`,
16930
+ ``,
16931
+ `function __dlWaterfallToolFailure(error: unknown): unknown {`,
16932
+ ` if (__dlRecoverableWaterfallToolError(error)) return __dlExtractorFailure(error);`,
16933
+ ` throw error;`,
16934
+ `}`,
16935
+ ``,
16903
16936
  `function __dlExtractorFailure(error: unknown): unknown {`,
16904
16937
  ` const message = __dlErrorMessage(error);`,
16905
16938
  ` return { matched_result: null, result: { error: message, message } };`,
@@ -16996,19 +17029,25 @@ function helperSource() {
16996
17029
  ` return result;`,
16997
17030
  `}`,
16998
17031
  ``,
16999
- `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean }): Promise<unknown> {`,
17032
+ `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean; waterfallSoftFail?: boolean }): Promise<unknown> {`,
17000
17033
  ` if (input.runIf) {`,
17001
17034
  ` const shouldRun = input.runIf(input.row);`,
17002
17035
  ` if (!shouldRun) return null;`,
17003
17036
  ` }`,
17004
17037
  ` const payload = __dlRuntimePayload(input.tool, __dlTemplate(input.payload, input.row) as Record<string, unknown>, input.row);`,
17005
- ` const result = await input.stepCtx.tools.execute({`,
17006
- ` id: input.callId,`,
17007
- ` tool: input.tool,`,
17008
- ` input: payload,`,
17009
- ` ...(input.description ? { description: input.description } : {}),`,
17010
- ` ...(input.force ? { force: true } : {}),`,
17011
- ` });`,
17038
+ ` let result: unknown;`,
17039
+ ` try {`,
17040
+ ` result = await input.stepCtx.tools.execute({`,
17041
+ ` id: input.callId,`,
17042
+ ` tool: input.tool,`,
17043
+ ` input: payload,`,
17044
+ ` ...(input.description ? { description: input.description } : {}),`,
17045
+ ` ...(input.force ? { force: true } : {}),`,
17046
+ ` });`,
17047
+ ` } catch (error) {`,
17048
+ ` if (input.waterfallSoftFail) return __dlWaterfallToolFailure(error);`,
17049
+ ` throw error;`,
17050
+ ` }`,
17012
17051
  ` return __dlExtract(input.alias, result, input.row, input.extract, Boolean(input.legacyEnvelope));`,
17013
17052
  `}`
17014
17053
  ].join("\n");
@@ -22357,6 +22396,7 @@ Notes:
22357
22396
  // src/cli/commands/update.ts
22358
22397
  var import_node_child_process2 = require("child_process");
22359
22398
  var import_node_fs16 = require("fs");
22399
+ var import_node_os13 = require("os");
22360
22400
  var import_node_path20 = require("path");
22361
22401
  function posixShellQuote(value) {
22362
22402
  return `'${value.replace(/'/g, `'\\''`)}'`;
@@ -22375,6 +22415,55 @@ function buildSourceUpdateCommand(sourceRoot) {
22375
22415
  const cdCommand = process.platform === "win32" ? `cd /d ${quotedRoot}` : `cd ${quotedRoot}`;
22376
22416
  return `${cdCommand} && git fetch origin main --tags && git merge --ff-only origin/main`;
22377
22417
  }
22418
+ function sidecarStateDir(input2) {
22419
+ const scope = input2.env.DEEPLINE_CONFIG_SCOPE?.trim();
22420
+ if (!scope || scope.includes("/") || scope.includes("\\")) {
22421
+ return null;
22422
+ }
22423
+ return (0, import_node_path20.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
22424
+ }
22425
+ function readOptionalText(path) {
22426
+ try {
22427
+ return (0, import_node_fs16.readFileSync)(path, "utf8").trim();
22428
+ } catch {
22429
+ return "";
22430
+ }
22431
+ }
22432
+ function resolvePythonSidecarUpdatePlan(options) {
22433
+ const stateDir = sidecarStateDir(options);
22434
+ if (!stateDir) return null;
22435
+ const relativeEntrypoint = (0, import_node_path20.relative)(
22436
+ (0, import_node_path20.resolve)(stateDir),
22437
+ (0, import_node_path20.resolve)(options.entrypoint)
22438
+ );
22439
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path20.isAbsolute)(relativeEntrypoint)) {
22440
+ return null;
22441
+ }
22442
+ const installMethod = readOptionalText((0, import_node_path20.join)(stateDir, ".install-method"));
22443
+ if (installMethod !== "python-sidecar") return null;
22444
+ const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
22445
+ const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
22446
+ const nodeBin = readOptionalText((0, import_node_path20.join)(stateDir, ".node-bin")) || process.execPath;
22447
+ const sidecarPath = readOptionalText((0, import_node_path20.join)(stateDir, ".command-path")) || (0, import_node_path20.join)(
22448
+ stateDir,
22449
+ "bin",
22450
+ process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
22451
+ );
22452
+ const packageSpec = options.packageSpec || "deepline@latest";
22453
+ const npmCommand = "npm";
22454
+ const manualCommand = `${npmCommand} install --prefix ${shellQuote3((0, import_node_path20.join)(stateDir, "versions", "<version>"))} --no-audit --no-fund ${shellQuote3(packageSpec)}`;
22455
+ return {
22456
+ kind: "python-sidecar",
22457
+ stateDir,
22458
+ sidecarPath,
22459
+ nodeBin,
22460
+ npmCommand,
22461
+ scope,
22462
+ hostUrl,
22463
+ packageSpec,
22464
+ manualCommand
22465
+ };
22466
+ }
22378
22467
  function findRepoBackedSdkRoot(startPath) {
22379
22468
  let current = (0, import_node_path20.resolve)(startPath);
22380
22469
  while (true) {
@@ -22386,8 +22475,10 @@ function findRepoBackedSdkRoot(startPath) {
22386
22475
  current = parent;
22387
22476
  }
22388
22477
  }
22389
- function resolveUpdatePlan() {
22390
- const entrypoint = process.argv[1] ? (0, import_node_path20.resolve)(process.argv[1]) : "";
22478
+ function resolveUpdatePlan(options = {}) {
22479
+ const env = options.env ?? process.env;
22480
+ const homeDir2 = options.homeDir ?? (0, import_node_os13.homedir)();
22481
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path20.resolve)(process.argv[1]) : "");
22391
22482
  const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path20.dirname)(entrypoint)) : null;
22392
22483
  if (sourceRoot) {
22393
22484
  return {
@@ -22396,8 +22487,16 @@ function resolveUpdatePlan() {
22396
22487
  manualCommand: buildSourceUpdateCommand(sourceRoot)
22397
22488
  };
22398
22489
  }
22490
+ const sidecarPlan = resolvePythonSidecarUpdatePlan({
22491
+ entrypoint,
22492
+ env,
22493
+ homeDir: homeDir2,
22494
+ packageSpec: options.packageSpec
22495
+ });
22496
+ if (sidecarPlan) return sidecarPlan;
22399
22497
  const command = "npm";
22400
- const args = ["install", "-g", "deepline@latest"];
22498
+ const packageSpec = options.packageSpec || "deepline@latest";
22499
+ const args = ["install", "-g", packageSpec];
22401
22500
  return {
22402
22501
  kind: "npm-global",
22403
22502
  command,
@@ -22405,12 +22504,40 @@ function resolveUpdatePlan() {
22405
22504
  manualCommand: `${command} ${args.map(shellQuote3).join(" ")}`
22406
22505
  };
22407
22506
  }
22408
- function runCommand(command, args) {
22507
+ function safeVersionSegment(value) {
22508
+ const normalized = value.trim();
22509
+ return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
22510
+ }
22511
+ function entryPathInVersionDir(versionDir) {
22512
+ return (0, import_node_path20.join)(
22513
+ versionDir,
22514
+ "node_modules",
22515
+ "deepline",
22516
+ "dist",
22517
+ "cli",
22518
+ "index.mjs"
22519
+ );
22520
+ }
22521
+ function installedPackageVersion(versionDir) {
22522
+ const packageJsonPath = (0, import_node_path20.join)(
22523
+ versionDir,
22524
+ "node_modules",
22525
+ "deepline",
22526
+ "package.json"
22527
+ );
22528
+ try {
22529
+ const parsed = JSON.parse((0, import_node_fs16.readFileSync)(packageJsonPath, "utf8"));
22530
+ return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
22531
+ } catch {
22532
+ return "";
22533
+ }
22534
+ }
22535
+ function runCommand(command, args, env = process.env) {
22409
22536
  return new Promise((resolveExitCode) => {
22410
22537
  const child = (0, import_node_child_process2.spawn)(command, args, {
22411
22538
  stdio: "inherit",
22412
22539
  shell: process.platform === "win32",
22413
- env: process.env
22540
+ env
22414
22541
  });
22415
22542
  child.on("error", (error) => {
22416
22543
  process.stderr.write(`Failed to start ${command}: ${error.message}
@@ -22422,11 +22549,137 @@ function runCommand(command, args) {
22422
22549
  });
22423
22550
  });
22424
22551
  }
22425
- async function runNpmGlobalUpdatePlan(plan) {
22426
- if (plan.kind !== "npm-global") {
22552
+ function writeSidecarLauncher(input2) {
22553
+ (0, import_node_fs16.mkdirSync)((0, import_node_path20.dirname)(input2.path), { recursive: true });
22554
+ if (process.platform === "win32") {
22555
+ (0, import_node_fs16.writeFileSync)(
22556
+ input2.path,
22557
+ [
22558
+ `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
22559
+ `@set DEEPLINE_CONFIG_SCOPE=${input2.scope.replace(/\r?\n/g, "")}`,
22560
+ `@"${input2.nodeBin}" "${input2.entryPath}" %*`,
22561
+ ""
22562
+ ].join("\r\n"),
22563
+ "utf8"
22564
+ );
22565
+ return;
22566
+ }
22567
+ (0, import_node_fs16.writeFileSync)(
22568
+ input2.path,
22569
+ [
22570
+ "#!/usr/bin/env sh",
22571
+ `export DEEPLINE_HOST_URL=${shellQuote3(input2.hostUrl)}`,
22572
+ `export DEEPLINE_CONFIG_SCOPE=${shellQuote3(input2.scope)}`,
22573
+ `exec ${shellQuote3(input2.nodeBin)} ${shellQuote3(input2.entryPath)} "$@"`,
22574
+ ""
22575
+ ].join("\n"),
22576
+ { encoding: "utf8", mode: 493 }
22577
+ );
22578
+ }
22579
+ async function runPythonSidecarUpdatePlan(plan) {
22580
+ const versionsDir = (0, import_node_path20.join)(plan.stateDir, "versions");
22581
+ const tempDir = (0, import_node_path20.join)(
22582
+ versionsDir,
22583
+ `.tmp-sdk-update-${process.pid}-${Date.now()}`
22584
+ );
22585
+ (0, import_node_fs16.rmSync)(tempDir, { recursive: true, force: true });
22586
+ (0, import_node_fs16.mkdirSync)(tempDir, { recursive: true });
22587
+ (0, import_node_fs16.writeFileSync)((0, import_node_path20.join)(tempDir, "package.json"), '{"private":true}\n', "utf8");
22588
+ const env = {
22589
+ ...process.env,
22590
+ PATH: `${(0, import_node_path20.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
22591
+ };
22592
+ const installExitCode = await runCommand(
22593
+ plan.npmCommand,
22594
+ [
22595
+ "install",
22596
+ "--prefix",
22597
+ tempDir,
22598
+ "--no-audit",
22599
+ "--no-fund",
22600
+ plan.packageSpec
22601
+ ],
22602
+ env
22603
+ );
22604
+ if (installExitCode !== 0) {
22605
+ (0, import_node_fs16.rmSync)(tempDir, { recursive: true, force: true });
22606
+ return installExitCode;
22607
+ }
22608
+ const installedVersion = installedPackageVersion(tempDir);
22609
+ if (!installedVersion) {
22610
+ process.stderr.write(
22611
+ "Updated Deepline SDK package did not report a version.\n"
22612
+ );
22613
+ (0, import_node_fs16.rmSync)(tempDir, { recursive: true, force: true });
22427
22614
  return 1;
22428
22615
  }
22429
- return runCommand(plan.command, plan.args);
22616
+ const finalDir = (0, import_node_path20.join)(versionsDir, installedVersion);
22617
+ const finalEntryPath = entryPathInVersionDir(finalDir);
22618
+ if ((0, import_node_fs16.existsSync)(finalEntryPath)) {
22619
+ (0, import_node_fs16.rmSync)(tempDir, { recursive: true, force: true });
22620
+ } else {
22621
+ (0, import_node_fs16.rmSync)(finalDir, { recursive: true, force: true });
22622
+ try {
22623
+ (0, import_node_fs16.renameSync)(tempDir, finalDir);
22624
+ } catch (error) {
22625
+ (0, import_node_fs16.rmSync)(tempDir, { recursive: true, force: true });
22626
+ process.stderr.write(
22627
+ `Failed to publish Deepline SDK sidecar update: ${error.message}
22628
+ `
22629
+ );
22630
+ return 1;
22631
+ }
22632
+ }
22633
+ if (!(0, import_node_fs16.existsSync)(finalEntryPath)) {
22634
+ process.stderr.write(
22635
+ `Updated Deepline SDK CLI entrypoint missing: ${finalEntryPath}
22636
+ `
22637
+ );
22638
+ return 1;
22639
+ }
22640
+ writeSidecarLauncher({
22641
+ path: plan.sidecarPath,
22642
+ hostUrl: plan.hostUrl,
22643
+ scope: plan.scope,
22644
+ nodeBin: plan.nodeBin,
22645
+ entryPath: finalEntryPath
22646
+ });
22647
+ (0, import_node_fs16.writeFileSync)(
22648
+ (0, import_node_path20.join)(plan.stateDir, ".version"),
22649
+ `${installedVersion}
22650
+ `,
22651
+ "utf8"
22652
+ );
22653
+ (0, import_node_fs16.writeFileSync)(
22654
+ (0, import_node_path20.join)(plan.stateDir, ".install-method"),
22655
+ "python-sidecar\n",
22656
+ "utf8"
22657
+ );
22658
+ (0, import_node_fs16.writeFileSync)(
22659
+ (0, import_node_path20.join)(plan.stateDir, ".command-path"),
22660
+ `${plan.sidecarPath}
22661
+ `,
22662
+ "utf8"
22663
+ );
22664
+ (0, import_node_fs16.writeFileSync)((0, import_node_path20.join)(plan.stateDir, ".runner"), "node\n", "utf8");
22665
+ (0, import_node_fs16.writeFileSync)((0, import_node_path20.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
22666
+ `, "utf8");
22667
+ (0, import_node_fs16.writeFileSync)(
22668
+ (0, import_node_path20.join)(plan.stateDir, ".entry-path"),
22669
+ `${finalEntryPath}
22670
+ `,
22671
+ "utf8"
22672
+ );
22673
+ return 0;
22674
+ }
22675
+ async function runUpdatePlan(plan) {
22676
+ if (plan.kind === "npm-global") {
22677
+ return runCommand(plan.command, plan.args);
22678
+ }
22679
+ if (plan.kind === "python-sidecar") {
22680
+ return runPythonSidecarUpdatePlan(plan);
22681
+ }
22682
+ return 1;
22430
22683
  }
22431
22684
  async function handleUpdate(options) {
22432
22685
  const plan = resolveUpdatePlan();
@@ -22437,6 +22690,9 @@ async function handleUpdate(options) {
22437
22690
  lines: plan.kind === "source" ? [
22438
22691
  "This Deepline CLI is running from SDK source, so it cannot safely update itself like an npm global.",
22439
22692
  `Update the backing checkout with: ${plan.manualCommand}`
22693
+ ] : plan.kind === "python-sidecar" ? [
22694
+ "This Deepline CLI is running from the Python-managed SDK sidecar.",
22695
+ "Updating will refresh that sidecar, not a global npm binary."
22440
22696
  ] : [`Updating Deepline SDK/CLI with: ${plan.manualCommand}`]
22441
22697
  }
22442
22698
  ]
@@ -22466,7 +22722,7 @@ async function handleUpdate(options) {
22466
22722
  `Updating Deepline SDK/CLI with: ${plan.manualCommand}
22467
22723
  `
22468
22724
  );
22469
- return runCommand(plan.command, plan.args);
22725
+ return runUpdatePlan(plan);
22470
22726
  }
22471
22727
  function registerUpdateCommand(program) {
22472
22728
  program.command("update").description("Update the Deepline SDK/CLI.").addHelpText(
@@ -22474,6 +22730,8 @@ function registerUpdateCommand(program) {
22474
22730
  `
22475
22731
  Notes:
22476
22732
  For the published npm CLI, this runs npm install -g deepline@latest.
22733
+ For Python-managed SDK sidecars, this refreshes the sidecar that launched
22734
+ the current SDK CLI instead of changing a global npm binary.
22477
22735
  For repo-backed SDK wrappers such as cli-env sdk-prod or sdk-worktree, this
22478
22736
  prints the exact git command to update the checkout that provides the CLI.
22479
22737
 
@@ -22687,10 +22945,13 @@ function isCi() {
22687
22945
  function shouldSkipSelfUpdate() {
22688
22946
  return envTruthy("DEEPLINE_SKIP_SELF_UPDATE") || envTruthy("DEEPLINE_NO_AUTO_UPDATE") || envTruthy("DEEPLINE_SKIP_SDK_AUTO_UPDATE") || envTruthy("DEEPLINE_DISABLE_AUTO_UPDATE") || isCi();
22689
22947
  }
22690
- function relaunchCurrentCommand() {
22948
+ function relaunchCurrentCommand(plan) {
22691
22949
  return new Promise((resolve16) => {
22692
- const child = (0, import_node_child_process3.spawn)(process.execPath, process.argv.slice(1), {
22950
+ const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
22951
+ const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
22952
+ const child = (0, import_node_child_process3.spawn)(command, args, {
22693
22953
  stdio: "inherit",
22954
+ shell: process.platform === "win32",
22694
22955
  env: {
22695
22956
  ...process.env,
22696
22957
  DEEPLINE_NO_AUTO_UPDATE: "1"
@@ -22711,8 +22972,9 @@ async function maybeAutoUpdateAndRelaunch(response) {
22711
22972
  if (!response || !autoUpdate?.should_auto_update || shouldSkipSelfUpdate()) {
22712
22973
  return false;
22713
22974
  }
22714
- const plan = resolveUpdatePlan();
22715
- if (plan.kind !== "npm-global") {
22975
+ const packageSpec = response.latest ? `deepline@${response.latest}` : void 0;
22976
+ const plan = resolveUpdatePlan({ packageSpec });
22977
+ if (plan.kind === "source") {
22716
22978
  return false;
22717
22979
  }
22718
22980
  const label = autoUpdate.reason === "rollback_forced" ? "has a server rollback pending and needs the latest rollback-aware CLI" : autoUpdate.required ? "requires an update" : "is more than the supported auto-update lag behind";
@@ -22720,7 +22982,7 @@ async function maybeAutoUpdateAndRelaunch(response) {
22720
22982
  `Deepline SDK/CLI ${label}; running ${plan.manualCommand}
22721
22983
  `
22722
22984
  );
22723
- const updateExitCode = await runNpmGlobalUpdatePlan(plan);
22985
+ const updateExitCode = await runUpdatePlan(plan);
22724
22986
  if (updateExitCode !== 0) {
22725
22987
  if (autoUpdate.required) {
22726
22988
  throw new Error(
@@ -22734,7 +22996,7 @@ async function maybeAutoUpdateAndRelaunch(response) {
22734
22996
  return false;
22735
22997
  }
22736
22998
  process.stderr.write("Deepline SDK/CLI updated; rerunning command.\n");
22737
- const exitCode = await relaunchCurrentCommand();
22999
+ const exitCode = await relaunchCurrentCommand(plan);
22738
23000
  process.exit(exitCode);
22739
23001
  return true;
22740
23002
  }
@@ -22742,7 +23004,7 @@ async function maybeAutoUpdateAndRelaunch(response) {
22742
23004
  // src/cli/skills-sync.ts
22743
23005
  var import_node_child_process4 = require("child_process");
22744
23006
  var import_node_fs17 = require("fs");
22745
- var import_node_os13 = require("os");
23007
+ var import_node_os14 = require("os");
22746
23008
  var import_node_path21 = require("path");
22747
23009
  var CHECK_TIMEOUT_MS2 = 3e3;
22748
23010
  var SDK_PLAY_SKILL_NAME = "deepline-plays";
@@ -22769,7 +23031,7 @@ function readPluginSkillsVersion() {
22769
23031
  }
22770
23032
  }
22771
23033
  function sdkSkillsVersionPath(baseUrl) {
22772
- const home = process.env.HOME?.trim() || (0, import_node_os13.homedir)();
23034
+ const home = process.env.HOME?.trim() || (0, import_node_os14.homedir)();
22773
23035
  return (0, import_node_path21.join)(
22774
23036
  home,
22775
23037
  ".local",
@@ -22972,7 +23234,7 @@ async function syncSdkSkillsIfNeeded(baseUrl) {
22972
23234
  }
22973
23235
 
22974
23236
  // src/cli/failure-reporting.ts
22975
- var import_node_os14 = require("os");
23237
+ var import_node_os15 = require("os");
22976
23238
  var FAILURE_REPORT_DISABLE_ENV = "DEEPLINE_DISABLE_FAILURE_REPORTING";
22977
23239
  var REPORT_FAILURE_TIMEOUT_MS = 1e4;
22978
23240
  var MAX_FAILURE_TEXT_CHARS = 4e3;
@@ -23094,12 +23356,12 @@ function detectAgentRuntime3() {
23094
23356
  }
23095
23357
  function buildEnvironmentContext() {
23096
23358
  const context = {
23097
- os: (0, import_node_os14.platform)(),
23098
- os_release: (0, import_node_os14.release)(),
23099
- platform: `${(0, import_node_os14.platform)()}-${(0, import_node_os14.release)()}-${process.arch}`,
23359
+ os: (0, import_node_os15.platform)(),
23360
+ os_release: (0, import_node_os15.release)(),
23361
+ platform: `${(0, import_node_os15.platform)()}-${(0, import_node_os15.release)()}-${process.arch}`,
23100
23362
  node_version: process.version,
23101
23363
  runtime: "Node.js",
23102
- hostname: (0, import_node_os14.hostname)(),
23364
+ hostname: (0, import_node_os15.hostname)(),
23103
23365
  agent_runtime: detectAgentRuntime3()
23104
23366
  };
23105
23367
  for (const key of ["CLAUDE_CODE_REMOTE", "DEEPLINE_PLUGIN_MODE"]) {
@@ -23279,7 +23541,7 @@ function topLevelCommandKnown(program, commandName) {
23279
23541
  );
23280
23542
  }
23281
23543
  async function runPlayRunnerHealthCheck() {
23282
- const dir = await (0, import_promises7.mkdtemp)((0, import_node_path22.join)((0, import_node_os15.tmpdir)(), "deepline-health-play-"));
23544
+ const dir = await (0, import_promises7.mkdtemp)((0, import_node_path22.join)((0, import_node_os16.tmpdir)(), "deepline-health-play-"));
23283
23545
  const file = (0, import_node_path22.join)(dir, "health-check.play.ts");
23284
23546
  try {
23285
23547
  await (0, import_promises7.writeFile)(
@@ -380,10 +380,10 @@ var SDK_RELEASE = {
380
380
  // skill on the sdk sync surface, and the people-search-to-email prebuilt.
381
381
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
382
382
  // the SDK enrich generator's one-second stale policy.
383
- version: "0.1.112",
383
+ version: "0.1.114",
384
384
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
385
385
  supportPolicy: {
386
- latest: "0.1.112",
386
+ latest: "0.1.114",
387
387
  minimumSupported: "0.1.53",
388
388
  deprecatedBelow: "0.1.53",
389
389
  commandMinimumSupported: [
@@ -16049,6 +16049,8 @@ ${indent(renderJavascriptBody(command.run_if_js), 6)}
16049
16049
  force: true` : "";
16050
16050
  const legacyEnvelope = options.legacyEnvelope ? `,
16051
16051
  legacyEnvelope: true` : "";
16052
+ const waterfallSoftFail = options.waterfallSoftFail ? `,
16053
+ waterfallSoftFail: true` : "";
16052
16054
  return [
16053
16055
  `async (row, stepCtx) => {`,
16054
16056
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
@@ -16060,7 +16062,7 @@ ${indent(renderJavascriptBody(command.run_if_js), 6)}
16060
16062
  ` extract: ${extractJs},`,
16061
16063
  ` runIf: ${runIfJs},`,
16062
16064
  ` row,`,
16063
- ` stepCtx${description}${force}${legacyEnvelope}`,
16065
+ ` stepCtx${description}${force}${legacyEnvelope}${waterfallSoftFail}`,
16064
16066
  ` });`,
16065
16067
  `}`
16066
16068
  ].join("\n");
@@ -16084,34 +16086,22 @@ function renderIdiomaticExecuteStep(command, options) {
16084
16086
  `async (row, ctx) => {`,
16085
16087
  ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
16086
16088
  ...runIfLines,
16087
- ` const result: any = await ctx.tools.execute({`,
16088
- ` id: ${callId},`,
16089
- ` tool: ${tool},`,
16090
- ` input: ${input2} as any,`,
16091
- ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
16092
- ...options.force ? [` force: true,`] : [],
16093
- ` });`,
16089
+ ` let result: any;`,
16090
+ ` try {`,
16091
+ ` result = await ctx.tools.execute({`,
16092
+ ` id: ${callId},`,
16093
+ ` tool: ${tool},`,
16094
+ ` input: ${input2} as any,`,
16095
+ ` description: ${stringLiteral((command.description ?? "").trim() || `Run ${command.alias} via ${command.tool}.`)},`,
16096
+ ...options.force ? [` force: true,`] : [],
16097
+ ` });`,
16098
+ ` } catch (error) {`,
16099
+ ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
16100
+ ` }`,
16094
16101
  ` return ${extraction};`,
16095
16102
  `}`
16096
16103
  ].join("\n");
16097
16104
  }
16098
- function renderInlineJavascriptStep(command, options) {
16099
- const code = typeof command.payload?.code === "string" ? command.payload.code : "return null;";
16100
- const runIfLines = command.run_if_js ? [
16101
- ` if (!((row: Record<string, any>) => { const input = row; const context = row;`,
16102
- indent(renderJavascriptBody(command.run_if_js), 4),
16103
- ` })(row as Record<string, any>)) return null;`
16104
- ] : [];
16105
- return [
16106
- `async (row) => {`,
16107
- ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
16108
- ...runIfLines,
16109
- ` return ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
16110
- indent(renderJavascriptBody(code), 4),
16111
- ` })(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
16112
- `}`
16113
- ].join("\n");
16114
- }
16115
16105
  function renderPlayStep(command, options) {
16116
16106
  const alias = stringLiteral(command.alias);
16117
16107
  const callId = stringLiteral(commandCallId(command));
@@ -16130,13 +16120,35 @@ ${indent(renderJavascriptBody(command.run_if_js), 6)}
16130
16120
  ` const templateRow = __dlPrepareEnrichRow(row, [${alias}]);`,
16131
16121
  ...runIfLines,
16132
16122
  ` const payload = __dlTemplate(${payload}, templateRow) as Record<string, unknown>;`,
16133
- ` const result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
16134
- ` description: ${stringLiteral(command.description ?? command.alias)}`,
16135
- ` });`,
16123
+ ` let result: unknown;`,
16124
+ ` try {`,
16125
+ ` result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
16126
+ ` description: ${stringLiteral(command.description ?? command.alias)}`,
16127
+ ` });`,
16128
+ ` } catch (error) {`,
16129
+ ...options.waterfallSoftFail ? [` return __dlWaterfallToolFailure(error);`] : [` throw error;`],
16130
+ ` }`,
16136
16131
  ` return __dlPlayResultValue(${alias}, result);`,
16137
16132
  `}`
16138
16133
  ].join("\n");
16139
16134
  }
16135
+ function renderInlineJavascriptStep(command, options) {
16136
+ const code = typeof command.payload?.code === "string" ? command.payload.code : "return null;";
16137
+ const runIfLines = command.run_if_js ? [
16138
+ ` if (!((row: Record<string, any>) => { const input = row; const context = row;`,
16139
+ indent(renderJavascriptBody(command.run_if_js), 4),
16140
+ ` })(row as Record<string, any>)) return null;`
16141
+ ] : [];
16142
+ return [
16143
+ `async (row) => {`,
16144
+ ...options.precheck ? [` if (${options.precheck}) return null;`] : [],
16145
+ ...runIfLines,
16146
+ ` return ((row: Record<string, any>, input: Record<string, any>, context: Record<string, any>) => {`,
16147
+ indent(renderJavascriptBody(code), 4),
16148
+ ` })(row as Record<string, any>, row as Record<string, any>, row as Record<string, any>);`,
16149
+ `}`
16150
+ ].join("\n");
16151
+ }
16140
16152
  function renderJavascriptBody(source) {
16141
16153
  assertUserCodeIsSafe(source, "play step code");
16142
16154
  const trimmed = source.trim();
@@ -16263,7 +16275,8 @@ function renderWaterfallColumns(command, forceAliases, inlineRunJavascript, idio
16263
16275
  precheck: priorAliases.length > 0 ? `__dlWaterfallSatisfied(row, ${stableJson(priorAliases)}, ${minResults})` : void 0,
16264
16276
  legacyEnvelope: Boolean(nested.extract_js),
16265
16277
  inlineRunJavascript,
16266
- idiomaticGetters
16278
+ idiomaticGetters,
16279
+ waterfallSoftFail: true
16267
16280
  }),
16268
16281
  { recompute: force, recomputeOnError: true }
16269
16282
  );
@@ -16918,6 +16931,26 @@ function helperSource() {
16918
16931
  ` return 'Extractor failed';`,
16919
16932
  `}`,
16920
16933
  ``,
16934
+ `function __dlErrorDetail(error: unknown): string {`,
16935
+ ` const message = __dlErrorMessage(error);`,
16936
+ ` if (!__dlRecord(error)) return message;`,
16937
+ ` try {`,
16938
+ ` return message + ' ' + JSON.stringify(error);`,
16939
+ ` } catch {`,
16940
+ ` return message;`,
16941
+ ` }`,
16942
+ `}`,
16943
+ ``,
16944
+ `function __dlRecoverableWaterfallToolError(error: unknown): boolean {`,
16945
+ ` const detail = __dlErrorDetail(error).toLowerCase();`,
16946
+ ` return /\\b5\\d\\d\\b/.test(detail) || detail.includes('upstream_failure') || detail.includes('"error_category":"upstream"') || (detail.includes('"failure_origin":"provider"') && detail.includes('"status":5')) || detail.includes('bad gateway') || detail.includes('gateway time-out') || detail.includes('gateway timeout') || detail.includes('service unavailable');`,
16947
+ `}`,
16948
+ ``,
16949
+ `function __dlWaterfallToolFailure(error: unknown): unknown {`,
16950
+ ` if (__dlRecoverableWaterfallToolError(error)) return __dlExtractorFailure(error);`,
16951
+ ` throw error;`,
16952
+ `}`,
16953
+ ``,
16921
16954
  `function __dlExtractorFailure(error: unknown): unknown {`,
16922
16955
  ` const message = __dlErrorMessage(error);`,
16923
16956
  ` return { matched_result: null, result: { error: message, message } };`,
@@ -17014,19 +17047,25 @@ function helperSource() {
17014
17047
  ` return result;`,
17015
17048
  `}`,
17016
17049
  ``,
17017
- `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean }): Promise<unknown> {`,
17050
+ `async function __dlRunCommand(input: { alias: string; callId: string; tool: string; payload: Record<string, unknown>; extract: ((args: __DlExtractorHelpers) => unknown) | null; runIf: ((row: Record<string, unknown>) => unknown) | null; row: Record<string, unknown>; stepCtx: { tools: { execute: (request: Record<string, unknown>) => Promise<unknown> } }; description?: string; force?: boolean; legacyEnvelope?: boolean; waterfallSoftFail?: boolean }): Promise<unknown> {`,
17018
17051
  ` if (input.runIf) {`,
17019
17052
  ` const shouldRun = input.runIf(input.row);`,
17020
17053
  ` if (!shouldRun) return null;`,
17021
17054
  ` }`,
17022
17055
  ` const payload = __dlRuntimePayload(input.tool, __dlTemplate(input.payload, input.row) as Record<string, unknown>, input.row);`,
17023
- ` const result = await input.stepCtx.tools.execute({`,
17024
- ` id: input.callId,`,
17025
- ` tool: input.tool,`,
17026
- ` input: payload,`,
17027
- ` ...(input.description ? { description: input.description } : {}),`,
17028
- ` ...(input.force ? { force: true } : {}),`,
17029
- ` });`,
17056
+ ` let result: unknown;`,
17057
+ ` try {`,
17058
+ ` result = await input.stepCtx.tools.execute({`,
17059
+ ` id: input.callId,`,
17060
+ ` tool: input.tool,`,
17061
+ ` input: payload,`,
17062
+ ` ...(input.description ? { description: input.description } : {}),`,
17063
+ ` ...(input.force ? { force: true } : {}),`,
17064
+ ` });`,
17065
+ ` } catch (error) {`,
17066
+ ` if (input.waterfallSoftFail) return __dlWaterfallToolFailure(error);`,
17067
+ ` throw error;`,
17068
+ ` }`,
17030
17069
  ` return __dlExtract(input.alias, result, input.row, input.extract, Boolean(input.legacyEnvelope));`,
17031
17070
  `}`
17032
17071
  ].join("\n");
@@ -22387,8 +22426,16 @@ Notes:
22387
22426
 
22388
22427
  // src/cli/commands/update.ts
22389
22428
  import { spawn as spawn2 } from "child_process";
22390
- import { existsSync as existsSync12 } from "fs";
22391
- import { dirname as dirname13, join as join15, resolve as resolve15 } from "path";
22429
+ import {
22430
+ existsSync as existsSync12,
22431
+ mkdirSync as mkdirSync8,
22432
+ readFileSync as readFileSync11,
22433
+ renameSync,
22434
+ rmSync as rmSync3,
22435
+ writeFileSync as writeFileSync13
22436
+ } from "fs";
22437
+ import { homedir as homedir9 } from "os";
22438
+ import { dirname as dirname13, isAbsolute as isAbsolute4, join as join15, relative as relative4, resolve as resolve15 } from "path";
22392
22439
  function posixShellQuote(value) {
22393
22440
  return `'${value.replace(/'/g, `'\\''`)}'`;
22394
22441
  }
@@ -22406,6 +22453,55 @@ function buildSourceUpdateCommand(sourceRoot) {
22406
22453
  const cdCommand = process.platform === "win32" ? `cd /d ${quotedRoot}` : `cd ${quotedRoot}`;
22407
22454
  return `${cdCommand} && git fetch origin main --tags && git merge --ff-only origin/main`;
22408
22455
  }
22456
+ function sidecarStateDir(input2) {
22457
+ const scope = input2.env.DEEPLINE_CONFIG_SCOPE?.trim();
22458
+ if (!scope || scope.includes("/") || scope.includes("\\")) {
22459
+ return null;
22460
+ }
22461
+ return join15(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
22462
+ }
22463
+ function readOptionalText(path) {
22464
+ try {
22465
+ return readFileSync11(path, "utf8").trim();
22466
+ } catch {
22467
+ return "";
22468
+ }
22469
+ }
22470
+ function resolvePythonSidecarUpdatePlan(options) {
22471
+ const stateDir = sidecarStateDir(options);
22472
+ if (!stateDir) return null;
22473
+ const relativeEntrypoint = relative4(
22474
+ resolve15(stateDir),
22475
+ resolve15(options.entrypoint)
22476
+ );
22477
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute4(relativeEntrypoint)) {
22478
+ return null;
22479
+ }
22480
+ const installMethod = readOptionalText(join15(stateDir, ".install-method"));
22481
+ if (installMethod !== "python-sidecar") return null;
22482
+ const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
22483
+ const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
22484
+ const nodeBin = readOptionalText(join15(stateDir, ".node-bin")) || process.execPath;
22485
+ const sidecarPath = readOptionalText(join15(stateDir, ".command-path")) || join15(
22486
+ stateDir,
22487
+ "bin",
22488
+ process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
22489
+ );
22490
+ const packageSpec = options.packageSpec || "deepline@latest";
22491
+ const npmCommand = "npm";
22492
+ const manualCommand = `${npmCommand} install --prefix ${shellQuote3(join15(stateDir, "versions", "<version>"))} --no-audit --no-fund ${shellQuote3(packageSpec)}`;
22493
+ return {
22494
+ kind: "python-sidecar",
22495
+ stateDir,
22496
+ sidecarPath,
22497
+ nodeBin,
22498
+ npmCommand,
22499
+ scope,
22500
+ hostUrl,
22501
+ packageSpec,
22502
+ manualCommand
22503
+ };
22504
+ }
22409
22505
  function findRepoBackedSdkRoot(startPath) {
22410
22506
  let current = resolve15(startPath);
22411
22507
  while (true) {
@@ -22417,8 +22513,10 @@ function findRepoBackedSdkRoot(startPath) {
22417
22513
  current = parent;
22418
22514
  }
22419
22515
  }
22420
- function resolveUpdatePlan() {
22421
- const entrypoint = process.argv[1] ? resolve15(process.argv[1]) : "";
22516
+ function resolveUpdatePlan(options = {}) {
22517
+ const env = options.env ?? process.env;
22518
+ const homeDir2 = options.homeDir ?? homedir9();
22519
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve15(process.argv[1]) : "");
22422
22520
  const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname13(entrypoint)) : null;
22423
22521
  if (sourceRoot) {
22424
22522
  return {
@@ -22427,8 +22525,16 @@ function resolveUpdatePlan() {
22427
22525
  manualCommand: buildSourceUpdateCommand(sourceRoot)
22428
22526
  };
22429
22527
  }
22528
+ const sidecarPlan = resolvePythonSidecarUpdatePlan({
22529
+ entrypoint,
22530
+ env,
22531
+ homeDir: homeDir2,
22532
+ packageSpec: options.packageSpec
22533
+ });
22534
+ if (sidecarPlan) return sidecarPlan;
22430
22535
  const command = "npm";
22431
- const args = ["install", "-g", "deepline@latest"];
22536
+ const packageSpec = options.packageSpec || "deepline@latest";
22537
+ const args = ["install", "-g", packageSpec];
22432
22538
  return {
22433
22539
  kind: "npm-global",
22434
22540
  command,
@@ -22436,12 +22542,40 @@ function resolveUpdatePlan() {
22436
22542
  manualCommand: `${command} ${args.map(shellQuote3).join(" ")}`
22437
22543
  };
22438
22544
  }
22439
- function runCommand(command, args) {
22545
+ function safeVersionSegment(value) {
22546
+ const normalized = value.trim();
22547
+ return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
22548
+ }
22549
+ function entryPathInVersionDir(versionDir) {
22550
+ return join15(
22551
+ versionDir,
22552
+ "node_modules",
22553
+ "deepline",
22554
+ "dist",
22555
+ "cli",
22556
+ "index.mjs"
22557
+ );
22558
+ }
22559
+ function installedPackageVersion(versionDir) {
22560
+ const packageJsonPath = join15(
22561
+ versionDir,
22562
+ "node_modules",
22563
+ "deepline",
22564
+ "package.json"
22565
+ );
22566
+ try {
22567
+ const parsed = JSON.parse(readFileSync11(packageJsonPath, "utf8"));
22568
+ return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
22569
+ } catch {
22570
+ return "";
22571
+ }
22572
+ }
22573
+ function runCommand(command, args, env = process.env) {
22440
22574
  return new Promise((resolveExitCode) => {
22441
22575
  const child = spawn2(command, args, {
22442
22576
  stdio: "inherit",
22443
22577
  shell: process.platform === "win32",
22444
- env: process.env
22578
+ env
22445
22579
  });
22446
22580
  child.on("error", (error) => {
22447
22581
  process.stderr.write(`Failed to start ${command}: ${error.message}
@@ -22453,11 +22587,137 @@ function runCommand(command, args) {
22453
22587
  });
22454
22588
  });
22455
22589
  }
22456
- async function runNpmGlobalUpdatePlan(plan) {
22457
- if (plan.kind !== "npm-global") {
22590
+ function writeSidecarLauncher(input2) {
22591
+ mkdirSync8(dirname13(input2.path), { recursive: true });
22592
+ if (process.platform === "win32") {
22593
+ writeFileSync13(
22594
+ input2.path,
22595
+ [
22596
+ `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
22597
+ `@set DEEPLINE_CONFIG_SCOPE=${input2.scope.replace(/\r?\n/g, "")}`,
22598
+ `@"${input2.nodeBin}" "${input2.entryPath}" %*`,
22599
+ ""
22600
+ ].join("\r\n"),
22601
+ "utf8"
22602
+ );
22603
+ return;
22604
+ }
22605
+ writeFileSync13(
22606
+ input2.path,
22607
+ [
22608
+ "#!/usr/bin/env sh",
22609
+ `export DEEPLINE_HOST_URL=${shellQuote3(input2.hostUrl)}`,
22610
+ `export DEEPLINE_CONFIG_SCOPE=${shellQuote3(input2.scope)}`,
22611
+ `exec ${shellQuote3(input2.nodeBin)} ${shellQuote3(input2.entryPath)} "$@"`,
22612
+ ""
22613
+ ].join("\n"),
22614
+ { encoding: "utf8", mode: 493 }
22615
+ );
22616
+ }
22617
+ async function runPythonSidecarUpdatePlan(plan) {
22618
+ const versionsDir = join15(plan.stateDir, "versions");
22619
+ const tempDir = join15(
22620
+ versionsDir,
22621
+ `.tmp-sdk-update-${process.pid}-${Date.now()}`
22622
+ );
22623
+ rmSync3(tempDir, { recursive: true, force: true });
22624
+ mkdirSync8(tempDir, { recursive: true });
22625
+ writeFileSync13(join15(tempDir, "package.json"), '{"private":true}\n', "utf8");
22626
+ const env = {
22627
+ ...process.env,
22628
+ PATH: `${dirname13(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
22629
+ };
22630
+ const installExitCode = await runCommand(
22631
+ plan.npmCommand,
22632
+ [
22633
+ "install",
22634
+ "--prefix",
22635
+ tempDir,
22636
+ "--no-audit",
22637
+ "--no-fund",
22638
+ plan.packageSpec
22639
+ ],
22640
+ env
22641
+ );
22642
+ if (installExitCode !== 0) {
22643
+ rmSync3(tempDir, { recursive: true, force: true });
22644
+ return installExitCode;
22645
+ }
22646
+ const installedVersion = installedPackageVersion(tempDir);
22647
+ if (!installedVersion) {
22648
+ process.stderr.write(
22649
+ "Updated Deepline SDK package did not report a version.\n"
22650
+ );
22651
+ rmSync3(tempDir, { recursive: true, force: true });
22652
+ return 1;
22653
+ }
22654
+ const finalDir = join15(versionsDir, installedVersion);
22655
+ const finalEntryPath = entryPathInVersionDir(finalDir);
22656
+ if (existsSync12(finalEntryPath)) {
22657
+ rmSync3(tempDir, { recursive: true, force: true });
22658
+ } else {
22659
+ rmSync3(finalDir, { recursive: true, force: true });
22660
+ try {
22661
+ renameSync(tempDir, finalDir);
22662
+ } catch (error) {
22663
+ rmSync3(tempDir, { recursive: true, force: true });
22664
+ process.stderr.write(
22665
+ `Failed to publish Deepline SDK sidecar update: ${error.message}
22666
+ `
22667
+ );
22668
+ return 1;
22669
+ }
22670
+ }
22671
+ if (!existsSync12(finalEntryPath)) {
22672
+ process.stderr.write(
22673
+ `Updated Deepline SDK CLI entrypoint missing: ${finalEntryPath}
22674
+ `
22675
+ );
22458
22676
  return 1;
22459
22677
  }
22460
- return runCommand(plan.command, plan.args);
22678
+ writeSidecarLauncher({
22679
+ path: plan.sidecarPath,
22680
+ hostUrl: plan.hostUrl,
22681
+ scope: plan.scope,
22682
+ nodeBin: plan.nodeBin,
22683
+ entryPath: finalEntryPath
22684
+ });
22685
+ writeFileSync13(
22686
+ join15(plan.stateDir, ".version"),
22687
+ `${installedVersion}
22688
+ `,
22689
+ "utf8"
22690
+ );
22691
+ writeFileSync13(
22692
+ join15(plan.stateDir, ".install-method"),
22693
+ "python-sidecar\n",
22694
+ "utf8"
22695
+ );
22696
+ writeFileSync13(
22697
+ join15(plan.stateDir, ".command-path"),
22698
+ `${plan.sidecarPath}
22699
+ `,
22700
+ "utf8"
22701
+ );
22702
+ writeFileSync13(join15(plan.stateDir, ".runner"), "node\n", "utf8");
22703
+ writeFileSync13(join15(plan.stateDir, ".node-bin"), `${plan.nodeBin}
22704
+ `, "utf8");
22705
+ writeFileSync13(
22706
+ join15(plan.stateDir, ".entry-path"),
22707
+ `${finalEntryPath}
22708
+ `,
22709
+ "utf8"
22710
+ );
22711
+ return 0;
22712
+ }
22713
+ async function runUpdatePlan(plan) {
22714
+ if (plan.kind === "npm-global") {
22715
+ return runCommand(plan.command, plan.args);
22716
+ }
22717
+ if (plan.kind === "python-sidecar") {
22718
+ return runPythonSidecarUpdatePlan(plan);
22719
+ }
22720
+ return 1;
22461
22721
  }
22462
22722
  async function handleUpdate(options) {
22463
22723
  const plan = resolveUpdatePlan();
@@ -22468,6 +22728,9 @@ async function handleUpdate(options) {
22468
22728
  lines: plan.kind === "source" ? [
22469
22729
  "This Deepline CLI is running from SDK source, so it cannot safely update itself like an npm global.",
22470
22730
  `Update the backing checkout with: ${plan.manualCommand}`
22731
+ ] : plan.kind === "python-sidecar" ? [
22732
+ "This Deepline CLI is running from the Python-managed SDK sidecar.",
22733
+ "Updating will refresh that sidecar, not a global npm binary."
22471
22734
  ] : [`Updating Deepline SDK/CLI with: ${plan.manualCommand}`]
22472
22735
  }
22473
22736
  ]
@@ -22497,7 +22760,7 @@ async function handleUpdate(options) {
22497
22760
  `Updating Deepline SDK/CLI with: ${plan.manualCommand}
22498
22761
  `
22499
22762
  );
22500
- return runCommand(plan.command, plan.args);
22763
+ return runUpdatePlan(plan);
22501
22764
  }
22502
22765
  function registerUpdateCommand(program) {
22503
22766
  program.command("update").description("Update the Deepline SDK/CLI.").addHelpText(
@@ -22505,6 +22768,8 @@ function registerUpdateCommand(program) {
22505
22768
  `
22506
22769
  Notes:
22507
22770
  For the published npm CLI, this runs npm install -g deepline@latest.
22771
+ For Python-managed SDK sidecars, this refreshes the sidecar that launched
22772
+ the current SDK CLI instead of changing a global npm binary.
22508
22773
  For repo-backed SDK wrappers such as cli-env sdk-prod or sdk-worktree, this
22509
22774
  prints the exact git command to update the checkout that provides the CLI.
22510
22775
 
@@ -22718,10 +22983,13 @@ function isCi() {
22718
22983
  function shouldSkipSelfUpdate() {
22719
22984
  return envTruthy("DEEPLINE_SKIP_SELF_UPDATE") || envTruthy("DEEPLINE_NO_AUTO_UPDATE") || envTruthy("DEEPLINE_SKIP_SDK_AUTO_UPDATE") || envTruthy("DEEPLINE_DISABLE_AUTO_UPDATE") || isCi();
22720
22985
  }
22721
- function relaunchCurrentCommand() {
22986
+ function relaunchCurrentCommand(plan) {
22722
22987
  return new Promise((resolve16) => {
22723
- const child = spawn3(process.execPath, process.argv.slice(1), {
22988
+ const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
22989
+ const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
22990
+ const child = spawn3(command, args, {
22724
22991
  stdio: "inherit",
22992
+ shell: process.platform === "win32",
22725
22993
  env: {
22726
22994
  ...process.env,
22727
22995
  DEEPLINE_NO_AUTO_UPDATE: "1"
@@ -22742,8 +23010,9 @@ async function maybeAutoUpdateAndRelaunch(response) {
22742
23010
  if (!response || !autoUpdate?.should_auto_update || shouldSkipSelfUpdate()) {
22743
23011
  return false;
22744
23012
  }
22745
- const plan = resolveUpdatePlan();
22746
- if (plan.kind !== "npm-global") {
23013
+ const packageSpec = response.latest ? `deepline@${response.latest}` : void 0;
23014
+ const plan = resolveUpdatePlan({ packageSpec });
23015
+ if (plan.kind === "source") {
22747
23016
  return false;
22748
23017
  }
22749
23018
  const label = autoUpdate.reason === "rollback_forced" ? "has a server rollback pending and needs the latest rollback-aware CLI" : autoUpdate.required ? "requires an update" : "is more than the supported auto-update lag behind";
@@ -22751,7 +23020,7 @@ async function maybeAutoUpdateAndRelaunch(response) {
22751
23020
  `Deepline SDK/CLI ${label}; running ${plan.manualCommand}
22752
23021
  `
22753
23022
  );
22754
- const updateExitCode = await runNpmGlobalUpdatePlan(plan);
23023
+ const updateExitCode = await runUpdatePlan(plan);
22755
23024
  if (updateExitCode !== 0) {
22756
23025
  if (autoUpdate.required) {
22757
23026
  throw new Error(
@@ -22765,15 +23034,15 @@ async function maybeAutoUpdateAndRelaunch(response) {
22765
23034
  return false;
22766
23035
  }
22767
23036
  process.stderr.write("Deepline SDK/CLI updated; rerunning command.\n");
22768
- const exitCode = await relaunchCurrentCommand();
23037
+ const exitCode = await relaunchCurrentCommand(plan);
22769
23038
  process.exit(exitCode);
22770
23039
  return true;
22771
23040
  }
22772
23041
 
22773
23042
  // src/cli/skills-sync.ts
22774
23043
  import { spawn as spawn4, spawnSync as spawnSync2 } from "child_process";
22775
- import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync13 } from "fs";
22776
- import { homedir as homedir9 } from "os";
23044
+ import { existsSync as existsSync13, mkdirSync as mkdirSync9, readFileSync as readFileSync12, writeFileSync as writeFileSync14 } from "fs";
23045
+ import { homedir as homedir10 } from "os";
22777
23046
  import { dirname as dirname14, join as join16 } from "path";
22778
23047
  var CHECK_TIMEOUT_MS2 = 3e3;
22779
23048
  var SDK_PLAY_SKILL_NAME = "deepline-plays";
@@ -22794,13 +23063,13 @@ function readPluginSkillsVersion() {
22794
23063
  const dir = activePluginSkillsDir();
22795
23064
  if (!dir) return "";
22796
23065
  try {
22797
- return readFileSync11(join16(dir, ".version"), "utf-8").trim();
23066
+ return readFileSync12(join16(dir, ".version"), "utf-8").trim();
22798
23067
  } catch {
22799
23068
  return "";
22800
23069
  }
22801
23070
  }
22802
23071
  function sdkSkillsVersionPath(baseUrl) {
22803
- const home = process.env.HOME?.trim() || homedir9();
23072
+ const home = process.env.HOME?.trim() || homedir10();
22804
23073
  return join16(
22805
23074
  home,
22806
23075
  ".local",
@@ -22816,15 +23085,15 @@ function readLocalSkillsVersion(baseUrl) {
22816
23085
  const path = sdkSkillsVersionPath(baseUrl);
22817
23086
  if (!existsSync13(path)) return "";
22818
23087
  try {
22819
- return readFileSync11(path, "utf-8").trim();
23088
+ return readFileSync12(path, "utf-8").trim();
22820
23089
  } catch {
22821
23090
  return "";
22822
23091
  }
22823
23092
  }
22824
23093
  function writeLocalSkillsVersion(baseUrl, version) {
22825
23094
  const path = sdkSkillsVersionPath(baseUrl);
22826
- mkdirSync8(dirname14(path), { recursive: true });
22827
- writeFileSync13(path, `${version}
23095
+ mkdirSync9(dirname14(path), { recursive: true });
23096
+ writeFileSync14(path, `${version}
22828
23097
  `, "utf-8");
22829
23098
  }
22830
23099
  function sortedUniqueSkillNames(names) {
package/dist/index.js CHANGED
@@ -274,10 +274,10 @@ var SDK_RELEASE = {
274
274
  // skill on the sdk sync surface, and the people-search-to-email prebuilt.
275
275
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
276
276
  // the SDK enrich generator's one-second stale policy.
277
- version: "0.1.112",
277
+ version: "0.1.114",
278
278
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
279
279
  supportPolicy: {
280
- latest: "0.1.112",
280
+ latest: "0.1.114",
281
281
  minimumSupported: "0.1.53",
282
282
  deprecatedBelow: "0.1.53",
283
283
  commandMinimumSupported: [
package/dist/index.mjs CHANGED
@@ -196,10 +196,10 @@ var SDK_RELEASE = {
196
196
  // skill on the sdk sync surface, and the people-search-to-email prebuilt.
197
197
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
198
198
  // the SDK enrich generator's one-second stale policy.
199
- version: "0.1.112",
199
+ version: "0.1.114",
200
200
  apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
201
201
  supportPolicy: {
202
- latest: "0.1.112",
202
+ latest: "0.1.114",
203
203
  minimumSupported: "0.1.53",
204
204
  deprecatedBelow: "0.1.53",
205
205
  commandMinimumSupported: [
@@ -99,10 +99,10 @@ export const SDK_RELEASE = {
99
99
  // skill on the sdk sync surface, and the people-search-to-email prebuilt.
100
100
  // 0.1.108 ships explicit dataset column/tool recompute policy and removes
101
101
  // the SDK enrich generator's one-second stale policy.
102
- version: '0.1.112',
102
+ version: '0.1.114',
103
103
  apiContract: '2026-06-dataset-column-cell-stale-hard-cutover',
104
104
  supportPolicy: {
105
- latest: '0.1.112',
105
+ latest: '0.1.114',
106
106
  minimumSupported: '0.1.53',
107
107
  deprecatedBelow: '0.1.53',
108
108
  commandMinimumSupported: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.112",
3
+ "version": "0.1.114",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {