Repository navigation
feat: first-class Kiro CLI executor on its subscription login - #4
Merged
Merged
Conversation
CLIs on a subscription (Kiro CLI) bill in credits instead of tokens, so their runs and chats showed no usage at all. TokenUsage gains Credits: - the stream adapter parses usage.credits; ClaudeStream.SetCredits puts it on the result line for translated agent CLIs - the engine accumulates it per session cursor like tokens and emits a credits metric - chat turns, conversation workspaces and the analytics summary (totalCredits) add it up; the run panel shows it next to cost Credits are never priced into CostUSD.
An MCP entry without arguments, such as the gate server, carries a nil []string. Stored in a map[string]any it is not nil as an interface, so the agent CLI MCP writers emitted "args": null. Kiro CLI drops such a server without an error, so a node never saw submit_gate_result and waited until it timed out. mcpValueSet checks for typed nils in every writer (default, OpenCode, DeepSeek Harness).
…ion login Kiro CLI (kind kiro, binary kiro-cli 3.3.0) runs SOP nodes, conversation workspaces and AI chat turns. It authenticates with a machine's `kiro-cli login` subscription, never an API key: - domain.AgentCLIAuthMode pins kiro to local login; runner inventory and SetRunnerRuntimeAuthMode keep it there - argv: `kiro-cli chat --v3 --no-interactive --output-format stream-json`; SOP nodes and workspaces trust all tools, read-only use trusts only read/grep/glob, skill and sub-agent loading (chat adds its MCP servers) - KIRO_HOME moves ~/.kiro (MCP, hooks, agents, sessions) into the private home; without a sandbox HOME stays the machine's own. Every run writes settings/cli.json with toolSearch.enabled false: with tool search on, Kiro hides MCP schemas behind tool_load and models then reported platform tools such as submit_assistant_reply as unavailable - every sandbox (Docker, seatbelt, bwrap), and a platform that mounts the host login read-only (AGENTFLOW_KIRO_DATA_DIR), runs on a copy of only the login (kiro_login.go): auth_kv login rows plus the selected profile, no conversations or history, so no sandboxed agent writes the machine's kiro-cli data. The refresh token does not rotate, so the host stays logged in (verified with IAM Identity Center). Stale session leases are removed and the token refreshed before a turn - process sandboxes share one read-only kiro-cli runtime that the machine unpacks once (EnsureKiroHostRuntime); Docker sandboxes use the image's KIRO_RUNTIME_DIR or unpack per run. An image without kiro-cli uses the execution machine's cached copy in AGENTFLOW_RUNTIME_CLI_DIR (runner default ~/.agentflow-runner/cli), otherwise installs the pinned release with a SHA-256 check - the ACP stream translator maps text, reasoning, tools, sub-agent dispatch (Task) and skill loads (Skill), hides schema loading, and reports credits as the session total (usage.credits, which the engine's per-session cursor splits per SOP invocation) plus this invocation's share (usage.turn_credits) - conversation approval: a global PreToolUse hook in KIRO_HOME/hooks; each conversation start clears KIRO_HOME of everything but sessions, logs, login state and platform-written files, so hooks or permission rules a workspace turn planted cannot load in a later turn. Outside Docker the wrapper never puts HOME on PATH and runs rm by absolute path, and every approval hook runs as `python3 -I`, so an executable or usercustomize.py planted in the persistent HOME cannot run in platform mode either
- kiro is a chat engine with no key. The engine list marks it configured when this server has kiro-cli and a login, or one of the user's execution machines is online with kiro-cli; a turn is never refused up front, since the machine it runs on reports a missing kiro-cli or login itself - read-only trust list names the session MCP servers; workspace mode trusts all tools - chat sums each invocation's credits (usage.turn_credits) rather than the session total an SOP node's cursor needs - project roles become Kiro V3 Markdown agents in KIRO_HOME/agents (Main Bot's own tools in excludedTools, skills as skill:// resources); skills go to KIRO_HOME/skills - native approval accepts Kiro's tool names (mcp_<server>_<tool>, tool_load, disclose_context, invoke_sub_agent) - chatbot: Kiro CLI in the executor switch
- executor picker and SOP run checks list Kiro CLI; the run check reports the kiro-cli login instead of an API key - the execution machine page lists the discovered kiro runtime with a fixed 本机登录(订阅) source, since Kiro cannot use a personal key
- Dockerfile installs kiro-cli 3.3.0 (SHA-256 checked, amd64/arm64) and unpacks its 415 MB runtime once into KIRO_RUNTIME_DIR=/opt/kiro-runtime - compose.yaml mounts LOOPFORGE_KIRO_DATA_DIR read-only at /kiro-host (AGENTFLOW_KIRO_DATA_DIR) so the platform can copy the login - README and docs/deployment.md describe Kiro's subscription login
local.sh with AGENTFLOW_E2E_EXECUTOR=kiro enables the real-model scenarios on this machine's kiro-cli login, without a CodeBuddy key. 40-model takes the assistant model from AGENTFLOW_E2E_ASSISTANT_MODEL, accepts credits as usage and skips run evaluation, which always runs on CodeBuddy.
# Conflicts: # internal/runtime/agent_cli_mcp_null_test.go # internal/runtime/agent_cli_stream.go
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.
动机 / Why
让 Kiro CLI 成为一等执行器,能力与 Codex 对齐:SOP 节点、Main Bot 对话、对话工作区、Docker 沙箱、用量统计都可用。
真实部署使用 订阅登录(
kiro-cli login,IAM Identity Center),不使用KIRO_API_KEY。因此本 PR 的核心问题是:在不泄露、不改写宿主机登录的前提下,把登录交给各种沙箱。Make Kiro CLI a first-class executor on par with Codex: SOP nodes, Main Bot chat, conversation workspaces, Docker sandboxes and usage accounting. Real deployments use the subscription login (
kiro-cli login), never an API key, so the core problem is handing that login to sandboxes without exposing or modifying the host's.改动 / Changes
runtime(
1f441cf)kiro,二进制kiro-cli3.3.0。命令为kiro-cli chat --v3 --no-interactive --output-format stream-json。SOP 节点和工作区使用--trust-all-tools;只读对话只信任 read/grep/glob、skill / sub-agent 加载和会话的 MCP server。domain.AgentCLIAuthMode("kiro")固定为本机登录。runner 上报运行时、修改认证方式时都保持这一点。KIRO_HOME指向私有 HOME,MCP、hooks、agents、sessions 都放在那里。每次运行都写入settings/cli.json,关闭 tool search。开启时 Kiro 会把 MCP schema 藏到tool_load后面,模型曾因此报告submit_assistant_reply不可用。kiro_login.go):凡是沙箱(Docker、seatbelt、bwrap),以及只挂载了宿主登录的平台(AGENTFLOW_KIRO_DATA_DIR),都运行在一份登录副本上。副本用 SQLiteVACUUM INTO生成,只保留auth_kv的kirocli:odic:*行、migrations,以及state中的 profile 和 IdC 设置,不含任何对话和历史。沙箱里的 agent 因此读不到也写不了宿主的 kiro-cli 数据。refresh token 不轮换,副本刷新 access token 不会让宿主掉线(已用 IAM Identity Center 验证)。EnsureKiroHostRuntime),以 kiro-cli 版本作为 key,并在完整性检查通过后才发布。KIRO_RUNTIME_DIR,没有时每次运行解压一次。AGENTFLOW_RUNTIME_CLI_DIR中的缓存;缓存也没有,就在 Docker 内安装固定版本,并校验 SHA-256。--resume-id会被拒绝),并在 prompt 前刷新 token。Docker 之外不把 HOME 下的任何目录放进 PATH,系统工具用绝对路径调用。usage.credits是会话累计,交给 engine 的 per-session cursor 拆分到每次 SOP 调用;usage.turn_credits是本次调用的用量。KIRO_HOME/hooks安装全局 PreToolUse hook。每次对话启动时清理KIRO_HOME,只保留 sessions、logs、登录状态和平台会重写的文件,这样工作区回合植入的 hooks、权限规则、steering 不会在之后的平台模式回合中生效。所有 provider 的审批 hook 改用python3 -I启动,忽略 HOME 中的usercustomize.py和PYTHON*变量。assistant(
cf2a0d2)turn_credits)。KIRO_HOME/agents;skills 写到KIRO_HOME/skills。mcp_<server>_<tool>、tool_load、disclose_context、invoke_sub_agent。web(
d565845)build / docs(
9c30554)KIRO_RUNTIME_DIR=/opt/kiro-runtime。compose.yaml把LOOPFORGE_KIRO_DATA_DIR只读挂载到/kiro-host。docs/deployment.md补充 Kiro 部署说明。e2e(
694e917)local.sh设置AGENTFLOW_E2E_EXECUTOR=kiro后,用本机的 kiro-cli 登录运行真实模型场景,不需要 CodeBuddy key。验证 / Verification
go build ./...和go vet均通过。go test ./... -count=1:没有新增失败(见下方基线)。go test ./web/通过。local.sh:176 tests,157 pass,1 fail,16 skipped。与origin/main结果完全相同,唯一的失败是下面列出的既有失败。api/40-model.test.mjs,claude-haiku-5.5):generic-docker沙箱:6 pass,0 fail,2 skipped。运行时设置了AGENTFLOW_BROWSER=off,因为本机网络下 feat(workspaces): open conversation workspaces by sandbox with agent-owned Git Tencent/LoopForge#947 引入的浏览器 sidecar 镜像构建太慢,与 Kiro 无关。风险与已知限制 / Risks
KIRO_HOME是未公开的环境变量,只在 kiro-cli 3.3.0 上验证过,升级 Kiro 时需要回归。submit_assistant_reply不可用,已通过关闭 tool search 处理。之后的两轮模型 e2e 没有再出现。既有失败 / Pre-existing failures
以下测试在本机(macOS arm64)的
origin/main69e4bf0 上同样失败,与本 PR 无关:These fail on this macOS arm64 machine on
origin/main69e4bf0 as well, independent of this PR:deploy:TestBindCLIReinstallStopsTheRunnerNamedInServicePID,TestBindCLIUninstallSignalsOnlyTheBackgroundRunner,TestBindCLIUninstallStopsARunnerWhoseArgv0IsTheScript,TestBindCLIUninstallStopsTheRunnerNamedInServicePIDinternal/gitwork:TestGitDiscoveryStopsBeforeParentRepositoryinternal/runtime:TestLocalWorkspaceGitDiscoveryCannotReachParent,TestProcessSandboxPathsProfilesAndCommands,TestProjectAgentGitIndexLockWaitStopsOnCancelcmd/agentflow:TestSDNotifySendsReadyAndMainPIDinternal/engine(偶发 / flaky):TestMaterializeConversationWorkspaceStopsAStalledCloneapi/30-runs: "approval gate: reject reworks upstream in the same workspace, approve completes"