Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(access): keep the CLI-only refusal for owner-only ops ahead of the unbound-read refusal

garrytana0c0d55c81ee
diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.ts
index 670a68e6fc..a6e9851f5f 100644
--- a/src/mcp/dispatch.ts
+++ b/src/mcp/dispatch.ts
@@ -1036,8 +1036,8 @@ export async function dispatchToolCall(
if (attested?.actor) scoped = await attestedReadScope(engine, resolved, attested.actor.member, readMode === 'scope');
if (opts.enforcedMember) access = { ...access, hidePrivate: true, owner: false, privateReadableSources: [] };
// GST-363: on a brain that serves several people, a read from a connection bound to nobody is refused (or, in its grace, noticed) before any work.
- // An op this connection cannot reach (hidden by its surface, or localOnly off stdio) keeps the unknown-tool envelope instead.
- const reachable = !!op && (!opts.allowedOps || opts.allowedOps.has(name)) && (!op.localOnly || opts.transport === 'stdio');
+ // An op this connection cannot reach (hidden by its surface, localOnly off stdio, or cliOnly over MCP) keeps its own refusal instead.
+ const reachable = !!op && (!opts.allowedOps || opts.allowedOps.has(name)) && (!op.localOnly || opts.transport === 'stdio') && !(op.cliOnly && opts.remote !== false);
if (!attested?.actor && reachable && requiresRequesterScope(op, opts.auth)) {
const credential = opts.auth ? await credentialScopeFor(engine, opts.auth) : undefined;
access = await withServesReread(engine, access, credential);
diff --git a/test/requester-scope.test.ts b/test/requester-scope.test.ts
index 4a155c6cea..216ecc8d51 100644
--- a/test/requester-scope.test.ts
+++ b/test/requester-scope.test.ts
@@ -326,7 +326,9 @@ for (const kind of testBackends()) {
try {
for (const op of operations.filter(o => (o.mutating === false || o.scope === 'read') && !o.localOnly)) {
const out = shape(await dispatchToolCall(engine, op.name, {}, { remote: true, transport: 'http', auth, sourceId: 'default', takesHoldersAllowList: ['world'] }));
- if (requiresRequesterScope(op, auth)) {
+ if (op.cliOnly) {
+ expect({ op: op.name, code: out.json.code }).toEqual({ op: op.name, code: 'trusted_local_only' });
+ } else if (requiresRequesterScope(op, auth)) {
expect({ op: op.name, code: out.structured?.error?.code }).toEqual({ op: op.name, code: 'requester_scope_required' });
} else answered.push(op.name);
}