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

Function policiesResolve

packages/core/sdk/src/executor.ts:3906–3933  ·  view source on GitHub ↗
(
      address: ToolAddress,
    )

Source from the content-addressed store, hash-verified

3904 });
3905
3906 const policiesResolve = (
3907 address: ToolAddress,
3908 ): Effect.Effect<EffectivePolicy, StorageFailure> =>
3909 Effect.gen(function* () {
3910 const parsed = parseToolAddress(String(address));
3911 const policyRows = yield* core.findMany("tool_policy", {});
3912 const toolId = parsed
3913 ? `${parsed.integration}.${parsed.owner}.${parsed.connection}.${parsed.tool}`
3914 : String(address);
3915 // Find the tool to read its default approval annotation.
3916 let requiresApproval: boolean | undefined;
3917 if (parsed) {
3918 const row = yield* core.findFirst("tool", {
3919 where: (b: AnyCb) =>
3920 b.and(
3921 byOwner(parsed.owner)(b),
3922 b("integration", "=", String(parsed.integration)),
3923 b("connection", "=", String(parsed.connection)),
3924 b("name", "=", String(parsed.tool)),
3925 ),
3926 });
3927 if (row) {
3928 const annotations = decodeJsonColumn(row.annotations) as ToolAnnotations | undefined;
3929 requiresApproval = annotations?.requiresApproval;
3930 }
3931 }
3932 return resolveEffectivePolicy(toolId, policyRows, ownerRankForRow, requiresApproval);
3933 });
3934
3935 // ------------------------------------------------------------------
3936 // Artifacts — saved generative-UI components, owner-scoped.

Callers

nothing calls this directly

Calls 4

resolveEffectivePolicyFunction · 0.90
parseToolAddressFunction · 0.85
byOwnerFunction · 0.85
decodeJsonColumnFunction · 0.85

Tested by

no test coverage detected