Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/system-specs/modules/subagent.md
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,10 @@ made; no gate reads it back. Two consumers:

kiro-cli defines `toolsSettings.subagent.availableAgents` for its own built-in
`subagent` tool: a glob list of the agents an agent may spawn, and **omitting it
allows all**. Kiro Crew's sub-agents come through `spawn_run` /
allows all**. It is read under every sub-agent spelling kiro-cli accepts
(`crew`, `agent_crew`, `agentCrew`, `subagent`, `use_subagent`); as in
kiro-cli, the first one the spec sets wins whole and the rest are ignored
(`spawn_allowlist`, through `canonical_tools_settings`). Kiro Crew's sub-agents come through `spawn_run` /
`spawn_sub_agents` rather than that tool, so the gate honours the same
declaration itself (`subagent._vet_parent_available_agents`, called from
`spawn_impl` right after `_vet_spawn_governance`):
Expand Down
17 changes: 9 additions & 8 deletions src/kiro_crew/acp/kas_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
expand_kiro_cli_tool_exclusions,
expand_kiro_cli_tool_names,
)
from kiro_crew.platform.tools_settings_aliases import as_authored
from kiro_crew.sel import sel
from kiro_crew.user_json import copy_json_document

Expand Down Expand Up @@ -277,19 +278,19 @@ def spec_keys_without_carrier(
lost.append("toolAliases")
if discards_mcp_oauth:
lost.extend(oauth_lost_keys(servers_with_discarded_oauth(spec, _registry_governed)))
tools_settings = spec.get("toolsSettings")
raw = spec.get("toolsSettings")
if not translates_tools_settings:
lost.extend(tools_settings_unapplied(tools_settings))
lost.extend(tools_settings_unapplied(raw))
return sorted(lost)
# kiro-cli reads one spelling per alias group; the dropped ones are named.
tools_settings, dropped = canonical_tools_settings(tools_settings)
# kiro-cli reads one spelling per alias group; each name is the one the spec wrote.
tools_settings, dropped = canonical_tools_settings(raw)
lost.extend(f"toolsSettings.{key}" for key in dropped)
_, not_carried = tools_settings_to_permissions(tools_settings)
lost.extend(f"toolsSettings.{path}" for path in not_carried)
lost.extend(f"toolsSettings.{as_authored(raw, path)}" for path in not_carried)
if spec.get("permissions") is not None and not projection_accepts(spec["permissions"]):
lost.append("permissions")
lost.extend(
f"toolsSettings.{path}"
f"toolsSettings.{as_authored(raw, path)}"
for path in trusted_agents_withheld(tools_settings, may_skip_gate_now)
)
if (
Expand All @@ -301,7 +302,7 @@ def spec_keys_without_carrier(
# Every entry is usable, but the session answers none of them: name each
# shell key that carries one, so the operator learns why they prompt.
lost.extend(
f"toolsSettings.{key}.allowedCommands"
f"toolsSettings.{as_authored(raw, key)}.allowedCommands"
for key in ("execute_bash", "shell")
if isinstance(tools_settings.get(key), dict)
and tools_settings[key].get("allowedCommands")
Expand All @@ -312,7 +313,7 @@ def spec_keys_without_carrier(
and _allowed_commands_withheld(spec, None, tools_settings, "fs_write")
):
lost.extend(
f"toolsSettings.{key}.allowedPaths"
f"toolsSettings.{as_authored(raw, key)}.allowedPaths"
for key in ("fs_write", "write")
if isinstance(tools_settings.get(key), dict) and tools_settings[key].get("allowedPaths")
)
Expand Down
4 changes: 3 additions & 1 deletion src/kiro_crew/agent_sdk/kas_tool_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,11 @@ def tools_settings_unenforced(raw: Any) -> list[str]:
cannot turn into a rule (a regex with no glob form, a URL pattern naming a
path) and an ``allowedCommands`` entry Crew's gate cannot answer are named,
and so is a duplicate alias key kiro-cli drops (``canonical_tools_settings``).
Each entry is named under the spelling *raw* wrote (``aliases.as_authored``).
"""
from kiro_crew.acp import kas_permissions
from kiro_crew.platform import tools_settings_aliases as aliases

settings, dropped = kas_permissions.canonical_tools_settings(raw)
_block, not_carried = kas_permissions.tools_settings_to_permissions(settings)
return sorted(set(not_carried) | set(dropped))
return sorted({aliases.as_authored(raw, path) for path in not_carried} | set(dropped))
27 changes: 17 additions & 10 deletions src/kiro_crew/agent_sdk/tools_settings_reach.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from typing import Any

from kiro_crew.platform.tools_settings_aliases import canonical_tools_settings
from kiro_crew.platform.tools_settings_aliases import as_authored, canonical_tools_settings

#: The ``toolsSettings`` tool key whose ``availableAgents`` Crew's spawn gate reads.
_SPAWN_GATE_TOOL = "subagent"
Expand Down Expand Up @@ -52,18 +52,22 @@ def _gate_applied_keys(tools_settings: dict[str, Any]) -> set[tuple[str, str]]:


def _unapplied_beside_gate(
tools_settings: dict[str, Any], applied: set[tuple[str, str]]
tools_settings: dict[str, Any], applied: set[tuple[str, str]], raw: dict[str, Any]
) -> list[str]:
"""Each set ``toolsSettings`` entry but the *applied* allowlist keys."""
"""Each set ``toolsSettings`` entry but the *applied* allowlist keys.

*tools_settings* is the folded form of the spec's *raw* field; each name uses
the spelling *raw* wrote.
"""
lost: list[str] = []
for tool, entry in tools_settings.items():
if not entry:
continue
if not isinstance(entry, dict):
lost.append(f"toolsSettings.{tool}")
lost.append(f"toolsSettings.{as_authored(raw, tool)}")
continue
lost.extend(
f"toolsSettings.{tool}.{key}"
f"toolsSettings.{as_authored(raw, tool)}.{key}"
for key, value in entry.items()
if value
and not (tool == _SPAWN_GATE_TOOL and key == _SPAWN_GATE_KEY)
Expand All @@ -89,28 +93,31 @@ def tools_settings_unapplied(tools_settings: Any, *, gate_allowlists: bool = Fal

Read with one key per kiro-cli alias group, as the gates read it
(:func:`~kiro_crew.platform.tools_settings_aliases.canonical_tools_settings`);
each dropped spelling is named as ``toolsSettings.<key>``.
each dropped spelling is named as ``toolsSettings.<key>``, and a kept one
under the spelling the spec wrote (``toolsSettings.use_subagent.<key>``, not
the ``subagent`` it is read as).
"""
if not tools_settings:
return []
if not isinstance(tools_settings, dict):
return ["toolsSettings"]
tools_settings, dropped = canonical_tools_settings(tools_settings)
raw = tools_settings
tools_settings, dropped = canonical_tools_settings(raw)
applied = _gate_applied_keys(tools_settings) if gate_allowlists else set()
if applied:
lost = _unapplied_beside_gate(tools_settings, applied)
lost = _unapplied_beside_gate(tools_settings, applied, raw)
return sorted({*lost, *(f"toolsSettings.{key}" for key in dropped)})
gated = tools_settings.get(_SPAWN_GATE_TOOL)
if not isinstance(gated, dict) or _SPAWN_GATE_KEY not in gated:
return ["toolsSettings"]
lost = [f"toolsSettings.{key}" for key in dropped]
lost += [
f"toolsSettings.{tool}"
f"toolsSettings.{as_authored(raw, tool)}"
for tool, entry in tools_settings.items()
if entry and tool != _SPAWN_GATE_TOOL
]
lost.extend(
f"toolsSettings.{_SPAWN_GATE_TOOL}.{key}"
f"toolsSettings.{as_authored(raw, _SPAWN_GATE_TOOL)}.{key}"
for key, value in gated.items()
if value and key != _SPAWN_GATE_KEY
)
Expand Down
Loading
Loading