deepline 0.3.286 → 0.3.287

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +47 -24
  2. package/dist/bundling-sources/sdk/src/index.ts +4 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +7 -1
  4. package/dist/bundling-sources/sdk/src/types.ts +36 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/cell-provenance.ts +16 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +2 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +38 -3
  8. package/dist/bundling-sources/shared_libs/play-runtime/run-observation.ts +12 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +3 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +43 -1
  11. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +19 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +88 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +3 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +53 -25
  15. package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +83 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +2 -0
  17. package/dist/cli/index.js +579 -628
  18. package/dist/cli/index.mjs +456 -506
  19. package/dist/{client-B7ic-kY5.d.ts → client-FR_u0dxT.d.ts} +38 -1
  20. package/dist/{client-Dzf_KovW.d.mts → client-phK1Ixcl.d.mts} +38 -1
  21. package/dist/index.d.mts +2 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +48 -25
  24. package/dist/index.mjs +48 -25
  25. package/dist/install-integrity.json +2 -2
  26. package/dist/plays/run-request.d.mts +1 -1
  27. package/dist/plays/run-request.d.ts +1 -1
  28. package/dist/release.d.mts +5 -1
  29. package/dist/release.d.ts +5 -1
  30. package/dist/release.js +6 -1
  31. package/dist/release.mjs +6 -1
  32. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -1964,7 +1964,7 @@ configureProxyFromEnv();
1964
1964
 
1965
1965
  // src/cli/index.ts
1966
1966
  var import_promises15 = require("fs/promises");
1967
- var import_node_path34 = require("path");
1967
+ var import_node_path35 = require("path");
1968
1968
  var import_node_os19 = require("os");
1969
1969
  var import_commander6 = require("commander");
1970
1970
 
