Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

docs: narrow an extension tool's result with toolResultFrom (#657)

Casey Gowrie0b0540ac42e8
diff --git a/docs/extensions.md b/docs/extensions.md
index 950149d0f..a07bdd74f 100644
--- a/docs/extensions.md
+++ b/docs/extensions.md
@@ -150,6 +150,27 @@ An override targets one slot, matched by name and kind: a static file replaces t
Overrides only work here — the `<namespace>__` prefix is reserved, so an agent-root contribution named `crm__…` is a build error and an extension can't be shadowed from outside its mount.
+### Typed tool results
+
+A consuming agent can narrow a mounted extension's tool result in a hook: import the tool from the extension's `./tools` export and pass it to [`toolResultFrom`](/guides/hooks#narrowing-tool-results). It matches the namespaced result (`crm__search`) because identity keys off the tool definition, not its name.
+
+```ts title="agent/hooks/narrow-crm.ts"
+import { defineHook } from "eve/hooks";
+import { toolResultFrom } from "eve/tools";
+import { search } from "@acme/crm/tools";
+
+export default defineHook({
+ events: {
+ "action.result"(event) {
+ const match = toolResultFrom(event.data.result, search);
+ if (match) console.log(match.output); // typed as search's output
+ },
+ },
+});
+```
+
+Matching keys off the tool's description, so keep extension tool descriptions distinct — one shared with another tool makes the identity ambiguous and `toolResultFrom` stops matching.
+
## Limits
An extension cannot declare a `sandbox`, agent config, schedules, or limits, and cannot mount other extensions — those are the consuming agent's to own (background scheduling, for instance, runs on the agent's deployment under its limits). An extension's tools run within the consuming agent's per-session limits.
diff --git a/docs/guides/hooks.md b/docs/guides/hooks.md
index 0a4732b6d..6a8132b91 100644
--- a/docs/guides/hooks.md
+++ b/docs/guides/hooks.md
@@ -71,6 +71,15 @@ export default defineHook({
Returns `undefined` when the result doesn't match, or when `isError` is `true`. For authored tools the return includes `{ output, toolName, callId }` with `output` typed as the tool's `TOutput`. For connections it includes `{ output, toolName, connectionToolName, callId }` with `output` as `unknown`.
+This works for a mounted extension's tools too — import the tool from the extension's `./tools` export and pass it. `toolResultFrom` matches the namespaced result (`crm__search`) because it keys off the tool definition, not the name:
+
+```ts
+import { search } from "@acme/crm/tools";
+
+// inside "action.result":
+const crmSearch = toolResultFrom(event.data.result, search); // typed; matches crm__search
+```
+
## Execution order
When a stream event fires, three things happen in order: