@action-llama/action-llama 0.5.0 → 0.6.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.
Files changed (60) hide show
  1. package/AGENTS.md +420 -0
  2. package/dist/agents/container-runner.d.ts.map +1 -1
  3. package/dist/agents/container-runner.js +1 -0
  4. package/dist/agents/container-runner.js.map +1 -1
  5. package/dist/agents/prompt.d.ts +8 -4
  6. package/dist/agents/prompt.d.ts.map +1 -1
  7. package/dist/agents/prompt.js +74 -8
  8. package/dist/agents/prompt.js.map +1 -1
  9. package/dist/cli/commands/doctor.d.ts +1 -0
  10. package/dist/cli/commands/doctor.d.ts.map +1 -1
  11. package/dist/cli/commands/doctor.js +76 -1
  12. package/dist/cli/commands/doctor.js.map +1 -1
  13. package/dist/cli/commands/start.js +1 -1
  14. package/dist/cli/commands/start.js.map +1 -1
  15. package/dist/docker/ecs-runtime.d.ts.map +1 -1
  16. package/dist/docker/ecs-runtime.js +58 -2
  17. package/dist/docker/ecs-runtime.js.map +1 -1
  18. package/dist/gateway/index.d.ts +3 -0
  19. package/dist/gateway/index.d.ts.map +1 -1
  20. package/dist/gateway/index.js +14 -2
  21. package/dist/gateway/index.js.map +1 -1
  22. package/dist/gateway/lock-store.d.ts +36 -0
  23. package/dist/gateway/lock-store.d.ts.map +1 -0
  24. package/dist/gateway/lock-store.js +119 -0
  25. package/dist/gateway/lock-store.js.map +1 -0
  26. package/dist/gateway/routes/dashboard.d.ts.map +1 -1
  27. package/dist/gateway/routes/dashboard.js +32 -0
  28. package/dist/gateway/routes/dashboard.js.map +1 -1
  29. package/dist/gateway/routes/locks.d.ts +6 -0
  30. package/dist/gateway/routes/locks.d.ts.map +1 -0
  31. package/dist/gateway/routes/locks.js +100 -0
  32. package/dist/gateway/routes/locks.js.map +1 -0
  33. package/dist/gateway/types.d.ts +1 -0
  34. package/dist/gateway/types.d.ts.map +1 -1
  35. package/dist/scheduler/event-queue.d.ts +1 -1
  36. package/dist/scheduler/event-queue.d.ts.map +1 -1
  37. package/dist/scheduler/event-queue.js +2 -2
  38. package/dist/scheduler/event-queue.js.map +1 -1
  39. package/dist/scheduler/index.d.ts +2 -10
  40. package/dist/scheduler/index.d.ts.map +1 -1
  41. package/dist/scheduler/index.js +150 -83
  42. package/dist/scheduler/index.js.map +1 -1
  43. package/dist/scheduler/runner-pool.d.ts +42 -0
  44. package/dist/scheduler/runner-pool.d.ts.map +1 -0
  45. package/dist/scheduler/runner-pool.js +59 -0
  46. package/dist/scheduler/runner-pool.js.map +1 -0
  47. package/dist/setup/scaffold.d.ts.map +1 -1
  48. package/dist/setup/scaffold.js +19 -423
  49. package/dist/setup/scaffold.js.map +1 -1
  50. package/dist/shared/config.d.ts +2 -0
  51. package/dist/shared/config.d.ts.map +1 -1
  52. package/dist/shared/config.js.map +1 -1
  53. package/dist/tui/App.d.ts.map +1 -1
  54. package/dist/tui/App.js +40 -10
  55. package/dist/tui/App.js.map +1 -1
  56. package/dist/tui/status-tracker.d.ts +4 -0
  57. package/dist/tui/status-tracker.d.ts.map +1 -1
  58. package/dist/tui/status-tracker.js +22 -0
  59. package/dist/tui/status-tracker.js.map +1 -1
  60. package/package.json +2 -1
@@ -1,429 +1,18 @@
1
- import { mkdirSync, writeFileSync, existsSync } from "fs";
1
+ import { mkdirSync, writeFileSync, existsSync, symlinkSync } from "fs";
2
2
  import { resolve } from "path";
3
+ import { fileURLToPath } from "url";
3
4
  import { stringify as stringifyTOML } from "smol-toml";
4
5
  import { writeCredentialField, writeCredentialFields } from "../shared/credentials.js";
5
6
  export { writeCredentialField, writeCredentialFields };
