@zookanalytics/agent-env 0.7.1 → 0.8.0

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.
@@ -28,6 +28,15 @@ else
28
28
  echo "agent-env: Warning: No SSH public keys found in ~/.ssh. SSH access will require manual setup."
29
29
  fi
30
30
 
31
+ # Stage PulseAudio cookie for audio passthrough (if setup-audio was run)
32
+ PULSE_COOKIE_SRC="$HOME/.agent-env/pulse/cookie"
33
+ PULSE_COOKIE_DST="$PWD/.agent-env/pulse"
34
+ if [ -f "$PULSE_COOKIE_SRC" ]; then
35
+ mkdir -p "$PULSE_COOKIE_DST"
36
+ cp -p "$PULSE_COOKIE_SRC" "$PULSE_COOKIE_DST/cookie"
37
+ echo "agent-env: Staged PulseAudio cookie for audio passthrough"
38
+ fi
39
+
31
40
  # Verify SSH agent socket exists (provided by Docker Desktop / OrbStack on macOS)
32
41
  if [ ! -S "$SSH_SOCKET" ]; then
33
42
  echo "agent-env: Warning: SSH agent socket not found at $SSH_SOCKET"
package/dist/cli.js CHANGED
@@ -42,7 +42,7 @@ import React3 from "react";
42
42
  // package.json
43
43
  var package_default = {
44
44
  name: "@zookanalytics/agent-env",
45
- version: "0.7.1",
45
+ version: "0.8.0",
46
46
  description: "CLI for creating isolated, AI-ready development environments",
47
47
  type: "module",
48
48
  bin: {
@@ -3579,13 +3579,139 @@ var reposCommand = new Command8("repos").description("List tracked repositories"
3579
3579
  }
3580
3580
  });
3581
3581
 
3582
- // src/commands/tmux-status.ts
3582
+ // src/commands/setup-audio.ts
3583
3583
  import { Command as Command9 } from "commander";
