Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Agent Instructions

## Selfimprove

This repository uses the global `selfimprovemeta` MCP. While working here,
record concrete tool friction with `record_friction` as it happens. Include
`caller_agent`, `project_slug = "gptqueue"`, and a queue/session id when one is
available.

If the MCP is unavailable, append the same record shape to
`~/.selfimprovemeta/friction.md`.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ Or set `GPTQ_AGENT_NAME` in the environment.
| `REDIS_URL` | `redis://127.0.0.1:6379` | Redis connection URL (MCP server and PTY wrapper) |
| `GPTQ_AGENT_NAME` | _(none)_ | Pre-register with this agent name on startup |
| `GPTQ_QUEUE_BOUND` | `10` | Max messages per agent inbox |
| `AGENT_ATTRIBUTION_CALLER` | `gptqueue-pty` | Attribution for PTY-wrapped child CLI processes |
| `AGENT_ATTRIBUTION_PROJECT` | Current directory name | Project attribution for PTY-wrapped child CLI processes |
| `AGENT_ATTRIBUTION_SESSION` | Agent name | Session attribution for PTY-wrapped child CLI processes |
| `REDIS_HOST` | `127.0.0.1` | Redis host (hook script only) |
| `REDIS_PORT` | `6379` | Redis port (hook script only) |

Expand Down
12 changes: 12 additions & 0 deletions src/pty-wrapper/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import * as path from "node:path";
import * as pty from "node-pty";
import { IdleDetector } from "./idle-detector.js";
import { RedisWatcher } from "./redis-watcher.js";
Expand Down Expand Up @@ -31,6 +32,16 @@ const { agent, cmd, args } = parseArgs(process.argv);

console.log(`[gptqueue-pty] Starting agent "${agent}" with command: ${cmd} ${args.join(" ")}`);

function agentAttributionEnv(agentName: string): Record<string, string> {
return {
AGENT_ATTRIBUTION_CALLER:
process.env.AGENT_ATTRIBUTION_CALLER || "gptqueue-pty",
AGENT_ATTRIBUTION_PROJECT:
process.env.AGENT_ATTRIBUTION_PROJECT || path.basename(process.cwd()),
AGENT_ATTRIBUTION_SESSION: process.env.AGENT_ATTRIBUTION_SESSION || agentName,
};
}

// Spawn the wrapped CLI in a PTY
const ptyProcess = pty.spawn(cmd, args, {
name: "xterm-color",
Expand All @@ -40,6 +51,7 @@ const ptyProcess = pty.spawn(cmd, args, {
env: {
...process.env,
GPTQ_AGENT_NAME: agent,
...agentAttributionEnv(agent),
} as Record<string, string>,
});

Expand Down
Loading