π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import type { BuiltinRestrictedManifestResolver } from '@lobechat/types';
import { SkillsManifest } from './manifest';
import { sharedSkillGuidelines } from './systemRole';
import { AGENT_SHARE_SKILL_API_NAMES } from './types';
/**
* Replacement `systemRole` for the share-visitor surface.
*
* The full {@link SkillsManifest.systemRole} documents all five APIs including
* a whole `runCommand` vs `execScript` decision tree. Kept as-is after the
* strip it would teach a visitor's model to announce β and keep retrying β
* capabilities that are not callable, so the role is rewritten rather than
* dropped: dropping it entirely would also lose the one instruction that
* actually matters here, that a skill already inlined into the message must not
* be activated again.
*/
export const agentShareSystemPrompt = `You have access to a Skills tool that loads skills β reusable instruction packages that extend your capabilities.
<guidelines>
${sharedSkillGuidelines}
- This tool cannot run commands or scripts in this conversation. If a skill's instructions call for executing a script, do as much as you can from the written instructions and tell the user which step needs execution instead of pretending it ran.
</guidelines>
`;
/**
* Owns the Agent Share projection of the Skills tool.
*
* Like the Documents projection, the semantic rewrite lives in the tool's own
* package so Share orchestration never has to know which of this tool's APIs
* the systemRole talks about. `shareToolManifest.ts` re-checks that the
* returned manifest's API set matches the policy-approved one exactly, so this
* resolver can never widen the surface the gate decided on.
*/
export const resolveSkillsRestrictedManifest: BuiltinRestrictedManifestResolver = ({
allowedApiNames,
restriction,
}) => {
if (restriction !== 'agentShare') return undefined;
// Only claim the surface this projection was written for. A different subset
// (e.g. `readReference` alone, or anything exec-class) returns `undefined`,
// and the caller falls back to the plain strip with no systemRole β the
// fail-closed outcome, never a role describing APIs that are not offered.
const allowed = new Set(allowedApiNames);
const isSupportedApiSet =
allowed.size === AGENT_SHARE_SKILL_API_NAMES.size &&
[...allowed].every((apiName) => AGENT_SHARE_SKILL_API_NAMES.has(apiName));
if (!isSupportedApiSet) return undefined;
return {
...SkillsManifest,
api: SkillsManifest.api.filter((api) => allowed.has(api.name)),
systemRole: agentShareSystemPrompt,
};
};