3584
+ import { copyFile, mkdir as mkdir10, readFile as readFile11, writeFile as writeFile9, access as access5 } from "fs/promises";
3585
+ import { homedir as homedir8, platform } from "os";
3586
+
3587
+ // src/lib/setup-audio.ts
3588
+ async function setupAudio(deps) {
3589
+ const steps = [];
3590
+ if (deps.platform !== "darwin") {
3591
+ return {
3592
+ ok: false,
3593
+ steps,
3594
+ error: "Audio passthrough is only supported on macOS. On Linux, use native PulseAudio directly."
3595
+ };
3596
+ }
3597
+ const brewPrefix = await deps.execute("brew", ["--prefix", "pulseaudio"]);
3598
+ if (!brewPrefix.ok) {
3599
+ return {
3600
+ ok: false,
3601
+ steps,
3602
+ error: "PulseAudio not found. Install with: brew install pulseaudio"
3603
+ };
3604
+ }
3605
+ const paPrefix = brewPrefix.stdout.trim();
3606
+ steps.push("PulseAudio found");
3607
+ const moduleCheck = await deps.execute("pactl", ["list", "short", "modules"]);
3608
+ const tcpAlreadyLoaded = moduleCheck.ok && moduleCheck.stdout.includes("module-native-protocol-tcp");
3609
+ if (!tcpAlreadyLoaded) {
3610
+ const loadResult = await deps.execute("pactl", [
3611
+ "load-module",
3612
+ "module-native-protocol-tcp",
3613
+ "auth-cookie-enabled=1",
3614
+ "listen=127.0.0.1",
3615
+ "port=4713"
3616
+ ]);
3617
+ if (!loadResult.ok) {
3618
+ return {
3619
+ ok: false,
3620
+ steps,
3621
+ error: `Failed to load PulseAudio TCP module: ${loadResult.stderr}`
3622
+ };
3623
+ }
3624
+ steps.push("TCP module loaded");
3625
+ } else {
3626
+ steps.push("TCP module already loaded");
3627
+ }
3628
+ const defaultPaPath = `${paPrefix}/etc/pulse/default.pa`;
3629
+ const tcpModuleLine = "load-module module-native-protocol-tcp auth-cookie-enabled=1 listen=127.0.0.1 port=4713";
3630
+ try {
3631
+ let paContent;
3632
+ try {
3633
+ paContent = await deps.readFile(defaultPaPath, "utf-8");
3634
+ } catch {
3635
+ await deps.mkdir(`${paPrefix}/etc/pulse`, { recursive: true });
3636
+ paContent = "";
3637
+ }
3638
+ const hasActiveModule = paContent.split("\n").some((line) => {
3639
+ const trimmed = line.trim();
3640
+ return !trimmed.startsWith("#") && !trimmed.startsWith(";") && trimmed.includes("load-module module-native-protocol-tcp");
3641
+ });
3642
+ if (!hasActiveModule) {
3643
+ const newContent = paContent ? paContent.trimEnd() + "\n" + tcpModuleLine + "\n" : tcpModuleLine + "\n";
3644
+ await deps.writeFile(defaultPaPath, newContent, "utf-8");
3645
+ steps.push("TCP module persisted to default.pa");
3646
+ } else {
3647
+ steps.push("TCP module already in default.pa");
3648
+ }
3649
+ } catch (err) {
3650
+ const msg = err instanceof Error ? err.message : String(err);
3651
+ return {
3652
+ ok: false,
3653
+ steps,
3654
+ error: `Failed to write ${defaultPaPath}: ${msg}`
3655
+ };
3656
+ }
3657
+ const cookieSrc = `${deps.homeDir}/.config/pulse/cookie`;
3658
+ const cookieDstDir = `${deps.homeDir}/.agent-env/pulse`;
3659
+ const cookieDst = `${cookieDstDir}/cookie`;
3660
+ try {
3661
+ await deps.access(cookieSrc);
3662
+ await deps.mkdir(cookieDstDir, { recursive: true });
3663
+ await deps.copyFile(cookieSrc, cookieDst);
3664
+ steps.push("Cookie staged");
3665
+ } catch {
3666
+ return {
3667
+ ok: false,
3668
+ steps,
3669
+ error: `PulseAudio cookie not found at ${cookieSrc}. Is PulseAudio running? Try: pulseaudio --start`
3670
+ };
3671
+ }
3672
+ return { ok: true, steps };
3673
+ }
3674
+
3675
+ // src/commands/setup-audio.ts
3676
+ function createDefaultSetupAudioDeps() {
3677
+ const exec = createExecutor();
3678
+ return {
3679
+ platform: platform(),
3680
+ homeDir: homedir8(),
3681
+ execute: exec,
3682
+ readFile: (path, encoding) => readFile11(path, encoding),
3683
+ writeFile: (path, content, encoding) => writeFile9(path, content, encoding),
3684
+ copyFile,
3685
+ mkdir: (path, opts) => mkdir10(path, opts),
3686
+ access: (path) => access5(path)
3687
+ };
3688
+ }
3689
+ var setupAudioCommand = new Command9("setup-audio").description("Configure macOS PulseAudio for audio passthrough to containers").action(async () => {
3690
+ const deps = createDefaultSetupAudioDeps();
3691
+ const result = await setupAudio(deps);
3692
+ if (!result.ok) {
3693
+ console.error(
3694
+ formatError(createError("AUDIO_SETUP_FAILED", result.error ?? "Unknown error"))
3695
+ );
3696
+ process.exit(1);
3697
+ return;
3698
+ }
3699
+ for (const step of result.steps) {
3700
+ console.log(`\x1B[32m\u2713\x1B[0m ${step}`);
3701
+ }
3702
+ console.log("");
3703
+ console.log(
3704
+ "Audio passthrough configured. Changes take effect on next container start or rebuild."
3705
+ );
3706
+ });
3707
+
3708
+ // src/commands/tmux-status.ts
3709
+ import { Command as Command10 } from "commander";
3584
3710
 
3585
3711
  // src/lib/tmux-status.ts
3586
- import { readFile as readFile11 } from "fs/promises";
3712
+ import { readFile as readFile12 } from "fs/promises";
3587
3713
  var MAX_PURPOSE_DISPLAY_LEN = 40;
3588
- var defaultDeps2 = { readFile: readFile11 };
3714
+ var defaultDeps2 = { readFile: readFile12 };
3589
3715
  function formatTmuxStatus(instance, purpose) {
3590
3716
  if (!instance) return "?";
3591
3717
  if (!purpose) return instance;
@@ -3621,7 +3747,7 @@ var defaultDeps3 = {
3621
3747
  statePath: CONTAINER_STATE_PATH
3622
3748
  };
3623
3749
  function createTmuxStatusCommand(deps = defaultDeps3) {
3624
- return new Command9("tmux-status").description("Output formatted instance status for tmux status bar (container only)").action(async () => {
3750
+ return new Command10("tmux-status").description("Output formatted instance status for tmux status bar (container only)").action(async () => {
3625
3751
  if (!deps.isInsideContainer()) {
3626
3752
  console.log("?");
3627
3753
  return;
@@ -3817,6 +3943,7 @@ program.addCommand(purposeCommand);
3817
3943
  program.addCommand(reposCommand);
3818
3944
  program.addCommand(tmuxStatusCommand);
3819
3945
  program.addCommand(completionCommand);
3946
+ program.addCommand(setupAudioCommand);
3820
3947
  program.action(async () => {
3821
3948
  if (program.args.length > 0) {
3822
3949
  const unknown = program.args[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zookanalytics/agent-env",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "CLI for creating isolated, AI-ready development environments",
5
5
  "type": "module",
6
6
  "bin": {