You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(kernel-agents): author built-in capabilities as pattern-guarded exos (#959)
## Explanation
Rewrites the `math`, `end`, and `examples` capabilities as discoverable
exos
built with the `described*()` combinators (added in #958, now on
`main`), so
each capability's argument shape is enforced by the exo's interface
guard at
invocation rather than only advertised in the prompt. A mistyped
argument now
fails with a guard rejection at the membrane instead of surfacing deep
inside
the capability.
Each module derives its `{ func, schema }` capability specs via a new
synchronous `makeInternalCapabilities` constructor, which builds the
pattern-guarded exo (kept private as the in-realm enforcement membrane)
and
projects a capability record from the just-authored schemas — without
round-tripping through `GET_DESCRIPTION`. All existing consumers
(example
transcripts, the REPL evaluator, `prepare-attempt`) keep the same spec
shape and
`makeEnd` stays synchronous. `end`'s closed-over result object is
intentionally
left un-hardened so the exo method can mutate it.
`makeInternalCapabilities` asserts at construction that the
implementation and
schema method sets match exactly. A missing implementation already
throws inside
`makeDiscoverableExo`, but an extra implementation absent from the
schema would
otherwise be silently accepted by the guard's `defaultGuards:
'passable'` and
never be reachable as a capability — so an authoring typo (e.g. `serch`
vs
`search`) now fails loudly at construction instead of surfacing as a
capability
that resolves to `undefined`. A colocated `discover.test.ts` covers the
positional-arg mapping, guard rejection at the membrane, and this
construction
check.
Installs the endoify mock as a package-wide vitest setup, since
capability
modules now build exos at import and need a `harden` global before they
load.
### Notable behavior changes
- `getMoonPhase` loses its (already unsupported, `@ts-expect-error`'d)
`enum` return hint.
- `end`'s off-spec per-argument `required` flags are gone; `final` is
required and `attachments` optional, expressed by the guard.
## Test plan
- [x] `yarn workspace @ocap/kernel-agents test` (58 pass) and
`test:dev:quiet`
- [x] `yarn workspace @ocap/kernel-agents-repl test` (178 pass)
- [x] `build` + `lint` for both packages; changelog validates
- [ ] Local-only `kernel-test-local` agent e2e: see #961 (out of scope
here)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches core agent capability invocation and changes runtime
validation behavior (guard rejections vs deep errors), though external
capability shapes and `makeEnd` sync API stay the same.
>
> **Overview**
> Built-in **`math`**, **`end`**, and **`examples`** capabilities are no
longer hand-authored with `capability()`; they are built via new
**`makeInternalCapabilities`**, which wraps implementations in a private
pattern-guarded discoverable exo and projects the same `{ func, schema
}` shape agents already use. Invalid or missing arguments are rejected
at the exo interface guard before implementation code runs.
>
> **`discover`** is refactored to share **`capabilitiesFrom`** with the
local path so remote and in-realm invocation both map named-arg objects
to positional exo calls the same way. **`makeInternalCapabilities`**
also fails at construction if schema and implementation method names do
not match exactly.
>
> Tests cover mapping, membrane rejection, and the construction check;
package **vitest** loads the endoify mock globally because capability
modules build exos at import. **`getMoonPhase`** no longer advertises an
unsupported `enum` return hint; **`end`** optional/required args are
expressed only via the guard schema.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
06d6853. 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>
Copy file name to clipboardExpand all lines: packages/kernel-agents/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,4 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
### Changed
11
+
12
+
- The built-in capabilities (`math`, `end`, `examples`) are now pattern-guarded discoverable exos authored with the `described*()` combinators, so their argument shapes are enforced by the exo's interface guard at invocation rather than only described in the prompt ([#959](https://github.com/MetaMask/ocap-kernel/pull/959))
0 commit comments