Commit 7c3845b
refactor(kernel-agents): make the exo membrane the sole capability arg enforcer (#960)
## Explanation
The base PRs ([#958](#958),
[#959](#959)) made every
built-in capability a pattern-guarded discoverable exo. Now that the
exo's interface guard already enforces each capability's argument shape,
this PR retires the parallel membraneless authoring and validation paths
so the guard is the single argument enforcer:
- Removes the `capability()` authoring helper and the internal
`validateCapabilityArgs` validator (and its now-dead module). The chat
strategy no longer re-validates arguments before invoking — it relies on
the guard rejection it catches and reports as an `Error calling …` tool
message. That catch is hardened to handle a non-`Error` rejection, so an
invalid-argument tool call surfaces as a tool error instead of crashing
the task (covered by a new regression test).
- Collapses the redundant `CapabilitySchema` type into kernel-utils'
`MethodSchema` (a capability's `schema` is exactly the `MethodSchema`
its exo describes), removing the parallel type and its
`ExtractRecordKeys` helper.
- Adds a `test/make-method-capability.ts` helper that builds a guarded,
discovered single-method capability from an `S.method`, and migrates the
chat and JSON evaluator tests (and the capability test, repurposed to
cover the surviving `extract*` helpers) onto it.
- Drops the now-unused `@metamask/superstruct` dependency.
### Breaking changes
- The `capability()` authoring helper is no longer exported from
`@ocap/kernel-agents/capabilities/capability`. Author capabilities as
pattern-guarded discoverable exos (via the `described*()` combinators in
`@metamask/kernel-utils`) and convert them with `discover`.
(`validateCapabilityArgs` was internal and never exported.)
## Test plan
- [x] \`yarn workspace @ocap/kernel-agents test:dev:quiet\` (56 pass),
incl. a chat-strategy regression test that an invalid-argument tool call
comes back as an \`Error calling …\` tool message instead of crashing
the task
- [x] \`yarn workspace @ocap/kernel-agents-repl test:dev:quiet\` (178
pass)
- [x] \`build\` + \`lint\` for both packages; changelog validates
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Breaking public API (`capability()` removal) affects downstream
authors, but runtime behavior stays aligned with prior exo-backed
builtins; main risk is consumers still using the old helper or assuming
pre-invoke Superstruct errors.
>
> **Overview**
> **Breaking:** Removes the exported `capability()` helper and the
internal Superstruct-based `validateCapabilityArgs` path. Capabilities
are expected to be authored as pattern-guarded discoverable exos
(`described*()` + `discover` / `makeInternalCapabilities`);
`CapabilitySpec.schema` is now kernel-utils `MethodSchema` instead of a
parallel `CapabilitySchema` type.
>
> Invocation errors from the exo interface guard are normalized in
`capabilitiesFrom` to `Error calling <name>(<params>): …` so chat and
other callers can surface actionable tool messages without a second
validation layer. The chat agent parses tool JSON locally when needed,
invokes capabilities directly, and pushes guard/implementation failures
as tool errors (including a regression test for bad args) instead of
crashing the loop.
>
> Tests migrate to `test/make-method-capability.ts`;
`@metamask/superstruct` is dropped from dependencies.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6dc44a8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent c631ac4 commit 7c3845b
15 files changed
Lines changed: 236 additions & 179 deletions
File tree
- packages/kernel-agents
- src
- capabilities
- strategies
- json
- types
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | 199 | | |
201 | 200 | | |
202 | 201 | | |
| |||
Lines changed: 25 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | | - | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
14 | 27 | | |
| 28 | + | |
| 29 | + | |
15 | 30 | | |
16 | 31 | | |
17 | 32 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 1 | + | |
8 | 2 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 3 | + | |
20 | 4 | | |
21 | | - | |
| 5 | + | |
22 | 6 | | |
23 | 7 | | |
24 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
72 | 90 | | |
73 | 91 | | |
74 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
19 | 34 | | |
20 | 35 | | |
21 | 36 | | |
| |||
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
45 | 74 | | |
46 | 75 | | |
47 | 76 | | |
| |||
Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 79 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
89 | | - | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| |||
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
154 | 205 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
159 | 212 | | |
160 | 213 | | |
161 | 214 | | |
| |||
177 | 230 | | |
178 | 231 | | |
179 | 232 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
185 | 239 | | |
186 | 240 | | |
187 | 241 | | |
| |||
0 commit comments