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

Function dynamicToolScopeForPattern

packages/core/sdk/src/policies.ts:147–164  ·  view source on GitHub ↗
(pattern: string)

Source from the content-addressed store, hash-verified

145 * every deeper segment; a mid-pattern `*` covers exactly that segment.
146 */
147export const dynamicToolScopeForPattern = (pattern: string): DynamicToolScope | null => {
148 if (pattern === "*") return { integration: null, owner: null, connection: null };
149 const segments = pattern.split(".");
150 const subtree = segments.at(-1) === "*";
151 if (!subtree && segments.length < 4) return null;
152 const at = (index: number): string | null => {
153 const segment = segments[index];
154 if (segment === undefined) return null;
155 // Only the trailing `*` reaches past its own position; a mid `*` is one
156 // segment, which is also "any value" for that position.
157 return segment === "*" ? null : segment;
158 };
159 const owner = at(1);
160 // A dynamic tool id's owner segment is always `org` or `user`; any other
161 // literal there names a static namespace (`executor.coreTools.*`).
162 if (owner !== null && owner !== "org" && owner !== "user") return null;
163 return { integration: at(0), owner, connection: at(2) };
164};
165
166// ---------------------------------------------------------------------------
167// Resolution — each owner contributes its first matching rule by local

Callers 2

policies.test.tsFile · 0.90
toolkitDynamicScopeFunction · 0.90

Calls 1

atFunction · 0.70

Tested by

no test coverage detected