mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 09:01:16 +00:00
give agent full shell
This commit is contained in:
parent
019bb0619a
commit
6dbec1d2da
1 changed files with 7 additions and 24 deletions
|
|
@ -5,14 +5,13 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
piAgentEnvFile = "/var/lib/pi-agent/pi-agent.env";
|
piAgentEnvFile = "/var/lib/pi-agent/pi-agent.env";
|
||||||
npmBin = "/home/${username}/.local/share/npm/bin";
|
piBin = "/home/${username}/.local/share/npm/bin/pi";
|
||||||
piBin = "${npmBin}/pi";
|
|
||||||
|
|
||||||
|
# Start pi inside a login shell so it inherits the full user environment
|
||||||
|
# (PATH, XDG dirs, etc). dtach provides the PTY that pi's TUI needs.
|
||||||
piAgentStart = pkgs.writeShellScript "start-pi-agent" ''
|
piAgentStart = pkgs.writeShellScript "start-pi-agent" ''
|
||||||
[ -x "${piBin}" ] || { echo "pi not found at ${piBin}" >&2; exit 1; }
|
|
||||||
export PATH="${npmBin}:$PATH"
|
|
||||||
exec ${pkgs.dtach}/bin/dtach -N /run/pi-agent/pi-agent.sock \
|
exec ${pkgs.dtach}/bin/dtach -N /run/pi-agent/pi-agent.sock \
|
||||||
${piBin} --chat-bridge
|
/bin/sh -lc 'exec ${piBin} --chat-bridge'
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +26,8 @@ in
|
||||||
# pi-subagents) and polls Telegram. Actual prompts run in separate
|
# pi-subagents) and polls Telegram. Actual prompts run in separate
|
||||||
# pi --mode rpc subprocesses spawned on demand.
|
# pi --mode rpc subprocesses spawned on demand.
|
||||||
#
|
#
|
||||||
|
# Runs as a login shell so the agent has the full user environment
|
||||||
|
#
|
||||||
# Config: ~/.pi/agent/settings.json (bot token, bridge settings)
|
# Config: ~/.pi/agent/settings.json (bot token, bridge settings)
|
||||||
# API key: /var/lib/pi-agent/pi-agent.env
|
# API key: /var/lib/pi-agent/pi-agent.env
|
||||||
systemd.services.pi-agent = {
|
systemd.services.pi-agent = {
|
||||||
|
|
@ -34,30 +35,12 @@ in
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = with pkgs; [
|
path = [ pkgs.dtach ];
|
||||||
nodejs_22
|
|
||||||
git
|
|
||||||
dtach
|
|
||||||
coreutils
|
|
||||||
gnutar
|
|
||||||
gzip
|
|
||||||
];
|
|
||||||
environment = {
|
|
||||||
HOME = "/home/${username}";
|
|
||||||
NODE_NO_WARNINGS = "1";
|
|
||||||
XDG_DATA_HOME = "/home/${username}/.local/share";
|
|
||||||
XDG_CACHE_HOME = "/home/${username}/.cache";
|
|
||||||
XDG_CONFIG_HOME = "/home/${username}/.config";
|
|
||||||
NPM_CONFIG_USERCONFIG = "/home/${username}/.config/npm/npmrc";
|
|
||||||
};
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = username;
|
User = username;
|
||||||
Group = "users";
|
Group = "users";
|
||||||
WorkingDirectory = "/home/${username}";
|
WorkingDirectory = "/home/${username}";
|
||||||
ExecCondition = "${pkgs.writeShellScript "pi-env-check" ''
|
|
||||||
[ -f "${piAgentEnvFile}" ]
|
|
||||||
''}";
|
|
||||||
EnvironmentFile = piAgentEnvFile;
|
EnvironmentFile = piAgentEnvFile;
|
||||||
ExecStart = piAgentStart;
|
ExecStart = piAgentStart;
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue