claude-triggers 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 minzique
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,174 @@
1
+ <div align="center">
2
+
3
+ # claude-triggers
4
+
5
+ **Manage Claude Code scheduled agents from any harness.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/claude-triggers?color=blue)](https://www.npmjs.com/package/claude-triggers)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
9
+ [![GitHub](https://img.shields.io/github/stars/minzique/claude-triggers?style=social)](https://github.com/minzique/claude-triggers)
10
+
11
+ Create, run, and manage remote Claude agents on cron schedules — from [pi](https://github.com/mariozechner/pi-coding-agent), [opencode](https://github.com/opencode-ai/opencode), your own tools, or the command line.
12
+
13
+ [Install](#install) · [Quick Start](#quick-start) · [CLI](#cli) · [Library](#library) · [Docs](./docs/ARCHITECTURE.md)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ > **⚠️ This package uses [reverse-engineered, undocumented Anthropic APIs](#disclaimer).** It may break at any time and may violate Anthropic's Terms of Service. Use at your own risk.
20
+
21
+ ## What It Does
22
+
23
+ Each trigger fires on a UTC cron schedule, spawning an **isolated cloud session** with its own git clone, tools, and optional MCP connections. The agent runs in Anthropic's infrastructure — it cannot access your local machine.
24
+
25
+ ```
26
+ Your Tool ──▶ claude-triggers ──▶ Anthropic API ──▶ Sandboxed Cloud Agent
27
+ (pi, opencode, /v1/code/triggers (git clone, Bash,
28
+ CLI, scripts) /v1/sessions Read, Write, Edit,
29
+ GitHub MCP, ...)
30
+ ```
31
+
32
+ Beyond what Claude Code's `/schedule` exposes, this package also lets you:
33
+ - **Create sessions directly** (no cron needed)
34
+ - **Read conversation history** from remote sessions
35
+ - **Send follow-up messages** to idle sessions
36
+ - **Upload seed bundles** for session initialization
37
+ - **Check GitHub integration** status programmatically
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install -g claude-triggers
43
+ ```
44
+
45
+ **Prerequisites:** Claude Code installed & logged in (`claude` run once), Claude Max/Pro subscription, Node 20+.
46
+
47
+ ## Quick Start
48
+
49
+ ```bash
50
+ # Verify everything works
51
+ claude-triggers test
52
+
53
+ # Create a scheduled agent
54
+ claude-triggers create \
55
+ --name "daily-review" \
56
+ --cron "0 9 * * 1-5" \
57
+ --prompt "Review open PRs and post summary comments" \
58
+ --repo "https://github.com/org/repo"
59
+
60
+ # Run it now (don't wait for cron)
61
+ claude-triggers run <trigger_id>
62
+
63
+ # See what it did
64
+ claude-triggers sessions
65
+ ```
66
+
67
+ ## CLI
68
+
69
+ ```bash
70
+ # ── Triggers ──
71
+ claude-triggers list [-v] # List (verbose: prompts, models)
72
+ claude-triggers create --name --cron --prompt [--repo] [--model] [--tools]
73
+ claude-triggers get <id>
74
+ claude-triggers update <id> [--name] [--cron] [--prompt] [--model] [--enabled]
75
+ claude-triggers enable <id>
76
+ claude-triggers disable <id>
77
+ claude-triggers run <id> # Run immediately
78
+ claude-triggers delete <id> # Opens browser (no API delete)
79
+
80
+ # ── Sessions ──
81
+ claude-triggers sessions # List remote sessions
82
+ claude-triggers session <id> # Session details
83
+ claude-triggers session-create --env <id> --prompt "..." [--repo] [--title]
84
+
85
+ # ── Infrastructure ──
86
+ claude-triggers envs # List environments
87
+ claude-triggers env-create [name] # Create environment
88
+ claude-triggers profile # Account & org info
89
+ claude-triggers github-check owner/repo # GitHub App + token sync
90
+ claude-triggers test # Full connectivity test
91
+
92
+ # All commands support --json for scripting
93
+ claude-triggers list --json | jq '.data[].name'
94
+ ```
95
+
96
+ ## Library
97
+
98
+ ```typescript
99
+ import { ClaudeTriggersClient, buildTriggerBody } from "claude-triggers";
100
+
101
+ const client = await ClaudeTriggersClient.create();
102
+
103
+ // Schedule an agent
104
+ const env = await client.ensureEnvironment();
105
+ const trigger = await client.createTrigger(
106
+ buildTriggerBody({
107
+ name: "nightly-tests",
108
+ cron: "0 3 * * *",
109
+ prompt: "Run the test suite and report failures",
110
+ environmentId: env.environment_id,
111
+ repoUrl: "https://github.com/org/repo",
112
+ })
113
+ );
114
+
115
+ // Run immediately
116
+ await client.runTrigger(trigger.id);
117
+
118
+ // Or create a one-off session (no cron)
119
+ const session = await client.createSession({
120
+ environmentId: env.environment_id,
121
+ prompt: "Refactor the auth module and open a PR",
122
+ repoUrl: "https://github.com/org/repo",
123
+ });
124
+
125
+ // Read the conversation
126
+ const events = await client.getSessionEvents(session.id);
127
+
128
+ // Send a follow-up
129
+ await client.sendSessionEvent(session.id, "Also update the tests");
130
+ ```
131
+
132
+ See the full [API reference →](./docs/API.md)
133
+
134
+ ## Cron
135
+
136
+ Standard 5-field UTC cron. **Minimum interval: 1 hour.**
137
+
138
+ | Expression | Meaning |
139
+ |:-----------|:--------|
140
+ | `0 9 * * 1-5` | Weekdays at 9am UTC |
141
+ | `0 */2 * * *` | Every 2 hours |
142
+ | `0 0 * * *` | Daily at midnight UTC |
143
+ | `30 14 * * 1` | Every Monday 2:30pm UTC |
144
+
145
+ ```typescript
146
+ import { validateCron, describeCron } from "claude-triggers";
147
+
148
+ validateCron("*/5 * * * *"); // "Minimum trigger interval is 1 hour..."
149
+ describeCron("0 9 * * 1-5", { utc: true }); // "Weekdays at 9:00am UTC"
150
+ ```
151
+
152
+ ## Docs
153
+
154
+ | Document | Contents |
155
+ |:---------|:---------|
156
+ | **[Architecture](./docs/ARCHITECTURE.md)** | How it works, API surface, session lifecycle, RE findings |
157
+ | **[API Reference](./docs/API.md)** | Full library API with types and examples |
158
+ | **[SKILL.md](./SKILL.md)** | Agent skill definition for pi and other harnesses |
159
+
160
+ ## Disclaimer
161
+
162
+ **This software is provided as-is, without warranty of any kind.**
163
+
164
+ This package interacts with **undocumented, internal Anthropic APIs** discovered through reverse engineering of Claude Code v2.1.81. These APIs use beta headers (`ccr-triggers-2026-01-30`, `ccr-byoc-2025-07-29`) that may be revoked without notice.
165
+
166
+ Anthropic's [Terms of Service](https://www.anthropic.com/terms) state that Claude Pro/Max subscription tokens should only be used with official clients. Using these credentials with third-party tools **may violate those terms** and could result in **account suspension**.
167
+
168
+ - **Use at your own risk.** The authors are not liable for any consequences — account suspension, charges, data loss, or service interruption.
169
+ - This project is **not affiliated with, endorsed by, or sponsored by Anthropic.**
170
+ - "Claude", "Claude Code", and "Anthropic" are trademarks of Anthropic, PBC.
171
+
172
+ ## License
173
+
174
+ [MIT](./LICENSE)
package/SKILL.md ADDED
@@ -0,0 +1,175 @@
1
+ ---
2
+ name: claude-triggers
3
+ description: Create, manage, and run Claude Code scheduled remote agents (triggers). Use when the user wants to schedule recurring AI tasks, set up cron-based automation, manage remote Claude sessions, or interact with the Anthropic trigger API. Works with any Claude Max/Pro account.
4
+ ---
5
+
6
+ # Claude Triggers Skill
7
+
8
+ Manage Claude Code's scheduled remote agents (triggers) from any agent harness. Each trigger runs on a cron schedule, spawning an isolated cloud session with its own git checkout, tools, and optional MCP connections.
9
+
10
+ ## Prerequisites
11
+
12
+ - Claude Code installed and authenticated (`claude` run at least once)
13
+ - Claude Max or Pro account (OAuth-based, not API key)
14
+ - Node.js 20+
15
+
16
+ ## Setup
17
+
18
+ ```bash
19
+ npm install -g claude-triggers
20
+ ```
21
+
22
+ Or use directly via npx:
23
+ ```bash
24
+ npx claude-triggers test
25
+ ```
26
+
27
+ ## Available Commands
28
+
29
+ ### Trigger Management
30
+
31
+ ```bash
32
+ # List all triggers
33
+ claude-triggers list
34
+ claude-triggers list -v # verbose: show prompts, models, repos
35
+
36
+ # Create a trigger
37
+ claude-triggers create \
38
+ --name "daily-pr-review" \
39
+ --cron "0 9 * * 1-5" \
40
+ --prompt "Review all open PRs. Post a summary comment on each." \
41
+ --repo "https://github.com/org/repo" \
42
+ --model "claude-sonnet-4-6"
43
+
44
+ # Get details
45
+ claude-triggers get <trigger_id>
46
+
47
+ # Update
48
+ claude-triggers update <trigger_id> --name "new-name"
49
+ claude-triggers update <trigger_id> --cron "0 */2 * * *"
50
+ claude-triggers update <trigger_id> --prompt "New instructions"
51
+ claude-triggers update <trigger_id> --enabled false
52
+
53
+ # Enable/disable
54
+ claude-triggers enable <trigger_id>
55
+ claude-triggers disable <trigger_id>
56
+
57
+ # Run immediately (without waiting for cron)
58
+ claude-triggers run <trigger_id>
59
+
60
+ # Delete (opens browser — API doesn't support delete)
61
+ claude-triggers delete <trigger_id>
62
+ ```
63
+
64
+ ### Session Management
65
+
66
+ ```bash
67
+ # List remote sessions
68
+ claude-triggers sessions
69
+
70
+ # Get session details
71
+ claude-triggers session <session_id>
72
+
73
+ # Create a session directly (without a trigger)
74
+ claude-triggers session-create \
75
+ --env <environment_id> \
76
+ --prompt "Run the test suite" \
77
+ --repo "https://github.com/org/repo"
78
+ ```
79
+
80
+ ### Infrastructure
81
+
82
+ ```bash
83
+ # List environments
84
+ claude-triggers envs
85
+
86
+ # Create an environment
87
+ claude-triggers env-create "my-env"
88
+
89
+ # Account info
90
+ claude-triggers profile
91
+
92
+ # Check GitHub integration
93
+ claude-triggers github-check owner/repo
94
+
95
+ # Test connectivity
96
+ claude-triggers test
97
+ ```
98
+
99
+ ### Output Formats
100
+
101
+ All commands support `--json` for raw JSON output, useful for scripting:
102
+ ```bash
103
+ claude-triggers list --json | jq '.data[].name'
104
+ ```
105
+
106
+ ## Library Usage
107
+
108
+ For integration into other tools, agents, or harnesses:
109
+
110
+ ```typescript
111
+ import { ClaudeTriggersClient, buildTriggerBody } from "claude-triggers";
112
+
113
+ // Auto-reads credentials from Claude Code
114
+ const client = await ClaudeTriggersClient.create();
115
+
116
+ // Create a trigger
117
+ const env = await client.ensureEnvironment();
118
+ const trigger = await client.createTrigger(
119
+ buildTriggerBody({
120
+ name: "nightly-tests",
121
+ cron: "0 3 * * *",
122
+ prompt: "Run the full test suite and report failures",
123
+ environmentId: env.environment_id,
124
+ repoUrl: "https://github.com/org/repo",
125
+ })
126
+ );
127
+
128
+ // Run it now
129
+ await client.runTrigger(trigger.id);
130
+
131
+ // Create a one-off session (no cron needed)
132
+ const session = await client.createSession({
133
+ environmentId: env.environment_id,
134
+ prompt: "Refactor the auth module",
135
+ repoUrl: "https://github.com/org/repo",
136
+ });
137
+ ```
138
+
139
+ ## Cron Expressions
140
+
141
+ Standard 5-field UTC cron: `minute hour day-of-month month day-of-week`
142
+
143
+ | Expression | Meaning |
144
+ |------------|---------|
145
+ | `0 9 * * 1-5` | Weekdays at 9am UTC |
146
+ | `0 */2 * * *` | Every 2 hours |
147
+ | `0 0 * * *` | Daily at midnight UTC |
148
+ | `30 14 * * 1` | Every Monday at 2:30pm UTC |
149
+ | `0 8 1 * *` | First of every month at 8am UTC |
150
+
151
+ **Minimum interval is 1 hour.** Sub-hour expressions like `*/30 * * * *` are rejected.
152
+
153
+ Cron expressions are always in **UTC**. Convert local times before creating triggers.
154
+
155
+ ## Important Notes
156
+
157
+ - Triggers run **remotely** in Anthropic's cloud — they can't access local files or services
158
+ - The agent prompt must be self-contained (the remote agent starts with zero context)
159
+ - Cannot delete triggers via API — use https://claude.ai/code/scheduled
160
+ - The trigger feature requires the `tengu_surreal_dali` feature flag (rolling out)
161
+ - Sessions are created with `events: []`, then the prompt is sent via `sendSessionEvent()` — this is how Claude Code does it internally
162
+ - When a GitHub repo is attached, the backend auto-provisions a scoped GitHub MCP server
163
+ - Cron is always **UTC** — convert local times before creating triggers
164
+
165
+ ## Session Lifecycle
166
+
167
+ 1. **Create** → status `pending` (environment provisioning)
168
+ 2. **Running** → agent is executing (tool calls, thinking)
169
+ 3. **Idle** → agent finished, waiting for follow-up input
170
+ 4. Use `getSessionEvents()` to read the conversation history
171
+ 5. Use `sendSessionEvent()` to send follow-up prompts to idle sessions
172
+
173
+ ## Disclaimer
174
+
175
+ This tool uses **reverse-engineered, undocumented Anthropic APIs** with beta headers that may change or break at any time. It uses your Claude Code OAuth credentials — Anthropic's ToS state that subscription tokens should only be used with official clients. **Use at your own risk.** The authors are not liable for account suspension, charges, or any other consequences. See the full [README disclaimer](https://github.com/minzique/claude-triggers#disclaimer) for details.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * claude-triggers CLI — manage Claude Code scheduled agents.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG"}