deepline 0.3.213 → 0.3.215

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 (33) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +122 -32
  2. package/dist/bundling-sources/sdk/src/compat.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/deployment-protection.ts +19 -0
  4. package/dist/bundling-sources/sdk/src/http.ts +3 -7
  5. package/dist/bundling-sources/sdk/src/index.ts +7 -0
  6. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  7. package/dist/bundling-sources/sdk/src/types.ts +25 -0
  8. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  9. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +33 -7
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +11 -1
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +3 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +53 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +187 -6
  15. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +12 -3
  16. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +5 -2
  17. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +40 -0
  18. package/dist/bundling-sources/shared_libs/plays/deploy/manifest.ts +51 -28
  19. package/dist/bundling-sources/shared_libs/plays/deploy/monitor-files.ts +52 -0
  20. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +146 -19
  21. package/dist/bundling-sources/shared_libs/plays/settings-contract.ts +176 -0
  22. package/dist/cli/index.js +1046 -416
  23. package/dist/cli/index.mjs +894 -264
  24. package/dist/index.d.mts +165 -3
  25. package/dist/index.d.ts +165 -3
  26. package/dist/index.js +67 -35
  27. package/dist/index.mjs +67 -35
  28. package/dist/install-integrity.json +3 -0
  29. package/dist/release.d.mts +1 -1
  30. package/dist/release.d.ts +1 -1
  31. package/dist/release.js +1 -1
  32. package/dist/release.mjs +1 -1
  33. package/package.json +3 -2