@@ -3515,7 +3515,7 @@ var SDK_RELEASE = {
3515
3515
  // getters keep their established compatibility behavior.
3516
3516
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3517
3517
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3518
- version: "0.3.286",
3518
+ version: "0.3.287",
3519
3519
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3520
3520
  packageCapabilities: {
3521
3521
  updatePreferences: 1
@@ -3549,6 +3549,11 @@ var SDK_RELEASE = {
3549
3549
  minimumSupported: "0.1.53",
3550
3550
  deprecatedBelow: "0.3.1",
3551
3551
  commandIntroducedIn: [
3552
+ {
3553
+ command: "search",
3554
+ introducedIn: "0.3.91",
3555
+ reason: "deepline search was added in SDK CLI 0.3.91 as the one search across tools, monitors, and plays. On an older version run deepline tools search or deepline plays search, or update."
3556
+ },
3552
3557
  {
3553
3558
  command: "notifications",
3554
3559
  introducedIn: "0.2.40",
@@ -7214,6 +7219,27 @@ function chunkRegisterPlayArtifacts(artifacts) {
7214
7219
  }
7215
7220
  return chunks;
7216
7221
  }
7222
+ function searchParams(options) {
7223
+ const params = new URLSearchParams();
7224
+ params.set("q", options.query?.trim() ?? "");
7225
+ params.set(
7226
+ "include_search_debug",
7227
+ options.includeSearchDebug ? "true" : "false"
7228
+ );
7229
+ params.set("search_mode", options.searchMode ?? "v2");
7230
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
7231
+ if (options.offset !== void 0) {
7232
+ params.set("offset", String(options.offset));
7233
+ }
7234
+ if (options.categories?.trim()) {
7235
+ params.set("categories", options.categories.trim());
7236
+ }
7237
+ if (options.searchTerms?.trim()) {
7238
+ params.set("search_terms", options.searchTerms.trim());
7239
+ }
7240
+ if (options.task?.trim()) params.set("task", options.task.trim());
7241
+ return params;
7242
+ }
7217
7243
  var RUNS_FAILED_LOG_LIMIT = 20;
7218
7244
  var RUN_LOGS_PAGE_LIMIT = 1e3;
7219
7245
  function requireTargetBillingIdempotencyKey(value) {
@@ -7694,33 +7720,30 @@ var DeeplineClient = class _DeeplineClient {
7694
7720
  * tool metadata, categories, agent guidance, and input schema fields.
7695
7721
  */
7696
7722
  async searchTools(options = {}) {
7697
- const params = new URLSearchParams();
7698
- const query = options.query?.trim() ?? "";
7699
- params.set("q", query);
7700
- params.set(
7701
- "include_search_debug",
7702
- options.includeSearchDebug ? "true" : "false"
7703
- );
7704
- params.set("search_mode", options.searchMode ?? "v2");
7705
- if (options.limit !== void 0) {
7706
- params.set("limit", String(options.limit));
7707
- }
7708
- if (options.offset !== void 0) {
7709
- params.set("offset", String(options.offset));
7710
- }
7711
- if (options.categories?.trim()) {
7712
- params.set("categories", options.categories.trim());
7713
- }
7714
- if (options.searchTerms?.trim()) {
7715
- params.set("search_terms", options.searchTerms.trim());
7716
- }
7717
- if (options.task?.trim()) {
7718
- params.set("task", options.task.trim());
7719
- }
7720
7723
  return this.http.get(
7721
- `/api/v2/tools/search?${params.toString()}`
7724
+ `/api/v2/tools/search?${searchParams(options).toString()}`
7722
7725
  );
7723
7726
  }
7727
+ /**
7728
+ * Search everything Deepline can run or deploy in one ranked list: tools,
7729
+ * monitor types, prebuilt plays, and your workspace's own plays.
7730
+ *
7731
+ * @example
7732
+ * ```typescript
7733
+ * const { results } = await client.search({
7734
+ * query: 'find work email',
7735
+ * types: ['tools', 'prebuilts'],
7736
+ * });
7737
+ * ```
7738
+ */
7739
+ async search(options = {}) {
7740
+ const params = searchParams(options);
7741
+ if (options.types?.length) params.set("types", options.types.join(","));
7742
+ if (options.exclude?.length) {
7743
+ params.set("exclude", options.exclude.join(","));
7744
+ }
7745
+ return this.http.get(`/api/v2/search?${params.toString()}`);
7746
+ }
7724
7747
  /**
7725
7748
  * Get detailed metadata for a single tool.
7726
7749
  *
@@ -22599,9 +22622,9 @@ ${JSON.stringify(value, null, 2)}` : `${key}: ${String(value)}`
22599
22622
  }
22600
22623
 
22601
22624
  // src/cli/commands/play.ts
22602
- var import_node_fs17 = require("fs");
22625
+ var import_node_fs18 = require("fs");
22603
22626
  var import_promises12 = require("fs/promises");
22604
- var import_node_path22 = require("path");
22627
+ var import_node_path23 = require("path");
22605
22628
  var import_commander4 = require("commander");
22606
22629
 
22607
22630
  // src/cli/commands/plays/bootstrap.ts
@@ -27658,19 +27681,193 @@ function formatRunHitCountLines(tables) {
27658
27681
  return lines;
27659
27682
  }
27660
27683
 
27684
+ // src/cli/search-ref.ts
27685
+ var import_node_fs13 = require("fs");
27686
+ var import_node_path13 = require("path");
27687
+ var SEARCH_REF_TTL_MS = 15 * 6e4;
27688
+ function lastSearchPath() {
27689
+ return (0, import_node_path13.join)(sdkCliStateDirPath(resolveConfig().baseUrl), "last-search.json");
27690
+ }
27691
+ function rememberSearchRef(searchRef) {
27692
+ try {
27693
+ (0, import_node_fs13.mkdirSync)((0, import_node_path13.dirname)(lastSearchPath()), { recursive: true });
27694
+ (0, import_node_fs13.writeFileSync)(
27695
+ lastSearchPath(),
27696
+ JSON.stringify({ searchRef, at: Date.now() }),
27697
+ { mode: 384 }
27698
+ );
27699
+ } catch {
27700
+ }
27701
+ }
27702
+ function recentSearchRef() {
27703
+ try {
27704
+ const saved = JSON.parse((0, import_node_fs13.readFileSync)(lastSearchPath(), "utf8"));
27705
+ return typeof saved.searchRef === "string" && typeof saved.at === "number" && Date.now() - saved.at < SEARCH_REF_TTL_MS ? saved.searchRef : void 0;
27706
+ } catch {
27707
+ return void 0;
27708
+ }
27709
+ }
27710
+
27711
+ // src/cli/commands/search.ts
27712
+ var SEARCH_TYPES = [
27713
+ "tools",
27714
+ "plays",
27715
+ "monitors",
27716
+ "prebuilts",
27717
+ "custom"
27718
+ ];
27719
+ var USAGE = "Usage: deepline search [query] [--type <types>] [--categories <categories>] [--search_terms <terms>] [--json]";
27720
+ function parseTypes(flag, raw) {
27721
+ const names = (raw ?? "").split(",").map((name) => name.trim().toLowerCase()).filter(Boolean);
27722
+ const unknown = names.filter(
27723
+ (name) => !SEARCH_TYPES.includes(name)
27724
+ );
27725
+ if (unknown.length > 0) {
27726
+ throw new Error(
27727
+ `Unknown ${flag} ${unknown.join(", ")}. Use any of: ${SEARCH_TYPES.join(", ")}.`
27728
+ );
27729
+ }
27730
+ return names;
27731
+ }
27732
+ function optionalInteger(raw) {
27733
+ return raw === void 0 ? void 0 : Number.parseInt(raw, 10);
27734
+ }
27735
+ function appendCsv(value, previous) {
27736
+ return previous ? `${previous},${value}` : value;
27737
+ }
27738
+ function addSearchOptions(command) {
27739
+ return command.option(
27740
+ "--categories <categories>",
27741
+ "Comma-separated tool categories; may be used without a query"
27742
+ ).option(
27743
+ "--search_terms <terms>",
27744
+ "Comma-separated structured search terms; may be used without a query"
27745
+ ).option("--search-terms <terms>", "Alias for --search_terms").option(
27746
+ "--task <sentence>",
27747
+ "What you are trying to accomplish: input you have -> result you need"
27748
+ ).option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--json", "Emit JSON output instead of the readable default");
27749
+ }
27750
+ async function runSearch(queryInput, options, types, exclude = []) {
27751
+ const query = queryInput?.trim() ?? "";
27752
+ const searchTerms = options.searchTerms ?? options.search_terms;
27753
+ if (!query && !options.categories?.trim() && !searchTerms?.trim()) {
27754
+ console.error(USAGE);
27755
+ return 1;
27756
+ }
27757
+ const { search_ref: searchRef, ...result } = await new DeeplineClient().search({
27758
+ query,
27759
+ types,
27760
+ exclude,
27761
+ categories: options.categories,
27762
+ searchTerms,
27763
+ task: options.task,
27764
+ limit: optionalInteger(options.limit),
27765
+ offset: optionalInteger(options.offset),
27766
+ searchMode: options.searchMode === "v1" || options.searchMode === "v2" ? options.searchMode : void 0,
27767
+ includeSearchDebug: Boolean(options.includeSearchDebug)
27768
+ });
27769
+ if (searchRef) rememberSearchRef(searchRef);
27770
+ printCommandEnvelope(result, {
27771
+ json: options.json === true
27772
+ });
27773
+ return 0;
27774
+ }
27775
+ function registerDeprecatedSearchCommand(parent, typesFor) {
27776
+ const name = `deepline ${parent.name()} search`;
27777
+ addSearchOptions(
27778
+ parent.command("search [query]").description(`Deprecated. Use deepline search --type <types>.`).addHelpText(
27779
+ "after",
27780
+ `
27781
+ Notes:
27782
+ Deprecated alias for the unified search. It runs deepline search with the
27783
+ matching --type and returns the same results envelope.
27784
+
27785
+ Examples:
27786
+ deepline search email --type ${typesFor({}).join(",")}
27787
+ `
27788
+ ).option("--all", "Include plays your workspace created").option("--compact", "Accepted for compatibility; results are compact")
27789
+ ).action(async (query, options) => {
27790
+ const types = typesFor(options);
27791
+ console.error(
27792
+ `${name} is deprecated. Use: deepline search${query ? ` ${JSON.stringify(query)}` : ""} --type ${types.join(",")}`
27793
+ );
27794
+ process.exitCode = await runSearch(query, options, types);
27795
+ });
27796
+ }
27797
+ function registerSearchCommand(program) {
27798
+ addSearchOptions(
27799
+ program.command("search [query]").description(
27800
+ "Search tools, monitors, and plays together, ranked by intent."
27801
+ ).addHelpText(
27802
+ "after",
27803
+ `
27804
+ Notes:
27805
+ One ranked search across everything Deepline can run, deploy, or explain.
27806
+ Every result carries a kind: tool, monitor_type, prebuilt_play, custom_play
27807
+ (a play your workspace created), or doc. Narrow with --type, a
27808
+ comma-separated list of:
27809
+ tools atomic provider operations (deepline tools execute)
27810
+ monitors monitor types you can deploy
27811
+ prebuilts Deepline-maintained plays
27812
+ custom plays your workspace created
27813
+ plays prebuilts and custom together
27814
+ --exclude takes the same names and leaves those kinds out instead.
27815
+ Ranking uses a third-party AI relevance model. For plays your workspace
27816
+ created it is sent only the play name and description, never play code.
27817
+ Both flags may be repeated: --type tools --type prebuilts.
27818
+ Provide a query, or omit it only when --categories and/or --search_terms is
27819
+ supplied. Use --limit and --offset to page (limit 1-50, offset zero-based);
27820
+ JSON includes next_offset. Pass --task with one sentence on what you are
27821
+ trying to accomplish: the input you have and the result you need. It
27822
+ materially improves ranking, especially for short queries.
27823
+ Search prints a readable result list by default, piped or not, and that is
27824
+ the recommended form. Pass --json only when a program parses the result.
27825
+
27826
+ Examples:
27827
+ deepline search "find work email"
27828
+ deepline search "find work email" --type tools --limit 10
27829
+ deepline search "company to contacts" --type plays
27830
+ deepline search "enrich a company" --exclude monitors,custom
27831
+ deepline search linkedin --task "I have 200 LinkedIn profile URLs and need each person's current title and company"
27832
+ deepline search --type tools --categories company_search --search_terms "investors,funding"
27833
+ `
27834
+ ).option(
27835
+ "--type <types>",
27836
+ `Kinds to search, comma-separated or repeated: ${SEARCH_TYPES.join(", ")}`,
27837
+ appendCsv
27838
+ ).option(
27839
+ "--exclude <types>",
27840
+ "Kinds to leave out, comma-separated or repeated; the opposite of --type",
27841
+ appendCsv
27842
+ )
27843
+ ).action(async (query, options) => {
27844
+ let types;
27845
+ let exclude;
27846
+ try {
27847
+ types = parseTypes("--type", options.type);
27848
+ exclude = parseTypes("--exclude", options.exclude);
27849
+ } catch (error) {
27850
+ console.error(error instanceof Error ? error.message : String(error));
27851
+ process.exitCode = 1;
27852
+ return;
27853
+ }
27854
+ process.exitCode = await runSearch(query, options, types, exclude);
27855
+ });
27856
+ }
27857
+
27661
27858
  // src/plays/bundle-play-file.ts
27662
27859
  var import_node_os9 = require("os");
27663
- var import_node_path15 = require("path");
27860
+ var import_node_path16 = require("path");
27664
27861
  var import_node_url = require("url");
27665
- var import_node_fs14 = require("fs");
27862
+ var import_node_fs15 = require("fs");
27666
27863
  var import_promises7 = require("fs/promises");
27667
27864
 
27668
27865
  // ../plays/bundling/index.ts
27669
27866
  var import_node_crypto7 = require("crypto");
27670
- var import_node_fs13 = require("fs");
27867
+ var import_node_fs14 = require("fs");
27671
27868
  var import_promises5 = require("fs/promises");
27672
27869
  var import_node_os8 = require("os");
27673
- var import_node_path13 = require("path");
27870
+ var import_node_path14 = require("path");
27674
27871
  var import_node_module = require("module");
27675
27872
  var import_acorn2 = require("acorn");
27676
27873
  var import_esbuild = require("esbuild");
@@ -29535,7 +29732,7 @@ var MAX_PLAY_BUNDLE_BYTES = 30 * 1024 * 1024;
29535
29732
 
29536
29733
  // ../plays/bundling/index.ts
29537
29734
  var PLAY_BUNDLE_CACHE_NAMESPACE = "deepline-play-artifacts-docflow-jsdoc";
29538
- var PLAY_ARTIFACT_CACHE_DIR = (0, import_node_path13.join)((0, import_node_os8.tmpdir)(), PLAY_BUNDLE_CACHE_NAMESPACE);
29735
+ var PLAY_ARTIFACT_CACHE_DIR = (0, import_node_path14.join)((0, import_node_os8.tmpdir)(), PLAY_BUNDLE_CACHE_NAMESPACE);
29539
29736
  var SOURCE_EXTENSIONS = [
29540
29737
  ".ts",
29541
29738
  ".tsx",
@@ -30152,7 +30349,7 @@ function resolveEnabledExecutionProfile(override) {
30152
30349
  // src/plays/local-file-discovery.ts
30153
30350
  var import_node_crypto8 = require("crypto");
30154
30351
  var import_promises6 = require("fs/promises");
30155
- var import_node_path14 = require("path");
30352
+ var import_node_path15 = require("path");
30156
30353
  var SOURCE_EXTENSIONS2 = [
30157
30354
  ".ts",
30158
30355
  ".tsx",
@@ -30172,19 +30369,19 @@ var EXPLICIT_IMPORT_EXTENSIONS2 = /* @__PURE__ */ new Set([
30172
30369
 
30173
30370
  // src/plays/bundle-play-file.ts
30174
30371
  var import_meta = {};
30175
- var MODULE_DIR = (0, import_node_path15.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
30176
- var SDK_PACKAGE_ROOT = (0, import_node_path15.resolve)(MODULE_DIR, "..", "..");
30177
- var SOURCE_REPO_ROOT = (0, import_node_path15.resolve)(SDK_PACKAGE_ROOT, "..", "..");
30178
- var HAS_SOURCE_BUNDLING_SOURCES = (0, import_node_fs14.existsSync)(
30179
- (0, import_node_path15.resolve)(SOURCE_REPO_ROOT, "packages", "plays", "bundling", "index.ts")
30372
+ var MODULE_DIR = (0, import_node_path16.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
30373
+ var SDK_PACKAGE_ROOT = (0, import_node_path16.resolve)(MODULE_DIR, "..", "..");
30374
+ var SOURCE_REPO_ROOT = (0, import_node_path16.resolve)(SDK_PACKAGE_ROOT, "..", "..");
30375
+ var HAS_SOURCE_BUNDLING_SOURCES = (0, import_node_fs15.existsSync)(
30376
+ (0, import_node_path16.resolve)(SOURCE_REPO_ROOT, "packages", "plays", "bundling", "index.ts")
30180
30377
  );
30181
- var PACKAGED_BUNDLING_SOURCE_ROOT = (0, import_node_path15.resolve)(
30378
+ var PACKAGED_BUNDLING_SOURCE_ROOT = (0, import_node_path16.resolve)(
30182
30379
  SDK_PACKAGE_ROOT,
30183
30380
  "dist",
30184
30381
  "bundling-sources"
30185
30382
  );
30186
- var HAS_PACKAGED_BUNDLING_SOURCES = (0, import_node_fs14.existsSync)(
30187
- (0, import_node_path15.resolve)(
30383
+ var HAS_PACKAGED_BUNDLING_SOURCES = (0, import_node_fs15.existsSync)(
30384
+ (0, import_node_path16.resolve)(
30188
30385
  PACKAGED_BUNDLING_SOURCE_ROOT,
30189
30386
  "shared_libs",
30190
30387
  "plays",
@@ -30192,15 +30389,15 @@ var HAS_PACKAGED_BUNDLING_SOURCES = (0, import_node_fs14.existsSync)(
30192
30389
  "index.ts"
30193
30390
  )
30194
30391
  );
30195
- var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_BUNDLING_SOURCE_ROOT : (0, import_node_path15.resolve)(SDK_PACKAGE_ROOT, "..");
30196
- var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? (0, import_node_path15.resolve)(SDK_PACKAGE_ROOT, "src") : HAS_PACKAGED_BUNDLING_SOURCES ? (0, import_node_path15.resolve)(PACKAGED_BUNDLING_SOURCE_ROOT, "sdk", "src") : (0, import_node_path15.resolve)(SDK_PACKAGE_ROOT, "src");
30197
- var SDK_PACKAGE_JSON = (0, import_node_path15.resolve)(SDK_PACKAGE_ROOT, "package.json");
30198
- var SDK_ENTRY_FILE = (0, import_node_path15.resolve)(SDK_SOURCE_ROOT, "index.ts");
30199
- var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : (0, import_node_path15.resolve)(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
30392
+ var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_BUNDLING_SOURCE_ROOT : (0, import_node_path16.resolve)(SDK_PACKAGE_ROOT, "..");
30393
+ var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? (0, import_node_path16.resolve)(SDK_PACKAGE_ROOT, "src") : HAS_PACKAGED_BUNDLING_SOURCES ? (0, import_node_path16.resolve)(PACKAGED_BUNDLING_SOURCE_ROOT, "sdk", "src") : (0, import_node_path16.resolve)(SDK_PACKAGE_ROOT, "src");
30394
+ var SDK_PACKAGE_JSON = (0, import_node_path16.resolve)(SDK_PACKAGE_ROOT, "package.json");
30395
+ var SDK_ENTRY_FILE = (0, import_node_path16.resolve)(SDK_SOURCE_ROOT, "index.ts");
30396
+ var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : (0, import_node_path16.resolve)(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
30200
30397
 
30201
30398
  // src/cli/run-dataset-csv.ts
30202
- var import_node_fs15 = require("fs");
30203
- var import_node_path16 = require("path");
30399
+ var import_node_fs16 = require("fs");
30400
+ var import_node_path17 = require("path");
30204
30401
 
30205
30402
  // ../plays/table-csv.ts
30206
30403
  var TABLE_EXPORT_ERROR_COLUMN = "_error";
@@ -30306,9 +30503,9 @@ var RunDatasetCsv = class _RunDatasetCsv {
30306
30503
  return this.#projection;
30307
30504
  }
30308
30505
  write(outPath) {
30309
- const absolutePath = (0, import_node_path16.resolve)(outPath);
30506
+ const absolutePath = (0, import_node_path17.resolve)(outPath);
30310
30507
  const { rows, columns } = this.#projection;
30311
- (0, import_node_fs15.writeFileSync)(
30508
+ (0, import_node_fs16.writeFileSync)(
30312
30509
  absolutePath,
30313
30510
  tableCsvText(
30314
30511
  columns,
@@ -30947,8 +31144,8 @@ function extractCanonicalRowsInfo(statusOrResult) {
30947
31144
  }
30948
31145
 
30949
31146
  // src/cli/run-dataset-selection.ts
30950
- var import_node_fs16 = require("fs");
30951
- var import_node_path17 = require("path");
31147
+ var import_node_fs17 = require("fs");
31148
+ var import_node_path18 = require("path");
30952
31149
  var Run = class _Run {
30953
31150
  #datasets;
30954
31151
  constructor(input2) {
@@ -31074,8 +31271,8 @@ var RunDataset = class _RunDataset {
31074
31271
  );
31075
31272
  }
31076
31273
  if (options.format === "json") {
31077
- const absolutePath = (0, import_node_path17.resolve)(outPath);
31078
- (0, import_node_fs16.writeFileSync)(
31274
+ const absolutePath = (0, import_node_path18.resolve)(outPath);
31275
+ (0, import_node_fs17.writeFileSync)(
31079
31276
  absolutePath,
31080
31277
  `${JSON.stringify(orderRunExportJson(this.rows), null, 2)}
31081
31278
  `,
@@ -32039,10 +32236,10 @@ function normalizeFixtureScopeValue(value, maxLength) {
32039
32236
  var import_node_crypto9 = require("crypto");
32040
32237
  var import_promises11 = require("fs/promises");
32041
32238
  var import_node_os10 = require("os");
32042
- var import_node_path21 = require("path");
32239
+ var import_node_path22 = require("path");
32043
32240
 
32044
32241
  // ../plays/deploy/run-deployment.ts
32045
- var import_node_path20 = require("path");
32242
+ var import_node_path21 = require("path");
32046
32243
  var import_promises10 = require("fs/promises");
32047
32244
 
32048
32245
  // ../plays/deployment-status.ts
@@ -32215,7 +32412,7 @@ var DeployApiClient = class {
32215
32412
 
32216
32413
  // ../plays/deploy/manifest.ts
32217
32414
  var import_promises8 = require("fs/promises");
32218
- var import_node_path18 = require("path");
32415
+ var import_node_path19 = require("path");
32219
32416
  var import_picomatch = __toESM(require_picomatch2(), 1);
32220
32417
  var DEFAULT_PLAY_GLOBS = ["**/*.play.ts"];
32221
32418
  var DEFAULT_MONITOR_GLOBS = ["**/*.monitor.json"];
@@ -32279,7 +32476,7 @@ var DEFAULT_MANIFEST_FILE = "deepline.json";
32279
32476
  async function readDeeplineManifest(projectRoot, manifestFile = DEFAULT_MANIFEST_FILE) {
32280
32477
  let raw = null;
32281
32478
  try {
32282
- raw = await (0, import_promises8.readFile)((0, import_node_path18.join)(projectRoot, manifestFile), "utf8");
32479
+ raw = await (0, import_promises8.readFile)((0, import_node_path19.join)(projectRoot, manifestFile), "utf8");
32283
32480
  } catch (error) {
32284
32481
  const code = error.code;
32285
32482
  if (code !== "ENOENT" && code !== "ENOTDIR") {
@@ -32310,14 +32507,14 @@ async function discoverDeploymentFiles(input2) {
32310
32507
  const entries = await (0, import_promises8.readdir)(dir, { withFileTypes: true });
32311
32508
  for (const entry of entries) {
32312
32509
  if (entry.name.startsWith(".") && entry.name !== ".") continue;
32313
- const absolute = (0, import_node_path18.join)(dir, entry.name);
32510
+ const absolute = (0, import_node_path19.join)(dir, entry.name);
32314
32511
  if (entry.isDirectory()) {
32315
32512
  if (IGNORED_DIRECTORIES.has(entry.name)) continue;
32316
32513
  await walk(absolute);
32317
32514
  continue;
32318
32515
  }
32319
32516
  if (!entry.isFile()) continue;
32320
- const relativePath = (0, import_node_path18.relative)(input2.projectRoot, absolute);
32517
+ const relativePath = (0, import_node_path19.relative)(input2.projectRoot, absolute);
32321
32518
  if (matchers.some((match) => match(relativePath))) {
32322
32519
  found.push(relativePath);
32323
32520
  if (found.length > MAX_DISCOVERED_FILES) {
@@ -32341,7 +32538,7 @@ var discoverPlayFiles = discoverDeploymentFiles;
32341
32538
 
32342
32539
  // ../plays/deploy/monitor-files.ts
32343
32540
  var import_promises9 = require("fs/promises");
32344
- var import_node_path19 = require("path");
32541
+ var import_node_path20 = require("path");
32345
32542
  async function readMonitorFiles(input2) {
32346
32543
  const files = await discoverDeploymentFiles(input2);
32347
32544
  if (files.length > 100) {
@@ -32352,7 +32549,7 @@ async function readMonitorFiles(input2) {
32352
32549
  return Promise.all(
32353
32550
  files.map(async (file) => {
32354
32551
  const sourcePath = input2.rootDirectory ? `${input2.rootDirectory}/${file}` : file;
32355
- const raw = await (0, import_promises9.readFile)((0, import_node_path19.join)(input2.projectRoot, file), "utf8");
32552
+ const raw = await (0, import_promises9.readFile)((0, import_node_path20.join)(input2.projectRoot, file), "utf8");
32356
32553
  try {
32357
32554
  return { file: sourcePath, definition: JSON.parse(raw) };
32358
32555
  } catch {
@@ -32645,7 +32842,7 @@ async function runDeployment(params, hooks) {
32645
32842
  };
32646
32843
  };
32647
32844
  await (0, import_promises10.mkdir)(hooks.workRoot, { recursive: true });
32648
- const workDir = await (0, import_promises10.mkdtemp)((0, import_node_path20.join)(hooks.workRoot, "deploy-"));
32845
+ const workDir = await (0, import_promises10.mkdtemp)((0, import_node_path21.join)(hooks.workRoot, "deploy-"));
32649
32846
  const postCheck = async (postCheckOnce, input2) => {
32650
32847
  let lastError;
32651
32848
  for (let attempt = 0; ; attempt += 1) {
@@ -32771,7 +32968,7 @@ async function runDeployment(params, hooks) {
32771
32968
  if (superseded) return superseded;
32772
32969
  }
32773
32970
  const { repoRoot } = await source.open(workDir);
32774
- const projectRoot = target.rootDirectory ? (0, import_node_path20.join)(repoRoot, target.rootDirectory) : repoRoot;
32971
+ const projectRoot = target.rootDirectory ? (0, import_node_path21.join)(repoRoot, target.rootDirectory) : repoRoot;
32775
32972
  const manifestFile = target.manifestPath || DEFAULT_MANIFEST_FILE;
32776
32973
  let manifest;
32777
32974
  let playFiles;
@@ -32865,7 +33062,7 @@ async function runDeployment(params, hooks) {
32865
33062
  annotations.push(annotationForFailure({ file, message }));
32866
33063
  };
32867
33064
  for (const file of playFiles) {
32868
- const entryFile = (0, import_node_path20.join)(projectRoot, file);
33065
+ const entryFile = (0, import_node_path21.join)(projectRoot, file);
32869
33066
  const result = await hooks.bundle(entryFile, {
32870
33067
  sourceIdentityRoot: projectRoot
32871
33068
  });
@@ -33353,8 +33550,8 @@ function printResult2(input2) {
33353
33550
  );
33354
33551
  }
33355
33552
  async function handlePlaysDeploy(directory, options) {
33356
- const root = await (0, import_promises11.realpath)((0, import_node_path21.resolve)(directory ?? ".")).catch(() => {
33357
- throw new Error(`No such directory: ${(0, import_node_path21.resolve)(directory ?? ".")}`);
33553
+ const root = await (0, import_promises11.realpath)((0, import_node_path22.resolve)(directory ?? ".")).catch(() => {
33554
+ throw new Error(`No such directory: ${(0, import_node_path22.resolve)(directory ?? ".")}`);
33358
33555
  });
33359
33556
  const { http, config } = getAuthedHttpClient();
33360
33557
  const deliveryId = `local:${(0, import_node_crypto9.randomUUID)()}`;
@@ -33365,7 +33562,7 @@ async function handlePlaysDeploy(directory, options) {
33365
33562
  ...options.commit ? { commit: options.commit } : {}
33366
33563
  });
33367
33564
  const { bundleDeployPlayFile } = await loadPlayBundler();
33368
- const workRoot = await (0, import_promises11.mkdtemp)((0, import_node_path21.join)((0, import_node_os10.tmpdir)(), "deepline-deploy-"));
33565
+ const workRoot = await (0, import_promises11.mkdtemp)((0, import_node_path22.join)((0, import_node_os10.tmpdir)(), "deepline-deploy-"));
33369
33566
  const consoleInfo = console.info;
33370
33567
  console.info = console.error;
33371
33568
  try {
@@ -34001,9 +34198,9 @@ async function pathExistsIncludingSymlink(path) {
34001
34198
  }
34002
34199
  }
34003
34200
  function runIdFileTempPath(destination) {
34004
- return (0, import_node_path22.join)(
34005
- (0, import_node_path22.dirname)(destination),
34006
- `.${(0, import_node_path22.basename)(destination)}.${process.pid}.${(0, import_node_crypto10.randomUUID)()}.tmp`
34201
+ return (0, import_node_path23.join)(
34202
+ (0, import_node_path23.dirname)(destination),
34203
+ `.${(0, import_node_path23.basename)(destination)}.${process.pid}.${(0, import_node_crypto10.randomUUID)()}.tmp`
34007
34204
  );
34008
34205
  }
34009
34206
  async function removeRunIdTempFile(path) {
@@ -34016,7 +34213,7 @@ async function removeRunIdTempFile(path) {
34016
34213
  }
34017
34214
  }
34018
34215
  async function preflightRunIdFile(path) {
34019
- const destination = (0, import_node_path22.resolve)(path);
34216
+ const destination = (0, import_node_path23.resolve)(path);
34020
34217
  if (await pathExistsIncludingSymlink(destination)) {
34021
34218
  throw new Error(
34022
34219
  `--run-id-file destination already exists: ${destination}. Choose a new path so this run cannot overwrite another run identity.`
@@ -34096,7 +34293,7 @@ async function writePlayRunIdFile(destination, runId, options = {}) {
34096
34293
  }
34097
34294
  }
34098
34295
  if (process.platform !== "win32") {
34099
- const directory = await (0, import_promises12.open)((0, import_node_path22.dirname)(destination), "r");
34296
+ const directory = await (0, import_promises12.open)((0, import_node_path23.dirname)(destination), "r");
34100
34297
  try {
34101
34298
  await directory.sync();
34102
34299
  } finally {
@@ -34293,7 +34490,7 @@ function buildPlayReferenceNotFoundMessage(input2) {
34293
34490
  lines.push(
34294
34491
  "",
34295
34492
  "Search visible plays:",
34296
- ` deepline plays search ${shellQuote4(searchQuery)} --all --json`
34493
+ ` deepline search --type plays ${shellQuote4(searchQuery)} --json`
34297
34494
  );
34298
34495
  }
34299
34496
  return lines.join("\n");
@@ -34385,7 +34582,7 @@ function formatPlayListReference(play) {
34385
34582
  return play.reference || play.name;
34386
34583
  }
34387
34584
  function defaultMaterializedPlayPath(reference) {
34388
- return (0, import_node_path22.resolve)(defaultStarterPlayPath(reference));
34585
+ return (0, import_node_path23.resolve)(defaultStarterPlayPath(reference));
34389
34586
  }
34390
34587
  function defaultStarterPlayPath(reference) {
34391
34588
  const playName = parseReferencedPlayTarget2(reference).unqualifiedPlayName;
@@ -34418,23 +34615,23 @@ function materializeRemotePlaySource(input2) {
34418
34615
  `Play ${input2.playName} has ${files.length} source files. Use --out <directory> to write the complete bundle.`
34419
34616
  );
34420
34617
  }
34421
- const outputDirectory = (0, import_node_path22.resolve)(input2.outPath);
34618
+ const outputDirectory = (0, import_node_path23.resolve)(input2.outPath);
34422
34619
  let created = 0;
34423
34620
  let updated = 0;
34424
34621
  for (const [logicalPath, sourceCode] of files) {
34425
- const outputPath2 = (0, import_node_path22.resolve)(outputDirectory, logicalPath);
34426
- const outputRelativePath = (0, import_node_path22.relative)(outputDirectory, outputPath2);
34427
- if (!outputRelativePath || outputRelativePath.startsWith("..") || (0, import_node_path22.isAbsolute)(outputRelativePath)) {
34622
+ const outputPath2 = (0, import_node_path23.resolve)(outputDirectory, logicalPath);
34623
+ const outputRelativePath = (0, import_node_path23.relative)(outputDirectory, outputPath2);
34624
+ if (!outputRelativePath || outputRelativePath.startsWith("..") || (0, import_node_path23.isAbsolute)(outputRelativePath)) {
34428
34625
  throw new Error(
34429
34626
  `Refusing to materialize unsafe Play source path ${JSON.stringify(logicalPath)}.`
34430
34627
  );
34431
34628
  }
34432
- (0, import_node_fs17.mkdirSync)((0, import_node_path22.dirname)(outputPath2), { recursive: true });
34433
- if (!(0, import_node_fs17.existsSync)(outputPath2)) {
34434
- (0, import_node_fs17.writeFileSync)(outputPath2, sourceCode, "utf-8");
34629
+ (0, import_node_fs18.mkdirSync)((0, import_node_path23.dirname)(outputPath2), { recursive: true });
34630
+ if (!(0, import_node_fs18.existsSync)(outputPath2)) {
34631
+ (0, import_node_fs18.writeFileSync)(outputPath2, sourceCode, "utf-8");
34435
34632
  created += 1;
34436
- } else if ((0, import_node_fs17.readFileSync)(outputPath2, "utf-8") !== sourceCode) {
34437
- (0, import_node_fs17.writeFileSync)(outputPath2, sourceCode, "utf-8");
34633
+ } else if ((0, import_node_fs18.readFileSync)(outputPath2, "utf-8") !== sourceCode) {
34634
+ (0, import_node_fs18.writeFileSync)(outputPath2, sourceCode, "utf-8");
34438
34635
  updated += 1;
34439
34636
  }
34440
34637
  }
@@ -34446,15 +34643,15 @@ function materializeRemotePlaySource(input2) {
34446
34643
  };
34447
34644
  }
34448
34645
  const outputPath = input2.outPath ?? defaultMaterializedPlayPath(input2.playName);
34449
- if ((0, import_node_fs17.existsSync)(outputPath)) {
34450
- const existingSource = (0, import_node_fs17.readFileSync)(outputPath, "utf-8");
34646
+ if ((0, import_node_fs18.existsSync)(outputPath)) {
34647
+ const existingSource = (0, import_node_fs18.readFileSync)(outputPath, "utf-8");
34451
34648
  if (existingSource === entrySource) {
34452
34649
  return { path: outputPath, status: "unchanged", created: false };
34453
34650
  }
34454
- (0, import_node_fs17.writeFileSync)(outputPath, entrySource, "utf-8");
34651
+ (0, import_node_fs18.writeFileSync)(outputPath, entrySource, "utf-8");
34455
34652
  return { path: outputPath, status: "updated", created: false };
34456
34653
  }
34457
- (0, import_node_fs17.writeFileSync)(outputPath, entrySource, "utf-8");
34654
+ (0, import_node_fs18.writeFileSync)(outputPath, entrySource, "utf-8");
34458
34655
  return { path: outputPath, status: "created", created: true };
34459
34656
  }
34460
34657
  function formatLoadedPlayMessage(materializedFile) {
@@ -34499,7 +34696,7 @@ function extractPlayName(code, filePath) {
34499
34696
  throw buildMissingDefinePlayError(filePath);
34500
34697
  }
34501
34698
  function isFileTarget(target) {
34502
- return (0, import_node_fs17.existsSync)((0, import_node_path22.resolve)(target));
34699
+ return (0, import_node_fs18.existsSync)((0, import_node_path23.resolve)(target));
34503
34700
  }
34504
34701
  function looksLikeRunId(target) {
34505
34702
  return /^play\/[^/]+\/run\/[^/]+/.test(target.trim());
@@ -34528,7 +34725,7 @@ function parsePositiveInteger3(value, flagName) {
34528
34725
  return parsed;
34529
34726
  }
34530
34727
  function parseJsonInput(raw, flag = "--input") {
34531
- const source = raw.startsWith("@") ? (0, import_node_fs17.readFileSync)((0, import_node_path22.resolve)(raw.slice(1)), "utf-8") : raw;
34728
+ const source = raw.startsWith("@") ? (0, import_node_fs18.readFileSync)((0, import_node_path23.resolve)(raw.slice(1)), "utf-8") : raw;
34532
34729
  let parsed;
34533
34730
  try {
34534
34731
  parsed = JSON.parse(source);
@@ -34579,7 +34776,7 @@ function parseInputFlagValue(raw) {
34579
34776
  function isLocalFilePathValue(value) {
34580
34777
  if (typeof value !== "string" || !value.trim()) return false;
34581
34778
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
34582
- return (0, import_node_fs17.existsSync)((0, import_node_path22.resolve)(value));
34779
+ return (0, import_node_fs18.existsSync)((0, import_node_path23.resolve)(value));
34583
34780
  }
34584
34781
  function inputContainsLocalFilePath(value) {
34585
34782
  if (isLocalFilePathValue(value)) {
@@ -34625,7 +34822,7 @@ function collectLocalFileInputRefs(value, inputPath, key, out) {
34625
34822
  const looksLikeFile = /\.[a-z0-9]{1,8}$/i.test(trimmed);
34626
34823
  if (keyIsCsvData) {
34627
34824
  out.push({ inputPath, value: trimmed, isCsvData: true });
34628
- } else if (endsWithCsv || looksLikeFile && (0, import_node_fs17.existsSync)((0, import_node_path22.resolve)(trimmed))) {
34825
+ } else if (endsWithCsv || looksLikeFile && (0, import_node_fs18.existsSync)((0, import_node_path23.resolve)(trimmed))) {
34629
34826
  out.push({ inputPath, value: trimmed, isCsvData: false });
34630
34827
  }
34631
34828
  return;
@@ -34667,8 +34864,8 @@ function preflightLocalFileInputs(runtimeInput) {
34667
34864
  collectLocalFileInputRefs(value, key, key, refs);
34668
34865
  }
34669
34866
  for (const ref of refs) {
34670
- const absolutePath = (0, import_node_path22.resolve)(ref.value);
34671
- if (!(0, import_node_fs17.existsSync)(absolutePath)) {
34867
+ const absolutePath = (0, import_node_path23.resolve)(ref.value);
34868
+ if (!(0, import_node_fs18.existsSync)(absolutePath)) {
34672
34869
  throw new DeeplineError(
34673
34870
  `Input ${ref.inputPath} references a local file that does not exist: ${ref.value} (resolved to ${absolutePath}). No run was created.`,
34674
34871
  void 0,
@@ -34678,7 +34875,7 @@ function preflightLocalFileInputs(runtimeInput) {
34678
34875
  }
34679
34876
  let stat4;
34680
34877
  try {
34681
- stat4 = (0, import_node_fs17.statSync)(absolutePath);
34878
+ stat4 = (0, import_node_fs18.statSync)(absolutePath);
34682
34879
  } catch (error) {
34683
34880
  throw new DeeplineError(
34684
34881
  `Input ${ref.inputPath} references a local file that is not readable: ${ref.value} (${error instanceof Error ? error.message : String(error)}). No run was created.`,
@@ -34704,7 +34901,7 @@ function preflightLocalFileInputs(runtimeInput) {
34704
34901
  function preflightCsvDataInput(ref, absolutePath) {
34705
34902
  let content;
34706
34903
  try {
34707
- content = (0, import_node_fs17.readFileSync)(absolutePath, "utf-8");
34904
+ content = (0, import_node_fs18.readFileSync)(absolutePath, "utf-8");
34708
34905
  } catch (error) {
34709
34906
  throw new DeeplineError(
34710
34907
  `Input ${ref.inputPath} CSV ${ref.value} is not readable: ${error instanceof Error ? error.message : String(error)}. No run was created.`,
@@ -34732,10 +34929,10 @@ async function stageFileInputArgs(input2) {
34732
34929
  codec: NODE_STAGED_FILE_CODEC,
34733
34930
  resolveLocalFile: (value) => {
34734
34931
  if (!isLocalFilePathValue(value)) return null;
34735
- const absolutePath = (0, import_node_path22.resolve)(value);
34932
+ const absolutePath = (0, import_node_path23.resolve)(value);
34736
34933
  return {
34737
- logicalPath: (0, import_node_path22.basename)(absolutePath),
34738
- read: async () => (0, import_node_fs17.readFileSync)(absolutePath)
34934
+ logicalPath: (0, import_node_path23.basename)(absolutePath),
34935
+ read: async () => (0, import_node_fs18.readFileSync)(absolutePath)
34739
34936
  };
34740
34937
  },
34741
34938
  onStaging: (fileCount) => input2.progress.phase(
@@ -34744,7 +34941,7 @@ async function stageFileInputArgs(input2) {
34744
34941
  });
34745
34942
  }
34746
34943
  function stageFile(logicalPath, absolutePath) {
34747
- const buffer = (0, import_node_fs17.readFileSync)(absolutePath);
34944
+ const buffer = (0, import_node_fs18.readFileSync)(absolutePath);
34748
34945
  return {
34749
34946
  logicalPath,
34750
34947
  contentBase64: buffer.toString("base64"),
@@ -34755,9 +34952,9 @@ function stageFile(logicalPath, absolutePath) {
34755
34952
  }
34756
34953
  function normalizePlayPath(filePath) {
34757
34954
  try {
34758
- return import_node_fs17.realpathSync.native((0, import_node_path22.resolve)(filePath));
34955
+ return import_node_fs18.realpathSync.native((0, import_node_path23.resolve)(filePath));
34759
34956
  } catch {
34760
- return (0, import_node_path22.resolve)(filePath);
34957
+ return (0, import_node_path23.resolve)(filePath);
34761
34958
  }
34762
34959
  }
34763
34960
  function formatBundlingErrors(filePath, errors) {
@@ -37803,7 +38000,7 @@ function shellSingleQuote(value) {
37803
38000
  return `'${value.replace(/'/g, `'\\''`)}'`;
37804
38001
  }
37805
38002
  function runExportRetryCommand(runId, outPath, datasetPath, options = {}) {
37806
- return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0, import_node_path22.resolve)(outPath))}${options.format === "json" ? " --format json" : ""}`;
38003
+ return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0, import_node_path23.resolve)(outPath))}${options.format === "json" ? " --format json" : ""}`;
37807
38004
  }
37808
38005
  function extractRunPlayName(status) {
37809
38006
  const run = status.run;
@@ -39213,7 +39410,7 @@ async function handlePlayCheck(args) {
39213
39410
  });
39214
39411
  return 0;
39215
39412
  } catch (error) {
39216
- const resolved = (0, import_node_path22.resolve)(options.target);
39413
+ const resolved = (0, import_node_path23.resolve)(options.target);
39217
39414
  const message = error instanceof Error && error.message ? error.message : `File not found: ${resolved}`;
39218
39415
  if (options.jsonOutput) {
39219
39416
  printCommandEnvelope(
@@ -39234,8 +39431,8 @@ async function handlePlayCheck(args) {
39234
39431
  return 1;
39235
39432
  }
39236
39433
  }
39237
- const absolutePlayPath = (0, import_node_path22.resolve)(options.target);
39238
- const sourceCode = (0, import_node_fs17.readFileSync)(absolutePlayPath, "utf-8");
39434
+ const absolutePlayPath = (0, import_node_path23.resolve)(options.target);
39435
+ const sourceCode = (0, import_node_fs18.readFileSync)(absolutePlayPath, "utf-8");
39239
39436
  const exportNames = resolvePlayCheckExportNames(sourceCode);
39240
39437
  const outcomes = [];
39241
39438
  for (const exportName of exportNames) {
@@ -39359,12 +39556,12 @@ async function handleFileBackedRun(options, hooks) {
39359
39556
  }
39360
39557
  const client2 = new DeeplineClient(playRunClientOptions(options));
39361
39558
  const progress = getActiveCliProgress() ?? createCliProgress(!options.jsonOutput);
39362
- const absolutePlayPath = (0, import_node_path22.resolve)(options.target.path);
39559
+ const absolutePlayPath = (0, import_node_path23.resolve)(options.target.path);
39363
39560
  progress.phase("compiling play");
39364
39561
  const sourceCode = traceCliSync(
39365
39562
  "cli.play_file_read_source",
39366
39563
  { targetKind: "file" },
39367
- () => (0, import_node_fs17.readFileSync)(absolutePlayPath, "utf-8")
39564
+ () => (0, import_node_fs18.readFileSync)(absolutePlayPath, "utf-8")
39368
39565
  );
39369
39566
  const runtimeInput = options.input ? { ...options.input } : {};
39370
39567
  try {
@@ -39781,19 +39978,19 @@ async function handlePlayRun(args, hooks) {
39781
39978
  if (isFileTarget(options.target.path)) {
39782
39979
  return handleFileBackedRun(options, runHooks);
39783
39980
  }
39784
- const resolved = (0, import_node_path22.resolve)(options.target.path);
39981
+ const resolved = (0, import_node_path23.resolve)(options.target.path);
39785
39982
  console.error(`File not found: ${resolved}`);
39786
- const dir = (0, import_node_path22.dirname)(resolved);
39787
- if ((0, import_node_fs17.existsSync)(dir)) {
39788
- const base = (0, import_node_path22.basename)(resolved);
39983
+ const dir = (0, import_node_path23.dirname)(resolved);
39984
+ if ((0, import_node_fs18.existsSync)(dir)) {
39985
+ const base = (0, import_node_path23.basename)(resolved);
39789
39986
  try {
39790
- const siblings = (0, import_node_fs17.readdirSync)(dir).filter(
39987
+ const siblings = (0, import_node_fs18.readdirSync)(dir).filter(
39791
39988
  (f) => f.includes(base.replace(/\.(play\.)?ts$/, "")) || f.endsWith(".play.ts")
39792
39989
  );
39793
39990
  if (siblings.length > 0) {
39794
39991
  console.error(`Did you mean one of these?`);
39795
39992
  for (const s of siblings.slice(0, 5)) {
39796
- console.error(` ${(0, import_node_path22.join)(dir, s)}`);
39993
+ console.error(` ${(0, import_node_path23.join)(dir, s)}`);
39797
39994
  }
39798
39995
  }
39799
39996
  } catch {
@@ -40563,7 +40760,7 @@ async function handleRunLogs(args) {
40563
40760
  continue;
40564
40761
  }
40565
40762
  if (arg === "--out" && args[index + 1]) {
40566
- outPath = (0, import_node_path22.resolve)(args[++index]);
40763
+ outPath = (0, import_node_path23.resolve)(args[++index]);
40567
40764
  continue;
40568
40765
  }
40569
40766
  if (arg === "--cursor" && args[index + 1]) {
@@ -40598,7 +40795,7 @@ async function handleRunLogs(args) {
40598
40795
  if (outPath) {
40599
40796
  const result2 = await client2.runs.logs(runId, { all: true });
40600
40797
  const logs = result2.entries.filter((line) => logLevelReaches(classifyLogLine(line).level, logLevel)).map((line) => classifyLogLine(line).line);
40601
- (0, import_node_fs17.writeFileSync)(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
40798
+ (0, import_node_fs18.writeFileSync)(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
40602
40799
  printCommandEnvelope(
40603
40800
  {
40604
40801
  runId: result2.runId,
@@ -41084,7 +41281,7 @@ async function handleRunExport(args) {
41084
41281
  for (let index = 0; index < args.length; index += 1) {
41085
41282
  const arg = args[index];
41086
41283
  if (arg === "--out" && args[index + 1]) {
41087
- outPath = (0, import_node_path22.resolve)(args[++index]);
41284
+ outPath = (0, import_node_path23.resolve)(args[++index]);
41088
41285
  continue;
41089
41286
  }
41090
41287
  if (arg === "--dataset" && args[index + 1]) {
@@ -41092,7 +41289,7 @@ async function handleRunExport(args) {
41092
41289
  continue;
41093
41290
  }
41094
41291
  if (arg === "--metadata-out" && args[index + 1]) {
41095
- metadataOutPath = (0, import_node_path22.resolve)(args[++index]);
41292
+ metadataOutPath = (0, import_node_path23.resolve)(args[++index]);
41096
41293
  }
41097
41294
  if (arg === "--format") format = args[++index] ?? "";
41098
41295
  if (arg === "--timeout-ms") {
@@ -41225,7 +41422,7 @@ async function handleRunExport(args) {
41225
41422
  payload.actions
41226
41423
  );
41227
41424
  if (metadataOutPath) {
41228
- (0, import_node_fs17.writeFileSync)(
41425
+ (0, import_node_fs18.writeFileSync)(
41229
41426
  metadataOutPath,
41230
41427
  `${JSON.stringify(payload, null, 2)}
41231
41428
  `,
@@ -41276,7 +41473,7 @@ async function handlePlayGet(args) {
41276
41473
  for (let index = 1; index < args.length; index += 1) {
41277
41474
  const arg = args[index];
41278
41475
  if (arg === "--out" && args[index + 1]) {
41279
- outPath = (0, import_node_path22.resolve)(args[++index]);
41476
+ outPath = (0, import_node_path23.resolve)(args[++index]);
41280
41477
  }
41281
41478
  if (arg === "--revision") {
41282
41479
  const rawVersion = args[++index];
@@ -41297,7 +41494,7 @@ async function handlePlayGet(args) {
41297
41494
  );
41298
41495
  return 2;
41299
41496
  }
41300
- const playName = isFileTarget(target) ? extractPlayName((0, import_node_fs17.readFileSync)((0, import_node_path22.resolve)(target), "utf-8"), (0, import_node_path22.resolve)(target)) : parseReferencedPlayTarget2(target).playName;
41497
+ const playName = isFileTarget(target) ? extractPlayName((0, import_node_fs18.readFileSync)((0, import_node_path23.resolve)(target), "utf-8"), (0, import_node_path23.resolve)(target)) : parseReferencedPlayTarget2(target).playName;
41301
41498
  const includeSource = sourceOutput || outPath !== null;
41302
41499
  const detail = isFileTarget(target) ? await client2.getPlay(
41303
41500
  playName,
@@ -41588,23 +41785,6 @@ async function handlePlayPin(args, pinned) {
41588
41785
  else console.log(`${result.pinned ? "Pinned" : "Unpinned"} ${result.name}.`);
41589
41786
  return 0;
41590
41787
  }
41591
- function parsePlaySearchOptions(args) {
41592
- const query = args[0]?.trim();
41593
- if (!query) {
41594
- throw new Error(
41595
- "Usage: deepline plays search <query> [--all] [--compact] [--json]"
41596
- );
41597
- }
41598
- return {
41599
- query,
41600
- jsonOutput: argsWantJson(args),
41601
- compact: args.includes("--compact"),
41602
- scope: args.includes("--all") && !args.includes("--prebuilt") ? "all" : "prebuilt"
41603
- };
41604
- }
41605
- function playSearchDisclaimer(scope) {
41606
- return scope === "all" ? "Prebuilt-first search: Deepline-managed prebuilts are trusted, robust plays with maintained contracts, so they are listed before plays you created. Use created-play results only when you are specifically looking for one." : "Prebuilt-first search: Deepline-managed prebuilts are trusted, robust plays with maintained contracts. Plays you created are omitted by default; add --all only when you are specifically looking for one.";
41607
- }
41608
41788
  function csvColumnLines(csvInput) {
41609
41789
  const rowSchema = isRecord7(csvInput.rowInputSchema) ? csvInput.rowInputSchema : {};
41610
41790
  const columns = isRecord7(rowSchema.properties) ? Object.keys(rowSchema.properties) : [];
@@ -41703,45 +41883,6 @@ function printPlayDescription(play) {
41703
41883
  console.log(` Check starter: ${cloneEditStarter.checkCommand}`);
41704
41884
  }
41705
41885
  }
41706
- function inputFieldNames(schema) {
41707
- const fields2 = Array.isArray(schema?.fields) ? schema.fields : [];
41708
- return fields2.map(
41709
- (field) => field && typeof field === "object" ? String(field.name ?? "").trim() : ""
41710
- ).filter(Boolean);
41711
- }
41712
- function printCompactPlaySearchResult(play) {
41713
- const reference = formatPlayListReference(play);
41714
- const aliases = play.aliases.slice(0, 6).join(", ");
41715
- console.log(`Play: ${reference}`);
41716
- if (play.displayName && play.displayName !== play.name) {
41717
- console.log(` Display name: ${play.displayName}`);
41718
- }
41719
- if (play.description) {
41720
- console.log(` Description: ${play.description}`);
41721
- }
41722
- if (aliases) {
41723
- console.log(` Aliases: ${aliases}`);
41724
- }
41725
- const fields2 = inputFieldNames(play.inputSchema);
41726
- if (fields2.length > 0) {
41727
- console.log(` Inputs: ${fields2.join(", ")}`);
41728
- } else if (play.inputSchema) {
41729
- console.log(" Inputs: see describe");
41730
- }
41731
- console.log(` Describe: deepline plays describe ${reference} --json`);
41732
- console.log(` Run: ${play.runCommand}`);
41733
- }
41734
- function compactPlaySchema(schema) {
41735
- if (!schema) return null;
41736
- const fields2 = Array.isArray(schema.fields) ? schema.fields.map(
41737
- (field) => field && typeof field === "object" ? {
41738
- name: String(field.name ?? ""),
41739
- type: field.type ?? void 0,
41740
- required: field.required ?? void 0
41741
- } : null
41742
- ).filter((field) => Boolean(field?.name)) : [];
41743
- return fields2.length > 0 ? { fields: fields2 } : schema;
41744
- }
41745
41886
  function summarizePlayGrepResult(play) {
41746
41887
  const reference = formatPlayListReference(play);
41747
41888
  return {
@@ -41754,61 +41895,6 @@ function summarizePlayGrepResult(play) {
41754
41895
  function formatPlayGrepMatches(matches) {
41755
41896
  return matches.map((match) => `${match.field}: ${match.terms.join(", ")}`).join("; ");
41756
41897
  }
41757
- async function handlePlaySearch(args) {
41758
- let options;
41759
- try {
41760
- options = parsePlaySearchOptions(args);
41761
- } catch (error) {
41762
- console.error(error instanceof Error ? error.message : String(error));
41763
- return 1;
41764
- }
41765
- const client2 = new DeeplineClient();
41766
- const plays = await client2.searchPlays({
41767
- query: options.query,
41768
- compact: options.compact,
41769
- scope: options.scope
41770
- });
41771
- const disclaimer = playSearchDisclaimer(options.scope);
41772
- if (options.jsonOutput) {
41773
- const jsonPlays = options.scope === "prebuilt" ? plays.map((play) => ({
41774
- ...play,
41775
- inputSchema: compactPlaySchema(play.inputSchema)
41776
- })) : plays;
41777
- printCompactJson({
41778
- disclaimer,
41779
- search_policy: {
41780
- default_scope: "prebuilt",
41781
- included_origins: options.scope === "all" ? ["prebuilt", "owned"] : ["prebuilt"],
41782
- owned_plays_omitted: options.scope === "prebuilt",
41783
- include_owned_flag: "--all"
41784
- },
41785
- plays: jsonPlays,
41786
- total: jsonPlays.length,
41787
- truncated: false
41788
- });
41789
- return 0;
41790
- }
41791
- const displayPlays = options.scope === "prebuilt" ? plays.slice(0, 5) : plays;
41792
- process.stdout.write(`${disclaimer}
41793
- `);
41794
- process.stdout.write(
41795
- `${plays.length} plays found${options.scope === "prebuilt" && plays.length > displayPlays.length ? `; showing top ${displayPlays.length}` : ""}:
41796
-
41797
- `
41798
- );
41799
- for (const play of displayPlays) {
41800
- if (options.scope === "prebuilt") {
41801
- printCompactPlaySearchResult(play);
41802
- } else {
41803
- printPlayDescription(play);
41804
- }
41805
- console.log("");
41806
- }
41807
- if (options.scope === "prebuilt" && plays.length > displayPlays.length) {
41808
- console.log("Use --json for the full machine-readable result set.");
41809
- }
41810
- return 0;
41811
- }
41812
41898
  async function handlePlayGrep(args) {
41813
41899
  const query = args[0]?.trim();
41814
41900
  if (!query) {
@@ -41866,7 +41952,7 @@ async function handlePlayDescribe(args) {
41866
41952
  const definedName = isFileTarget(playName) ? (() => {
41867
41953
  try {
41868
41954
  return extractPlayName(
41869
- (0, import_node_fs17.readFileSync)((0, import_node_path22.resolve)(playName), "utf-8"),
41955
+ (0, import_node_fs18.readFileSync)((0, import_node_path23.resolve)(playName), "utf-8"),
41870
41956
  playName
41871
41957
  );
41872
41958
  } catch {
@@ -41929,7 +42015,7 @@ async function handlePlaySave(args) {
41929
42015
  graph = await traceCliSpan(
41930
42016
  "cli.play_save_bundle_graph",
41931
42017
  { targetKind: "file" },
41932
- () => collectBundledPlayGraph((0, import_node_path22.resolve)(options.target))
42018
+ () => collectBundledPlayGraph((0, import_node_path23.resolve)(options.target))
41933
42019
  );
41934
42020
  assertBundledPlayGraphDescriptions(graph);
41935
42021
  } catch (error) {
@@ -42054,7 +42140,7 @@ async function handlePlayPublish(args) {
42054
42140
  graph = await traceCliSpan(
42055
42141
  "cli.play_publish_bundle_graph",
42056
42142
  { targetKind: "file" },
42057
- () => collectBundledPlayGraph((0, import_node_path22.resolve)(playName))
42143
+ () => collectBundledPlayGraph((0, import_node_path23.resolve)(playName))
42058
42144
  );
42059
42145
  assertBundledPlayGraphDescriptions(graph);
42060
42146
  } catch (error) {
@@ -42411,7 +42497,7 @@ Authoring:
42411
42497
  Play work unless the caller explicitly asks to leave the inferred graph.
42412
42498
 
42413
42499
  Common commands:
42414
- deepline plays search email --json
42500
+ deepline search --type prebuilts email --json
42415
42501
  deepline plays describe prebuilt/person-linkedin-to-email --json
42416
42502
  deepline plays check prebuilt/name-and-domain-to-email-waterfall-batch
42417
42503
  deepline plays run prebuilt/person-linkedin-to-email --input '{"linkedin_url":"..."}'
@@ -42718,7 +42804,7 @@ Notes:
42718
42804
  Examples:
42719
42805
  deepline plays list
42720
42806
  deepline plays list --tag smb --json
42721
- deepline plays search email --json
42807
+ deepline search --type prebuilts email --json
42722
42808
  `
42723
42809
  ).option("--limit <count>", "Page size").option("--cursor <cursor>", "Continue a previous page").option("--show-cost", "Include the per-row or per-run cost estimate").option("--json", "Emit JSON output. Also automatic when stdout is piped").option(
42724
42810
  "--categories <categories>",
@@ -42787,40 +42873,10 @@ Examples:
42787
42873
  false
42788
42874
  );
42789
42875
  });
42790
- const addPlaySearchCommand = (command) => command.description("Search Deepline prebuilt plays by task.").option(
42791
- "--prebuilt",
42792
- "Only show Deepline-managed prebuilt plays (default)"
42793
- ).option(
42794
- "--all",
42795
- "Also include plays you created after Deepline-managed prebuilts"
42796
- ).addHelpText(
42797
- "after",
42798
- `
42799
- Notes:
42800
- Ranked discovery for workflows. Search defaults to Deepline-managed prebuilts
42801
- because they are trusted, robust plays with maintained contracts. Use describe
42802
- on a result before running it.
42803
- Add --all only when you are specifically looking for a play you created.
42804
- Use plays grep to search active org-owned Plays through Convex's indexed
42805
- authored corpus. It does not search prebuilt or archived Plays.
42806
-
42807
- Examples:
42808
- deepline plays search email
42809
- deepline plays search email --all
42810
- deepline plays grep "linkedin to email" --json
42811
- deepline plays describe prebuilt/person-linkedin-to-email --json
42812
- deepline plays describe prebuilt/person-linkedin-to-email --json inputSchema,runCommand
42813
- `
42814
- ).option("--compact", "Emit compact schemas").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (query, options) => {
42815
- process.exitCode = await handlePlaySearch([
42816
- query,
42817
- ...options.prebuilt ? ["--prebuilt"] : [],
42818
- ...options.all ? ["--all"] : [],
42819
- ...options.compact ? ["--compact"] : [],
42820
- ...options.json ? ["--json"] : []
42821
- ]);
42822
- });
42823
- addPlaySearchCommand(play.command("search <query>"));
42876
+ registerDeprecatedSearchCommand(
42877
+ play,
42878
+ (options) => options.all ? ["plays"] : ["prebuilts"]
42879
+ );
42824
42880
  play.command("grep <query>").description(
42825
42881
  "Search active org-owned Plays through Convex full-text search."
42826
42882
  ).addHelpText(
@@ -44242,38 +44298,38 @@ Examples:
44242
44298
 
44243
44299
  // src/cli/commands/setup.ts
44244
44300
  var import_node_child_process5 = require("child_process");
44245
- var import_node_fs21 = require("fs");
44301
+ var import_node_fs22 = require("fs");
44246
44302
  var import_node_os14 = require("os");
44247
- var import_node_path26 = require("path");
44303
+ var import_node_path27 = require("path");
44248
44304
 
44249
44305
  // src/cli/installation-lifecycle.ts
44250
- var import_node_fs18 = require("fs");
44251
- var import_node_path23 = require("path");
44306
+ var import_node_fs19 = require("fs");
44307
+ var import_node_path24 = require("path");
44252
44308
  var nodeFileSystem = {
44253
- exists: import_node_fs18.existsSync,
44309
+ exists: import_node_fs19.existsSync,
44254
44310
  isSymbolicLink(path) {
44255
44311
  try {
44256
- return (0, import_node_fs18.lstatSync)(path).isSymbolicLink();
44312
+ return (0, import_node_fs19.lstatSync)(path).isSymbolicLink();
44257
44313
  } catch {
44258
44314
  return false;
44259
44315
  }
44260
44316
  },
44261
44317
  read(path) {
44262
44318
  try {
44263
- return (0, import_node_fs18.readFileSync)(path, "utf8");
44319
+ return (0, import_node_fs19.readFileSync)(path, "utf8");
44264
44320
  } catch {
44265
44321
  return "";
44266
44322
  }
44267
44323
  },
44268
44324
  realpath(path) {
44269
44325
  try {
44270
- return (0, import_node_fs18.realpathSync)(path);
44326
+ return (0, import_node_fs19.realpathSync)(path);
44271
44327
  } catch {
44272
44328
  return null;
44273
44329
  }
44274
44330
  },
44275
44331
  remove(path) {
44276
- (0, import_node_fs18.rmSync)(path, { force: true });
44332
+ (0, import_node_fs19.rmSync)(path, { force: true });
44277
44333
  }
44278
44334
  };
44279
44335
  function inspectLauncher(path, fileSystem = nodeFileSystem) {
@@ -44304,25 +44360,25 @@ var CliInstallation = class _CliInstallation {
44304
44360
  });
44305
44361
  }
44306
44362
  static isNpmPackagePath(path) {
44307
- return path?.includes(`${(0, import_node_path23.join)("node_modules", "deepline")}`) ?? false;
44363
+ return path?.includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`) ?? false;
44308
44364
  }
44309
44365
  launcher(path) {
44310
44366
  return inspectLauncher(path, this.input.fileSystem);
44311
44367
  }
44312
44368
  retiredArtifacts() {
44313
- const hostDir = (0, import_node_path23.join)(
44369
+ const hostDir = (0, import_node_path24.join)(
44314
44370
  this.input.home,
44315
44371
  ".local",
44316
44372
  "deepline",
44317
44373
  this.input.baseUrlSlug
44318
44374
  );
44319
- const legacyLauncherPath = (0, import_node_path23.join)(
44375
+ const legacyLauncherPath = (0, import_node_path24.join)(
44320
44376
  this.input.home,
44321
44377
  ".local",
44322
44378
  "bin",
44323
44379
  "deepline"
44324
44380
  );
44325
- const installerCommandPath = this.input.fileSystem.read((0, import_node_path23.join)(hostDir, "sdk", ".command-path")).trim();
44381
+ const installerCommandPath = this.input.fileSystem.read((0, import_node_path24.join)(hostDir, "sdk", ".command-path")).trim();
44326
44382
  const ownedInstallerCommand = isOwnedInstallerCommandPath({
44327
44383
  hostDir,
44328
44384
  commandPath: installerCommandPath
@@ -44330,16 +44386,16 @@ var CliInstallation = class _CliInstallation {
44330
44386
  const legacyLauncher = this.launcher(legacyLauncherPath);
44331
44387
  const candidates = [
44332
44388
  ...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
44333
- (0, import_node_path23.join)(this.input.home, ".local", "bin", "deepline-real"),
44334
- (0, import_node_path23.join)(hostDir, "bin", "deepline"),
44335
- (0, import_node_path23.join)(hostDir, "bin", "deepline-real"),
44336
- (0, import_node_path23.join)(hostDir, "cli", ".install-method"),
44337
- (0, import_node_path23.join)(hostDir, "cli", ".version"),
44338
- (0, import_node_path23.join)(hostDir, "sdk", ".install-method"),
44339
- (0, import_node_path23.join)(hostDir, "sdk", ".command-path"),
44389
+ (0, import_node_path24.join)(this.input.home, ".local", "bin", "deepline-real"),
44390
+ (0, import_node_path24.join)(hostDir, "bin", "deepline"),
44391
+ (0, import_node_path24.join)(hostDir, "bin", "deepline-real"),
44392
+ (0, import_node_path24.join)(hostDir, "cli", ".install-method"),
44393
+ (0, import_node_path24.join)(hostDir, "cli", ".version"),
44394
+ (0, import_node_path24.join)(hostDir, "sdk", ".install-method"),
44395
+ (0, import_node_path24.join)(hostDir, "sdk", ".command-path"),
44340
44396
  ...ownedInstallerCommand ? [
44341
44397
  installerCommandPath,
44342
- (0, import_node_path23.join)((0, import_node_path23.dirname)(installerCommandPath), "deepline-sdk")
44398
+ (0, import_node_path24.join)((0, import_node_path24.dirname)(installerCommandPath), "deepline-sdk")
44343
44399
  ] : []
44344
44400
  ];
44345
44401
  return {
@@ -44360,19 +44416,19 @@ function removeArtifacts(plan, fileSystem) {
44360
44416
  return plan.paths;
44361
44417
  }
44362
44418
  function isOwnedInstallerCommandPath(input2) {
44363
- if (!input2.commandPath || (0, import_node_path23.basename)(input2.commandPath) !== "deepline") {
44419
+ if (!input2.commandPath || (0, import_node_path24.basename)(input2.commandPath) !== "deepline") {
44364
44420
  return false;
44365
44421
  }
44366
- const commandPath = (0, import_node_path23.resolve)(input2.commandPath);
44367
- const fromHost = (0, import_node_path23.relative)((0, import_node_path23.resolve)(input2.hostDir), commandPath);
44422
+ const commandPath = (0, import_node_path24.resolve)(input2.commandPath);
44423
+ const fromHost = (0, import_node_path24.relative)((0, import_node_path24.resolve)(input2.hostDir), commandPath);
44368
44424
  return fromHost !== "" && fromHost !== ".." && !fromHost.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
44369
44425
  }
44370
44426
 
44371
44427
  // src/cli/commands/skills.ts
44372
44428
  var import_node_child_process3 = require("child_process");
44373
- var import_node_fs20 = require("fs");
44429
+ var import_node_fs21 = require("fs");
44374
44430
  var import_node_os13 = require("os");
44375
- var import_node_path25 = require("path");
44431
+ var import_node_path26 = require("path");
44376
44432
 
44377
44433
  // contracts/install-commands.json
44378
44434
  var install_commands_default = {
@@ -44488,8 +44544,8 @@ var import_node_child_process2 = require("child_process");
44488
44544
  var import_node_crypto11 = require("crypto");
44489
44545
  var import_node_os12 = require("os");
44490
44546
  var import_node_zlib2 = require("zlib");
44491
- var import_node_fs19 = require("fs");
44492
- var import_node_path24 = require("path");
44547
+ var import_node_fs20 = require("fs");
44548
+ var import_node_path25 = require("path");
44493
44549
 
44494
44550
  // src/cli/windows-arg-escape.ts
44495
44551
  var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
@@ -44899,7 +44955,7 @@ function shouldSkipSkillsSync() {
44899
44955
  return value === "1" || value === "true" || value === "yes" || value === "on";
44900
44956
  }
44901
44957
  function unavailableSkillsNoticePath(baseUrl) {
44902
- return (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
44958
+ return (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
44903
44959
  }
44904
44960
  var SKILLS_SYNC_IN_PROGRESS_TTL_MS = 10 * 60 * 1e3;
44905
44961
  var SKILLS_SYNC_IN_PROGRESS_PID_CAP_MS = 6 * 60 * 60 * 1e3;
@@ -44909,21 +44965,21 @@ function sortedLeaseAgents(agents) {
44909
44965
  return [...new Set(expanded)].sort((a, b) => a.localeCompare(b));
44910
44966
  }
44911
44967
  function inProgressSkillsSyncPath(baseUrl, agent) {
44912
- return (0, import_node_path24.join)(
44968
+ return (0, import_node_path25.join)(
44913
44969
  sdkCliStateDirPath(baseUrl),
44914
44970
  `skills-sync-in-progress-${agentLeaseSegment(agent)}`
44915
44971
  );
44916
44972
  }
44917
44973
  function readInProgressSkillsSyncLeaseFromDir(dir) {
44918
- const claim = readMarkedSkillsSyncVersion((0, import_node_path24.join)(dir, "claim"));
44974
+ const claim = readMarkedSkillsSyncVersion((0, import_node_path25.join)(dir, "claim"));
44919
44975
  const [version = "", startedAt = ""] = claim.split(" ");
44920
- const pidRaw = readMarkedSkillsSyncVersion((0, import_node_path24.join)(dir, "pid"));
44976
+ const pidRaw = readMarkedSkillsSyncVersion((0, import_node_path25.join)(dir, "pid"));
44921
44977
  return {
44922
44978
  claimToken: version && startedAt ? `${version} ${startedAt}` : "",
44923
44979
  version,
44924
44980
  startedAt: Number(startedAt),
44925
44981
  pid: /^\d+$/.test(pidRaw) ? Number(pidRaw) : null,
44926
- owner: readMarkedSkillsSyncVersion((0, import_node_path24.join)(dir, "owner"))
44982
+ owner: readMarkedSkillsSyncVersion((0, import_node_path25.join)(dir, "owner"))
44927
44983
  };
44928
44984
  }
44929
44985
  function readInProgressSkillsSyncLease(baseUrl, agent) {
@@ -44968,7 +45024,7 @@ function isFreshInProgressSkillsSync(lease, now = Date.now()) {
44968
45024
  function quarantine(path, tag) {
44969
45025
  const holding = `${path}.${tag}-${process.pid}-${Date.now()}`;
44970
45026
  try {
44971
- (0, import_node_fs19.renameSync)(path, holding);
45027
+ (0, import_node_fs20.renameSync)(path, holding);
44972
45028
  return holding;
44973
45029
  } catch {
44974
45030
  return null;
@@ -44980,15 +45036,15 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
44980
45036
  const create = () => {
44981
45037
  const claimToken = `${remoteVersion} ${Date.now()}`;
44982
45038
  const staging = `${dir}.staging-${process.pid}-${Date.now()}`;
44983
- (0, import_node_fs19.mkdirSync)(staging);
44984
- (0, import_node_fs19.writeFileSync)((0, import_node_path24.join)(staging, "claim"), `${claimToken}
45039
+ (0, import_node_fs20.mkdirSync)(staging);
45040
+ (0, import_node_fs20.writeFileSync)((0, import_node_path25.join)(staging, "claim"), `${claimToken}
44985
45041
  `, "utf-8");
44986
- (0, import_node_fs19.writeFileSync)((0, import_node_path24.join)(staging, "owner"), `${owner}
45042
+ (0, import_node_fs20.writeFileSync)((0, import_node_path25.join)(staging, "owner"), `${owner}
44987
45043
  `, "utf-8");
44988
45044
  try {
44989
- (0, import_node_fs19.renameSync)(staging, dir);
45045
+ (0, import_node_fs20.renameSync)(staging, dir);
44990
45046
  } catch (error) {
44991
- (0, import_node_fs19.rmSync)(staging, { recursive: true, force: true });
45047
+ (0, import_node_fs20.rmSync)(staging, { recursive: true, force: true });
44992
45048
  const code = errorCode(error);
44993
45049
  const err = new Error("lease directory already exists");
44994
45050
  err.code = code === "EEXIST" || code === "ENOTEMPTY" ? "EEXIST" : String(code ?? "");
@@ -44997,7 +45053,7 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
44997
45053
  return { state: "claimed", claimToken };
44998
45054
  };
44999
45055
  try {
45000
- (0, import_node_fs19.mkdirSync)((0, import_node_path24.dirname)(dir), { recursive: true });
45056
+ (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(dir), { recursive: true });
45001
45057
  return create();
45002
45058
  } catch (error) {
45003
45059
  if (errorCode(error) !== "EEXIST") return { state: "unavailable" };
@@ -45009,7 +45065,7 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
45009
45065
  if (!tombstone) {
45010
45066
  return { state: "held" };
45011
45067
  }
45012
- (0, import_node_fs19.rmSync)(tombstone, { recursive: true, force: true });
45068
+ (0, import_node_fs20.rmSync)(tombstone, { recursive: true, force: true });
45013
45069
  try {
45014
45070
  return create();
45015
45071
  } catch (error) {
@@ -45056,8 +45112,8 @@ function recordOwnPidOnInProgressSkillsSync(baseUrl, leases) {
45056
45112
  for (const [agent, lease] of leases) {
45057
45113
  if (!lease.claimToken) continue;
45058
45114
  try {
45059
- (0, import_node_fs19.writeFileSync)(
45060
- (0, import_node_path24.join)(inProgressSkillsSyncPath(baseUrl, agent), "pid"),
45115
+ (0, import_node_fs20.writeFileSync)(
45116
+ (0, import_node_path25.join)(inProgressSkillsSyncPath(baseUrl, agent), "pid"),
45061
45117
  `${process.pid}
45062
45118
  `,
45063
45119
  "utf-8"
@@ -45071,7 +45127,7 @@ function releaseInProgressSkillsSync(baseUrl, claimTokens) {
45071
45127
  const dir = inProgressSkillsSyncPath(baseUrl, agent);
45072
45128
  if (!claimToken) {
45073
45129
  try {
45074
- (0, import_node_fs19.rmSync)(dir, { recursive: true, force: true });
45130
+ (0, import_node_fs20.rmSync)(dir, { recursive: true, force: true });
45075
45131
  } catch {
45076
45132
  }
45077
45133
  continue;
@@ -45080,12 +45136,12 @@ function releaseInProgressSkillsSync(baseUrl, claimTokens) {
45080
45136
  if (!tombstone) continue;
45081
45137
  try {
45082
45138
  if (readInProgressSkillsSyncLeaseFromDir(tombstone).claimToken !== claimToken) {
45083
- (0, import_node_fs19.renameSync)(tombstone, dir);
45139
+ (0, import_node_fs20.renameSync)(tombstone, dir);
45084
45140
  continue;
45085
45141
  }
45086
45142
  } catch {
45087
45143
  }
45088
- (0, import_node_fs19.rmSync)(tombstone, { recursive: true, force: true });
45144
+ (0, import_node_fs20.rmSync)(tombstone, { recursive: true, force: true });
45089
45145
  }
45090
45146
  }
45091
45147
  function claimTokensOf(leases) {
@@ -45126,7 +45182,7 @@ function skillsInstallLeasePath(baseUrl, agents) {
45126
45182
  return sortedLeaseAgents(agents).map((agent) => inProgressSkillsSyncPath(baseUrl, agent)).join(", ");
45127
45183
  }
45128
45184
  function deferredSkillsNoticePath(baseUrl, agents) {
45129
- return (0, import_node_path24.join)(
45185
+ return (0, import_node_path25.join)(
45130
45186
  sdkCliStateDirPath(baseUrl),
45131
45187
  `skills-sync-notice-${sortedLeaseAgents(agents).map(agentLeaseSegment).join("-")}`
45132
45188
  );
@@ -45135,8 +45191,8 @@ function deferSkillsNotice(baseUrl, agents) {
45135
45191
  const path = deferredSkillsNoticePath(baseUrl, agents);
45136
45192
  return (text) => {
45137
45193
  try {
45138
- (0, import_node_fs19.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
45139
- (0, import_node_fs19.appendFileSync)(path, `${text.trimEnd()}
45194
+ (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
45195
+ (0, import_node_fs20.appendFileSync)(path, `${text.trimEnd()}
45140
45196
  `, "utf-8");
45141
45197
  } catch {
45142
45198
  }
@@ -45144,17 +45200,17 @@ function deferSkillsNotice(baseUrl, agents) {
45144
45200
  }
45145
45201
  function flushDeferredSkillsNotices(baseUrl, agents) {
45146
45202
  const path = deferredSkillsNoticePath(baseUrl, agents);
45147
- if (!(0, import_node_fs19.existsSync)(path)) return;
45203
+ if (!(0, import_node_fs20.existsSync)(path)) return;
45148
45204
  const tombstone = quarantine(path, "consuming");
45149
45205
  if (!tombstone) return;
45150
45206
  let text = "";
45151
45207
  try {
45152
- text = (0, import_node_fs19.readFileSync)(tombstone, "utf-8");
45208
+ text = (0, import_node_fs20.readFileSync)(tombstone, "utf-8");
45153
45209
  } catch {
45154
45210
  return;
45155
45211
  } finally {
45156
45212
  try {
45157
- (0, import_node_fs19.unlinkSync)(tombstone);
45213
+ (0, import_node_fs20.unlinkSync)(tombstone);
45158
45214
  } catch {
45159
45215
  }
45160
45216
  }
@@ -45177,7 +45233,7 @@ function spawnDetachedSkillsSyncChild(argv, onSpawnError) {
45177
45233
  child.unref();
45178
45234
  }
45179
45235
  function failedSkillsSyncPath(baseUrl, agents) {
45180
- return (0, import_node_path24.join)(
45236
+ return (0, import_node_path25.join)(
45181
45237
  sdkCliStateDirPath(baseUrl),
45182
45238
  `skills-sync-failed-${sortedLeaseAgents(agents).map(agentLeaseSegment).join("-")}-version`
45183
45239
  );
@@ -45187,15 +45243,15 @@ function hasMarkedSkillsSyncVersion(path, version) {
45187
45243
  }
45188
45244
  function readMarkedSkillsSyncVersion(path) {
45189
45245
  try {
45190
- return (0, import_node_fs19.existsSync)(path) ? (0, import_node_fs19.readFileSync)(path, "utf-8").trim() : "";
45246
+ return (0, import_node_fs20.existsSync)(path) ? (0, import_node_fs20.readFileSync)(path, "utf-8").trim() : "";
45191
45247
  } catch {
45192
45248
  return "";
45193
45249
  }
45194
45250
  }
45195
45251
  function writeMarkedSkillsSyncVersion(path, version) {
45196
45252
  try {
45197
- (0, import_node_fs19.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
45198
- (0, import_node_fs19.writeFileSync)(path, `${version}
45253
+ (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
45254
+ (0, import_node_fs20.writeFileSync)(path, `${version}
45199
45255
  `, "utf-8");
45200
45256
  return true;
45201
45257
  } catch {
@@ -45216,7 +45272,7 @@ ${manualCommand}`
45216
45272
  }
45217
45273
  function clearUnavailableSkillsNotice(baseUrl) {
45218
45274
  try {
45219
- (0, import_node_fs19.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
45275
+ (0, import_node_fs20.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
45220
45276
  } catch {
45221
45277
  }
45222
45278
  }
@@ -45234,7 +45290,7 @@ function hasFailedSkillsSync(baseUrl, remoteVersion, agents) {
45234
45290
  }
45235
45291
  }
45236
45292
  function hasFailedAutomaticSkillsSync(baseUrl, agents) {
45237
- return (0, import_node_fs19.existsSync)(failedSkillsSyncPath(baseUrl, agents));
45293
+ return (0, import_node_fs20.existsSync)(failedSkillsSyncPath(baseUrl, agents));
45238
45294
  }
45239
45295
  function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
45240
45296
  return writeMarkedSkillsSyncVersion(
@@ -45253,7 +45309,7 @@ function deferPublishedVerificationRetry(baseUrl, remoteVersion, agents) {
45253
45309
  }
45254
45310
  function clearFailedSkillsSync(baseUrl, agents) {
45255
45311
  try {
45256
- (0, import_node_fs19.unlinkSync)(failedSkillsSyncPath(baseUrl, agents));
45312
+ (0, import_node_fs20.unlinkSync)(failedSkillsSyncPath(baseUrl, agents));
45257
45313
  } catch {
45258
45314
  }
45259
45315
  }
@@ -45304,7 +45360,7 @@ function safeSkillFilePath(value) {
45304
45360
  }
45305
45361
  function installedSkillFiles(root, prefix = "") {
45306
45362
  const files = [];
45307
- for (const entry of (0, import_node_fs19.readdirSync)((0, import_node_path24.join)(root, prefix), {
45363
+ for (const entry of (0, import_node_fs20.readdirSync)((0, import_node_path25.join)(root, prefix), {
45308
45364
  withFileTypes: true
45309
45365
  })) {
45310
45366
  const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
@@ -45424,11 +45480,11 @@ async function verifyDefaultAgentSkillsInstall(baseUrl, remoteVersion, skillName
45424
45480
  controller.abort();
45425
45481
  }
45426
45482
  const home = (0, import_node_os12.homedir)();
45427
- const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path24.join)(home, ".claude");
45483
+ const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path25.join)(home, ".claude");
45428
45484
  for (const [name, { files }] of published) {
45429
45485
  for (const root of [
45430
- (0, import_node_path24.join)(home, ".agents", "skills", name),
45431
- (0, import_node_path24.join)(claudeConfigDir, "skills", name)
45486
+ (0, import_node_path25.join)(home, ".agents", "skills", name),
45487
+ (0, import_node_path25.join)(claudeConfigDir, "skills", name)
45432
45488
  ]) {
45433
45489
  const installed = installedSkillFiles(root);
45434
45490
  if (installed.length !== files.length || installed.some((file, index2) => file !== files[index2])) {
@@ -45436,7 +45492,7 @@ async function verifyDefaultAgentSkillsInstall(baseUrl, remoteVersion, skillName
45436
45492
  }
45437
45493
  for (const file of files) {
45438
45494
  const publishedContent = expected.get(`${name}/${file}`);
45439
- if (!publishedContent || !(0, import_node_fs19.readFileSync)((0, import_node_path24.join)(root, file)).equals(publishedContent)) {
45495
+ if (!publishedContent || !(0, import_node_fs20.readFileSync)((0, import_node_path25.join)(root, file)).equals(publishedContent)) {
45440
45496
  throw new Error(`installed content differs for ${name}/${file}`);
45441
45497
  }
45442
45498
  }
@@ -45490,7 +45546,7 @@ function probeInstallers(timeoutMs) {
45490
45546
  };
45491
45547
  }
45492
45548
  function noInstallerProbePath(baseUrl) {
45493
- return (0, import_node_path24.join)(
45549
+ return (0, import_node_path25.join)(
45494
45550
  sdkCliStateDirPath(baseUrl),
45495
45551
  "skills-sync-no-installer-unknown.json"
45496
45552
  );
@@ -45498,7 +45554,7 @@ function noInstallerProbePath(baseUrl) {
45498
45554
  function dueUnknownInstallerProbes(baseUrl, remoteVersion) {
45499
45555
  const path = noInstallerProbePath(baseUrl);
45500
45556
  try {
45501
- const cached = JSON.parse((0, import_node_fs19.readFileSync)(path, "utf-8"));
45557
+ const cached = JSON.parse((0, import_node_fs20.readFileSync)(path, "utf-8"));
45502
45558
  if (cached.version === remoteVersion && typeof cached.checkedAt === "number" && cached.checkedAt <= Date.now() && Date.now() - cached.checkedAt < NEGATIVE_INSTALLER_PROBE_TTL_MS && (cached.probes?.bunx === "missing" || cached.probes?.bunx === "failed") && (cached.probes?.npx === "missing" || cached.probes?.npx === "failed")) {
45503
45559
  return cached.probes;
45504
45560
  }
@@ -45507,8 +45563,8 @@ function dueUnknownInstallerProbes(baseUrl, remoteVersion) {
45507
45563
  const probes = probeInstallers(INSTALLER_PROBE_TIMEOUT_MS);
45508
45564
  if (probes.bunx !== "available" && probes.npx !== "available") {
45509
45565
  try {
45510
- (0, import_node_fs19.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
45511
- (0, import_node_fs19.writeFileSync)(
45566
+ (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
45567
+ (0, import_node_fs20.writeFileSync)(
45512
45568
  path,
45513
45569
  JSON.stringify({
45514
45570
  version: remoteVersion,
@@ -45959,13 +46015,13 @@ function detectSkillsAgents(input2) {
45959
46015
  ];
45960
46016
  const detected = AGENT_MARKERS.filter(
45961
46017
  (marker) => roots.some(
45962
- (root) => marker.paths.some((path) => (0, import_node_fs20.existsSync)((0, import_node_path25.join)(root, path)))
46018
+ (root) => marker.paths.some((path) => (0, import_node_fs21.existsSync)((0, import_node_path26.join)(root, path)))
45963
46019
  )
45964
46020
  ).map((marker) => marker.agent);
45965
46021
  return detected.length > 0 ? detected : ["*"];
45966
46022
  }
45967
46023
  function skillsStatePathForScope(baseUrl, scope, root) {
45968
- return scope === "local" && root ? (0, import_node_path25.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
46024
+ return scope === "local" && root ? (0, import_node_path26.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path26.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
45969
46025
  }
45970
46026
  function buildSkillsPlan(input2) {
45971
46027
  const scopeArgs = input2.scope === "global" ? ["--global"] : [];
@@ -46032,7 +46088,7 @@ function isSkillsPlanCurrent(plan, state) {
46032
46088
  }
46033
46089
  function readSkillsInstallState(path) {
46034
46090
  try {
46035
- const parsed = JSON.parse((0, import_node_fs20.readFileSync)(path, "utf8"));
46091
+ const parsed = JSON.parse((0, import_node_fs21.readFileSync)(path, "utf8"));
46036
46092
  return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
46037
46093
  } catch {
46038
46094
  return null;
@@ -46236,8 +46292,8 @@ async function runSkillsInstallWithLease(input2) {
46236
46292
  `
46237
46293
  );
46238
46294
  }
46239
- (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(plan.statePath), { recursive: true });
46240
- (0, import_node_fs20.writeFileSync)(
46295
+ (0, import_node_fs21.mkdirSync)((0, import_node_path26.dirname)(plan.statePath), { recursive: true });
46296
+ (0, import_node_fs21.writeFileSync)(
46241
46297
  plan.statePath,
46242
46298
  `${JSON.stringify(
46243
46299
  {
@@ -46426,7 +46482,7 @@ function phasesFromLegacyStatus(status) {
46426
46482
  function readSetupState(input2) {
46427
46483
  try {
46428
46484
  const parsed = JSON.parse(
46429
- (0, import_node_fs21.readFileSync)(
46485
+ (0, import_node_fs22.readFileSync)(
46430
46486
  setupStatePath(input2.baseUrl, input2.scope, input2.root),
46431
46487
  "utf8"
46432
46488
  )
@@ -46515,7 +46571,7 @@ function buildPendingAuthorizationOutput(input2) {
46515
46571
  };
46516
46572
  }
46517
46573
  function setupStatePath(baseUrl, scope, root) {
46518
- return scope === "local" && root ? (0, import_node_path26.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path26.join)(sdkCliStateDirPath(baseUrl), "setup.json");
46574
+ return scope === "local" && root ? (0, import_node_path27.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path27.join)(sdkCliStateDirPath(baseUrl), "setup.json");
46519
46575
  }
46520
46576
  async function captureStdout(run) {
46521
46577
  let stdout = "";
@@ -46544,7 +46600,7 @@ function asRecord4(value) {
46544
46600
  }
46545
46601
  function safeRead(path) {
46546
46602
  try {
46547
- return (0, import_node_fs21.readFileSync)(path, "utf8");
46603
+ return (0, import_node_fs22.readFileSync)(path, "utf8");
46548
46604
  } catch {
46549
46605
  return "";
46550
46606
  }
@@ -46563,7 +46619,7 @@ function resolvePathCommands(command) {
46563
46619
  );
46564
46620
  return [
46565
46621
  ...new Set(
46566
- String(lookup2.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path26.resolve)(path))
46622
+ String(lookup2.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path27.resolve)(path))
46567
46623
  )
46568
46624
  ];
46569
46625
  }
@@ -46573,7 +46629,7 @@ function resolvePathCommand(command) {
46573
46629
  function isHomebrewFormulaCommand(path) {
46574
46630
  let resolvedPath = path;
46575
46631
  try {
46576
- resolvedPath = (0, import_node_fs21.realpathSync)(path);
46632
+ resolvedPath = (0, import_node_fs22.realpathSync)(path);
46577
46633
  } catch {
46578
46634
  return false;
46579
46635
  }
@@ -46584,7 +46640,7 @@ function isHomebrewFormulaCommand(path) {
46584
46640
  function resolvePersistentGlobalCommand(dependencies = {}) {
46585
46641
  const platform3 = dependencies.platform ?? process.platform;
46586
46642
  const run = dependencies.spawn ?? import_node_child_process5.spawnSync;
46587
- const pathExists = dependencies.exists ?? import_node_fs21.existsSync;
46643
+ const pathExists = dependencies.exists ?? import_node_fs22.existsSync;
46588
46644
  const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
46589
46645
  const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
46590
46646
  if (homebrewCommand) return homebrewCommand;
@@ -46596,7 +46652,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
46596
46652
  if (prefix.status !== 0) return null;
46597
46653
  const root = String(prefix.stdout ?? "").trim();
46598
46654
  if (!root) return null;
46599
- const candidates = platform3 === "win32" ? [(0, import_node_path26.join)(root, "deepline.cmd"), (0, import_node_path26.join)(root, "deepline")] : [(0, import_node_path26.join)(root, "bin", "deepline")];
46655
+ const candidates = platform3 === "win32" ? [(0, import_node_path27.join)(root, "deepline.cmd"), (0, import_node_path27.join)(root, "deepline")] : [(0, import_node_path27.join)(root, "bin", "deepline")];
46600
46656
  return candidates.find((candidate) => pathExists(candidate)) ?? null;
46601
46657
  }
46602
46658
  function inspectGlobalCliAvailability(input2) {
@@ -46609,20 +46665,20 @@ function inspectGlobalCliAvailability(input2) {
46609
46665
  }
46610
46666
  function pathsResolveToSameFile(left, right) {
46611
46667
  try {
46612
- return (0, import_node_fs21.realpathSync)(left) === (0, import_node_fs21.realpathSync)(right);
46668
+ return (0, import_node_fs22.realpathSync)(left) === (0, import_node_fs22.realpathSync)(right);
46613
46669
  } catch {
46614
- return (0, import_node_path26.resolve)(left) === (0, import_node_path26.resolve)(right);
46670
+ return (0, import_node_path27.resolve)(left) === (0, import_node_path27.resolve)(right);
46615
46671
  }
46616
46672
  }
46617
46673
  function isKnownDeeplineCommand(path) {
46618
- const entrypoint = process.argv[1] ? (0, import_node_path26.resolve)(process.argv[1]) : "";
46674
+ const entrypoint = process.argv[1] ? (0, import_node_path27.resolve)(process.argv[1]) : "";
46619
46675
  let resolvedPath = path;
46620
46676
  try {
46621
- resolvedPath = (0, import_node_fs21.realpathSync)(path);
46677
+ resolvedPath = (0, import_node_fs22.realpathSync)(path);
46622
46678
  } catch {
46623
46679
  }
46624
46680
  if (entrypoint && resolvedPath === entrypoint) return true;
46625
- if (resolvedPath.includes(`${(0, import_node_path26.join)("node_modules", "deepline")}`)) return true;
46681
+ if (resolvedPath.includes(`${(0, import_node_path27.join)("node_modules", "deepline")}`)) return true;
46626
46682
  const content = safeRead(path);
46627
46683
  return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
46628
46684
  }
@@ -46630,9 +46686,9 @@ function inspectPathConflict() {
46630
46686
  const commandPath = resolvePathCommand("deepline");
46631
46687
  if (!commandPath || isKnownDeeplineCommand(commandPath)) return null;
46632
46688
  try {
46633
- if ((0, import_node_fs21.lstatSync)(commandPath).isSymbolicLink()) {
46634
- const target = (0, import_node_fs21.realpathSync)(commandPath);
46635
- if (target.includes(`${(0, import_node_path26.join)("node_modules", "deepline")}`)) return null;
46689
+ if ((0, import_node_fs22.lstatSync)(commandPath).isSymbolicLink()) {
46690
+ const target = (0, import_node_fs22.realpathSync)(commandPath);
46691
+ if (target.includes(`${(0, import_node_path27.join)("node_modules", "deepline")}`)) return null;
46636
46692
  }
46637
46693
  } catch {
46638
46694
  }
@@ -46640,8 +46696,8 @@ function inspectPathConflict() {
46640
46696
  }
46641
46697
  function writeSetupState(input2) {
46642
46698
  const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
46643
- (0, import_node_fs21.mkdirSync)((0, import_node_path26.dirname)(path), { recursive: true });
46644
- (0, import_node_fs21.writeFileSync)(
46699
+ (0, import_node_fs22.mkdirSync)((0, import_node_path27.dirname)(path), { recursive: true });
46700
+ (0, import_node_fs22.writeFileSync)(
46645
46701
  path,
46646
46702
  `${JSON.stringify(
46647
46703
  {
@@ -46681,7 +46737,7 @@ function failSetupPhase(phases, phase, code) {
46681
46737
  phases[phase] = { status: "failed", code };
46682
46738
  }
46683
46739
  function rollbackCommand(scope, root) {
46684
- const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path26.join)(root, ".deepline", "runtime"))}` : "";
46740
+ const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path27.join)(root, ".deepline", "runtime"))}` : "";
46685
46741
  const allowScriptsFlag = npmSupportsAllowScripts(readNpmVersion(process.env)) ? " --allow-scripts=esbuild" : "";
46686
46742
  return `npm install -g${prefix} --no-audit --no-fund --include=optional${allowScriptsFlag} deepline@${SDK_VERSION}`;
46687
46743
  }
@@ -46771,12 +46827,12 @@ function buildDoctorAssessment(input2) {
46771
46827
  const connected = input2.authStatus.payload?.connected === true;
46772
46828
  const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
46773
46829
  const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
46774
- const runningCliPath = process.argv[1] ? (0, import_node_path26.resolve)(process.argv[1]) : null;
46830
+ const runningCliPath = process.argv[1] ? (0, import_node_path27.resolve)(process.argv[1]) : null;
46775
46831
  const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
46776
46832
  const pathGlobalCli = globalCli?.path ?? null;
46777
46833
  const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
46778
46834
  const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
46779
- input2.root && runningCliPath?.includes((0, import_node_path26.join)(input2.root, ".deepline", "runtime"))
46835
+ input2.root && runningCliPath?.includes((0, import_node_path27.join)(input2.root, ".deepline", "runtime"))
46780
46836
  );
46781
46837
  const checks = {
46782
46838
  cli: {
@@ -47392,12 +47448,12 @@ Examples:
47392
47448
  }
47393
47449
 
47394
47450
  // src/cli/commands/settings.ts
47395
- var import_node_fs25 = require("fs");
47451
+ var import_node_fs26 = require("fs");
47396
47452
 
47397
47453
  // src/cli/update-preferences.ts
47398
- var import_node_fs22 = require("fs");
47454
+ var import_node_fs23 = require("fs");
47399
47455
  var import_node_os15 = require("os");
47400
- var import_node_path27 = require("path");
47456
+ var import_node_path28 = require("path");
47401
47457
  var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
47402
47458
  var CLI_UPDATE_MESSAGES = [
47403
47459
  {
@@ -47426,7 +47482,7 @@ function unreadablePreferences(path, error) {
47426
47482
  };
47427
47483
  }
47428
47484
  function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os15.homedir)()) {
47429
- return (0, import_node_path27.join)(
47485
+ return (0, import_node_path28.join)(
47430
47486
  homeDir2,
47431
47487
  ".local",
47432
47488
  "deepline",
@@ -47436,9 +47492,9 @@ function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os15.homedir)()) {
47436
47492
  }
47437
47493
  function readCliUpdatePreferences(homeDir2 = (0, import_node_os15.homedir)()) {
47438
47494
  const path = cliUpdatePreferencesPath(homeDir2);
47439
- if (!(0, import_node_fs22.existsSync)(path)) return defaultPreferences();
47495
+ if (!(0, import_node_fs23.existsSync)(path)) return defaultPreferences();
47440
47496
  try {
47441
- const parsed = JSON.parse((0, import_node_fs22.readFileSync)(path, "utf8"));
47497
+ const parsed = JSON.parse((0, import_node_fs23.readFileSync)(path, "utf8"));
47442
47498
  return {
47443
47499
  schemaVersion: UPDATE_PREFERENCES_SCHEMA_VERSION,
47444
47500
  autoUpdateEnabled: typeof parsed.autoUpdateEnabled === "boolean" ? parsed.autoUpdateEnabled : true,
@@ -47454,16 +47510,16 @@ function readCliUpdatePreferences(homeDir2 = (0, import_node_os15.homedir)()) {
47454
47510
  function writeCliUpdatePreferences(preferences, homeDir2 = (0, import_node_os15.homedir)()) {
47455
47511
  const path = cliUpdatePreferencesPath(homeDir2);
47456
47512
  const tempPath = `${path}.${process.pid}.tmp`;
47457
- (0, import_node_fs22.mkdirSync)((0, import_node_path27.dirname)(path), { recursive: true });
47513
+ (0, import_node_fs23.mkdirSync)((0, import_node_path28.dirname)(path), { recursive: true });
47458
47514
  try {
47459
- (0, import_node_fs22.writeFileSync)(tempPath, `${JSON.stringify(preferences, null, 2)}
47515
+ (0, import_node_fs23.writeFileSync)(tempPath, `${JSON.stringify(preferences, null, 2)}
47460
47516
  `, {
47461
47517
  encoding: "utf8",
47462
47518
  mode: 384
47463
47519
  });
47464
- (0, import_node_fs22.renameSync)(tempPath, path);
47520
+ (0, import_node_fs23.renameSync)(tempPath, path);
47465
47521
  } finally {
47466
- (0, import_node_fs22.rmSync)(tempPath, { force: true });
47522
+ (0, import_node_fs23.rmSync)(tempPath, { force: true });
47467
47523
  }
47468
47524
  }
47469
47525
  function setCliAutoUpdateEnabled(enabled, homeDir2 = (0, import_node_os15.homedir)()) {
@@ -47513,14 +47569,14 @@ function consumePendingCliUpdateMessages(homeDir2 = (0, import_node_os15.homedir
47513
47569
 
47514
47570
  // src/cli/commands/update.ts
47515
47571
  var import_node_child_process6 = require("child_process");
47516
- var import_node_fs24 = require("fs");
47572
+ var import_node_fs25 = require("fs");
47517
47573
  var import_node_os16 = require("os");
47518
- var import_node_path29 = require("path");
47574
+ var import_node_path30 = require("path");
47519
47575
 
47520
47576
  // src/cli/install-integrity.ts
47521
47577
  var import_node_module2 = require("module");
47522
- var import_node_fs23 = require("fs");
47523
- var import_node_path28 = require("path");
47578
+ var import_node_fs24 = require("fs");
47579
+ var import_node_path29 = require("path");
47524
47580
  var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
47525
47581
  "dist/cli/index.mjs",
47526
47582
  "dist/index.mjs",
@@ -47539,7 +47595,7 @@ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
47539
47595
  "esbuild/lib/main.js"
47540
47596
  ];
47541
47597
  function safeRelativePath(value) {
47542
- if (typeof value !== "string" || !value || (0, import_node_path28.isAbsolute)(value)) return false;
47598
+ if (typeof value !== "string" || !value || (0, import_node_path29.isAbsolute)(value)) return false;
47543
47599
  const segments = value.split(/[\\/]+/);
47544
47600
  return segments.every(
47545
47601
  (segment) => Boolean(segment) && segment !== "." && segment !== ".."
@@ -47547,25 +47603,25 @@ function safeRelativePath(value) {
47547
47603
  }
47548
47604
  function resolveContainedPath(root, value) {
47549
47605
  if (!safeRelativePath(value)) return null;
47550
- const target = (0, import_node_path28.resolve)(root, value);
47551
- const relativeTarget = (0, import_node_path28.relative)((0, import_node_path28.resolve)(root), target);
47552
- if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path28.isAbsolute)(relativeTarget)) {
47606
+ const target = (0, import_node_path29.resolve)(root, value);
47607
+ const relativeTarget = (0, import_node_path29.relative)((0, import_node_path29.resolve)(root), target);
47608
+ if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path29.isAbsolute)(relativeTarget)) {
47553
47609
  return null;
47554
47610
  }
47555
47611
  return target;
47556
47612
  }
47557
47613
  function parseJson(path) {
47558
- return JSON.parse((0, import_node_fs23.readFileSync)(path, "utf8"));
47614
+ return JSON.parse((0, import_node_fs24.readFileSync)(path, "utf8"));
47559
47615
  }
47560
47616
  function isFile(path) {
47561
47617
  try {
47562
- return (0, import_node_fs23.statSync)(path).isFile();
47618
+ return (0, import_node_fs24.statSync)(path).isFile();
47563
47619
  } catch {
47564
47620
  return false;
47565
47621
  }
47566
47622
  }
47567
47623
  function readManifest(packageRoot) {
47568
- const packageJsonPath = (0, import_node_path28.join)(packageRoot, "package.json");
47624
+ const packageJsonPath = (0, import_node_path29.join)(packageRoot, "package.json");
47569
47625
  let packageJson;
47570
47626
  try {
47571
47627
  packageJson = parseJson(packageJsonPath);
@@ -47573,7 +47629,7 @@ function readManifest(packageRoot) {
47573
47629
  return {
47574
47630
  mode: "manifest",
47575
47631
  invalidReason: `invalid Deepline package metadata: ${error.message}`,
47576
- missing: (0, import_node_fs23.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
47632
+ missing: (0, import_node_fs24.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
47577
47633
  };
47578
47634
  }
47579
47635
  if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
@@ -47639,8 +47695,8 @@ function readManifest(packageRoot) {
47639
47695
  return { mode: "manifest", manifest };
47640
47696
  }
47641
47697
  function inspectSdkSidecarInstall(versionDir) {
47642
- const nodeModulesRoot = (0, import_node_path28.join)(versionDir, "node_modules");
47643
- const packageRoot = (0, import_node_path28.join)(nodeModulesRoot, "deepline");
47698
+ const nodeModulesRoot = (0, import_node_path29.join)(versionDir, "node_modules");
47699
+ const packageRoot = (0, import_node_path29.join)(nodeModulesRoot, "deepline");
47644
47700
  const manifestResult = readManifest(packageRoot);
47645
47701
  if ("invalidReason" in manifestResult) {
47646
47702
  return {
@@ -47651,8 +47707,8 @@ function inspectSdkSidecarInstall(versionDir) {
47651
47707
  };
47652
47708
  }
47653
47709
  const missing = [
47654
- ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path28.join)(packageRoot, path))).map((path) => `deepline/${path}`),
47655
- ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path28.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
47710
+ ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path29.join)(packageRoot, path))).map((path) => `deepline/${path}`),
47711
+ ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path29.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
47656
47712
  ];
47657
47713
  return {
47658
47714
  ok: missing.length === 0,
@@ -47663,7 +47719,7 @@ function inspectSdkSidecarInstall(versionDir) {
47663
47719
  }
47664
47720
  function probeSdkSidecarEsbuild(versionDir) {
47665
47721
  try {
47666
- const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path28.join)(versionDir, "package.json"));
47722
+ const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path29.join)(versionDir, "package.json"));
47667
47723
  const esbuild = requireFromInstall("esbuild");
47668
47724
  if (typeof esbuild.transformSync !== "function") {
47669
47725
  return "esbuild does not export transformSync";
@@ -47732,7 +47788,7 @@ function sidecarStateDir(input2) {
47732
47788
  if (!scope || scope.includes("/") || scope.includes("\\")) {
47733
47789
  return null;
47734
47790
  }
47735
- return (0, import_node_path29.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
47791
+ return (0, import_node_path30.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
47736
47792
  }
47737
47793
  function sidecarRegistryUrl(hostUrl) {
47738
47794
  let url;
@@ -47759,7 +47815,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
47759
47815
  }
47760
47816
  function readOptionalText(path) {
47761
47817
  try {
47762
- return (0, import_node_fs24.readFileSync)(path, "utf8").trim();
47818
+ return (0, import_node_fs25.readFileSync)(path, "utf8").trim();
47763
47819
  } catch {
47764
47820
  return "";
47765
47821
  }
@@ -47767,19 +47823,19 @@ function readOptionalText(path) {
47767
47823
  function resolvePythonSidecarUpdatePlan(options) {
47768
47824
  const stateDir = sidecarStateDir(options);
47769
47825
  if (!stateDir) return null;
47770
- const relativeEntrypoint = (0, import_node_path29.relative)(
47771
- (0, import_node_path29.resolve)(stateDir),
47772
- (0, import_node_path29.resolve)(options.entrypoint)
47826
+ const relativeEntrypoint = (0, import_node_path30.relative)(
47827
+ (0, import_node_path30.resolve)(stateDir),
47828
+ (0, import_node_path30.resolve)(options.entrypoint)
47773
47829
  );
47774
- if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path29.isAbsolute)(relativeEntrypoint)) {
47830
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path30.isAbsolute)(relativeEntrypoint)) {
47775
47831
  return null;
47776
47832
  }
47777
- const installMethod = readOptionalText((0, import_node_path29.join)(stateDir, ".install-method"));
47833
+ const installMethod = readOptionalText((0, import_node_path30.join)(stateDir, ".install-method"));
47778
47834
  if (installMethod !== "python-sidecar") return null;
47779
47835
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
47780
47836
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
47781
- const nodeBin = readOptionalText((0, import_node_path29.join)(stateDir, ".node-bin")) || process.execPath;
47782
- const sidecarPath = readOptionalText((0, import_node_path29.join)(stateDir, ".command-path")) || (0, import_node_path29.join)(
47837
+ const nodeBin = readOptionalText((0, import_node_path30.join)(stateDir, ".node-bin")) || process.execPath;
47838
+ const sidecarPath = readOptionalText((0, import_node_path30.join)(stateDir, ".command-path")) || (0, import_node_path30.join)(
47783
47839
  stateDir,
47784
47840
  "bin",
47785
47841
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
@@ -47787,7 +47843,7 @@ function resolvePythonSidecarUpdatePlan(options) {
47787
47843
  const packageSpec = options.packageSpec || "deepline@latest";
47788
47844
  const npmCommand = "npm";
47789
47845
  const registryUrl = sidecarRegistryUrl(hostUrl);
47790
- const versionDir = (0, import_node_path29.join)(stateDir, "versions", "<version>");
47846
+ const versionDir = (0, import_node_path30.join)(stateDir, "versions", "<version>");
47791
47847
  const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote6(versionDir)} --registry ${shellQuote6(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote6).join(" ")} ${shellQuote6(packageSpec)}`;
47792
47848
  return {
47793
47849
  kind: "python-sidecar",
@@ -47803,16 +47859,16 @@ function resolvePythonSidecarUpdatePlan(options) {
47803
47859
  };
47804
47860
  }
47805
47861
  function findRepoBackedSdkRoot(startPath) {
47806
- let current = (0, import_node_path29.resolve)(startPath);
47862
+ let current = (0, import_node_path30.resolve)(startPath);
47807
47863
  while (true) {
47808
- if ((0, import_node_fs24.existsSync)((0, import_node_path29.join)(current, "package.json")) && (0, import_node_fs24.existsSync)((0, import_node_path29.join)(current, "bin", "deepline-dev.ts"))) {
47809
- const parent2 = (0, import_node_path29.dirname)(current);
47810
- return (0, import_node_path29.basename)(parent2) === "packages" && (0, import_node_path29.basename)(current) === "sdk" ? (0, import_node_path29.dirname)(parent2) : parent2;
47864
+ if ((0, import_node_fs25.existsSync)((0, import_node_path30.join)(current, "package.json")) && (0, import_node_fs25.existsSync)((0, import_node_path30.join)(current, "bin", "deepline-dev.ts"))) {
47865
+ const parent2 = (0, import_node_path30.dirname)(current);
47866
+ return (0, import_node_path30.basename)(parent2) === "packages" && (0, import_node_path30.basename)(current) === "sdk" ? (0, import_node_path30.dirname)(parent2) : parent2;
47811
47867
  }
47812
- if ((0, import_node_fs24.existsSync)((0, import_node_path29.join)(current, "sdk", "package.json")) && (0, import_node_fs24.existsSync)((0, import_node_path29.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
47868
+ if ((0, import_node_fs25.existsSync)((0, import_node_path30.join)(current, "sdk", "package.json")) && (0, import_node_fs25.existsSync)((0, import_node_path30.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
47813
47869
  return current;
47814
47870
  }
47815
- const parent = (0, import_node_path29.dirname)(current);
47871
+ const parent = (0, import_node_path30.dirname)(current);
47816
47872
  if (parent === current) return null;
47817
47873
  current = parent;
47818
47874
  }
@@ -47820,9 +47876,9 @@ function findRepoBackedSdkRoot(startPath) {
47820
47876
  function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
47821
47877
  const normalized = (() => {
47822
47878
  try {
47823
- return (0, import_node_fs24.realpathSync)(entrypoint);
47879
+ return (0, import_node_fs25.realpathSync)(entrypoint);
47824
47880
  } catch {
47825
- return (0, import_node_path29.resolve)(entrypoint);
47881
+ return (0, import_node_path30.resolve)(entrypoint);
47826
47882
  }
47827
47883
  })();
47828
47884
  const parts = normalized.split(/[\\/]+/);
@@ -47837,10 +47893,10 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
47837
47893
  const directPrefix = prefixParts.join("/").toLowerCase();
47838
47894
  const knownWindowsPrefixes = [
47839
47895
  env.npm_config_prefix,
47840
- env.APPDATA ? (0, import_node_path29.join)(env.APPDATA, "npm") : void 0
47841
- ].filter((value) => Boolean(value)).map((value) => (0, import_node_path29.resolve)(value).replace(/\\/g, "/").toLowerCase());
47896
+ env.APPDATA ? (0, import_node_path30.join)(env.APPDATA, "npm") : void 0
47897
+ ].filter((value) => Boolean(value)).map((value) => (0, import_node_path30.resolve)(value).replace(/\\/g, "/").toLowerCase());
47842
47898
  if (!knownWindowsPrefixes.includes(
47843
- (0, import_node_path29.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
47899
+ (0, import_node_path30.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
47844
47900
  )) {
47845
47901
  return null;
47846
47902
  }
@@ -47853,9 +47909,9 @@ function normalizedNpmPrefix(value) {
47853
47909
  if (!trimmed) return null;
47854
47910
  const normalized = (() => {
47855
47911
  try {
47856
- return (0, import_node_fs24.realpathSync)((0, import_node_path29.resolve)(trimmed));
47912
+ return (0, import_node_fs25.realpathSync)((0, import_node_path30.resolve)(trimmed));
47857
47913
  } catch {
47858
- return (0, import_node_path29.resolve)(trimmed);
47914
+ return (0, import_node_path30.resolve)(trimmed);
47859
47915
  }
47860
47916
  })().replace(/\\/g, "/");
47861
47917
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
@@ -47878,9 +47934,9 @@ function resolveNpmGlobalPrefix(env) {
47878
47934
  function isHomebrewFormulaEntrypoint(entrypoint) {
47879
47935
  const normalized = (() => {
47880
47936
  try {
47881
- return (0, import_node_fs24.realpathSync)(entrypoint);
47937
+ return (0, import_node_fs25.realpathSync)(entrypoint);
47882
47938
  } catch {
47883
- return (0, import_node_path29.resolve)(entrypoint);
47939
+ return (0, import_node_path30.resolve)(entrypoint);
47884
47940
  }
47885
47941
  })();
47886
47942
  const parts = normalized.split(/[\\/]+/);
@@ -47890,8 +47946,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
47890
47946
  function resolveUpdatePlan(options = {}) {
47891
47947
  const env = options.env ?? process.env;
47892
47948
  const homeDir2 = options.homeDir ?? (0, import_node_os16.homedir)();
47893
- const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path29.resolve)(process.argv[1]) : "");
47894
- const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path29.dirname)(entrypoint)) : null;
47949
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path30.resolve)(process.argv[1]) : "");
47950
+ const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path30.dirname)(entrypoint)) : null;
47895
47951
  if (sourceRoot) {
47896
47952
  return {
47897
47953
  kind: "source",
@@ -47944,9 +48000,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
47944
48000
  function autoUpdateFailurePath(plan) {
47945
48001
  if (plan.kind === "source" || plan.kind === "homebrew") return null;
47946
48002
  if (plan.kind === "python-sidecar") {
47947
- return (0, import_node_path29.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
48003
+ return (0, import_node_path30.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
47948
48004
  }
47949
- return (0, import_node_path29.join)(
48005
+ return (0, import_node_path30.join)(
47950
48006
  (0, import_node_os16.homedir)(),
47951
48007
  ".local",
47952
48008
  "deepline",
@@ -47964,7 +48020,7 @@ function readAutoUpdateFailure(plan) {
47964
48020
  if (!path) return null;
47965
48021
  try {
47966
48022
  const parsed = JSON.parse(
47967
- (0, import_node_fs24.readFileSync)(path, "utf8")
48023
+ (0, import_node_fs25.readFileSync)(path, "utf8")
47968
48024
  );
47969
48025
  if ((parsed.kind === "npm-global" || parsed.kind === "python-sidecar") && typeof parsed.packageSpec === "string" && typeof parsed.failedAt === "string" && typeof parsed.exitCode === "number" && typeof parsed.manualCommand === "string") {
47970
48026
  return parsed;
@@ -47985,8 +48041,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
47985
48041
  manualCommand: plan.manualCommand
47986
48042
  };
47987
48043
  try {
47988
- (0, import_node_fs24.mkdirSync)((0, import_node_path29.dirname)(path), { recursive: true });
47989
- (0, import_node_fs24.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
48044
+ (0, import_node_fs25.mkdirSync)((0, import_node_path30.dirname)(path), { recursive: true });
48045
+ (0, import_node_fs25.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
47990
48046
  `, "utf8");
47991
48047
  } catch {
47992
48048
  }
@@ -47995,7 +48051,7 @@ function clearAutoUpdateFailure(plan) {
47995
48051
  const path = autoUpdateFailurePath(plan);
47996
48052
  if (!path) return;
47997
48053
  try {
47998
- (0, import_node_fs24.unlinkSync)(path);
48054
+ (0, import_node_fs25.unlinkSync)(path);
47999
48055
  } catch {
48000
48056
  }
48001
48057
  }
@@ -48033,7 +48089,7 @@ function safeVersionSegment(value) {
48033
48089
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
48034
48090
  }
48035
48091
  function entryPathInVersionDir(versionDir) {
48036
- return (0, import_node_path29.join)(
48092
+ return (0, import_node_path30.join)(
48037
48093
  versionDir,
48038
48094
  "node_modules",
48039
48095
  "deepline",
@@ -48043,14 +48099,14 @@ function entryPathInVersionDir(versionDir) {
48043
48099
  );
48044
48100
  }
48045
48101
  function installedPackageVersion(versionDir) {
48046
- const packageJsonPath = (0, import_node_path29.join)(
48102
+ const packageJsonPath = (0, import_node_path30.join)(
48047
48103
  versionDir,
48048
48104
  "node_modules",
48049
48105
  "deepline",
48050
48106
  "package.json"
48051
48107
  );
48052
48108
  try {
48053
- const parsed = JSON.parse((0, import_node_fs24.readFileSync)(packageJsonPath, "utf8"));
48109
+ const parsed = JSON.parse((0, import_node_fs25.readFileSync)(packageJsonPath, "utf8"));
48054
48110
  return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
48055
48111
  } catch {
48056
48112
  return "";
@@ -48165,20 +48221,20 @@ async function runNpmInstallWithRegistryFallback(input2) {
48165
48221
  return first.exitCode;
48166
48222
  }
48167
48223
  function writeSidecarLauncher(input2) {
48168
- (0, import_node_fs24.mkdirSync)((0, import_node_path29.dirname)(input2.path), { recursive: true });
48169
- const packageRoot = (0, import_node_path29.dirname)((0, import_node_path29.dirname)((0, import_node_path29.dirname)(input2.entryPath)));
48170
- const versionDir = (0, import_node_path29.dirname)((0, import_node_path29.dirname)(packageRoot));
48224
+ (0, import_node_fs25.mkdirSync)((0, import_node_path30.dirname)(input2.path), { recursive: true });
48225
+ const packageRoot = (0, import_node_path30.dirname)((0, import_node_path30.dirname)((0, import_node_path30.dirname)(input2.entryPath)));
48226
+ const versionDir = (0, import_node_path30.dirname)((0, import_node_path30.dirname)(packageRoot));
48171
48227
  const esbuildProbe = "const {createRequire}=require('node:module');const path=require('node:path');const req=createRequire(path.join(process.argv[1],'package.json'));const result=req('esbuild').transformSync('const value: number = 1;',{loader:'ts'});if(!result||typeof result.code!=='string')process.exit(3);";
48172
48228
  const criticalPaths = [
48173
48229
  ...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
48174
- (path) => (0, import_node_path29.join)(packageRoot, path)
48230
+ (path) => (0, import_node_path30.join)(packageRoot, path)
48175
48231
  ),
48176
48232
  ...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
48177
- (path) => (0, import_node_path29.join)(versionDir, "node_modules", path)
48233
+ (path) => (0, import_node_path30.join)(versionDir, "node_modules", path)
48178
48234
  )
48179
48235
  ];
48180
48236
  if (process.platform === "win32") {
48181
- (0, import_node_fs24.writeFileSync)(
48237
+ (0, import_node_fs25.writeFileSync)(
48182
48238
  input2.path,
48183
48239
  [
48184
48240
  `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
@@ -48201,7 +48257,7 @@ function writeSidecarLauncher(input2) {
48201
48257
  );
48202
48258
  return;
48203
48259
  }
48204
- (0, import_node_fs24.writeFileSync)(
48260
+ (0, import_node_fs25.writeFileSync)(
48205
48261
  input2.path,
48206
48262
  [
48207
48263
  "#!/usr/bin/env sh",
@@ -48228,17 +48284,17 @@ function writeSidecarLauncher(input2) {
48228
48284
  );
48229
48285
  }
48230
48286
  async function runPythonSidecarUpdatePlan(plan) {
48231
- const versionsDir = (0, import_node_path29.join)(plan.stateDir, "versions");
48232
- const tempDir = (0, import_node_path29.join)(
48287
+ const versionsDir = (0, import_node_path30.join)(plan.stateDir, "versions");
48288
+ const tempDir = (0, import_node_path30.join)(
48233
48289
  versionsDir,
48234
48290
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
48235
48291
  );
48236
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48237
- (0, import_node_fs24.mkdirSync)(tempDir, { recursive: true });
48238
- (0, import_node_fs24.writeFileSync)((0, import_node_path29.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
48292
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48293
+ (0, import_node_fs25.mkdirSync)(tempDir, { recursive: true });
48294
+ (0, import_node_fs25.writeFileSync)((0, import_node_path30.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
48239
48295
  const env = {
48240
48296
  ...process.env,
48241
- PATH: `${(0, import_node_path29.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
48297
+ PATH: `${(0, import_node_path30.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
48242
48298
  };
48243
48299
  const installResult = await runCommand(
48244
48300
  plan.npmCommand,
@@ -48255,7 +48311,7 @@ async function runPythonSidecarUpdatePlan(plan) {
48255
48311
  );
48256
48312
  const installExitCode = installResult.exitCode;
48257
48313
  if (installExitCode !== 0) {
48258
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48314
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48259
48315
  return installExitCode;
48260
48316
  }
48261
48317
  const installedVersion = installedPackageVersion(tempDir);
@@ -48263,7 +48319,7 @@ async function runPythonSidecarUpdatePlan(plan) {
48263
48319
  process.stderr.write(
48264
48320
  "Updated Deepline SDK package did not report a version.\n"
48265
48321
  );
48266
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48322
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48267
48323
  return 1;
48268
48324
  }
48269
48325
  const stagedFailure = sidecarInstallFailure(tempDir);
@@ -48272,32 +48328,32 @@ async function runPythonSidecarUpdatePlan(plan) {
48272
48328
  `Updated Deepline SDK package is incomplete: ${stagedFailure}.
48273
48329
  `
48274
48330
  );
48275
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48331
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48276
48332
  return 1;
48277
48333
  }
48278
- const finalDir = (0, import_node_path29.join)(versionsDir, installedVersion);
48334
+ const finalDir = (0, import_node_path30.join)(versionsDir, installedVersion);
48279
48335
  const finalEntryPath = entryPathInVersionDir(finalDir);
48280
48336
  const finalFailure = sidecarInstallFailure(finalDir);
48281
48337
  let backupDir = null;
48282
48338
  if (!finalFailure) {
48283
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48339
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48284
48340
  } else {
48285
48341
  let shouldPublishTemp = true;
48286
- if ((0, import_node_fs24.existsSync)(finalDir)) {
48287
- backupDir = (0, import_node_path29.join)(
48342
+ if ((0, import_node_fs25.existsSync)(finalDir)) {
48343
+ backupDir = (0, import_node_path30.join)(
48288
48344
  versionsDir,
48289
48345
  `.backup-${installedVersion}-${process.pid}-${Date.now()}`
48290
48346
  );
48291
48347
  try {
48292
- (0, import_node_fs24.renameSync)(finalDir, backupDir);
48348
+ (0, import_node_fs25.renameSync)(finalDir, backupDir);
48293
48349
  } catch (error) {
48294
48350
  const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
48295
48351
  if (!concurrentlyPublishedFailure) {
48296
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48352
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48297
48353
  backupDir = null;
48298
48354
  shouldPublishTemp = false;
48299
48355
  } else {
48300
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48356
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48301
48357
  process.stderr.write(
48302
48358
  `Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
48303
48359
  `
@@ -48308,18 +48364,18 @@ async function runPythonSidecarUpdatePlan(plan) {
48308
48364
  }
48309
48365
  if (shouldPublishTemp) {
48310
48366
  try {
48311
- (0, import_node_fs24.renameSync)(tempDir, finalDir);
48367
+ (0, import_node_fs25.renameSync)(tempDir, finalDir);
48312
48368
  } catch (error) {
48313
- (0, import_node_fs24.rmSync)(tempDir, { recursive: true, force: true });
48369
+ (0, import_node_fs25.rmSync)(tempDir, { recursive: true, force: true });
48314
48370
  const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
48315
48371
  if (!concurrentlyPublishedFailure) {
48316
- if (backupDir) (0, import_node_fs24.rmSync)(backupDir, { recursive: true, force: true });
48372
+ if (backupDir) (0, import_node_fs25.rmSync)(backupDir, { recursive: true, force: true });
48317
48373
  backupDir = null;
48318
48374
  } else {
48319
48375
  let restoreFailure = "";
48320
- if (backupDir && (0, import_node_fs24.existsSync)(backupDir) && !(0, import_node_fs24.existsSync)(finalDir)) {
48376
+ if (backupDir && (0, import_node_fs25.existsSync)(backupDir) && !(0, import_node_fs25.existsSync)(finalDir)) {
48321
48377
  try {
48322
- (0, import_node_fs24.renameSync)(backupDir, finalDir);
48378
+ (0, import_node_fs25.renameSync)(backupDir, finalDir);
48323
48379
  backupDir = null;
48324
48380
  } catch (restoreError) {
48325
48381
  restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
@@ -48336,10 +48392,10 @@ async function runPythonSidecarUpdatePlan(plan) {
48336
48392
  }
48337
48393
  const publishedFailure = sidecarStructureFailure(finalDir);
48338
48394
  if (publishedFailure) {
48339
- if (backupDir && (0, import_node_fs24.existsSync)(backupDir)) {
48340
- (0, import_node_fs24.rmSync)(finalDir, { recursive: true, force: true });
48395
+ if (backupDir && (0, import_node_fs25.existsSync)(backupDir)) {
48396
+ (0, import_node_fs25.rmSync)(finalDir, { recursive: true, force: true });
48341
48397
  try {
48342
- (0, import_node_fs24.renameSync)(backupDir, finalDir);
48398
+ (0, import_node_fs25.renameSync)(backupDir, finalDir);
48343
48399
  backupDir = null;
48344
48400
  } catch {
48345
48401
  }
@@ -48350,7 +48406,7 @@ async function runPythonSidecarUpdatePlan(plan) {
48350
48406
  );
48351
48407
  return 1;
48352
48408
  }
48353
- if (backupDir) (0, import_node_fs24.rmSync)(backupDir, { recursive: true, force: true });
48409
+ if (backupDir) (0, import_node_fs25.rmSync)(backupDir, { recursive: true, force: true });
48354
48410
  writeSidecarLauncher({
48355
48411
  path: plan.sidecarPath,
48356
48412
  hostUrl: plan.hostUrl,
@@ -48358,28 +48414,28 @@ async function runPythonSidecarUpdatePlan(plan) {
48358
48414
  nodeBin: plan.nodeBin,
48359
48415
  entryPath: finalEntryPath
48360
48416
  });
48361
- (0, import_node_fs24.writeFileSync)(
48362
- (0, import_node_path29.join)(plan.stateDir, ".version"),
48417
+ (0, import_node_fs25.writeFileSync)(
48418
+ (0, import_node_path30.join)(plan.stateDir, ".version"),
48363
48419
  `${installedVersion}
48364
48420
  `,
48365
48421
  "utf8"
48366
48422
  );
48367
- (0, import_node_fs24.writeFileSync)(
48368
- (0, import_node_path29.join)(plan.stateDir, ".install-method"),
48423
+ (0, import_node_fs25.writeFileSync)(
48424
+ (0, import_node_path30.join)(plan.stateDir, ".install-method"),
48369
48425
  "python-sidecar\n",
48370
48426
  "utf8"
48371
48427
  );
48372
- (0, import_node_fs24.writeFileSync)(
48373
- (0, import_node_path29.join)(plan.stateDir, ".command-path"),
48428
+ (0, import_node_fs25.writeFileSync)(
48429
+ (0, import_node_path30.join)(plan.stateDir, ".command-path"),
48374
48430
  `${plan.sidecarPath}
48375
48431
  `,
48376
48432
  "utf8"
48377
48433
  );
48378
- (0, import_node_fs24.writeFileSync)((0, import_node_path29.join)(plan.stateDir, ".runner"), "node\n", "utf8");
48379
- (0, import_node_fs24.writeFileSync)((0, import_node_path29.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
48434
+ (0, import_node_fs25.writeFileSync)((0, import_node_path30.join)(plan.stateDir, ".runner"), "node\n", "utf8");
48435
+ (0, import_node_fs25.writeFileSync)((0, import_node_path30.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
48380
48436
  `, "utf8");
48381
- (0, import_node_fs24.writeFileSync)(
48382
- (0, import_node_path29.join)(plan.stateDir, ".entry-path"),
48437
+ (0, import_node_fs25.writeFileSync)(
48438
+ (0, import_node_path30.join)(plan.stateDir, ".entry-path"),
48383
48439
  `${finalEntryPath}
48384
48440
  `,
48385
48441
  "utf8"
@@ -49090,7 +49146,7 @@ function collectEvent(value, previous = []) {
49090
49146
  function collectNotificationTarget(value, previous = []) {
49091
49147
  return [...previous, value];
49092
49148
  }
49093
- async function readNotificationConfigurationChange(source, read2 = (path, encoding) => (0, import_node_fs25.readFileSync)(path, encoding)) {
49149
+ async function readNotificationConfigurationChange(source, read2 = (path, encoding) => (0, import_node_fs26.readFileSync)(path, encoding)) {
49094
49150
  const label = source === "-" ? "stdin" : source;
49095
49151
  let text;
49096
49152
  try {
@@ -49429,9 +49485,9 @@ Examples:
49429
49485
 
49430
49486
  // src/cli/commands/tools.ts
49431
49487
  var import_commander5 = require("commander");
49432
- var import_node_fs28 = require("fs");
49488
+ var import_node_fs29 = require("fs");
49433
49489
  var import_node_os18 = require("os");
49434
- var import_node_path32 = require("path");
49490
+ var import_node_path33 = require("path");
49435
49491
 
49436
49492
  // src/cli/tool-call-recovery.ts
49437
49493
  var import_node_crypto12 = require("crypto");
@@ -49453,8 +49509,8 @@ function stableStringify(value) {
49453
49509
  }
49454
49510
 
49455
49511
  // src/cli/tool-call-recovery.ts
49456
- var import_node_fs26 = require("fs");
49457
- var import_node_path30 = require("path");
49512
+ var import_node_fs27 = require("fs");
49513
+ var import_node_path31 = require("path");
49458
49514
  var ToolCallRecovery = class _ToolCallRecovery {
49459
49515
  constructor(idempotencyKey, path) {
49460
49516
  this.idempotencyKey = idempotencyKey;
@@ -49474,36 +49530,36 @@ var ToolCallRecovery = class _ToolCallRecovery {
49474
49530
  function pendingToolExecutionPath(input2) {
49475
49531
  const config = resolveConfig();
49476
49532
  const fingerprint = (0, import_node_crypto12.createHash)("sha256").update(config.baseUrl).update("\0").update((0, import_node_crypto12.createHash)("sha256").update(config.apiKey).digest("hex")).update("\0").update(input2.toolId).update("\0").update(stableStringify(input2.params)).update("\0").update(input2.responseIntent).digest("hex");
49477
- return (0, import_node_path30.join)(
49533
+ return (0, import_node_path31.join)(
49478
49534
  sdkCliStateDirPath(config.baseUrl),
49479
49535
  `pending-tool-execution-${fingerprint}.json`
49480
49536
  );
49481
49537
  }
49482
49538
  function loadOrCreatePendingToolExecution(path) {
49483
- (0, import_node_fs26.mkdirSync)((0, import_node_path30.dirname)(path), { recursive: true });
49484
- if ((0, import_node_fs26.existsSync)(path)) {
49539
+ (0, import_node_fs27.mkdirSync)((0, import_node_path31.dirname)(path), { recursive: true });
49540
+ if ((0, import_node_fs27.existsSync)(path)) {
49485
49541
  return readPendingToolExecution(path);
49486
49542
  }
49487
49543
  const idempotencyKey = (0, import_node_crypto12.randomUUID)();
49488
49544
  const temporaryPath = `${path}.${process.pid}.${(0, import_node_crypto12.randomUUID)()}.tmp`;
49489
49545
  try {
49490
- (0, import_node_fs26.writeFileSync)(temporaryPath, `${JSON.stringify({ idempotencyKey })}
49546
+ (0, import_node_fs27.writeFileSync)(temporaryPath, `${JSON.stringify({ idempotencyKey })}
49491
49547
  `, {
49492
49548
  encoding: "utf8",
49493
49549
  flag: "wx",
49494
49550
  mode: 384
49495
49551
  });
49496
- (0, import_node_fs26.linkSync)(temporaryPath, path);
49552
+ (0, import_node_fs27.linkSync)(temporaryPath, path);
49497
49553
  return idempotencyKey;
49498
49554
  } catch (error) {
49499
49555
  if (error.code !== "EEXIST") throw error;
49500
49556
  return readPendingToolExecution(path);
49501
49557
  } finally {
49502
- if ((0, import_node_fs26.existsSync)(temporaryPath)) (0, import_node_fs26.unlinkSync)(temporaryPath);
49558
+ if ((0, import_node_fs27.existsSync)(temporaryPath)) (0, import_node_fs27.unlinkSync)(temporaryPath);
49503
49559
  }
49504
49560
  }
49505
49561
  function readPendingToolExecution(path) {
49506
- const saved = JSON.parse((0, import_node_fs26.readFileSync)(path, "utf8"));
49562
+ const saved = JSON.parse((0, import_node_fs27.readFileSync)(path, "utf8"));
49507
49563
  if (typeof saved.idempotencyKey !== "string") {
49508
49564
  throw new Error(
49509
49565
  `Cannot resume the saved tool execution at ${path}: invalid recovery key.`
@@ -49512,7 +49568,7 @@ function readPendingToolExecution(path) {
49512
49568
  return saved.idempotencyKey;
49513
49569
  }
49514
49570
  async function completePendingToolExecution(path, idempotencyKey) {
49515
- if (!path || !idempotencyKey || !(0, import_node_fs26.existsSync)(path)) return;
49571
+ if (!path || !idempotencyKey || !(0, import_node_fs27.existsSync)(path)) return;
49516
49572
  await new Promise((resolve22, reject) => {
49517
49573
  const onError = (error) => {
49518
49574
  process.stdout.off("error", onError);
@@ -49530,16 +49586,16 @@ async function completePendingToolExecution(path, idempotencyKey) {
49530
49586
  });
49531
49587
  try {
49532
49588
  if (readPendingToolExecution(path) !== idempotencyKey) return;
49533
- (0, import_node_fs26.unlinkSync)(path);
49589
+ (0, import_node_fs27.unlinkSync)(path);
49534
49590
  } catch (error) {
49535
49591
  if (error.code !== "ENOENT") throw error;
49536
49592
  }
49537
49593
  }
49538
49594
 
49539
49595
  // src/tool-output.ts
49540
- var import_node_fs27 = require("fs");
49596
+ var import_node_fs28 = require("fs");
49541
49597
  var import_node_os17 = require("os");
49542
- var import_node_path31 = require("path");
49598
+ var import_node_path32 = require("path");
49543
49599
  function isPlainObject(value) {
49544
49600
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
49545
49601
  }
@@ -49666,19 +49722,19 @@ function projectRowOutput(conversion) {
49666
49722
  };
49667
49723
  }
49668
49724
  function ensureOutputDir() {
49669
- const outputDir = (0, import_node_path31.join)((0, import_node_os17.homedir)(), ".local", "share", "deepline", "data");
49670
- (0, import_node_fs27.mkdirSync)(outputDir, { recursive: true });
49725
+ const outputDir = (0, import_node_path32.join)((0, import_node_os17.homedir)(), ".local", "share", "deepline", "data");
49726
+ (0, import_node_fs28.mkdirSync)(outputDir, { recursive: true });
49671
49727
  return outputDir;
49672
49728
  }
49673
49729
  function writeJsonOutputFile(payload, stem) {
49674
49730
  const outputDir = ensureOutputDir();
49675
- const outputPath = (0, import_node_path31.join)(outputDir, `${stem}_${Date.now()}.json`);
49676
- (0, import_node_fs27.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
49731
+ const outputPath = (0, import_node_path32.join)(outputDir, `${stem}_${Date.now()}.json`);
49732
+ (0, import_node_fs28.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
49677
49733
  return outputPath;
49678
49734
  }
49679
49735
  function writeCsvOutputFile(rows, stem, options) {
49680
- const outputPath = options?.outPath ? options.outPath : (0, import_node_path31.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
49681
- (0, import_node_fs27.mkdirSync)((0, import_node_path31.dirname)(outputPath), { recursive: true });
49736
+ const outputPath = options?.outPath ? options.outPath : (0, import_node_path32.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
49737
+ (0, import_node_fs28.mkdirSync)((0, import_node_path32.dirname)(outputPath), { recursive: true });
49682
49738
  const columns = columnsForRows(rows);
49683
49739
  const escapeCell = (value) => {
49684
49740
  const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
@@ -49687,19 +49743,19 @@ function writeCsvOutputFile(rows, stem, options) {
49687
49743
  }
49688
49744
  return normalized;
49689
49745
  };
49690
- const fd = (0, import_node_fs27.openSync)(outputPath, "w");
49746
+ const fd = (0, import_node_fs28.openSync)(outputPath, "w");
49691
49747
  try {
49692
- (0, import_node_fs27.writeSync)(fd, `${columns.map(escapeCell).join(",")}
49748
+ (0, import_node_fs28.writeSync)(fd, `${columns.map(escapeCell).join(",")}
49693
49749
  `);
49694
49750
  for (const row of rows) {
49695
- (0, import_node_fs27.writeSync)(
49751
+ (0, import_node_fs28.writeSync)(
49696
49752
  fd,
49697
49753
  `${columns.map((column) => escapeCell(row[column])).join(",")}
49698
49754
  `
49699
49755
  );
49700
49756
  }
49701
49757
  } finally {
49702
- (0, import_node_fs27.closeSync)(fd);
49758
+ (0, import_node_fs28.closeSync)(fd);
49703
49759
  }
49704
49760
  const previewRows = rows.slice(0, 5);
49705
49761
  const previewColumns = columns.slice(0, 5);
@@ -49980,7 +50036,7 @@ function zeroMatchToolGuidance(options) {
49980
50036
  ...query ? [
49981
50037
  {
49982
50038
  label: "Use ranked semantic search for intent-style queries",
49983
- command: `deepline tools search -- ${shellCommandArg(query)}`
50039
+ command: `deepline search --type tools -- ${shellCommandArg(query)}`
49984
50040
  },
49985
50041
  ...options.mode === "all" ? [
49986
50042
  {
@@ -49996,7 +50052,7 @@ function zeroMatchToolGuidance(options) {
49996
50052
  ...query ? [
49997
50053
  {
49998
50054
  label: "Search composed Deepline plays separately",
49999
- command: `deepline plays search -- ${shellCommandArg(query)}`
50055
+ command: `deepline search --type prebuilts -- ${shellCommandArg(query)}`
50000
50056
  }
50001
50057
  ] : []
50002
50058
  ];
@@ -50273,62 +50329,6 @@ async function listTools(category, options = {}) {
50273
50329
  }
50274
50330
  return listToolCategories(emitJson, compact);
50275
50331
  }
50276
- var SEARCH_REF_TTL_MS = 15 * 6e4;
50277
- function lastSearchPath() {
50278
- return (0, import_node_path32.join)(sdkCliStateDirPath(resolveConfig().baseUrl), "last-search.json");
50279
- }
50280
- function rememberSearchRef(searchRef) {
50281
- try {
50282
- (0, import_node_fs28.mkdirSync)((0, import_node_path32.dirname)(lastSearchPath()), { recursive: true });
50283
- (0, import_node_fs28.writeFileSync)(
50284
- lastSearchPath(),
50285
- JSON.stringify({ searchRef, at: Date.now() }),
50286
- { mode: 384 }
50287
- );
50288
- } catch {
50289
- }
50290
- }
50291
- function recentSearchRef() {
50292
- try {
50293
- const saved = JSON.parse((0, import_node_fs28.readFileSync)(lastSearchPath(), "utf8"));
50294
- return typeof saved.searchRef === "string" && typeof saved.at === "number" && Date.now() - saved.at < SEARCH_REF_TTL_MS ? saved.searchRef : void 0;
50295
- } catch {
50296
- return void 0;
50297
- }
50298
- }
50299
- async function searchTools(queryInput, options = {}) {
50300
- const query = queryInput?.trim() ?? "";
50301
- const hasStructuredSearch = Boolean(
50302
- options.categories?.trim() || options.searchTerms?.trim()
50303
- );
50304
- if (!query && !hasStructuredSearch) {
50305
- console.error(
50306
- "Usage: deepline tools search [query] --categories <categories> [--search_terms <terms>] [--json]"
50307
- );
50308
- return 1;
50309
- }
50310
- const client2 = new DeeplineClient();
50311
- const { search_ref: searchRef, ...result } = await client2.searchTools({
50312
- query,
50313
- categories: options.categories,
50314
- searchTerms: options.searchTerms,
50315
- task: options.task,
50316
- limit: options.limit,
50317
- offset: options.offset,
50318
- searchMode: options.searchMode,
50319
- includeSearchDebug: options.includeSearchDebug
50320
- });
50321
- if (searchRef) rememberSearchRef(searchRef);
50322
- const shouldCompact = options.compact || !options.json;
50323
- const payload = shouldCompact && Array.isArray(result.tools) ? {
50324
- ...result,
50325
- tools: result.tools.slice(0, 8).map(compactTool)
50326
- } : result;
50327
- printCommandEnvelope(payload, {
50328
- json: options.json === true
50329
- });
50330
- return 0;
50331
- }
50332
50332
  async function grepTools(queryInput, options = {}) {
50333
50333
  const query = queryInput.trim();
50334
50334
  if (!query) {
@@ -50464,7 +50464,7 @@ function playReferenceForTool(tool) {
50464
50464
  return null;
50465
50465
  }
50466
50466
  function playSearchCommandForToolId(toolId) {
50467
- return `deepline plays search ${JSON.stringify(toolId.replace(/_/g, " "))} --json`;
50467
+ return `deepline search --type prebuilts ${JSON.stringify(toolId.replace(/_/g, " "))} --json`;
50468
50468
  }
50469
50469
  function playRunCommandForTool(tool, toolId, input2) {
50470
50470
  const playReference = playReferenceForTool(tool);
@@ -50478,7 +50478,7 @@ function playLikeToolExecuteErrorMessage(toolId, tool) {
50478
50478
  return [
50479
50479
  `${toolId} is a workflow/play entry, not an atomic provider tool.`,
50480
50480
  nextStep,
50481
- 'Or search provider tools only with: deepline tools search "<query>" --json'
50481
+ 'Or search provider tools only with: deepline search --type tools "<query>" --json'
50482
50482
  ].join("\n");
50483
50483
  }
50484
50484
  function printPlayLikeToolExecuteError(toolId, tool) {
@@ -50495,7 +50495,7 @@ Concepts:
50495
50495
  through the plays namespace.
50496
50496
 
50497
50497
  Common commands:
50498
- deepline tools search email --json
50498
+ deepline search --type tools email --json
50499
50499
  deepline tools describe hunter_email_verifier --json
50500
50500
  deepline tools describe hunter_email_verifier --pricing-only --json
50501
50501
  deepline tools execute hunter_email_verifier --input '{"email":"a@b.com"}'
@@ -50528,7 +50528,7 @@ Examples:
50528
50528
  deepline tools list email_finder
50529
50529
  deepline tools list email_finder --json
50530
50530
  deepline tools list --categories email_finder --json
50531
- deepline tools search email --json
50531
+ deepline search --type tools email --json
50532
50532
  `
50533
50533
  ).option(
50534
50534
  "--categories <categories>",
@@ -50540,58 +50540,7 @@ Examples:
50540
50540
  json: Boolean(options.json)
50541
50541
  });
50542
50542
  });
50543
- const addToolSearchCommand = (command) => command.description(
50544
- "Search available tools by intent query or structured filters."
50545
- ).addHelpText(
50546
- "after",
50547
- `
50548
- Notes:
50549
- Ranked discovery for atomic provider/API operations. Results include tool ids
50550
- that can be passed to deepline tools describe or deepline tools execute.
50551
- Provide a query, or omit it only when --categories and/or --search_terms is
50552
- supplied. Providing neither is a usage error. Both filters accept
50553
- comma-separated values. Use --limit and --offset to page through ranked
50554
- results (limit 1-50, offset is zero-based); JSON includes next_offset.
50555
- Pass --task with one sentence on what you are trying to accomplish right
50556
- now: the input you have and the result you need, not a restatement of the
50557
- query. It materially improves ranking, especially for short queries.
50558
- Use a provider name in the query; --prefix is not a supported option.
50559
- The grep alias is the same ranked retrieval surface with a more literal name
50560
- for agents that are filtering a registry rather than choosing a workflow.
50561
- Search prints a readable result list by default, piped or not, and that is
50562
- the recommended form. Pass --json only when a program parses the result.
50563
-
50564
- Examples:
50565
- deepline tools search email --limit 10
50566
- deepline tools search email --limit 10 --offset 10
50567
- deepline tools search linkedin --task "I have 200 LinkedIn profile URLs and need each person's current title and company"
50568
- deepline tools search --categories company_search --search_terms "investors,funding"
50569
- deepline tools grep "company enrichment" --categories enrichment --json
50570
- deepline tools search verifier --search-mode v2 --json
50571
- `
50572
- ).option(
50573
- "--categories <categories>",
50574
- "Comma-separated categories; may be used without a query"
50575
- ).option(
50576
- "--search_terms <terms>",
50577
- "Comma-separated structured search terms; may be used without a query"
50578
- ).option("--search-terms <terms>", "Alias for --search_terms").option(
50579
- "--task <sentence>",
50580
- "What you are trying to accomplish: input you have -> result you need"
50581
- ).option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--compact", "Drop verbose fields from JSON output").option("--json", "Emit JSON output instead of the readable default").action(async (query, options) => {
50582
- process.exitCode = await searchTools(query, {
50583
- json: options.json,
50584
- compact: options.compact,
50585
- limit: options.limit !== void 0 ? Number.parseInt(options.limit, 10) : void 0,
50586
- offset: options.offset !== void 0 ? Number.parseInt(options.offset, 10) : void 0,
50587
- categories: options.categories,
50588
- searchTerms: options.searchTerms ?? options.search_terms,
50589
- task: options.task,
50590
- searchMode: options.searchMode === "v1" || options.searchMode === "v2" ? options.searchMode : void 0,
50591
- includeSearchDebug: Boolean(options.includeSearchDebug)
50592
- });
50593
- });
50594
- addToolSearchCommand(tools.command("search [query]"));
50543
+ registerDeprecatedSearchCommand(tools, () => ["tools", "monitors"]);
50595
50544
  tools.command("grep <query>").description(
50596
50545
  "Literal grep over tool ids, descriptions, categories, and input fields."
50597
50546
  ).addHelpText(
@@ -51982,11 +51931,11 @@ function normalizeOutputFormat(raw) {
51982
51931
  }
51983
51932
  function resolveAtFilePath(rawPath) {
51984
51933
  const trimmed = rawPath.trim();
51985
- const resolved = (0, import_node_path32.resolve)(trimmed);
51986
- if ((0, import_node_fs28.existsSync)(resolved)) return resolved;
51934
+ const resolved = (0, import_node_path33.resolve)(trimmed);
51935
+ if ((0, import_node_fs29.existsSync)(resolved)) return resolved;
51987
51936
  if (process.platform !== "win32" && trimmed.includes("\\")) {
51988
- const normalized = (0, import_node_path32.resolve)(trimmed.replace(/\\/g, "/"));
51989
- if ((0, import_node_fs28.existsSync)(normalized)) return normalized;
51937
+ const normalized = (0, import_node_path33.resolve)(trimmed.replace(/\\/g, "/"));
51938
+ if ((0, import_node_fs29.existsSync)(normalized)) return normalized;
51990
51939
  }
51991
51940
  return resolved;
51992
51941
  }
@@ -51997,7 +51946,7 @@ function readJsonArgument(raw, flagName) {
51997
51946
  throw new Error(`Invalid ${flagName} value: empty @file path.`);
51998
51947
  }
51999
51948
  try {
52000
- return (0, import_node_fs28.readFileSync)(resolveAtFilePath(filePath), "utf8").replace(
51949
+ return (0, import_node_fs29.readFileSync)(resolveAtFilePath(filePath), "utf8").replace(
52001
51950
  /^\uFEFF/,
52002
51951
  ""
52003
51952
  );
@@ -52098,7 +52047,7 @@ function parseExecuteOptions(args) {
52098
52047
  continue;
52099
52048
  }
52100
52049
  if ((arg === "--out" || arg === "-o") && args[index + 1]) {
52101
- outPath = (0, import_node_path32.resolve)(args[++index]);
52050
+ outPath = (0, import_node_path33.resolve)(args[++index]);
52102
52051
  continue;
52103
52052
  }
52104
52053
  throw new Error(`Unknown option: ${arg}`);
@@ -52156,9 +52105,9 @@ function starterScriptJson(script) {
52156
52105
  function seedToolListScript(input2) {
52157
52106
  const stem = safeFileStem(input2.toolId);
52158
52107
  const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
52159
- const scriptDir = (0, import_node_fs28.mkdtempSync)((0, import_node_path32.join)((0, import_node_os18.tmpdir)(), "deepline-workflow-seed-"));
52160
- (0, import_node_fs28.chmodSync)(scriptDir, 448);
52161
- const scriptPath = (0, import_node_path32.join)(scriptDir, fileName);
52108
+ const scriptDir = (0, import_node_fs29.mkdtempSync)((0, import_node_path33.join)((0, import_node_os18.tmpdir)(), "deepline-workflow-seed-"));
52109
+ (0, import_node_fs29.chmodSync)(scriptDir, 448);
52110
+ const scriptPath = (0, import_node_path33.join)(scriptDir, fileName);
52162
52111
  const projectDir = `deepline/projects/${stem}-workflow`;
52163
52112
  const playName = `${stem}-workflow`;
52164
52113
  const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
@@ -52201,7 +52150,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
52201
52150
  description: ${JSON.stringify(`Seed ${input2.toolId} rows into a Deepline workflow-ready dataset.`)},
52202
52151
  });
52203
52152
  `;
52204
- (0, import_node_fs28.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
52153
+ (0, import_node_fs29.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
52205
52154
  return {
52206
52155
  path: scriptPath,
52207
52156
  sourceCode: script,
@@ -52671,7 +52620,7 @@ Examples:
52671
52620
 
52672
52621
  // src/cli/commands/workflow.ts
52673
52622
  var import_promises14 = require("fs/promises");
52674
- var import_node_path33 = require("path");
52623
+ var import_node_path34 = require("path");
52675
52624
 
52676
52625
  // src/cli/workflow-to-play.ts
52677
52626
  var import_node_crypto13 = require("crypto");
@@ -54281,7 +54230,7 @@ function readStatus(payload) {
54281
54230
  }
54282
54231
  async function readJsonOption(payload, file) {
54283
54232
  if (file) {
54284
- const raw = await (0, import_promises14.readFile)((0, import_node_path33.resolve)(file), "utf8");
54233
+ const raw = await (0, import_promises14.readFile)((0, import_node_path34.resolve)(file), "utf8");
54285
54234
  return JSON.parse(raw);
54286
54235
  }
54287
54236
  if (payload) {
@@ -54315,8 +54264,8 @@ async function transformOne(api, workflowId, outDir, publish) {
54315
54264
  revision.config,
54316
54265
  { workflowName: workflow.name, version: revision.version }
54317
54266
  );
54318
- const file = (0, import_node_path33.join)((0, import_node_path33.resolve)(outDir), `${compiled.playName}.play.ts`);
54319
- await (0, import_promises14.mkdir)((0, import_node_path33.dirname)(file), { recursive: true });
54267
+ const file = (0, import_node_path34.join)((0, import_node_path34.resolve)(outDir), `${compiled.playName}.play.ts`);
54268
+ await (0, import_promises14.mkdir)((0, import_node_path34.dirname)(file), { recursive: true });
54320
54269
  await (0, import_promises14.writeFile)(file, compiled.sourceCode, "utf8");
54321
54270
  let published = false;
54322
54271
  if (publish) {
@@ -54577,6 +54526,7 @@ Notes:
54577
54526
  function registerDeeplineCommandGroups(program) {
54578
54527
  registerAuthCommands(program);
54579
54528
  registerProviderCommands(program);
54529
+ registerSearchCommand(program);
54580
54530
  registerToolsCommands(program);
54581
54531
  registerExecutionsCommands(program);
54582
54532
  registerPlayCommands(program);
@@ -54827,10 +54777,11 @@ function shouldDeferSkillsSyncForCommand() {
54827
54777
  const args = process.argv.slice(2);
54828
54778
  const command = args[0];
54829
54779
  const subcommand = args[1];
54830
- if (command === "tools" && ["list", "search", "grep", "describe", "get"].includes(subcommand ?? "")) {
54780
+ if (command === "tools" && ["list", "grep", "describe", "get"].includes(subcommand ?? "")) {
54831
54781
  return true;
54832
54782
  }
54833
54783
  if (command === "providers" && subcommand === "list") return true;
54784
+ if (command === "search") return true;
54834
54785
  return (command === "play" || command === "plays") && subcommand === "run" && args.includes("--json");
54835
54786
  }
54836
54787
  function isDeprecatedCommandInvocation() {
@@ -54861,8 +54812,8 @@ function topLevelCommandKnown(program, commandName) {
54861
54812
  );
54862
54813
  }
54863
54814
  async function runPlayRunnerHealthCheck() {
54864
- const dir = await (0, import_promises15.mkdtemp)((0, import_node_path34.join)((0, import_node_os19.tmpdir)(), "deepline-health-play-"));
54865
- const file = (0, import_node_path34.join)(dir, "health-check.play.ts");
54815
+ const dir = await (0, import_promises15.mkdtemp)((0, import_node_path35.join)((0, import_node_os19.tmpdir)(), "deepline-health-play-"));
54816
+ const file = (0, import_node_path35.join)(dir, "health-check.play.ts");
54866
54817
  try {
54867
54818
  await (0, import_promises15.writeFile)(
54868
54819
  file,
@@ -55083,7 +55034,7 @@ Common commands:
55083
55034
  deepline health
55084
55035
  deepline auth status --json
55085
55036
  deepline sessions send --current-session --json
55086
- deepline plays search email --json
55037
+ deepline search --type prebuilts email --json
55087
55038
  deepline plays describe prebuilt/person-linkedin-to-email --json
55088
55039
  deepline plays run my.play.ts --input '{"domain":"stripe.com"}'
55089
55040
  deepline secrets check HUBSPOT_TOKEN