@adaptic/maestro 1.1.7 → 1.4.1
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/.claude/commands/init-maestro.md +502 -260
- package/README.md +47 -2
- package/bin/maestro.mjs +1 -1
- package/docs/guides/agents-observe-setup.md +64 -0
- package/docs/guides/ccxray-diagnostics.md +65 -0
- package/docs/guides/claude-mem-setup.md +79 -0
- package/docs/guides/claude-pace-setup.md +56 -0
- package/docs/guides/claudraband-sessions.md +98 -0
- package/docs/guides/clawteam-swarm.md +116 -0
- package/docs/guides/code-review-graph-setup.md +86 -0
- package/docs/guides/email-setup.md +399 -0
- package/docs/guides/media-generation-setup.md +349 -0
- package/docs/guides/outbound-governance-setup.md +438 -0
- package/docs/guides/pdf-generation-setup.md +315 -0
- package/docs/guides/poller-daemon-setup.md +550 -0
- package/docs/guides/rag-context-setup.md +459 -0
- package/docs/guides/self-optimization-pattern.md +82 -0
- package/docs/guides/slack-setup.md +350 -0
- package/docs/guides/twilio-subaccounts-setup.md +223 -0
- package/docs/guides/voice-sms-setup.md +698 -0
- package/docs/guides/webhook-relay-setup.md +349 -0
- package/docs/guides/whatsapp-setup.md +282 -0
- package/docs/runbooks/mac-mini-bootstrap.md +21 -0
- package/package.json +2 -1
- package/plugins/maestro-skills/plugin.json +16 -0
- package/plugins/maestro-skills/skills/agents-observe.md +110 -0
- package/plugins/maestro-skills/skills/ccxray-diagnostics.md +91 -0
- package/plugins/maestro-skills/skills/claude-pace.md +61 -0
- package/plugins/maestro-skills/skills/code-review-graph.md +99 -0
- package/scaffold/CLAUDE.md +64 -0
- package/scaffold/config/agent.ts.example +2 -1
- package/scaffold/config/caller-id-map.yaml +46 -0
- package/scaffold/config/known-agents.json +35 -0
- package/scripts/daemon/classifier.mjs +264 -50
- package/scripts/daemon/dispatcher.mjs +109 -5
- package/scripts/daemon/launchd-wrapper-generic.sh +96 -0
- package/scripts/daemon/launchd-wrapper-slack-events.sh +37 -0
- package/scripts/daemon/launchd-wrapper.sh +91 -0
- package/scripts/daemon/lib/session-router.mjs +274 -0
- package/scripts/daemon/lib/session-router.test.mjs +295 -0
- package/scripts/daemon/prompt-builder.mjs +51 -11
- package/scripts/daemon/responder.mjs +234 -19
- package/scripts/daemon/session-lock.mjs +194 -0
- package/scripts/daemon/sophie-daemon.mjs +16 -2
- package/scripts/email-signature.html +20 -4
- package/scripts/local-triggers/generate-plists.sh +62 -10
- package/scripts/media-generation/README.md +2 -0
- package/scripts/pdf-generation/README.md +2 -0
- package/scripts/poller/imap-client.mjs +4 -2
- package/scripts/poller/slack-poller.mjs +126 -59
- package/scripts/poller/trigger.mjs +12 -1
- package/scripts/setup/init-agent.sh +91 -1
- package/scripts/setup/install-dev-tools.sh +150 -0
- package/scripts/spawn-session.sh +21 -6
- package/workflows/continuous/backlog-executor.yaml +141 -0
- package/workflows/daily/evening-wrap.yaml +41 -1
- package/workflows/daily/morning-brief.yaml +17 -0
- package/workflows/event-driven/agent-failure-investigation.yaml +137 -0
- package/workflows/event-driven/pr-review.yaml +104 -0
- package/workflows/weekly/engineering-health.yaml +154 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# install-dev-tools.sh — Install and configure approved dev tooling for Maestro agents
|
|
3
|
+
#
|
|
4
|
+
# Approved tools (audited 2026-04-18 from #dev-tooling channel):
|
|
5
|
+
# - claude-pace — Rate limit status line tracker (Bash plugin)
|
|
6
|
+
# - agents-observe — Multi-agent observability dashboard (CC plugin)
|
|
7
|
+
# - ccxray — Claude Code token/cost observability proxy
|
|
8
|
+
# - ClawTeam — Git worktree swarm orchestrator (CLI)
|
|
9
|
+
# - code-review-graph — Tree-sitter codebase knowledge graph (MCP)
|
|
10
|
+
#
|
|
11
|
+
# Skipped:
|
|
12
|
+
# - Superset — GUI-only, Elastic License v2, not automatable
|
|
13
|
+
# - claudraband — Evaluate later; overlaps with maestro session mgmt
|
|
14
|
+
#
|
|
15
|
+
# Usage: ./scripts/setup/install-dev-tools.sh [--all | --tool <name>]
|
|
16
|
+
# Examples:
|
|
17
|
+
# ./scripts/setup/install-dev-tools.sh --all
|
|
18
|
+
# ./scripts/setup/install-dev-tools.sh --tool claude-pace
|
|
19
|
+
# ./scripts/setup/install-dev-tools.sh --tool ccxray
|
|
20
|
+
|
|
21
|
+
set -e
|
|
22
|
+
|
|
23
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
24
|
+
AGENT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
25
|
+
|
|
26
|
+
# ── Helpers ──────────────────────────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
info() { echo " [INFO] $1"; }
|
|
29
|
+
ok() { echo " [OK] $1"; }
|
|
30
|
+
skip() { echo " [SKIP] $1"; }
|
|
31
|
+
fail() { echo " [FAIL] $1" >&2; }
|
|
32
|
+
|
|
33
|
+
# ── Tool installers ─────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
install_claude_pace() {
|
|
36
|
+
info "Installing claude-pace (rate limit status line tracker)..."
|
|
37
|
+
if command -v claude >/dev/null 2>&1; then
|
|
38
|
+
# Install as Claude Code plugin
|
|
39
|
+
claude plugin install claude-pace 2>/dev/null && ok "claude-pace plugin installed" || {
|
|
40
|
+
info "Plugin install failed, trying npx setup..."
|
|
41
|
+
npx claude-pace setup 2>/dev/null && ok "claude-pace configured via npx" || skip "claude-pace: manual setup needed — see https://github.com/Astro-Han/claude-pace"
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
skip "claude-pace: Claude Code CLI not found"
|
|
45
|
+
fi
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
install_agents_observe() {
|
|
49
|
+
info "Installing agents-observe (multi-agent observability dashboard)..."
|
|
50
|
+
if command -v claude >/dev/null 2>&1; then
|
|
51
|
+
claude plugin install agents-observe 2>/dev/null && ok "agents-observe plugin installed" || {
|
|
52
|
+
info "Plugin install failed, trying npm global..."
|
|
53
|
+
npm install -g agents-observe 2>/dev/null && ok "agents-observe installed globally" || skip "agents-observe: manual setup needed — see https://github.com/simple10/agents-observe"
|
|
54
|
+
}
|
|
55
|
+
else
|
|
56
|
+
skip "agents-observe: Claude Code CLI not found"
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
install_ccxray() {
|
|
61
|
+
info "Installing ccxray (Claude Code token/cost observability)..."
|
|
62
|
+
# ccxray is zero-install via npx — just verify it's accessible
|
|
63
|
+
if npx ccxray --version >/dev/null 2>&1; then
|
|
64
|
+
ok "ccxray available via npx"
|
|
65
|
+
else
|
|
66
|
+
info "ccxray will be available via: npx ccxray claude"
|
|
67
|
+
ok "ccxray: zero-install, run with 'npx ccxray claude' when needed"
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Create a convenience wrapper
|
|
71
|
+
cat > "$AGENT_DIR/scripts/ccxray-session.sh" << 'WRAPPER'
|
|
72
|
+
#!/bin/bash
|
|
73
|
+
# Launch Claude Code through ccxray observability proxy
|
|
74
|
+
# Usage: ./scripts/ccxray-session.sh [claude args...]
|
|
75
|
+
exec npx ccxray claude "$@"
|
|
76
|
+
WRAPPER
|
|
77
|
+
chmod +x "$AGENT_DIR/scripts/ccxray-session.sh"
|
|
78
|
+
ok "Created scripts/ccxray-session.sh convenience wrapper"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
install_clawteam() {
|
|
82
|
+
info "Installing ClawTeam (git worktree swarm orchestrator)..."
|
|
83
|
+
if command -v pip3 >/dev/null 2>&1; then
|
|
84
|
+
pip3 install clawteam 2>/dev/null && ok "ClawTeam installed via pip" || {
|
|
85
|
+
info "pip install failed, trying git clone..."
|
|
86
|
+
if [ ! -d "$HOME/.clawteam" ]; then
|
|
87
|
+
git clone https://github.com/win4r/ClawTeam-OpenClaw.git "$HOME/.clawteam" 2>/dev/null && ok "ClawTeam cloned to ~/.clawteam" || skip "ClawTeam: manual setup needed — see https://github.com/win4r/ClawTeam-OpenClaw"
|
|
88
|
+
else
|
|
89
|
+
ok "ClawTeam already present at ~/.clawteam"
|
|
90
|
+
fi
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
skip "ClawTeam: pip3 not found"
|
|
94
|
+
fi
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
install_code_review_graph() {
|
|
98
|
+
info "Installing code-review-graph (Tree-sitter codebase knowledge graph)..."
|
|
99
|
+
if npx code-review-graph --version >/dev/null 2>&1; then
|
|
100
|
+
ok "code-review-graph available via npx"
|
|
101
|
+
else
|
|
102
|
+
npm install -g code-review-graph 2>/dev/null && ok "code-review-graph installed globally" || {
|
|
103
|
+
info "code-review-graph: available via npx when needed"
|
|
104
|
+
ok "Run with: npx code-review-graph"
|
|
105
|
+
}
|
|
106
|
+
fi
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# ── Main ─────────────────────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
echo "=========================================="
|
|
112
|
+
echo " Maestro Dev Tooling Installer"
|
|
113
|
+
echo " Agent dir: $AGENT_DIR"
|
|
114
|
+
echo "=========================================="
|
|
115
|
+
echo ""
|
|
116
|
+
|
|
117
|
+
TOOL="${2:-}"
|
|
118
|
+
case "${1:-}" in
|
|
119
|
+
--all)
|
|
120
|
+
install_claude_pace
|
|
121
|
+
install_agents_observe
|
|
122
|
+
install_ccxray
|
|
123
|
+
install_clawteam
|
|
124
|
+
install_code_review_graph
|
|
125
|
+
;;
|
|
126
|
+
--tool)
|
|
127
|
+
case "$TOOL" in
|
|
128
|
+
claude-pace) install_claude_pace ;;
|
|
129
|
+
agents-observe) install_agents_observe ;;
|
|
130
|
+
ccxray) install_ccxray ;;
|
|
131
|
+
clawteam) install_clawteam ;;
|
|
132
|
+
code-review-graph) install_code_review_graph ;;
|
|
133
|
+
*) echo "Unknown tool: $TOOL"; echo "Available: claude-pace, agents-observe, ccxray, clawteam, code-review-graph"; exit 1 ;;
|
|
134
|
+
esac
|
|
135
|
+
;;
|
|
136
|
+
*)
|
|
137
|
+
echo "Usage: $0 [--all | --tool <name>]"
|
|
138
|
+
echo ""
|
|
139
|
+
echo "Available tools:"
|
|
140
|
+
echo " claude-pace — Rate limit status line tracker"
|
|
141
|
+
echo " agents-observe — Multi-agent observability dashboard"
|
|
142
|
+
echo " ccxray — Token/cost observability proxy"
|
|
143
|
+
echo " clawteam — Git worktree swarm orchestrator"
|
|
144
|
+
echo " code-review-graph — Tree-sitter codebase knowledge graph"
|
|
145
|
+
exit 0
|
|
146
|
+
;;
|
|
147
|
+
esac
|
|
148
|
+
|
|
149
|
+
echo ""
|
|
150
|
+
echo "Done. See docs/guides/dev-tooling.md for usage details."
|
package/scripts/spawn-session.sh
CHANGED
|
@@ -67,16 +67,31 @@ YAML
|
|
|
67
67
|
echo "[$TIMESTAMP] Spawning session $SESSION_ID (budget: ${TIME_BUDGET}s)" | tee -a "$LOG_FILE"
|
|
68
68
|
|
|
69
69
|
# Spawn Claude Code session in background with timeout
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
# Supports two backends:
|
|
71
|
+
# MAESTRO_SESSION_BACKEND=claude (default) — direct claude -p
|
|
72
|
+
# MAESTRO_SESSION_BACKEND=claudraband — persistent sessions via claudraband daemon
|
|
73
|
+
SESSION_BACKEND="${MAESTRO_SESSION_BACKEND:-claude}"
|
|
74
|
+
|
|
75
|
+
SESSION_PROMPT="$TASK_CONTENT
|
|
72
76
|
|
|
73
|
-
IMPORTANT: You are a sub-session spawned
|
|
77
|
+
IMPORTANT: You are a sub-session spawned for an Adaptic AI agent.
|
|
74
78
|
Write your output to: $SESSION_DIR/output.md
|
|
75
79
|
When complete, write 'DONE' to: $SESSION_DIR/complete
|
|
76
80
|
Working directory: $SOPHIE_AI_DIR
|
|
77
|
-
Do NOT send any communications. Only produce the requested output."
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
Do NOT send any communications. Only produce the requested output."
|
|
82
|
+
|
|
83
|
+
(
|
|
84
|
+
if [ "$SESSION_BACKEND" = "claudraband" ]; then
|
|
85
|
+
# Use claudraband for persistent, resumable sessions
|
|
86
|
+
timeout "$TIME_BUDGET" npx @halfwhey/claudraband "$SESSION_PROMPT" \
|
|
87
|
+
--output-format text \
|
|
88
|
+
>> "$LOG_FILE" 2>&1
|
|
89
|
+
else
|
|
90
|
+
# Default: direct claude -p
|
|
91
|
+
timeout "$TIME_BUDGET" claude -p "$SESSION_PROMPT" \
|
|
92
|
+
--output-format text \
|
|
93
|
+
>> "$LOG_FILE" 2>&1
|
|
94
|
+
fi
|
|
80
95
|
|
|
81
96
|
EXIT_CODE=$?
|
|
82
97
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Backlog Executor — Continuous Execution Loop
|
|
2
|
+
# Runs every 10 minutes via launchd
|
|
3
|
+
# This is the "getting shit done" engine — items move from open → resolved → closed
|
|
4
|
+
|
|
5
|
+
name: backlog-executor
|
|
6
|
+
type: continuous
|
|
7
|
+
schedule: "*/10 * * * *"
|
|
8
|
+
timezone: Asia/Dubai
|
|
9
|
+
description: >
|
|
10
|
+
The core execution engine. Every 10 minutes: check quota, read all queues,
|
|
11
|
+
select top actionable items, spawn parallel agents to execute, review results,
|
|
12
|
+
update queues. Items continuously move forward — not sitting in queues.
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
# ── Gate: Check API quota before spawning agents ──
|
|
16
|
+
- id: quota-gate
|
|
17
|
+
skill: claude-pace
|
|
18
|
+
action: check-quota-headroom
|
|
19
|
+
description: >
|
|
20
|
+
Check Claude API rate limit quota before spawning parallel agents.
|
|
21
|
+
Determines execution batch size based on pace delta zone.
|
|
22
|
+
timeout: 30
|
|
23
|
+
outputs:
|
|
24
|
+
pace_delta: green|yellow|red
|
|
25
|
+
max_parallel_agents: 5|2|1
|
|
26
|
+
recommendation: proceed|reduce|critical-only
|
|
27
|
+
on_result:
|
|
28
|
+
green:
|
|
29
|
+
max_parallel: 5
|
|
30
|
+
include_improvement_backlog: true
|
|
31
|
+
yellow:
|
|
32
|
+
max_parallel: 2
|
|
33
|
+
include_improvement_backlog: false
|
|
34
|
+
red:
|
|
35
|
+
max_parallel: 1
|
|
36
|
+
include_improvement_backlog: false
|
|
37
|
+
skip_non_critical: true
|
|
38
|
+
|
|
39
|
+
# ── Read all queues and select actionable items ──
|
|
40
|
+
- id: queue-scan
|
|
41
|
+
agent: pmo-execution
|
|
42
|
+
action: scan-all-queues
|
|
43
|
+
description: Read all 15 operational queues, select top actionable items by priority
|
|
44
|
+
timeout: 120
|
|
45
|
+
depends_on: [quota-gate]
|
|
46
|
+
inputs:
|
|
47
|
+
queues_dir: state/queues/
|
|
48
|
+
max_items: "{quota-gate.outputs.max_parallel_agents}"
|
|
49
|
+
include_improvement_backlog: "{quota-gate.outputs.on_result.include_improvement_backlog}"
|
|
50
|
+
status_filter: [open, in_progress, blocked]
|
|
51
|
+
sort_by: [priority, sla_deadline, created_at]
|
|
52
|
+
outputs:
|
|
53
|
+
selected_items: []
|
|
54
|
+
queue_summary: {}
|
|
55
|
+
|
|
56
|
+
# ── Spawn parallel execution agents ──
|
|
57
|
+
- id: parallel-execution
|
|
58
|
+
agent: session-spawner
|
|
59
|
+
action: spawn-execution-agents
|
|
60
|
+
description: >
|
|
61
|
+
Spawn one background agent per selected item. Each agent gets full context
|
|
62
|
+
and executes independently. Quota-gated parallelism.
|
|
63
|
+
timeout: 1800 # 30 minutes max for the batch
|
|
64
|
+
depends_on: [queue-scan]
|
|
65
|
+
inputs:
|
|
66
|
+
items: "{queue-scan.outputs.selected_items}"
|
|
67
|
+
max_concurrent: "{quota-gate.outputs.max_parallel_agents}"
|
|
68
|
+
mode: background
|
|
69
|
+
outputs:
|
|
70
|
+
agent_sessions: []
|
|
71
|
+
results: []
|
|
72
|
+
|
|
73
|
+
# ── Monitor running agents (if agents-observe is active) ──
|
|
74
|
+
- id: agent-monitoring
|
|
75
|
+
skill: agents-observe
|
|
76
|
+
action: monitor-parallel-execution
|
|
77
|
+
description: >
|
|
78
|
+
Monitor spawned agents for failures, hangs, or resource contention.
|
|
79
|
+
Only runs if agents-observe dashboard is active — otherwise skipped.
|
|
80
|
+
timeout: 60
|
|
81
|
+
depends_on: [parallel-execution]
|
|
82
|
+
optional: true # Skip if agents-observe is not running
|
|
83
|
+
inputs:
|
|
84
|
+
session_ids: "{parallel-execution.outputs.agent_sessions}"
|
|
85
|
+
check_for: [hung_agents, error_patterns, resource_contention]
|
|
86
|
+
outputs:
|
|
87
|
+
health_report: {}
|
|
88
|
+
failed_agents: []
|
|
89
|
+
|
|
90
|
+
# ── Review results and update queues ──
|
|
91
|
+
- id: results-review
|
|
92
|
+
agent: pmo-execution
|
|
93
|
+
action: review-execution-results
|
|
94
|
+
description: >
|
|
95
|
+
Review agent outputs, update queue item statuses, mark completed items
|
|
96
|
+
as resolved, flag failures for investigation.
|
|
97
|
+
timeout: 120
|
|
98
|
+
depends_on: [parallel-execution, agent-monitoring]
|
|
99
|
+
inputs:
|
|
100
|
+
results: "{parallel-execution.outputs.results}"
|
|
101
|
+
health_report: "{agent-monitoring.outputs.health_report}"
|
|
102
|
+
failed_agents: "{agent-monitoring.outputs.failed_agents}"
|
|
103
|
+
outputs:
|
|
104
|
+
items_resolved: []
|
|
105
|
+
items_failed: []
|
|
106
|
+
items_requeued: []
|
|
107
|
+
|
|
108
|
+
# ── Update executive summary ──
|
|
109
|
+
- id: dashboard-update
|
|
110
|
+
agent: pmo-execution
|
|
111
|
+
action: update-executive-summary
|
|
112
|
+
description: Refresh executive summary dashboard with cycle results
|
|
113
|
+
timeout: 60
|
|
114
|
+
depends_on: [results-review]
|
|
115
|
+
inputs:
|
|
116
|
+
resolved: "{results-review.outputs.items_resolved}"
|
|
117
|
+
failed: "{results-review.outputs.items_failed}"
|
|
118
|
+
requeued: "{results-review.outputs.items_requeued}"
|
|
119
|
+
dashboard: state/dashboards/executive-summary.yaml
|
|
120
|
+
|
|
121
|
+
# ── Log cycle ──
|
|
122
|
+
- id: cycle-log
|
|
123
|
+
action: log
|
|
124
|
+
description: Append cycle summary to backlog executor log
|
|
125
|
+
depends_on: [dashboard-update]
|
|
126
|
+
inputs:
|
|
127
|
+
file: logs/workflows/{date}-backlog-executor.jsonl
|
|
128
|
+
data:
|
|
129
|
+
cycle_time: "{timestamp}"
|
|
130
|
+
pace_delta: "{quota-gate.outputs.pace_delta}"
|
|
131
|
+
items_selected: "{queue-scan.outputs.selected_items.length}"
|
|
132
|
+
items_resolved: "{results-review.outputs.items_resolved.length}"
|
|
133
|
+
items_failed: "{results-review.outputs.items_failed.length}"
|
|
134
|
+
|
|
135
|
+
on_failure:
|
|
136
|
+
action: log-and-notify
|
|
137
|
+
message: "Backlog executor cycle failed at step {failed_step}"
|
|
138
|
+
notify: sophie-chief-of-staff
|
|
139
|
+
severity: high
|
|
140
|
+
# If quota-gate fails, the entire cycle is skipped — this is by design
|
|
141
|
+
quota_gate_failure: skip_cycle
|
|
@@ -41,18 +41,58 @@ steps:
|
|
|
41
41
|
outputs:
|
|
42
42
|
file: outputs/briefs/daily/{date}/still-open.md
|
|
43
43
|
|
|
44
|
+
# ── Daily agent performance summary via agents-observe ──
|
|
45
|
+
- id: agent-performance-summary
|
|
46
|
+
skill: agents-observe
|
|
47
|
+
action: daily-performance-summary
|
|
48
|
+
description: >
|
|
49
|
+
Summarise today's agent execution — sessions run, items completed,
|
|
50
|
+
failures, and total token spend. Feeds into the evening wrap so
|
|
51
|
+
the CEO sees system operational health alongside business outcomes.
|
|
52
|
+
timeout: 120
|
|
53
|
+
parallel_with: still-open
|
|
54
|
+
inputs:
|
|
55
|
+
time_range: today
|
|
56
|
+
metrics:
|
|
57
|
+
- sessions_count
|
|
58
|
+
- items_resolved
|
|
59
|
+
- items_failed
|
|
60
|
+
- total_duration
|
|
61
|
+
- failure_details
|
|
62
|
+
outputs:
|
|
63
|
+
file: outputs/briefs/daily/{date}/agent-performance.md
|
|
64
|
+
summary:
|
|
65
|
+
sessions_today: 0
|
|
66
|
+
items_resolved: 0
|
|
67
|
+
items_failed: 0
|
|
68
|
+
total_agent_hours: ""
|
|
69
|
+
|
|
70
|
+
# ── EOD quota status via claude-pace ──
|
|
71
|
+
- id: eod-quota-status
|
|
72
|
+
skill: claude-pace
|
|
73
|
+
action: eod-quota-check
|
|
74
|
+
description: Report end-of-day quota position for overnight capacity planning
|
|
75
|
+
timeout: 30
|
|
76
|
+
parallel_with: still-open
|
|
77
|
+
outputs:
|
|
78
|
+
pace_delta: green|yellow|red
|
|
79
|
+
overnight_capacity_note: ""
|
|
80
|
+
|
|
44
81
|
- id: synthesise-wrap
|
|
45
82
|
agent: ceo-briefing
|
|
46
83
|
action: produce-evening-wrap
|
|
47
84
|
description: Produce the evening wrap document
|
|
48
85
|
timeout: 300
|
|
49
|
-
depends_on: [completed-today, comms-review, still-open]
|
|
86
|
+
depends_on: [completed-today, comms-review, still-open, agent-performance-summary, eod-quota-status]
|
|
50
87
|
inputs:
|
|
51
88
|
morning_brief: outputs/briefs/daily/{date}/ceo-morning-brief.md
|
|
89
|
+
agent_performance: "{agent-performance-summary.outputs.summary}"
|
|
90
|
+
quota_status: "{eod-quota-status.outputs}"
|
|
52
91
|
components:
|
|
53
92
|
- outputs/briefs/daily/{date}/completed-today.md
|
|
54
93
|
- outputs/briefs/daily/{date}/comms-review.md
|
|
55
94
|
- outputs/briefs/daily/{date}/still-open.md
|
|
95
|
+
- outputs/briefs/daily/{date}/agent-performance.md
|
|
56
96
|
outputs:
|
|
57
97
|
file: outputs/briefs/daily/{date}/ceo-evening-wrap.md
|
|
58
98
|
|
|
@@ -11,11 +11,26 @@ description: >
|
|
|
11
11
|
|
|
12
12
|
# Workflow steps execute sequentially
|
|
13
13
|
steps:
|
|
14
|
+
# ── System health gate — check API quota before the day's workload ──
|
|
15
|
+
- id: quota-status
|
|
16
|
+
skill: claude-pace
|
|
17
|
+
action: morning-quota-check
|
|
18
|
+
description: >
|
|
19
|
+
Check overnight quota consumption and current headroom. Reports pace
|
|
20
|
+
delta zone so the morning brief can flag capacity constraints early.
|
|
21
|
+
timeout: 30
|
|
22
|
+
outputs:
|
|
23
|
+
pace_delta: green|yellow|red
|
|
24
|
+
five_hour_pct: 0
|
|
25
|
+
seven_day_pct: 0
|
|
26
|
+
capacity_note: "" # included in the morning brief if yellow/red
|
|
27
|
+
|
|
14
28
|
- id: market-sweep
|
|
15
29
|
agent: market-research
|
|
16
30
|
action: overnight-market-summary
|
|
17
31
|
description: Gather overnight market movements, key indices, relevant asset class performance
|
|
18
32
|
timeout: 300 # 5 minutes
|
|
33
|
+
parallel_with: quota-status
|
|
19
34
|
inputs:
|
|
20
35
|
scope: [equities, crypto, forex, fixed-income]
|
|
21
36
|
regions: [us, emea, apac]
|
|
@@ -105,6 +120,7 @@ steps:
|
|
|
105
120
|
timeout: 300
|
|
106
121
|
depends_on:
|
|
107
122
|
[
|
|
123
|
+
quota-status,
|
|
108
124
|
market-sweep,
|
|
109
125
|
news-intelligence,
|
|
110
126
|
comms-triage,
|
|
@@ -114,6 +130,7 @@ steps:
|
|
|
114
130
|
calendar-review,
|
|
115
131
|
]
|
|
116
132
|
inputs:
|
|
133
|
+
quota_status: "{quota-status.outputs}" # included as system health section
|
|
117
134
|
components:
|
|
118
135
|
- outputs/briefs/daily/{date}/market-sweep.md
|
|
119
136
|
- outputs/briefs/daily/{date}/news-intelligence.md
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Agent Failure Investigation
|
|
2
|
+
# Event-driven — triggered when a backlog executor agent fails or hangs
|
|
3
|
+
# Uses agents-observe for session analysis and ccxray for token diagnostics
|
|
4
|
+
|
|
5
|
+
name: agent-failure-investigation
|
|
6
|
+
type: event-driven
|
|
7
|
+
trigger:
|
|
8
|
+
event: agent_failure
|
|
9
|
+
source: backlog-executor # or any workflow that spawns agents
|
|
10
|
+
conditions:
|
|
11
|
+
- agent_exit_code: non-zero
|
|
12
|
+
- agent_timeout: exceeded
|
|
13
|
+
- agent_output: error_pattern
|
|
14
|
+
description: >
|
|
15
|
+
Automated post-mortem when an agent fails. Pulls the full session trace
|
|
16
|
+
via agents-observe, analyses token/cost via ccxray logs, determines root
|
|
17
|
+
cause, and recommends remediation. Prevents recurring failures.
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
# ── Pull session trace via agents-observe ──
|
|
21
|
+
- id: session-trace
|
|
22
|
+
skill: agents-observe
|
|
23
|
+
action: query-failed-session
|
|
24
|
+
description: >
|
|
25
|
+
Retrieve the full tool call sequence, timing data, and error state
|
|
26
|
+
for the failed agent session. Identify the last successful action
|
|
27
|
+
before failure.
|
|
28
|
+
timeout: 120
|
|
29
|
+
inputs:
|
|
30
|
+
session_id: "{trigger.session_id}"
|
|
31
|
+
agent_name: "{trigger.agent_name}"
|
|
32
|
+
query:
|
|
33
|
+
- full_tool_call_sequence
|
|
34
|
+
- last_successful_tool
|
|
35
|
+
- error_message
|
|
36
|
+
- timing_breakdown
|
|
37
|
+
- resource_state_at_failure
|
|
38
|
+
outputs:
|
|
39
|
+
file: outputs/investigations/{date}/{session_id}/session-trace.md
|
|
40
|
+
summary:
|
|
41
|
+
last_successful_tool: ""
|
|
42
|
+
error_type: "" # timeout|rate_limit|permission|context_overflow|unknown
|
|
43
|
+
duration_before_failure: ""
|
|
44
|
+
tool_call_count: 0
|
|
45
|
+
|
|
46
|
+
# ── Token analysis via ccxray ──
|
|
47
|
+
- id: token-analysis
|
|
48
|
+
skill: ccxray-diagnostics
|
|
49
|
+
action: analyse-failed-session
|
|
50
|
+
description: >
|
|
51
|
+
Check if the failure was token-related — context window overflow,
|
|
52
|
+
excessive input from tool reads, or cost runaway. Cross-reference
|
|
53
|
+
with session trace timing.
|
|
54
|
+
timeout: 120
|
|
55
|
+
parallel_with: session-trace
|
|
56
|
+
inputs:
|
|
57
|
+
session_id: "{trigger.session_id}"
|
|
58
|
+
log_dir: ~/.ccxray/logs/
|
|
59
|
+
checks:
|
|
60
|
+
- context_window_utilisation
|
|
61
|
+
- input_token_spike # large file reads or tool outputs
|
|
62
|
+
- output_token_pattern # repetitive or runaway generation
|
|
63
|
+
- cost_vs_average # compared to similar agent sessions
|
|
64
|
+
outputs:
|
|
65
|
+
file: outputs/investigations/{date}/{session_id}/token-analysis.md
|
|
66
|
+
summary:
|
|
67
|
+
context_peak_pct: 0
|
|
68
|
+
token_anomaly_detected: false
|
|
69
|
+
cost_vs_average: ""
|
|
70
|
+
|
|
71
|
+
# ── Quota state at time of failure ──
|
|
72
|
+
- id: quota-state
|
|
73
|
+
skill: claude-pace
|
|
74
|
+
action: check-quota-at-failure
|
|
75
|
+
description: >
|
|
76
|
+
Determine whether the failure was caused by or correlated with
|
|
77
|
+
API rate limiting. Check pace delta at the time of failure.
|
|
78
|
+
timeout: 30
|
|
79
|
+
parallel_with: session-trace
|
|
80
|
+
inputs:
|
|
81
|
+
timestamp: "{trigger.failure_timestamp}"
|
|
82
|
+
check:
|
|
83
|
+
- was_rate_limited
|
|
84
|
+
- pace_delta_at_time
|
|
85
|
+
- concurrent_sessions_count
|
|
86
|
+
outputs:
|
|
87
|
+
rate_limited: false
|
|
88
|
+
pace_delta: ""
|
|
89
|
+
concurrent_sessions: 0
|
|
90
|
+
|
|
91
|
+
# ── Root cause analysis ──
|
|
92
|
+
- id: root-cause-analysis
|
|
93
|
+
agent: engineering-oversight
|
|
94
|
+
action: determine-root-cause
|
|
95
|
+
description: >
|
|
96
|
+
Synthesise session trace, token analysis, and quota state to determine
|
|
97
|
+
the root cause. Classify the failure and recommend remediation.
|
|
98
|
+
timeout: 300
|
|
99
|
+
depends_on: [session-trace, token-analysis, quota-state]
|
|
100
|
+
inputs:
|
|
101
|
+
session_trace: outputs/investigations/{date}/{session_id}/session-trace.md
|
|
102
|
+
token_analysis: outputs/investigations/{date}/{session_id}/token-analysis.md
|
|
103
|
+
quota_state: "{quota-state.outputs}"
|
|
104
|
+
trigger_context: "{trigger}"
|
|
105
|
+
outputs:
|
|
106
|
+
file: outputs/investigations/{date}/{session_id}/root-cause.md
|
|
107
|
+
classification:
|
|
108
|
+
root_cause: "" # rate_limit|context_overflow|tool_error|prompt_bug|external_service|unknown
|
|
109
|
+
severity: "" # low|medium|high|critical
|
|
110
|
+
recurrence_risk: "" # low|medium|high
|
|
111
|
+
remediation: "" # specific fix recommendation
|
|
112
|
+
|
|
113
|
+
# ── Update tech debt / improvement backlog if systemic ──
|
|
114
|
+
- id: queue-remediation
|
|
115
|
+
agent: pmo-execution
|
|
116
|
+
action: queue-fix-if-systemic
|
|
117
|
+
description: >
|
|
118
|
+
If the root cause indicates a systemic issue (recurrence_risk: high),
|
|
119
|
+
create an item in tech-debt or improvement-backlog queue.
|
|
120
|
+
timeout: 60
|
|
121
|
+
depends_on: [root-cause-analysis]
|
|
122
|
+
condition: "{root-cause-analysis.outputs.classification.recurrence_risk} == high"
|
|
123
|
+
inputs:
|
|
124
|
+
root_cause: outputs/investigations/{date}/{session_id}/root-cause.md
|
|
125
|
+
target_queue: state/queues/tech-debt.yaml
|
|
126
|
+
item:
|
|
127
|
+
title: "Agent failure: {trigger.agent_name} — {root-cause-analysis.outputs.classification.root_cause}"
|
|
128
|
+
priority: high
|
|
129
|
+
source: "auto:agent-failure-investigation"
|
|
130
|
+
|
|
131
|
+
on_failure:
|
|
132
|
+
action: log-and-notify
|
|
133
|
+
message: "Agent failure investigation failed for session {trigger.session_id}"
|
|
134
|
+
notify: sophie-chief-of-staff
|
|
135
|
+
severity: medium
|
|
136
|
+
|
|
137
|
+
final_output: outputs/investigations/{date}/{session_id}/root-cause.md
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# PR Review Workflow
|
|
2
|
+
# Event-driven — triggered when a new PR is opened or updated in a tracked repo
|
|
3
|
+
# Uses code-review-graph for structural analysis before human/agent review
|
|
4
|
+
|
|
5
|
+
name: pr-review
|
|
6
|
+
type: event-driven
|
|
7
|
+
trigger:
|
|
8
|
+
event: pull_request
|
|
9
|
+
actions: [opened, synchronize]
|
|
10
|
+
repos: # from config/repo-registry.yaml
|
|
11
|
+
- adapticai/engine
|
|
12
|
+
- adapticai/backend
|
|
13
|
+
- adapticai/frontend
|
|
14
|
+
- adapticai/maestro
|
|
15
|
+
- adapticai/sophie-ai
|
|
16
|
+
description: >
|
|
17
|
+
Automated PR review pipeline. When a PR is opened or updated, runs structural
|
|
18
|
+
blast radius analysis via code-review-graph, then produces a review brief.
|
|
19
|
+
Engineering agents use this to make informed review decisions.
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
# ── Structural blast radius analysis ──
|
|
23
|
+
- id: blast-radius
|
|
24
|
+
skill: code-review-graph
|
|
25
|
+
action: blast-radius-analysis
|
|
26
|
+
description: >
|
|
27
|
+
Analyse the PR diff through the tree-sitter knowledge graph. Map which
|
|
28
|
+
functions, modules, and entry points are affected by the changes.
|
|
29
|
+
Determine risk level based on dependency depth and consumer count.
|
|
30
|
+
timeout: 300
|
|
31
|
+
inputs:
|
|
32
|
+
repo: "{trigger.repo}"
|
|
33
|
+
pr_number: "{trigger.pr_number}"
|
|
34
|
+
base_branch: "{trigger.base_ref}"
|
|
35
|
+
head_branch: "{trigger.head_ref}"
|
|
36
|
+
analysis:
|
|
37
|
+
- changed_functions
|
|
38
|
+
- direct_dependents
|
|
39
|
+
- transitive_impact
|
|
40
|
+
- affected_entry_points
|
|
41
|
+
- untouched_related_functions # functions that probably should have changed
|
|
42
|
+
outputs:
|
|
43
|
+
file: outputs/reviews/{repo}/{pr_number}/blast-radius.md
|
|
44
|
+
summary:
|
|
45
|
+
risk_level: low|medium|high|critical
|
|
46
|
+
direct_dependents: 0
|
|
47
|
+
transitive_impact: 0
|
|
48
|
+
missing_changes: [] # related functions not in the diff
|
|
49
|
+
|
|
50
|
+
# ── Review context enrichment ──
|
|
51
|
+
- id: review-context
|
|
52
|
+
skill: code-review-graph
|
|
53
|
+
action: review-context
|
|
54
|
+
description: >
|
|
55
|
+
Pull structural context for each changed file — what calls them, what
|
|
56
|
+
they call, hot paths, and critical modules. Provides the reviewer with
|
|
57
|
+
the "why this matters" context for every changed file.
|
|
58
|
+
timeout: 180
|
|
59
|
+
parallel_with: blast-radius
|
|
60
|
+
inputs:
|
|
61
|
+
repo: "{trigger.repo}"
|
|
62
|
+
changed_files: "{trigger.changed_files}"
|
|
63
|
+
outputs:
|
|
64
|
+
file: outputs/reviews/{repo}/{pr_number}/review-context.md
|
|
65
|
+
|
|
66
|
+
# ── Produce review brief ──
|
|
67
|
+
- id: review-brief
|
|
68
|
+
agent: engineering-oversight
|
|
69
|
+
action: produce-pr-review-brief
|
|
70
|
+
description: >
|
|
71
|
+
Synthesise blast radius and review context into a concise review brief.
|
|
72
|
+
Highlights risk areas, suggests review focus, and flags missing changes.
|
|
73
|
+
timeout: 180
|
|
74
|
+
depends_on: [blast-radius, review-context]
|
|
75
|
+
inputs:
|
|
76
|
+
blast_radius: outputs/reviews/{repo}/{pr_number}/blast-radius.md
|
|
77
|
+
review_context: outputs/reviews/{repo}/{pr_number}/review-context.md
|
|
78
|
+
pr_metadata:
|
|
79
|
+
repo: "{trigger.repo}"
|
|
80
|
+
pr_number: "{trigger.pr_number}"
|
|
81
|
+
author: "{trigger.author}"
|
|
82
|
+
title: "{trigger.title}"
|
|
83
|
+
outputs:
|
|
84
|
+
file: outputs/reviews/{repo}/{pr_number}/review-brief.md
|
|
85
|
+
|
|
86
|
+
# ── Post review brief as PR comment ──
|
|
87
|
+
- id: post-review
|
|
88
|
+
agent: github-operator
|
|
89
|
+
action: post-pr-comment
|
|
90
|
+
description: Post the review brief as a PR comment for the reviewer
|
|
91
|
+
depends_on: [review-brief]
|
|
92
|
+
inputs:
|
|
93
|
+
repo: "{trigger.repo}"
|
|
94
|
+
pr_number: "{trigger.pr_number}"
|
|
95
|
+
content: outputs/reviews/{repo}/{pr_number}/review-brief.md
|
|
96
|
+
format: markdown
|
|
97
|
+
|
|
98
|
+
on_failure:
|
|
99
|
+
action: log-and-notify
|
|
100
|
+
message: "PR review workflow failed for {trigger.repo}#{trigger.pr_number} at step {failed_step}"
|
|
101
|
+
notify: sophie-chief-of-staff
|
|
102
|
+
severity: low # PR review failure is inconvenient but not critical
|
|
103
|
+
|
|
104
|
+
final_output: outputs/reviews/{repo}/{pr_number}/review-brief.md
|