package/dist/cli/index.js CHANGED
@@ -1963,8 +1963,8 @@ function configureProxyFromEnv() {
1963
1963
  configureProxyFromEnv();
1964
1964
 
1965
1965
  // src/cli/index.ts
1966
- var import_promises14 = require("fs/promises");
1967
- var import_node_path32 = require("path");
1966
+ var import_promises15 = require("fs/promises");
1967
+ var import_node_path33 = require("path");
1968
1968
  var import_node_os20 = require("os");
1969
1969
  var import_commander5 = require("commander");
1970
1970
 
@@ -3051,7 +3051,7 @@ var SDK_RELEASE = {
3051
3051
  // getters keep their established compatibility behavior.
3052
3052
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3053
3053
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3054
- version: "0.3.213",
3054
+ version: "0.3.215",
3055
3055
  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.",
3056
3056
  packageCapabilities: {
3057
3057
  updatePreferences: 1
@@ -3372,6 +3372,22 @@ function writeSdkSkillsLocalVersion(baseUrl, version, agents) {
3372
3372
  return complete;
3373
3373
  }
3374
3374
 
3375
+ // src/deployment-protection.ts
3376
+ function deploymentProtectionHeaders() {
3377
+ const token = typeof process !== "undefined" ? process.env?.VERCEL_PROTECTION_BYPASS_TOKEN : void 0;
3378
+ return token ? { "x-vercel-protection-bypass": token } : {};
3379
+ }
3380
+ var fetchWithDeploymentProtection = (input2, init) => {
3381
+ const headers = new Headers(
3382
+ input2 instanceof Request ? input2.headers : void 0
3383
+ );
3384
+ new Headers(init?.headers).forEach((value, name) => headers.set(name, value));
3385
+ for (const [name, value] of Object.entries(deploymentProtectionHeaders())) {
3386
+ headers.set(name, value);
3387
+ }
3388
+ return fetch(input2, { ...init, headers });
3389
+ };
3390
+
3375
3391
  // ../play-runtime/coordinator-headers.ts
3376
3392
  var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
3377
3393
  var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
@@ -3754,16 +3770,13 @@ var HttpClient = class {
3754
3770
  "X-Deepline-SDK-Version": SDK_VERSION,
3755
3771
  "X-Deepline-API-Contract": SDK_API_CONTRACT,
3756
3772
  "X-Deepline-Run-Result-Shape": "canonical",
3757
- ...extra
3773
+ ...extra,
3774
+ ...deploymentProtectionHeaders()
3758
3775
  };
3759
3776
  const skillsVersion = this.readSkillsVersionHeader();
3760
3777
  if (skillsVersion) {
3761
3778
  headers["X-Deepline-Skills-Version"] = skillsVersion;
3762
3779
  }
3763
- const bypassToken = typeof process !== "undefined" ? process.env?.VERCEL_PROTECTION_BYPASS_TOKEN : void 0;
3764
- if (bypassToken) {
3765
- headers["x-vercel-protection-bypass"] = bypassToken;
3766
- }
3767
3780
  const playArtifactR2Prefix = typeof process !== "undefined" ? process.env?.DEEPLINE_PLAY_ARTIFACT_R2_PREFIX : void 0;
3768
3781
  if (playArtifactR2Prefix) {
3769
3782
  headers["x-deepline-play-artifact-r2-prefix"] = playArtifactR2Prefix;
@@ -4892,13 +4905,13 @@ function previewValue(value, input2) {
4892
4905
  ([, descriptor]) => descriptor.enumerable
4893
4906
  );
4894
4907
  const selected = entries.slice(0, DOCFLOW_NODE_IO_LIMITS.maxObjectFields);
4895
- const fields = {};
4908
+ const fields2 = {};
4896
4909
  for (const [key, descriptor] of selected) {
4897
4910
  const safeKey = truncateUtf8(
4898
4911
  ledgerSafeDocflowPreviewKey(input2.redactor.redactString(key)),
4899
4912
  DOCFLOW_NODE_IO_LIMITS.maxStringBytes
4900
4913
  );
4901
- fields[safeKey] = "value" in descriptor ? previewValue(descriptor.value, {
4914
+ fields2[safeKey] = "value" in descriptor ? previewValue(descriptor.value, {
4902
4915
  ...input2,
4903
4916
  depth: input2.depth + 1,
4904
4917
  key
@@ -4906,7 +4919,7 @@ function previewValue(value, input2) {
4906
4919
  }
4907
4920
  return {
4908
4921
  kind: "object",
4909
- fields,
4922
+ fields: fields2,
4910
4923
  totalFields: entries.length,
4911
4924
  ...entries.length > selected.length ? { truncated: true } : {}
4912
4925
  };
@@ -5015,20 +5028,20 @@ function normalizePreview(value, depth) {
5015
5028
  };
5016
5029
  }
5017
5030
  if (value.kind === "object" && isRecord3(value.fields)) {
5018
- const fields = {};
5031
+ const fields2 = {};
5019
5032
  for (const [key, field] of Object.entries(value.fields).slice(
5020
5033
  0,
5021
5034
  DOCFLOW_NODE_IO_LIMITS.maxObjectFields
5022
5035
  )) {
5023
5036
  const normalized = normalizePreview(field, depth + 1);
5024
- if (normalized) fields[ledgerSafeDocflowPreviewKey(key)] = normalized;
5037
+ if (normalized) fields2[ledgerSafeDocflowPreviewKey(key)] = normalized;
5025
5038
  }
5026
- const totalFields = typeof value.totalFields === "number" && Number.isFinite(value.totalFields) ? Math.max(Object.keys(fields).length, Math.floor(value.totalFields)) : Object.keys(fields).length;
5039
+ const totalFields = typeof value.totalFields === "number" && Number.isFinite(value.totalFields) ? Math.max(Object.keys(fields2).length, Math.floor(value.totalFields)) : Object.keys(fields2).length;
5027
5040
  return {
5028
5041
  kind: "object",
5029
- fields,
5042
+ fields: fields2,
5030
5043
  totalFields,
5031
- ...value.truncated === true || totalFields > Object.keys(fields).length ? { truncated: true } : {}
5044
+ ...value.truncated === true || totalFields > Object.keys(fields2).length ? { truncated: true } : {}
5032
5045
  };
5033
5046
  }
5034
5047
  return null;
@@ -7040,10 +7053,19 @@ function normalizePlayStatus(raw) {
7040
7053
  );
7041
7054
  }
7042
7055
  const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : packageRun?.id ?? "";
7056
+ const legacyOverview = runPackage?.overview ?? raw.overview;
7057
+ const runStatus = runPackage?.runStatus ?? raw.runStatus;
7043
7058
  return {
7044
7059
  ...raw,
7045
7060
  runId,
7046
- ...runPackage ? { package: runPackage, outputs: runPackage.outputs } : {},
7061
+ ...isRecord7(legacyOverview) ? {
7062
+ overview: legacyOverview
7063
+ } : {},
7064
+ ...isRecord7(runStatus) ? { runStatus } : {},
7065
+ ...runPackage ? {
7066
+ package: runPackage,
7067
+ outputs: runPackage.outputs
7068
+ } : {},
7047
7069
  status
7048
7070
  };
7049
7071
  }
@@ -7225,18 +7247,6 @@ function playRunResultFromStatus(status, startedAt, fallbackRunId) {
7225
7247
  error: status.progress?.error ?? (status.status !== "completed" ? status.status : void 0)
7226
7248
  };
7227
7249
  }
7228
- function playRunStatusFromState(state) {
7229
- return {
7230
- runId: state.runId,
7231
- status: state.status,
7232
- progress: {
7233
- status: state.status,
7234
- logs: state.logs,
7235
- ...state.error ? { error: state.error } : {}
7236
- },
7237
- ..."result" in state ? { result: state.result } : {}
7238
- };
7239
- }
7240
7250
  var DeeplineClient = class _DeeplineClient {
7241
7251
  http;
7242
7252
  config;
@@ -7379,14 +7389,14 @@ var DeeplineClient = class _DeeplineClient {
7379
7389
  }
7380
7390
  compactSchema(schema) {
7381
7391
  if (!schema) return null;
7382
- const fields = Array.isArray(schema.fields) ? schema.fields.map(
7392
+ const fields2 = Array.isArray(schema.fields) ? schema.fields.map(
7383
7393
  (field) => field && typeof field === "object" ? {
7384
7394
  name: String(field.name ?? ""),
7385
7395
  type: field.type ?? void 0,
7386
7396
  required: field.required ?? void 0
7387
7397
  } : null
7388
7398
  ).filter((field) => Boolean(field?.name)) : [];
7389
- return fields.length > 0 ? { fields } : schema;
7399
+ return fields2.length > 0 ? { fields: fields2 } : schema;
7390
7400
  }
7391
7401
  schemaMetadata(schema, key) {
7392
7402
  if (!isRecord7(schema)) return null;
@@ -7573,6 +7583,12 @@ var DeeplineClient = class _DeeplineClient {
7573
7583
  options.includeSearchDebug ? "true" : "false"
7574
7584
  );
7575
7585
  params.set("search_mode", options.searchMode ?? "v2");
7586
+ if (options.limit !== void 0) {
7587
+ params.set("limit", String(options.limit));
7588
+ }
7589
+ if (options.offset !== void 0) {
7590
+ params.set("offset", String(options.offset));
7591
+ }
7576
7592
  if (options.categories?.trim()) {
7577
7593
  params.set("categories", options.categories.trim());
7578
7594
  }
@@ -8634,9 +8650,18 @@ var DeeplineClient = class _DeeplineClient {
8634
8650
  }
8635
8651
  const query = params.size > 0 ? `?${params.toString()}` : "";
8636
8652
  const response = await this.http.get(
8637
- `/api/v2/runs/${encodeURIComponent(runId)}${query}`
8653
+ `/api/v2/runs/${encodeURIComponent(runId)}${query}`,
8654
+ { headers: { "x-deepline-run-status": "1" } }
8638
8655
  );
8656
+ const responseRunStatus = isPlayRunPackage(response) ? response.runStatus : isPlayRunPackage(response.package) ? response.package.runStatus : response.runStatus;
8657
+ const responseOverview = isPlayRunPackage(response) ? response.overview : isPlayRunPackage(response.package) ? response.package.overview : response.overview;
8639
8658
  const status = normalizePlayStatus(response);
8659
+ if (isRecord7(responseRunStatus)) {
8660
+ status.runStatus = responseRunStatus;
8661
+ }
8662
+ if (isRecord7(responseOverview)) {
8663
+ status.overview = responseOverview;
8664
+ }
8640
8665
  if (options?.failedLogs !== true || status.status !== "failed") {
8641
8666
  return status;
8642
8667
  }
@@ -8677,7 +8702,10 @@ var DeeplineClient = class _DeeplineClient {
8677
8702
  }
8678
8703
  };
8679
8704
  }
8680
- /** Read only the bounded scalar projection; does not hydrate the run package. */
8705
+ /** Fetch only the legacy scalar lifecycle status for a run.
8706
+ *
8707
+ * @deprecated Use `client.runs.get(runId)` for the canonical run read.
8708
+ */
8681
8709
  async getRunLifecycleStatus(runId) {
8682
8710
  const response = await this.http.get(
8683
8711
  `/api/v2/runs/${encodeURIComponent(runId)}/status`
@@ -8853,9 +8881,7 @@ var DeeplineClient = class _DeeplineClient {
8853
8881
  if (!status || !TERMINAL_PLAY_STATUSES.has(status.status)) {
8854
8882
  continue;
8855
8883
  }
8856
- return await this.getRunStatus(status.runId || runId).catch(
8857
- () => state.latest ?? playRunStatusFromState(state)
8858
- );
8884
+ return await this.getRunStatus(status.runId || runId);
8859
8885
  }
8860
8886
  if (options?.signal?.aborted) {
8861
8887
  throw new DeeplineError("Run observation aborted.", void 0, "ABORTED");
@@ -8906,6 +8932,7 @@ var DeeplineClient = class _DeeplineClient {
8906
8932
  for (; ; ) {
8907
8933
  const connectedAt = Date.now();
8908
8934
  let sawEvent = false;
8935
+ let terminalRunId = null;
8909
8936
  let endedReason = "stream window ended before a terminal event";
8910
8937
  try {
8911
8938
  for await (const event of this.streamPlayRunEvents(runId, {
@@ -8918,9 +8945,8 @@ var DeeplineClient = class _DeeplineClient {
8918
8945
  if (!status || !TERMINAL_PLAY_STATUSES.has(status.status)) {
8919
8946
  continue;
8920
8947
  }
8921
- return await this.getRunStatus(status.runId || runId).catch(
8922
- () => state.latest ?? playRunStatusFromState(state)
8923
- );
8948
+ terminalRunId = status.runId || runId;
8949
+ break;
8924
8950
  }
8925
8951
  } catch (error) {
8926
8952
  if (options?.signal?.aborted || !isTransientPlayStreamError(error)) {
@@ -8928,15 +8954,11 @@ var DeeplineClient = class _DeeplineClient {
8928
8954
  }
8929
8955
  endedReason = error instanceof Error ? error.message : String(error);
8930
8956
  }
8931
- let refreshed = null;
8932
- try {
8933
- refreshed = await this.getRunStatus(runId);
8934
- } catch (error) {
8935
- if (!isTransientPlayStreamError(error)) {
8936
- throw error;
8937
- }
8957
+ if (terminalRunId) {
8958
+ return await this.getRunStatus(terminalRunId);
8938
8959
  }
8939
- if (refreshed && TERMINAL_PLAY_STATUSES.has(refreshed.status)) {
8960
+ const refreshed = await this.getRunStatus(runId);
8961
+ if (TERMINAL_PLAY_STATUSES.has(refreshed.status)) {
8940
8962
  return refreshed;
8941
8963
  }
8942
8964
  if (sawEvent || Date.now() - connectedAt >= STREAM_HEALTHY_CONNECTION_MS) {
@@ -9225,6 +9247,26 @@ var DeeplineClient = class _DeeplineClient {
9225
9247
  hasMore: Boolean(response.pagination?.hasMore ?? response.hasMore)
9226
9248
  };
9227
9249
  }
9250
+ /** Read definition-level settings, independently of code revisions. */
9251
+ async getPlaySettings(playName) {
9252
+ return this.http.get(
9253
+ `/api/v2/plays/${encodeURIComponent(playName)}/settings`
9254
+ );
9255
+ }
9256
+ /** Retry-safe field patch; omitted fields retain their current value. */
9257
+ async updatePlaySettings(playName, patch) {
9258
+ return this.http.patch(
9259
+ `/api/v2/plays/${encodeURIComponent(playName)}/settings`,
9260
+ patch
9261
+ );
9262
+ }
9263
+ /** List one bounded page of existing Play locations; continue with cursor. */
9264
+ async listPlaySettingsPaths(options = {}) {
9265
+ const query = new URLSearchParams();
9266
+ for (const [key, value] of Object.entries(options))
9267
+ if (value !== void 0) query.set(key, String(value));
9268
+ return this.http.get(`/api/v2/plays/settings/paths?${query}`);
9269
+ }
9228
9270
  /** Set whether an org-owned Play sorts before unpinned Plays. */
9229
9271
  async setPlayPinned(playName, pinned) {
9230
9272
  return this.http.post(`/api/v2/plays/${encodeURIComponent(playName)}/pin`, {
@@ -10842,6 +10884,7 @@ async function checkSdkCompatibility(baseUrl, options = {}) {
10842
10884
  const response = await fetch(url, {
10843
10885
  method: "GET",
10844
10886
  headers: {
10887
+ ...deploymentProtectionHeaders(),
10845
10888
  "User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
10846
10889
  "X-Deepline-SDK-Version": SDK_VERSION,
10847
10890
  "X-Deepline-API-Major": String(SDK_API_MAJOR),
@@ -11706,8 +11749,8 @@ function resolvePendingAuthClaimForResume(baseUrl, requestedScope) {
11706
11749
  const claim = readPendingAuthClaim(baseUrl, requestedScope);
11707
11750
  return { claim, scope: claim?.scope ?? requestedScope };
11708
11751
  }
11709
- const folder = readPendingAuthClaim(baseUrl, "folder");
11710
- if (folder) return { claim: folder, scope: folder.scope };
11752
+ const folder2 = readPendingAuthClaim(baseUrl, "folder");
11753
+ if (folder2) return { claim: folder2, scope: folder2.scope };
11711
11754
  const global = readPendingAuthClaim(baseUrl, "global");
11712
11755
  return { claim: global, scope: global?.scope ?? "global" };
11713
11756
  }
@@ -15513,14 +15556,14 @@ function customerDbColumnNames(result) {
15513
15556
  function errorMessage(value) {
15514
15557
  return value instanceof Error ? value.message : String(value ?? "");
15515
15558
  }
15516
- function resolveDbQuerySql(rawSql, readFile7 = (path) => (0, import_node_fs8.readFileSync)(path, "utf8")) {
15559
+ function resolveDbQuerySql(rawSql, readFile8 = (path) => (0, import_node_fs8.readFileSync)(path, "utf8")) {
15517
15560
  const value = rawSql.trim();
15518
15561
  if (!value.startsWith("@")) return value;
15519
15562
  const filePath = value.slice(1).trim();
15520
15563
  if (!filePath) {
15521
15564
  throw new Error("--sql @file requires a file path after `@`.");
15522
15565
  }
15523
- return readFile7((0, import_node_path9.resolve)(filePath)).trim();
15566
+ return readFile8((0, import_node_path9.resolve)(filePath)).trim();
15524
15567
  }
15525
15568
  function collectErrorText(value) {
15526
15569
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -15886,16 +15929,342 @@ Examples:
15886
15929
  }
15887
15930
 
15888
15931
  // src/cli/commands/enrich.ts
15889
- var import_promises10 = require("fs/promises");
15932
+ var import_promises11 = require("fs/promises");
15890
15933
  var import_node_os10 = require("os");
15891
- var import_node_path18 = require("path");
15934
+ var import_node_path19 = require("path");
15892
15935
  var import_commander2 = require("commander");
15893
15936
 
15937
+ // ../plays/settings-contract.ts
15938
+ var import_zod = require("zod");
15939
+ function formatPlaySettingsError(error) {
15940
+ if (error instanceof import_zod.z.ZodError)
15941
+ return [...new Set(error.issues.map((issue) => issue.message))].join(" ");
15942
+ return error instanceof Error ? error.message : String(error);
15943
+ }
15944
+ var PLAY_LOCATION_ROOTS = [
15945
+ {
15946
+ value: "person",
15947
+ label: "Personal",
15948
+ description: "The creator\u2019s personal root, displayed as their name followed by \u201C\u2019s team\u201D."
15949
+ },
15950
+ {
15951
+ value: "team",
15952
+ label: "Team library",
15953
+ description: "The shared team library. Publishing moves personal locations here, keeping their folders."
15954
+ }
15955
+ ];
15956
+ var folder = import_zod.z.string().min(1).max(128).refine(
15957
+ (value) => value === value.trim() && value !== "." && value !== ".." && !/[\\/\u0000-\u001f\u007f]/u.test(value),
15958
+ "Folder names must be trimmed, cannot be . or .., and cannot contain slashes or control characters."
15959
+ );
15960
+ var playPathSchema = import_zod.z.union([
15961
+ import_zod.z.null(),
15962
+ import_zod.z.object({
15963
+ root: import_zod.z.enum(["person", "team"]),
15964
+ folders: import_zod.z.array(folder).max(16).default([])
15965
+ }).strict()
15966
+ ]).transform(
15967
+ (path) => path?.root === "person" && path.folders.length === 0 ? null : path
15968
+ );
15969
+ function parsePlayPath(value) {
15970
+ const [root, ...parts] = value.split("/");
15971
+ if (!PLAY_LOCATION_ROOTS.some((option) => option.value === root)) {
15972
+ throw new Error(
15973
+ "Path must start with person or team. Example: person/Research/ICP."
15974
+ );
15975
+ }
15976
+ let folders;
15977
+ try {
15978
+ folders = parts.map(decodeURIComponent);
15979
+ } catch {
15980
+ throw new Error(
15981
+ "Path contains an invalid percent escape. Encode a literal % as %25."
15982
+ );
15983
+ }
15984
+ return playPathSchema.parse({ root, folders });
15985
+ }
15986
+ function formatPlayPath(path) {
15987
+ return path === null ? "person" : [path.root, ...path.folders.map(encodeURIComponent)].join("/");
15988
+ }
15989
+ function personalPlayRootLabel(ownerName) {
15990
+ const name = ownerName?.trim();
15991
+ return name ? `${name.split(/\s+/)[0]}\u2019s team` : "Personal";
15992
+ }
15993
+ function displayPlayPath(path, ownerName) {
15994
+ return [
15995
+ path?.root === "team" ? "Team library" : personalPlayRootLabel(ownerName),
15996
+ ...path?.folders ?? []
15997
+ ].join(" / ");
15998
+ }
15999
+ var PLAY_SETTING_FIELDS = {
16000
+ path: {
16001
+ schema: playPathSchema.default(null).describe(
16002
+ "Play location. Null means the creator\u2019s personal root. Publishing moves it into Team library, preserving folders."
16003
+ ),
16004
+ label: "Location",
16005
+ description: "Organize this Play in the creator\u2019s personal root or Team library. Publishing moves it to Team library and keeps its folders. Workspace sharing permissions apply in both roots.",
16006
+ get defaultValue() {
16007
+ return this.schema.parse(void 0);
16008
+ },
16009
+ cli: {
16010
+ valueSyntax: "person[/folder/\u2026] | team[/folder/\u2026] | null",
16011
+ examples: [
16012
+ "person",
16013
+ "person/Research/ICP",
16014
+ "team",
16015
+ "team/Research",
16016
+ "null"
16017
+ ],
16018
+ parse: (value) => value === "null" ? null : parsePlayPath(value),
16019
+ format: formatPlayPath
16020
+ },
16021
+ ui: { control: "play-location-picker" }
16022
+ }
16023
+ };
16024
+ var playSettingsSchema = import_zod.z.object(
16025
+ Object.fromEntries(
16026
+ Object.entries(PLAY_SETTING_FIELDS).map(([key, field]) => [
16027
+ key,
16028
+ field.schema
16029
+ ])
16030
+ )
16031
+ ).passthrough();
16032
+ var playSettingsPatchSchema = import_zod.z.object(
16033
+ Object.fromEntries(
16034
+ Object.entries(PLAY_SETTING_FIELDS).map(([key, field]) => [
16035
+ key,
16036
+ field.schema.unwrap().optional()
16037
+ ])
16038
+ )
16039
+ ).strict().refine(
16040
+ (patch) => Object.keys(patch).length > 0,
16041
+ "Supply at least one setting."
16042
+ );
16043
+ function parsePlaySettings(value) {
16044
+ return playSettingsSchema.parse(value);
16045
+ }
16046
+ var DEFAULT_PLAY_SETTINGS = parsePlaySettings({});
16047
+
16048
+ // src/cli/commands/plays-settings.ts
16049
+ var fields = Object.entries(PLAY_SETTING_FIELDS);
16050
+ var help = `
16051
+ Settings live on the Play definition. Edits preserve code revisions.
16052
+ New Plays start at person (the creator\u2019s personal root, e.g. Chirag\u2019s team).
16053
+ Publishing moves a Play into team and keeps its folders. Workspace sharing
16054
+ permissions apply in both roots. Folder paths are independent of your cwd.
16055
+
16056
+ Setting names and values:
16057
+ ${fields.map(([key, field]) => ` ${key}: ${field.schema.description}
16058
+ Values: ${field.cli.valueSyntax}
16059
+ Default: ${JSON.stringify(field.defaultValue)} (${field.cli.format(field.defaultValue)})`).join("\n")}
16060
+
16061
+ Roots:
16062
+ ${PLAY_LOCATION_ROOTS.map((root) => ` ${root.value}: ${root.description}`).join("\n")}
16063
+
16064
+ Examples:
16065
+ deepline plays settings describe --name path --json
16066
+ deepline plays settings get --play company-research --json
16067
+ deepline plays settings get --play company-research --name path
16068
+ deepline plays settings set --play company-research --name path --value person/Research/ICP
16069
+ deepline plays settings set --play company-research --name path --value team/Research
16070
+ deepline plays settings reset --play company-research --name path
16071
+ deepline plays settings paths --root team --json
16072
+
16073
+ Quote values containing spaces. Use percent escapes for literal % characters.
16074
+ `;
16075
+ function resolveField(key, command) {
16076
+ const entry = fields.find(([name]) => name === key);
16077
+ if (!entry)
16078
+ command.error(
16079
+ `Unknown --name ${JSON.stringify(key)}. Available settings: ${fields.map(([name]) => name).join(", ")}. Run deepline plays settings describe.`,
16080
+ { exitCode: 2 }
16081
+ );
16082
+ return entry[1];
16083
+ }
16084
+ function printSettings(result, json2, name) {
16085
+ const selected = fields.filter(([key]) => !name || key === name);
16086
+ printCommandEnvelope(
16087
+ {
16088
+ ...result,
16089
+ settings: Object.fromEntries(
16090
+ selected.map(([key]) => [
16091
+ key,
16092
+ result.settings[key]
16093
+ ])
16094
+ ),
16095
+ render: {
16096
+ sections: [
16097
+ {
16098
+ title: "Play settings",
16099
+ lines: selected.map(
16100
+ ([key, field]) => `${field.label}: ${key === "path" ? displayPlayPath(result.settings.path, result.ownerName) : field.cli.format(result.settings[key])} (${field.cli.format(result.settings[key])})`
16101
+ )
16102
+ }
16103
+ ]
16104
+ }
16105
+ },
16106
+ { json: json2 }
16107
+ );
16108
+ }
16109
+ function registerPlaySettingsCommands(plays) {
16110
+ const settings = plays.command("settings").description("Read and change Play settings by name and value.").exitOverride((error) => {
16111
+ if (error.exitCode !== 0) error.exitCode = 2;
16112
+ throw error;
16113
+ }).addHelpText("after", help);
16114
+ settings.command("describe").usage("[--name <setting>] [options]").description(
16115
+ "List setting names, values, examples and defaults; no authentication required."
16116
+ ).option(
16117
+ "--name <setting>",
16118
+ `Describe one setting. Available: ${fields.map(([key]) => key).join(", ")}`
16119
+ ).option("--json", "Emit JSON; automatic when piped").addHelpText("after", help).action((options, command) => {
16120
+ if (options.name !== void 0) resolveField(options.name, command);
16121
+ const descriptions = fields.filter(([name]) => !options.name || options.name === name).map(([name, field]) => ({
16122
+ key: name,
16123
+ label: field.label,
16124
+ description: field.schema.description ?? field.description,
16125
+ default: field.defaultValue,
16126
+ defaultText: field.cli.format(field.defaultValue),
16127
+ valueSyntax: field.cli.valueSyntax,
16128
+ examples: field.cli.examples
16129
+ }));
16130
+ printCommandEnvelope(
16131
+ {
16132
+ fields: descriptions,
16133
+ render: {
16134
+ sections: descriptions.map((field) => ({
16135
+ title: field.key,
16136
+ lines: [
16137
+ field.description,
16138
+ `Values: ${field.valueSyntax}`,
16139
+ `Default: ${JSON.stringify(field.default)} (${field.defaultText})`,
16140
+ `Examples: ${field.examples.join(", ")}`
16141
+ ]
16142
+ }))
16143
+ }
16144
+ },
16145
+ { json: options.json }
16146
+ );
16147
+ });
16148
+ settings.command("get").usage("--play <play> [--name <setting>] [options]").description("Read all settings, or one setting selected with --name.").requiredOption("--play <play>", "Play to read").option(
16149
+ "--name <setting>",
16150
+ `Read one setting. Available: ${fields.map(([key]) => key).join(", ")}`
16151
+ ).option("--json", "Emit JSON; automatic when piped").addHelpText("after", help).action(
16152
+ async (options, command) => {
16153
+ if (options.name !== void 0) resolveField(options.name, command);
16154
+ printSettings(
16155
+ await new DeeplineClient().getPlaySettings(options.play),
16156
+ options.json,
16157
+ options.name
16158
+ );
16159
+ }
16160
+ );
16161
+ const set = settings.command("set").usage("--play <play> --name <setting> --value <value> [options]").requiredOption("--play <play>", "Play to update").requiredOption(
16162
+ "--name <setting>",
16163
+ `Setting name. Available: ${fields.map(([key]) => key).join(", ")}`
16164
+ ).requiredOption(
16165
+ "--value <value>",
16166
+ "New value; see settings describe --name <setting>"
16167
+ ).description("Set one setting without creating or publishing a revision.");
16168
+ const reset = settings.command("reset").usage("--play <play> --name <setting> [options]").requiredOption("--play <play>", "Play to update").requiredOption(
16169
+ "--name <setting>",
16170
+ `Setting name. Available: ${fields.map(([key]) => key).join(", ")}`
16171
+ ).description("Reset one setting to its schema default.");
16172
+ const change = async (command, play, key, value, options, resetting) => {
16173
+ const field = resolveField(key, command);
16174
+ let patch;
16175
+ try {
16176
+ patch = playSettingsPatchSchema.parse({
16177
+ [key]: resetting ? field.defaultValue : field.cli.parse(value)
16178
+ });
16179
+ } catch (error) {
16180
+ command.error(
16181
+ `Invalid --value for --name ${key}: ${formatPlaySettingsError(error)} Values: ${field.cli.valueSyntax}.`,
16182
+ { exitCode: 2 }
16183
+ );
16184
+ }
16185
+ if (options.dryRun) {
16186
+ printCommandEnvelope(
16187
+ {
16188
+ dryRun: true,
16189
+ play,
16190
+ patch,
16191
+ render: {
16192
+ sections: [
16193
+ {
16194
+ title: "Planned settings patch",
16195
+ lines: Object.entries(patch).map(
16196
+ ([name, setting]) => `${name}: ${JSON.stringify(setting)}`
16197
+ )
16198
+ }
16199
+ ]
16200
+ }
16201
+ },
16202
+ { json: options.json }
16203
+ );
16204
+ return;
16205
+ }
16206
+ printSettings(
16207
+ await new DeeplineClient().updatePlaySettings(play, patch),
16208
+ options.json
16209
+ );
16210
+ };
16211
+ for (const [command, resetting] of [
16212
+ [set, false],
16213
+ [reset, true]
16214
+ ])
16215
+ command.option("--dry-run", "Show the patch without changing settings").option("--json", "Emit JSON; automatic when piped").addHelpText("after", help).action(
16216
+ (options) => change(
16217
+ command,
16218
+ options.play,
16219
+ options.name,
16220
+ options.value,
16221
+ options,
16222
+ resetting
16223
+ )
16224
+ );
16225
+ settings.command("paths").description("List existing locations (one bounded page).").option("--root <person|team>", "Filter by root").option("--limit <n>", "Plays to inspect, 1\u2013100", "50").option("--cursor <cursor>", "Continue from a previous page").option("--json", "Emit JSON; automatic when piped").addHelpText("after", help).action(
16226
+ async (options, command) => {
16227
+ const limit = Number(options.limit);
16228
+ if (options.root !== void 0 && options.root !== "person" && options.root !== "team" || !Number.isInteger(limit) || limit < 1 || limit > 100)
16229
+ command.error(
16230
+ "--root must be person or team; --limit must be 1\u2013100.",
16231
+ { exitCode: 2 }
16232
+ );
16233
+ const page = await new DeeplineClient().listPlaySettingsPaths({
16234
+ root: options.root,
16235
+ limit,
16236
+ cursor: options.cursor
16237
+ });
16238
+ const nextCommand = page.hasMore ? `deepline plays settings paths --cursor '${page.cursor}'${options.root ? ` --root ${options.root}` : ""} --json` : null;
16239
+ printCommandEnvelope(
16240
+ {
16241
+ ...page,
16242
+ nextCommand,
16243
+ render: {
16244
+ sections: [
16245
+ {
16246
+ title: "Play locations",
16247
+ lines: [
16248
+ ...page.paths.map(
16249
+ (item) => `${displayPlayPath(item.path, item.ownerName)} (${formatPlayPath(item.path)}) \u2014 ${item.playName}`
16250
+ ),
16251
+ ...nextCommand ? [`More: ${nextCommand}`] : []
16252
+ ]
16253
+ }
16254
+ ]
16255
+ }
16256
+ },
16257
+ { json: options.json }
16258
+ );
16259
+ }
16260
+ );
16261
+ }
16262
+
15894
16263
  // src/cli/commands/play.ts
15895
16264
  var import_node_crypto7 = require("crypto");
15896
16265
  var import_node_fs12 = require("fs");
15897
- var import_promises9 = require("fs/promises");
15898
- var import_node_path17 = require("path");
16266
+ var import_promises10 = require("fs/promises");
16267
+ var import_node_path18 = require("path");
15899
16268
  var import_sync5 = require("csv-parse/sync");
15900
16269
 
15901
16270
  // src/cli/commands/plays/bootstrap.ts
@@ -16506,8 +16875,8 @@ function readCsvHeaderFields(csvPath, sample) {
16506
16875
  skip_empty_lines: false
16507
16876
  });
16508
16877
  const firstRecord = Array.isArray(records) ? records[0] : null;
16509
- const fields = Array.isArray(firstRecord) ? firstRecord.map((field) => String(field ?? "").trim()).filter(Boolean) : [];
16510
- const uniqueFields = [...new Set(fields)];
16878
+ const fields2 = Array.isArray(firstRecord) ? firstRecord.map((field) => String(field ?? "").trim()).filter(Boolean) : [];
16879
+ const uniqueFields = [...new Set(fields2)];
16511
16880
  if (uniqueFields.length === 0) {
16512
16881
  throw new PlayBootstrapUsageError(
16513
16882
  `Could not read a header row from --from csv:${csvPath}.`
@@ -17596,6 +17965,45 @@ Examples:
17596
17965
  });
17597
17966
  }
17598
17967
 
17968
+ // src/cli/commands/plays/run-history.ts
17969
+ async function handleRunsHistory(options) {
17970
+ const query = new URLSearchParams();
17971
+ if (options.cursor) query.set("cursor", options.cursor);
17972
+ if (options.org) query.set("orgId", options.org);
17973
+ if (options.limit !== void 0) {
17974
+ const limit = Number(options.limit);
17975
+ if (!/^\d+$/.test(options.limit) || !Number.isSafeInteger(limit) || limit < 1) {
17976
+ throw new Error("--limit must be a positive integer.");
17977
+ }
17978
+ query.set("limit", String(limit));
17979
+ }
17980
+ const search = query.toString();
17981
+ const page = await new HttpClient(resolveConfig()).get(
17982
+ `/api/v2/dashboard/runs-history${search ? `?${search}` : ""}`
17983
+ );
17984
+ const lines = page.runs.map(
17985
+ (run) => `${run.workflowName} \xB7 ${run.status} \xB7 ${run.runId}`
17986
+ );
17987
+ if (lines.length === 0) lines.push("No runs found on this page.");
17988
+ if (page.hasMore) lines.push(`Next cursor: ${page.nextCursor}`);
17989
+ printCommandEnvelope(
17990
+ { ...page, render: { sections: [{ title: "Run history", lines }] } },
17991
+ options.json ? { json: true } : {}
17992
+ );
17993
+ }
17994
+ function registerRunHistoryCommand(runs) {
17995
+ runs.command("history").description("Page workspace run history.").option(
17996
+ "--cursor <cursor>",
17997
+ "Opaque nextCursor returned by the previous page"
17998
+ ).option("--limit <count>", "Maximum runs on this page").option(
17999
+ "--org <id>",
18000
+ "Workspace ID (must match the authenticated workspace)"
18001
+ ).option("--json", "Emit JSON output. Also automatic when stdout is piped").addHelpText(
18002
+ "after",
18003
+ "\nUse the opaque --cursor returned by the previous page to continue.\n\nExample:\n deepline runs history --limit 100 --json\n"
18004
+ ).action(handleRunsHistory);
18005
+ }
18006
+
17599
18007
  // src/plays/bundle-play-file.ts
17600
18008
  var import_node_os8 = require("os");
17601
18009
  var import_node_path13 = require("path");
@@ -20481,7 +20889,7 @@ function recordCliTrace(event) {
20481
20889
  process.stderr.write(`[cli-trace] ${JSON.stringify(payload)}
20482
20890
  `);
20483
20891
  }
20484
- async function traceCliSpan(phase, fields, run) {
20892
+ async function traceCliSpan(phase, fields2, run) {
20485
20893
  if (!isCliTraceEnabled()) {
20486
20894
  return run();
20487
20895
  }
@@ -20492,7 +20900,7 @@ async function traceCliSpan(phase, fields, run) {
20492
20900
  phase,
20493
20901
  ms: Date.now() - startedAt,
20494
20902
  ok: true,
20495
- ...fields
20903
+ ...fields2
20496
20904
  });
20497
20905
  return result;
20498
20906
  } catch (error) {
@@ -20501,7 +20909,7 @@ async function traceCliSpan(phase, fields, run) {
20501
20909
  ms: Date.now() - startedAt,
20502
20910
  ok: false,
20503
20911
  error: error instanceof Error ? error.message : String(error),
20504
- ...fields
20912
+ ...fields2
20505
20913
  });
20506
20914
  throw error;
20507
20915
  }
@@ -21148,13 +21556,13 @@ function normalizeFixtureScopeValue(value, maxLength) {
21148
21556
 
21149
21557
  // src/cli/commands/plays-deploy.ts
21150
21558
  var import_node_crypto6 = require("crypto");
21151
- var import_promises8 = require("fs/promises");
21559
+ var import_promises9 = require("fs/promises");
21152
21560
  var import_node_os9 = require("os");
21153
- var import_node_path16 = require("path");
21561
+ var import_node_path17 = require("path");
21154
21562
 
21155
21563
  // ../plays/deploy/run-deployment.ts
21156
- var import_node_path15 = require("path");
21157
- var import_promises7 = require("fs/promises");
21564
+ var import_node_path16 = require("path");
21565
+ var import_promises8 = require("fs/promises");
21158
21566
 
21159
21567
  // ../plays/deployment-status.ts
21160
21568
  var TERMINAL_PLAY_DEPLOYMENT_STATUSES = /* @__PURE__ */ new Set([
@@ -21262,6 +21670,21 @@ var DeployApiClient = class {
21262
21670
  body: { names }
21263
21671
  });
21264
21672
  }
21673
+ monitors(action, entries) {
21674
+ return this.request({
21675
+ method: "POST",
21676
+ path: this.deploymentPath("/monitors"),
21677
+ body: { action, entries }
21678
+ });
21679
+ }
21680
+ monitorJob(jobId, monitorKey) {
21681
+ return this.request({
21682
+ method: "GET",
21683
+ path: this.deploymentPath(
21684
+ `/monitors?jobId=${encodeURIComponent(jobId)}&monitorKey=${encodeURIComponent(monitorKey)}`
21685
+ )
21686
+ });
21687
+ }
21265
21688
  compileManifest(input2) {
21266
21689
  return this.request({
21267
21690
  method: "POST",
@@ -21314,7 +21737,8 @@ var import_promises6 = require("fs/promises");
21314
21737
  var import_node_path14 = require("path");
21315
21738
  var import_picomatch = __toESM(require_picomatch2(), 1);
21316
21739
  var DEFAULT_PLAY_GLOBS = ["**/*.play.ts"];
21317
- var MAX_DISCOVERED_PLAY_FILES = 200;
21740
+ var DEFAULT_MONITOR_GLOBS = ["**/*.monitor.json"];
21741
+ var MAX_DISCOVERED_FILES = 200;
21318
21742
  var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
21319
21743
  "node_modules",
21320
21744
  ".git",
@@ -21328,9 +21752,26 @@ var DeeplineManifestError = class extends Error {
21328
21752
  this.name = "DeeplineManifestError";
21329
21753
  }
21330
21754
  };
21755
+ function readGlobs(value, field) {
21756
+ if (!Array.isArray(value) || field === "plays" && value.length === 0 || !value.every((glob) => typeof glob === "string" && glob.trim().length > 0)) {
21757
+ throw new DeeplineManifestError(
21758
+ `deepline.json "${field}" must be ${field === "plays" ? "a non-empty" : "an"} array of glob strings.`
21759
+ );
21760
+ }
21761
+ const globs = value.map((glob) => glob.trim().replace(/^\.\//, ""));
21762
+ if (globs.some((glob) => glob.startsWith("/") || glob.includes(".."))) {
21763
+ throw new DeeplineManifestError(
21764
+ `deepline.json "${field}" globs must be relative and must not contain "..".`
21765
+ );
21766
+ }
21767
+ return globs;
21768
+ }
21331
21769
  function parseDeeplineManifest(raw) {
21332
21770
  if (raw === null) {
21333
- return { plays: DEFAULT_PLAY_GLOBS };
21771
+ return {
21772
+ plays: DEFAULT_PLAY_GLOBS,
21773
+ monitors: DEFAULT_MONITOR_GLOBS
21774
+ };
21334
21775
  }
21335
21776
  let parsed;
21336
21777
  try {
@@ -21344,24 +21785,14 @@ function parseDeeplineManifest(raw) {
21344
21785
  throw new DeeplineManifestError("deepline.json must be a JSON object.");
21345
21786
  }
21346
21787
  const record3 = parsed;
21347
- let plays = DEFAULT_PLAY_GLOBS;
21348
- if (record3.plays !== void 0) {
21349
- if (!Array.isArray(record3.plays) || record3.plays.length === 0 || !record3.plays.every(
21350
- (glob) => typeof glob === "string" && glob.trim().length > 0
21351
- )) {
21352
- throw new DeeplineManifestError(
21353
- 'deepline.json "plays" must be a non-empty array of glob strings, e.g. ["plays/**/*.play.ts"].'
21354
- );
21355
- }
21356
- plays = record3.plays.map((glob) => glob.trim().replace(/^\.\//, ""));
21357
- }
21358
- if (plays.some((glob) => glob.startsWith("/") || glob.includes(".."))) {
21359
- throw new DeeplineManifestError(
21360
- 'deepline.json "plays" globs must be relative and must not contain "..".'
21361
- );
21362
- }
21788
+ const plays = record3.plays === void 0 ? DEFAULT_PLAY_GLOBS : readGlobs(record3.plays, "plays");
21789
+ const monitors = record3.monitors === void 0 ? DEFAULT_MONITOR_GLOBS : readGlobs(record3.monitors, "monitors");
21363
21790
  const org = typeof record3.org === "string" && record3.org.trim() ? record3.org.trim() : void 0;
21364
- return { plays, ...org ? { org } : {} };
21791
+ return {
21792
+ plays,
21793
+ monitors,
21794
+ ...org ? { org } : {}
21795
+ };
21365
21796
  }
21366
21797
  var DEFAULT_MANIFEST_FILE = "deepline.json";
21367
21798
  async function readDeeplineManifest(projectRoot, manifestFile = DEFAULT_MANIFEST_FILE) {
@@ -21391,7 +21822,7 @@ async function readDeeplineManifest(projectRoot, manifestFile = DEFAULT_MANIFEST
21391
21822
  throw error;
21392
21823
  }
21393
21824
  }
21394
- async function discoverPlayFiles(input2) {
21825
+ async function discoverDeploymentFiles(input2) {
21395
21826
  const matchers = input2.globs.map((glob) => (0, import_picomatch.default)(glob));
21396
21827
  const found = [];
21397
21828
  async function walk(dir) {
@@ -21408,9 +21839,9 @@ async function discoverPlayFiles(input2) {
21408
21839
  const relativePath = (0, import_node_path14.relative)(input2.projectRoot, absolute);
21409
21840
  if (matchers.some((match) => match(relativePath))) {
21410
21841
  found.push(relativePath);
21411
- if (found.length > MAX_DISCOVERED_PLAY_FILES) {
21842
+ if (found.length > MAX_DISCOVERED_FILES) {
21412
21843
  throw new DeeplineManifestError(
21413
- `deepline.json globs matched more than ${MAX_DISCOVERED_PLAY_FILES} play files. Tighten the globs.`
21844
+ `deepline.json globs matched more than ${MAX_DISCOVERED_FILES} files. Tighten the globs.`
21414
21845
  );
21415
21846
  }
21416
21847
  }
@@ -21425,6 +21856,39 @@ async function discoverPlayFiles(input2) {
21425
21856
  await walk(input2.projectRoot);
21426
21857
  return found.sort();
21427
21858
  }
21859
+ var discoverPlayFiles = discoverDeploymentFiles;
21860
+
21861
+ // ../plays/deploy/monitor-files.ts
21862
+ var import_promises7 = require("fs/promises");
21863
+ var import_node_path15 = require("path");
21864
+ async function readMonitorFiles(input2) {
21865
+ const files = await discoverDeploymentFiles(input2);
21866
+ if (files.length > 100) {
21867
+ throw new DeeplineManifestError(
21868
+ "A deployment may contain at most 100 monitor definitions. Split the repository into multiple linked targets."
21869
+ );
21870
+ }
21871
+ return Promise.all(
21872
+ files.map(async (file) => {
21873
+ const sourcePath = input2.rootDirectory ? `${input2.rootDirectory}/${file}` : file;
21874
+ const raw = await (0, import_promises7.readFile)((0, import_node_path15.join)(input2.projectRoot, file), "utf8");
21875
+ try {
21876
+ return { file: sourcePath, definition: JSON.parse(raw) };
21877
+ } catch {
21878
+ throw new DeeplineManifestError(
21879
+ `${sourcePath} must contain a monitor definition as valid JSON.`
21880
+ );
21881
+ }
21882
+ })
21883
+ );
21884
+ }
21885
+ function monitorDeploymentSummary(outcomes) {
21886
+ return outcomes.map(
21887
+ (outcome) => `- Monitor \`${outcome.key}\` (\`${outcome.file}\`): ${outcome.status}${outcome.credits != null ? ` (${outcome.credits} Deepline credits)` : ""}${outcome.jobId ? ` \u2014 job \`${outcome.jobId}\`` : ""}${outcome.error ? `
21888
+ - ${outcome.error}` : ""}${outcome.warning ? `
21889
+ - :warning: ${outcome.warning}` : ""}`
21890
+ ).join("\n");
21891
+ }
21428
21892
 
21429
21893
  // ../plays/play-reference.ts
21430
21894
  var PREBUILT_PLAY_NAMESPACE = "prebuilt";
@@ -21640,12 +22104,15 @@ async function runDeployment(params, hooks) {
21640
22104
  }
21641
22105
  }
21642
22106
  const buildSeconds = () => Math.max(0, (Date.now() - startedAt) / 1e3);
22107
+ let monitorOutcomes = [];
22108
+ const monitorResults = () => monitorOutcomes.length > 0 ? { monitors: monitorOutcomes } : {};
22109
+ const monitorRunResult = () => monitorOutcomes.length > 0 ? { monitorOutcomes } : {};
21643
22110
  const finishFailed = async (input2) => {
21644
22111
  try {
21645
22112
  await setStatus({
21646
22113
  status: "failed",
21647
22114
  error: input2.error.slice(0, 2e3),
21648
- results: { plays: input2.outcomes },
22115
+ results: { plays: input2.outcomes, ...monitorResults() },
21649
22116
  buildSeconds: buildSeconds(),
21650
22117
  ...input2.checkRunId ? { checkRunId: input2.checkRunId } : {}
21651
22118
  });
@@ -21664,15 +22131,18 @@ async function runDeployment(params, hooks) {
21664
22131
  return {
21665
22132
  finalStatus: "failed",
21666
22133
  outcomes: input2.outcomes,
22134
+ ...monitorRunResult(),
21667
22135
  checkRunId: input2.checkRunId
21668
22136
  };
21669
22137
  };
21670
22138
  const finishSucceeded = async (outcomes, checkRun) => {
21671
- const finalStatus = outcomes.some((outcome) => outcome.warning) ? "succeeded_with_warnings" : "succeeded";
22139
+ const finalStatus = [...outcomes, ...monitorOutcomes].some(
22140
+ (outcome) => outcome.warning
22141
+ ) ? "succeeded_with_warnings" : "succeeded";
21672
22142
  try {
21673
22143
  await setStatus({
21674
22144
  status: finalStatus,
21675
- results: { plays: outcomes },
22145
+ results: { plays: outcomes, ...monitorResults() },
21676
22146
  buildSeconds: buildSeconds(),
21677
22147
  ...checkRun ? { checkRunId: checkRun.checkRunId } : {}
21678
22148
  });
@@ -21689,11 +22159,12 @@ async function runDeployment(params, hooks) {
21689
22159
  return {
21690
22160
  finalStatus,
21691
22161
  outcomes,
22162
+ ...monitorRunResult(),
21692
22163
  checkRunId: checkRun?.checkRunId
21693
22164
  };
21694
22165
  };
21695
- await (0, import_promises7.mkdir)(hooks.workRoot, { recursive: true });
21696
- const workDir = await (0, import_promises7.mkdtemp)((0, import_node_path15.join)(hooks.workRoot, "deploy-"));
22166
+ await (0, import_promises8.mkdir)(hooks.workRoot, { recursive: true });
22167
+ const workDir = await (0, import_promises8.mkdtemp)((0, import_node_path16.join)(hooks.workRoot, "deploy-"));
21697
22168
  const postCheck = async (postCheckOnce, input2) => {
21698
22169
  let lastError;
21699
22170
  for (let attempt = 0; ; attempt += 1) {
@@ -21769,7 +22240,7 @@ async function runDeployment(params, hooks) {
21769
22240
  await writeCheck({
21770
22241
  conclusion: "neutral",
21771
22242
  title: `Deployment ${stopped}`,
21772
- summary: "This deployment was stopped before it finished. Nothing from it went live."
22243
+ summary: monitorOutcomes.some((outcome) => outcome.jobId) ? "This deployment was stopped before it finished. Monitor jobs already submitted may have changed live resources; inspect the jobs in its receipt." : "This deployment was stopped before it finished. Nothing from it went live."
21773
22244
  }).catch(() => void 0);
21774
22245
  throw revocation;
21775
22246
  });
@@ -21809,6 +22280,7 @@ async function runDeployment(params, hooks) {
21809
22280
  status: "superseded",
21810
22281
  error: `Branch ${deploymentBranch} is now at ${head?.slice(0, 12) ?? "<deleted>"}; this deployment's commit is no longer the head.`,
21811
22282
  buildSeconds: buildSeconds(),
22283
+ ...monitorOutcomes.length > 0 ? { results: monitorResults() } : {},
21812
22284
  ...head ? { observedHeadSha: head } : {}
21813
22285
  });
21814
22286
  return { finalStatus: "superseded", outcomes: [] };
@@ -21818,16 +22290,28 @@ async function runDeployment(params, hooks) {
21818
22290
  if (superseded) return superseded;
21819
22291
  }
21820
22292
  const { repoRoot } = await source.open(workDir);
21821
- const projectRoot = target.rootDirectory ? (0, import_node_path15.join)(repoRoot, target.rootDirectory) : repoRoot;
22293
+ const projectRoot = target.rootDirectory ? (0, import_node_path16.join)(repoRoot, target.rootDirectory) : repoRoot;
21822
22294
  const manifestFile = target.manifestPath || DEFAULT_MANIFEST_FILE;
21823
22295
  let manifest;
21824
22296
  let playFiles;
22297
+ let monitorEntries;
21825
22298
  try {
21826
22299
  manifest = await readDeeplineManifest(projectRoot, manifestFile);
21827
22300
  playFiles = await discoverPlayFiles({
21828
22301
  projectRoot,
21829
22302
  globs: manifest.plays
21830
22303
  });
22304
+ const discoveredMonitors = await readMonitorFiles({
22305
+ projectRoot,
22306
+ rootDirectory: target.rootDirectory,
22307
+ globs: manifest.monitors
22308
+ });
22309
+ if (!project && discoveredMonitors.length > 0) {
22310
+ throw new DeeplineManifestError(
22311
+ "Monitor Git deployment requires a linked repository. Deploy individual monitor files with deepline monitors deploy --file."
22312
+ );
22313
+ }
22314
+ monitorEntries = project && discoveredMonitors.length > 0 ? discoveredMonitors : void 0;
21831
22315
  } catch (error) {
21832
22316
  if (error instanceof DeeplineManifestError) {
21833
22317
  return await failWithCheck({
@@ -21852,7 +22336,28 @@ async function runDeployment(params, hooks) {
21852
22336
  });
21853
22337
  }
21854
22338
  }
21855
- if (playFiles.length === 0) {
22339
+ if (monitorEntries !== void 0) {
22340
+ const plan = await client2.monitors("plan", monitorEntries);
22341
+ monitorOutcomes = plan.monitors;
22342
+ const failed = monitorOutcomes.filter(
22343
+ (outcome) => outcome.status === "failed"
22344
+ );
22345
+ if (failed.length > 0) {
22346
+ return await failWithCheck({
22347
+ title: "Monitor validation failed",
22348
+ summary: monitorDeploymentSummary(monitorOutcomes),
22349
+ error: `${failed.length} monitor definition(s) failed validation.`,
22350
+ outcomes: [],
22351
+ annotations: failed.map(
22352
+ (outcome) => annotationForFailure({
22353
+ file: outcome.file,
22354
+ message: outcome.error ?? "Monitor validation failed."
22355
+ })
22356
+ )
22357
+ });
22358
+ }
22359
+ }
22360
+ if (playFiles.length === 0 && monitorOutcomes.length === 0) {
21856
22361
  const checkRun2 = await postCheckOrNull({
21857
22362
  conclusion: "neutral",
21858
22363
  title: "No plays matched",
@@ -21879,7 +22384,7 @@ async function runDeployment(params, hooks) {
21879
22384
  annotations.push(annotationForFailure({ file, message }));
21880
22385
  };
21881
22386
  for (const file of playFiles) {
21882
- const entryFile = (0, import_node_path15.join)(projectRoot, file);
22387
+ const entryFile = (0, import_node_path16.join)(projectRoot, file);
21883
22388
  const result = await hooks.bundle(entryFile, {
21884
22389
  sourceIdentityRoot: projectRoot
21885
22390
  });
@@ -21985,7 +22490,7 @@ async function runDeployment(params, hooks) {
21985
22490
  if (superseded) return superseded;
21986
22491
  }
21987
22492
  await setStatus({ status: "publishing" }).catch(() => void 0);
21988
- const states = await client2.playsState(ordered.map((play) => play.name));
22493
+ const states = ordered.length > 0 ? await client2.playsState(ordered.map((play) => play.name)) : { plays: [] };
21989
22494
  const stateByName = new Map(
21990
22495
  states.plays.map((play) => [play.name, play])
21991
22496
  );
@@ -22119,12 +22624,15 @@ async function runDeployment(params, hooks) {
22119
22624
  ).length;
22120
22625
  const checkRun2 = await postCheckOrNull({
22121
22626
  conclusion: "success",
22122
- title: `${ordered.length} play${ordered.length === 1 ? "" : "s"} validated and registered (not deployed)`,
22627
+ title: monitorEntries !== void 0 ? `${ordered.length} play(s) validated and registered; ${monitorEntries.length} monitor(s) checked (not deployed)` : `${ordered.length} play${ordered.length === 1 ? "" : "s"} validated and registered (not deployed)`,
22123
22628
  ...annotations.length > 0 ? { annotations } : {},
22124
- summary: outcomes.map(
22125
- (outcome) => `- \`${outcome.name}\`: ${outcome.status}${outcome.version !== void 0 ? ` (v${outcome.version})` : ""}${outcome.sdkUpdated ? " \u2014 SDK updated" : ""}${outcome.warning ? `
22629
+ summary: [
22630
+ outcomes.map(
22631
+ (outcome) => `- \`${outcome.name}\`: ${outcome.status}${outcome.version !== void 0 ? ` (v${outcome.version})` : ""}${outcome.sdkUpdated ? " \u2014 SDK updated" : ""}${outcome.warning ? `
22126
22632
  - :warning: ${outcome.warning}` : ""}`
22127
- ).join("\n")
22633
+ ).join("\n"),
22634
+ monitorDeploymentSummary(monitorOutcomes)
22635
+ ].filter(Boolean).join("\n")
22128
22636
  });
22129
22637
  const result = await finishSucceeded(outcomes, checkRun2);
22130
22638
  console.info("[deploy-worker] PR registration complete", {
@@ -22138,6 +22646,51 @@ async function runDeployment(params, hooks) {
22138
22646
  const superseded = await supersedeIfHeadMoved();
22139
22647
  if (superseded) return superseded;
22140
22648
  }
22649
+ if (monitorEntries !== void 0) {
22650
+ monitorOutcomes = (await client2.monitors("apply", monitorEntries)).monitors;
22651
+ await setStatus({
22652
+ status: "publishing",
22653
+ results: { plays: outcomes, ...monitorResults() }
22654
+ });
22655
+ const deadline = Date.now() + 10 * 6e4;
22656
+ while (monitorOutcomes.some((outcome) => outcome.status === "applying")) {
22657
+ if (Date.now() >= deadline) {
22658
+ throw new RetryableDeploymentError(
22659
+ "Monitor jobs are still reconciling. Retrying this deployment will resume the same jobs."
22660
+ );
22661
+ }
22662
+ await new Promise((resolve22) => setTimeout(resolve22, 1e3));
22663
+ for (let index = 0; index < monitorOutcomes.length; index += 1) {
22664
+ const outcome = monitorOutcomes[index];
22665
+ if (outcome.status !== "applying") continue;
22666
+ if (!outcome.jobId) {
22667
+ throw new Error(
22668
+ `Monitor ${outcome.key} has no reconciliation job.`
22669
+ );
22670
+ }
22671
+ const result = await client2.monitorJob(outcome.jobId, outcome.key);
22672
+ const settled = result.monitors.find(
22673
+ (monitor) => monitor.key === outcome.key && monitor.jobId === outcome.jobId
22674
+ );
22675
+ if (!settled) {
22676
+ throw new Error(`Monitor job ${outcome.jobId} returned no result.`);
22677
+ }
22678
+ monitorOutcomes[index] = { ...outcome, ...settled };
22679
+ }
22680
+ }
22681
+ if (monitorOutcomes.some(
22682
+ (outcome) => outcome.status === "failed" || outcome.status === "planned"
22683
+ )) {
22684
+ return await failWithCheck({
22685
+ title: "Monitor deployment failed",
22686
+ summary: monitorDeploymentSummary(monitorOutcomes),
22687
+ error: "Some monitor changes failed. Applied changes remain live; inspect the reported jobs before retrying.",
22688
+ outcomes
22689
+ });
22690
+ }
22691
+ const superseded = await supersedeIfHeadMoved();
22692
+ if (superseded) return { ...superseded, ...monitorRunResult() };
22693
+ }
22141
22694
  if (toPromote.length > 0) {
22142
22695
  try {
22143
22696
  const promotion = await client2.promote(toPromote);
@@ -22195,12 +22748,15 @@ async function runDeployment(params, hooks) {
22195
22748
  }
22196
22749
  const checkRun = await postCheckOrNull({
22197
22750
  conclusion: "success",
22198
- title: `Deployed ${outcomes.filter((o) => o.status === "promoted").length} play(s) (${outcomes.filter((o) => o.status === "unchanged").length} unchanged)`,
22751
+ title: `Deployed ${outcomes.filter((o) => o.status === "promoted").length} play(s) (${outcomes.filter((o) => o.status === "unchanged").length} unchanged)${monitorEntries !== void 0 ? `; ${monitorOutcomes.filter((outcome) => outcome.status === "applied").length} monitor(s) applied` : ""}`,
22199
22752
  ...annotations.length > 0 ? { annotations } : {},
22200
- summary: outcomes.map(
22201
- (outcome) => `- \`${outcome.name}\`: ${outcome.status}${outcome.sdkUpdated ? " \u2014 SDK updated" : ""}${outcome.warning ? `
22753
+ summary: [
22754
+ outcomes.map(
22755
+ (outcome) => `- \`${outcome.name}\`: ${outcome.status}${outcome.sdkUpdated ? " \u2014 SDK updated" : ""}${outcome.warning ? `
22202
22756
  - :warning: ${outcome.warning}` : ""}`
22203
- ).join("\n")
22757
+ ).join("\n"),
22758
+ monitorDeploymentSummary(monitorOutcomes)
22759
+ ].filter(Boolean).join("\n")
22204
22760
  });
22205
22761
  return await finishSucceeded(outcomes, checkRun);
22206
22762
  } catch (error) {
@@ -22246,12 +22802,13 @@ async function runDeployment(params, hooks) {
22246
22802
  await setStatus({
22247
22803
  status: "failed",
22248
22804
  error: message.slice(0, 2e3),
22805
+ ...monitorOutcomes.length > 0 ? { results: monitorResults() } : {},
22249
22806
  buildSeconds: buildSeconds(),
22250
22807
  ...checkRunId ? { checkRunId } : {}
22251
22808
  }).catch(() => void 0);
22252
22809
  throw error;
22253
22810
  } finally {
22254
- await (0, import_promises7.rm)(workDir, { recursive: true, force: true }).catch(() => void 0);
22811
+ await (0, import_promises8.rm)(workDir, { recursive: true, force: true }).catch(() => void 0);
22255
22812
  }
22256
22813
  }
22257
22814
  function topoSortByPlayDependencies(plays) {
@@ -22315,8 +22872,8 @@ function printResult(input2) {
22315
22872
  );
22316
22873
  }
22317
22874
  async function handlePlaysDeploy(directory, options) {
22318
- const root = await (0, import_promises8.realpath)((0, import_node_path16.resolve)(directory ?? ".")).catch(() => {
22319
- throw new Error(`No such directory: ${(0, import_node_path16.resolve)(directory ?? ".")}`);
22875
+ const root = await (0, import_promises9.realpath)((0, import_node_path17.resolve)(directory ?? ".")).catch(() => {
22876
+ throw new Error(`No such directory: ${(0, import_node_path17.resolve)(directory ?? ".")}`);
22320
22877
  });
22321
22878
  const { http, config } = getAuthedHttpClient();
22322
22879
  const deliveryId = `local:${(0, import_node_crypto6.randomUUID)()}`;
@@ -22327,7 +22884,7 @@ async function handlePlaysDeploy(directory, options) {
22327
22884
  ...options.commit ? { commit: options.commit } : {}
22328
22885
  });
22329
22886
  const { bundleDeployPlayFile } = await loadPlayBundler();
22330
- const workRoot = await (0, import_promises8.mkdtemp)((0, import_node_path16.join)((0, import_node_os9.tmpdir)(), "deepline-deploy-"));
22887
+ const workRoot = await (0, import_promises9.mkdtemp)((0, import_node_path17.join)((0, import_node_os9.tmpdir)(), "deepline-deploy-"));
22331
22888
  const consoleInfo = console.info;
22332
22889
  console.info = console.error;
22333
22890
  try {
@@ -22345,6 +22902,7 @@ async function handlePlaysDeploy(directory, options) {
22345
22902
  },
22346
22903
  {
22347
22904
  bundle: bundleDeployPlayFile,
22905
+ fetchImpl: fetchWithDeploymentProtection,
22348
22906
  // The plays are already here: "opening" the source is naming it.
22349
22907
  openSource: async () => ({
22350
22908
  open: async () => ({ repoRoot: root })
@@ -22380,7 +22938,7 @@ async function handlePlaysDeploy(directory, options) {
22380
22938
  }
22381
22939
  } finally {
22382
22940
  console.info = consoleInfo;
22383
- await (0, import_promises8.rm)(workRoot, { recursive: true, force: true });
22941
+ await (0, import_promises9.rm)(workRoot, { recursive: true, force: true });
22384
22942
  }
22385
22943
  }
22386
22944
 
@@ -22728,10 +23286,22 @@ function renderDeploymentPlayLines(results) {
22728
23286
  ];
22729
23287
  });
22730
23288
  }
23289
+ function renderDeploymentMonitorLines(results) {
23290
+ const monitors = results?.monitors;
23291
+ if (!Array.isArray(monitors)) return [];
23292
+ return monitors.flatMap((monitor) => [
23293
+ `${monitor.key ?? "?"}${monitor.file ? ` (${monitor.file})` : ""} - ${monitor.status ?? "?"}`,
23294
+ ...monitor.jobId ? [` job: ${monitor.jobId}`] : [],
23295
+ ...monitor.credits != null ? [` Deepline credits: ${monitor.credits}`] : [],
23296
+ ...monitor.error ? [` error: ${monitor.error}`] : [],
23297
+ ...monitor.warning ? [` warning: ${monitor.warning}`] : []
23298
+ ]);
23299
+ }
22731
23300
  async function handleDeploymentGet(id, options) {
22732
23301
  const { http } = getAuthedHttpClient();
22733
23302
  const payload = await http.get(`/api/v2/deployments/${encodeURIComponent(id)}`);
22734
23303
  const playLines = renderDeploymentPlayLines(payload.deployment.results);
23304
+ const monitorLines = renderDeploymentMonitorLines(payload.deployment.results);
22735
23305
  const repository = payload.project?.repoFullName ?? payload.deployment.repoFullName;
22736
23306
  printCommandEnvelope(
22737
23307
  {
@@ -22743,7 +23313,8 @@ async function handleDeploymentGet(id, options) {
22743
23313
  title: `deployment ${payload.deployment.id}${repository ? ` (${repository})` : ""}`,
22744
23314
  lines: [renderDeployment(payload.deployment)]
22745
23315
  },
22746
- ...playLines.length ? [{ title: "plays", lines: playLines }] : []
23316
+ ...playLines.length ? [{ title: "plays", lines: playLines }] : [],
23317
+ ...monitorLines.length ? [{ title: "monitors", lines: monitorLines }] : []
22747
23318
  ]
22748
23319
  }
22749
23320
  },
@@ -22939,7 +23510,7 @@ function isBarePlayRunDebugFlag(args, index) {
22939
23510
  }
22940
23511
  async function pathExistsIncludingSymlink(path) {
22941
23512
  try {
22942
- await (0, import_promises9.lstat)(path);
23513
+ await (0, import_promises10.lstat)(path);
22943
23514
  return true;
22944
23515
  } catch (error) {
22945
23516
  if (error.code === "ENOENT") {
@@ -22949,14 +23520,14 @@ async function pathExistsIncludingSymlink(path) {
22949
23520
  }
22950
23521
  }
22951
23522
  function runIdFileTempPath(destination) {
22952
- return (0, import_node_path17.join)(
22953
- (0, import_node_path17.dirname)(destination),
22954
- `.${(0, import_node_path17.basename)(destination)}.${process.pid}.${(0, import_node_crypto7.randomUUID)()}.tmp`
23523
+ return (0, import_node_path18.join)(
23524
+ (0, import_node_path18.dirname)(destination),
23525
+ `.${(0, import_node_path18.basename)(destination)}.${process.pid}.${(0, import_node_crypto7.randomUUID)()}.tmp`
22955
23526
  );
22956
23527
  }
22957
23528
  async function removeRunIdTempFile(path) {
22958
23529
  try {
22959
- await (0, import_promises9.unlink)(path);
23530
+ await (0, import_promises10.unlink)(path);
22960
23531
  } catch (error) {
22961
23532
  if (error.code !== "ENOENT") {
22962
23533
  throw error;
@@ -22964,7 +23535,7 @@ async function removeRunIdTempFile(path) {
22964
23535
  }
22965
23536
  }
22966
23537
  async function preflightRunIdFile(path) {
22967
- const destination = (0, import_node_path17.resolve)(path);
23538
+ const destination = (0, import_node_path18.resolve)(path);
22968
23539
  if (await pathExistsIncludingSymlink(destination)) {
22969
23540
  throw new Error(
22970
23541
  `--run-id-file destination already exists: ${destination}. Choose a new path so this run cannot overwrite another run identity.`
@@ -22973,7 +23544,7 @@ async function preflightRunIdFile(path) {
22973
23544
  const tempPath = runIdFileTempPath(destination);
22974
23545
  let handle = null;
22975
23546
  try {
22976
- handle = await (0, import_promises9.open)(tempPath, "wx", 384);
23547
+ handle = await (0, import_promises10.open)(tempPath, "wx", 384);
22977
23548
  await handle.sync();
22978
23549
  } catch (error) {
22979
23550
  throw new Error(
@@ -22991,7 +23562,7 @@ async function readRunIdFile(destination) {
22991
23562
  }
22992
23563
  let parsed;
22993
23564
  try {
22994
- parsed = JSON.parse(await (0, import_promises9.readFile)(destination, "utf8"));
23565
+ parsed = JSON.parse(await (0, import_promises10.readFile)(destination, "utf8"));
22995
23566
  } catch (error) {
22996
23567
  throw new Error(
22997
23568
  `--run-id-file destination contains invalid JSON: ${destination}. Refusing to overwrite it (${error instanceof Error ? error.message : String(error)}).`
@@ -23017,7 +23588,7 @@ async function writePlayRunIdFile(destination, runId, options = {}) {
23017
23588
  const tempPath = runIdFileTempPath(destination);
23018
23589
  let handle = null;
23019
23590
  try {
23020
- handle = await (0, import_promises9.open)(tempPath, "wx", 384);
23591
+ handle = await (0, import_promises10.open)(tempPath, "wx", 384);
23021
23592
  await handle.writeFile(
23022
23593
  `${JSON.stringify({ version: 1, runId, ...options })}
23023
23594
  `,
@@ -23027,10 +23598,10 @@ async function writePlayRunIdFile(destination, runId, options = {}) {
23027
23598
  await handle.close();
23028
23599
  handle = null;
23029
23600
  if (existing) {
23030
- await (0, import_promises9.rename)(tempPath, destination);
23601
+ await (0, import_promises10.rename)(tempPath, destination);
23031
23602
  } else {
23032
23603
  try {
23033
- await (0, import_promises9.link)(tempPath, destination);
23604
+ await (0, import_promises10.link)(tempPath, destination);
23034
23605
  } catch (error) {
23035
23606
  if (error.code !== "EEXIST") throw error;
23036
23607
  const raced = await readRunIdFile(destination);
@@ -23040,11 +23611,11 @@ async function writePlayRunIdFile(destination, runId, options = {}) {
23040
23611
  );
23041
23612
  }
23042
23613
  if (!options.launchConfirmed || raced.launchConfirmed) return;
23043
- await (0, import_promises9.rename)(tempPath, destination);
23614
+ await (0, import_promises10.rename)(tempPath, destination);
23044
23615
  }
23045
23616
  }
23046
23617
  if (process.platform !== "win32") {
23047
- const directory = await (0, import_promises9.open)((0, import_node_path17.dirname)(destination), "r");
23618
+ const directory = await (0, import_promises10.open)((0, import_node_path18.dirname)(destination), "r");
23048
23619
  try {
23049
23620
  await directory.sync();
23050
23621
  } finally {
@@ -23056,7 +23627,7 @@ async function writePlayRunIdFile(destination, runId, options = {}) {
23056
23627
  await removeRunIdTempFile(tempPath);
23057
23628
  }
23058
23629
  }
23059
- function traceCliSync(phase, fields, run) {
23630
+ function traceCliSync(phase, fields2, run) {
23060
23631
  const startedAt = Date.now();
23061
23632
  try {
23062
23633
  const result = run();
@@ -23064,7 +23635,7 @@ function traceCliSync(phase, fields, run) {
23064
23635
  phase,
23065
23636
  ms: Date.now() - startedAt,
23066
23637
  ok: true,
23067
- ...fields
23638
+ ...fields2
23068
23639
  });
23069
23640
  return result;
23070
23641
  } catch (error) {
@@ -23073,7 +23644,7 @@ function traceCliSync(phase, fields, run) {
23073
23644
  ms: Date.now() - startedAt,
23074
23645
  ok: false,
23075
23646
  error: error instanceof Error ? error.message : String(error),
23076
- ...fields
23647
+ ...fields2
23077
23648
  });
23078
23649
  throw error;
23079
23650
  }
@@ -23333,7 +23904,7 @@ function formatPlayListReference(play) {
23333
23904
  return play.reference || play.name;
23334
23905
  }
23335
23906
  function defaultMaterializedPlayPath(reference) {
23336
- return (0, import_node_path17.resolve)(defaultStarterPlayPath(reference));
23907
+ return (0, import_node_path18.resolve)(defaultStarterPlayPath(reference));
23337
23908
  }
23338
23909
  function defaultStarterPlayPath(reference) {
23339
23910
  const playName = parseReferencedPlayTarget2(reference).unqualifiedPlayName;
@@ -23366,18 +23937,18 @@ function materializeRemotePlaySource(input2) {
23366
23937
  `Play ${input2.playName} has ${files.length} source files. Use --out <directory> to write the complete bundle.`
23367
23938
  );
23368
23939
  }
23369
- const outputDirectory = (0, import_node_path17.resolve)(input2.outPath);
23940
+ const outputDirectory = (0, import_node_path18.resolve)(input2.outPath);
23370
23941
  let created = 0;
23371
23942
  let updated = 0;
23372
23943
  for (const [logicalPath, sourceCode] of files) {
23373
- const outputPath2 = (0, import_node_path17.resolve)(outputDirectory, logicalPath);
23374
- const outputRelativePath = (0, import_node_path17.relative)(outputDirectory, outputPath2);
23375
- if (!outputRelativePath || outputRelativePath.startsWith("..") || (0, import_node_path17.isAbsolute)(outputRelativePath)) {
23944
+ const outputPath2 = (0, import_node_path18.resolve)(outputDirectory, logicalPath);
23945
+ const outputRelativePath = (0, import_node_path18.relative)(outputDirectory, outputPath2);
23946
+ if (!outputRelativePath || outputRelativePath.startsWith("..") || (0, import_node_path18.isAbsolute)(outputRelativePath)) {
23376
23947
  throw new Error(
23377
23948
  `Refusing to materialize unsafe Play source path ${JSON.stringify(logicalPath)}.`
23378
23949
  );
23379
23950
  }
23380
- (0, import_node_fs12.mkdirSync)((0, import_node_path17.dirname)(outputPath2), { recursive: true });
23951
+ (0, import_node_fs12.mkdirSync)((0, import_node_path18.dirname)(outputPath2), { recursive: true });
23381
23952
  if (!(0, import_node_fs12.existsSync)(outputPath2)) {
23382
23953
  (0, import_node_fs12.writeFileSync)(outputPath2, sourceCode, "utf-8");
23383
23954
  created += 1;
@@ -23447,7 +24018,7 @@ function extractPlayName(code, filePath) {
23447
24018
  throw buildMissingDefinePlayError(filePath);
23448
24019
  }
23449
24020
  function isFileTarget(target) {
23450
- return (0, import_node_fs12.existsSync)((0, import_node_path17.resolve)(target));
24021
+ return (0, import_node_fs12.existsSync)((0, import_node_path18.resolve)(target));
23451
24022
  }
23452
24023
  function looksLikeRunId(target) {
23453
24024
  return /^play\/[^/]+\/run\/[^/]+/.test(target.trim());
@@ -23476,7 +24047,7 @@ function parsePositiveInteger3(value, flagName) {
23476
24047
  return parsed;
23477
24048
  }
23478
24049
  function parseJsonInput(raw) {
23479
- const source = raw.startsWith("@") ? (0, import_node_fs12.readFileSync)((0, import_node_path17.resolve)(raw.slice(1)), "utf-8") : raw;
24050
+ const source = raw.startsWith("@") ? (0, import_node_fs12.readFileSync)((0, import_node_path18.resolve)(raw.slice(1)), "utf-8") : raw;
23480
24051
  const parsed = JSON.parse(source);
23481
24052
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
23482
24053
  throw new Error("--input must be a JSON object.");
@@ -23580,7 +24151,7 @@ function fileInputBindingsFromStaticPipeline(staticPipeline) {
23580
24151
  function isLocalFilePathValue(value) {
23581
24152
  if (typeof value !== "string" || !value.trim()) return false;
23582
24153
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
23583
- return (0, import_node_fs12.existsSync)((0, import_node_path17.resolve)(value));
24154
+ return (0, import_node_fs12.existsSync)((0, import_node_path18.resolve)(value));
23584
24155
  }
23585
24156
  function inputContainsLocalFilePath(value) {
23586
24157
  if (isLocalFilePathValue(value)) {
@@ -23627,7 +24198,7 @@ function collectLocalFileInputRefs(value, inputPath, key, out) {
23627
24198
  const looksLikeFile = /\.[a-z0-9]{1,8}$/i.test(trimmed);
23628
24199
  if (keyIsCsvData) {
23629
24200
  out.push({ inputPath, value: trimmed, isCsvData: true });
23630
- } else if (endsWithCsv || looksLikeFile && (0, import_node_fs12.existsSync)((0, import_node_path17.resolve)(trimmed))) {
24201
+ } else if (endsWithCsv || looksLikeFile && (0, import_node_fs12.existsSync)((0, import_node_path18.resolve)(trimmed))) {
23631
24202
  out.push({ inputPath, value: trimmed, isCsvData: false });
23632
24203
  }
23633
24204
  return;
@@ -23669,7 +24240,7 @@ function preflightLocalFileInputs(runtimeInput) {
23669
24240
  collectLocalFileInputRefs(value, key, key, refs);
23670
24241
  }
23671
24242
  for (const ref of refs) {
23672
- const absolutePath = (0, import_node_path17.resolve)(ref.value);
24243
+ const absolutePath = (0, import_node_path18.resolve)(ref.value);
23673
24244
  if (!(0, import_node_fs12.existsSync)(absolutePath)) {
23674
24245
  throw new DeeplineError(
23675
24246
  `Input ${ref.inputPath} references a local file that does not exist: ${ref.value} (resolved to ${absolutePath}). No run was created.`,
@@ -23788,8 +24359,8 @@ async function stageFileInputArgs(input2) {
23788
24359
  const localFiles = uniqueBindings.flatMap((binding) => {
23789
24360
  const value = getDottedInputValue(input2.runtimeInput, binding.inputPath);
23790
24361
  if (!isLocalFilePathValue(value)) return [];
23791
- const absolutePath = (0, import_node_path17.resolve)(value);
23792
- return [{ binding, absolutePath, logicalPath: (0, import_node_path17.basename)(absolutePath) }];
24362
+ const absolutePath = (0, import_node_path18.resolve)(value);
24363
+ return [{ binding, absolutePath, logicalPath: (0, import_node_path18.basename)(absolutePath) }];
23793
24364
  });
23794
24365
  if (localFiles.length === 0) {
23795
24366
  return { inputFile: null, packagedFiles: [] };
@@ -23832,9 +24403,9 @@ function stageFile(logicalPath, absolutePath) {
23832
24403
  }
23833
24404
  function normalizePlayPath(filePath) {
23834
24405
  try {
23835
- return import_node_fs12.realpathSync.native((0, import_node_path17.resolve)(filePath));
24406
+ return import_node_fs12.realpathSync.native((0, import_node_path18.resolve)(filePath));
23836
24407
  } catch {
23837
- return (0, import_node_path17.resolve)(filePath);
24408
+ return (0, import_node_path18.resolve)(filePath);
23838
24409
  }
23839
24410
  }
23840
24411
  function formatBundlingErrors(filePath, errors) {
@@ -24397,7 +24968,8 @@ function formatProgressCounts(input2) {
24397
24968
  Math.min(100, Math.round(completed / total * 100))
24398
24969
  );
24399
24970
  const failed = typeof input2.failed === "number" && Number.isFinite(input2.failed) && input2.failed > 0 ? `, failed ${formatInteger(input2.failed)}` : "";
24400
- return `${formatInteger(completed)}/${formatInteger(total)} (${percent}%)${failed}`;
24971
+ const completedLabel = typeof input2.failed === "number" ? "successful " : "";
24972
+ return `${completedLabel}${formatInteger(completed)}/${formatInteger(total)} (${percent}%)${failed}`;
24401
24973
  }
24402
24974
  function formatProgressMessageSuffix(input2) {
24403
24975
  const message = typeof input2.message === "string" ? input2.message.trim() : "";
@@ -25283,8 +25855,8 @@ function formatPlayLogLine(rawLine, status, state) {
25283
25855
  if (!logLevelReaches("info", state.logLevel ?? "info")) {
25284
25856
  return null;
25285
25857
  }
25286
- const [, rows, fields, namespace, cached, pending] = mapStart;
25287
- return `${prefix}map ${sourceLabelForNamespace(namespace)}: ${formatInteger(Number(rows))} rows, ${fields} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
25858
+ const [, rows, fields2, namespace, cached, pending] = mapStart;
25859
+ return `${prefix}map ${sourceLabelForNamespace(namespace)}: ${formatInteger(Number(rows))} rows, ${fields2} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
25288
25860
  }
25289
25861
  const mapDone = message.match(
25290
25862
  /^Map completed: (\d+) results \((\d+) executed, (\d+) already satisfied\)$/
@@ -26338,6 +26910,54 @@ function buildRunActivityTextLines(run) {
26338
26910
  if (observedAt) lines.push(` observed: ${observedAt}`);
26339
26911
  return lines;
26340
26912
  }
26913
+ function formatObservedRunCounter(value) {
26914
+ const counter = readRecord(value);
26915
+ const count = counter?.value;
26916
+ if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) {
26917
+ return "unknown";
26918
+ }
26919
+ return counter?.confirmed === true ? formatInteger(count) : `${formatInteger(count)} observed`;
26920
+ }
26921
+ function buildRunStatusEvidenceTextLines(packaged) {
26922
+ const evidence = readRecord(packaged.runStatus);
26923
+ if (!evidence || evidence.available !== true) return [];
26924
+ const calls = readRecord(evidence.calls);
26925
+ const lines = [];
26926
+ if (calls) {
26927
+ lines.push(
26928
+ ` calls: ${formatObservedRunCounter(calls.logicalCalls)} logical, ${formatObservedRunCounter(calls.toolDispatches)} tool dispatches, ${formatObservedRunCounter(calls.provider429s)} provider 429s`
26929
+ );
26930
+ }
26931
+ const source = readRecord(evidence.source);
26932
+ if (source?.aligned === false) {
26933
+ lines.push(
26934
+ ` consistency: run snapshot event ${String(source.runSnapshotLedgerNextSeq)} and progress event ${String(source.ledgerNextSeq)} differ; retry this read to align them`
26935
+ );
26936
+ }
26937
+ const focus = readRecord(evidence.focusStep);
26938
+ const rows = readRecord(focus?.rows);
26939
+ if (focus) {
26940
+ const id = typeof focus.id === "string" && focus.id.trim() ? focus.id.trim() : "unknown step";
26941
+ const label = typeof focus.label === "string" && focus.label.trim() ? ` (${focus.label.trim()})` : "";
26942
+ const state = typeof focus.status === "string" && focus.status.trim() ? `: ${focus.status.trim()}` : "";
26943
+ const rowCounts = rows ? `; rows ${formatObservedRunCounter({ value: rows.succeeded, confirmed: true })} succeeded, ${formatObservedRunCounter({ value: rows.failed, confirmed: true })} failed, ${formatObservedRunCounter({ value: rows.total, confirmed: true })} total` : "";
26944
+ lines.push(` current step: ${id}${label}${state}${rowCounts}`);
26945
+ }
26946
+ return lines;
26947
+ }
26948
+ function buildRecentRunLogTextLines(packaged) {
26949
+ const logs = readRecord(packaged.logs);
26950
+ const tail = Array.isArray(logs?.tail) ? logs.tail.filter((line) => typeof line === "string") : [];
26951
+ if (tail.length === 0) return [];
26952
+ const visible = tail.slice(-5);
26953
+ const total = typeof logs?.totalCount === "number" && Number.isFinite(logs.totalCount) ? ` of ${formatInteger(logs.totalCount)}` : "";
26954
+ const lines = [` recent logs: showing ${visible.length}${total}`];
26955
+ lines.push(...visible.map((line) => ` ${line}`));
26956
+ if (logs?.truncated === true) {
26957
+ lines.push(" older log lines were truncated by the retention cap");
26958
+ }
26959
+ return lines;
26960
+ }
26341
26961
  function buildRunPackageTextLines(packaged) {
26342
26962
  const run = readRunPackageRun(packaged);
26343
26963
  const runId = typeof run.id === "string" ? run.id : "unknown";
@@ -26407,6 +27027,8 @@ function buildRunPackageTextLines(packaged) {
26407
27027
  if (!isRuntimeLimitCheckpoint) {
26408
27028
  lines.push(...buildRunActivityTextLines(run));
26409
27029
  }
27030
+ lines.push(...buildRunStatusEvidenceTextLines(packaged));
27031
+ lines.push(...buildRecentRunLogTextLines(packaged));
26410
27032
  lines.push(...formatPackageValueOutputLines(packaged));
26411
27033
  lines.push(
26412
27034
  ...formatPackageDatasetActionLines(packaged, {
@@ -26414,12 +27036,7 @@ function buildRunPackageTextLines(packaged) {
26414
27036
  })
26415
27037
  );
26416
27038
  const next = packaged.next && typeof packaged.next === "object" && !Array.isArray(packaged.next) ? packaged.next : {};
26417
- const billingCommand = actionToCommand(next.billing);
26418
27039
  const logsCommand = actionToCommand(next.logs);
26419
- if (billingCommand) {
26420
- const costState = status === "completed" || status === "failed" || status === "cancelled" ? "settles asynchronously \u2014 run the billing command below for totals" : "pending";
26421
- lines.push(` cost: ${costState}`);
26422
- }
26423
27040
  for (const step of isRuntimeLimitCheckpoint ? [] : readRecordArray(packaged.steps).slice(0, 8)) {
26424
27041
  const id = typeof step.id === "string" ? step.id : "step";
26425
27042
  const kind = typeof step.kind === "string" ? step.kind : "step";
@@ -26449,7 +27066,6 @@ function buildRunPackageTextLines(packaged) {
26449
27066
  ` ${isRuntimeTimeout ? "full run details" : "full result"}: ${fullResultCommand}`
26450
27067
  );
26451
27068
  if (logsCommand) lines.push(` logs: ${logsCommand}`);
26452
- if (billingCommand) lines.push(` billing: ${billingCommand}`);
26453
27069
  if (legacyExportCommand) {
26454
27070
  lines.push(` export CSV: ${legacyExportCommand}`);
26455
27071
  }
@@ -26649,7 +27265,7 @@ function shellSingleQuote(value) {
26649
27265
  return `'${value.replace(/'/g, `'\\''`)}'`;
26650
27266
  }
26651
27267
  function runExportRetryCommand(runId, outPath, datasetPath) {
26652
- return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0, import_node_path17.resolve)(outPath))}`;
27268
+ return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0, import_node_path18.resolve)(outPath))}`;
26653
27269
  }
26654
27270
  function extractRunPlayName(status) {
26655
27271
  const run = status.run;
@@ -26791,7 +27407,7 @@ async function fetchBackingDatasetRows(input2) {
26791
27407
  function exportDatasetCommand(input2) {
26792
27408
  return `deepline runs export ${input2.runId} --dataset ${shellSingleQuote(
26793
27409
  input2.datasetPath
26794
- )} --out ${shellSingleQuote((0, import_node_path17.resolve)(input2.outPath))}`;
27410
+ )} --out ${shellSingleQuote((0, import_node_path18.resolve)(input2.outPath))}`;
26795
27411
  }
26796
27412
  function datasetChoiceLines(input2) {
26797
27413
  return input2.datasets.flatMap((dataset) => {
@@ -28115,7 +28731,7 @@ async function handlePlayCheck(args) {
28115
28731
  }
28116
28732
  return 0;
28117
28733
  } catch (error) {
28118
- const resolved = (0, import_node_path17.resolve)(options.target);
28734
+ const resolved = (0, import_node_path18.resolve)(options.target);
28119
28735
  const message = error instanceof Error && error.message ? error.message : `File not found: ${resolved}`;
28120
28736
  if (options.jsonOutput) {
28121
28737
  printCompactJson({
@@ -28129,7 +28745,7 @@ async function handlePlayCheck(args) {
28129
28745
  return 1;
28130
28746
  }
28131
28747
  }
28132
- const absolutePlayPath = (0, import_node_path17.resolve)(options.target);
28748
+ const absolutePlayPath = (0, import_node_path18.resolve)(options.target);
28133
28749
  const sourceCode = (0, import_node_fs12.readFileSync)(absolutePlayPath, "utf-8");
28134
28750
  const exportNames = resolvePlayCheckExportNames(sourceCode);
28135
28751
  const outcomes = [];
@@ -28371,7 +28987,7 @@ async function handleFileBackedRun(options, hooks) {
28371
28987
  }
28372
28988
  const client2 = new DeeplineClient(playRunClientOptions(options));
28373
28989
  const progress = getActiveCliProgress() ?? createCliProgress(!options.jsonOutput);
28374
- const absolutePlayPath = (0, import_node_path17.resolve)(options.target.path);
28990
+ const absolutePlayPath = (0, import_node_path18.resolve)(options.target.path);
28375
28991
  progress.phase("compiling play");
28376
28992
  const sourceCode = traceCliSync(
28377
28993
  "cli.play_file_read_source",
@@ -28788,11 +29404,11 @@ async function handlePlayRun(args, hooks) {
28788
29404
  if (isFileTarget(options.target.path)) {
28789
29405
  return handleFileBackedRun(options, runHooks);
28790
29406
  }
28791
- const resolved = (0, import_node_path17.resolve)(options.target.path);
29407
+ const resolved = (0, import_node_path18.resolve)(options.target.path);
28792
29408
  console.error(`File not found: ${resolved}`);
28793
- const dir = (0, import_node_path17.dirname)(resolved);
29409
+ const dir = (0, import_node_path18.dirname)(resolved);
28794
29410
  if ((0, import_node_fs12.existsSync)(dir)) {
28795
- const base = (0, import_node_path17.basename)(resolved);
29411
+ const base = (0, import_node_path18.basename)(resolved);
28796
29412
  try {
28797
29413
  const siblings = (0, import_node_fs12.readdirSync)(dir).filter(
28798
29414
  (f) => f.includes(base.replace(/\.(play\.)?ts$/, "")) || f.endsWith(".play.ts")
@@ -28800,7 +29416,7 @@ async function handlePlayRun(args, hooks) {
28800
29416
  if (siblings.length > 0) {
28801
29417
  console.error(`Did you mean one of these?`);
28802
29418
  for (const s of siblings.slice(0, 5)) {
28803
- console.error(` ${(0, import_node_path17.join)(dir, s)}`);
29419
+ console.error(` ${(0, import_node_path18.join)(dir, s)}`);
28804
29420
  }
28805
29421
  }
28806
29422
  } catch {
@@ -29237,7 +29853,7 @@ async function handleRunLogs(args) {
29237
29853
  continue;
29238
29854
  }
29239
29855
  if (arg === "--out" && args[index + 1]) {
29240
- outPath = (0, import_node_path17.resolve)(args[++index]);
29856
+ outPath = (0, import_node_path18.resolve)(args[++index]);
29241
29857
  continue;
29242
29858
  }
29243
29859
  if (arg.startsWith("--")) {
@@ -29533,7 +30149,7 @@ async function handleRunExport(args) {
29533
30149
  for (let index = 0; index < args.length; index += 1) {
29534
30150
  const arg = args[index];
29535
30151
  if (arg === "--out" && args[index + 1]) {
29536
- outPath = (0, import_node_path17.resolve)(args[++index]);
30152
+ outPath = (0, import_node_path18.resolve)(args[++index]);
29537
30153
  continue;
29538
30154
  }
29539
30155
  if (arg === "--dataset" && args[index + 1]) {
@@ -29541,7 +30157,7 @@ async function handleRunExport(args) {
29541
30157
  continue;
29542
30158
  }
29543
30159
  if (arg === "--metadata-out" && args[index + 1]) {
29544
- metadataOutPath = (0, import_node_path17.resolve)(args[++index]);
30160
+ metadataOutPath = (0, import_node_path18.resolve)(args[++index]);
29545
30161
  }
29546
30162
  }
29547
30163
  if (!outPath) {
@@ -29637,7 +30253,7 @@ async function handlePlayGet(args) {
29637
30253
  for (let index = 1; index < args.length; index += 1) {
29638
30254
  const arg = args[index];
29639
30255
  if (arg === "--out" && args[index + 1]) {
29640
- outPath = (0, import_node_path17.resolve)(args[++index]);
30256
+ outPath = (0, import_node_path18.resolve)(args[++index]);
29641
30257
  }
29642
30258
  if (arg === "--revision") {
29643
30259
  const rawVersion = args[++index];
@@ -29658,7 +30274,7 @@ async function handlePlayGet(args) {
29658
30274
  );
29659
30275
  return 2;
29660
30276
  }
29661
- const playName = isFileTarget(target) ? extractPlayName((0, import_node_fs12.readFileSync)((0, import_node_path17.resolve)(target), "utf-8"), (0, import_node_path17.resolve)(target)) : parseReferencedPlayTarget2(target).playName;
30277
+ const playName = isFileTarget(target) ? extractPlayName((0, import_node_fs12.readFileSync)((0, import_node_path18.resolve)(target), "utf-8"), (0, import_node_path18.resolve)(target)) : parseReferencedPlayTarget2(target).playName;
29662
30278
  const includeSource = sourceOutput || outPath !== null;
29663
30279
  const detail = isFileTarget(target) ? await client2.getPlay(
29664
30280
  playName,
@@ -30044,8 +30660,8 @@ function printPlayDescription(play) {
30044
30660
  }
30045
30661
  }
30046
30662
  function inputFieldNames(schema) {
30047
- const fields = Array.isArray(schema?.fields) ? schema.fields : [];
30048
- return fields.map(
30663
+ const fields2 = Array.isArray(schema?.fields) ? schema.fields : [];
30664
+ return fields2.map(
30049
30665
  (field) => field && typeof field === "object" ? String(field.name ?? "").trim() : ""
30050
30666
  ).filter(Boolean);
30051
30667
  }
@@ -30062,9 +30678,9 @@ function printCompactPlaySearchResult(play) {
30062
30678
  if (aliases) {
30063
30679
  console.log(` Aliases: ${aliases}`);
30064
30680
  }
30065
- const fields = inputFieldNames(play.inputSchema);
30066
- if (fields.length > 0) {
30067
- console.log(` Inputs: ${fields.join(", ")}`);
30681
+ const fields2 = inputFieldNames(play.inputSchema);
30682
+ if (fields2.length > 0) {
30683
+ console.log(` Inputs: ${fields2.join(", ")}`);
30068
30684
  } else if (play.inputSchema) {
30069
30685
  console.log(" Inputs: see describe");
30070
30686
  }
@@ -30073,14 +30689,14 @@ function printCompactPlaySearchResult(play) {
30073
30689
  }
30074
30690
  function compactPlaySchema(schema) {
30075
30691
  if (!schema) return null;
30076
- const fields = Array.isArray(schema.fields) ? schema.fields.map(
30692
+ const fields2 = Array.isArray(schema.fields) ? schema.fields.map(
30077
30693
  (field) => field && typeof field === "object" ? {
30078
30694
  name: String(field.name ?? ""),
30079
30695
  type: field.type ?? void 0,
30080
30696
  required: field.required ?? void 0
30081
30697
  } : null
30082
30698
  ).filter((field) => Boolean(field?.name)) : [];
30083
- return fields.length > 0 ? { fields } : schema;
30699
+ return fields2.length > 0 ? { fields: fields2 } : schema;
30084
30700
  }
30085
30701
  function summarizePlayGrepResult(play) {
30086
30702
  const reference = formatPlayListReference(play);
@@ -30204,7 +30820,7 @@ async function handlePlayDescribe(args) {
30204
30820
  const definedName = isFileTarget(playName) ? (() => {
30205
30821
  try {
30206
30822
  return extractPlayName(
30207
- (0, import_node_fs12.readFileSync)((0, import_node_path17.resolve)(playName), "utf-8"),
30823
+ (0, import_node_fs12.readFileSync)((0, import_node_path18.resolve)(playName), "utf-8"),
30208
30824
  playName
30209
30825
  );
30210
30826
  } catch {
@@ -30266,7 +30882,7 @@ async function handlePlaySave(args) {
30266
30882
  graph = await traceCliSpan(
30267
30883
  "cli.play_save_bundle_graph",
30268
30884
  { targetKind: "file" },
30269
- () => collectBundledPlayGraph((0, import_node_path17.resolve)(options.target))
30885
+ () => collectBundledPlayGraph((0, import_node_path18.resolve)(options.target))
30270
30886
  );
30271
30887
  assertBundledPlayGraphDescriptions(graph);
30272
30888
  } catch (error) {
@@ -30391,7 +31007,7 @@ async function handlePlayPublish(args) {
30391
31007
  graph = await traceCliSpan(
30392
31008
  "cli.play_publish_bundle_graph",
30393
31009
  { targetKind: "file" },
30394
- () => collectBundledPlayGraph((0, import_node_path17.resolve)(playName))
31010
+ () => collectBundledPlayGraph((0, import_node_path18.resolve)(playName))
30395
31011
  );
30396
31012
  assertBundledPlayGraphDescriptions(graph);
30397
31013
  } catch (error) {
@@ -30709,6 +31325,8 @@ Concepts:
30709
31325
  Installed npm and repo-local CLIs can run saved/prebuilt plays by name or
30710
31326
  bundle local .play.ts files for development workflows.
30711
31327
  Running a local file does not make it live; use publish or set-live for that.
31328
+ plays settings organizes a Play independently of code revisions.
31329
+ New Plays start at person; publishing moves them to team, preserving folders.
30712
31330
 
30713
31331
  Authoring:
30714
31332
  Use normal TypeScript interpolation for human-facing strings:
@@ -30914,6 +31532,7 @@ Pass-through input flags:
30914
31532
  process.exitCode = exitCode;
30915
31533
  });
30916
31534
  registerPlayBootstrapCommand(play);
31535
+ registerPlaySettingsCommands(play);
30917
31536
  play.command("get <target>").description(
30918
31537
  "Fetch full play details or materialize a saved source bundle."
30919
31538
  ).addHelpText(
@@ -31182,6 +31801,8 @@ Notes:
31182
31801
  plays check to refuse publishing bytes that changed after validation.
31183
31802
  --dry-run bundles only and prints the exact artifact that would be published.
31184
31803
  Running a local file with plays run does not publish it.
31804
+ Publishing moves personal locations into Team library, preserving folders.
31805
+ Change location with: deepline plays settings set --play <play> --name path --value team/Research
31185
31806
 
31186
31807
  Examples:
31187
31808
  deepline plays set-live my-play --latest --json
@@ -31325,7 +31946,10 @@ Examples:
31325
31946
  deepline runs export play/my-play/run/20260501t000000-000 --out output.csv
31326
31947
  `
31327
31948
  );
31328
- runs.command("status <runId>").description("Read bounded lifecycle and confirmed work counts for a run.").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (runId, options) => {
31949
+ registerRunHistoryCommand(runs);
31950
+ runs.command("status <runId>").description(
31951
+ "Legacy scalar-only read. Use runs get for canonical status, progress, logs, and results."
31952
+ ).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (runId, options) => {
31329
31953
  process.exitCode = await handleRunLifecycleStatus([
31330
31954
  runId,
31331
31955
  ...options.json ? ["--json"] : []
@@ -33509,7 +34133,7 @@ function expandAtFilePath(rawPath) {
33509
34133
  return (0, import_node_os10.homedir)();
33510
34134
  }
33511
34135
  if (expanded.startsWith("~/") || expanded.startsWith("~\\")) {
33512
- return (0, import_node_path18.join)((0, import_node_os10.homedir)(), expanded.slice(2));
34136
+ return (0, import_node_path19.join)((0, import_node_os10.homedir)(), expanded.slice(2));
33513
34137
  }
33514
34138
  return expanded;
33515
34139
  }
@@ -33522,7 +34146,7 @@ async function readAtFileReference(value, argumentName, strip = true) {
33522
34146
  throw new Error(`Invalid ${argumentName} value: empty @file path.`);
33523
34147
  }
33524
34148
  try {
33525
- const text = await (0, import_promises10.readFile)(filePath, "utf8");
34149
+ const text = await (0, import_promises11.readFile)(filePath, "utf8");
33526
34150
  const normalized = text.replace(/^\uFEFF/, "");
33527
34151
  return strip ? normalized.trim() : normalized;
33528
34152
  } catch (error) {
@@ -33686,7 +34310,7 @@ function createSdkEnrichTelemetryContext(input2) {
33686
34310
  runId: `sdk-enrich-${process.pid}-${Date.now()}`,
33687
34311
  command: sdkEnrichCommandText(input2.args),
33688
34312
  rowsRange: input2.rowsRange,
33689
- inputPath: (0, import_node_path18.basename)(input2.inputCsv),
34313
+ inputPath: (0, import_node_path19.basename)(input2.inputCsv),
33690
34314
  startedAtMs: Date.now(),
33691
34315
  rowsTargeted: input2.selectedRange.count,
33692
34316
  columnsTargeted: countConfiguredEnrichColumns(input2.config)
@@ -33818,9 +34442,9 @@ async function buildPlanArgs(args) {
33818
34442
  return planArgs;
33819
34443
  }
33820
34444
  async function assertInputCsvExists(inputCsv) {
33821
- const path = (0, import_node_path18.resolve)(inputCsv);
34445
+ const path = (0, import_node_path19.resolve)(inputCsv);
33822
34446
  try {
33823
- const info = await (0, import_promises10.stat)(path);
34447
+ const info = await (0, import_promises11.stat)(path);
33824
34448
  if (info.isFile()) {
33825
34449
  return;
33826
34450
  }
@@ -33832,8 +34456,8 @@ async function assertInputCsvExists(inputCsv) {
33832
34456
  }
33833
34457
  }
33834
34458
  async function assertSafeOutputPath(inputCsv, outputPath) {
33835
- const input2 = (0, import_node_path18.resolve)(inputCsv);
33836
- const output2 = (0, import_node_path18.resolve)(outputPath);
34459
+ const input2 = (0, import_node_path19.resolve)(inputCsv);
34460
+ const output2 = (0, import_node_path19.resolve)(outputPath);
33837
34461
  if (input2 === output2) {
33838
34462
  throw new Error(
33839
34463
  "--input and --output must be different files when not using --in-place."
@@ -33841,8 +34465,8 @@ async function assertSafeOutputPath(inputCsv, outputPath) {
33841
34465
  }
33842
34466
  try {
33843
34467
  const [inputInfo, outputInfo] = await Promise.all([
33844
- (0, import_promises10.stat)(input2),
33845
- (0, import_promises10.stat)(output2)
34468
+ (0, import_promises11.stat)(input2),
34469
+ (0, import_promises11.stat)(output2)
33846
34470
  ]);
33847
34471
  if (inputInfo.dev === outputInfo.dev && inputInfo.ino === outputInfo.ino) {
33848
34472
  throw new Error(
@@ -33862,7 +34486,7 @@ async function assertSafeOutputPath(inputCsv, outputPath) {
33862
34486
  }
33863
34487
  async function regularFileExists(path) {
33864
34488
  try {
33865
- const info = await (0, import_promises10.stat)((0, import_node_path18.resolve)(path));
34489
+ const info = await (0, import_promises11.stat)((0, import_node_path19.resolve)(path));
33866
34490
  return info.isFile();
33867
34491
  } catch (error) {
33868
34492
  const code = error && typeof error === "object" ? error.code : void 0;
@@ -33873,7 +34497,7 @@ async function regularFileExists(path) {
33873
34497
  }
33874
34498
  }
33875
34499
  async function readConfig(path) {
33876
- const source = await (0, import_promises10.readFile)((0, import_node_path18.resolve)(path), "utf8");
34500
+ const source = await (0, import_promises11.readFile)((0, import_node_path19.resolve)(path), "utf8");
33877
34501
  let parsed;
33878
34502
  try {
33879
34503
  parsed = JSON.parse(source);
@@ -34294,8 +34918,8 @@ async function writeOutputCsv(outputPath, status, options) {
34294
34918
  ]),
34295
34919
  options?.config
34296
34920
  );
34297
- await (0, import_promises10.writeFile)(
34298
- (0, import_node_path18.resolve)(outputPath),
34921
+ await (0, import_promises11.writeFile)(
34922
+ (0, import_node_path19.resolve)(outputPath),
34299
34923
  csvStringFromRows(merged.rows, columns),
34300
34924
  "utf8"
34301
34925
  );
@@ -34305,7 +34929,7 @@ async function writeOutputCsv(outputPath, status, options) {
34305
34929
  selectedRows: rowsInfo.totalRows,
34306
34930
  enrichedRows: rowsInfo.rows.length,
34307
34931
  rows: merged.rows.length,
34308
- path: (0, import_node_path18.resolve)(outputPath),
34932
+ path: (0, import_node_path19.resolve)(outputPath),
34309
34933
  partial: !rowsInfo.complete,
34310
34934
  enrichedDataRows: rowsInfo.rows
34311
34935
  };
@@ -34486,7 +35110,7 @@ function enrichCustomerDbJson(input2) {
34486
35110
  ...actions.slowExportAsCsvCommand ? { command: actions.slowExportAsCsvCommand } : runId && input2.outputPath ? {
34487
35111
  command: `deepline runs export ${runId} --dataset ${shellSingleQuote2(
34488
35112
  exportDatasetPath
34489
- )} --out ${shellSingleQuote2((0, import_node_path18.resolve)(input2.outputPath))}`
35113
+ )} --out ${shellSingleQuote2((0, import_node_path19.resolve)(input2.outputPath))}`
34490
35114
  } : {},
34491
35115
  action: actions.exportCsv ?? {}
34492
35116
  }
@@ -34931,9 +35555,9 @@ function readEnrichRunStatus(status) {
34931
35555
  return null;
34932
35556
  }
34933
35557
  function firstCollectedStringField(value, key) {
34934
- const fields = /* @__PURE__ */ new Set();
34935
- collectStringFields(value, key, fields);
34936
- return fields.values().next().value ?? null;
35558
+ const fields2 = /* @__PURE__ */ new Set();
35559
+ collectStringFields(value, key, fields2);
35560
+ return fields2.values().next().value ?? null;
34937
35561
  }
34938
35562
  function emitPlainRunFailure(status) {
34939
35563
  const runId = extractRunId(status) ?? firstCollectedStringField(status, "runId");
@@ -35883,15 +36507,15 @@ function addEnrichRowsExportFollowUpCommand(commands, seen, input2) {
35883
36507
  label: "export enrich rows",
35884
36508
  path: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
35885
36509
  command: `deepline runs export ${input2.runId} --dataset ${GENERATED_ENRICH_ROWS_TABLE_NAMESPACE} --out ${shellSingleQuote2(
35886
- (0, import_node_path18.resolve)(input2.outputPath)
36510
+ (0, import_node_path19.resolve)(input2.outputPath)
35887
36511
  )}`
35888
36512
  });
35889
36513
  }
35890
36514
  function sidecarEnrichRowsExportPath(outputPath) {
35891
- const resolved = (0, import_node_path18.resolve)(outputPath);
35892
- const ext = (0, import_node_path18.extname)(resolved) || ".csv";
35893
- const stem = (0, import_node_path18.basename)(resolved, ext);
35894
- return (0, import_node_path18.join)((0, import_node_path18.dirname)(resolved), `${stem}.deepline-enrich-rows${ext}`);
36515
+ const resolved = (0, import_node_path19.resolve)(outputPath);
36516
+ const ext = (0, import_node_path19.extname)(resolved) || ".csv";
36517
+ const stem = (0, import_node_path19.basename)(resolved, ext);
36518
+ return (0, import_node_path19.join)((0, import_node_path19.dirname)(resolved), `${stem}.deepline-enrich-rows${ext}`);
35895
36519
  }
35896
36520
  function collectDatasetFollowUpCommands(value, state) {
35897
36521
  if (state.depth > 12 || !value || typeof value !== "object" || state.commands.length >= 8) {
@@ -35932,7 +36556,7 @@ function collectDatasetFollowUpCommands(value, state) {
35932
36556
  path: selector,
35933
36557
  command: `deepline runs export ${state.runId} --dataset ${shellSingleQuote2(
35934
36558
  selector
35935
- )} --out ${shellSingleQuote2((0, import_node_path18.resolve)(state.outputPath))}`
36559
+ )} --out ${shellSingleQuote2((0, import_node_path19.resolve)(state.outputPath))}`
35936
36560
  });
35937
36561
  }
35938
36562
  }
@@ -35972,10 +36596,10 @@ async function persistEnrichFailureReport(input2) {
35972
36596
  if (input2.jobs.length === 0 && input2.issues.length === 0) {
35973
36597
  return null;
35974
36598
  }
35975
- const stateDir = (0, import_node_path18.join)((0, import_node_os10.homedir)(), ".local", "deepline", "runtime", "state");
36599
+ const stateDir = (0, import_node_path19.join)((0, import_node_os10.homedir)(), ".local", "deepline", "runtime", "state");
35976
36600
  const reportPrefix = input2.jobs.length > 0 ? "run-block-failures" : "enrich-issues";
35977
- await (0, import_promises10.mkdir)(stateDir, { recursive: true });
35978
- const reportPath = (0, import_node_path18.join)(
36601
+ await (0, import_promises11.mkdir)(stateDir, { recursive: true });
36602
+ const reportPath = (0, import_node_path19.join)(
35979
36603
  stateDir,
35980
36604
  `${reportPrefix}-${Math.floor(Date.now() / 1e3)}-${process.pid}.json`
35981
36605
  );
@@ -36000,7 +36624,7 @@ async function persistEnrichFailureReport(input2) {
36000
36624
  if (input2.rows.rowStart !== null && input2.rows.rowEnd !== null) {
36001
36625
  report.rows = { start: input2.rows.rowStart, end: input2.rows.rowEnd };
36002
36626
  }
36003
- await (0, import_promises10.writeFile)(reportPath, `${JSON.stringify(report, null, 2)}
36627
+ await (0, import_promises11.writeFile)(reportPath, `${JSON.stringify(report, null, 2)}
36004
36628
  `, "utf8");
36005
36629
  return reportPath;
36006
36630
  }
@@ -36858,8 +37482,8 @@ function registerEnrichCommand(program) {
36858
37482
  if (options.json) {
36859
37483
  printJson({
36860
37484
  dryRun: true,
36861
- input: (0, import_node_path18.resolve)(inputCsv),
36862
- output: options.output ? (0, import_node_path18.resolve)(options.output) : null,
37485
+ input: (0, import_node_path19.resolve)(inputCsv),
37486
+ output: options.output ? (0, import_node_path19.resolve)(options.output) : null,
36863
37487
  plan: summary
36864
37488
  });
36865
37489
  return;
@@ -36870,7 +37494,7 @@ function registerEnrichCommand(program) {
36870
37494
  }
36871
37495
  const rows = parseRows(options.rows, options.all);
36872
37496
  let outputPath = options.inPlace ? inputCsv : options.output;
36873
- const requestedOutputPath = options.inPlace ? (0, import_node_path18.resolve)(inputCsv) : options.output ? (0, import_node_path18.resolve)(options.output) : void 0;
37497
+ const requestedOutputPath = options.inPlace ? (0, import_node_path19.resolve)(inputCsv) : options.output ? (0, import_node_path19.resolve)(options.output) : void 0;
36874
37498
  const sourceCsvPath = !options.inPlace && outputPath && await regularFileExists(outputPath) ? outputPath : inputCsv;
36875
37499
  const forceAliases = resolveForceAliases(config, options);
36876
37500
  for (const alias of collectFailedInputAliases(
@@ -36904,13 +37528,13 @@ function registerEnrichCommand(program) {
36904
37528
  sdkEnrichTelemetryCompleted = true;
36905
37529
  await completeSdkEnrichTelemetry(sdkEnrichTelemetry, input2);
36906
37530
  };
36907
- const tempDir = await (0, import_promises10.mkdtemp)((0, import_node_path18.join)((0, import_node_os10.tmpdir)(), "deepline-enrich-play-"));
37531
+ const tempDir = await (0, import_promises11.mkdtemp)((0, import_node_path19.join)((0, import_node_os10.tmpdir)(), "deepline-enrich-play-"));
36908
37532
  await emitSdkEnrichTelemetry(sdkEnrichTelemetry, "enrich_started");
36909
- const tempPlay = (0, import_node_path18.join)(tempDir, "deepline-enrich.play.ts");
37533
+ const tempPlay = (0, import_node_path19.join)(tempDir, "deepline-enrich.play.ts");
36910
37534
  let inPlaceTempDir = null;
36911
37535
  let inPlaceTempOutputPath = null;
36912
- const inPlaceFinalOutputPath = options.inPlace ? (0, import_node_path18.resolve)(inputCsv) : null;
36913
- const inPlaceCommitOutputPath = options.inPlace ? (await (0, import_promises10.lstat)(inputCsv)).isSymbolicLink() ? await (0, import_promises10.realpath)(inputCsv) : inPlaceFinalOutputPath : null;
37536
+ const inPlaceFinalOutputPath = options.inPlace ? (0, import_node_path19.resolve)(inputCsv) : null;
37537
+ const inPlaceCommitOutputPath = options.inPlace ? (await (0, import_promises11.lstat)(inputCsv)).isSymbolicLink() ? await (0, import_promises11.realpath)(inputCsv) : inPlaceFinalOutputPath : null;
36914
37538
  const failureReportOutputPath = options.inPlace ? inPlaceFinalOutputPath : null;
36915
37539
  const enrichIssueFollowUpOutputPath = options.inPlace && inPlaceFinalOutputPath ? sidecarEnrichRowsExportPath(inPlaceFinalOutputPath) : null;
36916
37540
  let activeRunId2 = null;
@@ -36931,16 +37555,16 @@ function registerEnrichCommand(program) {
36931
37555
  return;
36932
37556
  }
36933
37557
  if (inPlaceTempDir) {
36934
- await (0, import_promises10.rm)(inPlaceTempDir, { recursive: true, force: true });
37558
+ await (0, import_promises11.rm)(inPlaceTempDir, { recursive: true, force: true });
36935
37559
  }
36936
- inPlaceTempDir = await (0, import_promises10.mkdtemp)(
36937
- (0, import_node_path18.join)(
36938
- (0, import_node_path18.dirname)(inPlaceCommitOutputPath ?? (0, import_node_path18.resolve)(inputCsv)),
37560
+ inPlaceTempDir = await (0, import_promises11.mkdtemp)(
37561
+ (0, import_node_path19.join)(
37562
+ (0, import_node_path19.dirname)(inPlaceCommitOutputPath ?? (0, import_node_path19.resolve)(inputCsv)),
36939
37563
  ".deepline-enrich-in-place-"
36940
37564
  )
36941
37565
  );
36942
- inPlaceTempOutputPath = (0, import_node_path18.join)(inPlaceTempDir, "output.csv");
36943
- await (0, import_promises10.copyFile)((0, import_node_path18.resolve)(inputCsv), inPlaceTempOutputPath);
37566
+ inPlaceTempOutputPath = (0, import_node_path19.join)(inPlaceTempDir, "output.csv");
37567
+ await (0, import_promises11.copyFile)((0, import_node_path19.resolve)(inputCsv), inPlaceTempOutputPath);
36944
37568
  outputPath = inPlaceTempOutputPath;
36945
37569
  };
36946
37570
  const commitInPlaceOutput = async (exportResult) => {
@@ -36948,12 +37572,12 @@ function registerEnrichCommand(program) {
36948
37572
  return exportResult;
36949
37573
  }
36950
37574
  const committedTempDir = inPlaceTempDir;
36951
- await (0, import_promises10.rename)(inPlaceTempOutputPath, inPlaceCommitOutputPath);
37575
+ await (0, import_promises11.rename)(inPlaceTempOutputPath, inPlaceCommitOutputPath);
36952
37576
  inPlaceTempDir = null;
36953
37577
  inPlaceTempOutputPath = null;
36954
37578
  outputPath = inPlaceFinalOutputPath;
36955
37579
  if (committedTempDir) {
36956
- await (0, import_promises10.rm)(committedTempDir, { recursive: true, force: true });
37580
+ await (0, import_promises11.rm)(committedTempDir, { recursive: true, force: true });
36957
37581
  }
36958
37582
  if (!exportResult) {
36959
37583
  return null;
@@ -36966,13 +37590,13 @@ function registerEnrichCommand(program) {
36966
37590
  try {
36967
37591
  process.once("SIGINT", onSigint);
36968
37592
  process.once("SIGTERM", onSigterm);
36969
- await (0, import_promises10.writeFile)(tempPlay, playSource, "utf8");
37593
+ await (0, import_promises11.writeFile)(tempPlay, playSource, "utf8");
36970
37594
  if (options.inPlace) {
36971
37595
  await prepareInPlaceOutput();
36972
37596
  }
36973
37597
  const runOne = async (input2) => {
36974
37598
  const runtimeInput = {
36975
- file: (0, import_node_path18.resolve)(input2.sourceCsvPath),
37599
+ file: (0, import_node_path19.resolve)(input2.sourceCsvPath),
36976
37600
  ...input2.rows.rowStart !== null ? { rowStart: input2.rows.rowStart } : {},
36977
37601
  ...input2.rows.rowEnd !== null ? { rowEnd: input2.rows.rowEnd } : {}
36978
37602
  };
@@ -37160,11 +37784,11 @@ function registerEnrichCommand(program) {
37160
37784
  process.removeListener("SIGINT", onSigint);
37161
37785
  process.removeListener("SIGTERM", onSigterm);
37162
37786
  if (inPlaceTempDir) {
37163
- await (0, import_promises10.rm)(inPlaceTempDir, { recursive: true, force: true });
37787
+ await (0, import_promises11.rm)(inPlaceTempDir, { recursive: true, force: true });
37164
37788
  } else if (inPlaceTempOutputPath) {
37165
- await (0, import_promises10.rm)(inPlaceTempOutputPath, { force: true });
37789
+ await (0, import_promises11.rm)(inPlaceTempOutputPath, { force: true });
37166
37790
  }
37167
- await (0, import_promises10.rm)(tempDir, { recursive: true, force: true });
37791
+ await (0, import_promises11.rm)(tempDir, { recursive: true, force: true });
37168
37792
  }
37169
37793
  });
37170
37794
  }
@@ -37206,7 +37830,7 @@ async function handleFeedback(text, options) {
37206
37830
  { json: options.json }
37207
37831
  );
37208
37832
  }
37209
- function resolveFeedbackText(text, file, readFile7 = (path) => (0, import_node_fs13.readFileSync)(path, "utf8")) {
37833
+ function resolveFeedbackText(text, file, readFile8 = (path) => (0, import_node_fs13.readFileSync)(path, "utf8")) {
37210
37834
  if (text !== void 0 && file !== void 0) {
37211
37835
  throw new Error(
37212
37836
  "Pass feedback text positionally or with --file, not both."
@@ -37215,7 +37839,7 @@ function resolveFeedbackText(text, file, readFile7 = (path) => (0, import_node_f
37215
37839
  let value;
37216
37840
  if (file !== void 0) {
37217
37841
  try {
37218
- value = readFile7(file === "-" ? 0 : file);
37842
+ value = readFile8(file === "-" ? 0 : file);
37219
37843
  } catch (error) {
37220
37844
  throw new Error(
37221
37845
  `Could not read feedback ${file === "-" ? "from stdin" : `file ${file}`}: ${error instanceof Error ? error.message : String(error)}`
@@ -37224,7 +37848,7 @@ function resolveFeedbackText(text, file, readFile7 = (path) => (0, import_node_f
37224
37848
  } else if (text !== void 0) {
37225
37849
  value = text;
37226
37850
  } else if (!process.stdin.isTTY) {
37227
- value = readFile7(0);
37851
+ value = readFile8(0);
37228
37852
  } else {
37229
37853
  throw new Error(
37230
37854
  "Feedback text is required. Pass it positionally, use --file <path>, or pipe stdin."
@@ -37275,7 +37899,7 @@ Examples:
37275
37899
  // src/cli/commands/sessions.ts
37276
37900
  var import_node_fs14 = require("fs");
37277
37901
  var import_node_os11 = require("os");
37278
- var import_node_path19 = require("path");
37902
+ var import_node_path20 = require("path");
37279
37903
  var import_node_zlib = require("zlib");
37280
37904
  var import_node_crypto8 = require("crypto");
37281
37905
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -37294,17 +37918,17 @@ function homeDir() {
37294
37918
  function detectShellContext() {
37295
37919
  const shellPath = process.env.SHELL?.trim() || process.env.ComSpec?.trim() || process.env.COMSPEC?.trim() || "";
37296
37920
  return {
37297
- shell: shellPath ? (0, import_node_path19.basename)(shellPath).replace(/\.exe$/i, "") : "unknown",
37921
+ shell: shellPath ? (0, import_node_path20.basename)(shellPath).replace(/\.exe$/i, "") : "unknown",
37298
37922
  shell_path: shellPath || null,
37299
37923
  os: (0, import_node_os11.platform)(),
37300
37924
  cwd: process.cwd()
37301
37925
  };
37302
37926
  }
37303
37927
  function claudeProjectsRoot() {
37304
- return (0, import_node_path19.join)(homeDir(), ".claude", "projects");
37928
+ return (0, import_node_path20.join)(homeDir(), ".claude", "projects");
37305
37929
  }
37306
37930
  function codexSessionsRoot() {
37307
- return (0, import_node_path19.join)(homeDir(), ".codex", "sessions");
37931
+ return (0, import_node_path20.join)(homeDir(), ".codex", "sessions");
37308
37932
  }
37309
37933
  function listClaudeSessionFiles() {
37310
37934
  const root = claudeProjectsRoot();
@@ -37312,10 +37936,10 @@ function listClaudeSessionFiles() {
37312
37936
  const projectDirs = readDirectoryNames(root);
37313
37937
  const files = [];
37314
37938
  for (const projectDir of projectDirs) {
37315
- const fullProjectDir = (0, import_node_path19.join)(root, projectDir);
37939
+ const fullProjectDir = (0, import_node_path20.join)(root, projectDir);
37316
37940
  for (const fileName of readDirectoryNames(fullProjectDir)) {
37317
37941
  if (fileName.endsWith(".jsonl")) {
37318
- const filePath = (0, import_node_path19.join)(fullProjectDir, fileName);
37942
+ const filePath = (0, import_node_path20.join)(fullProjectDir, fileName);
37319
37943
  const sessionId = sessionIdFromClaudeFilePath(filePath);
37320
37944
  const stat5 = statIfReadable(filePath);
37321
37945
  if (sessionId && stat5) {
@@ -37372,7 +37996,7 @@ function listJsonlFilesRecursive(root, maxDepth) {
37372
37996
  return;
37373
37997
  }
37374
37998
  for (const entry of entries) {
37375
- const fullPath = (0, import_node_path19.join)(dir, entry.name);
37999
+ const fullPath = (0, import_node_path20.join)(dir, entry.name);
37376
38000
  if (entry.isDirectory()) {
37377
38001
  visit(fullPath, depth + 1);
37378
38002
  } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
@@ -37400,10 +38024,10 @@ function newestSessionFile(agent) {
37400
38024
  return newest;
37401
38025
  }
37402
38026
  function sessionIdFromClaudeFilePath(filePath) {
37403
- return (0, import_node_path19.basename)(filePath, ".jsonl");
38027
+ return (0, import_node_path20.basename)(filePath, ".jsonl");
37404
38028
  }
37405
38029
  function sessionIdFromCodexFilePath(filePath) {
37406
- const match = (0, import_node_path19.basename)(filePath, ".jsonl").match(UUID_IN_TEXT_RE);
38030
+ const match = (0, import_node_path20.basename)(filePath, ".jsonl").match(UUID_IN_TEXT_RE);
37407
38031
  return match?.[0] ?? null;
37408
38032
  }
37409
38033
  function readCodexSessionId(filePath) {
@@ -37732,26 +38356,26 @@ async function uploadChunkedSessions(sessions, options) {
37732
38356
  async function handleSessionsSend(options) {
37733
38357
  const rating = parseSessionRating(options.rating);
37734
38358
  if (options.file) {
37735
- const filePath = (0, import_node_path19.resolve)(options.file);
38359
+ const filePath = (0, import_node_path20.resolve)(options.file);
37736
38360
  if (!(0, import_node_fs14.existsSync)(filePath)) {
37737
38361
  throw new Error(`File not found: ${options.file}`);
37738
38362
  }
37739
38363
  const response2 = await uploadPayload("/api/v2/cli/send-session", {
37740
38364
  file: (0, import_node_fs14.readFileSync)(filePath).toString("base64"),
37741
- filename: (0, import_node_path19.basename)(filePath),
38365
+ filename: (0, import_node_path20.basename)(filePath),
37742
38366
  ...rating ? { rating } : {}
37743
38367
  });
37744
38368
  printCommandEnvelope(
37745
38369
  {
37746
38370
  ...response2,
37747
38371
  ok: true,
37748
- filename: (0, import_node_path19.basename)(filePath),
38372
+ filename: (0, import_node_path20.basename)(filePath),
37749
38373
  render: {
37750
38374
  sections: [
37751
38375
  {
37752
38376
  title: "sessions send",
37753
38377
  lines: [
37754
- `File '${(0, import_node_path19.basename)(filePath)}' uploaded to #internal-reports.`
38378
+ `File '${(0, import_node_path20.basename)(filePath)}' uploaded to #internal-reports.`
37755
38379
  ]
37756
38380
  }
37757
38381
  ]
@@ -37808,24 +38432,24 @@ async function handleSessionsSend(options) {
37808
38432
  );
37809
38433
  }
37810
38434
  function loadViewerAssets() {
37811
- const cliEntry = process.argv[1]?.trim() ? (0, import_node_fs14.realpathSync)((0, import_node_path19.resolve)(process.argv[1])) : null;
38435
+ const cliEntry = process.argv[1]?.trim() ? (0, import_node_fs14.realpathSync)((0, import_node_path20.resolve)(process.argv[1])) : null;
37812
38436
  const candidateRoots2 = [
37813
38437
  ...cliEntry ? [
37814
- (0, import_node_path19.join)((0, import_node_path19.dirname)((0, import_node_path19.dirname)(cliEntry)), "viewer"),
37815
- (0, import_node_path19.join)(
37816
- (0, import_node_path19.dirname)((0, import_node_path19.dirname)((0, import_node_path19.dirname)(cliEntry))),
38438
+ (0, import_node_path20.join)((0, import_node_path20.dirname)((0, import_node_path20.dirname)(cliEntry)), "viewer"),
38439
+ (0, import_node_path20.join)(
38440
+ (0, import_node_path20.dirname)((0, import_node_path20.dirname)((0, import_node_path20.dirname)(cliEntry))),
37817
38441
  "src",
37818
38442
  "lib",
37819
38443
  "cli",
37820
38444
  "viewer"
37821
38445
  )
37822
38446
  ] : [],
37823
- (0, import_node_path19.join)(process.cwd(), "packages", "sdk", "assets", "viewer")
38447
+ (0, import_node_path20.join)(process.cwd(), "packages", "sdk", "assets", "viewer")
37824
38448
  ];
37825
38449
  for (const root of candidateRoots2) {
37826
38450
  try {
37827
- const cssPath = (0, import_node_path19.join)(root, "viewer.css");
37828
- const jsPath = (0, import_node_path19.join)(root, "viewer.js");
38451
+ const cssPath = (0, import_node_path20.join)(root, "viewer.css");
38452
+ const jsPath = (0, import_node_path20.join)(root, "viewer.js");
37829
38453
  if (!(0, import_node_fs14.existsSync)(cssPath) || !(0, import_node_fs14.existsSync)(jsPath)) continue;
37830
38454
  return {
37831
38455
  css: (0, import_node_fs14.readFileSync)(cssPath, "utf8"),
@@ -37855,16 +38479,16 @@ async function handleSessionsRender(options) {
37855
38479
  currentSession: options.currentSession,
37856
38480
  agent: options.agent
37857
38481
  });
37858
- let outputPath = options.output ? (0, import_node_path19.resolve)(options.output) : "";
38482
+ let outputPath = options.output ? (0, import_node_path20.resolve)(options.output) : "";
37859
38483
  if (!outputPath) {
37860
- const outputDir = (0, import_node_path19.join)(process.cwd(), "deepline", "data");
38484
+ const outputDir = (0, import_node_path20.join)(process.cwd(), "deepline", "data");
37861
38485
  (0, import_node_fs14.mkdirSync)(outputDir, { recursive: true });
37862
- outputPath = (0, import_node_path19.join)(
38486
+ outputPath = (0, import_node_path20.join)(
37863
38487
  outputDir,
37864
38488
  targets.length > 1 ? "session-viewer.html" : `session-${targets[0]?.sessionId}.html`
37865
38489
  );
37866
38490
  } else {
37867
- (0, import_node_fs14.mkdirSync)((0, import_node_path19.dirname)(outputPath), { recursive: true });
38491
+ (0, import_node_fs14.mkdirSync)((0, import_node_path20.dirname)(outputPath), { recursive: true });
37868
38492
  }
37869
38493
  const sessions = targets.map((target) => ({
37870
38494
  label: target.label,
@@ -38108,8 +38732,8 @@ Examples:
38108
38732
  // src/cli/commands/monitors.ts
38109
38733
  var import_node_crypto9 = require("crypto");
38110
38734
  var import_node_fs15 = require("fs");
38111
- var import_node_path20 = require("path");
38112
- var import_promises11 = require("readline/promises");
38735
+ var import_node_path21 = require("path");
38736
+ var import_promises12 = require("readline/promises");
38113
38737
 
38114
38738
  // ../integration-contracts/monitor-input-contract.ts
38115
38739
  var import_handlebars = __toESM(require("handlebars"), 1);
@@ -38971,7 +39595,7 @@ function parseJsonObjectArg(raw, argLabel) {
38971
39595
  return parsed;
38972
39596
  }
38973
39597
  function resolveMonitorJsonBody(input2) {
38974
- const readFile7 = input2.readFile ?? ((path) => (0, import_node_fs15.readFileSync)(path, "utf-8"));
39598
+ const readFile8 = input2.readFile ?? ((path) => (0, import_node_fs15.readFileSync)(path, "utf-8"));
38975
39599
  const readStdin = input2.readStdin ?? (() => (0, import_node_fs15.readFileSync)(0, "utf-8"));
38976
39600
  if (input2.positional !== void 0 && input2.file !== void 0) {
38977
39601
  throw new MonitorsUsageError(
@@ -38987,7 +39611,7 @@ function resolveMonitorJsonBody(input2) {
38987
39611
  }
38988
39612
  let raw;
38989
39613
  try {
38990
- raw = readFile7(input2.file);
39614
+ raw = readFile8(input2.file);
38991
39615
  } catch (error) {
38992
39616
  throw new MonitorsUsageError(
38993
39617
  `Could not read --file ${input2.file}: ${error instanceof Error ? error.message : String(error)}`
@@ -40269,7 +40893,7 @@ async function handleMonitorFleetsInit(fleetId, options) {
40269
40893
  }
40270
40894
  };
40271
40895
  const definition = requireCompiledFleetDefinition(authoredDefinition);
40272
- const file = (0, import_node_path20.resolve)(out);
40896
+ const file = (0, import_node_path21.resolve)(out);
40273
40897
  (0, import_node_fs15.writeFileSync)(file, `${JSON.stringify(definition, null, 2)}
40274
40898
  `, "utf8");
40275
40899
  const next = `deepline monitors fleets deploy --file ${fleetShellArg(file)} --dry-run --json`;
@@ -40530,7 +41154,7 @@ function fleetDeactivateCommandLine(fleetId, options) {
40530
41154
  }
40531
41155
  async function confirmFleetDeactivate(fleetId, plan) {
40532
41156
  process.stderr.write(renderFleetDeactivatePlan(plan, fleetId));
40533
- const rl = (0, import_promises11.createInterface)({ input: process.stdin, output: process.stderr });
41157
+ const rl = (0, import_promises12.createInterface)({ input: process.stdin, output: process.stderr });
40534
41158
  try {
40535
41159
  const answer = await rl.question(
40536
41160
  `Deactivate fleet "${fleetId}" and the monitors it owns? [y/N] `
@@ -40844,7 +41468,7 @@ async function handleMonitorsValidate(key, options) {
40844
41468
  if (result.valid === false) process.exitCode = 7;
40845
41469
  }
40846
41470
  async function confirmMonitorDelete(key) {
40847
- const rl = (0, import_promises11.createInterface)({
41471
+ const rl = (0, import_promises12.createInterface)({
40848
41472
  input: process.stdin,
40849
41473
  output: process.stderr
40850
41474
  });
@@ -41150,7 +41774,7 @@ async function handleMonitorBatchDeploy(options) {
41150
41774
  }
41151
41775
  let manifestNdjson;
41152
41776
  try {
41153
- manifestNdjson = (0, import_node_fs15.readFileSync)((0, import_node_path20.resolve)(options.file), "utf8");
41777
+ manifestNdjson = (0, import_node_fs15.readFileSync)((0, import_node_path21.resolve)(options.file), "utf8");
41154
41778
  } catch (error) {
41155
41779
  throw new MonitorsUsageError(
41156
41780
  `Could not read monitor batch manifest '${options.file}': ${error instanceof Error ? error.message : String(error)}`
@@ -42051,10 +42675,10 @@ Example:
42051
42675
  // src/cli/commands/org.ts
42052
42676
  var import_node_crypto10 = require("crypto");
42053
42677
  var import_node_fs16 = require("fs");
42054
- var import_node_path21 = require("path");
42678
+ var import_node_path22 = require("path");
42055
42679
  function pendingOrgCreatePath(baseUrl, accountId, sourceOrgId, name) {
42056
42680
  const intent = (0, import_node_crypto10.createHash)("sha256").update(accountId).update("\0").update(sourceOrgId).update("\0").update(name).digest("hex");
42057
- return (0, import_node_path21.join)(sdkCliStateDirPath(baseUrl), `pending-org-create-${intent}.json`);
42681
+ return (0, import_node_path22.join)(sdkCliStateDirPath(baseUrl), `pending-org-create-${intent}.json`);
42058
42682
  }
42059
42683
  function readPendingOrgCreate(path, accountId, sourceOrgId, name) {
42060
42684
  let value;
@@ -42937,7 +43561,7 @@ Deprecated:
42937
43561
 
42938
43562
  // src/cli/commands/secrets.ts
42939
43563
  var import_node_process = require("process");
42940
- var import_promises12 = require("fs/promises");
43564
+ var import_promises13 = require("fs/promises");
42941
43565
  var hiddenInputBuffer = "";
42942
43566
  function normalizeSecretName(value) {
42943
43567
  const normalized = value.trim().toUpperCase();
@@ -43110,7 +43734,7 @@ async function readSecretValueFromOptions(options) {
43110
43734
  }
43111
43735
  value = envValue;
43112
43736
  } else {
43113
- value = trimOneTerminalNewline(await (0, import_promises12.readFile)(options.fromFile, "utf8"));
43737
+ value = trimOneTerminalNewline(await (0, import_promises13.readFile)(options.fromFile, "utf8"));
43114
43738
  }
43115
43739
  if (!value) throw new Error("Secret value is required.");
43116
43740
  return value;
@@ -43314,11 +43938,11 @@ Examples:
43314
43938
  var import_node_child_process5 = require("child_process");
43315
43939
  var import_node_fs20 = require("fs");
43316
43940
  var import_node_os15 = require("os");
43317
- var import_node_path25 = require("path");
43941
+ var import_node_path26 = require("path");
43318
43942
 
43319
43943
  // src/cli/installation-lifecycle.ts
43320
43944
  var import_node_fs17 = require("fs");
43321
- var import_node_path22 = require("path");
43945
+ var import_node_path23 = require("path");
43322
43946
  var nodeFileSystem = {
43323
43947
  exists: import_node_fs17.existsSync,
43324
43948
  isSymbolicLink(path) {
@@ -43374,25 +43998,25 @@ var CliInstallation = class _CliInstallation {
43374
43998
  });
43375
43999
  }
43376
44000
  static isNpmPackagePath(path) {
43377
- return path?.includes(`${(0, import_node_path22.join)("node_modules", "deepline")}`) ?? false;
44001
+ return path?.includes(`${(0, import_node_path23.join)("node_modules", "deepline")}`) ?? false;
43378
44002
  }
43379
44003
  launcher(path) {
43380
44004
  return inspectLauncher(path, this.input.fileSystem);
43381
44005
  }
43382
44006
  retiredArtifacts() {
43383
- const hostDir = (0, import_node_path22.join)(
44007
+ const hostDir = (0, import_node_path23.join)(
43384
44008
  this.input.home,
43385
44009
  ".local",
43386
44010
  "deepline",
43387
44011
  this.input.baseUrlSlug
43388
44012
  );
43389
- const legacyLauncherPath = (0, import_node_path22.join)(
44013
+ const legacyLauncherPath = (0, import_node_path23.join)(
43390
44014
  this.input.home,
43391
44015
  ".local",
43392
44016
  "bin",
43393
44017
  "deepline"
43394
44018
  );
43395
- const installerCommandPath = this.input.fileSystem.read((0, import_node_path22.join)(hostDir, "sdk", ".command-path")).trim();
44019
+ const installerCommandPath = this.input.fileSystem.read((0, import_node_path23.join)(hostDir, "sdk", ".command-path")).trim();
43396
44020
  const ownedInstallerCommand = isOwnedInstallerCommandPath({
43397
44021
  hostDir,
43398
44022
  commandPath: installerCommandPath
@@ -43400,16 +44024,16 @@ var CliInstallation = class _CliInstallation {
43400
44024
  const legacyLauncher = this.launcher(legacyLauncherPath);
43401
44025
  const candidates = [
43402
44026
  ...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
43403
- (0, import_node_path22.join)(this.input.home, ".local", "bin", "deepline-real"),
43404
- (0, import_node_path22.join)(hostDir, "bin", "deepline"),
43405
- (0, import_node_path22.join)(hostDir, "bin", "deepline-real"),
43406
- (0, import_node_path22.join)(hostDir, "cli", ".install-method"),
43407
- (0, import_node_path22.join)(hostDir, "cli", ".version"),
43408
- (0, import_node_path22.join)(hostDir, "sdk", ".install-method"),
43409
- (0, import_node_path22.join)(hostDir, "sdk", ".command-path"),
44027
+ (0, import_node_path23.join)(this.input.home, ".local", "bin", "deepline-real"),
44028
+ (0, import_node_path23.join)(hostDir, "bin", "deepline"),
44029
+ (0, import_node_path23.join)(hostDir, "bin", "deepline-real"),
44030
+ (0, import_node_path23.join)(hostDir, "cli", ".install-method"),
44031
+ (0, import_node_path23.join)(hostDir, "cli", ".version"),
44032
+ (0, import_node_path23.join)(hostDir, "sdk", ".install-method"),
44033
+ (0, import_node_path23.join)(hostDir, "sdk", ".command-path"),
43410
44034
  ...ownedInstallerCommand ? [
43411
44035
  installerCommandPath,
43412
- (0, import_node_path22.join)((0, import_node_path22.dirname)(installerCommandPath), "deepline-sdk")
44036
+ (0, import_node_path23.join)((0, import_node_path23.dirname)(installerCommandPath), "deepline-sdk")
43413
44037
  ] : []
43414
44038
  ];
43415
44039
  return {
@@ -43430,11 +44054,11 @@ function removeArtifacts(plan, fileSystem) {
43430
44054
  return plan.paths;
43431
44055
  }
43432
44056
  function isOwnedInstallerCommandPath(input2) {
43433
- if (!input2.commandPath || (0, import_node_path22.basename)(input2.commandPath) !== "deepline") {
44057
+ if (!input2.commandPath || (0, import_node_path23.basename)(input2.commandPath) !== "deepline") {
43434
44058
  return false;
43435
44059
  }
43436
- const commandPath = (0, import_node_path22.resolve)(input2.commandPath);
43437
- const fromHost = (0, import_node_path22.relative)((0, import_node_path22.resolve)(input2.hostDir), commandPath);
44060
+ const commandPath = (0, import_node_path23.resolve)(input2.commandPath);
44061
+ const fromHost = (0, import_node_path23.relative)((0, import_node_path23.resolve)(input2.hostDir), commandPath);
43438
44062
  return fromHost !== "" && fromHost !== ".." && !fromHost.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
43439
44063
  }
43440
44064
 
@@ -43442,7 +44066,7 @@ function isOwnedInstallerCommandPath(input2) {
43442
44066
  var import_node_child_process3 = require("child_process");
43443
44067
  var import_node_fs19 = require("fs");
43444
44068
  var import_node_os14 = require("os");
43445
- var import_node_path24 = require("path");
44069
+ var import_node_path25 = require("path");
43446
44070
 
43447
44071
  // contracts/install-commands.json
43448
44072
  var install_commands_default = {
@@ -43559,7 +44183,7 @@ var import_node_crypto11 = require("crypto");
43559
44183
  var import_node_os13 = require("os");
43560
44184
  var import_node_zlib2 = require("zlib");
43561
44185
  var import_node_fs18 = require("fs");
43562
- var import_node_path23 = require("path");
44186
+ var import_node_path24 = require("path");
43563
44187
 
43564
44188
  // src/cli/windows-arg-escape.ts
43565
44189
  var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
@@ -43924,7 +44548,7 @@ function shouldSkipSkillsSync() {
43924
44548
  return value === "1" || value === "true" || value === "yes" || value === "on";
43925
44549
  }
43926
44550
  function unavailableSkillsNoticePath(baseUrl) {
43927
- return (0, import_node_path23.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
44551
+ return (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
43928
44552
  }
43929
44553
  var SKILLS_SYNC_IN_PROGRESS_TTL_MS = 10 * 60 * 1e3;
43930
44554
  var SKILLS_SYNC_IN_PROGRESS_PID_CAP_MS = 6 * 60 * 60 * 1e3;
@@ -43934,21 +44558,21 @@ function sortedLeaseAgents(agents) {
43934
44558
  return [...new Set(expanded)].sort((a, b) => a.localeCompare(b));
43935
44559
  }
43936
44560
  function inProgressSkillsSyncPath(baseUrl, agent) {
43937
- return (0, import_node_path23.join)(
44561
+ return (0, import_node_path24.join)(
43938
44562
  sdkCliStateDirPath(baseUrl),
43939
44563
  `skills-sync-in-progress-${agentLeaseSegment(agent)}`
43940
44564
  );
43941
44565
  }
43942
44566
  function readInProgressSkillsSyncLeaseFromDir(dir) {
43943
- const claim = readMarkedSkillsSyncVersion((0, import_node_path23.join)(dir, "claim"));
44567
+ const claim = readMarkedSkillsSyncVersion((0, import_node_path24.join)(dir, "claim"));
43944
44568
  const [version = "", startedAt = ""] = claim.split(" ");
43945
- const pidRaw = readMarkedSkillsSyncVersion((0, import_node_path23.join)(dir, "pid"));
44569
+ const pidRaw = readMarkedSkillsSyncVersion((0, import_node_path24.join)(dir, "pid"));
43946
44570
  return {
43947
44571
  claimToken: version && startedAt ? `${version} ${startedAt}` : "",
43948
44572
  version,
43949
44573
  startedAt: Number(startedAt),
43950
44574
  pid: /^\d+$/.test(pidRaw) ? Number(pidRaw) : null,
43951
- owner: readMarkedSkillsSyncVersion((0, import_node_path23.join)(dir, "owner"))
44575
+ owner: readMarkedSkillsSyncVersion((0, import_node_path24.join)(dir, "owner"))
43952
44576
  };
43953
44577
  }
43954
44578
  function readInProgressSkillsSyncLease(baseUrl, agent) {
@@ -44006,9 +44630,9 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
44006
44630
  const claimToken = `${remoteVersion} ${Date.now()}`;
44007
44631
  const staging = `${dir}.staging-${process.pid}-${Date.now()}`;
44008
44632
  (0, import_node_fs18.mkdirSync)(staging);
44009
- (0, import_node_fs18.writeFileSync)((0, import_node_path23.join)(staging, "claim"), `${claimToken}
44633
+ (0, import_node_fs18.writeFileSync)((0, import_node_path24.join)(staging, "claim"), `${claimToken}
44010
44634
  `, "utf-8");
44011
- (0, import_node_fs18.writeFileSync)((0, import_node_path23.join)(staging, "owner"), `${owner}
44635
+ (0, import_node_fs18.writeFileSync)((0, import_node_path24.join)(staging, "owner"), `${owner}
44012
44636
  `, "utf-8");
44013
44637
  try {
44014
44638
  (0, import_node_fs18.renameSync)(staging, dir);
@@ -44022,7 +44646,7 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
44022
44646
  return { state: "claimed", claimToken };
44023
44647
  };
44024
44648
  try {
44025
- (0, import_node_fs18.mkdirSync)((0, import_node_path23.dirname)(dir), { recursive: true });
44649
+ (0, import_node_fs18.mkdirSync)((0, import_node_path24.dirname)(dir), { recursive: true });
44026
44650
  return create();
44027
44651
  } catch (error) {
44028
44652
  if (errorCode(error) !== "EEXIST") return { state: "unavailable" };
@@ -44082,7 +44706,7 @@ function recordOwnPidOnInProgressSkillsSync(baseUrl, leases) {
44082
44706
  if (!lease.claimToken) continue;
44083
44707
  try {
44084
44708
  (0, import_node_fs18.writeFileSync)(
44085
- (0, import_node_path23.join)(inProgressSkillsSyncPath(baseUrl, agent), "pid"),
44709
+ (0, import_node_path24.join)(inProgressSkillsSyncPath(baseUrl, agent), "pid"),
44086
44710
  `${process.pid}
44087
44711
  `,
44088
44712
  "utf-8"
@@ -44151,7 +44775,7 @@ function skillsInstallLeasePath(baseUrl, agents) {
44151
44775
  return sortedLeaseAgents(agents).map((agent) => inProgressSkillsSyncPath(baseUrl, agent)).join(", ");
44152
44776
  }
44153
44777
  function deferredSkillsNoticePath(baseUrl, agents) {
44154
- return (0, import_node_path23.join)(
44778
+ return (0, import_node_path24.join)(
44155
44779
  sdkCliStateDirPath(baseUrl),
44156
44780
  `skills-sync-notice-${sortedLeaseAgents(agents).map(agentLeaseSegment).join("-")}`
44157
44781
  );
@@ -44160,7 +44784,7 @@ function deferSkillsNotice(baseUrl, agents) {
44160
44784
  const path = deferredSkillsNoticePath(baseUrl, agents);
44161
44785
  return (text) => {
44162
44786
  try {
44163
- (0, import_node_fs18.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
44787
+ (0, import_node_fs18.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
44164
44788
  (0, import_node_fs18.appendFileSync)(path, `${text.trimEnd()}
44165
44789
  `, "utf-8");
44166
44790
  } catch {
@@ -44202,7 +44826,7 @@ function spawnDetachedSkillsSyncChild(argv, onSpawnError) {
44202
44826
  child.unref();
44203
44827
  }
44204
44828
  function failedSkillsSyncPath(baseUrl, agents) {
44205
- return (0, import_node_path23.join)(
44829
+ return (0, import_node_path24.join)(
44206
44830
  sdkCliStateDirPath(baseUrl),
44207
44831
  `skills-sync-failed-${sortedLeaseAgents(agents).map(agentLeaseSegment).join("-")}-version`
44208
44832
  );
@@ -44219,7 +44843,7 @@ function readMarkedSkillsSyncVersion(path) {
44219
44843
  }
44220
44844
  function writeMarkedSkillsSyncVersion(path, version) {
44221
44845
  try {
44222
- (0, import_node_fs18.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
44846
+ (0, import_node_fs18.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
44223
44847
  (0, import_node_fs18.writeFileSync)(path, `${version}
44224
44848
  `, "utf-8");
44225
44849
  return true;
@@ -44329,7 +44953,7 @@ function safeSkillFilePath(value) {
44329
44953
  }
44330
44954
  function installedSkillFiles(root, prefix = "") {
44331
44955
  const files = [];
44332
- for (const entry of (0, import_node_fs18.readdirSync)((0, import_node_path23.join)(root, prefix), {
44956
+ for (const entry of (0, import_node_fs18.readdirSync)((0, import_node_path24.join)(root, prefix), {
44333
44957
  withFileTypes: true
44334
44958
  })) {
44335
44959
  const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
@@ -44449,11 +45073,11 @@ async function verifyDefaultAgentSkillsInstall(baseUrl, remoteVersion, skillName
44449
45073
  controller.abort();
44450
45074
  }
44451
45075
  const home = (0, import_node_os13.homedir)();
44452
- const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path23.join)(home, ".claude");
45076
+ const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path24.join)(home, ".claude");
44453
45077
  for (const [name, { files }] of published) {
44454
45078
  for (const root of [
44455
- (0, import_node_path23.join)(home, ".agents", "skills", name),
44456
- (0, import_node_path23.join)(claudeConfigDir, "skills", name)
45079
+ (0, import_node_path24.join)(home, ".agents", "skills", name),
45080
+ (0, import_node_path24.join)(claudeConfigDir, "skills", name)
44457
45081
  ]) {
44458
45082
  const installed = installedSkillFiles(root);
44459
45083
  if (installed.length !== files.length || installed.some((file, index2) => file !== files[index2])) {
@@ -44461,7 +45085,7 @@ async function verifyDefaultAgentSkillsInstall(baseUrl, remoteVersion, skillName
44461
45085
  }
44462
45086
  for (const file of files) {
44463
45087
  const publishedContent = expected.get(`${name}/${file}`);
44464
- if (!publishedContent || !(0, import_node_fs18.readFileSync)((0, import_node_path23.join)(root, file)).equals(publishedContent)) {
45088
+ if (!publishedContent || !(0, import_node_fs18.readFileSync)((0, import_node_path24.join)(root, file)).equals(publishedContent)) {
44465
45089
  throw new Error(`installed content differs for ${name}/${file}`);
44466
45090
  }
44467
45091
  }
@@ -44515,7 +45139,7 @@ function probeInstallers(timeoutMs) {
44515
45139
  };
44516
45140
  }
44517
45141
  function noInstallerProbePath(baseUrl) {
44518
- return (0, import_node_path23.join)(
45142
+ return (0, import_node_path24.join)(
44519
45143
  sdkCliStateDirPath(baseUrl),
44520
45144
  "skills-sync-no-installer-unknown.json"
44521
45145
  );
@@ -44532,7 +45156,7 @@ function dueUnknownInstallerProbes(baseUrl, remoteVersion) {
44532
45156
  const probes = probeInstallers(INSTALLER_PROBE_TIMEOUT_MS);
44533
45157
  if (probes.bunx !== "available" && probes.npx !== "available") {
44534
45158
  try {
44535
- (0, import_node_fs18.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
45159
+ (0, import_node_fs18.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
44536
45160
  (0, import_node_fs18.writeFileSync)(
44537
45161
  path,
44538
45162
  JSON.stringify({
@@ -44984,13 +45608,13 @@ function detectSkillsAgents(input2) {
44984
45608
  ];
44985
45609
  const detected = AGENT_MARKERS.filter(
44986
45610
  (marker) => roots.some(
44987
- (root) => marker.paths.some((path) => (0, import_node_fs19.existsSync)((0, import_node_path24.join)(root, path)))
45611
+ (root) => marker.paths.some((path) => (0, import_node_fs19.existsSync)((0, import_node_path25.join)(root, path)))
44988
45612
  )
44989
45613
  ).map((marker) => marker.agent);
44990
45614
  return detected.length > 0 ? detected : ["*"];
44991
45615
  }
44992
45616
  function skillsStatePathForScope(baseUrl, scope, root) {
44993
- return scope === "local" && root ? (0, import_node_path24.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
45617
+ return scope === "local" && root ? (0, import_node_path25.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
44994
45618
  }
44995
45619
  function buildSkillsPlan(input2) {
44996
45620
  const scopeArgs = input2.scope === "global" ? ["--global"] : [];
@@ -45261,7 +45885,7 @@ async function runSkillsInstallWithLease(input2) {
45261
45885
  `
45262
45886
  );
45263
45887
  }
45264
- (0, import_node_fs19.mkdirSync)((0, import_node_path24.dirname)(plan.statePath), { recursive: true });
45888
+ (0, import_node_fs19.mkdirSync)((0, import_node_path25.dirname)(plan.statePath), { recursive: true });
45265
45889
  (0, import_node_fs19.writeFileSync)(
45266
45890
  plan.statePath,
45267
45891
  `${JSON.stringify(
@@ -45540,7 +46164,7 @@ function buildPendingAuthorizationOutput(input2) {
45540
46164
  };
45541
46165
  }
45542
46166
  function setupStatePath(baseUrl, scope, root) {
45543
- return scope === "local" && root ? (0, import_node_path25.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "setup.json");
46167
+ return scope === "local" && root ? (0, import_node_path26.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path26.join)(sdkCliStateDirPath(baseUrl), "setup.json");
45544
46168
  }
45545
46169
  async function captureStdout2(run) {
45546
46170
  let stdout = "";
@@ -45588,7 +46212,7 @@ function resolvePathCommands(command) {
45588
46212
  );
45589
46213
  return [
45590
46214
  ...new Set(
45591
- String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path25.resolve)(path))
46215
+ String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path26.resolve)(path))
45592
46216
  )
45593
46217
  ];
45594
46218
  }
@@ -45621,7 +46245,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
45621
46245
  if (prefix.status !== 0) return null;
45622
46246
  const root = String(prefix.stdout ?? "").trim();
45623
46247
  if (!root) return null;
45624
- const candidates = platform3 === "win32" ? [(0, import_node_path25.join)(root, "deepline.cmd"), (0, import_node_path25.join)(root, "deepline")] : [(0, import_node_path25.join)(root, "bin", "deepline")];
46248
+ 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")];
45625
46249
  return candidates.find((candidate) => pathExists(candidate)) ?? null;
45626
46250
  }
45627
46251
  function inspectGlobalCliAvailability(input2) {
@@ -45636,18 +46260,18 @@ function pathsResolveToSameFile(left, right) {
45636
46260
  try {
45637
46261
  return (0, import_node_fs20.realpathSync)(left) === (0, import_node_fs20.realpathSync)(right);
45638
46262
  } catch {
45639
- return (0, import_node_path25.resolve)(left) === (0, import_node_path25.resolve)(right);
46263
+ return (0, import_node_path26.resolve)(left) === (0, import_node_path26.resolve)(right);
45640
46264
  }
45641
46265
  }
45642
46266
  function isKnownDeeplineCommand(path) {
45643
- const entrypoint = process.argv[1] ? (0, import_node_path25.resolve)(process.argv[1]) : "";
46267
+ const entrypoint = process.argv[1] ? (0, import_node_path26.resolve)(process.argv[1]) : "";
45644
46268
  let resolvedPath = path;
45645
46269
  try {
45646
46270
  resolvedPath = (0, import_node_fs20.realpathSync)(path);
45647
46271
  } catch {
45648
46272
  }
45649
46273
  if (entrypoint && resolvedPath === entrypoint) return true;
45650
- if (resolvedPath.includes(`${(0, import_node_path25.join)("node_modules", "deepline")}`)) return true;
46274
+ if (resolvedPath.includes(`${(0, import_node_path26.join)("node_modules", "deepline")}`)) return true;
45651
46275
  const content = safeRead(path);
45652
46276
  return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
45653
46277
  }
@@ -45657,7 +46281,7 @@ function inspectPathConflict() {
45657
46281
  try {
45658
46282
  if ((0, import_node_fs20.lstatSync)(commandPath).isSymbolicLink()) {
45659
46283
  const target = (0, import_node_fs20.realpathSync)(commandPath);
45660
- if (target.includes(`${(0, import_node_path25.join)("node_modules", "deepline")}`)) return null;
46284
+ if (target.includes(`${(0, import_node_path26.join)("node_modules", "deepline")}`)) return null;
45661
46285
  }
45662
46286
  } catch {
45663
46287
  }
@@ -45665,7 +46289,7 @@ function inspectPathConflict() {
45665
46289
  }
45666
46290
  function writeSetupState(input2) {
45667
46291
  const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
45668
- (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
46292
+ (0, import_node_fs20.mkdirSync)((0, import_node_path26.dirname)(path), { recursive: true });
45669
46293
  (0, import_node_fs20.writeFileSync)(
45670
46294
  path,
45671
46295
  `${JSON.stringify(
@@ -45706,7 +46330,7 @@ function failSetupPhase(phases, phase, code) {
45706
46330
  phases[phase] = { status: "failed", code };
45707
46331
  }
45708
46332
  function rollbackCommand(scope, root) {
45709
- const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path25.join)(root, ".deepline", "runtime"))}` : "";
46333
+ const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path26.join)(root, ".deepline", "runtime"))}` : "";
45710
46334
  const allowScriptsFlag = npmSupportsAllowScripts(readNpmVersion(process.env)) ? " --allow-scripts=esbuild" : "";
45711
46335
  return `npm install -g${prefix} --no-audit --no-fund --include=optional${allowScriptsFlag} deepline@${SDK_VERSION}`;
45712
46336
  }
@@ -45796,12 +46420,12 @@ function buildDoctorAssessment(input2) {
45796
46420
  const connected = input2.authStatus.payload?.connected === true;
45797
46421
  const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
45798
46422
  const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
45799
- const runningCliPath = process.argv[1] ? (0, import_node_path25.resolve)(process.argv[1]) : null;
46423
+ const runningCliPath = process.argv[1] ? (0, import_node_path26.resolve)(process.argv[1]) : null;
45800
46424
  const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
45801
46425
  const pathGlobalCli = globalCli?.path ?? null;
45802
46426
  const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
45803
46427
  const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
45804
- input2.root && runningCliPath?.includes((0, import_node_path25.join)(input2.root, ".deepline", "runtime"))
46428
+ input2.root && runningCliPath?.includes((0, import_node_path26.join)(input2.root, ".deepline", "runtime"))
45805
46429
  );
45806
46430
  const checks = {
45807
46431
  cli: {
@@ -46421,7 +47045,7 @@ var import_node_fs24 = require("fs");
46421
47045
  // src/cli/update-preferences.ts
46422
47046
  var import_node_fs21 = require("fs");
46423
47047
  var import_node_os16 = require("os");
46424
- var import_node_path26 = require("path");
47048
+ var import_node_path27 = require("path");
46425
47049
  var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
46426
47050
  var CLI_UPDATE_MESSAGES = [
46427
47051
  {
@@ -46450,7 +47074,7 @@ function unreadablePreferences(path, error) {
46450
47074
  };
46451
47075
  }
46452
47076
  function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os16.homedir)()) {
46453
- return (0, import_node_path26.join)(
47077
+ return (0, import_node_path27.join)(
46454
47078
  homeDir2,
46455
47079
  ".local",
46456
47080
  "deepline",
@@ -46478,7 +47102,7 @@ function readCliUpdatePreferences(homeDir2 = (0, import_node_os16.homedir)()) {
46478
47102
  function writeCliUpdatePreferences(preferences, homeDir2 = (0, import_node_os16.homedir)()) {
46479
47103
  const path = cliUpdatePreferencesPath(homeDir2);
46480
47104
  const tempPath = `${path}.${process.pid}.tmp`;
46481
- (0, import_node_fs21.mkdirSync)((0, import_node_path26.dirname)(path), { recursive: true });
47105
+ (0, import_node_fs21.mkdirSync)((0, import_node_path27.dirname)(path), { recursive: true });
46482
47106
  try {
46483
47107
  (0, import_node_fs21.writeFileSync)(tempPath, `${JSON.stringify(preferences, null, 2)}
46484
47108
  `, {
@@ -46539,12 +47163,12 @@ function consumePendingCliUpdateMessages(homeDir2 = (0, import_node_os16.homedir
46539
47163
  var import_node_child_process6 = require("child_process");
46540
47164
  var import_node_fs23 = require("fs");
46541
47165
  var import_node_os17 = require("os");
46542
- var import_node_path28 = require("path");
47166
+ var import_node_path29 = require("path");
46543
47167
 
46544
47168
  // src/cli/install-integrity.ts
46545
47169
  var import_node_module2 = require("module");
46546
47170
  var import_node_fs22 = require("fs");
46547
- var import_node_path27 = require("path");
47171
+ var import_node_path28 = require("path");
46548
47172
  var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
46549
47173
  "dist/cli/index.mjs",
46550
47174
  "dist/index.mjs",
@@ -46563,7 +47187,7 @@ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
46563
47187
  "esbuild/lib/main.js"
46564
47188
  ];
46565
47189
  function safeRelativePath(value) {
46566
- if (typeof value !== "string" || !value || (0, import_node_path27.isAbsolute)(value)) return false;
47190
+ if (typeof value !== "string" || !value || (0, import_node_path28.isAbsolute)(value)) return false;
46567
47191
  const segments = value.split(/[\\/]+/);
46568
47192
  return segments.every(
46569
47193
  (segment) => Boolean(segment) && segment !== "." && segment !== ".."
@@ -46571,9 +47195,9 @@ function safeRelativePath(value) {
46571
47195
  }
46572
47196
  function resolveContainedPath(root, value) {
46573
47197
  if (!safeRelativePath(value)) return null;
46574
- const target = (0, import_node_path27.resolve)(root, value);
46575
- const relativeTarget = (0, import_node_path27.relative)((0, import_node_path27.resolve)(root), target);
46576
- if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path27.isAbsolute)(relativeTarget)) {
47198
+ const target = (0, import_node_path28.resolve)(root, value);
47199
+ const relativeTarget = (0, import_node_path28.relative)((0, import_node_path28.resolve)(root), target);
47200
+ if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path28.isAbsolute)(relativeTarget)) {
46577
47201
  return null;
46578
47202
  }
46579
47203
  return target;
@@ -46589,7 +47213,7 @@ function isFile(path) {
46589
47213
  }
46590
47214
  }
46591
47215
  function readManifest(packageRoot) {
46592
- const packageJsonPath = (0, import_node_path27.join)(packageRoot, "package.json");
47216
+ const packageJsonPath = (0, import_node_path28.join)(packageRoot, "package.json");
46593
47217
  let packageJson;
46594
47218
  try {
46595
47219
  packageJson = parseJson(packageJsonPath);
@@ -46663,8 +47287,8 @@ function readManifest(packageRoot) {
46663
47287
  return { mode: "manifest", manifest };
46664
47288
  }
46665
47289
  function inspectSdkSidecarInstall(versionDir) {
46666
- const nodeModulesRoot = (0, import_node_path27.join)(versionDir, "node_modules");
46667
- const packageRoot = (0, import_node_path27.join)(nodeModulesRoot, "deepline");
47290
+ const nodeModulesRoot = (0, import_node_path28.join)(versionDir, "node_modules");
47291
+ const packageRoot = (0, import_node_path28.join)(nodeModulesRoot, "deepline");
46668
47292
  const manifestResult = readManifest(packageRoot);
46669
47293
  if ("invalidReason" in manifestResult) {
46670
47294
  return {
@@ -46675,8 +47299,8 @@ function inspectSdkSidecarInstall(versionDir) {
46675
47299
  };
46676
47300
  }
46677
47301
  const missing = [
46678
- ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path27.join)(packageRoot, path))).map((path) => `deepline/${path}`),
46679
- ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path27.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
47302
+ ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path28.join)(packageRoot, path))).map((path) => `deepline/${path}`),
47303
+ ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path28.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
46680
47304
  ];
46681
47305
  return {
46682
47306
  ok: missing.length === 0,
@@ -46687,7 +47311,7 @@ function inspectSdkSidecarInstall(versionDir) {
46687
47311
  }
46688
47312
  function probeSdkSidecarEsbuild(versionDir) {
46689
47313
  try {
46690
- const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path27.join)(versionDir, "package.json"));
47314
+ const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path28.join)(versionDir, "package.json"));
46691
47315
  const esbuild = requireFromInstall("esbuild");
46692
47316
  if (typeof esbuild.transformSync !== "function") {
46693
47317
  return "esbuild does not export transformSync";
@@ -46756,7 +47380,7 @@ function sidecarStateDir(input2) {
46756
47380
  if (!scope || scope.includes("/") || scope.includes("\\")) {
46757
47381
  return null;
46758
47382
  }
46759
- return (0, import_node_path28.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
47383
+ return (0, import_node_path29.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
46760
47384
  }
46761
47385
  function sidecarRegistryUrl(hostUrl) {
46762
47386
  let url;
@@ -46791,19 +47415,19 @@ function readOptionalText(path) {
46791
47415
  function resolvePythonSidecarUpdatePlan(options) {
46792
47416
  const stateDir = sidecarStateDir(options);
46793
47417
  if (!stateDir) return null;
46794
- const relativeEntrypoint = (0, import_node_path28.relative)(
46795
- (0, import_node_path28.resolve)(stateDir),
46796
- (0, import_node_path28.resolve)(options.entrypoint)
47418
+ const relativeEntrypoint = (0, import_node_path29.relative)(
47419
+ (0, import_node_path29.resolve)(stateDir),
47420
+ (0, import_node_path29.resolve)(options.entrypoint)
46797
47421
  );
46798
- if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path28.isAbsolute)(relativeEntrypoint)) {
47422
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path29.isAbsolute)(relativeEntrypoint)) {
46799
47423
  return null;
46800
47424
  }
46801
- const installMethod = readOptionalText((0, import_node_path28.join)(stateDir, ".install-method"));
47425
+ const installMethod = readOptionalText((0, import_node_path29.join)(stateDir, ".install-method"));
46802
47426
  if (installMethod !== "python-sidecar") return null;
46803
47427
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
46804
47428
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
46805
- const nodeBin = readOptionalText((0, import_node_path28.join)(stateDir, ".node-bin")) || process.execPath;
46806
- const sidecarPath = readOptionalText((0, import_node_path28.join)(stateDir, ".command-path")) || (0, import_node_path28.join)(
47429
+ const nodeBin = readOptionalText((0, import_node_path29.join)(stateDir, ".node-bin")) || process.execPath;
47430
+ const sidecarPath = readOptionalText((0, import_node_path29.join)(stateDir, ".command-path")) || (0, import_node_path29.join)(
46807
47431
  stateDir,
46808
47432
  "bin",
46809
47433
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
@@ -46811,7 +47435,7 @@ function resolvePythonSidecarUpdatePlan(options) {
46811
47435
  const packageSpec = options.packageSpec || "deepline@latest";
46812
47436
  const npmCommand = "npm";
46813
47437
  const registryUrl = sidecarRegistryUrl(hostUrl);
46814
- const versionDir = (0, import_node_path28.join)(stateDir, "versions", "<version>");
47438
+ const versionDir = (0, import_node_path29.join)(stateDir, "versions", "<version>");
46815
47439
  const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote5(versionDir)} --registry ${shellQuote5(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote5).join(" ")} ${shellQuote5(packageSpec)}`;
46816
47440
  return {
46817
47441
  kind: "python-sidecar",
@@ -46827,16 +47451,16 @@ function resolvePythonSidecarUpdatePlan(options) {
46827
47451
  };
46828
47452
  }
46829
47453
  function findRepoBackedSdkRoot(startPath) {
46830
- let current = (0, import_node_path28.resolve)(startPath);
47454
+ let current = (0, import_node_path29.resolve)(startPath);
46831
47455
  while (true) {
46832
- if ((0, import_node_fs23.existsSync)((0, import_node_path28.join)(current, "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path28.join)(current, "bin", "deepline-dev.ts"))) {
46833
- const parent2 = (0, import_node_path28.dirname)(current);
46834
- return (0, import_node_path28.basename)(parent2) === "packages" && (0, import_node_path28.basename)(current) === "sdk" ? (0, import_node_path28.dirname)(parent2) : parent2;
47456
+ if ((0, import_node_fs23.existsSync)((0, import_node_path29.join)(current, "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path29.join)(current, "bin", "deepline-dev.ts"))) {
47457
+ const parent2 = (0, import_node_path29.dirname)(current);
47458
+ return (0, import_node_path29.basename)(parent2) === "packages" && (0, import_node_path29.basename)(current) === "sdk" ? (0, import_node_path29.dirname)(parent2) : parent2;
46835
47459
  }
46836
- if ((0, import_node_fs23.existsSync)((0, import_node_path28.join)(current, "sdk", "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path28.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
47460
+ if ((0, import_node_fs23.existsSync)((0, import_node_path29.join)(current, "sdk", "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path29.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
46837
47461
  return current;
46838
47462
  }
46839
- const parent = (0, import_node_path28.dirname)(current);
47463
+ const parent = (0, import_node_path29.dirname)(current);
46840
47464
  if (parent === current) return null;
46841
47465
  current = parent;
46842
47466
  }
@@ -46846,7 +47470,7 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
46846
47470
  try {
46847
47471
  return (0, import_node_fs23.realpathSync)(entrypoint);
46848
47472
  } catch {
46849
- return (0, import_node_path28.resolve)(entrypoint);
47473
+ return (0, import_node_path29.resolve)(entrypoint);
46850
47474
  }
46851
47475
  })();
46852
47476
  const parts = normalized.split(/[\\/]+/);
@@ -46861,10 +47485,10 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
46861
47485
  const directPrefix = prefixParts.join("/").toLowerCase();
46862
47486
  const knownWindowsPrefixes = [
46863
47487
  env.npm_config_prefix,
46864
- env.APPDATA ? (0, import_node_path28.join)(env.APPDATA, "npm") : void 0
46865
- ].filter((value) => Boolean(value)).map((value) => (0, import_node_path28.resolve)(value).replace(/\\/g, "/").toLowerCase());
47488
+ env.APPDATA ? (0, import_node_path29.join)(env.APPDATA, "npm") : void 0
47489
+ ].filter((value) => Boolean(value)).map((value) => (0, import_node_path29.resolve)(value).replace(/\\/g, "/").toLowerCase());
46866
47490
  if (!knownWindowsPrefixes.includes(
46867
- (0, import_node_path28.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
47491
+ (0, import_node_path29.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
46868
47492
  )) {
46869
47493
  return null;
46870
47494
  }
@@ -46877,9 +47501,9 @@ function normalizedNpmPrefix(value) {
46877
47501
  if (!trimmed) return null;
46878
47502
  const normalized = (() => {
46879
47503
  try {
46880
- return (0, import_node_fs23.realpathSync)((0, import_node_path28.resolve)(trimmed));
47504
+ return (0, import_node_fs23.realpathSync)((0, import_node_path29.resolve)(trimmed));
46881
47505
  } catch {
46882
- return (0, import_node_path28.resolve)(trimmed);
47506
+ return (0, import_node_path29.resolve)(trimmed);
46883
47507
  }
46884
47508
  })().replace(/\\/g, "/");
46885
47509
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
@@ -46904,7 +47528,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
46904
47528
  try {
46905
47529
  return (0, import_node_fs23.realpathSync)(entrypoint);
46906
47530
  } catch {
46907
- return (0, import_node_path28.resolve)(entrypoint);
47531
+ return (0, import_node_path29.resolve)(entrypoint);
46908
47532
  }
46909
47533
  })();
46910
47534
  const parts = normalized.split(/[\\/]+/);
@@ -46914,8 +47538,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
46914
47538
  function resolveUpdatePlan(options = {}) {
46915
47539
  const env = options.env ?? process.env;
46916
47540
  const homeDir2 = options.homeDir ?? (0, import_node_os17.homedir)();
46917
- const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path28.resolve)(process.argv[1]) : "");
46918
- const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path28.dirname)(entrypoint)) : null;
47541
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path29.resolve)(process.argv[1]) : "");
47542
+ const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path29.dirname)(entrypoint)) : null;
46919
47543
  if (sourceRoot) {
46920
47544
  return {
46921
47545
  kind: "source",
@@ -46968,9 +47592,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
46968
47592
  function autoUpdateFailurePath(plan) {
46969
47593
  if (plan.kind === "source" || plan.kind === "homebrew") return null;
46970
47594
  if (plan.kind === "python-sidecar") {
46971
- return (0, import_node_path28.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
47595
+ return (0, import_node_path29.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
46972
47596
  }
46973
- return (0, import_node_path28.join)(
47597
+ return (0, import_node_path29.join)(
46974
47598
  (0, import_node_os17.homedir)(),
46975
47599
  ".local",
46976
47600
  "deepline",
@@ -47009,7 +47633,7 @@ function writeAutoUpdateFailure(plan, exitCode) {
47009
47633
  manualCommand: plan.manualCommand
47010
47634
  };
47011
47635
  try {
47012
- (0, import_node_fs23.mkdirSync)((0, import_node_path28.dirname)(path), { recursive: true });
47636
+ (0, import_node_fs23.mkdirSync)((0, import_node_path29.dirname)(path), { recursive: true });
47013
47637
  (0, import_node_fs23.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
47014
47638
  `, "utf8");
47015
47639
  } catch {
@@ -47057,7 +47681,7 @@ function safeVersionSegment(value) {
47057
47681
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
47058
47682
  }
47059
47683
  function entryPathInVersionDir(versionDir) {
47060
- return (0, import_node_path28.join)(
47684
+ return (0, import_node_path29.join)(
47061
47685
  versionDir,
47062
47686
  "node_modules",
47063
47687
  "deepline",
@@ -47067,7 +47691,7 @@ function entryPathInVersionDir(versionDir) {
47067
47691
  );
47068
47692
  }
47069
47693
  function installedPackageVersion(versionDir) {
47070
- const packageJsonPath = (0, import_node_path28.join)(
47694
+ const packageJsonPath = (0, import_node_path29.join)(
47071
47695
  versionDir,
47072
47696
  "node_modules",
47073
47697
  "deepline",
@@ -47189,16 +47813,16 @@ async function runNpmInstallWithRegistryFallback(input2) {
47189
47813
  return first.exitCode;
47190
47814
  }
47191
47815
  function writeSidecarLauncher(input2) {
47192
- (0, import_node_fs23.mkdirSync)((0, import_node_path28.dirname)(input2.path), { recursive: true });
47193
- const packageRoot = (0, import_node_path28.dirname)((0, import_node_path28.dirname)((0, import_node_path28.dirname)(input2.entryPath)));
47194
- const versionDir = (0, import_node_path28.dirname)((0, import_node_path28.dirname)(packageRoot));
47816
+ (0, import_node_fs23.mkdirSync)((0, import_node_path29.dirname)(input2.path), { recursive: true });
47817
+ const packageRoot = (0, import_node_path29.dirname)((0, import_node_path29.dirname)((0, import_node_path29.dirname)(input2.entryPath)));
47818
+ const versionDir = (0, import_node_path29.dirname)((0, import_node_path29.dirname)(packageRoot));
47195
47819
  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);";
47196
47820
  const criticalPaths = [
47197
47821
  ...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
47198
- (path) => (0, import_node_path28.join)(packageRoot, path)
47822
+ (path) => (0, import_node_path29.join)(packageRoot, path)
47199
47823
  ),
47200
47824
  ...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
47201
- (path) => (0, import_node_path28.join)(versionDir, "node_modules", path)
47825
+ (path) => (0, import_node_path29.join)(versionDir, "node_modules", path)
47202
47826
  )
47203
47827
  ];
47204
47828
  if (process.platform === "win32") {
@@ -47252,17 +47876,17 @@ function writeSidecarLauncher(input2) {
47252
47876
  );
47253
47877
  }
47254
47878
  async function runPythonSidecarUpdatePlan(plan) {
47255
- const versionsDir = (0, import_node_path28.join)(plan.stateDir, "versions");
47256
- const tempDir = (0, import_node_path28.join)(
47879
+ const versionsDir = (0, import_node_path29.join)(plan.stateDir, "versions");
47880
+ const tempDir = (0, import_node_path29.join)(
47257
47881
  versionsDir,
47258
47882
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
47259
47883
  );
47260
47884
  (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
47261
47885
  (0, import_node_fs23.mkdirSync)(tempDir, { recursive: true });
47262
- (0, import_node_fs23.writeFileSync)((0, import_node_path28.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
47886
+ (0, import_node_fs23.writeFileSync)((0, import_node_path29.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
47263
47887
  const env = {
47264
47888
  ...process.env,
47265
- PATH: `${(0, import_node_path28.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
47889
+ PATH: `${(0, import_node_path29.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
47266
47890
  };
47267
47891
  const installResult = await runCommand(
47268
47892
  plan.npmCommand,
@@ -47299,7 +47923,7 @@ async function runPythonSidecarUpdatePlan(plan) {
47299
47923
  (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
47300
47924
  return 1;
47301
47925
  }
47302
- const finalDir = (0, import_node_path28.join)(versionsDir, installedVersion);
47926
+ const finalDir = (0, import_node_path29.join)(versionsDir, installedVersion);
47303
47927
  const finalEntryPath = entryPathInVersionDir(finalDir);
47304
47928
  const finalFailure = sidecarInstallFailure(finalDir);
47305
47929
  let backupDir = null;
@@ -47308,7 +47932,7 @@ async function runPythonSidecarUpdatePlan(plan) {
47308
47932
  } else {
47309
47933
  let shouldPublishTemp = true;
47310
47934
  if ((0, import_node_fs23.existsSync)(finalDir)) {
47311
- backupDir = (0, import_node_path28.join)(
47935
+ backupDir = (0, import_node_path29.join)(
47312
47936
  versionsDir,
47313
47937
  `.backup-${installedVersion}-${process.pid}-${Date.now()}`
47314
47938
  );
@@ -47383,27 +48007,27 @@ async function runPythonSidecarUpdatePlan(plan) {
47383
48007
  entryPath: finalEntryPath
47384
48008
  });
47385
48009
  (0, import_node_fs23.writeFileSync)(
47386
- (0, import_node_path28.join)(plan.stateDir, ".version"),
48010
+ (0, import_node_path29.join)(plan.stateDir, ".version"),
47387
48011
  `${installedVersion}
47388
48012
  `,
47389
48013
  "utf8"
47390
48014
  );
47391
48015
  (0, import_node_fs23.writeFileSync)(
47392
- (0, import_node_path28.join)(plan.stateDir, ".install-method"),
48016
+ (0, import_node_path29.join)(plan.stateDir, ".install-method"),
47393
48017
  "python-sidecar\n",
47394
48018
  "utf8"
47395
48019
  );
47396
48020
  (0, import_node_fs23.writeFileSync)(
47397
- (0, import_node_path28.join)(plan.stateDir, ".command-path"),
48021
+ (0, import_node_path29.join)(plan.stateDir, ".command-path"),
47398
48022
  `${plan.sidecarPath}
47399
48023
  `,
47400
48024
  "utf8"
47401
48025
  );
47402
- (0, import_node_fs23.writeFileSync)((0, import_node_path28.join)(plan.stateDir, ".runner"), "node\n", "utf8");
47403
- (0, import_node_fs23.writeFileSync)((0, import_node_path28.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
48026
+ (0, import_node_fs23.writeFileSync)((0, import_node_path29.join)(plan.stateDir, ".runner"), "node\n", "utf8");
48027
+ (0, import_node_fs23.writeFileSync)((0, import_node_path29.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
47404
48028
  `, "utf8");
47405
48029
  (0, import_node_fs23.writeFileSync)(
47406
- (0, import_node_path28.join)(plan.stateDir, ".entry-path"),
48030
+ (0, import_node_path29.join)(plan.stateDir, ".entry-path"),
47407
48031
  `${finalEntryPath}
47408
48032
  `,
47409
48033
  "utf8"
@@ -47670,7 +48294,7 @@ function requireCatalogEvent(settings, eventType) {
47670
48294
  }
47671
48295
  return event;
47672
48296
  }
47673
- async function printSettings(options) {
48297
+ async function printSettings2(options) {
47674
48298
  const settings = await new DeeplineClient().getNotificationSettings();
47675
48299
  const slack = slackDestination(settings);
47676
48300
  const destinationId = typeof slack?._id === "string" ? slack._id : void 0;
@@ -47797,7 +48421,7 @@ Slack is the delivery integration. This command group only manages product
47797
48421
  notifications; there is no general integrations CLI.
47798
48422
  `
47799
48423
  );
47800
- notifications.command("get").description("Show destination, subscriptions, and DLQ health.").option("--json", "Emit JSON output").action(printSettings);
48424
+ notifications.command("get").description("Show destination, subscriptions, and DLQ health.").option("--json", "Emit JSON output").action(printSettings2);
47801
48425
  notifications.command("connect").description("Start the OAuth connection required by a destination.").argument("<destination>", "Destination kind (currently slack)").option("--open", "Open the Slack authorization URL in a browser").option("--dry-run", "Describe the mutation without starting OAuth").option("--json", "Emit JSON output").action(
47802
48426
  async (destination, options) => {
47803
48427
  if (destination !== "slack")
@@ -48474,12 +49098,12 @@ function stableStringify(value) {
48474
49098
  // src/cli/commands/tools.ts
48475
49099
  var import_node_fs26 = require("fs");
48476
49100
  var import_node_os19 = require("os");
48477
- var import_node_path30 = require("path");
49101
+ var import_node_path31 = require("path");
48478
49102
 
48479
49103
  // src/tool-output.ts
48480
49104
  var import_node_fs25 = require("fs");
48481
49105
  var import_node_os18 = require("os");
48482
- var import_node_path29 = require("path");
49106
+ var import_node_path30 = require("path");
48483
49107
  function isPlainObject(value) {
48484
49108
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
48485
49109
  }
@@ -48606,19 +49230,19 @@ function projectRowOutput(conversion) {
48606
49230
  };
48607
49231
  }
48608
49232
  function ensureOutputDir() {
48609
- const outputDir = (0, import_node_path29.join)((0, import_node_os18.homedir)(), ".local", "share", "deepline", "data");
49233
+ const outputDir = (0, import_node_path30.join)((0, import_node_os18.homedir)(), ".local", "share", "deepline", "data");
48610
49234
  (0, import_node_fs25.mkdirSync)(outputDir, { recursive: true });
48611
49235
  return outputDir;
48612
49236
  }
48613
49237
  function writeJsonOutputFile(payload, stem) {
48614
49238
  const outputDir = ensureOutputDir();
48615
- const outputPath = (0, import_node_path29.join)(outputDir, `${stem}_${Date.now()}.json`);
49239
+ const outputPath = (0, import_node_path30.join)(outputDir, `${stem}_${Date.now()}.json`);
48616
49240
  (0, import_node_fs25.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
48617
49241
  return outputPath;
48618
49242
  }
48619
49243
  function writeCsvOutputFile(rows, stem, options) {
48620
- const outputPath = options?.outPath ? options.outPath : (0, import_node_path29.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
48621
- (0, import_node_fs25.mkdirSync)((0, import_node_path29.dirname)(outputPath), { recursive: true });
49244
+ const outputPath = options?.outPath ? options.outPath : (0, import_node_path30.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
49245
+ (0, import_node_fs25.mkdirSync)((0, import_node_path30.dirname)(outputPath), { recursive: true });
48622
49246
  const columns = columnsForRows(rows);
48623
49247
  const escapeCell = (value) => {
48624
49248
  const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
@@ -49220,6 +49844,8 @@ async function searchTools(queryInput, options = {}) {
49220
49844
  query,
49221
49845
  categories: options.categories,
49222
49846
  searchTerms: options.searchTerms,
49847
+ limit: options.limit,
49848
+ offset: options.offset,
49223
49849
  searchMode: options.searchMode,
49224
49850
  includeSearchDebug: options.includeSearchDebug
49225
49851
  });
@@ -49450,13 +50076,15 @@ Notes:
49450
50076
  that can be passed to deepline tools describe or deepline tools execute.
49451
50077
  Provide a query, or omit it only when --categories and/or --search_terms is
49452
50078
  supplied. Providing neither is a usage error. Both filters accept
49453
- comma-separated values. Use a provider name in the query; --prefix is not a
49454
- supported option.
50079
+ comma-separated values. Use --limit and --offset to page through ranked
50080
+ results (limit 1-50, offset is zero-based); JSON includes next_offset.
50081
+ Use a provider name in the query; --prefix is not a supported option.
49455
50082
  The grep alias is the same ranked retrieval surface with a more literal name
49456
50083
  for agents that are filtering a registry rather than choosing a workflow.
49457
50084
 
49458
50085
  Examples:
49459
- deepline tools search email
50086
+ deepline tools search email --limit 10 --json
50087
+ deepline tools search email --limit 10 --offset 10 --json
49460
50088
  deepline tools search --categories company_search --search_terms "investors,funding"
49461
50089
  deepline tools grep "company enrichment" --categories enrichment --json
49462
50090
  deepline tools search verifier --search-mode v2 --json
@@ -49467,10 +50095,12 @@ Examples:
49467
50095
  ).option(
49468
50096
  "--search_terms <terms>",
49469
50097
  "Comma-separated structured search terms; may be used without a query"
49470
- ).option("--search-terms <terms>", "Alias for --search_terms").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--compact", "Drop verbose fields from JSON output").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (query, options) => {
50098
+ ).option("--search-terms <terms>", "Alias for --search_terms").option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--compact", "Drop verbose fields from JSON output").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (query, options) => {
49471
50099
  process.exitCode = await searchTools(query, {
49472
50100
  json: options.json,
49473
50101
  compact: options.compact,
50102
+ limit: options.limit !== void 0 ? Number.parseInt(options.limit, 10) : void 0,
50103
+ offset: options.offset !== void 0 ? Number.parseInt(options.offset, 10) : void 0,
49474
50104
  categories: options.categories,
49475
50105
  searchTerms: options.searchTerms ?? options.search_terms,
49476
50106
  searchMode: options.searchMode === "v1" || options.searchMode === "v2" ? options.searchMode : void 0,
@@ -49873,8 +50503,8 @@ function printMonitorTypeFilters(tool) {
49873
50503
  }
49874
50504
  function printMonitorTypeFilterExamples(tool) {
49875
50505
  const documentation = recordField2(tool, "documentation");
49876
- const fields = recordField2(documentation, "fields");
49877
- const examples = Object.entries(fields).flatMap(([name, rawField]) => {
50506
+ const fields2 = recordField2(documentation, "fields");
50507
+ const examples = Object.entries(fields2).flatMap(([name, rawField]) => {
49878
50508
  const grammar = recordField2(isRecord12(rawField) ? rawField : {}, "grammar");
49879
50509
  const example = stringField2(grammar, "example");
49880
50510
  const values = [
@@ -50229,9 +50859,9 @@ function sampleValueForField(field) {
50229
50859
  if (type === "object") return {};
50230
50860
  return "...";
50231
50861
  }
50232
- function samplePayloadForInputFields(fields) {
50862
+ function samplePayloadForInputFields(fields2) {
50233
50863
  return Object.fromEntries(
50234
- fields.slice(0, 4).flatMap((field) => {
50864
+ fields2.slice(0, 4).flatMap((field) => {
50235
50865
  if (!isRecord12(field)) return [];
50236
50866
  const name = stringField2(field, "name");
50237
50867
  if (!name) return [];
@@ -50362,8 +50992,8 @@ function formatListedToolCost(tool) {
50362
50992
  }
50363
50993
  function toolInputFieldsForDisplay(inputSchema) {
50364
50994
  if (Array.isArray(inputSchema.fields)) {
50365
- const fields = inputSchema.fields.filter(isRecord12);
50366
- if (!isRecord12(inputSchema.jsonSchema)) return fields;
50995
+ const fields2 = inputSchema.fields.filter(isRecord12);
50996
+ if (!isRecord12(inputSchema.jsonSchema)) return fields2;
50367
50997
  const jsonSchemaFields = new Map(
50368
50998
  recursiveToolInputFieldsForDisplay({
50369
50999
  jsonSchema: inputSchema.jsonSchema
@@ -50371,7 +51001,7 @@ function toolInputFieldsForDisplay(inputSchema) {
50371
51001
  (field) => typeof field.name === "string" ? [[field.name, field]] : []
50372
51002
  )
50373
51003
  );
50374
- return fields.map((field) => {
51004
+ return fields2.map((field) => {
50375
51005
  const jsonSchemaField = typeof field.name === "string" ? jsonSchemaFields.get(field.name) : void 0;
50376
51006
  const minItems = typeof field.minItems === "number" ? field.minItems : jsonSchemaField?.minItems;
50377
51007
  const maxItems = typeof field.maxItems === "number" ? field.maxItems : jsonSchemaField?.maxItems;
@@ -50468,7 +51098,7 @@ function publicToolInputSchemaForDescribe(inputSchema) {
50468
51098
  }
50469
51099
  function recursiveToolInputFieldsForDisplay(inputSchema) {
50470
51100
  const root = canonicalToolJsonSchema(inputSchema);
50471
- const fields = /* @__PURE__ */ new Map();
51101
+ const fields2 = /* @__PURE__ */ new Map();
50472
51102
  const schemasById = /* @__PURE__ */ new Map();
50473
51103
  const collectSchemaIds = (value) => {
50474
51104
  if (Array.isArray(value)) {
@@ -50496,9 +51126,9 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
50496
51126
  const addField = (field) => {
50497
51127
  const name = typeof field.name === "string" ? field.name : "";
50498
51128
  if (!name) return;
50499
- const existing = fields.get(name);
51129
+ const existing = fields2.get(name);
50500
51130
  if (!existing || existing.type === "unknown") {
50501
- fields.set(name, field);
51131
+ fields2.set(name, field);
50502
51132
  }
50503
51133
  };
50504
51134
  const visit = (unresolvedSchema, path, required, activeRefs = /* @__PURE__ */ new Set()) => {
@@ -50546,7 +51176,7 @@ function recursiveToolInputFieldsForDisplay(inputSchema) {
50546
51176
  }
50547
51177
  };
50548
51178
  visit(root, "", false);
50549
- return fields.size ? [...fields.values()] : toolInputFieldsForDisplay(inputSchema);
51179
+ return fields2.size ? [...fields2.values()] : toolInputFieldsForDisplay(inputSchema);
50550
51180
  }
50551
51181
  function inputFieldJsonForDescribe(field) {
50552
51182
  const publicItems = isRecord12(field.items) ? publicToolInputSchemaForDescribe({ items: field.items }).items : void 0;
@@ -50812,10 +51442,10 @@ function normalizeOutputFormat(raw) {
50812
51442
  }
50813
51443
  function resolveAtFilePath(rawPath) {
50814
51444
  const trimmed = rawPath.trim();
50815
- const resolved = (0, import_node_path30.resolve)(trimmed);
51445
+ const resolved = (0, import_node_path31.resolve)(trimmed);
50816
51446
  if ((0, import_node_fs26.existsSync)(resolved)) return resolved;
50817
51447
  if (process.platform !== "win32" && trimmed.includes("\\")) {
50818
- const normalized = (0, import_node_path30.resolve)(trimmed.replace(/\\/g, "/"));
51448
+ const normalized = (0, import_node_path31.resolve)(trimmed.replace(/\\/g, "/"));
50819
51449
  if ((0, import_node_fs26.existsSync)(normalized)) return normalized;
50820
51450
  }
50821
51451
  return resolved;
@@ -50928,7 +51558,7 @@ function parseExecuteOptions(args) {
50928
51558
  continue;
50929
51559
  }
50930
51560
  if ((arg === "--out" || arg === "-o") && args[index + 1]) {
50931
- outPath = (0, import_node_path30.resolve)(args[++index]);
51561
+ outPath = (0, import_node_path31.resolve)(args[++index]);
50932
51562
  continue;
50933
51563
  }
50934
51564
  throw new Error(`Unknown option: ${arg}`);
@@ -50966,13 +51596,13 @@ function parseToolExecuteTimeout(raw) {
50966
51596
  function pendingToolExecutionPath(input2) {
50967
51597
  const config = resolveConfig();
50968
51598
  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");
50969
- return (0, import_node_path30.join)(
51599
+ return (0, import_node_path31.join)(
50970
51600
  sdkCliStateDirPath(resolveConfig().baseUrl),
50971
51601
  `pending-tool-execution-${fingerprint}.json`
50972
51602
  );
50973
51603
  }
50974
51604
  function loadOrCreatePendingToolExecution(path) {
50975
- (0, import_node_fs26.mkdirSync)((0, import_node_path30.dirname)(path), { recursive: true });
51605
+ (0, import_node_fs26.mkdirSync)((0, import_node_path31.dirname)(path), { recursive: true });
50976
51606
  if ((0, import_node_fs26.existsSync)(path)) {
50977
51607
  return readPendingToolExecution(path);
50978
51608
  }
@@ -51050,9 +51680,9 @@ function starterScriptJson(script) {
51050
51680
  function seedToolListScript(input2) {
51051
51681
  const stem = safeFileStem(input2.toolId);
51052
51682
  const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
51053
- const scriptDir = (0, import_node_fs26.mkdtempSync)((0, import_node_path30.join)((0, import_node_os19.tmpdir)(), "deepline-workflow-seed-"));
51683
+ const scriptDir = (0, import_node_fs26.mkdtempSync)((0, import_node_path31.join)((0, import_node_os19.tmpdir)(), "deepline-workflow-seed-"));
51054
51684
  (0, import_node_fs26.chmodSync)(scriptDir, 448);
51055
- const scriptPath = (0, import_node_path30.join)(scriptDir, fileName);
51685
+ const scriptPath = (0, import_node_path31.join)(scriptDir, fileName);
51056
51686
  const projectDir = `deepline/projects/${stem}-workflow`;
51057
51687
  const playName = `${stem}-workflow`;
51058
51688
  const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
@@ -51557,8 +52187,8 @@ Examples:
51557
52187
  }
51558
52188
 
51559
52189
  // src/cli/commands/workflow.ts
51560
- var import_promises13 = require("fs/promises");
51561
- var import_node_path31 = require("path");
52190
+ var import_promises14 = require("fs/promises");
52191
+ var import_node_path32 = require("path");
51562
52192
 
51563
52193
  // src/cli/workflow-to-play.ts
51564
52194
  var import_node_crypto13 = require("crypto");
@@ -51775,7 +52405,7 @@ function readStatus(payload) {
51775
52405
  }
51776
52406
  async function readJsonOption(payload, file) {
51777
52407
  if (file) {
51778
- const raw = await (0, import_promises13.readFile)((0, import_node_path31.resolve)(file), "utf8");
52408
+ const raw = await (0, import_promises14.readFile)((0, import_node_path32.resolve)(file), "utf8");
51779
52409
  return JSON.parse(raw);
51780
52410
  }
51781
52411
  if (payload) {
@@ -51809,9 +52439,9 @@ async function transformOne(api, workflowId, outDir, publish) {
51809
52439
  revision.config,
51810
52440
  { workflowName: workflow.name, version: revision.version }
51811
52441
  );
51812
- const file = (0, import_node_path31.join)((0, import_node_path31.resolve)(outDir), `${compiled.playName}.play.ts`);
51813
- await (0, import_promises13.mkdir)((0, import_node_path31.dirname)(file), { recursive: true });
51814
- await (0, import_promises13.writeFile)(file, compiled.sourceCode, "utf8");
52442
+ const file = (0, import_node_path32.join)((0, import_node_path32.resolve)(outDir), `${compiled.playName}.play.ts`);
52443
+ await (0, import_promises14.mkdir)((0, import_node_path32.dirname)(file), { recursive: true });
52444
+ await (0, import_promises14.writeFile)(file, compiled.sourceCode, "utf8");
51815
52445
  let published = false;
51816
52446
  if (publish) {
51817
52447
  const code = await handlePlayPublish([file]);
@@ -52356,10 +52986,10 @@ function topLevelCommandKnown(program, commandName) {
52356
52986
  );
52357
52987
  }
52358
52988
  async function runPlayRunnerHealthCheck() {
52359
- const dir = await (0, import_promises14.mkdtemp)((0, import_node_path32.join)((0, import_node_os20.tmpdir)(), "deepline-health-play-"));
52360
- const file = (0, import_node_path32.join)(dir, "health-check.play.ts");
52989
+ const dir = await (0, import_promises15.mkdtemp)((0, import_node_path33.join)((0, import_node_os20.tmpdir)(), "deepline-health-play-"));
52990
+ const file = (0, import_node_path33.join)(dir, "health-check.play.ts");
52361
52991
  try {
52362
- await (0, import_promises14.writeFile)(
52992
+ await (0, import_promises15.writeFile)(
52363
52993
  file,
52364
52994
  [
52365
52995
  "import { definePlay } from 'deepline';",
@@ -52408,7 +53038,7 @@ async function runPlayRunnerHealthCheck() {
52408
53038
  }
52409
53039
  };
52410
53040
  } finally {
52411
- await (0, import_promises14.rm)(dir, { recursive: true, force: true });
53041
+ await (0, import_promises15.rm)(dir, { recursive: true, force: true });
52412
53042
  }
52413
53043
  }
52414
53044
  function pickString(value, ...keys) {