agent-auto-resume 0.1.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.
@@ -0,0 +1,65 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best for the overall community, not just the individual
26
+
27
+ Examples of unacceptable behavior include:
28
+
29
+ * The use of sexualized language or imagery, and unwelcome sexual attention or
30
+ advances
31
+ * Trolling, insulting or derogatory comments, and personal or political attacks
32
+ * Public or private harassment
33
+ * Publishing others' private information, such as a physical or email address,
34
+ without their explicit permission
35
+ * Other conduct which could reasonably be considered inappropriate in a
36
+ professional setting
37
+
38
+ ## Enforcement Responsibilities
39
+
40
+ Community leaders are responsible for clarifying and enforcing our standards of
41
+ acceptable behavior and will take appropriate and fair corrective action in
42
+ response to any behavior that they deem inappropriate, threatening, offensive,
43
+ or harmful.
44
+
45
+ Community leaders have the right and responsibility to remove, edit, or reject
46
+ comments, commits, code, wiki edits, questions, and other contributions that are
47
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
48
+ decisions when appropriate.
49
+
50
+ ## Scope
51
+
52
+ This Code of Conduct applies within all community spaces, and also applies when
53
+ an individual is officially representing the community in public spaces.
54
+ Examples of representing our community include using an official email address,
55
+ posting via an official social media account, or acting as an appointed
56
+ representative at an online or offline event.
57
+
58
+ ## Enforcement
59
+
60
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
61
+ reported to the community leaders responsible for enforcement. All complaints
62
+ will be reviewed and investigated promptly and fairly.
63
+
64
+ All community leaders are obligated to respect the privacy and security of the
65
+ reporter of any incident.
@@ -0,0 +1,46 @@
1
+ # Contributing to agent-auto-resume
2
+
3
+ We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4
+
5
+ - Reporting a bug
6
+ - Discussing the current state of the code
7
+ - Submitting a fix
8
+ - Proposing new features
9
+
10
+ ## Development Setup
11
+
12
+ 1. Fork and clone the repository.
13
+ 2. Install dependencies:
14
+ ```bash
15
+ npm install
16
+ ```
17
+ 3. Run in development mode:
18
+ ```bash
19
+ npm run dev
20
+ ```
21
+ 4. Run tests:
22
+ ```bash
23
+ npm run test
24
+ ```
25
+
26
+ ## Pull Request Process
27
+
28
+ 1. Create a new branch for your feature or bug fix:
29
+ ```bash
30
+ git checkout -b feature/your-feature-name
31
+ ```
32
+ 2. Make your changes and write unit tests if applicable.
33
+ 3. Ensure types and code formatting are correct:
34
+ ```bash
35
+ npm run typecheck
36
+ npm run format
37
+ ```
38
+ 4. Run all tests to make sure everything passes:
39
+ ```bash
40
+ npm run test
41
+ ```
42
+ 5. Submit a Pull Request with a clear description of your changes.
43
+
44
+ ## Code of Conduct
45
+
46
+ By participating in this project, you agree to abide by the [Code of Conduct](CODE_OF_CONDUCT.md).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agent-auto-resume contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # agent-auto-resume (aar)
2
+
3
+ Daemon-based auto-resume CLI tool for Claude Code, OpenAI Codex CLI, and Google Antigravity CLI.
4
+
5
+ ---
6
+
7
+ ## What it does
8
+
9
+ `agent-auto-resume` (command: `aar`) acts as a wrapper and watcher daemon for popular AI agent command-line interfaces.
10
+ When an agent stops due to a provider-declared usage limit, rate limit, or quota exhaustion, `aar` detects the limit pattern, extracts the reset/retry time, waits until that time in a daemon background worker, and automatically resumes the session safely.
11
+
12
+ ## What it does not do
13
+
14
+ **This tool does not bypass, evade, or spoof usage limits.**
15
+ It does not rotate API keys, switch accounts, or trick provider servers. It simply respects the provider-declared reset time by waiting locally, and then automatically resumes the existing session on your machine once the limit resets.
16
+
17
+ ---
18
+
19
+ ## Why daemon mode?
20
+
21
+ Running AI agents can take hours to complete complex tasks. If they hit a limit while you are away (or asleep), you lose valuable time.
22
+ With `agent-auto-resume` running in the background, you don't need to manually check the terminal or click "resume" when the quota resets; it will automatically trigger the resume command when the time comes.
23
+
24
+ ---
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install -g agent-auto-resume
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Quick start
35
+
36
+ 1. Run the interactive setup:
37
+ ```bash
38
+ aar setup
39
+ ```
40
+ 2. Start the background daemon:
41
+ ```bash
42
+ aar daemon start
43
+ ```
44
+ 3. Run your AI agents as usual:
45
+ ```bash
46
+ claude
47
+ codex
48
+ agy
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Architecture & Modes
54
+
55
+ `agent-auto-resume` operates in three cooperative modes:
56
+
57
+ ### 1. Managed Command Mode (`aar managed`)
58
+ When you launch an agent, it is wrapped inside a Pseudoterminal (PTY) runner.
59
+ - It captures all stdout/stderr, pipe it to your terminal, and scans it in real-time for limit patterns.
60
+ - When a limit occurs, it captures the reset time, saves the session state, and safely kills the PTY process.
61
+
62
+ ### 2. Shell Shim Mode
63
+ Installed via `aar setup`. It adds shell functions (in `~/.zshrc`, `~/.bashrc`, or `~/.config/fish/config.fish`) so that calling `claude`, `codex`, or `agy` automatically runs them under `aar managed`.
64
+ > [!NOTE]
65
+ > `agent-auto-resume` works best after `aar setup`, which installs shell functions so future `claude`, `codex`, and `agy` sessions are launched in managed mode.
66
+
67
+ ### 3. Watcher Daemon Mode (`aar daemon`)
68
+ A background process that:
69
+ - Periodically scans `~/.agent-auto-resume/sessions/` for sessions in `waiting_limit_reset`.
70
+ - Calculates the wait time (reset time + `bufferSeconds`).
71
+ - Triggers the resume command via a background PTY when the wait expires.
72
+ - (Optional) Watches local transcript directories and `tmux` panes.
73
+
74
+ ---
75
+
76
+ ## Provider Support Matrix
77
+
78
+ | Provider | Command | Managed mode | Daemon resume | Transcript watcher | tmux watcher | Headless resume |
79
+ |---|---|---:|---:|---:|---:|---:|
80
+ | Claude Code | `claude` | Yes | Yes | Experimental | Experimental | Partial |
81
+ | Codex CLI | `codex` | Yes | Yes | Experimental | Experimental | Yes |
82
+ | Google Antigravity CLI | `agy` | Yes | Yes | No | Experimental | Experimental |
83
+
84
+ ---
85
+
86
+ ## Details on Provider Support
87
+
88
+ ### Claude Code (`claude`)
89
+ - **Detection**: Matches patterns like `5-hour limit reached`, `usage limit reached`, or `Your limit will reset at YYYY-MM-DD...`
90
+ - **Resume Strategy**: Resumes via PTY input (`continue\n`) if running, or executes `claude --continue`.
91
+ - **Transcript Watcher**: Watches `~/.claude/projects` for session events.
92
+
93
+ ### Codex CLI (`codex`)
94
+ - **Detection**: Matches patterns like `try again at HH:MM` or `resets_at: YYYY-MM-DD...`
95
+ - **Resume Strategy**: Resumes by executing `codex exec resume --last "<CODEX_SAFE_RESUME_PROMPT>"`.
96
+ - **Transcript Watcher**: Watches `~/.codex/sessions`.
97
+
98
+ ### Google Antigravity CLI (`agy`)
99
+ - **Detection**: Matches common Antigravity quota messages.
100
+ - **Resume Strategy**: Queries `agy --help` dynamically to find available subcommands (`agy resume --last`, `agy continue`, `agy c`, `agy conversation --last`) and falls back to `agy` with an interactive safe resume prompt.
101
+ - **Status**: **Experimental**.
102
+ > [!WARNING]
103
+ > Antigravity CLI support is experimental because its resume behavior may change across versions. If Antigravity requires workspace trust, tool permissions, or review confirmations, `agent-auto-resume` does not automatically bypass them. The user may still need to approve them manually.
104
+
105
+ ---
106
+
107
+ ## Watcher Extras (Experimental)
108
+
109
+ ### tmux watcher
110
+ By enabling the `tmux` watcher (via `--tmux` flag or config), the daemon scans open tmux panes.
111
+ It captures the screen content, parses it for limit text, and sends keypresses to resume when the time comes.
112
+ - Enable via config: `"tmux": { "enabled": true }`
113
+ - Run daemon: `aar daemon start --tmux`
114
+
115
+ ### transcript watcher
116
+ The daemon can watch logs written to `~/.claude/projects` or `~/.codex/sessions` and record limit-reached events in the background, even if the session was not started inside `aar managed`.
117
+ - **Note**: It cannot reliably read arbitrary terminal output from sessions that were started before setup unless tmux watcher or transcript watcher can detect them.
118
+
119
+ ---
120
+
121
+ ## Commands Reference
122
+
123
+ ### setup
124
+ ```bash
125
+ aar setup
126
+ ```
127
+ Initializes `~/.agent-auto-resume/`, generates default `config.json`, and guides shell configuration.
128
+ - `--shell <zsh|bash|fish>`: Specific shell configuration.
129
+ - `--no-shell-modify`: Setup directories but do not edit rc files.
130
+ - `--print-shell-snippet`: Only output the snippet to add.
131
+
132
+ ### daemon
133
+ ```bash
134
+ aar daemon start # Start background daemon
135
+ aar daemon stop # Stop background daemon
136
+ aar daemon restart # Restart daemon
137
+ aar daemon status # View daemon PID status
138
+ aar daemon logs # Print daemon log output
139
+ ```
140
+
141
+ ### status
142
+ ```bash
143
+ aar status
144
+ aar status --json
145
+ ```
146
+ Prints the daemon status and a list of currently waiting sessions, including time remaining.
147
+
148
+ ### sessions
149
+ ```bash
150
+ aar sessions
151
+ aar sessions --json
152
+ ```
153
+ Lists all saved session logs and statuses.
154
+
155
+ ### recover
156
+ ```bash
157
+ aar recover
158
+ aar recover --last
159
+ aar recover --id <session-id>
160
+ ```
161
+ Manually triggers recovery for a failed or waiting session in the background.
162
+
163
+ ### retry-now
164
+ ```bash
165
+ aar retry-now --id <session-id>
166
+ aar retry-now --last
167
+ aar retry-now --force
168
+ ```
169
+ Immediately resumes a session, bypassing the waiting time. If the reset time hasn't passed, it will warn you unless `--force` is provided (not recommended).
170
+
171
+ ---
172
+
173
+ ## Safety & Security Design
174
+
175
+ 1. **No Evading Limits**: Does not evade limits or abuse providers. Respects declared wait times.
176
+ 2. **Safe Resume Prompts**: When resuming, `aar` passes instruction prompts to inspect repository states (`git status`, `git diff`) and resume only the remaining, incomplete parts.
177
+ 3. **No Automatic Tool/Trust Approval**: Does not bypass "Workspace Trust" or "Tool Confirmations" (like file writes). These must still be approved by the user when required.
178
+ 4. **Environment Warning**: Since `aar` runs commands in background PTYs, make sure your environment is secure. Do not leave sensitive files uncommitted.
179
+
180
+ ---
181
+
182
+ ## License
183
+
184
+ MIT License. See [LICENSE](file:///Volumes/MOVESPEED/Documents/GitHub/agent-auto-resume/LICENSE) for details.
package/SECURITY.md ADDED
@@ -0,0 +1,17 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ We support security updates for the following versions:
6
+
7
+ | Version | Supported |
8
+ | ------- | --------- |
9
+ | < 1.0.0 | Yes |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ We take the security of this project seriously. If you find a security vulnerability, please do not report it publicly via GitHub Issues. Instead, please report it privately.
14
+
15
+ Please report security issues by opening a private vulnerability report on GitHub if available, or contact the project maintainers directly.
16
+
17
+ We will acknowledge your report within 48 hours and provide a detailed response with next steps, including proposed patches or mitigation instructions.
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node