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
@@ -608,10 +608,10 @@ var SDK_RELEASE = {
608
608
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
609
609
  // fields shipped in 0.1.153.
610
610
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
611
- version: "0.1.201",
611
+ version: "0.1.203",
612
612
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
613
613
  supportPolicy: {
614
- latest: "0.1.201",
614
+ latest: "0.1.203",
615
615
  minimumSupported: "0.1.53",
616
616
  deprecatedBelow: "0.1.53",
617
617
  commandMinimumSupported: [
@@ -1892,10 +1892,10 @@ var OBSERVER_LOG_PAGE_QUERY = "runObservers:getRunLogPageForObserver";
1892
1892
  function errorText(error) {
1893
1893
  return error instanceof Error ? error.message : String(error);
1894
1894
  }
1895
- async function mintRunObserveGrant(http, runId) {
1895
+ async function mintRunObserveGrant(http2, runId) {
1896
1896
  let response;
1897
1897
  try {
1898
- response = await http.post(
1898
+ response = await http2.post(
1899
1899
  `/api/v2/runs/${encodeURIComponent(runId)}/observe-grant`,
1900
1900
  {}
1901
1901
  );
@@ -1959,8 +1959,8 @@ async function backfillLogGap(input2) {
1959
1959
  return lines;
1960
1960
  }
1961
1961
  async function* observeRunEvents(options) {
1962
- const { http, runId } = options;
1963
- let grant = await mintRunObserveGrant(http, runId);
1962
+ const { http: http2, runId } = options;
1963
+ let grant = await mintRunObserveGrant(http2, runId);
1964
1964
  let convexBrowser;
1965
1965
  let convexServer;
1966
1966
  try {
@@ -2023,7 +2023,7 @@ async function* observeRunEvents(options) {
2023
2023
  lastForcedRefreshAt = now;
2024
2024
  }
2025
2025
  try {
2026
- grant = await mintRunObserveGrant(http, runId);
2026
+ grant = await mintRunObserveGrant(http2, runId);
2027
2027
  return grant.token;
2028
2028
  } catch (error) {
2029
2029
  push({ kind: "error", error });
@@ -4442,17 +4442,6 @@ function enforceSdkCompatibilityResponse(response) {
4442
4442
  }
4443
4443
  }
4444
4444
 
4445
- // src/cli/commands/auth.ts
4446
- import {
4447
- existsSync as existsSync5,
4448
- mkdirSync as mkdirSync4,
4449
- readFileSync as readFileSync5,
4450
- rmSync as rmSync2,
4451
- writeFileSync as writeFileSync4
4452
- } from "fs";
4453
- import { hostname } from "os";
4454
- import { dirname as dirname4 } from "path";
4455
-
4456
4445
  // src/cli/utils.ts
4457
4446
  import { createHash } from "crypto";
4458
4447
  import {
@@ -5134,7 +5123,139 @@ function printCommandEnvelope(envelope, options = {}) {
5134
5123
  process.stdout.write(options.text ?? renderCommandEnvelopeText(envelope));
5135
5124
  }
5136
5125
 
5126
+ // src/cli/commands/admin.ts
5127
+ function normalizeEnvironment(value) {
5128
+ const trimmed = value?.trim().toLowerCase();
5129
+ if (!trimmed || trimmed === "production" || trimmed === "prod") {
5130
+ return "production";
5131
+ }
5132
+ if (trimmed === "preview") return "preview";
5133
+ throw new Error(
5134
+ `Invalid --environment "${value}". Expected production or preview.`
5135
+ );
5136
+ }
5137
+ function http() {
5138
+ return new HttpClient(resolveConfig());
5139
+ }
5140
+ function laneLine(lane) {
5141
+ const flag = lane.active ? "* " : " ";
5142
+ const depth = lane.queueDepth.empty ? "empty" : `${lane.queueDepth.queuedTasks} tasks / ${lane.queueDepth.nonTerminalRuns} runs`;
5143
+ return `${flag}${lane.releaseId} [${lane.status}] queue=${lane.queue} depth=${depth}`;
5144
+ }
5145
+ async function handleLanesList(options) {
5146
+ const environment = normalizeEnvironment(options.environment);
5147
+ const payload = await http().get(
5148
+ `/api/v2/admin/runtime/lanes?environment=${environment}`
5149
+ );
5150
+ printCommandEnvelope(
5151
+ {
5152
+ ...payload,
5153
+ render: {
5154
+ sections: [
5155
+ {
5156
+ title: `Absurd lanes (${environment}):`,
5157
+ lines: payload.lanes.length > 0 ? payload.lanes.map(laneLine) : ["(no registered lanes)"]
5158
+ }
5159
+ ]
5160
+ }
5161
+ },
5162
+ { json: options.json }
5163
+ );
5164
+ }
5165
+ async function handleLanesShow(releaseId, options) {
5166
+ const environment = normalizeEnvironment(options.environment);
5167
+ const payload = await http().get(
5168
+ `/api/v2/admin/runtime/lanes?environment=${environment}&release=${encodeURIComponent(releaseId)}`
5169
+ );
5170
+ printCommandEnvelope(
5171
+ {
5172
+ ...payload,
5173
+ render: {
5174
+ sections: [
5175
+ {
5176
+ title: `Lane ${releaseId} (${environment}):`,
5177
+ lines: [
5178
+ `registered: ${payload.registered}`,
5179
+ payload.lane ? `status: ${payload.lane.status}${payload.lane.active ? " (active)" : ""}` : "status: (not in registry)",
5180
+ `queue: ${payload.retireCheck.queue}`,
5181
+ `queued tasks: ${payload.retireCheck.queuedTasks}`,
5182
+ `non-terminal runs: ${payload.retireCheck.nonTerminalRuns}`,
5183
+ `retirable: ${payload.retireCheck.retirable}`
5184
+ ]
5185
+ }
5186
+ ]
5187
+ }
5188
+ },
5189
+ { json: options.json }
5190
+ );
5191
+ }
5192
+ async function handleLanesRetireCheck(releaseId, options) {
5193
+ const environment = normalizeEnvironment(options.environment);
5194
+ const payload = await http().get(
5195
+ `/api/v2/admin/runtime/lanes?environment=${environment}&release=${encodeURIComponent(releaseId)}`
5196
+ );
5197
+ printCommandEnvelope(
5198
+ {
5199
+ ...payload,
5200
+ render: {
5201
+ sections: [
5202
+ {
5203
+ title: `Retire check ${releaseId} (${environment}):`,
5204
+ lines: [
5205
+ payload.retireCheck.retirable ? "retirable: yes (lane queue empty)" : `retirable: no (${payload.retireCheck.queuedTasks} tasks, ${payload.retireCheck.nonTerminalRuns} runs pending)`
5206
+ ]
5207
+ }
5208
+ ]
5209
+ }
5210
+ },
5211
+ { json: options.json }
5212
+ );
5213
+ }
5214
+ async function handleReleasesActivate(releaseId, options) {
5215
+ const environment = normalizeEnvironment(options.environment);
5216
+ const payload = await http().post(
5217
+ "/api/v2/admin/runtime/releases",
5218
+ {
5219
+ releaseId,
5220
+ environment,
5221
+ ...options.schedulerBackend ? { schedulerBackend: options.schedulerBackend } : {}
5222
+ }
5223
+ );
5224
+ printCommandEnvelope(
5225
+ {
5226
+ ...payload,
5227
+ render: {
5228
+ sections: [
5229
+ {
5230
+ title: `Activated release ${releaseId} (${environment}).`,
5231
+ lines: ["Runtime release pointer flipped to this lane."]
5232
+ }
5233
+ ]
5234
+ }
5235
+ },
5236
+ { json: options.json }
5237
+ );
5238
+ }
5239
+ function registerAdminCommands(program) {
5240
+ const admin = program.command("admin").description("Platform-admin operations (runtime lanes, releases).");
5241
+ const lanes = admin.command("lanes").description("Inspect Absurd runtime release lanes.");
5242
+ 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);
5243
+ 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);
5244
+ 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);
5245
+ const releases = admin.command("releases").description("Manage the active runtime release pointer.");
5246
+ 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);
5247
+ }
5248
+
5137
5249
  // src/cli/commands/auth.ts
5250
+ import {
5251
+ existsSync as existsSync5,
5252
+ mkdirSync as mkdirSync4,
5253
+ readFileSync as readFileSync5,
5254
+ rmSync as rmSync2,
5255
+ writeFileSync as writeFileSync4
5256
+ } from "fs";
5257
+ import { hostname } from "os";
5258
+ import { dirname as dirname4 } from "path";
5138
5259
  var EXIT_OK = 0;
5139
5260
  var EXIT_AUTH = 3;
5140
5261
  var EXIT_SERVER = 5;
@@ -5997,8 +6118,8 @@ function defaultLedgerExportPath() {
5997
6118
  );
5998
6119
  }
5999
6120
  async function handleBalance(options) {
6000
- const { http } = getAuthedHttpClient();
6001
- const payload = await http.get(
6121
+ const { http: http2 } = getAuthedHttpClient();
6122
+ const payload = await http2.get(
6002
6123
  "/api/v2/billing/balance"
6003
6124
  );
6004
6125
  const status = String(payload.balance_status || "");
@@ -6032,13 +6153,13 @@ async function handleBalance(options) {
6032
6153
  return;
6033
6154
  }
6034
6155
  async function handleUsage(options) {
6035
- const { http } = getAuthedHttpClient();
6156
+ const { http: http2 } = getAuthedHttpClient();
6036
6157
  const params = new URLSearchParams();
6037
6158
  if (options.limit) params.set("recent_limit", options.limit);
6038
6159
  if (options.offset) params.set("recent_offset", options.offset);
6039
6160
  if (options.runId) params.set("run_id", options.runId);
6040
6161
  const suffix = Array.from(params).length > 0 ? `?${params.toString()}` : "";
6041
- const payload = await http.get(
6162
+ const payload = await http2.get(
6042
6163
  `/api/v2/billing/usage${suffix}`
6043
6164
  );
6044
6165
  const usage = payload.usage ?? {};
@@ -6064,8 +6185,8 @@ async function handleUsage(options) {
6064
6185
  );
6065
6186
  }
6066
6187
  async function handleLimit(options) {
6067
- const { http } = getAuthedHttpClient();
6068
- const payload = await http.get(
6188
+ const { http: http2 } = getAuthedHttpClient();
6189
+ const payload = await http2.get(
6069
6190
  "/api/v2/billing/limit"
6070
6191
  );
6071
6192
  const lines = payload.enabled ? [
@@ -6081,8 +6202,8 @@ async function handleLimit(options) {
6081
6202
  );
6082
6203
  }
6083
6204
  async function handleSetLimit(credits, options) {
6084
- const { http } = getAuthedHttpClient();
6085
- const payload = await http.request("/api/v2/billing/limit", {
6205
+ const { http: http2 } = getAuthedHttpClient();
6206
+ const payload = await http2.request("/api/v2/billing/limit", {
6086
6207
  method: "PUT",
6087
6208
  body: { monthly_credits_limit: Number.parseInt(credits, 10) }
6088
6209
  });
@@ -6102,8 +6223,8 @@ async function handleSetLimit(credits, options) {
6102
6223
  );
6103
6224
  }
6104
6225
  async function handleLimitOff(options) {
6105
- const { http } = getAuthedHttpClient();
6106
- const payload = await http.request("/api/v2/billing/limit", {
6226
+ const { http: http2 } = getAuthedHttpClient();
6227
+ const payload = await http2.request("/api/v2/billing/limit", {
6107
6228
  method: "DELETE"
6108
6229
  });
6109
6230
  printCommandEnvelope(
@@ -6122,7 +6243,7 @@ async function handleLimitOff(options) {
6122
6243
  );
6123
6244
  }
6124
6245
  async function handleHistory(options) {
6125
- const { http } = getAuthedHttpClient();
6246
+ const { http: http2 } = getAuthedHttpClient();
6126
6247
  const windows = {
6127
6248
  "1d": 86400,
6128
6249
  "1w": 604800,
@@ -6130,7 +6251,7 @@ async function handleHistory(options) {
6130
6251
  "1y": 31536e3
6131
6252
  };
6132
6253
  const sinceAt = Math.max(0, Math.floor(Date.now() / 1e3) - windows[options.time]) * 1e3;
6133
- const payload = await http.get(
6254
+ const payload = await http2.get(
6134
6255
  `/api/v2/billing/ledger?since_at=${sinceAt}&limit=5000`
6135
6256
  );
6136
6257
  const entries = Array.isArray(payload.entries) ? payload.entries : [];
@@ -6161,7 +6282,7 @@ async function handleHistory(options) {
6161
6282
  );
6162
6283
  }
6163
6284
  async function handleLedgerExportAll(options) {
6164
- const { http } = getAuthedHttpClient();
6285
+ const { http: http2 } = getAuthedHttpClient();
6165
6286
  const outputPath = options.output ? resolve3(String(options.output)) : defaultLedgerExportPath();
6166
6287
  let summary = { row_count: 0, net_delta_credits: 0 };
6167
6288
  let cursor = null;
@@ -6170,7 +6291,7 @@ async function handleLedgerExportAll(options) {
6170
6291
  const params = new URLSearchParams({ limit: "5000" });
6171
6292
  if (cursor !== null) params.set("cursor", cursor);
6172
6293
  if (options.runId) params.set("run_id", options.runId);
6173
- const payload = await http.get(
6294
+ const payload = await http2.get(
6174
6295
  `/api/v2/billing/ledger?${params.toString()}`
6175
6296
  );
6176
6297
  const entries = Array.isArray(payload.entries) ? payload.entries : [];
@@ -6230,8 +6351,8 @@ function planRolloverText(rollover) {
6230
6351
  return `rollover ${mode}`;
6231
6352
  }
6232
6353
  async function handlePlans(options) {
6233
- const { http } = getAuthedHttpClient();
6234
- const payload = await http.get(
6354
+ const { http: http2 } = getAuthedHttpClient();
6355
+ const payload = await http2.get(
6235
6356
  "/api/v2/billing/catalog/current"
6236
6357
  );
6237
6358
  const activePlan = payload.active_plan ?? {};
@@ -6263,8 +6384,8 @@ async function handlePlans(options) {
6263
6384
  );
6264
6385
  }
6265
6386
  async function handleSubscribe(planVersionId, options) {
6266
- const { http } = getAuthedHttpClient();
6267
- const payload = await http.request(
6387
+ const { http: http2 } = getAuthedHttpClient();
6388
+ const payload = await http2.request(
6268
6389
  "/api/v2/billing/subscription/checkout",
6269
6390
  {
6270
6391
  method: "POST",
@@ -6483,8 +6604,8 @@ async function handleInvoices(options) {
6483
6604
  );
6484
6605
  }
6485
6606
  async function handleCheckout(options) {
6486
- const { http } = getAuthedHttpClient();
6487
- const payload = await http.post(
6607
+ const { http: http2 } = getAuthedHttpClient();
6608
+ const payload = await http2.post(
6488
6609
  "/api/v2/billing/checkout",
6489
6610
  {
6490
6611
  ...options.tier ? { tierId: options.tier } : {},
@@ -6603,8 +6724,8 @@ async function handleTopUp(creditsRaw, options) {
6603
6724
  });
6604
6725
  }
6605
6726
  async function handleRedeemCode(code, options) {
6606
- const { http } = getAuthedHttpClient();
6607
- const payload = await http.post(
6727
+ const { http: http2 } = getAuthedHttpClient();
6728
+ const payload = await http2.post(
6608
6729
  "/api/v2/billing/checkout",
6609
6730
  {
6610
6731
  discountCode: code
@@ -18223,6 +18344,8 @@ var ENRICH_CELL_META_PATCH_FIELD = "__deeplineCellMetaPatch";
18223
18344
  var EXIT_SERVER2 = 5;
18224
18345
  var ENRICH_DEBUG_T0 = Date.now();
18225
18346
  var GENERATED_ENRICH_ROWS_TABLE_NAMESPACE = "deepline_enrich_rows";
18347
+ var SDK_ENRICH_TELEMETRY_TIMEOUT_MS = 1e4;
18348
+ var SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH = 2e4;
18226
18349
  var HEAVY_ENRICH_AUTO_BATCH_PLAYS = /* @__PURE__ */ new Set([
18227
18350
  "company-to-contact",
18228
18351
  "company-to-contact-by-role-waterfall",
@@ -18500,6 +18623,100 @@ function currentEnrichArgs() {
18500
18623
  const index = process.argv.findIndex((arg) => arg === "enrich");
18501
18624
  return index >= 0 ? process.argv.slice(index + 1) : [];
18502
18625
  }
18626
+ function shouldSuppressSdkEnrichTelemetry() {
18627
+ return ["1", "true", "yes", "on"].includes(
18628
+ String(process.env.DEEPLINE_SUPPRESS_ACTIVITY_EVENTS ?? "").trim().toLowerCase()
18629
+ );
18630
+ }
18631
+ function shellQuoteArg(value) {
18632
+ if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {
18633
+ return value;
18634
+ }
18635
+ return `'${value.replace(/'/g, "'\\''")}'`;
18636
+ }
18637
+ function sdkEnrichCommandText(args) {
18638
+ const command = ["deepline", "enrich", ...args].map(shellQuoteArg).join(" ");
18639
+ if (command.length <= SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH) {
18640
+ return command;
18641
+ }
18642
+ return `${command.slice(0, SDK_ENRICH_TELEMETRY_COMMAND_MAX_LENGTH - 3)}...`;
18643
+ }
18644
+ function countConfiguredEnrichColumns(config) {
18645
+ const count = (commands) => commands.reduce((total, command) => {
18646
+ if ("with_waterfall" in command) {
18647
+ return total + count(command.commands);
18648
+ }
18649
+ return total + (command.disabled ? 0 : 1);
18650
+ }, 0);
18651
+ return count(config.commands ?? []);
18652
+ }
18653
+ function createSdkEnrichTelemetryContext(input2) {
18654
+ if (shouldSuppressSdkEnrichTelemetry()) {
18655
+ return null;
18656
+ }
18657
+ const baseUrl = input2.client.baseUrl.replace(/\/$/, "");
18658
+ let apiKey = null;
18659
+ try {
18660
+ apiKey = resolveApiKeyForBaseUrl(baseUrl);
18661
+ } catch {
18662
+ apiKey = null;
18663
+ }
18664
+ return {
18665
+ baseUrl,
18666
+ apiKey,
18667
+ runId: `sdk-enrich-${process.pid}-${Date.now()}`,
18668
+ command: sdkEnrichCommandText(input2.args),
18669
+ rowsRange: input2.rowsRange,
18670
+ inputPath: basename2(input2.inputCsv),
18671
+ startedAtMs: Date.now(),
18672
+ rowsTargeted: input2.selectedRange.count,
18673
+ columnsTargeted: countConfiguredEnrichColumns(input2.config)
18674
+ };
18675
+ }
18676
+ async function emitSdkEnrichTelemetry(context, event, summary) {
18677
+ if (!context?.apiKey) {
18678
+ return;
18679
+ }
18680
+ const controller = new AbortController();
18681
+ const timeout = setTimeout(
18682
+ () => controller.abort(),
18683
+ SDK_ENRICH_TELEMETRY_TIMEOUT_MS
18684
+ );
18685
+ try {
18686
+ const body = {
18687
+ event,
18688
+ source: "cli_enrich",
18689
+ run_id: context.runId,
18690
+ command: context.command,
18691
+ input_path: context.inputPath,
18692
+ ...context.rowsRange ? { rows_range: context.rowsRange } : {},
18693
+ ...summary ? { summary } : {}
18694
+ };
18695
+ await fetch(new URL("/api/v2/telemetry/activity", context.baseUrl), {
18696
+ method: "POST",
18697
+ headers: {
18698
+ Authorization: `Bearer ${context.apiKey}`,
18699
+ "Content-Type": "application/json"
18700
+ },
18701
+ body: JSON.stringify(body),
18702
+ signal: controller.signal
18703
+ });
18704
+ } catch {
18705
+ } finally {
18706
+ clearTimeout(timeout);
18707
+ }
18708
+ }
18709
+ async function completeSdkEnrichTelemetry(context, input2) {
18710
+ await emitSdkEnrichTelemetry(context, "enrich_completed", {
18711
+ status: input2.status,
18712
+ rows_targeted: context?.rowsTargeted ?? 0,
18713
+ columns_targeted: context?.columnsTargeted ?? 0,
18714
+ failed_jobs: Math.max(0, Math.trunc(input2.failedJobs ?? 0)),
18715
+ skipped_cells: Math.max(0, Math.trunc(input2.skippedCells ?? 0)),
18716
+ duration_ms: Math.max(0, Date.now() - (context?.startedAtMs ?? Date.now())),
18717
+ rate_limits: null
18718
+ });
18719
+ }
18503
18720
  async function buildPlanArgs(args) {
18504
18721
  const passthrough = /* @__PURE__ */ new Set([
18505
18722
  "--with",
@@ -21662,7 +21879,25 @@ function registerEnrichCommand(program) {
21662
21879
  inlineRunJavascript: true,
21663
21880
  failFast: options.failFast
21664
21881
  });
21882
+ const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
21883
+ const sdkEnrichTelemetry = createSdkEnrichTelemetryContext({
21884
+ client: client2,
21885
+ args,
21886
+ inputCsv,
21887
+ rowsRange: options.rows ?? (options.all ? "all" : null),
21888
+ selectedRange,
21889
+ config
21890
+ });
21891
+ let sdkEnrichTelemetryCompleted = false;
21892
+ const completeTelemetry = async (input2) => {
21893
+ if (sdkEnrichTelemetryCompleted) {
21894
+ return;
21895
+ }
21896
+ sdkEnrichTelemetryCompleted = true;
21897
+ await completeSdkEnrichTelemetry(sdkEnrichTelemetry, input2);
21898
+ };
21665
21899
  const tempDir = await mkdtemp(join7(tmpdir2(), "deepline-enrich-play-"));
21900
+ await emitSdkEnrichTelemetry(sdkEnrichTelemetry, "enrich_started");
21666
21901
  const tempPlay = join7(tempDir, "deepline-enrich.play.ts");
21667
21902
  let inPlaceTempDir = null;
21668
21903
  let inPlaceTempOutputPath = null;
@@ -21761,7 +21996,6 @@ function registerEnrichCommand(program) {
21761
21996
  });
21762
21997
  return { captured: captured2, status: status2, exportResult: exportResult2 };
21763
21998
  };
21764
- const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
21765
21999
  const autoBatchRows = enrichAutoBatchRowsForConfig(config);
21766
22000
  if (outputPath && selectedRange.count > autoBatchRows) {
21767
22001
  const chunkCount = Math.ceil(selectedRange.count / autoBatchRows);
@@ -21942,6 +22176,10 @@ function registerEnrichCommand(program) {
21942
22176
  });
21943
22177
  }
21944
22178
  process.exitCode = failureReport3 ? EXIT_SERVER2 : chunk.captured.result;
22179
+ await completeTelemetry({
22180
+ status: "failed",
22181
+ failedJobs: failureReport3?.jobs.length ?? 1
22182
+ });
21945
22183
  return;
21946
22184
  }
21947
22185
  if (chunk.exportResult) {
@@ -22020,6 +22258,10 @@ function registerEnrichCommand(program) {
22020
22258
  if (failureReport2) {
22021
22259
  process.exitCode = EXIT_SERVER2;
22022
22260
  }
22261
+ await completeTelemetry({
22262
+ status: failureReport2 ? "completed_with_failures" : "completed",
22263
+ failedJobs: failureReport2?.jobs.length ?? 0
22264
+ });
22023
22265
  return;
22024
22266
  }
22025
22267
  const { captured, status, exportResult } = await runOne({
@@ -22062,6 +22304,10 @@ function registerEnrichCommand(program) {
22062
22304
  });
22063
22305
  }
22064
22306
  process.exitCode = failureReport2 ? EXIT_SERVER2 : captured.result;
22307
+ await completeTelemetry({
22308
+ status: "failed",
22309
+ failedJobs: failureReport2?.jobs.length ?? 1
22310
+ });
22065
22311
  return;
22066
22312
  }
22067
22313
  if (options.json) {
@@ -22098,6 +22344,10 @@ function registerEnrichCommand(program) {
22098
22344
  if (failureReport2) {
22099
22345
  process.exitCode = EXIT_SERVER2;
22100
22346
  }
22347
+ await completeTelemetry({
22348
+ status: failureReport2 ? "completed_with_failures" : "completed",
22349
+ failedJobs: failureReport2?.jobs.length ?? 0
22350
+ });
22101
22351
  return;
22102
22352
  }
22103
22353
  const failureReport = await maybeEmitEnrichFailureReport({
@@ -22128,6 +22378,13 @@ function registerEnrichCommand(program) {
22128
22378
  if (failureReport) {
22129
22379
  process.exitCode = EXIT_SERVER2;
22130
22380
  }
22381
+ await completeTelemetry({
22382
+ status: failureReport ? "completed_with_failures" : "completed",
22383
+ failedJobs: failureReport?.jobs.length ?? 0
22384
+ });
22385
+ } catch (error) {
22386
+ await completeTelemetry({ status: "failed", failedJobs: 1 });
22387
+ throw error;
22131
22388
  } finally {
22132
22389
  if (inPlaceTempDir) {
22133
22390
  await rm(inPlaceTempDir, { recursive: true, force: true });
@@ -22141,8 +22398,8 @@ function registerEnrichCommand(program) {
22141
22398
 
22142
22399
  // src/cli/commands/feedback.ts
22143
22400
  async function handleFeedback(text, options) {
22144
- const { http } = getAuthedHttpClient();
22145
- const response = await http.post("/api/v2/cli/feedback", {
22401
+ const { http: http2 } = getAuthedHttpClient();
22402
+ const response = await http2.post("/api/v2/cli/feedback", {
22146
22403
  text,
22147
22404
  environment: collectLocalEnvInfo(),
22148
22405
  ...options.command ? { command: options.command } : {},
@@ -22553,8 +22810,8 @@ function buildSessionUploadContent(raw) {
22553
22810
  return { encodedContent: encoded, needsChunking: true };
22554
22811
  }
22555
22812
  async function uploadPayload(path, payload) {
22556
- const { http } = getAuthedHttpClient();
22557
- return await http.post(path, payload);
22813
+ const { http: http2 } = getAuthedHttpClient();
22814
+ return await http2.post(path, payload);
22558
22815
  }
22559
22816
  async function uploadChunkedSessions(sessions, options) {
22560
22817
  const uploadId = randomUUID3();
@@ -23314,8 +23571,8 @@ Preview the plan first with:
23314
23571
  );
23315
23572
  }
23316
23573
  async function handleMonitorsStatus(options) {
23317
- const http = buildHttpClient();
23318
- const payload = await http.request(
23574
+ const http2 = buildHttpClient();
23575
+ const payload = await http2.request(
23319
23576
  "/api/v2/monitors/access",
23320
23577
  { method: "GET" }
23321
23578
  );
@@ -23370,7 +23627,7 @@ async function handleMonitorsAvailable(toolId, options) {
23370
23627
  }
23371
23628
  }
23372
23629
  const tool = toolId ?? options.tool;
23373
- const http = buildHttpClient();
23630
+ const http2 = buildHttpClient();
23374
23631
  const params = new URLSearchParams();
23375
23632
  if (options.provider) params.set("provider", options.provider);
23376
23633
  if (tool) params.set("tool", tool);
@@ -23379,7 +23636,7 @@ async function handleMonitorsAvailable(toolId, options) {
23379
23636
  const compactList = !tool && !options.full;
23380
23637
  if (compactList || options.compact) params.set("compact", "true");
23381
23638
  const query = params.toString();
23382
- const payload = await http.request(
23639
+ const payload = await http2.request(
23383
23640
  `/api/v2/monitors/tools${query ? `?${query}` : ""}`,
23384
23641
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
23385
23642
  );
@@ -23419,13 +23676,13 @@ function renderDeployedListText(payload, requestedStatus) {
23419
23676
  `;
23420
23677
  }
23421
23678
  async function handleMonitorsList(options) {
23422
- const http = buildHttpClient();
23679
+ const http2 = buildHttpClient();
23423
23680
  const params = new URLSearchParams();
23424
23681
  if (options.status) params.set("status", options.status);
23425
23682
  if (options.limit) params.set("limit", options.limit);
23426
23683
  if (options.compact) params.set("compact", "true");
23427
23684
  const query = params.toString();
23428
- const payload = await http.request(
23685
+ const payload = await http2.request(
23429
23686
  `/api/v2/monitors/deployed${query ? `?${query}` : ""}`,
23430
23687
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
23431
23688
  );
@@ -23435,21 +23692,21 @@ async function handleMonitorsList(options) {
23435
23692
  });
23436
23693
  }
23437
23694
  async function handleMonitorsCheck(definition, options) {
23438
- const http = buildHttpClient();
23695
+ const http2 = buildHttpClient();
23439
23696
  const body = resolveMonitorJsonBody({
23440
23697
  positional: definition,
23441
23698
  file: options.file,
23442
23699
  argLabel: "<definition>",
23443
23700
  command: "deepline monitors check"
23444
23701
  });
23445
- const payload = await http.request(
23702
+ const payload = await http2.request(
23446
23703
  "/api/v2/monitors/check",
23447
23704
  { method: "POST", body, ...FORBIDDEN_AS_API_ERROR }
23448
23705
  );
23449
23706
  printCommandEnvelope(payload, { json: options.json });
23450
23707
  }
23451
23708
  async function handleMonitorsDeploy(definition, options) {
23452
- const http = buildHttpClient();
23709
+ const http2 = buildHttpClient();
23453
23710
  const body = resolveMonitorJsonBody({
23454
23711
  positional: definition,
23455
23712
  file: options.file,
@@ -23457,7 +23714,7 @@ async function handleMonitorsDeploy(definition, options) {
23457
23714
  command: "deepline monitors deploy"
23458
23715
  });
23459
23716
  if (options.dryRun) {
23460
- const payload2 = await http.request(
23717
+ const payload2 = await http2.request(
23461
23718
  "/api/v2/monitors/check",
23462
23719
  { method: "POST", body, ...FORBIDDEN_AS_API_ERROR }
23463
23720
  );
@@ -23471,7 +23728,7 @@ async function handleMonitorsDeploy(definition, options) {
23471
23728
  }
23472
23729
  return;
23473
23730
  }
23474
- const payload = await http.request(
23731
+ const payload = await http2.request(
23475
23732
  "/api/v2/monitors/deploy",
23476
23733
  { method: "POST", body, ...FORBIDDEN_AS_API_ERROR }
23477
23734
  );
@@ -23481,8 +23738,8 @@ async function handleMonitorsDeploy(definition, options) {
23481
23738
  });
23482
23739
  }
23483
23740
  async function handleMonitorsGet(key, options) {
23484
- const http = buildHttpClient();
23485
- const payload = await http.request(
23741
+ const http2 = buildHttpClient();
23742
+ const payload = await http2.request(
23486
23743
  `/api/v2/monitors/deployed/${encodeKey(key)}`,
23487
23744
  { method: "GET", ...FORBIDDEN_AS_API_ERROR }
23488
23745
  );
@@ -23504,12 +23761,12 @@ async function confirmMonitorDelete(key, options) {
23504
23761
  }
23505
23762
  }
23506
23763
  async function handleMonitorsDelete(key, options) {
23507
- const http = buildHttpClient();
23764
+ const http2 = buildHttpClient();
23508
23765
  const params = new URLSearchParams();
23509
23766
  if (options.localOnly) params.set("local_only", "true");
23510
23767
  if (options.dryRun) {
23511
23768
  params.set("dry_run", "true");
23512
- const payload2 = await http.request(
23769
+ const payload2 = await http2.request(
23513
23770
  `/api/v2/monitors/deployed/${encodeKey(key)}?${params.toString()}`,
23514
23771
  { method: "DELETE", ...FORBIDDEN_AS_API_ERROR }
23515
23772
  );
@@ -23541,30 +23798,30 @@ async function handleMonitorsDelete(key, options) {
23541
23798
  }
23542
23799
  }
23543
23800
  const query = params.toString();
23544
- const payload = await http.request(
23801
+ const payload = await http2.request(
23545
23802
  `/api/v2/monitors/deployed/${encodeKey(key)}${query ? `?${query}` : ""}`,
23546
23803
  { method: "DELETE", ...FORBIDDEN_AS_API_ERROR }
23547
23804
  );
23548
23805
  printCommandEnvelope(payload, { json: options.json });
23549
23806
  }
23550
23807
  async function handleMonitorsUpdate(key, patch, options) {
23551
- const http = buildHttpClient();
23808
+ const http2 = buildHttpClient();
23552
23809
  const body = resolveMonitorJsonBody({
23553
23810
  positional: patch,
23554
23811
  file: options.file,
23555
23812
  argLabel: "<patch>",
23556
23813
  command: `deepline monitors update ${key}`
23557
23814
  });
23558
- const payload = await http.request(
23815
+ const payload = await http2.request(
23559
23816
  `/api/v2/monitors/deployed/${encodeKey(key)}`,
23560
23817
  { method: "PATCH", body, ...FORBIDDEN_AS_API_ERROR }
23561
23818
  );
23562
23819
  printCommandEnvelope(payload, { json: options.json });
23563
23820
  }
23564
23821
  async function handleMonitorsReactivate(key, options) {
23565
- const http = buildHttpClient();
23822
+ const http2 = buildHttpClient();
23566
23823
  if (options.dryRun) {
23567
- const payload2 = await http.request(
23824
+ const payload2 = await http2.request(
23568
23825
  `/api/v2/monitors/deployed/${encodeKey(key)}/reactivate?dry_run=true`,
23569
23826
  { method: "POST", body: {}, ...FORBIDDEN_AS_API_ERROR }
23570
23827
  );
@@ -23578,7 +23835,7 @@ async function handleMonitorsReactivate(key, options) {
23578
23835
  });
23579
23836
  return;
23580
23837
  }
23581
- const payload = await http.request(
23838
+ const payload = await http2.request(
23582
23839
  `/api/v2/monitors/deployed/${encodeKey(key)}/reactivate`,
23583
23840
  { method: "POST", body: {}, ...FORBIDDEN_AS_API_ERROR }
23584
23841
  );
@@ -23822,8 +24079,8 @@ Examples:
23822
24079
  }
23823
24080
 
23824
24081
  // src/cli/commands/org.ts
23825
- async function fetchOrganizations(http, apiKey) {
23826
- return http.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
24082
+ async function fetchOrganizations(http2, apiKey) {
24083
+ return http2.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
23827
24084
  }
23828
24085
  function normalizeAuthScope(value) {
23829
24086
  if (!value) return "auto";
@@ -23927,8 +24184,8 @@ function resolveOrgSwitchAuthTarget(scope, config) {
23927
24184
  }
23928
24185
  async function handleOrgList(options) {
23929
24186
  const config = resolveConfig();
23930
- const http = new HttpClient(config);
23931
- const payload = await fetchOrganizations(http, config.apiKey);
24187
+ const http2 = new HttpClient(config);
24188
+ const payload = await fetchOrganizations(http2, config.apiKey);
23932
24189
  printCommandEnvelope(
23933
24190
  {
23934
24191
  ...payload,
@@ -23946,8 +24203,8 @@ async function handleOrgList(options) {
23946
24203
  }
23947
24204
  async function handleOrgStatus(options) {
23948
24205
  const config = resolveConfig();
23949
- const http = new HttpClient(config);
23950
- const payload = await fetchOrganizations(http, config.apiKey);
24206
+ const http2 = new HttpClient(config);
24207
+ const payload = await fetchOrganizations(http2, config.apiKey);
23951
24208
  const current = payload.organizations.find((org) => org.is_current) ?? payload.organizations.find(
23952
24209
  (org) => org.org_id === payload.current_org_id
23953
24210
  ) ?? null;
@@ -24030,8 +24287,8 @@ async function handleOrgStatus(options) {
24030
24287
  async function handleOrgSwitch(selection, options) {
24031
24288
  const authScope = normalizeAuthScope(options.authScope);
24032
24289
  const config = resolveConfig();
24033
- const http = new HttpClient(config);
24034
- const payload = await fetchOrganizations(http, config.apiKey);
24290
+ const http2 = new HttpClient(config);
24291
+ const payload = await fetchOrganizations(http2, config.apiKey);
24035
24292
  if (!selection && !options.orgId) {
24036
24293
  printCommandEnvelope(
24037
24294
  {
@@ -24126,7 +24383,7 @@ async function handleOrgSwitch(selection, options) {
24126
24383
  );
24127
24384
  return;
24128
24385
  }
24129
- const switched = await http.post("/api/v2/auth/cli/switch", {
24386
+ const switched = await http2.post("/api/v2/auth/cli/switch", {
24130
24387
  api_key: config.apiKey,
24131
24388
  org_id: target.org_id
24132
24389
  });
@@ -24194,8 +24451,8 @@ async function handleOrgSwitch(selection, options) {
24194
24451
  }
24195
24452
  async function handleOrgCreate(name, options) {
24196
24453
  const config = resolveConfig();
24197
- const http = new HttpClient(config);
24198
- const created = await http.post("/api/v2/auth/cli/org-create", {
24454
+ const http2 = new HttpClient(config);
24455
+ const created = await http2.post("/api/v2/auth/cli/org-create", {
24199
24456
  api_key: config.apiKey,
24200
24457
  name
24201
24458
  });
@@ -24787,8 +25044,8 @@ async function handleSet(nameInput, forbidden, options) {
24787
25044
  throw new Error("--play <name> is required when --scope play is used.");
24788
25045
  }
24789
25046
  const value = await readSecretValue();
24790
- const { http } = getAuthedHttpClient();
24791
- const response = await http.post(
25047
+ const { http: http2 } = getAuthedHttpClient();
25048
+ const response = await http2.post(
24792
25049
  "/api/v2/secrets",
24793
25050
  {
24794
25051
  name,
@@ -28935,7 +29192,7 @@ async function runPreflightCheck() {
28935
29192
  };
28936
29193
  }).catch(() => ({ status: "unreachable", version: null })).finally(() => clearTimeout(healthTimeout));
28937
29194
  const apiKey = resolveApiKeyForBaseUrl(baseUrl);
28938
- const http = apiKey ? new HttpClient(
29195
+ const http2 = apiKey ? new HttpClient(
28939
29196
  resolveConfig({
28940
29197
  baseUrl,
28941
29198
  apiKey,
@@ -28943,8 +29200,8 @@ async function runPreflightCheck() {
28943
29200
  maxRetries: 0
28944
29201
  })
28945
29202
  ) : null;
28946
- const [auth, billing] = http ? await Promise.all([
28947
- http.post("/api/v2/auth/cli/status", {
29203
+ const [auth, billing] = http2 ? await Promise.all([
29204
+ http2.post("/api/v2/auth/cli/status", {
28948
29205
  api_key: apiKey,
28949
29206
  reveal: false
28950
29207
  }).catch((error) => ({
@@ -28952,7 +29209,7 @@ async function runPreflightCheck() {
28952
29209
  connected: false,
28953
29210
  error: preflightErrorMessage(error)
28954
29211
  })),
28955
- http.get("/api/v2/billing/balance").catch((error) => ({
29212
+ http2.get("/api/v2/billing/balance").catch((error) => ({
28956
29213
  balance: null,
28957
29214
  balance_display: "unavailable",
28958
29215
  balance_status: "unknown",
@@ -29135,6 +29392,7 @@ Exit codes:
29135
29392
  registerBillingCommands(program);
29136
29393
  registerMonitorsCommands(program);
29137
29394
  registerOrgCommands(program);
29395
+ registerAdminCommands(program);
29138
29396
  registerEnrichCommand(program);
29139
29397
  registerCsvCommands(program);
29140
29398
  registerDbCommands(program);