6
- const PROJECT_AGENTS_MD = `# Action Llama Project
7
-
8
- This is an Action Llama project. It runs automated development agents triggered by cron schedules or webhooks.
9
-
10
- ## Project Structure
11
-
12
- Each agent is a directory containing:
13
-
14
- - \`agent-config.toml\` — credentials, model, schedule, webhooks, params
15
- - \`PLAYBOOK.md\` — the system prompt (playbook) that defines what the agent does
16
- - \`Dockerfile\` (optional) — custom Docker image extending the base \`al-agent:latest\` (e.g. to install extra tools like \`gh\`)
17
-
18
- ## Creating an Agent
19
-
20
- 1. Create a directory for your agent (e.g. \`my-agent/\`)
21
- 2. Add \`agent-config.toml\` with credentials, model config, and a schedule or webhook trigger
22
- 3. Add \`PLAYBOOK.md\` with the playbook — step-by-step instructions the LLM follows each run
23
- 4. If running in Docker mode and your agent needs tools beyond what the base image provides (git, curl, openssh-client, node), add a \`Dockerfile\` — see Docker Mode section below
24
- 5. Verify with \`npx al status\`
25
- 6. Run with \`npx al start\`
26
-
27
- ## Credential Reference
28
-
29
- Credentials are managed by the user via \`al doctor\` and stored in \`~/.action-llama-credentials/<type>/<instance>/<field>\`. Reference them in \`credentials\` arrays as \`"type:instance"\` (e.g. \`"github_token:default"\`). The \`:default\` instance suffix can be omitted.
30
-
31
- | Type | What it is | Fields | Runtime injection | What it enables |
32
- |------|-----------|--------|-------------------|----------------|
33
- | \`anthropic_key\` | Anthropic API key or OAuth token | \`token\` | Read directly by the agent SDK (not an env var) | LLM access (Anthropic models) |
34
- | \`openai_key\` | OpenAI API key | \`token\` | Read directly by the agent SDK | LLM access (OpenAI models) |
35
- | \`groq_key\` | Groq API key | \`token\` | Read directly by the agent SDK | LLM access (Groq models) |
36
- | \`google_key\` | Google Gemini API key | \`token\` | Read directly by the agent SDK | LLM access (Gemini models) |
37
- | \`xai_key\` | xAI API key | \`token\` | Read directly by the agent SDK | LLM access (Grok models) |
38
- | \`mistral_key\` | Mistral API key | \`token\` | Read directly by the agent SDK | LLM access (Mistral models) |
39
- | \`openrouter_key\` | OpenRouter API key | \`token\` | Read directly by the agent SDK | LLM access (OpenRouter multi-provider) |
40
- | \`custom_key\` | Custom provider API key | \`token\` | Read directly by the agent SDK | LLM access (custom providers) |
41
- | \`github_token\` | GitHub PAT (repo + workflow scopes) | \`token\` | \`GITHUB_TOKEN\` and \`GH_TOKEN\` env vars | \`gh\` CLI, \`git\` over HTTPS, GitHub API |
42
- | \`git_ssh\` | SSH private key + git identity | \`id_rsa\`, \`username\`, \`email\` | SSH key mounted as file; \`GIT_SSH_COMMAND\` configured automatically; \`GIT_AUTHOR_NAME\`/\`GIT_AUTHOR_EMAIL\`/\`GIT_COMMITTER_NAME\`/\`GIT_COMMITTER_EMAIL\` set from \`username\`/\`email\` | \`git clone\`/\`push\` over SSH — **required for pushing to repos** |
43
- | \`sentry_token\` | Sentry auth token | \`token\` | \`SENTRY_AUTH_TOKEN\` env var | Sentry API via \`curl\` |
44
- | \`github_webhook_secret\` | Shared HMAC secret | \`secret\` | Used by gateway only (not injected into agents) | Validates GitHub webhook payloads |
45
- | \`sentry_client_secret\` | Sentry client secret | \`secret\` | Used by gateway only (not injected into agents) | Validates Sentry webhook payloads |
46
-
47
- **IMPORTANT:** Agents MUST NEVER ask users for credentials directly (API keys, tokens, passwords, etc.). Agents MUST NEVER run \`al doctor\` or interact with the credential system on behalf of the user. If a credential is missing at runtime, the agent should report the error and stop — the user will run \`al doctor\` and \`al start\` themselves.
48
-
49
- ## Runtime Context
50
-
51
- Every agent prompt has these XML blocks injected automatically at runtime:
52
-
53
- ### \`<agent-config>\`
54
-
55
- JSON object containing the agent's custom \`[params]\` from \`agent-config.toml\`. Example:
56
-
57
- \`\`\`json
58
- {"repos":["acme/app"],"triggerLabel":"agent","assignee":"bot-user"}
59
- \`\`\`
60
-
61
- (In this example, \`repos\` is a custom param defined in \`[params]\` — not a built-in field.)
62
-
63
- ### \`<credential-context>\`
64
-
65
- Lists which env vars and tools are available based on the agent's \`credentials\` array. Includes anti-exfiltration policy. The agent can rely on env vars like \`GITHUB_TOKEN\`, \`GH_TOKEN\`, \`SENTRY_AUTH_TOKEN\` being already set — it does NOT need to set them.
66
-
67
- ### \`<webhook-trigger>\` (webhook runs only)
68
-
69
- JSON object with the webhook event details. Only present when the agent is triggered by a webhook (not on scheduled runs). Schema:
70
-
71
- \`\`\`json
72
- {
73
- "source": "github",
74
- "event": "issues",
75
- "action": "labeled",
76
- "repo": "acme/app",
77
- "number": 42,
78
- "title": "Add dark mode",
79
- "body": "Issue description...",
80
- "url": "https://github.com/acme/app/issues/42",
81
- "author": "user",
82
- "assignee": "bot-user",
83
- "labels": ["agent"],
84
- "branch": null,
85
- "comment": null,
86
- "sender": "user",
87
- "timestamp": "2025-01-15T10:30:00Z"
7
+ /**
8
+ * Resolve the path to the shipped AGENTS.md at the package root.
9
+ * This module lives at src/setup/scaffold.ts (or dist/setup/scaffold.js),
10
+ * so the package root is two directories up.
11
+ */
12
+ function resolvePackageAgentsMd() {
13
+ const thisFile = fileURLToPath(import.meta.url);
14
+ return resolve(thisFile, "..", "..", "..", "AGENTS.md");
88
15
  }
89
- \`\`\`
90
-
91
- ### \`<agent-trigger>\` (agent-triggered runs only)
92
-
93
- JSON object with the source agent name and context. Only present when the agent was triggered by another agent via a \`[TRIGGER]\` signal. Schema:
94
-
95
- \`\`\`json
96
- {
97
- "source": "dev",
98
- "context": "I just opened PR #42 on acme/app. Please review it."
99
- }
100
- \`\`\`
101
-
102
- ### Triggering other agents
103
-
104
- An agent can trigger another agent by including a \`[TRIGGER]\` block in its output:
105
-
106
- \`\`\`
107
- [TRIGGER: reviewer]
108
- I just opened PR #42. Please review it.
109
- URL: https://github.com/acme/app/pull/42
110
- [/TRIGGER]
111
- \`\`\`
112
-
113
- The scheduler will run the target agent with the context injected as an \`<agent-trigger>\` block. Rules:
114
- - An agent cannot trigger itself
115
- - If the target is busy or does not exist, the trigger is skipped
116
- - Trigger chains are limited by \`maxTriggerDepth\` in \`config.toml\` (default: 3)
117
-
118
- ## Webhook Reference
119
-
120
- ### How webhooks work
121
-
122
- 1. Webhook sources are defined in the project's \`config.toml\` under \`[webhooks.<name>]\` with a provider type and optional credential
123
- 2. The gateway receives an HTTP POST at \`/webhooks/github\` or \`/webhooks/sentry\`
124
- 3. The payload is validated using the credential's HMAC secret (e.g. \`github_webhook_secret\` for GitHub)
125
- 4. The gateway matches the event against all agents' \`[[webhooks]]\` entries (AND logic — all specified fields must match; omitted fields are not checked)
126
- 5. Matching agents are triggered with a \`<webhook-trigger>\` block injected into their prompt
127
-
128
- ### Defining webhook sources in \`config.toml\`
129
-
130
- Webhook sources are defined once at the project level. Each source has a name, provider type, and optional credential instance for HMAC validation:
131
-
132
- \`\`\`toml
133
- [webhooks.my-github]
134
- type = "github"
135
- credential = "MyOrg" # credential instance name (github_webhook_secret:MyOrg)
136
-
137
- [webhooks.my-sentry]
138
- type = "sentry"
139
- credential = "SentryProd" # credential instance name (sentry_client_secret:SentryProd)
140
-
141
- [webhooks.unsigned-github]
142
- type = "github" # no credential — accepts unsigned webhooks
143
- \`\`\`
144
-
145
- ### Agent webhook filters
146
-
147
- Agents reference a webhook source by name and add filters:
148
-
149
- | Field | Type | Description |
150
- |-------|------|-------------|
151
- | \`source\` | string | Name of a webhook source from \`config.toml\` (required) |
152
- | \`repos\` | string[] | Filter to specific repos (owner/repo format) |
153
- | \`events\` | string[] | Event types: \`issues\`, \`pull_request\`, \`push\`, \`issue_comment\`, etc. |
154
- | \`actions\` | string[] | Event actions: \`opened\`, \`labeled\`, \`closed\`, \`synchronize\`, etc. |
155
- | \`labels\` | string[] | Only trigger when the issue/PR has ALL of these labels |
156
- | \`assignee\` | string | Only trigger when assigned to this user |
157
- | \`author\` | string | Only trigger for events by this author |
158
- | \`branches\` | string[] | Only trigger for pushes/PRs on these branches |
159
- | \`resources\` | string[] | Sentry: \`error\`, \`event_alert\`, \`metric_alert\`, \`issue\`, \`comment\` |
160
-
161
- ### GitHub webhook setup
162
-
163
- In your GitHub repo settings, add a webhook:
164
- - **Payload URL:** \`http://<your-host>:8080/webhooks/github\`
165
- - **Content type:** \`application/json\`
166
- - **Secret:** the same secret stored as the \`github_webhook_secret\` credential
167
-
168
- ### TOML syntax for webhooks
169
-
170
- Each webhook is a separate \`[[webhooks]]\` block (double brackets = array of tables). The \`source\` field references a webhook source defined in \`config.toml\`:
171
-
172
- \`\`\`toml
173
- # Each [[webhooks]] references a source from config.toml
174
- [[webhooks]]
175
- source = "my-github"
176
- events = ["issues"]
177
- actions = ["labeled"]
178
- labels = ["agent"]
179
-
180
- [[webhooks]]
181
- source = "my-github"
182
- events = ["pull_request"]
183
- # repos = ["my-org/specific-repo"] # optional — filter to specific repos
184
-
185
- [[webhooks]]
186
- source = "my-sentry"
187
- resources = ["error", "event_alert"]
188
- \`\`\`
189
-
190
- ## \`agent-config.toml\` Complete Reference
191
-
192
- The config file uses TOML syntax. The agent name is derived from the directory name — do not include it in the config.
193
-
194
- ### Minimal example (webhook-driven)
195
-
196
- \`\`\`toml
197
- credentials = ["github_token:default", "git_ssh:default"]
198
-
199
- [[webhooks]]
200
- source = "my-github"
201
- events = ["issues"]
202
- actions = ["labeled"]
203
- labels = ["agent"]
204
-
205
- [params]
206
- triggerLabel = "agent"
207
- assignee = "your-github-username"
208
- \`\`\`
209
-
210
- The \`[model]\` section is **optional** — agents inherit the default model from the project's \`config.toml\`. Only add \`[model]\` to an agent config if you want to override the default (e.g. use a different model or thinking level for that specific agent).
211
-
212
- ### Full example (webhooks + params + model override + optional schedule)
213
-
214
- \`\`\`toml
215
- credentials = ["github_token:default", "git_ssh:default", "sentry_token:default"]
216
- # schedule = "*/5 * * * *" # Optional: for scheduled polling in addition to webhooks
217
-
218
- # Optional: override the project default model for this agent
219
- [model]
220
- provider = "anthropic"
221
- model = "claude-sonnet-4-20250514"
222
- thinkingLevel = "medium"
223
- authType = "api_key"
224
-
225
- [[webhooks]]
226
- source = "my-github"
227
- events = ["issues"]
228
- actions = ["labeled"]
229
- labels = ["agent"]
230
-
231
- [[webhooks]]
232
- source = "my-sentry"
233
- resources = ["error", "event_alert"]
234
-
235
- [params]
236
- triggerLabel = "agent"
237
- assignee = "bot-user"
238
- sentryOrg = "acme"
239
- sentryProjects = ["web-app", "api"]
240
- # repos = ["fallback/repo"] # Optional: only needed if using schedule without webhook repo context
241
- \`\`\`
242
-
243
- ### Field reference
244
-
245
- | Field | Type | Required | Description |
246
- |-------|------|----------|-------------|
247
- | \`credentials\` | string[] | Yes | Credential refs as \`"type:instance"\` (see Credential Reference above) |
248
- | \`schedule\` | string | No* | Cron expression (e.g. "*/5 * * * *") |
249
- | \`model\` | table | No | LLM model config — omit to inherit from project \`config.toml\` |
250
- | \`model.provider\` | string | Yes* | "anthropic", "openai", "groq", "google", "xai", "mistral", "openrouter", or "custom" |
251
- | \`model.model\` | string | Yes* | Model ID (e.g. "claude-sonnet-4-20250514") |
252
- | \`model.thinkingLevel\` | string | No | off \\| minimal \\| low \\| medium \\| high \\| xhigh (only relevant for models with reasoning support, e.g. Claude Sonnet/Opus; omit for other models) |
253
- | \`model.authType\` | string | Yes* | api_key \\| oauth_token \\| pi_auth |
254
- | \`webhooks[].source\` | string | Yes | Name of a webhook source from \`config.toml\` |
255
- | \`webhooks[].repos\` | string[] | No | Filter to specific repos |
256
- | \`webhooks[].events\` | string[] | No | GitHub event types: issues, pull_request, push |
257
- | \`webhooks[].actions\` | string[] | No | GitHub actions: opened, labeled, closed |
258
- | \`webhooks[].labels\` | string[] | No | Only trigger for issues/PRs with these labels |
259
- | \`webhooks[].resources\` | string[] | No | Sentry resources: error, event_alert, metric_alert, issue, comment |
260
- | \`params.*\` | any | No | Custom key-value pairs injected into the prompt |
261
-
262
- *At least one of \`schedule\` or \`webhooks\` is required. *Required within \`[model]\` if the agent defines its own model block.
263
-
264
- ### TOML syntax reminders
265
-
266
- - Strings: \`key = "value"\`
267
- - Arrays: \`key = ["a", "b"]\`
268
- - Tables (objects): \`[tableName]\` on its own line, followed by key-value pairs
269
- - Array of tables: \`[[arrayName]]\` on its own line — each block is one entry in the array
270
- - Comments: \`# comment\`
271
-
272
- ## Example Playbook
273
-
274
- **Agent playbooks must be detailed and prescriptive with step-by-step commands. Copy this example and customize rather than writing from scratch.**
275
-
276
- The following is a complete, working PLAYBOOK.md for a developer agent. Use it as a template for all new agents:
277
-
278
- \`\`\`markdown
279
- # Developer Agent
280
-
281
- You are a developer agent. Your job is to pick up GitHub issues and implement the requested changes.
282
-
283
- Your configuration is in the \\\`<agent-config>\\\` block at the start of your prompt.
284
- Use those values for triggerLabel and assignee.
285
-
286
- \\\`GITHUB_TOKEN\\\` is already set in your environment. Use \\\`gh\\\` CLI and \\\`git\\\` directly.
287
- (Note: \\\`gh\\\` is not in the base Docker image — this agent needs a custom Dockerfile that installs it. See Docker Mode section.)
288
-
289
- **You MUST complete ALL steps below.** Do not stop after reading the issue — you must implement, commit, push, and open a PR.
290
-
291
- ## Repository Context
292
-
293
- This agent infers the repository from the issue context instead of using hardcoded configuration.
294
-
295
- **For webhook triggers:** The repository is extracted from the \\\`<webhook-trigger>\\\` block's \\\`repo\\\` field.
296
-
297
- **For scheduled triggers:** The agent uses the \\\`repos\\\` parameter from \\\`<agent-config>\\\` as a fallback to check for work across configured repositories.
298
-
299
- ## Setup — ensure labels exist
300
-
301
- Before looking for work, ensure the required labels exist on the target repo. The repo is determined as follows:
302
-
303
- - **Webhook mode:** Extract repo from \\\`<webhook-trigger>\\\` JSON block
304
- - **Scheduled mode:** Use repos from \\\`<agent-config>\\\` params
305
-
306
- Run the following (these are idempotent — they succeed silently if the label already exists):
307
-
308
- \\\`\\\`\\\`
309
- # For webhook triggers, use the repo from webhook context
310
- # For scheduled triggers, iterate through configured repos
311
- gh label create "<triggerLabel>" --repo <determined-repo> --color 0E8A16 --description "Trigger label for dev agent" --force
312
- gh label create "in-progress" --repo <determined-repo> --color FBCA04 --description "Agent is working on this" --force
313
- gh label create "agent-completed" --repo <determined-repo> --color 1D76DB --description "Agent has opened a PR" --force
314
- \\\`\\\`\\\`
315
-
316
- ## Finding work
317
-
318
- **Webhook trigger:** When you receive a \\\`<webhook-trigger>\\\` block, extract the repository from the \\\`repo\\\` field and the issue details from the trigger context. Check the issue's labels and assignee against your \\\`triggerLabel\\\` and \\\`assignee\\\` params. If the issue matches (has your trigger label and is assigned to your assignee), proceed with implementation using the extracted repository. If it does not match, respond \\\`[SILENT]\\\` and stop.
319
-
320
- **Scheduled trigger:** If \\\`repos\\\` parameter exists in \\\`<agent-config>\\\`, run \\\`gh issue list --repo <repo> --label <triggerLabel> --assignee <assignee> --state open --json number,title,body,comments,labels --limit 1\\\` for each configured repo. If no work found in any repo, respond \\\`[SILENT]\\\` and stop.
321
-
322
- ## Workflow
323
-
324
- **Important:** First determine the target repository from the trigger context (webhook \\\`repo\\\` field or configured \\\`repos\\\` parameter).
325
-
326
- 1. **Claim the issue** — run \\\`gh issue edit <number> --repo <determined-repo> --add-label in-progress\\\` to mark it as claimed.
327
-
328
- 2. **Clone and branch** — run \\\`git clone git@github.com:<determined-repo>.git /workspace/repo && cd /workspace/repo && git checkout -b agent/<number>\\\`.
329
-
330
- 3. **Understand the issue** — read the title, body, and comments. Note file paths, acceptance criteria, and linked issues.
331
-
332
- 4. **Read project conventions** — in the repo, read \\\`PLAYBOOK.md\\\`, \\\`CLAUDE.md\\\`, \\\`CONTRIBUTING.md\\\`, and \\\`README.md\\\` if they exist. Follow any conventions found there.
333
-
334
- 5. **Implement changes** — work in the repo. Make the minimum necessary changes, follow existing patterns, and write or update tests if the project has a test suite.
335
-
336
- 6. **Validate** — run the project's test suite and linters (e.g., \\\`npm test\\\`). Fix failures before proceeding.
337
-
338
- 7. **Commit** — \\\`git add -A && git commit -m "fix: <description> (closes #<number>)"\\\`
339
-
340
- 8. **Push** — \\\`git push -u origin agent/<number>\\\`
341
-
342
- 9. **Create a PR** — run \\\`gh pr create --repo <determined-repo> --head agent/<number> --base main --title "<title>" --body "Closes #<number>\\\\n\\\\n<description>"\\\`.
343
-
344
- 10. **Comment on the issue** — run \\\`gh issue comment <number> --repo <determined-repo> --body "PR created: <pr_url>"\\\`.
345
-
346
- 11. **Mark done** — run \\\`gh issue edit <number> --repo <determined-repo> --remove-label in-progress --add-label agent-completed\\\`.
347
-
348
- ## Rules
349
-
350
- - Work on exactly ONE issue per run
351
- - Never modify files outside the repo directory
352
- - **You MUST complete steps 7-11.** Do not stop early.
353
- - If tests fail after 2 attempts, create the PR anyway with a note about failing tests
354
- - If the issue is unclear, comment asking for clarification and stop
355
- \`\`\`
356
-
357
- ## Docker Mode
358
-
359
- Docker container isolation is enabled by default. Each agent run launches an isolated container with a read-only root filesystem, dropped capabilities, non-root user, and resource limits. Use \`--no-docker\` to disable it for development.
360
-
361
- ### Base image
362
-
363
- The base image (\`al-agent:latest\`) is built automatically on first run. It includes Node.js, git, curl, openssh-client, and ca-certificates — the minimum needed for any agent.
364
-
365
- ### Custom agent images
366
-
367
- If your agent needs extra tools (e.g. \`gh\` CLI, Python, \`jq\`), add a \`Dockerfile\` to the agent directory that extends the base image:
368
-
369
- \`\`\`dockerfile
370
- FROM al-agent:latest
371
- USER root
372
- RUN apt-get update && apt-get install -y --no-install-recommends gh && rm -rf /var/lib/apt/lists/*
373
- USER node
374
- \`\`\`
375
-
376
- Agent images are built automatically on startup. If no \`Dockerfile\` is present, the agent uses the base image.
377
-
378
- ### Container filesystem
379
-
380
- | Path | Mode | Contents |
381
- |------|------|----------|
382
- | \`/app\` | read-only | Action Llama application + node_modules |
383
- | \`/credentials\` | read-only | Mounted credential files (\`/<type>/<instance>/<field>\`) |
384
- | \`/workspace\` | read-write (tmpfs, 2GB) | Working directory — repos are cloned here |
385
- | \`/tmp\` | read-write (tmpfs, 512MB) | Temporary files |
386
- | \`/home/node\` | read-write (tmpfs, 64MB) | User home — \`.ssh/\` for SSH keys |
387
-
388
- ### Docker config options
389
-
390
- | Key | Default | Description |
391
- |-----|---------|-------------|
392
- | \`local.enabled\` | \`true\` | Enable Docker container isolation |
393
- | \`local.image\` | \`"al-agent:latest"\` | Base Docker image name |
394
- | \`local.memory\` | \`"4g"\` | Memory limit per container |
395
- | \`local.cpus\` | \`2\` | CPU limit per container |
396
- | \`local.timeout\` | \`3600\` | Max container runtime in seconds |
397
-
398
- ## Running Agents
399
-
400
- Start all agents with \`al start\` (or \`npx al start\`). This starts the scheduler which runs all discovered agents on their configured schedules/webhooks. There is no per-agent start command — \`al start\` always starts the entire project.
401
-
402
- ### Automatic re-runs
403
-
404
- When a scheduled agent completes productive work (i.e. it does not respond with \`[SILENT]\`), the scheduler immediately re-runs it. This continues until the agent reports \`[SILENT]\` (no more work), hits an error, or reaches the \`maxReruns\` limit. This way an agent drains its work queue without waiting for the next cron tick.
405
-
406
- Set \`maxReruns\` in \`config.toml\` to control the limit (default: 10):
407
-
408
- \`\`\`toml
409
- maxReruns = 5
410
- maxTriggerDepth = 3 # max depth for agent-to-agent trigger chains (default: 3)
411
- \`\`\`
412
-
413
- Webhook-triggered and agent-triggered runs do not re-run — they respond to a single event.
414
-
415
- ## Further Documentation
416
-
417
- Full documentation is available on GitHub:
418
-
419
- - [Creating Agents](https://github.com/Action-Llama/action-llama/blob/main/docs/creating-agents.md)
420
- - [agent-config.toml Reference](https://github.com/Action-Llama/action-llama/blob/main/docs/agent-config-reference.md)
421
- - [Credentials](https://github.com/Action-Llama/action-llama/blob/main/docs/credentials.md)
422
- - [Webhooks](https://github.com/Action-Llama/action-llama/blob/main/docs/webhooks.md)
423
- - [Docker](https://github.com/Action-Llama/action-llama/blob/main/docs/docker.md) — custom Dockerfiles, standalone images, troubleshooting
424
- - [CLI Commands](https://github.com/Action-Llama/action-llama/blob/main/docs/commands.md)
425
- - [Example Agents](https://github.com/Action-Llama/action-llama/blob/main/docs/examples/dev-agent.md) — dev, reviewer, devops
426
- `;
427
16
  export function scaffoldAgent(projectPath, agent) {
428
17
  const agentPath = resolve(projectPath, agent.name);
429
18
  mkdirSync(agentPath, { recursive: true });
@@ -458,10 +47,17 @@ export function scaffoldProject(projectPath, globalConfig, agents = [], projectN
458
47
  for (const agent of agents) {
459
48
  scaffoldAgent(projectPath, agent);
460
49
  }
461
- // Write project-level AGENTS.md for coding agents
50
+ // Symlink project-level AGENTS.md to the shipped copy in node_modules
462
51
  const agentsMdPath = resolve(projectPath, "AGENTS.md");
463
52
  if (!existsSync(agentsMdPath)) {
464
- writeFileSync(agentsMdPath, PROJECT_AGENTS_MD);
53
+ try {
54
+ const packageAgentsMd = resolvePackageAgentsMd();
55
+ symlinkSync(packageAgentsMd, agentsMdPath);
56
+ }
57
+ catch {
58
+ // Fallback: if the package can't be resolved (e.g. running from source
59
+ // before npm install), skip the symlink — the user can create it later.
60
+ }
465
61
  }
466
62
  // Create workspace directory
467
63
  mkdirSync(resolve(projectPath, ".workspace"), { recursive: true });
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/setup/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC;AAEvD,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoazB,CAAC;AAOF,MAAM,UAAU,aAAa,CAAC,WAAmB,EAAE,KAAoB;IACrE,MAAM,SAAS,GAAG,OAAO,CAAC,W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a,CAAC,aAAa,EAAE;YAC3B,eAAe;YACf,aAAa;YACb,MAAM;YACN,OAAO;YACP,WAAW;YACX,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -31,6 +31,7 @@ export interface CloudConfig {
31
31
  }
32
32
  export interface GatewayConfig {
33
33
  port?: number;
34
+ lockTimeout?: number;
34
35
  }
35
36
  export interface WebhookSourceConfig {
36
37
  type: string;
@@ -53,6 +54,7 @@ export interface AgentConfig {
53
54
  schedule?: string;
54
55
  webhooks?: WebhookTrigger[];
55
56
  params?: Record<string, unknown>;
57
+ scale?: number;
56
58
  }
57
59
  export declare function loadGlobalConfig(projectPath: string): GlobalConfig;
58
60
  export declare function loadAgentConfig(projectPath: string, agentName: string): AgentConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/shared/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACxE,QAAQ,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC;CACjD;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,WAAW,GAAG,KAAK,CAAC;IAE9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC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M,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/tui/App.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,qBAAqB,CAAC;AA4I9F,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAAE,aAAa,EAAE,EAAE;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,2CAqC9E"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/tui/App.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,qBAAqB,CAAC;AAyJ9F,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAAE,aAAa,EAAE,EAAE;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,2CA8D9E"}
package/dist/tui/App.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
- import { Box, Text } from "ink";
3
+ import { Box, Text, useInput } from "ink";
4
4
  function formatRelativeTime(date) {
5
5
  if (!date)
6
6
  return "";
@@ -39,7 +39,7 @@ function formatTimeUntil(date) {
39
39
  function formatTime(date) {
40
40
  return date.toLocaleTimeString("en-US", { hour12: false });
41
41
  }
42
- function Header({ info, agentCount }) {
42
+ function Header({ info, agentCount, agents }) {
43
43
  if (!info)
44
44
  return null;
45
45
  const isCloud = info.mode === "docker" && info.runtime && info.runtime !== "local";
@@ -52,9 +52,11 @@ function Header({ info, agentCount }) {
52
52
  : isCloud
53
53
  ? runtimeLabels[info.runtime] || "Cloud mode"
54
54
  : "Docker mode";
55
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { bold: true, children: ["Action Llama (", modeLabel, ") \u2014 ", agentCount, " agent", agentCount !== 1 ? "s" : "", ", ", info.cronJobCount, " cron job", info.cronJobCount !== 1 ? "s" : ""] }), _jsxs(Text, { dimColor: true, children: [info.gatewayPort ? `Gateway: :${info.gatewayPort}` : "", info.gatewayPort && info.webhooksActive ? " | " : "", info.webhooksActive ? "Webhooks: active" : ""] }), info.webhookUrls.map((url, i) => (_jsxs(Text, { dimColor: true, children: [" ", url] }, i))), info.dashboardUrl ? (_jsxs(Text, { dimColor: true, children: ["Dashboard: ", info.dashboardUrl] })) : null, isCloud ? (_jsx(Text, { color: "yellow", children: "Logs may be delayed ~10s (Cloud Logging ingestion)" })) : null, _jsx(Text, { dimColor: true, children: "─".repeat(50) })] }));
55
+ const enabledCount = agents.filter(a => a.enabled).length;
56
+ const disabledCount = agentCount - enabledCount;
57
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { bold: true, children: ["Action Llama (", modeLabel, ") \u2014 ", agentCount, " agent", agentCount !== 1 ? "s" : "", "(", enabledCount, " enabled", disabledCount > 0 ? `, ${disabledCount} disabled` : "", "), ", info.cronJobCount, " cron job", info.cronJobCount !== 1 ? "s" : ""] }), _jsxs(Text, { dimColor: true, children: [info.gatewayPort ? `Gateway: :${info.gatewayPort}` : "", info.gatewayPort && info.webhooksActive ? " | " : "", info.webhooksActive ? "Webhooks: active" : ""] }), info.webhookUrls.map((url, i) => (_jsxs(Text, { dimColor: true, children: [" ", url] }, i))), info.dashboardUrl ? (_jsxs(Text, { dimColor: true, children: ["Dashboard: ", info.dashboardUrl] })) : null, isCloud ? (_jsx(Text, { color: "yellow", children: "Logs may be delayed ~10s (Cloud Logging ingestion)" })) : null, _jsx(Text, { dimColor: true, children: "─".repeat(50) })] }));
56
58
  }
