recappi 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19334,7 +19334,9 @@ function readCliVersion() {
19334
19334
  var CLI_VERSION = readCliVersion();
19335
19335
 
19336
19336
  // src/record.tsx
19337
- import { existsSync } from "fs";
19337
+ import { chmodSync, existsSync, statSync } from "fs";
19338
+ import { createRequire as createRequire2 } from "module";
19339
+ import { dirname, join } from "path";
19338
19340
  import { fileURLToPath } from "url";
19339
19341
  import { render, useInput as useInput2 } from "ink";
19340
19342
 
@@ -19525,6 +19527,7 @@ init_LiveCaptionsScreen();
19525
19527
  import { jsx as jsx3 } from "react/jsx-runtime";
19526
19528
  var SIDECAR_COMMAND_ENV = "RECAPPI_MINI_SIDECAR";
19527
19529
  var SIDECAR_HELPER_NAME = "RecappiMiniSidecar";
19530
+ var requireFromCli = createRequire2(import.meta.url);
19528
19531
  async function recordViaSidecar(opts) {
19529
19532
  let liveRenderer;
19530
19533
  let session;
@@ -19612,6 +19615,7 @@ async function startRecordSession(opts) {
19612
19615
  capabilities: opts.live ? ["recording.capture", "recording.upload", "live_captions.stream"] : ["recording.capture", "recording.upload"]
19613
19616
  })
19614
19617
  );
19618
+ assertSidecarCapabilities(handshake, opts);
19615
19619
  const started = await sidecar.client.startRecording({
19616
19620
  account,
19617
19621
  options: {
@@ -19663,11 +19667,25 @@ async function startRecordSession(opts) {
19663
19667
  throw error51;
19664
19668
  }
19665
19669
  }
19670
+ function assertSidecarCapabilities(handshake, opts) {
19671
+ const capabilities = new Set(handshake.capabilities);
19672
+ const missing = [];
19673
+ if (!capabilities.has("recording.capture")) missing.push("recording.capture");
19674
+ if (opts.live && !capabilities.has("live_captions.stream")) {
19675
+ missing.push("live_captions.stream");
19676
+ }
19677
+ if (missing.length === 0) return;
19678
+ throw cliError("usage.invalid_argument", "Recappi recording helper cannot capture yet.", {
19679
+ hint: `Found ${handshake.sidecar.name} ${handshake.sidecar.version}, but it did not advertise ${missing.join(
19680
+ ", "
19681
+ )}. Upgrade recappi when a helper build with native recording support ships, or set ${SIDECAR_COMMAND_ENV} to a compatible helper.`
19682
+ });
19683
+ }
19666
19684
  function resolveSidecarCommand(opts) {
19667
19685
  const command = opts.sidecarCommand?.trim() || opts.env?.[SIDECAR_COMMAND_ENV]?.trim();
19668
19686
  if (command) return command;
19669
19687
  const bundled = bundledSidecarCommand(process.platform, process.arch);
19670
- if (bundled && existsSync(bundled)) return bundled;
19688
+ if (bundled && existsSync(bundled)) return ensureBundledHelperExecutable(bundled);
19671
19689
  const platform = `${process.platform}-${process.arch}`;
19672
19690
  if (bundled) {
19673
19691
  throw cliError("usage.invalid_argument", "Recappi recording helper is not available.", {
@@ -19678,9 +19696,28 @@ function resolveSidecarCommand(opts) {
19678
19696
  hint: `No bundled helper is registered for ${platform}. Set ${SIDECAR_COMMAND_ENV} to a compatible helper when one is available.`
19679
19697
  });
19680
19698
  }
19699
+ function ensureBundledHelperExecutable(path6) {
19700
+ if (process.platform === "win32") return path6;
19701
+ const mode = statSync(path6).mode;
19702
+ if ((mode & 73) !== 0) return path6;
19703
+ try {
19704
+ chmodSync(path6, mode | 493);
19705
+ } catch (error51) {
19706
+ const message = error51 instanceof Error ? error51.message : String(error51);
19707
+ throw cliError("usage.invalid_argument", "Recappi recording helper is not executable.", {
19708
+ hint: `Could not make bundled helper executable at ${path6}: ${message}. Reinstall recappi, or set ${SIDECAR_COMMAND_ENV} to a compatible helper.`
19709
+ });
19710
+ }
19711
+ return path6;
19712
+ }
19681
19713
  function bundledSidecarCommand(platform, arch) {
19682
19714
  const executable = helperExecutableName(platform);
19683
19715
  if (!executable) return null;
19716
+ const helperPackage = helperPackageName(platform, arch);
19717
+ if (helperPackage) {
19718
+ const packageJson = resolveOptionalHelperPackage(helperPackage);
19719
+ if (packageJson) return join(dirname(packageJson), executable);
19720
+ }
19684
19721
  const packageRoot = new URL("..", import.meta.url);
19685
19722
  return fileURLToPath(new URL(`helpers/${platform}-${arch}/${executable}`, packageRoot));
19686
19723
  }
@@ -19689,6 +19726,17 @@ function helperExecutableName(platform) {
19689
19726
  if (platform === "win32") return `${SIDECAR_HELPER_NAME}.exe`;
19690
19727
  return null;
19691
19728
  }
19729
+ function helperPackageName(platform, arch) {
19730
+ if (platform === "darwin" && arch === "arm64") return "recappi-helper-darwin-arm64";
19731
+ return null;
19732
+ }
19733
+ function resolveOptionalHelperPackage(packageName) {
19734
+ try {
19735
+ return requireFromCli.resolve(`${packageName}/package.json`);
19736
+ } catch {
19737
+ return null;
19738
+ }
19739
+ }
19692
19740
  function persistArtifacts(artifacts, account, opts) {
19693
19741
  if (artifacts.length === 0) return;
19694
19742
  const store = openCliStore({ homeDir: opts.homeDir, env: opts.env });