import type { OpenClawConfig } from "../config/types.openclaw.js"; import { callGateway as defaultCallGateway } from "../gateway/call.js"; import { resolveAgentIdFromSessionKey } from "../routing/session-key.js"; import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "../shared/string-coerce.js";
type GatewayCaller = typeof defaultCallGateway;
let callGatewayForListSpawned: GatewayCaller = defaultCallGateway;
/** Test hook: must stay aligned with `sessions-resolution` `__testing.setDepsForTest`. */
export const sessionVisibilityGatewayTesting = {
setCallGatewayForListSpawned(overrides?: GatewayCaller) {
callGatewayForListSpawned = overrides ?? defaultCallGateway;
},
};
function actionPrefix(action: SessionAccessAction): string { if (action === "history") { return"Session history";
} if (action === "send") { return"Session send";
} if (action === "status") { return"Session status";
} return"Session list";
}
function a2aDisabledMessage(action: SessionAccessAction): string { if (action === "history") { return"Agent-to-agent history is disabled. Set tools.agentToAgent.enabled=true to allow cross-agent access.";
} if (action === "send") { return"Agent-to-agent messaging is disabled. Set tools.agentToAgent.enabled=true to allow cross-agent sends.";
} if (action === "status") { return"Agent-to-agent status is disabled. Set tools.agentToAgent.enabled=true to allow cross-agent access.";
} return"Agent-to-agent listing is disabled. Set tools.agentToAgent.enabled=true to allow cross-agent visibility.";
}
function a2aDeniedMessage(action: SessionAccessAction): string { if (action === "history") { return"Agent-to-agent history denied by tools.agentToAgent.allow.";
} if (action === "send") { return"Agent-to-agent messaging denied by tools.agentToAgent.allow.";
} if (action === "status") { return"Agent-to-agent status denied by tools.agentToAgent.allow.";
} return"Agent-to-agent listing denied by tools.agentToAgent.allow.";
}
function crossVisibilityMessage(action: SessionAccessAction): string { if (action === "history") { return"Session history visibility is restricted. Set tools.sessions.visibility=all to allow cross-agent access.";
} if (action === "send") { return"Session send visibility is restricted. Set tools.sessions.visibility=all to allow cross-agent access.";
} if (action === "status") { return"Session status visibility is restricted. Set tools.sessions.visibility=all to allow cross-agent access.";
} return"Session list visibility is restricted. Set tools.sessions.visibility=all to allow cross-agent access.";
}
function selfVisibilityMessage(action: SessionAccessAction): string { return `${actionPrefix(action)} visibility is restricted to the current session (tools.sessions.visibility=self).`;
}
function treeVisibilityMessage(action: SessionAccessAction): string { return `${actionPrefix(action)} visibility is restricted to the current session tree (tools.sessions.visibility=tree).`;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.