57
- function AgentRow({ agent }) {
59
+ function AgentRow({ agent, isSelected }) {
58
60
  const stateColor = agent.state === "running" ? "green" : agent.state === "building" ? "yellow" : agent.state === "error" ? "red" : "white";
59
61
  const stateLabel = agent.state === "running" ? "Running" : agent.state === "building" ? "Building" : agent.state === "error" ? "Error" : "Idle";
60
62
  // Show status text, or last error for error state
@@ -63,9 +65,11 @@ function AgentRow({ agent }) {
63
65
  : agent.state === "error" && agent.lastError
64
66
  ? agent.lastError
65
67
  : "";
66
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Box, { width: 12, children: _jsx(Text, { bold: true, children: agent.name }) }), _jsx(Box, { width: 10, children: _jsx(Text, { color: stateColor, children: stateLabel }) }), _jsx(Box, { width: 30, children: _jsx(Text, { dimColor: true, children: agent.lastRunAt
68
+ const enabledLabel = agent.enabled ? "Enabled" : "Disabled";
69
+ const enabledColor = agent.enabled ? "green" : "yellow";
70
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { backgroundColor: isSelected ? "blue" : undefined, children: [_jsx(Box, { width: 12, children: _jsxs(Text, { bold: true, color: isSelected ? "white" : undefined, children: [isSelected ? "▶ " : " ", agent.name] }) }), _jsx(Box, { width: 10, children: _jsx(Text, { color: isSelected ? "white" : stateColor, children: stateLabel }) }), _jsx(Box, { width: 10, children: _jsx(Text, { color: isSelected ? "white" : enabledColor, children: enabledLabel }) }), _jsx(Box, { width: 30, children: _jsx(Text, { dimColor: !isSelected, children: agent.lastRunAt
67
71
  ? `Last: ${formatRelativeTime(agent.lastRunAt)}${agent.lastRunDuration !== null ? ` (${formatDuration(agent.lastRunDuration)})` : ""}`
68
- : "" }) }), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: agent.nextRunAt ? `Next: ${formatTimeUntil(agent.nextRunAt)}` : "" }) })] }), detail ? (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { color: agent.state === "error" ? "red" : undefined, dimColor: agent.state !== "error", wrap: "truncate-end", children: detail.slice(0, 120) }) })) : null] }));
72
+ : "" }) }), _jsx(Box, { children: _jsx(Text, { dimColor: !isSelected, children: agent.nextRunAt ? `Next: ${formatTimeUntil(agent.nextRunAt)}` : "" }) })] }), detail ? (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { color: agent.state === "error" ? "red" : undefined, dimColor: agent.state !== "error" || isSelected, wrap: "truncate-end", children: detail.slice(0, 120) }) })) : null] }));
69
73
  }
