deepline 0.1.201 → 0.1.203

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/apps/play-runner-workers/src/entry.ts +30 -9
  2. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +25 -0
  3. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +139 -124
  4. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  5. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +17 -2
  6. package/dist/bundling-sources/shared_libs/play-runtime/bounded-dispatch.ts +52 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +154 -23
  8. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +10 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +16 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +121 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/governor/adaptive-admission.ts +6 -1
  12. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-budget-state-backend.ts +22 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +86 -19
  14. package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +141 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +129 -41
  17. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +40 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/receipt-completion-sink.ts +92 -33
  19. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +13 -5
  20. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +122 -120
  21. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +10 -8
  22. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +140 -32
  23. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +2 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +225 -29
  25. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +26 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +21 -0
  27. package/dist/bundling-sources/shared_libs/plays/dataset.ts +32 -10
  28. package/dist/cli/index.js +335 -77
  29. package/dist/cli/index.mjs +341 -83
  30. package/dist/index.js +3 -2
  31. package/dist/index.mjs +3 -2
  32. package/package.json +1 -1
  33. package/dist/bundling-sources/shared_libs/play-runtime/adaptive-tool-dispatcher.ts +0 -355
package/dist/cli/index.js CHANGED
@@ -623,10 +623,10 @@ var SDK_RELEASE = {
623
623
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
624
624
  // fields shipped in 0.1.153.
625
625
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
626
- version: "0.1.201",
626
+ version: "0.1.203",
627
627
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
628
628
  supportPolicy: {
629
- latest: "0.1.201",
629
+ latest: "0.1.203",
630
630
  minimumSupported: "0.1.53",
631
631
  deprecatedBelow: "0.1.53",
632
632
  commandMinimumSupported: [
@@ -1907,10 +1907,10 @@ var OBSERVER_LOG_PAGE_QUERY = "runObservers:getRunLogPageForObserver";
1907
1907
  function errorText(error) {
1908
1908
  return error instanceof Error ? error.message : String(error);
1909
1909
  }
1910
- async function mintRunObserveGrant(http, runId) {
1910
+ async function mintRunObserveGrant(http2, runId) {
1911
1911
  let response;
1912
1912
  try {
1913
- response = await http.post(
1913
+ response = await http2.post(
1914
1914
  `/api/v2/runs/${encodeURIComponent(runId)}/observe-grant`,
1915
1915
  {}
1916
1916
  );
@@ -1974,8 +1974,8 @@ async function backfillLogGap(input2) {
1974
1974
  return lines;
1975
1975
  }
1976
1976
  async function* observeRunEvents(options) {
1977
- const { http, runId } = options;
1978
- let grant = await mintRunObserveGrant(http, runId);
1977
+ const { http: http2, runId } = options;
1978
+ let grant = await mintRunObserveGrant(http2, runId);
1979
1979
  let convexBrowser;
1980
1980
  let convexServer;
1981
1981
  try {
@@ -2038,7 +2038,7 @@ async function* observeRunEvents(options) {
2038
2038
  lastForcedRefreshAt = now;
2039
2039
  }
2040
2040
  try {
2041
- grant = await mintRunObserveGrant(http, runId);
2041
+ grant = await mintRunObserveGrant(http2, runId);
2042
2042
  return grant.token;
2043
2043
  } catch (error) {
2044
2044
  push({ kind: "error", error });
@@ -4457,11 +4457,6 @@ function enforceSdkCompatibilityResponse(response) {
4457
4457
  }
4458
4458
  }
4459
4459
 
4460
- // src/cli/commands/auth.ts
4461
- var import_node_fs5 = require("fs");
4462
- var import_node_os6 = require("os");
4463
- var import_node_path5 = require("path");
4464
-
4465
4460
  // src/cli/utils.ts
4466
4461
  var import_node_crypto = require("crypto");
4467
4462
  var import_node_fs4 = require("fs");
@@ -5137,7 +5132,133 @@ function printCommandEnvelope(envelope, options = {}) {
5137
5132
  process.stdout.write(options.text ?? renderCommandEnvelopeText(envelope));
5138
5133
  }
5139
5134
 
5135
+ // src/cli/commands/admin.ts
5136
+ function normalizeEnvironment(value) {
5137
+ const trimmed = value?.trim().toLowerCase();
5138
+ if (!trimmed || trimmed === "production" || trimmed === "prod") {
5139
+ return "production";
5140
+ }
5141
+ if (trimmed === "preview") return "preview";
5142
+ throw new Error(
5143
+ `Invalid --environment "${value}". Expected production or preview.`
5144
+ );
5145
+ }
5146
+ function http() {
5147
+ return new HttpClient(resolveConfig());
5148
+ }
5149
+ function laneLine(lane) {
5150
+ const flag = lane.active ? "* " : " ";
5151
+ const depth = lane.queueDepth.empty ? "empty" : `${lane.queueDepth.queuedTasks} tasks / ${lane.queueDepth.nonTerminalRuns} runs`;
5152
+ return `${flag}${lane.releaseId} [${lane.status}] queue=${lane.queue} depth=${depth}`;
5153
+ }
5154
+ async function handleLanesList(options) {
5155
+ const environment = normalizeEnvironment(options.environment);
5156
+ const payload = await http().get(
5157
+ `/api/v2/admin/runtime/lanes?environment=${environment}`
5158
+ );
5159
+ printCommandEnvelope(
5160
+ {
5161
+ ...payload,
5162
+ render: {
5163
+ sections: [
5164
+ {
5165
+ title: `Absurd lanes (${environment}):`,
5166
+ lines: payload.lanes.length > 0 ? payload.lanes.map(laneLine) : ["(no registered lanes)"]
5167
+ }
5168
+ ]
5169
+ }
5170
+ },
5171
+ { json: options.json }
5172
+ );
5173
+ }
5174
+ async function handleLanesShow(releaseId, options) {
5175
+ const environment = normalizeEnvironment(options.environment);
5176
+ const payload = await http().get(
5177
+ `/api/v2/admin/runtime/lanes?environment=${environment}&release=${encodeURIComponent(releaseId)}`
5178
+ );
5179
+ printCommandEnvelope(
5180
+ {
5181
+ ...payload,
5182
+ render: {
5183
+ sections: [
5184
+ {
5185
+ title: `Lane ${releaseId} (${environment}):`,
5186
+ lines: [
5187
+ `registered: ${payload.registered}`,
5188
+ payload.lane ? `status: ${payload.lane.status}${payload.lane.active ? " (active)" : ""}` : "status: (not in registry)",
5189
+ `queue: ${payload.retireCheck.queue}`,
5190
+ `queued tasks: ${payload.retireCheck.queuedTasks}`,
5191
+ `non-terminal runs: ${payload.retireCheck.nonTerminalRuns}`,
5192
+ `retirable: ${payload.retireCheck.retirable}`
5193
+ ]
5194
+ }
5195
+ ]
5196
+ }
5197
+ },
5198
+ { json: options.json }
5199
+ );
5200
+ }
5201
+ async function handleLanesRetireCheck(releaseId, options) {
5202
+ const environment = normalizeEnvironment(options.environment);
5203
+ const payload = await http().get(
5204
+ `/api/v2/admin/runtime/lanes?environment=${environment}&release=${encodeURIComponent(releaseId)}`
5205
+ );
5206
+ printCommandEnvelope(
5207
+ {
5208
+ ...payload,
5209
+ render: {
5210
+ sections: [
5211
+ {
5212
+ title: `Retire check ${releaseId} (${environment}):`,
5213
+ lines: [
5214
+ payload.retireCheck.retirable ? "retirable: yes (lane queue empty)" : `retirable: no (${payload.retireCheck.queuedTasks} tasks, ${payload.retireCheck.nonTerminalRuns} runs pending)`
5215
+ ]
5216
+ }
5217
+ ]
5218
+ }
5219
+ },
5220
+ { json: options.json }
5221
+ );
5222
+ }
5223
+ async function handleReleasesActivate(releaseId, options) {
5224
+ const environment = normalizeEnvironment(options.environment);
5225
+ const payload = await http().post(
5226
+ "/api/v2/admin/runtime/releases",
5227
+ {
5228
+ releaseId,
5229
+ environment,
5230
+ ...options.schedulerBackend ? { schedulerBackend: options.schedulerBackend } : {}
5231
+ }
5232
+ );
5233
+ printCommandEnvelope(
5234
+ {
5235
+ ...payload,
5236
+ render: {
5237
+ sections: [
5238
+ {
5239
+ title: `Activated release ${releaseId} (${environment}).`,
5240
+ lines: ["Runtime release pointer flipped to this lane."]
5241
+ }
5242
+ ]
5243
+ }
5244
+ },
5245
+ { json: options.json }
5246
+ );
5247
+ }
5248
+ function registerAdminCommands(program) {
5249
+ const admin = program.command("admin").description("Platform-admin operations (runtime lanes, releases).");
5250
+ const lanes = admin.command("lanes").description("Inspect Absurd runtime release lanes.");
5251
+ lanes.command("list").description("List all registered Absurd lanes with queue depth.").option("--environment <env>", "production (default) or preview").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleLanesList);
5252
+ lanes.command("show <releaseId>").description("Show one lane and its retire-gate depth.").option("--environment <env>", "production (default) or preview").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleLanesShow);
5253
+ lanes.command("retire-check <releaseId>").description("Check whether a lane is safe to retire (queue empty).").option("--environment <env>", "production (default) or preview").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleLanesRetireCheck);
5254
+ const releases = admin.command("releases").description("Manage the active runtime release pointer.");
5255
+ releases.command("activate <releaseId>").description("Flip the active runtime release to a prior registered lane.").option("--environment <env>", "production (default) or preview").option("--scheduler-backend <backend>", "absurd or workers_edge").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleReleasesActivate);
5256
+ }
5257
+
5140
5258
  // src/cli/commands/auth.ts
5259
+ var import_node_fs5 = require("fs");
5260
+ var import_node_os6 = require("os");
5261
+ var import_node_path5 = require("path");
5141
5262
  var EXIT_OK = 0;
5142
5263
  var EXIT_AUTH = 3;
5143
5264
  var EXIT_SERVER = 5;
@@ -6000,8 +6121,8 @@ function defaultLedgerExportPath() {
6000
6121
  );
6001
6122
  }
6002
6123
  async function handleBalance(options) {
6003
- const { http } = getAuthedHttpClient();
6004
- const payload = await http.get(
6124
+ const { http: http2 } = getAuthedHttpClient();
6125
+ const payload = await http2.get(
6005
6126
  "/api/v2/billing/balance"
6006
6127
  );
6007
6128
  const status = String(payload.balance_status || "");
@@ -6035,13 +6156,13 @@ async function handleBalance(options) {
6035
6156
  return;
6036
6157
  }
6037
6158
  async function handleUsage(options) {
6038
- const { http } = getAuthedHttpClient();
6159
+ const { http: http2 } = getAuthedHttpClient();
6039
6160
  const params = new URLSearchParams();
6040
6161
  if (options.limit) params.set("recent_limit", options.limit);
6041
6162
  if (options.offset) params.set("recent_offset", options.offset);
6042
6163
  if (options.runId) params.set("run_id", options.runId);
6043
6164
  const suffix = Array.from(params).length > 0 ? `?${params.toString()}` : "";
6044
- const payload = await http.get(
6165
+ const payload = await http2.get(
6045
6166
  `/api/v2/billing/usage${suffix}`
6046
6167
  );
6047
6168
  const usage = payload.usage ?? {};
@@ -6067,8 +6188,8 @@ async function handleUsage(options) {
6067
6188
  );
6068
6189
  }
6069
6190
  async function handleLimit(options) {
6070
- const { http } = getAuthedHttpClient();
6071
- const payload = await http.get(
6191
+ const { http: http2 } = getAuthedHttpClient();
6192
+ const payload = await http2.get(
6072
6193
  "/api/v2/billing/limit"
6073
6194
  );
6074
6195
  const lines = payload.enabled ? [
@@ -6084,8 +6205,8 @@ async function handleLimit(options) {
6084
6205
  );
6085
6206
  }
6086
6207
  async function handleSetLimit(credits, options) {
6087
- const { http } = getAuthedHttpClient();
6088
- const payload = await http.request("/api/v2/billing/limit", {
6208
+ const { http: http2 } = getAuthedHttpClient();
6209
+ const payload = await http2.request("/api/v2/billing/limit", {
6089
6210
  method: "PUT",
6090
6211
  body: { monthly_credits_limit: Number.parseInt(credits, 10) }
6091
6212
  });
@@ -6105,8 +6226,8 @@ async function handleSetLimit(credits, options) {
6105
6226
  );
6106
6227
  }
6107
6228
  async function handleLimitOff(options) {
6108
- const { http } = getAuthedHttpClient();
6109
- const payload = await http.request("/api/v2/billing/limit", {
6229
+ const { http: http2 } = getAuthedHttpClient();
6230
+ const payload = await http2.request("/api/v2/billing/limit", {
6110
6231
  method: "DELETE"
6111
6232
  });
6112
6233
  printCommandEnvelope(
@@ -6125,7 +6246,7 @@ async function handleLimitOff(options) {
6125
6246
  );
6126
6247
  }
6127
6248
  async function handleHistory(options) {
6128
- const { http } = getAuthedHttpClient();
6249
+ const { http: http2 } = getAuthedHttpClient();
6129
6250
  const windows = {
6130
6251
  "1d": 86400,
6131
6252
  "1w": 604800,
@@ -6133,7 +6254,7 @@ async function handleHistory(options) {
6133
6254
  "1y": 31536e3
6134
6255
  };
6135
6256
  const sinceAt = Math.max(0, Math.floor(Date.now() / 1e3) - windows[options.time]) * 1e3;
6136
- const payload = await http.get(
6257
+ const payload = await http2.get(
6137
6258
  `/api/v2/billing/ledger?since_at=${sinceAt}&limit=5000`
6138
6259
  );
6139
6260
  const entries = Array.isArray(payload.entries) ? payload.entries : [];
@@ -6164,7 +6285,7 @@ async function handleHistory(options) {
6164
6285
  );
6165
6286
  }
6166
6287
  async function handleLedgerExportAll(options) {
6167
- const { http } = getAuthedHttpClient();
6288
+ const { http: http2 } = getAuthedHttpClient();
6168
6289
  const outputPath = options.output ? (0, import_node_path6.resolve)(String(options.output)) : defaultLedgerExportPath();
6169
6290
  let summary = { row_count: 0, net_delta_credits: 0 };
6170
6291
  let cursor = null;
@@ -6173,7 +6294,7 @@ async function handleLedgerExportAll(options) {
6173
6294
  const params = new URLSearchParams({ limit: "5000" });
6174
6295
  if (cursor !== null) params.set("cursor", cursor);
6175
6296
  if (options.runId) params.set("run_id", options.runId);
6176
- const payload = await http.get(
6297
+ const payload = await http2.get(
6177
6298
  `/api/v2/billing/ledger?${params.toString()}`
6178
6299
  );
6179
6300
  const entries = Array.isArray(payload.entries) ? payload.entries : [];
@@ -6233,8 +6354,8 @@ function planRolloverText(rollover) {
6233
6354
  return `rollover ${mode}`;
6234
6355
  }
6235
6356
  async function handlePlans(options) {
6236
- const { http } = getAuthedHttpClient();
6237
- const payload = await http.get(
6357
+ const { http: http2 } = getAuthedHttpClient();
6358
+ const payload = await http2.get(
6238
6359
  "/api/v2/billing/catalog/current"
6239
6360
  );
6240
6361
  const activePlan = payload.active_plan ?? {};
@@ -6266,8 +6387,8 @@ async function handlePlans(options) {
6266
6387
  );
6267
6388
  }
6268
6389
  async function handleSubscribe(planVersionId, options) {
6269
- const { http } = getAuthedHttpClient();
6270
- const payload = await http.request(
6390
+ const { http: http2 } = getAuthedHttpClient();
6391
+ const payload = await http2.request(
6271
6392
  "/api/v2/billing/subscription/checkout",
6272
6393
  {
6273
6394
  method: "POST",
@@ -6486,8 +6607,8 @@ async function handleInvoices(options) {
6486
6607
  );
6487
6608
  }
6488
6609
  async function handleCheckout(options) {
6489
- const { http } = getAuthedHttpClient();
6490
- const payload = await http.post(
6610
+ const { http: http2 } = getAuthedHttpClient();
6611
+ const payload = await http2.post(
6491
6612
  "/api/v2/billing/checkout",
6492
6613
  {
6493
6614
  ...options.tier ? { tierId: options.tier } : {},
@@ -6606,8 +6727,8 @@ async function handleTopUp(creditsRaw, options) {
6606
6727
  });
6607
6728
  }
6608
6729
  async function handleRedeemCode(code, options) {
6609
- const { http } = getAuthedHttpClient();
6610
- const payload = await http.post(
6730
+ const { http: http2 } = getAuthedHttpClient();
6731
+ const payload = await http2.post(
6611
6732
  "/api/v2/billing/checkout",
6612
6733
  {
6613
6734
  discountCode: code
@@ -18194,6 +18315,8 @@ var ENRICH_CELL_META_PATCH_FIELD = "__deeplineCellMetaPatch";
18194
18315
  var EXIT_SERVER2 = 5;
18195
18316
  var ENRICH_DEBUG_T0 = Date.now();
18196
18317
  var GENERATED_ENRICH_ROWS_TABLE_NAMESPACE = "deepline_enrich_rows";
18318
+ var SDK_ENRICH_TELEMETRY_TIMEOUT_MS = 1e4;
18319
+ var SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH = 2e4;
18197
18320
  var HEAVY_ENRICH_AUTO_BATCH_PLAYS = /* @__PURE__ */ new Set([
18198
18321
  "company-to-contact",
18199
18322
  "company-to-contact-by-role-waterfall",
@@ -18471,6 +18594,100 @@ function currentEnrichArgs() {
18471
18594
  const index = process.argv.findIndex((arg) => arg === "enrich");
18472
18595
  return index >= 0 ? process.argv.slice(index + 1) : [];
18473
18596
  }
18597
+ function shouldSuppressSdkEnrichTelemetry() {
18598
+ return ["1", "true", "yes", "on"].includes(
18599
+ String(process.env.DEEPLINE_SUPPRESS_ACTIVITY_EVENTS ?? "").trim().toLowerCase()
18600
+ );
18601
+ }
18602
+ function shellQuoteArg(value) {
18603
+ if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {
18604
+ return value;
18605
+ }
18606
+ return `'${value.replace(/'/g, "'\\''")}'`;
18607
+ }
18608
+ function sdkEnrichCommandText(args) {
18609
+ const command = ["deepline", "enrich", ...args].map(shellQuoteArg).join(" ");
18610
+ if (command.length <= SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH) {
18611
+ return command;
18612
+ }
18613
+ return `${command.slice(0, SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH - 3)}...`;
18614
+ }
18615
+ function countConfiguredEnrichColumns(config) {
18616
+ const count = (commands) => commands.reduce((total, command) => {
18617
+ if ("with_waterfall" in command) {
18618
+ return total + count(command.commands);
18619
+ }
18620
+ return total + (command.disabled ? 0 : 1);
18621
+ }, 0);
18622
+ return count(config.commands ?? []);
18623
+ }
18624
+ function createSdkEnrichTelemetryContext(input2) {
18625
+ if (shouldSuppressSdkEnrichTelemetry()) {
18626
+ return null;
18627
+ }
18628
+ const baseUrl = input2.client.baseUrl.replace(/\/$/, "");
18629
+ let apiKey = null;
18630
+ try {
18631
+ apiKey = resolveApiKeyForBaseUrl(baseUrl);
18632
+ } catch {
18633
+ apiKey = null;
18634
+ }
18635
+ return {
18636
+ baseUrl,
18637
+ apiKey,
18638
+ runId: `sdk-enrich-${process.pid}-${Date.now()}`,
18639
+ command: sdkEnrichCommandText(input2.args),
18640
+ rowsRange: input2.rowsRange,
18641
+ inputPath: (0, import_node_path12.basename)(input2.inputCsv),
18642
+ startedAtMs: Date.now(),
18643
+ rowsTargeted: input2.selectedRange.count,
18644
+ columnsTargeted: countConfiguredEnrichColumns(input2.config)
18645
+ };
18646
+ }
18647
+ async function emitSdkEnrichTelemetry(context, event, summary) {
18648
+ if (!context?.apiKey) {
18649
+ return;
18650
+ }
18651
+ const controller = new AbortController();
18652
+ const timeout = setTimeout(
18653
+ () => controller.abort(),
18654
+ SDK_ENRICH_TELEMETRY_TIMEOUT_MS
18655
+ );
18656
+ try {
18657
+ const body = {
18658
+ event,
18659
+ source: "cli_enrich",
18660
+ run_id: context.runId,
18661
+ command: context.command,
18662
+ input_path: context.inputPath,
18663
+ ...context.rowsRange ? { rows_range: context.rowsRange } : {},
18664
+ ...summary ? { summary } : {}
18665
+ };
18666
+ await fetch(new URL("/api/v2/telemetry/activity", context.baseUrl), {
18667
+ method: "POST",
18668
+ headers: {
18669
+ Authorization: `Bearer ${context.apiKey}`,
18670
+ "Content-Type": "application/json"
18671
+ },
18672
+ body: JSON.stringify(body),
18673
+ signal: controller.signal
18674
+ });
18675
+ } catch {
18676
+ } finally {
18677
+ clearTimeout(timeout);
18678
+ }
18679
+ }
18680
+ async function completeSdkEnrichTelemetry(context, input2) {
18681
+ await emitSdkEnrichTelemetry(context, "enrich_completed", {
18682
+ status: input2.status,
18683
+ rows_targeted: context?.rowsTargeted ?? 0,
18684
+ columns_targeted: context?.columnsTargeted ?? 0,
18685
+ failed_jobs: Math.max(0, Math.trunc(input2.failedJobs ?? 0)),
18686
+ skipped_cells: Math.max(0, Math.trunc(input2.skippedCells ?? 0)),
18687
+ duration_ms: Math.max(0, Date.now() - (context?.startedAtMs ?? Date.now())),
18688
+ rate_limits: null
18689
+ });
18690
+ }
18474
18691
  async function buildPlanArgs(args) {
18475
18692
  const passthrough = /* @__PURE__ */ new Set([
18476
18693
  "--with",
@@ -21633,7 +21850,25 @@ function registerEnrichCommand(program) {
21633
21850
  inlineRunJavascript: true,
21634
21851
  failFast: options.failFast
21635
21852
  });
21853
+ const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
21854
+ const sdkEnrichTelemetry = createSdkEnrichTelemetryContext({
21855
+ client: client2,
21856
+ args,
21857
+ inputCsv,
21858
+ rowsRange: options.rows ?? (options.all ? "all" : null),
21859
+ selectedRange,
21860
+ config
21861
+ });
21862
+ let sdkEnrichTelemetryCompleted = false;
21863
+ const completeTelemetry = async (input2) => {
21864
+ if (sdkEnrichTelemetryCompleted) {
21865
+ return;
21866
+ }
21867
+ sdkEnrichTelemetryCompleted = true;
21868
+ await completeSdkEnrichTelemetry(sdkEnrichTelemetry, input2);
21869
+ };
21636
21870
  const tempDir = await (0, import_promises3.mkdtemp)((0, import_node_path12.join)((0, import_node_os8.tmpdir)(), "deepline-enrich-play-"));
21871
+ await emitSdkEnrichTelemetry(sdkEnrichTelemetry, "enrich_started");
21637
21872
  const tempPlay = (0, import_node_path12.join)(tempDir, "deepline-enrich.play.ts");
21638
21873
  let inPlaceTempDir = null;
21639
21874
  let inPlaceTempOutputPath = null;
@@ -21732,7 +21967,6 @@ function registerEnrichCommand(program) {
21732
21967
  });
21733
21968
  return { captured: captured2, status: status2, exportResult: exportResult2 };
21734
21969
  };
21735
- const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
21736
21970
  const autoBatchRows = enrichAutoBatchRowsForConfig(config);
21737
21971
  if (outputPath && selectedRange.count > autoBatchRows) {
21738
21972
  const chunkCount = Math.ceil(selectedRange.count / autoBatchRows);
@@ -21913,6 +22147,10 @@ function registerEnrichCommand(program) {
21913
22147
  });
21914
22148
  }
21915
22149
  process.exitCode = failureReport3 ? EXIT_SERVER2 : chunk.captured.result;
22150
+ await completeTelemetry({
22151
+ status: "failed",
22152
+ failedJobs: failureReport3?.jobs.length ?? 1
22153
+ });
21916
22154
  return;
21917
22155
  }
21918
22156
  if (chunk.exportResult) {
@@ -21991,6 +22229,10 @@ function registerEnrichCommand(program) {
21991
22229
  if (failureReport2) {
21992
22230
  process.exitCode = EXIT_SERVER2;
21993
22231
  }
22232
+ await completeTelemetry({
22233
+ status: failureReport2 ? "completed_with_failures" : "completed",
22234
+ failedJobs: failureReport2?.jobs.length ?? 0
22235
+ });
21994
22236
  return;
21995
22237
  }
21996
22238
  const { captured, status, exportResult } = await runOne({
@@ -22033,6 +22275,10 @@ function registerEnrichCommand(program) {
22033
22275
  });
22034
22276
  }
22035
22277
  process.exitCode = failureReport2 ? EXIT_SERVER2 : captured.result;
22278
+ await completeTelemetry({
22279
+ status: "failed",
22280
+ failedJobs: failureReport2?.jobs.length ?? 1
22281
+ });
22036
22282
  return;
22037
22283
  }
22038
22284
  if (options.json) {
@@ -22069,6 +22315,10 @@ function registerEnrichCommand(program) {
22069
22315
  if (failureReport2) {
22070
22316
  process.exitCode = EXIT_SERVER2;
22071
22317
  }
22318
+ await completeTelemetry({
22319
+ status: failureReport2 ? "completed_with_failures" : "completed",
22320
+ failedJobs: failureReport2?.jobs.length ?? 0
22321
+ });
22072
22322
  return;
22073
22323
  }
22074
22324
  const failureReport = await maybeEmitEnrichFailureReport({
@@ -22099,6 +22349,13 @@ function registerEnrichCommand(program) {
22099
22349
  if (failureReport) {
22100
22350
  process.exitCode = EXIT_SERVER2;
22101
22351
  }
22352
+ await completeTelemetry({
22353
+ status: failureReport ? "completed_with_failures" : "completed",
22354
+ failedJobs: failureReport?.jobs.length ?? 0
22355
+ });
22356
+ } catch (error) {
22357
+ await completeTelemetry({ status: "failed", failedJobs: 1 });
22358
+ throw error;
22102
22359
  } finally {
22103
22360
  if (inPlaceTempDir) {
22104
22361
  await (0, import_promises3.rm)(inPlaceTempDir, { recursive: true, force: true });
@@ -22112,8 +22369,8 @@ function registerEnrichCommand(program) {
22112
22369
 
22113
22370
  // src/cli/commands/feedback.ts
22114
22371
  async function handleFeedback(text, options) {
22115
- const { http } = getAuthedHttpClient();
22116
- const response = await http.post("/api/v2/cli/feedback", {
22372
+ const { http: http2 } = getAuthedHttpClient();
22373
+ const response = await http2.post("/api/v2/cli/feedback", {
22117
22374
  text,
22118
22375
  environment: collectLocalEnvInfo(),
22119
22376
  ...options.command ? { command: options.command } : {},
@@ -22517,8 +22774,8 @@ function buildSessionUploadContent(raw) {
22517
22774
  return { encodedContent: encoded, needsChunking: true };
22518
22775
  }
22519
22776
  async function uploadPayload(path, payload) {
22520
- const { http } = getAuthedHttpClient();
22521
- return await http.post(path, payload);
22777
+ const { http: http2 } = getAuthedHttpClient();
22778
+ return await http2.post(path, payload);
22522
22779
  }
22523
22780
  async function uploadChunkedSessions(sessions, options) {
22524
22781
  const uploadId = (0, import_node_crypto5.randomUUID)();
@@ -23278,8 +23535,8 @@ Preview the plan first with:
23278
23535
  );
23279
23536
  }
23280
23537
  async function handleMonitorsStatus(options) {
23281
- const http = buildHttpClient();
23282
- const payload = await http.request(
23538
+ const http2 = buildHttpClient();
23539
+ const payload = await http2.request(
23283
23540
  "/api/v2/monitors/access",
23284
23541
  { method: "GET" }
23285
23542
  );
@@ -23334,7 +23591,7 @@ async function handleMonitorsAvailable(toolId, options) {
23334
23591
  }
23335
23592
  }
23336
23593
  const tool = toolId ?? options.tool;
23337
- const http = buildHttpClient();
23594
+ const http2 = buildHttpClient();
23338
23595
  const params = new URLSearchParams();
23339
23596
  if (options.provider) params.set("provider", options.provider);
23340
23597
  if (tool) params.set("tool", tool);
@@ -23343,7 +23600,7 @@ async function handleMonitorsAvailable(toolId, options) {
23343
23600
  const compactList = !tool && !options.full;
23344
23601
  if (compactList || options.compact) params.set("compact", "true");
23345
23602
  const query = params.toString();
23346
- const payload = await http.request(
23603
+ const payload = await http2.request(
23347
23604
  `/api/v2/monitors/tools${query ? `?${query}` : ""}`,
23348
23605
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
23349
23606
  );
@@ -23383,13 +23640,13 @@ function renderDeployedListText(payload, requestedStatus) {
23383
23640
  `;
23384
23641
  }
23385
23642
  async function handleMonitorsList(options) {
23386
- const http = buildHttpClient();
23643
+ const http2 = buildHttpClient();
23387
23644
  const params = new URLSearchParams();
23388
23645
  if (options.status) params.set("status", options.status);
23389
23646
  if (options.limit) params.set("limit", options.limit);
23390
23647
  if (options.compact) params.set("compact", "true");
23391
23648
  const query = params.toString();
23392
- const payload = await http.request(
23649
+ const payload = await http2.request(
23393
23650
  `/api/v2/monitors/deployed${query ? `?${query}` : ""}`,
23394
23651
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
23395
23652
  );
@@ -23399,21 +23656,21 @@ async function handleMonitorsList(options) {
23399
23656
  });
23400
23657
  }
23401
23658
  async function handleMonitorsCheck(definition, options) {
23402
- const http = buildHttpClient();
23659
+ const http2 = buildHttpClient();
23403
23660
  const body = resolveMonitorJsonBody({
23404
23661
  positional: definition,
23405
23662
  file: options.file,
23406
23663
  argLabel: "<definition>",
23407
23664
  command: "deepline monitors check"
23408
23665
  });
23409
- const payload = await http.request(
23666
+ const payload = await http2.request(
23410
23667
  "/api/v2/monitors/check",
23411
23668
  { method: "POST", body, ...FORBIDDEN_AS_API_ERROR }
23412
23669
  );
23413
23670
  printCommandEnvelope(payload, { json: options.json });
23414
23671
  }
23415
23672
  async function handleMonitorsDeploy(definition, options) {
23416
- const http = buildHttpClient();
23673
+ const http2 = buildHttpClient();
23417
23674
  const body = resolveMonitorJsonBody({
23418
23675
  positional: definition,
23419
23676
  file: options.file,
@@ -23421,7 +23678,7 @@ async function handleMonitorsDeploy(definition, options) {
23421
23678
  command: "deepline monitors deploy"
23422
23679
  });
23423
23680
  if (options.dryRun) {
23424
- const payload2 = await http.request(
23681
+ const payload2 = await http2.request(
23425
23682
  "/api/v2/monitors/check",
23426
23683
  { method: "POST", body, ...FORBIDDEN_AS_API_ERROR }
23427
23684
  );
@@ -23435,7 +23692,7 @@ async function handleMonitorsDeploy(definition, options) {
23435
23692
  }
23436
23693
  return;
23437
23694
  }
23438
- const payload = await http.request(
23695
+ const payload = await http2.request(
23439
23696
  "/api/v2/monitors/deploy",
23440
23697
  { method: "POST", body, ...FORBIDDEN_AS_API_ERROR }
23441
23698
  );
@@ -23445,8 +23702,8 @@ async function handleMonitorsDeploy(definition, options) {
23445
23702
  });
23446
23703
  }
23447
23704
  async function handleMonitorsGet(key, options) {
23448
- const http = buildHttpClient();
23449
- const payload = await http.request(
23705
+ const http2 = buildHttpClient();
23706
+ const payload = await http2.request(
23450
23707
  `/api/v2/monitors/deployed/${encodeKey(key)}`,
23451
23708
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
23452
23709
  );
@@ -23468,12 +23725,12 @@ async function confirmMonitorDelete(key, options) {
23468
23725
  }
23469
23726
  }
23470
23727
  async function handleMonitorsDelete(key, options) {
23471
- const http = buildHttpClient();
23728
+ const http2 = buildHttpClient();
23472
23729
  const params = new URLSearchParams();
23473
23730
  if (options.localOnly) params.set("local_only", "true");
23474
23731
  if (options.dryRun) {
23475
23732
  params.set("dry_run", "true");
23476
- const payload2 = await http.request(
23733
+ const payload2 = await http2.request(
23477
23734
  `/api/v2/monitors/deployed/${encodeKey(key)}?${params.toString()}`,
23478
23735
  { method: "DELETE", ...FORBIDDEN_AS_API_ERROR }
23479
23736
  );
@@ -23505,30 +23762,30 @@ async function handleMonitorsDelete(key, options) {
23505
23762
  }
23506
23763
  }
23507
23764
  const query = params.toString();
23508
- const payload = await http.request(
23765
+ const payload = await http2.request(
23509
23766
  `/api/v2/monitors/deployed/${encodeKey(key)}${query ? `?${query}` : ""}`,
23510
23767
  { method: "DELETE", ...FORBIDDEN_AS_API_ERROR }
23511
23768
  );
23512
23769
  printCommandEnvelope(payload, { json: options.json });
23513
23770
  }
23514
23771
  async function handleMonitorsUpdate(key, patch, options) {
23515
- const http = buildHttpClient();
23772
+ const http2 = buildHttpClient();
23516
23773
  const body = resolveMonitorJsonBody({
23517
23774
  positional: patch,
23518
23775
  file: options.file,
23519
23776
  argLabel: "<patch>",
23520
23777
  command: `deepline monitors update ${key}`
23521
23778
  });
23522
- const payload = await http.request(
23779
+ const payload = await http2.request(
23523
23780
  `/api/v2/monitors/deployed/${encodeKey(key)}`,
23524
23781
  { method: "PATCH", body, ...FORBIDDEN_AS_API_ERROR }
23525
23782
  );
23526
23783
  printCommandEnvelope(payload, { json: options.json });
23527
23784
  }
23528
23785
  async function handleMonitorsReactivate(key, options) {
23529
- const http = buildHttpClient();
23786
+ const http2 = buildHttpClient();
23530
23787
  if (options.dryRun) {
23531
- const payload2 = await http.request(
23788
+ const payload2 = await http2.request(
23532
23789
  `/api/v2/monitors/deployed/${encodeKey(key)}/reactivate?dry_run=true`,
23533
23790
  { method: "POST", body: {}, ...FORBIDDEN_AS_API_ERROR }
23534
23791
  );
@@ -23542,7 +23799,7 @@ async function handleMonitorsReactivate(key, options) {
23542
23799
  });
23543
23800
  return;
23544
23801
  }
23545
- const payload = await http.request(
23802
+ const payload = await http2.request(
23546
23803
  `/api/v2/monitors/deployed/${encodeKey(key)}/reactivate`,
23547
23804
  { method: "POST", body: {}, ...FORBIDDEN_AS_API_ERROR }
23548
23805
  );
@@ -23786,8 +24043,8 @@ Examples:
23786
24043
  }
23787
24044
 
23788
24045
  // src/cli/commands/org.ts
23789
- async function fetchOrganizations(http, apiKey) {
23790
- return http.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
24046
+ async function fetchOrganizations(http2, apiKey) {
24047
+ return http2.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
23791
24048
  }
23792
24049
  function normalizeAuthScope(value) {
23793
24050
  if (!value) return "auto";
@@ -23891,8 +24148,8 @@ function resolveOrgSwitchAuthTarget(scope, config) {
23891
24148
  }
23892
24149
  async function handleOrgList(options) {
23893
24150
  const config = resolveConfig();
23894
- const http = new HttpClient(config);
23895
- const payload = await fetchOrganizations(http, config.apiKey);
24151
+ const http2 = new HttpClient(config);
24152
+ const payload = await fetchOrganizations(http2, config.apiKey);
23896
24153
  printCommandEnvelope(
23897
24154
  {
23898
24155
  ...payload,
@@ -23910,8 +24167,8 @@ async function handleOrgList(options) {
23910
24167
  }
23911
24168
  async function handleOrgStatus(options) {
23912
24169
  const config = resolveConfig();
23913
- const http = new HttpClient(config);
23914
- const payload = await fetchOrganizations(http, config.apiKey);
24170
+ const http2 = new HttpClient(config);
24171
+ const payload = await fetchOrganizations(http2, config.apiKey);
23915
24172
  const current = payload.organizations.find((org) => org.is_current) ?? payload.organizations.find(
23916
24173
  (org) => org.org_id === payload.current_org_id
23917
24174
  ) ?? null;
@@ -23994,8 +24251,8 @@ async function handleOrgStatus(options) {
23994
24251
  async function handleOrgSwitch(selection, options) {
23995
24252
  const authScope = normalizeAuthScope(options.authScope);
23996
24253
  const config = resolveConfig();
23997
- const http = new HttpClient(config);
23998
- const payload = await fetchOrganizations(http, config.apiKey);
24254
+ const http2 = new HttpClient(config);
24255
+ const payload = await fetchOrganizations(http2, config.apiKey);
23999
24256
  if (!selection && !options.orgId) {
24000
24257
  printCommandEnvelope(
24001
24258
  {
@@ -24090,7 +24347,7 @@ async function handleOrgSwitch(selection, options) {
24090
24347
  );
24091
24348
  return;
24092
24349
  }
24093
- const switched = await http.post("/api/v2/auth/cli/switch", {
24350
+ const switched = await http2.post("/api/v2/auth/cli/switch", {
24094
24351
  api_key: config.apiKey,
24095
24352
  org_id: target.org_id
24096
24353
  });
@@ -24158,8 +24415,8 @@ async function handleOrgSwitch(selection, options) {
24158
24415
  }
24159
24416
  async function handleOrgCreate(name, options) {
24160
24417
  const config = resolveConfig();
24161
- const http = new HttpClient(config);
24162
- const created = await http.post("/api/v2/auth/cli/org-create", {
24418
+ const http2 = new HttpClient(config);
24419
+ const created = await http2.post("/api/v2/auth/cli/org-create", {
24163
24420
  api_key: config.apiKey,
24164
24421
  name
24165
24422
  });
@@ -24751,8 +25008,8 @@ async function handleSet(nameInput, forbidden, options) {
24751
25008
  throw new Error("--play <name> is required when --scope play is used.");
24752
25009
  }
24753
25010
  const value = await readSecretValue();
24754
- const { http } = getAuthedHttpClient();
24755
- const response = await http.post(
25011
+ const { http: http2 } = getAuthedHttpClient();
25012
+ const response = await http2.post(
24756
25013
  "/api/v2/secrets",
24757
25014
  {
24758
25015
  name,
@@ -28878,7 +29135,7 @@ async function runPreflightCheck() {
28878
29135
  };
28879
29136
  }).catch(() => ({ status: "unreachable", version: null })).finally(() => clearTimeout(healthTimeout));
28880
29137
  const apiKey = resolveApiKeyForBaseUrl(baseUrl);
28881
- const http = apiKey ? new HttpClient(
29138
+ const http2 = apiKey ? new HttpClient(
28882
29139
  resolveConfig({
28883
29140
  baseUrl,
28884
29141
  apiKey,
@@ -28886,8 +29143,8 @@ async function runPreflightCheck() {
28886
29143
  maxRetries: 0
28887
29144
  })
28888
29145
  ) : null;
28889
- const [auth, billing] = http ? await Promise.all([
28890
- http.post("/api/v2/auth/cli/status", {
29146
+ const [auth, billing] = http2 ? await Promise.all([
29147
+ http2.post("/api/v2/auth/cli/status", {
28891
29148
  api_key: apiKey,
28892
29149
  reveal: false
28893
29150
  }).catch((error) => ({
@@ -28895,7 +29152,7 @@ async function runPreflightCheck() {
28895
29152
  connected: false,
28896
29153
  error: preflightErrorMessage(error)
28897
29154
  })),
28898
- http.get("/api/v2/billing/balance").catch((error) => ({
29155
+ http2.get("/api/v2/billing/balance").catch((error) => ({
28899
29156
  balance: null,
28900
29157
  balance_display: "unavailable",
28901
29158
  balance_status: "unknown",
@@ -29078,6 +29335,7 @@ Exit codes:
29078
29335
  registerBillingCommands(program);
29079
29336
  registerMonitorsCommands(program);
29080
29337
  registerOrgCommands(program);
29338
+ registerAdminCommands(program);
29081
29339
  registerEnrichCommand(program);
29082
29340
  registerCsvCommands(program);
29083
29341
  registerDbCommands(program);