Feat/kiro cli executor with tool usage#330
Open
perezjoseph wants to merge 6 commits into
Open
Conversation
- Add Claude SDK and Kiro CLI executor implementations with comprehensive test coverage - Create executor interface abstraction for pluggable AI backend support - Implement container and preflight service tests for reliability validation - Add vitest configuration for worker package testing - Extend environment variable forwarding for AWS credentials and Kiro API configuration - Add SHANNON_EXECUTOR_BACKEND mode detection supporting kiro-cli backend - Create .kiro/agents directory structure for agent definitions mount point - Add kiro-cli binary installation to Docker build with Go security tool configuration - Mount kiro-agents workspace overlay for writable agent definitions in containers - Update .gitignore to exclude .kiro and .vscode directories - Add licenses.txt documentation file - Update dependencies in pnpm-lock.yaml
…obal agent directory - Update agent JSON prompt paths to use relative file:// URIs (file://./ prefix) - Write agents to global ~/.kiro/agents/ directory for reliable kiro-cli resolution - Add best-effort fallback writes to project-level .kiro/agents/ for host-side visibility - Change verify-queue-file output extension from .js to .mjs - Remove unused execSync import from kiro-cli-executor - Add cpSync import for potential file operations - Update generateAgentJson to handle both global and project directories with retry logic - Update generateQueueValidationHooks to write to global directory with project fallback - Add detailed comments explaining Docker bind-mount strategy and agent resolution
…output - Update CREDITS_PATTERN regex to match both "Credits used:" and "▸ Credits:" formats - Rename extractCreditsUsed parameter from stdout to text for clarity - Check stderr first for credits output, then fall back to stdout - Enhance JSDoc to document kiro-cli's stderr credit format and accepted patterns - Handle kiro-cli's new credit output format in stderr with bullet point prefix
- Add optional onHeartbeat callback to ExecutorOptions interface for orchestrator liveness signaling - Implement heartbeat loop in spawnKiroCli that emits elapsed time and process ID every 30 seconds - Pass onHeartbeat callback through agent execution pipeline from Temporal activities to CLI executor - Clean up heartbeat timer on process completion to prevent resource leaks - Prevents Temporal heartbeat starvation when multiple kiro-cli subprocesses saturate the event loop with I/O callbacks
# Conflicts: # jpilier/week1/shannon/Dockerfile # jpilier/week1/shannon/apps/cli/src/env.ts # jpilier/week1/shannon/apps/worker/src/services/preflight.ts # jpilier/week1/shannon/apps/worker/src/temporal/activities.ts # jpilier/week1/shannon/pnpm-lock.yaml
- Install kiro-cli binary in Docker image for headless mode execution - Add SHANNON_EXECUTOR_BACKEND and KIRO_API_KEY environment variables - Implement credential validation for kiro-cli backend mode - Exclude conflicting provider variables when using kiro-cli backend - Add ToolUsageSummary type and tool invocation tracking to ClaudePromptResult - Implement KiroCliExecutor with tool usage logging via pre/post-tool hooks - Add mergeHooks utility to combine multiple hook configurations - Implement readAndLogToolUsage to parse and aggregate tool execution metrics - Add generateToolUsageLoggerScript to create hook scripts for tool tracking - Update metrics tracking to record tool usage events with timestamps and duration - Extend audit logging to capture tool invocation details and performance data - Add comprehensive test coverage for hook merging and tool usage extraction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add Kiro CLI executor backend with tool usage logging
Summary
Adds a new executor backend (
kiro-cli) that runs Shannon agents via the Kiro CLI in headless mode, as an alternative to the Claude Agent SDK. Includes per-invocation tool usage tracking exposed through a Temporal workflow query.Changes
Kiro CLI Executor (
apps/worker/src/ai/kiro-cli-executor.ts).kiro/agents/<name>.jsonwith model, prompt, MCP servers, and hooksTool Usage Tracking
~/.kiro/agents/tool-usage.jsonlreadAndLogToolUsage()parses JSONL and returns both summary and per-invocation recordsgetToolUsageaccepts optionaldetailedboolean arg:false(default): returnsRecord<string, ToolUsageSummaryMetrics>(counts, failures)true: returnsRecord<string, DetailedToolUsageMetrics>(includesinvocations[]with tool name, timestamp, success)CLI Credential Validation
validateCredentials()now recognizesSHANNON_EXECUTOR_BACKEND=kiro-cliand only requiresKIRO_API_KEYbuildEnvFlags()excludes conflicting Bedrock/Vertex env vars when kiro-cli backend is activepreflight.ts) has matching kiro-cli bypassDockerfile
kiro-clibinary in builder stage via official installerInfrastructure
~/.kiro/agents/) used for writable hook scripts inside Docker (repo mounted:ro)Configuration
# .env SHANNON_EXECUTOR_BACKEND=kiro-cli KIRO_API_KEY=ksk_your_key_hereQuerying Tool Usage (Temporal)
Testing
getToolUsagequery returns correct data in both summary and detailed modespnpm run build,pnpm run check)