Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(mcp): owner-only ops are not listed on stdio; refusals name the CLI command (F5)
garrytan7687acf78e61
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.mdindex 0a4d44bca6..d1bb4dc4c6 100644--- a/docs/guides/error-codes.md+++ b/docs/guides/error-codes.md@@ -18,6 +18,7 @@ different value, it keeps sending it in `error` and adds the canonical value in| `permission_denied` | `insufficient_scope` | The connection lacks the OAuth scope the operation requires. || `invalid_params` | `not_found` | The requested resource does not exist or is not visible to this caller. || `page_identity_changed` | `page_not_found` | No page with that slug exists in the selected source. |+| `permission_denied` | `trusted_local_only` | The operation runs only from the trusted local CLI on the brain host; no MCP connection can call it. || `unknown_operation` | `unknown_tool` | The named tool does not exist or is not callable on this connection. |## Codes@@ -1662,6 +1663,14 @@ More: [docs/guides/write-refusals.md#sync_in_progress](../../docs/guides/write-r|---|---|---|---|---|---|---|| Adding this source would replace or overlap another owner root. | Only the operator of the brain host can change what blocks this. | Only the brain host's operator can resolve this. Tell the user the message and run `gbrain doctor --json` on the brain host. | host_admin | `gbrain doctor --json` | 1 | no |+### trusted_local_only++<a id="trusted_local_only"></a>++| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |+|---|---|---|---|---|---|---|+| The operation runs only from the trusted local CLI on the brain host; no MCP connection can call it. | Only the operator of the brain host can change what blocks this. | Ask the user to run the named gbrain command on the brain host. | host_admin | `gbrain doctor --json` | 1 | no |+### unavailable<a id="unavailable"></a>diff --git a/src/core/error-registry.ts b/src/core/error-registry.tsindex 1a39858b2d..61d6053916 100644--- a/src/core/error-registry.ts+++ b/src/core/error-registry.ts@@ -234,6 +234,7 @@ export const CODES = {target_escape: { class: 'caller', summary: "The skill target must remain within its selected root." },timeout: { class: 'retryable', summary: "The operation did not finish within its time bound.", exit: 124 },topology_change_required: { class: 'host_only', summary: "Adding this source would replace or overlap another owner root." },+ trusted_local_only: { class: 'host_only', summary: 'The operation runs only from the trusted local CLI on the brain host; no MCP connection can call it.', legacy_error: 'permission_denied', suggestion: 'Ask the user to run the named gbrain command on the brain host.' },unavailable: { class: 'unavailable', summary: "A required dependency or capability cannot serve this request." },unexpected_file_bytes: { class: 'server', summary: "A canonical skill file mode changed outside publication." },unexpected_staging_bytes: { class: 'server', summary: "Recovery staging has unexpected bytes or identity; the root and its recovery capacity remain reserved." },diff --git a/src/core/operations-descriptions.ts b/src/core/operations-descriptions.tsindex 471c9c9832..b80eb570c9 100644--- a/src/core/operations-descriptions.ts+++ b/src/core/operations-descriptions.ts@@ -82,8 +82,8 @@ export const QUERY_DESCRIPTION ="'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens " +"`search` is cheaper (no expansion LLM call). " +"For personal/emotional questions ('what's going on with me', 'anything notable', " +- "'how am I feeling'), prefer get_recent_salience, find_anomalies, or " +- "get_recent_transcripts. Semantic search returns polished pages and misses " ++ "'how am I feeling'), prefer get_recent_salience or find_anomalies (raw " ++ "transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses " +"recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' " +"mean impressive — they often mean difficult or emotionally charged.";diff --git a/src/core/ops/callable.ts b/src/core/ops/callable.tsindex 50129a4039..3cfeb41d4a 100644--- a/src/core/ops/callable.ts+++ b/src/core/ops/callable.ts@@ -5,7 +5,7 @@* (`RenderContext.isCallable`). Pure: the caller resolves its own scopes,* publish gates and bound-tool allow-set first.*/-import type { Operation } from './contract.ts';+import { opError, type Operation, type OperationError } from './contract.ts';import type { Surface, Transport } from '../agent-output.ts';import { operationScopesAllowed } from '../scope.ts';import { filterOpsForSurface } from '../../mcp/surface.ts';@@ -26,6 +26,7 @@ export function isCallable(op: Operation, ctx: CallableContext): boolean {if (ctx.allowedOps && !ctx.allowedOps.has(op.name)) return false;if (filterOpsForSurface([op], ctx.surface).length === 0) return false;if (ctx.transport === 'cli') return true;+ if (op.cliOnly) return false;if (op.localOnly && ctx.transport !== 'stdio') return false;if (op.publishGateKey && ctx.publishGates[op.publishGateKey] !== true) return false;if (ctx.transport === 'http') return operationScopesAllowed(ctx.scopes, op);@@ -44,3 +45,18 @@ export function publishGatesFromDisabled(ops: readonly Operation[], disabled: Re}return gates;}++/**+ * F5: the refusal for a `cliOnly` op called over MCP (it is never listed+ * there): the exact CLI command as the fix, relayed to the user. `error`+ * keeps the historical `permission_denied`.+ */+export function cliOnlyRefusal(op: Operation): OperationError {+ const argv = [...(op.cliOnly?.argv ?? ['gbrain', '--help'])];+ const inputs = argv.filter(a => /^<[a-z_]+>$/.test(a)).map(a => ({ name: a.slice(1, -1), how: `The ${a.slice(1, -1)} value from your ${op.name} call.` }));+ return opError('trusted_local_only', `${op.name} runs only from the trusted local CLI on the brain host, not over MCP.`,+ `Ask the user to run \`${argv.join(' ')}\` on the brain host.`, {+ legacy_error: 'permission_denied',+ fix: { argv, consent: [], actor: 'user', requires_exclusive: false, why: `${op.name} is owner-only (filesystem, credentials or review authority), so no MCP connection can call it.`, ...(inputs.length ? { inputs } : {}) },+ });+}diff --git a/src/core/ops/connectors.ts b/src/core/ops/connectors.tsindex 5506396971..78b127d201 100644--- a/src/core/ops/connectors.ts+++ b/src/core/ops/connectors.ts@@ -37,7 +37,7 @@ const connectors_status: Operation = {'last_sync_at, auth_error_at, auto_sync, and the incremental watermark. ' +'Local-only; credentials never cross the wire.',scope: 'read',- localOnly: true,+ localOnly: true, cliOnly: { argv: ['gbrain', 'connectors', 'status'] },params: {provider: {type: 'string',@@ -83,7 +83,7 @@ const connector_sync: Operation = {'Local-only (uses on-disk credentials).',scope: 'write',mutating: true,- localOnly: true,+ localOnly: true, cliOnly: { argv: ['gbrain', 'connectors', 'sync', '<provider>'] },params: {provider: { type: 'string', required: true, description: "'chatgpt' or 'claude'." },full: { type: 'boolean', description: 'Ignore the watermark and re-scan everything.' },diff --git a/src/core/ops/contract.ts b/src/core/ops/contract.tsindex 4a4e64e81c..dd404016c6 100644--- a/src/core/ops/contract.ts+++ b/src/core/ops/contract.ts@@ -655,6 +655,13 @@ export interface Operation {scope?: 'read' | 'write' | 'admin' | 'sources_admin' | 'users_admin' | 'agent';requiredScopes?: readonly string[];localOnly?: boolean;+ /**+ * Agent contract v1 (F5): the handler refuses every agent-facing caller,+ * stdio included; only the trusted local CLI runs it. `isCallable` never+ * lists it on MCP, and a call returns `cli_only` whose fix is this exact+ * command (`<name>` tokens are inputs the agent fills from its call).+ */+ cliOnly?: { argv: readonly string[] };/*** WP1 honest catalog: the op is callable by remote callers only when this* config gate resolves true (dual-plane, DB > file > absent=false). Networkdiff --git a/src/core/ops/embedding-migration.ts b/src/core/ops/embedding-migration.tsindex ce8fe38a0f..c0693ed37c 100644--- a/src/core/ops/embedding-migration.ts+++ b/src/core/ops/embedding-migration.ts@@ -30,7 +30,7 @@ const migrate_embeddings: Operation = {},mutating: true,scope: 'admin',- localOnly: true,+ localOnly: true, cliOnly: { argv: ['gbrain', 'migrate', 'embeddings', '--to', '<model>'] },handler: async (ctx, p) => {// Belt-and-braces on top of localOnly (the get_recent_transcripts// pattern): a schema-rebuilding, money-spending op must never bediff --git a/src/core/ops/extraction.ts b/src/core/ops/extraction.tsindex d0b14cc401..0c149b6004 100644--- a/src/core/ops/extraction.ts+++ b/src/core/ops/extraction.ts@@ -160,7 +160,7 @@ const extraction_review: Operation = {},mutating: true,scope: 'write',- localOnly: true,+ localOnly: true, cliOnly: { argv: ['gbrain', 'extraction-review', '<action>', '--slugs', '<slugs>'] },handler: async (ctx, p) => {// The review decision IS the trust gate — if a remote caller could// promote, injected content could self-promote and the quarantine lanediff --git a/src/core/ops/skills-catalog.ts b/src/core/ops/skills-catalog.tsindex 7d7efbbd5d..d2bedaae8e 100644--- a/src/core/ops/skills-catalog.ts+++ b/src/core/ops/skills-catalog.ts@@ -162,7 +162,7 @@ const import_skill_proposal: Operation = {name: 'import_skill_proposal', description: 'Publish explicitly reviewed human-edited canonical skill files through the durable coordinator. Requires exact current file hashes and skill revision; trusted local operator only.',idempotent: true,outputRedaction: 'no_stored_text',- scope: 'admin', localOnly: true, mutating: true,+ scope: 'admin', localOnly: true, cliOnly: { argv: ['gbrain', 'call', 'import_skill_proposal', '<params_json>'] }, mutating: true,params: { ...put_skill.params, expected_hashes: { type: 'object', required: true, description: 'Reviewed current SHA-256 hashes for every affected file and skillpack.json; null denotes an absent file.' } },handler: async (ctx, p) => (await import('../shared-skills/publication.ts')).importSharedSkillProposal(ctx, p),};@@ -193,7 +193,7 @@ const get_skill_retention: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- scope: 'admin', localOnly: true,+ scope: 'admin', localOnly: true, cliOnly: { argv: ['gbrain', 'skill-retention'] },cliHints: { name: 'skill-retention', positional: [] },params: { source_id: { type: 'string', description: 'Canonical source to inspect.' } },handler: async (ctx, p) => (await import('../shared-skills/retention.ts')).getSharedSkillRetention(ctx, typeof p.source_id === 'string' ? p.source_id : ctx.sourceId),@@ -202,7 +202,7 @@ const prune_skill_revisions: Operation = {name: 'prune_skill_revisions', description: 'Prune one bounded batch of expired shared-skill history. Preserves heads, tombstones, pending publication refs, delivery leases, pins and permanent write receipts.',idempotent: false,outputRedaction: 'no_stored_text',- scope: 'admin', localOnly: true, mutating: true,+ scope: 'admin', localOnly: true, cliOnly: { argv: ['gbrain', 'prune-skill-revisions'] }, mutating: true,cliHints: { name: 'prune-skill-revisions', positional: [] },params: { source_id: { type: 'string', description: 'Canonical source to prune.' } },handler: async (ctx, p) => (await import('../shared-skills/retention.ts')).pruneSharedSkillRevisions(ctx, typeof p.source_id === 'string' ? p.source_id : ctx.sourceId),@@ -211,7 +211,7 @@ const retain_skill_revision: Operation = {name: 'retain_skill_revision', description: 'Pin an exact shared-skill revision for up to 24 hours under a bounded operator quota. Does not grant read or execution permission.',idempotent: false,outputRedaction: 'no_stored_text',- scope: 'admin', localOnly: true, mutating: true,+ scope: 'admin', localOnly: true, cliOnly: { argv: ['gbrain', 'retain-skill-revision'] }, mutating: true,cliHints: { name: 'retain-skill-revision', positional: [] },params: { ...sharedSkillKeyParams, source_incarnation: { type: 'string', required: true, description: 'Exact source incarnation.' },revision: { type: 'string', required: true, description: 'Exact existing immutable revision.' }, hours: { type: 'number', description: 'Pin lifetime greater than zero and at most 24 hours.' } },diff --git a/src/core/ops/sources.ts b/src/core/ops/sources.tsindex 0d20f5b17c..f2dc8d5720 100644--- a/src/core/ops/sources.ts+++ b/src/core/ops/sources.ts@@ -304,7 +304,7 @@ const sources_inspect: Operation = {exclude: { type: 'array', items: { type: 'string' }, description: 'Repository-relative exclude globs.' },},scope: 'read',- localOnly: true,+ localOnly: true, cliOnly: { argv: ['gbrain', 'sources', 'inspect', '<path>'] },mutating: false,handler: async (ctx, params) => {if (ctx.remote !== false) throw new OperationError('permission_denied', 'Repository inspection requires the trusted local CLI.');diff --git a/src/core/ops/transcripts.ts b/src/core/ops/transcripts.tsindex 99b23be656..df2c67d004 100644--- a/src/core/ops/transcripts.ts+++ b/src/core/ops/transcripts.ts@@ -20,7 +20,7 @@ const get_recent_transcripts: Operation = {// Local-only: rejects HTTP-borne MCP traffic at tool-list time// (serve-http.ts filters on `localOnly`) AND at runtime via the in-handler// ctx.remote check. Defense in depth: hidden + rejected.- localOnly: true,+ localOnly: true, cliOnly: { argv: ['gbrain', 'transcripts', 'recent'] },params: {days: { type: 'number', description: 'Window in days. Default 7.' },summary: {diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 9ff22b0558..2d02f4e696 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -14,7 +14,7 @@ import { loadConfig } from '../core/config.ts';import { resolveBrainId } from '../core/brain-resolver.ts';import { VERB_NAMES, MEMORY_VERBS_VERSION } from '../core/verbs.ts';import { cliRenderContext, toAgentError, toolErrorResult, toolResultWithNotices, type Notice, type RenderContext } from '../core/agent-output.ts';-import { isCallable } from '../core/ops/callable.ts';+import { cliOnlyRefusal, isCallable } from '../core/ops/callable.ts';import { mutedNoticeCodes, processNoticeLedger, __resetProcessNoticeLedgerForTests, type NoticeLedger } from '../core/notice-ledger.ts';import { logVerbUsage } from '../core/verbs/usage-log.ts';import { recallInteropNotices } from '../core/interop-notices.ts';@@ -636,6 +636,8 @@ export async function dispatchToolCall(if (op.localOnly && opts.transport !== 'stdio') {return unknownToolEnvelope(name, opts);}+ // F5: an owner-only op is never listed on MCP; a call gets the exact CLI command.+ if (op.cliOnly && opts.remote !== false) return errorResult(cliOnlyRefusal(op), opts, { op: name });// --source-guard (plugin lanes): fail-closed write routing. A user-global// plugin serve has no per-workspace source binding, so an ambient-tierdiff --git a/test/callable-predicate.test.ts b/test/callable-predicate.test.tsindex a565762d34..9ac961f631 100644--- a/test/callable-predicate.test.ts+++ b/test/callable-predicate.test.ts@@ -25,9 +25,9 @@ function legacyHttpList(surface: typeof SURFACES[number], scopes: string[], gate.map(op => op.name);}-/** The pre-A2 stdio list filter (surface, required-scope grant, gates). */+/** The pre-A2 stdio list filter (surface, required-scope grant, gates), minus F5's owner-only (`cliOnly`) ops. */function legacyStdioList(surface: typeof SURFACES[number], scopes: string[], gates: Record<string, boolean>): string[] {- return filterOpsForSurface(operations, surface)+ return filterOpsForSurface(operations.filter(op => !op.cliOnly), surface).filter(op => !op.requiredScopes?.length || operationScopesAllowed(scopes, op)).filter(op => !(op.publishGateKey && gates[op.publishGateKey] !== true)).map(op => op.name);@@ -63,7 +63,8 @@ describe('dispatch refuses what the list hides on the dispatch-enforced axes', (const unknown = async (op: Operation, transport: 'stdio' | 'http', allowed: ReadonlySet<string> | undefined) => {const r = await dispatchToolCall(engine, op.name, {}, { remote: true, transport, sourceId: 'default', ...(allowed ? { allowedOps: allowed } : {}) });if (!r.isError) return false;- return JSON.parse(r.content[0].text).code === 'unknown_tool';+ // F5: an owner-only op on stdio is refused with its CLI command instead.+ return ['unknown_tool', 'trusted_local_only'].includes(JSON.parse(r.content[0].text).code);};for (const surface of SURFACES) {diff --git a/test/fixtures/goldens/cli/help-and-errors.json b/test/fixtures/goldens/cli/help-and-errors.jsonindex 61f9371020..4febe12d9f 100644--- a/test/fixtures/goldens/cli/help-and-errors.json+++ b/test/fixtures/goldens/cli/help-and-errors.json@@ -671,7 +671,7 @@"stdout": ["Usage: gbrain query <query> [options]","",- "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience, find_anomalies, or get_recent_transcripts. Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.",+ "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience or find_anomalies (raw transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.","","Options:"," <query> Question or topic text for hybrid retrieval with expansion (e.g. 'agents that do web research'). This is the search text param — there is no `text` or `q` param. Optional ONLY because `image` is the alternative entry point; a call with neither fails with invalid_params.",diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.jsonindex c08fca9bdf..8eb9d7c5f2 100644--- a/test/fixtures/goldens/cli/tools-json.json+++ b/test/fixtures/goldens/cli/tools-json.json@@ -2,8 +2,8 @@"golden": {"exitCode": 0,"stderr": "",- "stdoutBytes": 229615,- "stdoutSha256": "aaf93740a028c3db9ce963308738d61d0d1b008b249b4cbf6430e1a6fd859630",+ "stdoutBytes": 229836,+ "stdoutSha256": "05879677743f457797f2e950a2dc1b28d33301479253bfcf8e663a4414155457","toolNames": ["remember","entity",@@ -996,7 +996,7 @@"scope": "read"},{- "description": "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience, find_anomalies, or get_recent_transcripts. Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.",+ "description": "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience or find_anomalies (raw transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.","idempotent": true,"local_only": false,"mutating": false,@@ -6224,7 +6224,12 @@"description": "Notice code, the word after `[gbrain notice` in the block.","enum": ["backup_coverage",+ "degraded_dedup","empty_retrieval",+ "listing_truncated",+ "source_binding_narrowed",+ "synthesis_keyless",+ "think_not_saved","unknown_param"],"type": "string"diff --git a/test/mcp-stdio-gate-list.test.ts b/test/mcp-stdio-gate-list.test.tsindex 96df044c52..1b3a108380 100644--- a/test/mcp-stdio-gate-list.test.ts+++ b/test/mcp-stdio-gate-list.test.ts@@ -7,7 +7,8 @@* gate-off publish-gated ops or it advertises tools that deny at call time* (the listed-but-denied class the honest-catalog wave exists to kill).* localOnly ops stay listed: locality is the transport axis (D7), consent is- * the gate axis. These tests pin stdioVisibleTools, the extracted per-request+ * the gate axis — except owner-only (`cliOnly`) ops, which refuse every MCP+ * caller and so are never listed (agent contract v1, F5). These tests pin stdioVisibleTools, the extracted per-request* list builder.*/import { describe, test, expect } from 'bun:test';@@ -16,7 +17,8 @@ import { operations } from '../src/core/operations.ts';import type { BrainEngine } from '../src/core/engine.ts';const GATED = operations.filter(op => op.publishGateKey).map(op => op.name);-const LOCAL_ONLY = operations.filter(op => op.localOnly).map(op => op.name);+const LOCAL_ONLY = operations.filter(op => op.localOnly && !op.cliOnly).map(op => op.name);+const CLI_ONLY = operations.filter(op => op.cliOnly).map(op => op.name);function engineWithGates(values: Record<string, string | null>): BrainEngine {return {@@ -38,6 +40,9 @@ describe('stdioVisibleTools (B1)', () => {for (const gated of GATED) expect(names).not.toContain(gated);// D7: stdio IS the local surface — localOnly ops remain listed.for (const local of LOCAL_ONLY) expect(names).toContain(local);+ // F5: owner-only ops always refuse on stdio, so they are not listed.+ expect(CLI_ONLY.length).toBeGreaterThan(0);+ for (const owner of CLI_ONLY) expect(names).not.toContain(owner);expect(names).toContain('get_page');});@@ -52,7 +57,7 @@ describe('stdioVisibleTools (B1)', () => {test('both gates on: full surfaced set returned unchanged', async () => {const engine = engineWithGates({ 'mcp.publish_skills': 'true', 'mcp.publish_advisor': 'true' });const visible = await stdioVisibleTools(engine, operations);- expect(visible.map(op => op.name)).toEqual(operations.filter(op => !op.requiredScopes?.length).map(op => op.name));+ expect(visible.map(op => op.name)).toEqual(operations.filter(op => !op.requiredScopes?.length && !op.cliOnly).map(op => op.name));for (const op of operations.filter(op => op.requiredScopes?.length)) expect(visible).not.toContain(op);});@@ -67,7 +72,7 @@ describe('stdioVisibleTools (B1)', () => {});test('surfaced set without gated ops passes through untouched (no gate read needed)', async () => {- const ungated = operations.filter(op => !op.publishGateKey && !op.requiredScopes?.length);+ const ungated = operations.filter(op => !op.publishGateKey && !op.requiredScopes?.length && !op.cliOnly);let reads = 0;const engine = {getConfig: async () => { reads += 1; return null; },diff --git a/test/operations-descriptions.test.ts b/test/operations-descriptions.test.tsindex 9fb2f16cc1..458f2ae48b 100644--- a/test/operations-descriptions.test.ts+++ b/test/operations-descriptions.test.ts@@ -96,7 +96,10 @@ describe('v0.29 — redirect hints on existing ops', () => {expect(operationsByName['query'].description).toBe(QUERY_DESCRIPTION);expect(QUERY_DESCRIPTION).toContain("get_recent_salience");expect(QUERY_DESCRIPTION).toContain("find_anomalies");- expect(QUERY_DESCRIPTION).toContain("get_recent_transcripts");+ // Agent contract v1 (F5): get_recent_transcripts is never MCP-callable, so+ // query names the owner's CLI read instead of routing agents to it.+ expect(QUERY_DESCRIPTION).not.toContain("get_recent_transcripts");+ expect(QUERY_DESCRIPTION).toContain("`gbrain transcripts recent`");});test('query warns the LLM not to assume "crazy" means impressive', () => {