70
74
  function RecentActivity({ logs }) {
71
75
  if (logs.length === 0)
@@ -73,18 +77,44 @@ function RecentActivity({ logs }) {
73
77
  return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "─".repeat(50) }), _jsx(Text, { bold: true, children: "Recent:" }), logs.map((log, i) => (_jsxs(Text, { dimColor: true, children: [" ", formatTime(log.timestamp), " [", log.agent, "] ", log.message.slice(0, 80)] }, i)))] }));
74
78
  }
75
79
  function Footer() {
76
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "─".repeat(50) }), _jsx(Text, { dimColor: true, children: "Ctrl+C to stop" })] }));
80
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "─".repeat(50) }), _jsx(Text, { dimColor: true, children: "\u2191/\u2193: Select agent \u2022 Space: Enable/Disable \u2022 Ctrl+C: Stop" })] }));
77
81
  }
78
82
  export default function App({ statusTracker }) {
79
83
  const [agents, setAgents] = useState(() => statusTracker.getAllAgents());
80
84
  const [info, setInfo] = useState(() => statusTracker.getSchedulerInfo());
81
85
  const [logs, setLogs] = useState(() => statusTracker.getRecentLogs(5));
86
+ const [selectedIndex, setSelectedIndex] = useState(0);
82
87
  const [, setTick] = useState(0);
88
+ useInput((input, key) => {
89
+ if (key.upArrow) {
90
+ setSelectedIndex((prev) => Math.max(0, prev - 1));
91
+ }
92
+ else if (key.downArrow) {
93
+ setSelectedIndex((prev) => Math.min(agents.length - 1, prev + 1));
94
+ }
95
+ else if (input === " " && agents.length > 0) {
96
+ // Toggle agent enabled/disabled state
97
+ const selectedAgent = agents[selectedIndex];
98
+ if (selectedAgent) {
99
+ if (selectedAgent.enabled) {
100
+ statusTracker.disableAgent(selectedAgent.name);
101
+ }
102
+ else {
103
+ statusTracker.enableAgent(selectedAgent.name);
104
+ }
105
+ }
106
+ }
107
+ });
83
108
  useEffect(() => {
84
109
  const update = () => {
85
- setAgents(statusTracker.getAllAgents());
110
+ const newAgents = statusTracker.getAllAgents();
111
+ setAgents(newAgents);
86
112
  setInfo(statusTracker.getSchedulerInfo());
87
113
  setLogs(statusTracker.getRecentLogs(5));
114
+ // Adjust selection if agents list changed
115
+ if (selectedIndex >= newAgents.length) {
116
+ setSelectedIndex(Math.max(0, newAgents.length - 1));
117
+ }
88
118
  };
89
119
  statusTracker.on("update", update);
90
120
  update(); // initial render
@@ -94,7 +124,7 @@ export default function App({ statusTracker }) {
94
124
  statusTracker.off("update", update);
95
125
  clearInterval(timer);
96
126
  };
97
- }, [statusTracker]);
98
- return (_jsxs(Box, { flexDirection: "column", paddingTop: 1, children: [_jsx(Header, { info: info, agentCount: agents.length }), _jsx(Box, { flexDirection: "column", paddingTop: 1, paddingBottom: 1, children: agents.map((agent) => (_jsx(AgentRow, { agent: agent }, agent.name))) }), _jsx(RecentActivity, { logs: logs }), _jsx(Footer, {})] }));
127
+ }, [statusTracker, selectedIndex]);
128
+ return (_jsxs(Box, { flexDirection: "column", paddingTop: 1, children: [_jsx(Header, { info: info, agentCount: agents.length, agents: agents }), _jsx(Box, { flexDirection: "column", paddingTop: 1, paddingBottom: 1, children: agents.map((agent, index) => (_jsx(AgentRow, { agent: agent, isSelected: index === selectedIndex }, agent.name))) }), _jsx(RecentActivity, { logs: logs }), _jsx(Footer, {})] }));
99
129
  }
100
130
  //# sourceMappingURL=App.js.map