MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / resolveToolkitPolicy

Function resolveToolkitPolicy

packages/plugins/toolkits/src/page.tsx:139–154  ·  view source on GitHub ↗
(
  matchId: string,
  policies: readonly ToolkitPolicyResponse[],
  requiresApproval?: boolean,
)

Source from the content-addressed store, hash-verified

137};
138
139const resolveToolkitPolicy = (
140 matchId: string,
141 policies: readonly ToolkitPolicyResponse[],
142 requiresApproval?: boolean,
143): EffectivePolicy => {
144 for (const policy of [...policies].sort(comparePolicy)) {
145 if (!matchPattern(policy.pattern, matchId)) continue;
146 return {
147 action: policy.action,
148 source: "user",
149 pattern: policy.pattern,
150 policyId: policy.id,
151 };
152 }
153 return pluginDefaultPolicy(requiresApproval);
154};
155
156const toolMatchId = (tool: ToolRow): string =>
157 tool.static ? String(tool.address) : String(tool.address).replace(/^tools\./, "");

Callers 1

ToolkitWorkspaceFunction · 0.70

Calls 2

pluginDefaultPolicyFunction · 0.70
matchPatternFunction · 0.50

Tested by

no test coverage detected