openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5 lines • 1.81 kB
JavaScript
import{a as readPublishedXAllowlist,r as normalizeXUserId}from"./allowlist-C2fjJq54.mjs";import{t as getXRuntime}from"./runtime-BQ8PpbJh.mjs";
//!extensions/x/src/guest-tools.ts
const X_GUEST_TOOLS=[`read`,`ls`,`sessions_spawn`,`sessions_yield`,`subagents`];
//!extensions/x/src/guest-policy.ts
function resolveXGuestSettings(e){return{enabled:e.config.guests?.enabled===true,maxMentionsPerAuthorPerDay:e.config.guests?.maxMentionsPerAuthorPerDay??5,threadContextMaxPosts:e.config.guests?.threadContextMaxPosts??10}}function resolveXSenderTier(e,t){const n=t&&normalizeXUserId(t);const r=[...e.config.allowFrom??[],...readPublishedXAllowlist(getXRuntime(),e.accountId,e.config.verifiedFromGitHub)];return n&&r.some(e=>normalizeXUserId(e)===n)?`maintainer`:`guest`}function resolveXGuestToolPolicy(e){const t=e.config.guests?.tools;const n=X_GUEST_TOOLS.filter(e=>!t?.allow||t.allow.includes(e));return n.length?{allow:n,deny:[`skills_read`,...t?.deny??[]]}:{deny:[`*`]}}function formatXSenderLine(e,t,n,r){const inline=e=>e.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu,` `).trim();const i=[n?.username?`@${inline(n.username)}`:``,n?.name?`(${inline(n.name)})`:``].filter(Boolean).join(` `);const a=`${i?`${i}, `:``}X user id ${t}`;if(e===`maintainer`){if(r)return`This is from a verified user: ${a}, GitHub @${inline(r.entry.githubLogin)} with write access to ${inline(r.repo)}.`;return`This is from a verified user: ${a}, on the maintainer allowlist.`}return`This is from a guest: ${a}. Guest tier: answer from the OpenClaw repo only; hidden helpers must use the same agent and repository. You cannot open visible work sessions, write, run commands, or read unrelated sessions for guests.`}export{X_GUEST_TOOLS as a,resolveXSenderTier as i,resolveXGuestSettings as n,resolveXGuestToolPolicy as r,formatXSenderLine as t};