@zookanalytics/agent-env 0.7.0 → 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.0",
45
+ version: "0.8.0",
46
46
  description: "CLI for creating isolated, AI-ready development environments",
47
47
  type: "module",
48
48
  bin: {
@@ -603,7 +603,7 @@ var defaultMergeDeps = { readFile: readFile2, writeFile: writeFile2, rename, acc
603
603
  var STATUS_BAR_JSON_FILENAME = "statusBar.json";
604
604
  var LABEL_LIFECYCLE_CMDS = {
605
605
  postCreateCommand: "/usr/local/bin/post-create.sh",
606
- postStartCommand: "sudo /usr/local/bin/start-sshd.sh; tmux new-session -d -s main 2>/dev/null || true"
606
+ postStartCommand: "sudo /usr/local/bin/start-sshd.sh; tmux new-session -d -s main 2>/dev/null || true; : > /tmp/install-shared-skills.log; /usr/local/bin/install-shared-skills.sh >> /tmp/install-shared-skills.log 2>&1 || true"
607
607
  };
608
608
  var COMPOSABLE_LIFECYCLE_CMDS = [
609
609
  "postCreateCommand",
@@ -1990,14 +1990,13 @@ _agent_env_repos() {
1990
1990
 
1991
1991
  _agent_env_instances() {
1992
1992
  local ws_dir=~/.agent-env/workspaces
1993
- local entry base instance
1993
+ local entry base
1994
1994
  if [[ -d "\${ws_dir}" ]]; then
1995
1995
  for entry in "\${ws_dir}"/*/; do
1996
1996
  [[ -d "\${entry}" ]] || continue
1997
1997
  base="\${entry%/}"
1998
1998
  base="\${base##*/}"
1999
- instance="\${base##*-}"
2000
- [[ "\${instance}" != "\${base}" ]] && echo "\${instance}"
1999
+ echo "\${base}"
2001
2000
  done | sort -u
2002
2001
  fi
2003
2002
  }
@@ -2102,14 +2101,13 @@ _agent_env_repos() {
2102
2101
  _agent_env_instances() {
2103
2102
  local ws_dir=~/.agent-env/workspaces
2104
2103
  local -a instances
2105
- local entry base instance
2104
+ local entry base
2106
2105
  if [[ -d "\${ws_dir}" ]]; then
2107
2106
  for entry in "\${ws_dir}"/*/; do
2108
2107
  [[ -d "\${entry}" ]] || continue
2109
2108
  base="\${entry%/}"
2110
2109
  base="\${base##*/}"
2111
- instance="\${base##*-}"
2112
- [[ "\${instance}" != "\${base}" ]] && instances+=("\${instance}")
2110
+ instances+=("\${base}")
2113
2111
  done
2114
2112
  fi
2115
2113
  instances=(\${(u)instances})
@@ -3581,13 +3579,139 @@ var reposCommand = new Command8("repos").description("List tracked repositories"
3581
3579
  }
3582
3580
  });
3583
3581
 
3584
- // src/commands/tmux-status.ts
3582
+ // src/commands/setup-audio.ts
3585
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";
3586
3710
 
3587
3711
  // src/lib/tmux-status.ts
3588
- import { readFile as readFile11 } from "fs/promises";
3712
+ import { readFile as readFile12 } from "fs/promises";
3589
3713
  var MAX_PURPOSE_DISPLAY_LEN = 40;
3590
- var defaultDeps2 = { readFile: readFile11 };
3714
+ var defaultDeps2 = { readFile: readFile12 };
3591
3715
  function formatTmuxStatus(instance, purpose) {
3592
3716
  if (!instance) return "?";
3593
3717
  if (!purpose) return instance;
@@ -3623,7 +3747,7 @@ var defaultDeps3 = {
3623
3747
  statePath: CONTAINER_STATE_PATH
3624
3748
  };
3625
3749
  function createTmuxStatusCommand(deps = defaultDeps3) {
3626
- 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 () => {
3627
3751
  if (!deps.isInsideContainer()) {
3628
3752
  console.log("?");
3629
3753
  return;
@@ -3819,6 +3943,7 @@ program.addCommand(purposeCommand);
3819
3943
  program.addCommand(reposCommand);
3820
3944
  program.addCommand(tmuxStatusCommand);
3821
3945
  program.addCommand(completionCommand);
3946
+ program.addCommand(setupAudioCommand);
3822
3947
  program.action(async () => {
3823
3948
  if (program.args.length > 0) {
3824
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.0",
3
+ "version": "0.8.0",
4
4
  "description": "CLI for creating isolated, AI-ready development environments",
5
5
  "type": "module",
6
6
  "bin": {